From 74004e698ba7479d2cab0ecb5c2259d44072f6e0 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 1 Aug 2010 21:09:55 +0200 Subject: Configure cropping on output pads before setting the format Image size on output pads depend on the cropping parameters. Cropping must be configured before setting the image size on those pads. Signed-off-by: Laurent Pinchart --- main.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 62277b0..15ccfb2 100644 --- a/main.c +++ b/main.c @@ -321,6 +321,9 @@ static int set_crop(struct media_entity_pad *pad, struct v4l2_rect *crop) { int ret; + if (crop->left == -1 || crop->top == -1) + return 0; + printf("Setting up crop rectangle %u,%u/%ux%u on pad %s/%u\n", crop->left, crop->top, crop->width, crop->height, pad->entity->info.name, pad->index); @@ -374,18 +377,20 @@ static int setup_format(struct media_device *media, const char *p, char **endp) return -EINVAL; } + if (pad->type == MEDIA_PAD_TYPE_OUTPUT) { + ret = set_crop(pad, &crop); + if (ret < 0) + return ret; + } + ret = set_format(pad, &format); - if (ret < 0) { - printf("Unable to set format\n"); + if (ret < 0) return ret; - } - if (crop.left != -1 && crop.top != -1) { + if (pad->type == MEDIA_PAD_TYPE_INPUT) { ret = set_crop(pad, &crop); - if (ret < 0) { - printf("Unable to set crop rectangle\n"); + if (ret < 0) return ret; - } } if (interval.numerator != 0) { -- cgit v1.2.3