]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/omapdrmtest.git/blobdiff - util/util.h
omx cam: add test app
[glsdk/omapdrmtest.git] / util / util.h
index 53b6e1cd1689cc38422fdaceadf0dcacab1f6360..985917a4965cb04ee1d50b4580d4328ffad96d2c 100644 (file)
 /* align x to next highest multiple of 2^n */
 #define ALIGN2(x,n)   (((x) + ((1 << (n)) - 1)) & ~((1 << (n)) - 1))
 
+#ifndef __cplusplus
 typedef enum {
        false = 0,
        true = 1
 } bool;
+#endif
 
 #include "list.h"
 
@@ -54,6 +56,15 @@ struct buffer {
        struct omap_bo *bo[4];
        uint32_t pitches[4];
        struct list unlocked;
+       bool multiplanar;       /* True when Y and U/V are in separate buffers. */
+};
+
+/* State variables, used to maintain the playback rate. */
+struct rate_control {
+       int fps;                /* When > zero, we maintain playback rate. */
+       long last_frame_mark;   /* The time when the last frame was displayed,
+                                * as returned by the mark() function. */
+       int usecs_to_sleep;     /* Number of useconds we have slep last frame. */
 };
 
 struct display {
@@ -61,6 +72,7 @@ struct display {
        uint32_t width, height;
        struct omap_device *dev;
        struct list unlocked;
+       struct rate_control rtctl;
 
        struct buffer ** (*get_buffers)(struct display *disp, uint32_t n);
        struct buffer ** (*get_vid_buffers)(struct display *disp,
@@ -68,6 +80,9 @@ struct display {
        int (*post_buffer)(struct display *disp, struct buffer *buf);
        int (*post_vid_buffer)(struct display *disp, struct buffer *buf,
                        uint32_t x, uint32_t y, uint32_t w, uint32_t h);
+       void (*close)(struct display *disp);
+
+       bool multiplanar;       /* True when Y and U/V are in separate buffers. */
 };
 
 /* Print display related help */
@@ -79,7 +94,11 @@ void disp_usage(void);
 struct display * disp_open(int argc, char **argv);
 
 /* Close display */
-void disp_close(struct display *disp);
+static inline void
+disp_close(struct display *disp)
+{
+       disp->close(disp);
+}
 
 /* Get normal RGB/UI buffers (ie. not scaled, not YUV) */
 static inline struct buffer **
@@ -93,19 +112,13 @@ struct buffer ** disp_get_vid_buffers(struct display *disp, uint32_t n,
                uint32_t fourcc, uint32_t w, uint32_t h);
 
 /* flip to / post the specified buffer */
-static inline int
-disp_post_buffer(struct display *disp, struct buffer *buf)
-{
-       return disp->post_buffer(disp, buf);
-}
+int
+disp_post_buffer(struct display *disp, struct buffer *buf);
 
 /* flip to / post the specified video buffer */
-static inline int
+int
 disp_post_vid_buffer(struct display *disp, struct buffer *buf,
-               uint32_t x, uint32_t y, uint32_t w, uint32_t h)
-{
-       return disp->post_vid_buffer(disp, buf, x, y, w, h);
-}
+               uint32_t x, uint32_t y, uint32_t w, uint32_t h);
 
 /* allocate a buffer from pool created by disp_get_vid_buffers() */
 struct buffer * disp_get_vid_buffer(struct display *disp);
@@ -144,6 +157,7 @@ struct buffer * v4l2_dqbuf(struct v4l2 *v4l2);
 
 /* Other utilities..
  */
+extern int debug;
 
 int check_args(int argc, char **argv);
 
@@ -152,6 +166,10 @@ void fill(struct buffer *buf, int i);
 #define FOURCC(a, b, c, d) ((uint32_t)(uint8_t)(a) | ((uint32_t)(uint8_t)(b) << 8) | ((uint32_t)(uint8_t)(c) << 16) | ((uint32_t)(uint8_t)(d) << 24 ))
 #define FOURCC_STR(str)    FOURCC(str[0], str[1], str[2], str[3])
 
+/* Dynamic debug. */
+#define DBG(fmt, ...) \
+               do { if (debug) fprintf(stderr, fmt "\n", ##__VA_ARGS__); } while (0)
+
 #define MSG(fmt, ...) \
                do { fprintf(stderr, fmt "\n", ##__VA_ARGS__); } while (0)
 #define ERROR(fmt, ...) \