From 411839713ddf7d7d4fff5a7dbe36eedf83b3ae65 Mon Sep 17 00:00:00 2001 From: Javier Viguera Date: Thu, 9 Oct 2014 16:05:33 +0200 Subject: [PATCH] v4l2_test: filter out invalid cropping height and width The camera/driver does not support a cropping rectangle with height and width less than 8 pixels. Add those limits to the sanity check of the values in the user-space test application. https://jira.digi.com/browse/DEL-1201 Signed-off-by: Javier Viguera --- .../dey-examples/files/v4l2_test/v4l2_common.c | 15 +++++++++------ .../files/v4l2_test/v4l2_preview_test.c | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/meta-digi-dey/recipes-digi/dey-examples/files/v4l2_test/v4l2_common.c b/meta-digi-dey/recipes-digi/dey-examples/files/v4l2_test/v4l2_common.c index 937409102..52f8941ce 100644 --- a/meta-digi-dey/recipes-digi/dey-examples/files/v4l2_test/v4l2_common.c +++ b/meta-digi-dey/recipes-digi/dey-examples/files/v4l2_test/v4l2_common.c @@ -601,9 +601,9 @@ int v4l2_crop_input(int fd, struct v4l2_rect *crop_rectangle) if (retval < 0) return retval; - if (crop_rectangle->left + crop_rectangle->width > crop_bounds.left + - crop_bounds.width || crop_rectangle->top + - crop_rectangle->height > crop_bounds.top + crop_bounds.height) { + if (crop_rectangle->left + crop_rectangle->width > crop_bounds.left + crop_bounds.width || + crop_rectangle->top + crop_rectangle->height > crop_bounds.top + crop_bounds.height || + crop_rectangle->width < 8 || crop_rectangle->height < 8) { log("Invalid input\n"); return -EINVAL; } @@ -643,10 +643,13 @@ int v4l2_area_zoom(int fd, struct v4l2_rect *crop_rectangle) crop_rectangle->top, crop_rectangle->left, crop_rectangle->width, crop_rectangle->height); printf("\nValid rectangles are those which:\n" - "Top + Height < Bound_Top + Bound_Height\n" - "and\n" "Left + Width < Bound_Left + Bound_Width\n\n"); + " Height >= 8\n" + " Width >= 8\n" + " Top + Height < Bound_Top + Bound_Height\n" + " Left + Width < Bound_Left + Bound_Width\n\n"); + } else { + return retval; } - return retval; } retval = v4l2_overlay_control(fd, 1); diff --git a/meta-digi-dey/recipes-digi/dey-examples/files/v4l2_test/v4l2_preview_test.c b/meta-digi-dey/recipes-digi/dey-examples/files/v4l2_test/v4l2_preview_test.c index 92d52f730..905e81c2c 100644 --- a/meta-digi-dey/recipes-digi/dey-examples/files/v4l2_test/v4l2_preview_test.c +++ b/meta-digi-dey/recipes-digi/dey-examples/files/v4l2_test/v4l2_preview_test.c @@ -230,7 +230,7 @@ static int cmd_area_zoom(int fd) struct v4l2_rect zoom_rectangle; int ret = -1; - printf("Enter rectangle's values (top, left, width, height): "); + printf("Enter rectangle's values (top, left, width [>=8], height [>=8]): "); if ((scanf("%d,%d,%d,%d", &zoom_rectangle.top, &zoom_rectangle.left, &zoom_rectangle.width, &zoom_rectangle.height)) != 4 || should_stop) { printf("Enter four parameters\n");