Re: [RFC PATCH 1/8] v4l2 subdevs: replace get/set_crop by get/set_selection

2014-12-16 Thread Prabhakar Lad
On Thu, Dec 4, 2014 at 3:24 PM, Hans Verkuil hverk...@xs4all.nl wrote:
 From: Hans Verkuil hans.verk...@cisco.com

 The crop and selection pad ops are duplicates. Replace all uses of 
 get/set_crop
 by get/set_selection. This will make it possible to drop get/set_crop
 altogether.

 Signed-off-by: Hans Verkuil hans.verk...@cisco.com
 Acked-by: Sylwester Nawrocki s.nawro...@samsung.com
 Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
 Cc: Prabhakar Lad prabhakar.cse...@gmail.com
 Cc: Philipp Zabel p.za...@pengutronix.de

Acked-by: Lad, Prabhakar prabhakar.cse...@gmail.com

Regards,
--Prabhakar Lad

 ---
  drivers/media/i2c/mt9m032.c | 42 ---
  drivers/media/i2c/mt9p031.c | 41 ---
  drivers/media/i2c/mt9t001.c | 41 ---
  drivers/media/i2c/mt9v032.c | 43 ---
  drivers/media/i2c/s5k6aa.c  | 44 +---
  drivers/staging/media/davinci_vpfe/dm365_isif.c | 69 
 +
  6 files changed, 156 insertions(+), 124 deletions(-)

 diff --git a/drivers/media/i2c/mt9m032.c b/drivers/media/i2c/mt9m032.c
 index 45b3fca..7643122 100644
 --- a/drivers/media/i2c/mt9m032.c
 +++ b/drivers/media/i2c/mt9m032.c
 @@ -422,22 +422,25 @@ done:
 return ret;
  }

 -static int mt9m032_get_pad_crop(struct v4l2_subdev *subdev,
 -   struct v4l2_subdev_fh *fh,
 -   struct v4l2_subdev_crop *crop)
 +static int mt9m032_get_pad_selection(struct v4l2_subdev *subdev,
 +struct v4l2_subdev_fh *fh,
 +struct v4l2_subdev_selection *sel)
  {
 struct mt9m032 *sensor = to_mt9m032(subdev);

 +   if (sel-target != V4L2_SEL_TGT_CROP)
 +   return -EINVAL;
 +
 mutex_lock(sensor-lock);
 -   crop-rect = *__mt9m032_get_pad_crop(sensor, fh, crop-which);
 +   sel-r = *__mt9m032_get_pad_crop(sensor, fh, sel-which);
 mutex_unlock(sensor-lock);

 return 0;
  }

 -static int mt9m032_set_pad_crop(struct v4l2_subdev *subdev,
 -   struct v4l2_subdev_fh *fh,
 -   struct v4l2_subdev_crop *crop)
 +static int mt9m032_set_pad_selection(struct v4l2_subdev *subdev,
 +struct v4l2_subdev_fh *fh,
 +struct v4l2_subdev_selection *sel)
  {
 struct mt9m032 *sensor = to_mt9m032(subdev);
 struct v4l2_mbus_framefmt *format;
 @@ -445,9 +448,12 @@ static int mt9m032_set_pad_crop(struct v4l2_subdev 
 *subdev,
 struct v4l2_rect rect;
 int ret = 0;

 +   if (sel-target != V4L2_SEL_TGT_CROP)
 +   return -EINVAL;
 +
 mutex_lock(sensor-lock);

 -   if (sensor-streaming  crop-which == V4L2_SUBDEV_FORMAT_ACTIVE) {
 +   if (sensor-streaming  sel-which == V4L2_SUBDEV_FORMAT_ACTIVE) {
 ret = -EBUSY;
 goto done;
 }
 @@ -455,13 +461,13 @@ static int mt9m032_set_pad_crop(struct v4l2_subdev 
 *subdev,
 /* Clamp the crop rectangle boundaries and align them to a multiple 
 of 2
  * pixels to ensure a GRBG Bayer pattern.
  */
 -   rect.left = clamp(ALIGN(crop-rect.left, 2), MT9M032_COLUMN_START_MIN,
 +   rect.left = clamp(ALIGN(sel-r.left, 2), MT9M032_COLUMN_START_MIN,
   MT9M032_COLUMN_START_MAX);
 -   rect.top = clamp(ALIGN(crop-rect.top, 2), MT9M032_ROW_START_MIN,
 +   rect.top = clamp(ALIGN(sel-r.top, 2), MT9M032_ROW_START_MIN,
  MT9M032_ROW_START_MAX);
 -   rect.width = clamp_t(unsigned int, ALIGN(crop-rect.width, 2),
 +   rect.width = clamp_t(unsigned int, ALIGN(sel-r.width, 2),
  MT9M032_COLUMN_SIZE_MIN, 
 MT9M032_COLUMN_SIZE_MAX);
 -   rect.height = clamp_t(unsigned int, ALIGN(crop-rect.height, 2),
 +   rect.height = clamp_t(unsigned int, ALIGN(sel-r.height, 2),
   MT9M032_ROW_SIZE_MIN, MT9M032_ROW_SIZE_MAX);

 rect.width = min_t(unsigned int, rect.width,
 @@ -469,21 +475,21 @@ static int mt9m032_set_pad_crop(struct v4l2_subdev 
 *subdev,
 rect.height = min_t(unsigned int, rect.height,
 MT9M032_PIXEL_ARRAY_HEIGHT - rect.top);

 -   __crop = __mt9m032_get_pad_crop(sensor, fh, crop-which);
 +   __crop = __mt9m032_get_pad_crop(sensor, fh, sel-which);

 if (rect.width != __crop-width || rect.height != __crop-height) {
 /* Reset the output image size if the crop rectangle size has
  * been modified.
  */
 -   format = __mt9m032_get_pad_format(sensor, fh, crop-which);
 +   format = __mt9m032_get_pad_format(sensor, fh, sel-which);
 format-width = rect.width;
 format-height = rect.height;
  

Re: [RFC PATCH 1/8] v4l2 subdevs: replace get/set_crop by get/set_selection

2014-12-12 Thread Sakari Ailus
On Thu, Dec 04, 2014 at 10:54:52AM +0100, Hans Verkuil wrote:
 From: Hans Verkuil hans.verk...@cisco.com
 
 The crop and selection pad ops are duplicates. Replace all uses of 
 get/set_crop
 by get/set_selection. This will make it possible to drop get/set_crop
 altogether.
 
 Signed-off-by: Hans Verkuil hans.verk...@cisco.com
 Acked-by: Sylwester Nawrocki s.nawro...@samsung.com
 Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
 Cc: Prabhakar Lad prabhakar.cse...@gmail.com
 Cc: Philipp Zabel p.za...@pengutronix.de

Acked-by: Sakari Ailus sakari.ai...@linux.intel.com

-- 
Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH 1/8] v4l2 subdevs: replace get/set_crop by get/set_selection

2014-12-04 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

The crop and selection pad ops are duplicates. Replace all uses of get/set_crop
by get/set_selection. This will make it possible to drop get/set_crop
altogether.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Acked-by: Sylwester Nawrocki s.nawro...@samsung.com
Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
Cc: Prabhakar Lad prabhakar.cse...@gmail.com
Cc: Philipp Zabel p.za...@pengutronix.de
---
 drivers/media/i2c/mt9m032.c | 42 ---
 drivers/media/i2c/mt9p031.c | 41 ---
 drivers/media/i2c/mt9t001.c | 41 ---
 drivers/media/i2c/mt9v032.c | 43 ---
 drivers/media/i2c/s5k6aa.c  | 44 +---
 drivers/staging/media/davinci_vpfe/dm365_isif.c | 69 +
 6 files changed, 156 insertions(+), 124 deletions(-)

diff --git a/drivers/media/i2c/mt9m032.c b/drivers/media/i2c/mt9m032.c
index 45b3fca..7643122 100644
--- a/drivers/media/i2c/mt9m032.c
+++ b/drivers/media/i2c/mt9m032.c
@@ -422,22 +422,25 @@ done:
return ret;
 }
 
-static int mt9m032_get_pad_crop(struct v4l2_subdev *subdev,
-   struct v4l2_subdev_fh *fh,
-   struct v4l2_subdev_crop *crop)
+static int mt9m032_get_pad_selection(struct v4l2_subdev *subdev,
+struct v4l2_subdev_fh *fh,
+struct v4l2_subdev_selection *sel)
 {
struct mt9m032 *sensor = to_mt9m032(subdev);
 
+   if (sel-target != V4L2_SEL_TGT_CROP)
+   return -EINVAL;
+
mutex_lock(sensor-lock);
-   crop-rect = *__mt9m032_get_pad_crop(sensor, fh, crop-which);
+   sel-r = *__mt9m032_get_pad_crop(sensor, fh, sel-which);
mutex_unlock(sensor-lock);
 
return 0;
 }
 
-static int mt9m032_set_pad_crop(struct v4l2_subdev *subdev,
-   struct v4l2_subdev_fh *fh,
-   struct v4l2_subdev_crop *crop)
+static int mt9m032_set_pad_selection(struct v4l2_subdev *subdev,
+struct v4l2_subdev_fh *fh,
+struct v4l2_subdev_selection *sel)
 {
struct mt9m032 *sensor = to_mt9m032(subdev);
struct v4l2_mbus_framefmt *format;
@@ -445,9 +448,12 @@ static int mt9m032_set_pad_crop(struct v4l2_subdev *subdev,
struct v4l2_rect rect;
int ret = 0;
 
+   if (sel-target != V4L2_SEL_TGT_CROP)
+   return -EINVAL;
+
mutex_lock(sensor-lock);
 
-   if (sensor-streaming  crop-which == V4L2_SUBDEV_FORMAT_ACTIVE) {
+   if (sensor-streaming  sel-which == V4L2_SUBDEV_FORMAT_ACTIVE) {
ret = -EBUSY;
goto done;
}
@@ -455,13 +461,13 @@ static int mt9m032_set_pad_crop(struct v4l2_subdev 
*subdev,
/* Clamp the crop rectangle boundaries and align them to a multiple of 2
 * pixels to ensure a GRBG Bayer pattern.
 */
-   rect.left = clamp(ALIGN(crop-rect.left, 2), MT9M032_COLUMN_START_MIN,
+   rect.left = clamp(ALIGN(sel-r.left, 2), MT9M032_COLUMN_START_MIN,
  MT9M032_COLUMN_START_MAX);
-   rect.top = clamp(ALIGN(crop-rect.top, 2), MT9M032_ROW_START_MIN,
+   rect.top = clamp(ALIGN(sel-r.top, 2), MT9M032_ROW_START_MIN,
 MT9M032_ROW_START_MAX);
-   rect.width = clamp_t(unsigned int, ALIGN(crop-rect.width, 2),
+   rect.width = clamp_t(unsigned int, ALIGN(sel-r.width, 2),
 MT9M032_COLUMN_SIZE_MIN, MT9M032_COLUMN_SIZE_MAX);
-   rect.height = clamp_t(unsigned int, ALIGN(crop-rect.height, 2),
+   rect.height = clamp_t(unsigned int, ALIGN(sel-r.height, 2),
  MT9M032_ROW_SIZE_MIN, MT9M032_ROW_SIZE_MAX);
 
rect.width = min_t(unsigned int, rect.width,
@@ -469,21 +475,21 @@ static int mt9m032_set_pad_crop(struct v4l2_subdev 
*subdev,
rect.height = min_t(unsigned int, rect.height,
MT9M032_PIXEL_ARRAY_HEIGHT - rect.top);
 
-   __crop = __mt9m032_get_pad_crop(sensor, fh, crop-which);
+   __crop = __mt9m032_get_pad_crop(sensor, fh, sel-which);
 
if (rect.width != __crop-width || rect.height != __crop-height) {
/* Reset the output image size if the crop rectangle size has
 * been modified.
 */
-   format = __mt9m032_get_pad_format(sensor, fh, crop-which);
+   format = __mt9m032_get_pad_format(sensor, fh, sel-which);
format-width = rect.width;
format-height = rect.height;
}
 
*__crop = rect;
-   crop-rect = rect;
+   sel-r = rect;
 
-   if (crop-which == V4L2_SUBDEV_FORMAT_ACTIVE)
+   if (sel-which == V4L2_SUBDEV_FORMAT_ACTIVE)
ret =