summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnric Balletbo i Serra <eballetbo@iseebcn.com>2012-10-17 11:22:59 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-10-19 15:54:44 +0200
commit7e62380de5584b9edbd61048f5b16e521e893eeb (patch)
treeaf82bcc9146d3449316edd3cfeafbb3d3da9acfe
parent1342aa685ab910a633a3087b38c000fb832a6d5b (diff)
live: Support 16bpp and 24bpp RGB frame buffer formats
Paint the frame buffer correctly and set the corresponding color key value for 16bpp and 24bpp RGB formats. Signed-off-by: Enric Balletbo i Serra <eballetbo@iseebcn.com> [Extract the bpp value through the fbdev API, add support for 24bpp] Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--live.c54
1 files changed, 51 insertions, 3 deletions
diff --git a/live.c b/live.c
index 512c529..2c24e00 100644
--- a/live.c
+++ b/live.c
@@ -259,8 +259,14 @@ static const char *video_out_find(void)
* Frame buffer
*/
+struct color_rgb24 {
+ unsigned int value:24;
+} __attribute__((__packed__));
+
static int fb_init(struct v4l2_rect *rect)
{
+ struct color_24bpp ;
+
struct fb_fix_screeninfo fix;
struct fb_var_screeninfo var;
unsigned int i;
@@ -293,8 +299,47 @@ static int fb_init(struct v4l2_rect *rect)
}
/* Fill the frame buffer with the background color. */
- for (i = 0; i < fix.smem_len; i += 4)
- *(uint32_t *)(mem + i) = 0x00123456;
+ printf("%u bpp\n", var.bits_per_pixel);
+ switch (var.bits_per_pixel) {
+ case 16: {
+ uint16_t color = 0x11b6;
+ uint16_t *pix = mem;
+
+ for (i = 0; i < fix.smem_len; i += 2)
+ *pix++ = color;
+
+ ret = color;
+ break;
+ }
+
+ case 24: {
+ struct color_rgb24 color = { .value = 0x123456, };
+ struct color_rgb24 *pix = mem;
+
+ for (i = 0; i < fix.smem_len; i += 3)
+ *pix++ = color;
+
+ ret = color.value;
+ break;
+ }
+
+ case 32: {
+ uint32_t color = 0x00123456;
+ uint32_t *pix = mem;
+
+ for (i = 0; i < fix.smem_len; i += 4)
+ *pix++ = color;
+
+ ret = color;
+ break;
+ }
+
+ default:
+ printf("error: unsupported %ubpp color depth\n",
+ var.bits_per_pixel);
+ ret = -EINVAL;
+ goto done;
+ }
/* Return the frame buffer size. */
rect->left = var.xoffset;
@@ -365,6 +410,7 @@ int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unu
struct v4l2_rect rect;
int exit_code = EXIT_FAILURE;
const char *vo_devname;
+ unsigned int colorkey;
float fps;
int ret;
int c;
@@ -410,6 +456,8 @@ int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unu
goto cleanup;
}
+ colorkey = ret;
+
/* Register a signal handler for SIGINT, received when the user presses
* CTRL-C. This will allow the main loop to be interrupted, and resources
* to be freed cleanly.
@@ -460,7 +508,7 @@ int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unu
goto cleanup;
}
- vo_enable_colorkey(vo, 0x123456);
+ vo_enable_colorkey(vo, colorkey);
/* Allocate a buffers pool and use it for the viewfinder. */
pool = vo_get_pool(vo);