summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodor Tomov <ttomov@mm-sol.com>2010-08-12 13:55:34 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2010-08-16 15:02:48 +0200
commit468bc21f8c6c7eca85477680752052e1ead0e515 (patch)
tree2e81db19d09518d965bb5496b32f8a34c4e9be07
parentabdf840de983369cc3e65364304fb761c015d5b1 (diff)
Make format setting optional for -f option
This allows to setup crop rectangle or frame interval alone - without format. Signed-off-by: Todor Tomov <ttomov@mm-sol.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--main.c30
1 files changed, 18 insertions, 12 deletions
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.