aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/mt9v022.c
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2009-12-11 09:14:46 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-12-16 06:27:13 -0500
commit325361088b73269f4cc96256276a142addbf3454 (patch)
tree6a18f4b10d1df53bfae4a773480fdadfad587b62 /drivers/media/video/mt9v022.c
parent11e3d1adbe0246fc8d6c06f7e42aff5bead25670 (diff)
V4L/DVB (13644): v4l: add new v4l2-subdev sensor operations, use g_skip_top_lines in soc-camera
Introduce new v4l2-subdev sensor operations, move .enum_framesizes() and .enum_frameintervals() methods to it, add a new .g_skip_top_lines() method and switch soc-camera to use it instead of .y_skip_top soc_camera_device member, which can now be removed. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Reviewed-by: Hans Verkuil <hverkuil@xs4all.nl> Reviewed-by: Sergio Aguirre <saaguirre@ti.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/mt9v022.c')
-rw-r--r--drivers/media/video/mt9v022.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/drivers/media/video/mt9v022.c b/drivers/media/video/mt9v022.c
index 995607f9d3b..b71898f1b08 100644
--- a/drivers/media/video/mt9v022.c
+++ b/drivers/media/video/mt9v022.c
@@ -97,6 +97,7 @@ struct mt9v022 {
97 __u32 fourcc; 97 __u32 fourcc;
98 int model; /* V4L2_IDENT_MT9V022* codes from v4l2-chip-ident.h */ 98 int model; /* V4L2_IDENT_MT9V022* codes from v4l2-chip-ident.h */
99 u16 chip_control; 99 u16 chip_control;
100 unsigned short y_skip_top; /* Lines to skip at the top */
100}; 101};
101 102
102static struct mt9v022 *to_mt9v022(const struct i2c_client *client) 103static struct mt9v022 *to_mt9v022(const struct i2c_client *client)
@@ -265,7 +266,6 @@ static int mt9v022_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
265 struct i2c_client *client = sd->priv; 266 struct i2c_client *client = sd->priv;
266 struct mt9v022 *mt9v022 = to_mt9v022(client); 267 struct mt9v022 *mt9v022 = to_mt9v022(client);
267 struct v4l2_rect rect = a->c; 268 struct v4l2_rect rect = a->c;
268 struct soc_camera_device *icd = client->dev.platform_data;
269 int ret; 269 int ret;
270 270
271 /* Bayer format - even size lengths */ 271 /* Bayer format - even size lengths */
@@ -287,10 +287,10 @@ static int mt9v022_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
287 if (ret >= 0) { 287 if (ret >= 0) {
288 if (ret & 1) /* Autoexposure */ 288 if (ret & 1) /* Autoexposure */
289 ret = reg_write(client, MT9V022_MAX_TOTAL_SHUTTER_WIDTH, 289 ret = reg_write(client, MT9V022_MAX_TOTAL_SHUTTER_WIDTH,
290 rect.height + icd->y_skip_top + 43); 290 rect.height + mt9v022->y_skip_top + 43);
291 else 291 else
292 ret = reg_write(client, MT9V022_TOTAL_SHUTTER_WIDTH, 292 ret = reg_write(client, MT9V022_TOTAL_SHUTTER_WIDTH,
293 rect.height + icd->y_skip_top + 43); 293 rect.height + mt9v022->y_skip_top + 43);
294 } 294 }
295 /* Setup frame format: defaults apart from width and height */ 295 /* Setup frame format: defaults apart from width and height */
296 if (!ret) 296 if (!ret)
@@ -309,7 +309,7 @@ static int mt9v022_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
309 ret = reg_write(client, MT9V022_WINDOW_WIDTH, rect.width); 309 ret = reg_write(client, MT9V022_WINDOW_WIDTH, rect.width);
310 if (!ret) 310 if (!ret)
311 ret = reg_write(client, MT9V022_WINDOW_HEIGHT, 311 ret = reg_write(client, MT9V022_WINDOW_HEIGHT,
312 rect.height + icd->y_skip_top); 312 rect.height + mt9v022->y_skip_top);
313 313
314 if (ret < 0) 314 if (ret < 0)
315 return ret; 315 return ret;
@@ -410,15 +410,15 @@ static int mt9v022_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
410static int mt9v022_try_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) 410static int mt9v022_try_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
411{ 411{
412 struct i2c_client *client = sd->priv; 412 struct i2c_client *client = sd->priv;
413 struct soc_camera_device *icd = client->dev.platform_data; 413 struct mt9v022 *mt9v022 = to_mt9v022(client);
414 struct v4l2_pix_format *pix = &f->fmt.pix; 414 struct v4l2_pix_format *pix = &f->fmt.pix;
415 int align = pix->pixelformat == V4L2_PIX_FMT_SBGGR8 || 415 int align = pix->pixelformat == V4L2_PIX_FMT_SBGGR8 ||
416 pix->pixelformat == V4L2_PIX_FMT_SBGGR16; 416 pix->pixelformat == V4L2_PIX_FMT_SBGGR16;
417 417
418 v4l_bound_align_image(&pix->width, MT9V022_MIN_WIDTH, 418 v4l_bound_align_image(&pix->width, MT9V022_MIN_WIDTH,
419 MT9V022_MAX_WIDTH, align, 419 MT9V022_MAX_WIDTH, align,
420 &pix->height, MT9V022_MIN_HEIGHT + icd->y_skip_top, 420 &pix->height, MT9V022_MIN_HEIGHT + mt9v022->y_skip_top,
421 MT9V022_MAX_HEIGHT + icd->y_skip_top, align, 0); 421 MT9V022_MAX_HEIGHT + mt9v022->y_skip_top, align, 0);
422 422
423 return 0; 423 return 0;
424} 424}
@@ -787,6 +787,16 @@ static void mt9v022_video_remove(struct soc_camera_device *icd)
787 icl->free_bus(icl); 787 icl->free_bus(icl);
788} 788}
789 789
790static int mt9v022_g_skip_top_lines(struct v4l2_subdev *sd, u32 *lines)
791{
792 struct i2c_client *client = sd->priv;
793 struct mt9v022 *mt9v022 = to_mt9v022(client);
794
795 *lines = mt9v022->y_skip_top;
796
797 return 0;
798}
799
790static struct v4l2_subdev_core_ops mt9v022_subdev_core_ops = { 800static struct v4l2_subdev_core_ops mt9v022_subdev_core_ops = {
791 .g_ctrl = mt9v022_g_ctrl, 801 .g_ctrl = mt9v022_g_ctrl,
792 .s_ctrl = mt9v022_s_ctrl, 802 .s_ctrl = mt9v022_s_ctrl,
@@ -807,9 +817,14 @@ static struct v4l2_subdev_video_ops mt9v022_subdev_video_ops = {
807 .cropcap = mt9v022_cropcap, 817 .cropcap = mt9v022_cropcap,
808}; 818};
809 819
820static struct v4l2_subdev_sensor_ops mt9v022_subdev_sensor_ops = {
821 .g_skip_top_lines = mt9v022_g_skip_top_lines,
822};
823
810static struct v4l2_subdev_ops mt9v022_subdev_ops = { 824static struct v4l2_subdev_ops mt9v022_subdev_ops = {
811 .core = &mt9v022_subdev_core_ops, 825 .core = &mt9v022_subdev_core_ops,
812 .video = &mt9v022_subdev_video_ops, 826 .video = &mt9v022_subdev_video_ops,
827 .sensor = &mt9v022_subdev_sensor_ops,
813}; 828};
814 829
815static int mt9v022_probe(struct i2c_client *client, 830static int mt9v022_probe(struct i2c_client *client,
@@ -851,8 +866,7 @@ static int mt9v022_probe(struct i2c_client *client,
851 * MT9V022 _really_ corrupts the first read out line. 866 * MT9V022 _really_ corrupts the first read out line.
852 * TODO: verify on i.MX31 867 * TODO: verify on i.MX31
853 */ 868 */
854 icd->y_skip_top = 1; 869 mt9v022->y_skip_top = 1;
855
856 mt9v022->rect.left = MT9V022_COLUMN_SKIP; 870 mt9v022->rect.left = MT9V022_COLUMN_SKIP;
857 mt9v022->rect.top = MT9V022_ROW_SKIP; 871 mt9v022->rect.top = MT9V022_ROW_SKIP;
858 mt9v022->rect.width = MT9V022_MAX_WIDTH; 872 mt9v022->rect.width = MT9V022_MAX_WIDTH;