summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2010-08-01 21:09:55 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2010-08-01 21:09:55 +0200
commit74004e698ba7479d2cab0ecb5c2259d44072f6e0 (patch)
tree3d84a60a25cf35d7035a276d662f56457ef0c391 /main.c
parent821996487a44e7ef95760e47f149a95e3132918f (diff)
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 <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'main.c')
-rw-r--r--main.c19
1 files changed, 12 insertions, 7 deletions
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) {