Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a0705b07 authored by Guennadi Liakhovetski's avatar Guennadi Liakhovetski Committed by Mauro Carvalho Chehab
Browse files

V4L/DVB (12515): soc-camera: use struct v4l2_rect in struct soc_camera_device



Switch to using struct v4l2_rect in struct soc_camera_device for uniformity and
simplicity.

Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 4a6110bc
Loading
Loading
Loading
Loading
+16 −14
Original line number Diff line number Diff line
@@ -240,8 +240,8 @@ static int mt9m001_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
	struct i2c_client *client = sd->priv;
	struct soc_camera_device *icd = client->dev.platform_data;
	struct v4l2_rect rect = {
		.left	= icd->x_current,
		.top	= icd->y_current,
		.left	= icd->rect_current.left,
		.top	= icd->rect_current.top,
		.width	= f->fmt.pix.width,
		.height	= f->fmt.pix.height,
	};
@@ -467,11 +467,13 @@ static int mt9m001_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
	case V4L2_CID_EXPOSURE_AUTO:
		if (ctrl->value) {
			const u16 vblank = 25;
			if (reg_write(client, MT9M001_SHUTTER_WIDTH, icd->height +
			if (reg_write(client, MT9M001_SHUTTER_WIDTH,
				      icd->rect_current.height +
				      icd->y_skip_top + vblank) < 0)
				return -EIO;
			qctrl = soc_camera_find_qctrl(icd->ops, V4L2_CID_EXPOSURE);
			icd->exposure = (524 + (icd->height + icd->y_skip_top + vblank - 1) *
			icd->exposure = (524 + (icd->rect_current.height +
						icd->y_skip_top + vblank - 1) *
					 (qctrl->maximum - qctrl->minimum)) /
				1048 + qctrl->minimum;
			mt9m001->autoexposure = 1;
@@ -614,14 +616,14 @@ static int mt9m001_probe(struct i2c_client *client,

	/* Second stage probe - when a capture adapter is there */
	icd->ops		= &mt9m001_ops;
	icd->x_min	= 20;
	icd->y_min	= 12;
	icd->x_current	= 20;
	icd->y_current	= 12;
	icd->rect_max.left	= 20;
	icd->rect_max.top	= 12;
	icd->rect_max.width	= 1280;
	icd->rect_max.height	= 1024;
	icd->rect_current.left	= 20;
	icd->rect_current.top	= 12;
	icd->width_min		= 48;
	icd->width_max	= 1280;
	icd->height_min		= 32;
	icd->height_max	= 1024;
	icd->y_skip_top		= 1;
	/* Simulated autoexposure. If enabled, we calculate shutter width
	 * ourselves in the driver based on vertical blanking and frame width */
+10 −10
Original line number Diff line number Diff line
@@ -949,14 +949,14 @@ static int mt9m111_probe(struct i2c_client *client,

	/* Second stage probe - when a capture adapter is there */
	icd->ops		= &mt9m111_ops;
	icd->x_min	= MT9M111_MIN_DARK_COLS;
	icd->y_min	= MT9M111_MIN_DARK_ROWS;
	icd->x_current	= icd->x_min;
	icd->y_current	= icd->y_min;
	icd->rect_max.left	= MT9M111_MIN_DARK_COLS;
	icd->rect_max.top	= MT9M111_MIN_DARK_ROWS;
	icd->rect_max.width	= MT9M111_MAX_WIDTH;
	icd->rect_max.height	= MT9M111_MAX_HEIGHT;
	icd->rect_current.left	= icd->rect_max.left;
	icd->rect_current.top	= icd->rect_max.top;
	icd->width_min		= MT9M111_MIN_DARK_ROWS;
	icd->width_max	= MT9M111_MAX_WIDTH;
	icd->height_min		= MT9M111_MIN_DARK_COLS;
	icd->height_max	= MT9M111_MAX_HEIGHT;
	icd->y_skip_top		= 0;

	ret = mt9m111_video_probe(icd, client);
+26 −23
Original line number Diff line number Diff line
@@ -222,12 +222,12 @@ static unsigned long mt9t031_query_bus_param(struct soc_camera_device *icd)
static void recalculate_limits(struct soc_camera_device *icd,
			       u16 xskip, u16 yskip)
{
	icd->x_min = (MT9T031_COLUMN_SKIP + xskip - 1) / xskip;
	icd->y_min = (MT9T031_ROW_SKIP + yskip - 1) / yskip;
	icd->rect_max.left = (MT9T031_COLUMN_SKIP + xskip - 1) / xskip;
	icd->rect_max.top = (MT9T031_ROW_SKIP + yskip - 1) / yskip;
	icd->width_min = (MT9T031_MIN_WIDTH + xskip - 1) / xskip;
	icd->height_min = (MT9T031_MIN_HEIGHT + yskip - 1) / yskip;
	icd->width_max = MT9T031_MAX_WIDTH / xskip;
	icd->height_max = MT9T031_MAX_HEIGHT / yskip;
	icd->rect_max.width = MT9T031_MAX_WIDTH / xskip;
	icd->rect_max.height = MT9T031_MAX_HEIGHT / yskip;
}

static int mt9t031_set_params(struct soc_camera_device *icd,
@@ -241,11 +241,13 @@ static int mt9t031_set_params(struct soc_camera_device *icd,
		vblank = MT9T031_VERTICAL_BLANK;

	/* Make sure we don't exceed sensor limits */
	if (rect->left + rect->width > icd->width_max)
		rect->left = (icd->width_max - rect->width) / 2 + icd->x_min;
	if (rect->left + rect->width > icd->rect_max.width)
		rect->left = (icd->rect_max.width - rect->width) / 2 +
			icd->rect_max.left;

	if (rect->top + rect->height > icd->height_max)
		rect->top = (icd->height_max - rect->height) / 2 + icd->y_min;
	if (rect->top + rect->height > icd->rect_max.height)
		rect->top = (icd->rect_max.height - rect->height) / 2 +
			icd->rect_max.top;

	width = rect->width * xskip;
	height = rect->height * yskip;
@@ -346,8 +348,8 @@ static int mt9t031_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
	int ret;
	u16 xskip, yskip;
	struct v4l2_rect rect = {
		.left	= icd->x_current,
		.top	= icd->y_current,
		.left	= icd->rect_current.left,
		.top	= icd->rect_current.top,
		.width	= f->fmt.pix.width,
		.height	= f->fmt.pix.height,
	};
@@ -618,11 +620,12 @@ static int mt9t031_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
		if (ctrl->value) {
			const u16 vblank = MT9T031_VERTICAL_BLANK;
			const u32 shutter_max = MT9T031_MAX_HEIGHT + vblank;
			if (set_shutter(client, icd->height +
			if (set_shutter(client, icd->rect_current.height +
					icd->y_skip_top + vblank) < 0)
				return -EIO;
			qctrl = soc_camera_find_qctrl(icd->ops, V4L2_CID_EXPOSURE);
			icd->exposure = (shutter_max / 2 + (icd->height +
			icd->exposure = (shutter_max / 2 +
					 (icd->rect_current.height +
					  icd->y_skip_top + vblank - 1) *
					 (qctrl->maximum - qctrl->minimum)) /
				shutter_max + qctrl->minimum;
@@ -727,14 +730,14 @@ static int mt9t031_probe(struct i2c_client *client,

	/* Second stage probe - when a capture adapter is there */
	icd->ops		= &mt9t031_ops;
	icd->x_min	= MT9T031_COLUMN_SKIP;
	icd->y_min	= MT9T031_ROW_SKIP;
	icd->x_current	= icd->x_min;
	icd->y_current	= icd->y_min;
	icd->rect_max.left	= MT9T031_COLUMN_SKIP;
	icd->rect_max.top	= MT9T031_ROW_SKIP;
	icd->rect_current.left	= icd->rect_max.left;
	icd->rect_current.top	= icd->rect_max.top;
	icd->width_min		= MT9T031_MIN_WIDTH;
	icd->width_max	= MT9T031_MAX_WIDTH;
	icd->rect_max.width	= MT9T031_MAX_WIDTH;
	icd->height_min		= MT9T031_MIN_HEIGHT;
	icd->height_max	= MT9T031_MAX_HEIGHT;
	icd->rect_max.height	= MT9T031_MAX_HEIGHT;
	icd->y_skip_top		= 0;
	/* Simulated autoexposure. If enabled, we calculate shutter width
	 * ourselves in the driver based on vertical blanking and frame width */
+12 −12
Original line number Diff line number Diff line
@@ -298,8 +298,8 @@ static int mt9v022_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
	struct soc_camera_device *icd = client->dev.platform_data;
	struct v4l2_pix_format *pix = &f->fmt.pix;
	struct v4l2_rect rect = {
		.left	= icd->x_current,
		.top	= icd->y_current,
		.left	= icd->rect_current.left,
		.top	= icd->rect_current.top,
		.width	= pix->width,
		.height	= pix->height,
	};
@@ -742,14 +742,14 @@ static int mt9v022_probe(struct i2c_client *client,
	mt9v022->chip_control = MT9V022_CHIP_CONTROL_DEFAULT;

	icd->ops		= &mt9v022_ops;
	icd->x_min	= 1;
	icd->y_min	= 4;
	icd->x_current	= 1;
	icd->y_current	= 4;
	icd->rect_max.left	= 1;
	icd->rect_max.top	= 4;
	icd->rect_max.width	= 752;
	icd->rect_max.height	= 480;
	icd->rect_current.left	= 1;
	icd->rect_current.top	= 4;
	icd->width_min		= 48;
	icd->width_max	= 752;
	icd->height_min		= 32;
	icd->height_max	= 480;
	icd->y_skip_top		= 1;

	ret = mt9v022_video_probe(icd, client);
+5 −5
Original line number Diff line number Diff line
@@ -126,7 +126,7 @@ static int mx1_videobuf_setup(struct videobuf_queue *vq, unsigned int *count,
{
	struct soc_camera_device *icd = vq->priv_data;

	*size = icd->width * icd->height *
	*size = icd->rect_current.width * icd->rect_current.height *
		((icd->current_fmt->depth + 7) >> 3);

	if (!*count)
@@ -178,12 +178,12 @@ static int mx1_videobuf_prepare(struct videobuf_queue *vq,
	buf->inwork = 1;

	if (buf->fmt	!= icd->current_fmt ||
	    vb->width	!= icd->width ||
	    vb->height	!= icd->height ||
	    vb->width	!= icd->rect_current.width ||
	    vb->height	!= icd->rect_current.height ||
	    vb->field	!= field) {
		buf->fmt	= icd->current_fmt;
		vb->width	= icd->width;
		vb->height	= icd->height;
		vb->width	= icd->rect_current.width;
		vb->height	= icd->rect_current.height;
		vb->field	= field;
		vb->state	= VIDEOBUF_NEEDS_INIT;
	}
Loading