Skip to content

Commit

Permalink
V4L/DVB (12529): soc-camera: switch to s_crop v4l2-subdev video opera…
Browse files Browse the repository at this point in the history
…tion

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: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Guennadi Liakhovetski authored and Mauro Carvalho Chehab committed Sep 19, 2009
1 parent 961801b commit 08590b9
Show file tree
Hide file tree
Showing 13 changed files with 142 additions and 139 deletions.
23 changes: 13 additions & 10 deletions drivers/media/video/mt9m001.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 = {
.left = icd->rect_current.left,
.top = icd->rect_current.top,
.width = f->fmt.pix.width,
.height = f->fmt.pix.height,
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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 = {
Expand Down
9 changes: 5 additions & 4 deletions drivers/media/video/mt9m111.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 = {
Expand Down
9 changes: 5 additions & 4 deletions drivers/media/video/mt9t031.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 = {
Expand Down
23 changes: 13 additions & 10 deletions drivers/media/video/mt9v022.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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 = {
.left = icd->rect_current.left,
.top = icd->rect_current.top,
.width = pix->width,
.height = pix->height,
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
Expand All @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 = {
Expand Down
8 changes: 6 additions & 2 deletions drivers/media/video/mx1_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions drivers/media/video/mx3_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,10 +781,13 @@ static int acquire_dma_channel(struct mx3_camera_dev *mx3_cam)
}

static int mx3_camera_set_crop(struct soc_camera_device *icd,
struct v4l2_rect *rect)
struct v4l2_crop *a)
{
struct v4l2_rect *rect = &a->c;
struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
struct mx3_camera_dev *mx3_cam = ici->priv;
struct device *control = to_soc_camera_control(icd);
struct v4l2_subdev *sd = dev_get_drvdata(control);

/*
* We now know pixel formats and can decide upon DMA-channel(s)
Expand All @@ -798,7 +801,7 @@ static int mx3_camera_set_crop(struct soc_camera_device *icd,

configure_geometry(mx3_cam, rect);

return icd->ops->set_crop(icd, rect);
return v4l2_subdev_call(sd, video, s_crop, a);
}

static int mx3_camera_set_fmt(struct soc_camera_device *icd,
Expand Down
19 changes: 0 additions & 19 deletions drivers/media/video/ov772x.c
Original file line number Diff line number Diff line change
Expand Up @@ -955,24 +955,6 @@ static int ov772x_set_params(struct i2c_client *client,
return ret;
}

/* Cannot crop, just return the current geometry */
static int ov772x_set_crop(struct soc_camera_device *icd,
struct v4l2_rect *rect)
{
struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
struct ov772x_priv *priv = to_ov772x(client);

if (!priv->fmt || !priv->win)
return -EINVAL;

rect->left = 0;
rect->top = 0;
rect->width = priv->win->width;
rect->height = priv->win->height;

return 0;
}

static int ov772x_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
{
struct i2c_client *client = sd->priv;
Expand Down Expand Up @@ -1060,7 +1042,6 @@ static int ov772x_video_probe(struct soc_camera_device *icd,
}

static struct soc_camera_ops ov772x_ops = {
.set_crop = ov772x_set_crop,
.set_bus_param = ov772x_set_bus_param,
.query_bus_param = ov772x_query_bus_param,
.controls = ov772x_controls,
Expand Down
7 changes: 5 additions & 2 deletions drivers/media/video/pxa_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -1281,10 +1281,13 @@ static int pxa_camera_get_formats(struct soc_camera_device *icd, int idx,
}

static int pxa_camera_set_crop(struct soc_camera_device *icd,
struct v4l2_rect *rect)
struct v4l2_crop *a)
{
struct v4l2_rect *rect = &a->c;
struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
struct pxa_camera_dev *pcdev = ici->priv;
struct device *control = to_soc_camera_control(icd);
struct v4l2_subdev *sd = dev_get_drvdata(control);
struct soc_camera_sense sense = {
.master_clock = pcdev->mclk,
.pixel_clock_max = pcdev->ciclk / 4,
Expand All @@ -1295,7 +1298,7 @@ static int pxa_camera_set_crop(struct soc_camera_device *icd,
if (pcdev->platform_flags & PXA_CAMERA_PCLK_EN)
icd->sense = &sense;

ret = icd->ops->set_crop(icd, rect);
ret = v4l2_subdev_call(sd, video, s_crop, a);

icd->sense = NULL;

Expand Down
Loading

0 comments on commit 08590b9

Please sign in to comment.