summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@iki.fi>2012-05-23 01:30:58 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-05-25 12:23:13 +0200
commit378bf2a0360161879efb842051933da4fb7e75c6 (patch)
treeb60cca8f20a5b8b3aa2c84c87a052b5af4f7e55b
parent79fc1080b905dc3d61a93c31f68acaf3b4985c57 (diff)
Compose rectangle support for libv4l2subdev
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--src/main.c14
-rw-r--r--src/options.c7
-rw-r--r--src/v4l2subdev.c32
3 files changed, 42 insertions, 11 deletions
diff --git a/src/main.c b/src/main.c
index ca633c8..af16818 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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");
}
diff --git a/src/options.c b/src/options.c
index f367daf..4dc542f 100644
--- a/src/options.c
+++ b/src/options.c
@@ -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");
diff --git a/src/v4l2subdev.c b/src/v4l2subdev.c
index bc33610..d60bd7e 100644
--- a/src/v4l2subdev.c
+++ b/src/v4l2subdev.c
@@ -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;
}