Compose rectangle support for libv4l2subdev
authorSakari Ailus <sakari.ailus@iki.fi>
Tue, 22 May 2012 22:30:58 +0000 (01:30 +0300)
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Fri, 25 May 2012 10:23:13 +0000 (12:23 +0200)
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
src/main.c
src/options.c
src/v4l2subdev.c

index ca633c8..af16818 100644 (file)
@@ -77,6 +77,20 @@ static void v4l2_subdev_print_format(struct media_entity *entity,
                printf("\n\t\t crop:(%u,%u)/%ux%u", rect.left, rect.top,
                       rect.width, rect.height);
 
+       ret = v4l2_subdev_get_selection(entity, &rect, pad,
+                                       V4L2_SUBDEV_SEL_TGT_COMPOSE_BOUNDS,
+                                       which);
+       if (ret == 0)
+               printf("\n\t\t compose.bounds:%u,%u/%ux%u",
+                      rect.left, rect.top, rect.width, rect.height);
+
+       ret = v4l2_subdev_get_selection(entity, &rect, pad,
+                                       V4L2_SUBDEV_SEL_TGT_COMPOSE_ACTUAL,
+                                       which);
+       if (ret == 0)
+               printf("\n\t\t compose:%u,%u/%ux%u",
+                      rect.left, rect.top, rect.width, rect.height);
+
        printf("]\n");
 }
 
index f367daf..4dc542f 100644 (file)
@@ -58,11 +58,14 @@ static void usage(const char *argv0, int verbose)
        printf("\n");
        printf("\tv4l2            = pad '[' v4l2-properties ']' ;\n");
        printf("\tv4l2-properties = v4l2-property { ',' v4l2-property } ;\n");
-       printf("\tv4l2-property   = v4l2-mbusfmt | v4l2-crop | v4l2-interval ;\n");
+       printf("\tv4l2-property   = v4l2-mbusfmt | v4l2-crop | v4l2-interval\n");
+       printf("\t                | v4l2-compose | v4l2-interval ;\n");
        printf("\tv4l2-mbusfmt    = 'fmt:' fcc '/' size ;\n");
-       printf("\tv4l2-crop       = 'crop:' '(' left ',' top ')' '/' size ;\n");
+       printf("\tv4l2-crop       = 'crop:' rectangle ;\n");
+       printf("\tv4l2-compose    = 'compose:' rectangle ;\n");
        printf("\tv4l2-interval   = '@' numerator '/' denominator ;\n");
        printf("\n");
+       printf("\trectangle       = '(' left ',' top, ')' '/' size ;\n");
        printf("\tsize            = width 'x' height ;\n");
        printf("\n");
        printf("where the fields are\n");
index bc33610..d60bd7e 100644 (file)
@@ -331,8 +331,8 @@ static bool strhazit(const char *str, const char **p)
 
 static struct media_pad *v4l2_subdev_parse_pad_format(
        struct media_device *media, struct v4l2_mbus_framefmt *format,
-       struct v4l2_rect *crop, struct v4l2_fract *interval, const char *p,
-       char **endp)
+       struct v4l2_rect *crop, struct v4l2_rect *compose,
+       struct v4l2_fract *interval, const char *p, char **endp)
 {
        struct media_pad *pad;
        bool first;
@@ -378,6 +378,15 @@ static struct media_pad *v4l2_subdev_parse_pad_format(
                        continue;
                }
 
+               if (strhazit("compose:", &p)) {
+                       ret = v4l2_subdev_parse_rectangle(compose, p, &end);
+                       if (ret < 0)
+                               return NULL;
+
+                       for (p = end; isspace(*p); p++);
+                       continue;
+               }
+
                if (*p == '@') {
                        ret = v4l2_subdev_parse_frame_interval(interval, ++p, &end);
                        if (ret < 0)
@@ -491,30 +500,35 @@ static int v4l2_subdev_parse_setup_format(struct media_device *media,
        struct v4l2_mbus_framefmt format = { 0, 0, 0 };
        struct media_pad *pad;
        struct v4l2_rect crop = { -1, -1, -1, -1 };
+       struct v4l2_rect compose = crop;
        struct v4l2_fract interval = { 0, 0 };
        unsigned int i;
        char *end;
        int ret;
 
-       pad = v4l2_subdev_parse_pad_format(media, &format, &crop, &interval,
-                                          p, &end);
+       pad = v4l2_subdev_parse_pad_format(media, &format, &crop, &compose,
+                                          &interval, p, &end);
        if (pad == NULL) {
                media_dbg(media, "Unable to parse format\n");
                return -EINVAL;
        }
 
-       if (pad->flags & MEDIA_PAD_FL_SOURCE) {
-               ret = set_selection(pad, V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL, &crop);
+       if (pad->flags & MEDIA_PAD_FL_SINK) {
+               ret = set_format(pad, &format);
                if (ret < 0)
                        return ret;
        }
 
-       ret = set_format(pad, &format);
+       ret = set_selection(pad, V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL, &crop);
        if (ret < 0)
                return ret;
 
-       if (pad->flags & MEDIA_PAD_FL_SINK) {
-               ret = set_selection(pad, V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL, &crop);
+       ret = set_selection(pad, V4L2_SUBDEV_SEL_TGT_COMPOSE_ACTUAL, &compose);
+       if (ret < 0)
+               return ret;
+
+       if (pad->flags & MEDIA_PAD_FL_SOURCE) {
+               ret = set_format(pad, &format);
                if (ret < 0)
                        return ret;
        }