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

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

V4L/DVB (12529): soc-camera: switch to s_crop v4l2-subdev video operation



Remove set_crop soc-camera device method and switch to s_crop from v4l2-subdev
video operations. Also extend non-i2c drivers to also hold a pointer to their
v4l2-subdev instance in control device driver-data, i.e., in
dev_get_drvdata((struct device *)to_soc_camera_control(icd))

Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 961801bb
Loading
Loading
Loading
Loading
+13 −10
Original line number Diff line number Diff line
@@ -194,11 +194,12 @@ static unsigned long mt9m001_query_bus_param(struct soc_camera_device *icd)
	return soc_camera_apply_sensor_flags(icl, flags);
}

static int mt9m001_set_crop(struct soc_camera_device *icd,
			    struct v4l2_rect *rect)
static int mt9m001_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
{
	struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
	struct v4l2_rect *rect = &a->c;
	struct i2c_client *client = sd->priv;
	struct mt9m001 *mt9m001 = to_mt9m001(client);
	struct soc_camera_device *icd = client->dev.platform_data;
	int ret;
	const u16 hblank = 9, vblank = 25;

@@ -239,15 +240,17 @@ 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 = {
	struct v4l2_crop a = {
		.c = {
			.left	= icd->rect_current.left,
			.top	= icd->rect_current.top,
			.width	= f->fmt.pix.width,
			.height	= f->fmt.pix.height,
		},
	};

	/* No support for scaling so far, just crop. TODO: use skipping */
	return mt9m001_set_crop(icd, &rect);
	return mt9m001_s_crop(sd, &a);
}

static int mt9m001_try_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
@@ -361,7 +364,6 @@ static const struct v4l2_queryctrl mt9m001_controls[] = {
static struct soc_camera_ops mt9m001_ops = {
	.init			= mt9m001_init,
	.release		= mt9m001_release,
	.set_crop		= mt9m001_set_crop,
	.set_bus_param		= mt9m001_set_bus_param,
	.query_bus_param	= mt9m001_query_bus_param,
	.controls		= mt9m001_controls,
@@ -575,6 +577,7 @@ static struct v4l2_subdev_video_ops mt9m001_subdev_video_ops = {
	.s_stream	= mt9m001_s_stream,
	.s_fmt		= mt9m001_s_fmt,
	.try_fmt	= mt9m001_try_fmt,
	.s_crop		= mt9m001_s_crop,
};

static struct v4l2_subdev_ops mt9m001_subdev_ops = {
+5 −4
Original line number Diff line number Diff line
@@ -395,11 +395,12 @@ static int mt9m111_set_bus_param(struct soc_camera_device *icd, unsigned long f)
	return 0;
}

static int mt9m111_set_crop(struct soc_camera_device *icd,
			    struct v4l2_rect *rect)
static int mt9m111_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
{
	struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
	struct v4l2_rect *rect = &a->c;
	struct i2c_client *client = sd->priv;
	struct mt9m111 *mt9m111 = to_mt9m111(client);
	struct soc_camera_device *icd = client->dev.platform_data;
	int ret;

	dev_dbg(&icd->dev, "%s left=%d, top=%d, width=%d, height=%d\n",
@@ -601,7 +602,6 @@ static struct soc_camera_ops mt9m111_ops = {
	.init			= mt9m111_init,
	.resume			= mt9m111_resume,
	.release		= mt9m111_release,
	.set_crop		= mt9m111_set_crop,
	.query_bus_param	= mt9m111_query_bus_param,
	.set_bus_param		= mt9m111_set_bus_param,
	.controls		= mt9m111_controls,
@@ -908,6 +908,7 @@ static struct v4l2_subdev_core_ops mt9m111_subdev_core_ops = {
static struct v4l2_subdev_video_ops mt9m111_subdev_video_ops = {
	.s_fmt		= mt9m111_s_fmt,
	.try_fmt	= mt9m111_try_fmt,
	.s_crop		= mt9m111_s_crop,
};

static struct v4l2_subdev_ops mt9m111_subdev_ops = {
+5 −4
Original line number Diff line number Diff line
@@ -321,11 +321,12 @@ static int mt9t031_set_params(struct soc_camera_device *icd,
	return ret < 0 ? ret : 0;
}

static int mt9t031_set_crop(struct soc_camera_device *icd,
			    struct v4l2_rect *rect)
static int mt9t031_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
{
	struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
	struct v4l2_rect *rect = &a->c;
	struct i2c_client *client = sd->priv;
	struct mt9t031 *mt9t031 = to_mt9t031(client);
	struct soc_camera_device *icd = client->dev.platform_data;

	/* Make sure we don't exceed sensor limits */
	if (rect->left + rect->width > icd->rect_max.left + icd->rect_max.width)
@@ -495,7 +496,6 @@ static const struct v4l2_queryctrl mt9t031_controls[] = {
static struct soc_camera_ops mt9t031_ops = {
	.init			= mt9t031_init,
	.release		= mt9t031_release,
	.set_crop		= mt9t031_set_crop,
	.set_bus_param		= mt9t031_set_bus_param,
	.query_bus_param	= mt9t031_query_bus_param,
	.controls		= mt9t031_controls,
@@ -689,6 +689,7 @@ static struct v4l2_subdev_video_ops mt9t031_subdev_video_ops = {
	.s_stream	= mt9t031_s_stream,
	.s_fmt		= mt9t031_s_fmt,
	.try_fmt	= mt9t031_try_fmt,
	.s_crop		= mt9t031_s_crop,
};

static struct v4l2_subdev_ops mt9t031_subdev_ops = {
+13 −10
Original line number Diff line number Diff line
@@ -248,10 +248,11 @@ static unsigned long mt9v022_query_bus_param(struct soc_camera_device *icd)
		width_flag;
}

static int mt9v022_set_crop(struct soc_camera_device *icd,
			    struct v4l2_rect *rect)
static int mt9v022_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
{
	struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
	struct v4l2_rect *rect = &a->c;
	struct i2c_client *client = sd->priv;
	struct soc_camera_device *icd = client->dev.platform_data;
	int ret;

	/* Like in example app. Contradicts the datasheet though */
@@ -297,11 +298,13 @@ static int mt9v022_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
	struct mt9v022 *mt9v022 = to_mt9v022(client);
	struct soc_camera_device *icd = client->dev.platform_data;
	struct v4l2_pix_format *pix = &f->fmt.pix;
	struct v4l2_rect rect = {
	struct v4l2_crop a = {
		.c = {
			.left	= icd->rect_current.left,
			.top	= icd->rect_current.top,
			.width	= pix->width,
			.height	= pix->height,
		},
	};

	/* The caller provides a supported format, as verified per call to
@@ -325,7 +328,7 @@ static int mt9v022_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
	}

	/* No support for scaling on this camera, just crop. */
	return mt9v022_set_crop(icd, &rect);
	return mt9v022_s_crop(sd, &a);
}

static int mt9v022_try_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
@@ -454,7 +457,6 @@ static const struct v4l2_queryctrl mt9v022_controls[] = {

static struct soc_camera_ops mt9v022_ops = {
	.init			= mt9v022_init,
	.set_crop		= mt9v022_set_crop,
	.set_bus_param		= mt9v022_set_bus_param,
	.query_bus_param	= mt9v022_query_bus_param,
	.controls		= mt9v022_controls,
@@ -700,6 +702,7 @@ static struct v4l2_subdev_video_ops mt9v022_subdev_video_ops = {
	.s_stream	= mt9v022_s_stream,
	.s_fmt		= mt9v022_s_fmt,
	.try_fmt	= mt9v022_try_fmt,
	.s_crop		= mt9v022_s_crop,
};

static struct v4l2_subdev_ops mt9v022_subdev_ops = {
+6 −2
Original line number Diff line number Diff line
@@ -463,9 +463,13 @@ static void mx1_camera_remove_device(struct soc_camera_device *icd)
}

static int mx1_camera_set_crop(struct soc_camera_device *icd,
			       struct v4l2_rect *rect)
			       struct v4l2_crop *a)
{
	return icd->ops->set_crop(icd, rect);
	struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
	struct device *control = to_soc_camera_control(icd);
	struct v4l2_subdev *sd = dev_get_drvdata(control);

	return v4l2_subdev_call(sd, video, s_crop, a);
}

static int mx1_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt)
Loading