unify messages, small readme update
authornotaz <notasas@gmail.com>
Sun, 14 Nov 2010 23:46:01 +0000 (01:46 +0200)
committernotaz <notasas@gmail.com>
Sun, 14 Nov 2010 23:46:01 +0000 (01:46 +0200)
README.OMAP
src/video/omapdss/omapsdl.h
src/video/omapdss/osdl_input.c
src/video/omapdss/osdl_video.c

index d99cbc4..4c6be5d 100644 (file)
@@ -59,3 +59,9 @@ force_vsync = 1/0
 # bind ev_home = sdlk_space
 bind ev_<evdev_key> = <sdl_key>
 
+
+Source
+------
+
+Available at git://notaz.gp2x.de/~notaz/sdl_omap.git
+
index b59533e..b34caa3 100644 (file)
@@ -7,8 +7,16 @@
 
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
 
-#define err(fmt, ...) fprintf(stderr, "omapsdl: " fmt "\n", ##__VA_ARGS__)
-#define not_supported() fprintf(stderr, "omapsdl: %s not supported\n", __FUNCTION__)
+#define err(fmt, ...) \
+       fprintf(stderr, "omapsdl: " fmt "\n", ##__VA_ARGS__)
+#define err_perror(fmt, ...) do { \
+       fprintf(stderr, "omapsdl: " fmt ": ", ##__VA_ARGS__); \
+       perror(NULL); \
+} while (0)
+#define log(fmt, ...) \
+       fprintf(stdout, "omapsdl: " fmt "\n", ##__VA_ARGS__)
+#define not_supported() \
+       fprintf(stderr, "omapsdl: %s not supported\n", __FUNCTION__)
 #if 0
 #define trace(fmt, ...) printf(" %s(" fmt ")\n", __FUNCTION__, ##__VA_ARGS__)
 #define dbg err
index fff2ca2..8192209 100644 (file)
@@ -501,10 +501,10 @@ void omapsdl_input_init(void)
                osdl_tslib_fd = ts_fd(osdl_tslib_dev);
                osdl_evdev_devs[osdl_evdev_dev_count++] = osdl_tslib_fd;
                if (fstat(osdl_tslib_fd, &stat_buf) == -1)
-                       perror("fstat ts");
+                       err_perror("fstat ts");
                else
                        touchscreen_ino = stat_buf.st_ino;
-               printf("opened tslib touchscreen\n");
+               log("opened tslib touchscreen");
        }
 #endif
 
@@ -529,9 +529,9 @@ void omapsdl_input_init(void)
                /* touchscreen check */
                if (touchscreen_ino != (dev_t)-1) {
                        if (fstat(fd, &stat_buf) == -1)
-                               perror("fstat");
+                               err_perror("fstat");
                        else if (touchscreen_ino == stat_buf.st_ino) {
-                               printf("skip %s as ts\n", name);
+                               log("skip %s as ts", name);
                                goto skip;
                        }
                }
@@ -539,7 +539,7 @@ void omapsdl_input_init(void)
                /* check supported events */
                ret = ioctl(fd, EVIOCGBIT(0, sizeof(support)), &support);
                if (ret == -1) {
-                       printf("in_evdev: ioctl failed on %s\n", name);
+                       err_perror("in_evdev: ioctl failed on %s", name);
                        goto skip;
                }
 
@@ -548,7 +548,7 @@ void omapsdl_input_init(void)
 
                ret = ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybits)), keybits);
                if (ret == -1) {
-                       printf("in_evdev: ioctl failed on %s\n", name);
+                       err_perror("in_evdev: ioctl failed on %s", name);
                        goto skip;
                }
 
@@ -565,7 +565,7 @@ void omapsdl_input_init(void)
 
                osdl_evdev_devs[osdl_evdev_dev_count++] = fd;
                ioctl(fd, EVIOCGNAME(sizeof(name)), name);
-               printf("in_evdev: found \"%s\" with %d events (type %08x)\n",
+               log("in_evdev: found \"%s\" with %d events (type %08x)",
                        name, count, support);
                continue;
 
@@ -573,7 +573,7 @@ skip:
                close(fd);
        }
 
-       printf("found %d evdev device(s).\n", osdl_evdev_dev_count);
+       log("found %d evdev device(s).", osdl_evdev_dev_count);
 }
 
 void omapsdl_input_finish(void)
@@ -624,7 +624,7 @@ int omapsdl_input_get_events(int timeout_ms,
                ret = select(fdmax + 1, &fdset, NULL, NULL, timeout);
                if (ret == -1)
                {
-                       perror("in_evdev: select failed");
+                       err_perror("in_evdev: select failed");
                        return -1;
                }
                else if (ret == 0)
@@ -655,7 +655,7 @@ int omapsdl_input_get_events(int timeout_ms,
                                ret = read(fd, &ev, sizeof(ev));
                                if (ret < (int)sizeof(ev)) {
                                        if (errno != EAGAIN) {
-                                               perror("in_evdev: read failed");
+                                               err_perror("in_evdev: read failed");
                                                return -1;
                                        }
                                        break;
index d492d36..450176e 100644 (file)
@@ -35,13 +35,13 @@ static int osdl_setup_omapfb(int fd, int enabled, int x, int y, int w, int h, in
 
        ret = ioctl(fd, OMAPFB_QUERY_PLANE, &pi);
        if (ret != 0) {
-               perror("QUERY_PLANE");
+               err_perror("QUERY_PLANE");
                return -1;
        }
 
        ret = ioctl(fd, OMAPFB_QUERY_MEM, &mi);
        if (ret != 0) {
-               perror("QUERY_MEM");
+               err_perror("QUERY_MEM");
                return -1;
        }
 
@@ -50,13 +50,13 @@ static int osdl_setup_omapfb(int fd, int enabled, int x, int y, int w, int h, in
                pi.enabled = 0;
                ret = ioctl(fd, OMAPFB_SETUP_PLANE, &pi);
                if (ret != 0)
-                       perror("SETUP_PLANE");
+                       err_perror("SETUP_PLANE");
        }
 
        mi.size = mem;
        ret = ioctl(fd, OMAPFB_SETUP_MEM, &mi);
        if (ret != 0) {
-               perror("SETUP_MEM");
+               err_perror("SETUP_MEM");
                return -1;
        }
 
@@ -68,7 +68,7 @@ static int osdl_setup_omapfb(int fd, int enabled, int x, int y, int w, int h, in
 
        ret = ioctl(fd, OMAPFB_SETUP_PLANE, &pi);
        if (ret != 0) {
-               perror("SETUP_PLANE");
+               err_perror("SETUP_PLANE");
                return -1;
        }
 
@@ -82,16 +82,14 @@ static int read_sysfs(const char *fname, char *buff, size_t size)
 
        f = fopen(fname, "r");
        if (f == NULL) {
-               fprintf(stderr, "open %s: ", fname);
-               perror(NULL);
+               err_perror("open %s: ", fname);
                return -1;
        }
 
        ret = fread(buff, 1, size - 1, f);
        fclose(f);
        if (ret <= 0) {
-               fprintf(stderr, "read %s: ", fname);
-               perror(NULL);
+               err_perror("read %s: ", fname);
                return -1;
        }
 
@@ -116,8 +114,7 @@ static int osdl_setup_omap_layer(struct SDL_PrivateVideoData *pdata,
 
        fd = open(fbname, O_RDWR);
        if (fd == -1) {
-               fprintf(stderr, "open %s: ", fbname);
-               perror(NULL);
+               err_perror("open %s", fbname);
                return -1;
        }
 
@@ -130,13 +127,13 @@ static int osdl_setup_omap_layer(struct SDL_PrivateVideoData *pdata,
 
                ret = ioctl(fd, OMAPFB_QUERY_PLANE, &slayer->pi);
                if (ret != 0) {
-                       perror("QUERY_PLANE");
+                       err_perror("QUERY_PLANE");
                        return -1;
                }
 
                ret = ioctl(fd, OMAPFB_QUERY_MEM, &slayer->mi);
                if (ret != 0) {
-                       perror("QUERY_MEM");
+                       err_perror("QUERY_MEM");
                        return -1;
                }
 
@@ -147,8 +144,7 @@ static int osdl_setup_omap_layer(struct SDL_PrivateVideoData *pdata,
         * The only way to achieve this seems to be walking some sysfs files.. */
        ret = stat(fbname, &status);
        if (ret != 0) {
-               fprintf(stderr, "can't stat %s: ", fbname);
-               perror(NULL);
+               err_perror("can't stat %s", fbname);
                return -1;
        }
        fb_id = minor(status.st_rdev);
@@ -156,21 +152,21 @@ static int osdl_setup_omap_layer(struct SDL_PrivateVideoData *pdata,
        snprintf(buff, sizeof(buff), "/sys/class/graphics/fb%d/overlays", fb_id);
        f = fopen(buff, "r");
        if (f == NULL) {
-               fprintf(stderr, "can't open %s, skip screen detection\n", buff);
+               err("can't open %s, skip screen detection", buff);
                goto skip_screen;
        }
 
        ret = fscanf(f, "%d", &overlay_id);
        fclose(f);
        if (ret != 1) {
-               fprintf(stderr, "can't parse %s, skip screen detection\n", buff);
+               err("can't parse %s, skip screen detection", buff);
                goto skip_screen;
        }
 
        snprintf(buff, sizeof(buff), "/sys/devices/platform/omapdss/overlay%d/manager", overlay_id);
        ret = read_sysfs(buff, screen_name, sizeof(screen_name));
        if (ret < 0) {
-               fprintf(stderr, "skip screen detection\n");
+               err("skip screen detection");
                goto skip_screen;
        }
 
@@ -187,25 +183,25 @@ static int osdl_setup_omap_layer(struct SDL_PrivateVideoData *pdata,
        }
 
        if (screen_id < 0) {
-               fprintf(stderr, "could not find screen\n");
+               err("could not find screen");
                goto skip_screen;
        }
 
        snprintf(buff, sizeof(buff), "/sys/devices/platform/omapdss/display%d/timings", screen_id);
        f = fopen(buff, "r");
        if (f == NULL) {
-               fprintf(stderr, "can't open %s, skip screen detection\n", buff);
+               err("can't open %s, skip screen detection", buff);
                goto skip_screen;
        }
 
        ret = fscanf(f, "%*d,%d/%*d/%*d/%*d,%d/%*d/%*d/%*d", &screen_w, &screen_h);
        fclose(f);
        if (ret != 2) {
-               fprintf(stderr, "can't parse %s (%d), skip screen detection\n", buff, ret);
+               err("can't parse %s (%d), skip screen detection", buff, ret);
                goto skip_screen;
        }
 
-       printf("detected %dx%d '%s' (%d) screen attached to fb %d and overlay %d\n",
+       log("detected %dx%d '%s' (%d) screen attached to fb %d and overlay %d",
                screen_w, screen_h, screen_name, screen_id, fb_id, overlay_id);
 
 skip_screen:
@@ -217,8 +213,8 @@ skip_screen:
                else if (sscanf(tmp, "%dx%d", &w_, &h_) == 2)
                        w = w_, h = h_;
                else
-                       fprintf(stderr, "layer size specified incorrectly, "
-                                       "should be like 800x480");
+                       err("layer size specified incorrectly, "
+                               "should be like 800x480");
        }
 
        x = screen_w / 2 - w / 2;