From 468bc21f8c6c7eca85477680752052e1ead0e515 Mon Sep 17 00:00:00 2001 From: Todor Tomov Date: Thu, 12 Aug 2010 13:55:34 +0300 Subject: Make format setting optional for -f option This allows to setup crop rectangle or frame interval alone - without format. Signed-off-by: Todor Tomov Signed-off-by: Laurent Pinchart --- main.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index ec1ff1f..3ca1600 100644 --- a/main.c +++ b/main.c @@ -272,11 +272,14 @@ static struct media_entity_pad *parse_pad_format(struct media_device *media, if (*p++ != '[') return NULL; - ret = parse_format(format, p, &end); - if (ret < 0) - return NULL; + if (isalnum(*p)) { + ret = parse_format(format, p, &end); + if (ret < 0) + return NULL; + + for (p = end; isspace(*p); p++); + } - for (p = end; isspace(*p); p++); if (*p == '(') { ret = parse_crop(crop, p, &end); if (ret < 0) @@ -304,6 +307,9 @@ static int set_format(struct media_entity_pad *pad, struct v4l2_mbus_framefmt *f { int ret; + if (format->width == 0 || format->height == 0) + return 0; + printf("Setting up format %s %ux%u on pad %s/%u\n", pixelcode_to_string(format->code), format->width, format->height, pad->entity->info.name, pad->index); @@ -349,6 +355,9 @@ static int set_frame_interval(struct media_entity *entity, struct v4l2_fract *in { int ret; + if (interval->numerator == 0) + return 0; + printf("Setting up frame interval %u/%u on entity %s\n", interval->numerator, interval->denominator, entity->info.name); @@ -367,7 +376,7 @@ static int set_frame_interval(struct media_entity *entity, struct v4l2_fract *in static int setup_format(struct media_device *media, const char *p, char **endp) { - struct v4l2_mbus_framefmt format; + struct v4l2_mbus_framefmt format = { 0, 0, 0 }; struct media_entity_pad *pad; struct v4l2_rect crop = { -1, -1, -1, -1 }; struct v4l2_fract interval = { 0, 0 }; @@ -397,13 +406,10 @@ static int setup_format(struct media_device *media, const char *p, char **endp) return ret; } - if (interval.numerator != 0) { - ret = set_frame_interval(pad->entity, &interval); - if (ret < 0) { - printf("Unable to set frame interval\n"); - return ret; - } - } + ret = set_frame_interval(pad->entity, &interval); + if (ret < 0) + return ret; + /* If the pad is an output pad, automatically set the same format on * the remote subdev input pads, if any. -- cgit v1.2.3