diff --git a/util/util.h b/util/util.h
index 33af61deb06f963f724fefffdcbcd8cdd0a235bc..53b6e1cd1689cc38422fdaceadf0dcacab1f6360 100644 (file)
--- a/util/util.h
+++ b/util/util.h
#include <string.h>
#include <errno.h>
#include <unistd.h>
+#include <assert.h>
#include <omap_drm.h>
#include <omap_drmif.h>
+/* align x to next highest multiple of 2^n */
+#define ALIGN2(x,n) (((x) + ((1 << (n)) - 1)) & ~((1 << (n)) - 1))
+
+typedef enum {
+ false = 0,
+ true = 1
+} bool;
+
+#include "list.h"
/* Display Interface:
*
*/
struct buffer {
- uint32_t fourcc, width, height, stride;
- struct omap_bo *bo;
+ uint32_t fourcc, width, height;
+ int nbo;
+ struct omap_bo *bo[4];
+ uint32_t pitches[4];
+ struct list unlocked;
};
struct display {
int fd;
uint32_t width, height;
struct omap_device *dev;
+ struct list unlocked;
struct buffer ** (*get_buffers)(struct display *disp, uint32_t n);
struct buffer ** (*get_vid_buffers)(struct display *disp,
uint32_t n, uint32_t fourcc, uint32_t w, uint32_t h);
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);
};
/* Print display related help */
*/
struct display * disp_open(int argc, char **argv);
+/* Close display */
+void disp_close(struct display *disp);
+
/* Get normal RGB/UI buffers (ie. not scaled, not YUV) */
static inline struct buffer **
disp_get_buffers(struct display *disp, uint32_t n)
}
/* Get video/overlay buffers (ie. can be YUV, scaled, etc) */
-static inline struct buffer **
-disp_get_vid_buffers(struct display *disp, uint32_t n,
- uint32_t fourcc, uint32_t w, uint32_t h)
-{
- return disp->get_vid_buffers(disp, n, fourcc, w, h);
-}
+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
return disp->post_buffer(disp, buf);
}
+/* flip to / post the specified video buffer */
+static inline 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);
+}
+
+/* allocate a buffer from pool created by disp_get_vid_buffers() */
+struct buffer * disp_get_vid_buffer(struct display *disp);
+/* free to video buffer pool */
+void disp_put_vid_buffer(struct display *disp, struct buffer *buf);
+
+/* helper to setup the display for apps that just need video with
+ * no flipchain on the GUI layer
+ */
+struct buffer * disp_get_fb(struct display *disp);
+
+
/* V4L2 utilities:
*/
void v4l2_usage(void);
/* Open v4l2 (and media0??) XXX */
-struct v4l2 * v4l2_open(int argc, char **argv);
+struct v4l2 * v4l2_open(int argc, char **argv, uint32_t *fourcc,
+ uint32_t *width, uint32_t *height);
/* Share the buffers w/ v4l2 via dmabuf */
int v4l2_reqbufs(struct v4l2 *v4l2, struct buffer **bufs, uint32_t n);
(type *)((char *)(ptr) - (char *) &((type *)0)->member)
#endif
-typedef enum {
- false = 0,
- true = 1
-} bool;
+#ifndef MIN
+# define MIN(a,b) (((a) < (b)) ? (a) : (b))
+#endif
+
+#ifndef MAX
+# define MAX(a,b) (((a) > (b)) ? (a) : (b))
+#endif
+
+#ifndef PAGE_SHIFT
+# define PAGE_SHIFT 12
+#endif
+
+#ifndef PAGE_SIZE
+# define PAGE_SIZE (1 << PAGE_SHIFT)
+#endif
+
+/* align x to next highest multiple of 2^n */
+#define ALIGN2(x,n) (((x) + ((1 << (n)) - 1)) & ~((1 << (n)) - 1))
+
+#include <sys/time.h>
+static inline long
+mark(long *last)
+{
+ struct timeval t;
+ gettimeofday(&t, NULL);
+ if (last) {
+ long delta = t.tv_usec - *last;
+
+ /* Handle the case, where the seconds have changed.
+ * TODO: keep the whole timeval struct, to be able to cope with
+ * more than one second deltas? */
+ if (t.tv_usec < *last)
+ delta += 1000000;
+
+ *last = t.tv_usec;
+ return delta;
+ }
+ return t.tv_usec;
+}
#endif /* UTIL_H_ */