diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2009-12-11 09:14:46 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-12-16 06:27:13 -0500 |
commit | 325361088b73269f4cc96256276a142addbf3454 (patch) | |
tree | 6a18f4b10d1df53bfae4a773480fdadfad587b62 /drivers/media/video/mt9m001.c | |
parent | 11e3d1adbe0246fc8d6c06f7e42aff5bead25670 (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/mt9m001.c')
-rw-r--r-- | drivers/media/video/mt9m001.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/drivers/media/video/mt9m001.c b/drivers/media/video/mt9m001.c index 45388d2ce2fd..17be2d46fd40 100644 --- a/drivers/media/video/mt9m001.c +++ b/drivers/media/video/mt9m001.c | |||
@@ -82,6 +82,7 @@ struct mt9m001 { | |||
82 | int model; /* V4L2_IDENT_MT9M001* codes from v4l2-chip-ident.h */ | 82 | int model; /* V4L2_IDENT_MT9M001* codes from v4l2-chip-ident.h */ |
83 | unsigned int gain; | 83 | unsigned int gain; |
84 | unsigned int exposure; | 84 | unsigned int exposure; |
85 | unsigned short y_skip_top; /* Lines to skip at the top */ | ||
85 | unsigned char autoexposure; | 86 | unsigned char autoexposure; |
86 | }; | 87 | }; |
87 | 88 | ||
@@ -222,7 +223,7 @@ static int mt9m001_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a) | |||
222 | soc_camera_limit_side(&rect.top, &rect.height, | 223 | soc_camera_limit_side(&rect.top, &rect.height, |
223 | MT9M001_ROW_SKIP, MT9M001_MIN_HEIGHT, MT9M001_MAX_HEIGHT); | 224 | MT9M001_ROW_SKIP, MT9M001_MIN_HEIGHT, MT9M001_MAX_HEIGHT); |
224 | 225 | ||
225 | total_h = rect.height + icd->y_skip_top + vblank; | 226 | total_h = rect.height + mt9m001->y_skip_top + vblank; |
226 | 227 | ||
227 | /* Blanking and start values - default... */ | 228 | /* Blanking and start values - default... */ |
228 | ret = reg_write(client, MT9M001_HORIZONTAL_BLANKING, hblank); | 229 | ret = reg_write(client, MT9M001_HORIZONTAL_BLANKING, hblank); |
@@ -239,7 +240,7 @@ static int mt9m001_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a) | |||
239 | ret = reg_write(client, MT9M001_WINDOW_WIDTH, rect.width - 1); | 240 | ret = reg_write(client, MT9M001_WINDOW_WIDTH, rect.width - 1); |
240 | if (!ret) | 241 | if (!ret) |
241 | ret = reg_write(client, MT9M001_WINDOW_HEIGHT, | 242 | ret = reg_write(client, MT9M001_WINDOW_HEIGHT, |
242 | rect.height + icd->y_skip_top - 1); | 243 | rect.height + mt9m001->y_skip_top - 1); |
243 | if (!ret && mt9m001->autoexposure) { | 244 | if (!ret && mt9m001->autoexposure) { |
244 | ret = reg_write(client, MT9M001_SHUTTER_WIDTH, total_h); | 245 | ret = reg_write(client, MT9M001_SHUTTER_WIDTH, total_h); |
245 | if (!ret) { | 246 | if (!ret) { |
@@ -327,13 +328,13 @@ static int mt9m001_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) | |||
327 | static int mt9m001_try_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) | 328 | static int mt9m001_try_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) |
328 | { | 329 | { |
329 | struct i2c_client *client = sd->priv; | 330 | struct i2c_client *client = sd->priv; |
330 | struct soc_camera_device *icd = client->dev.platform_data; | 331 | struct mt9m001 *mt9m001 = to_mt9m001(client); |
331 | struct v4l2_pix_format *pix = &f->fmt.pix; | 332 | struct v4l2_pix_format *pix = &f->fmt.pix; |
332 | 333 | ||
333 | v4l_bound_align_image(&pix->width, MT9M001_MIN_WIDTH, | 334 | v4l_bound_align_image(&pix->width, MT9M001_MIN_WIDTH, |
334 | MT9M001_MAX_WIDTH, 1, | 335 | MT9M001_MAX_WIDTH, 1, |
335 | &pix->height, MT9M001_MIN_HEIGHT + icd->y_skip_top, | 336 | &pix->height, MT9M001_MIN_HEIGHT + mt9m001->y_skip_top, |
336 | MT9M001_MAX_HEIGHT + icd->y_skip_top, 0, 0); | 337 | MT9M001_MAX_HEIGHT + mt9m001->y_skip_top, 0, 0); |
337 | 338 | ||
338 | if (pix->pixelformat == V4L2_PIX_FMT_SBGGR8 || | 339 | if (pix->pixelformat == V4L2_PIX_FMT_SBGGR8 || |
339 | pix->pixelformat == V4L2_PIX_FMT_SBGGR16) | 340 | pix->pixelformat == V4L2_PIX_FMT_SBGGR16) |
@@ -552,7 +553,7 @@ static int mt9m001_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) | |||
552 | if (ctrl->value) { | 553 | if (ctrl->value) { |
553 | const u16 vblank = 25; | 554 | const u16 vblank = 25; |
554 | unsigned int total_h = mt9m001->rect.height + | 555 | unsigned int total_h = mt9m001->rect.height + |
555 | icd->y_skip_top + vblank; | 556 | mt9m001->y_skip_top + vblank; |
556 | if (reg_write(client, MT9M001_SHUTTER_WIDTH, | 557 | if (reg_write(client, MT9M001_SHUTTER_WIDTH, |
557 | total_h) < 0) | 558 | total_h) < 0) |
558 | return -EIO; | 559 | return -EIO; |
@@ -655,6 +656,16 @@ static void mt9m001_video_remove(struct soc_camera_device *icd) | |||
655 | icl->free_bus(icl); | 656 | icl->free_bus(icl); |
656 | } | 657 | } |
657 | 658 | ||
659 | static int mt9m001_g_skip_top_lines(struct v4l2_subdev *sd, u32 *lines) | ||
660 | { | ||
661 | struct i2c_client *client = sd->priv; | ||
662 | struct mt9m001 *mt9m001 = to_mt9m001(client); | ||
663 | |||
664 | *lines = mt9m001->y_skip_top; | ||
665 | |||
666 | return 0; | ||
667 | } | ||
668 | |||
658 | static struct v4l2_subdev_core_ops mt9m001_subdev_core_ops = { | 669 | static struct v4l2_subdev_core_ops mt9m001_subdev_core_ops = { |
659 | .g_ctrl = mt9m001_g_ctrl, | 670 | .g_ctrl = mt9m001_g_ctrl, |
660 | .s_ctrl = mt9m001_s_ctrl, | 671 | .s_ctrl = mt9m001_s_ctrl, |
@@ -675,9 +686,14 @@ static struct v4l2_subdev_video_ops mt9m001_subdev_video_ops = { | |||
675 | .cropcap = mt9m001_cropcap, | 686 | .cropcap = mt9m001_cropcap, |
676 | }; | 687 | }; |
677 | 688 | ||
689 | static struct v4l2_subdev_sensor_ops mt9m001_subdev_sensor_ops = { | ||
690 | .g_skip_top_lines = mt9m001_g_skip_top_lines, | ||
691 | }; | ||
692 | |||
678 | static struct v4l2_subdev_ops mt9m001_subdev_ops = { | 693 | static struct v4l2_subdev_ops mt9m001_subdev_ops = { |
679 | .core = &mt9m001_subdev_core_ops, | 694 | .core = &mt9m001_subdev_core_ops, |
680 | .video = &mt9m001_subdev_video_ops, | 695 | .video = &mt9m001_subdev_video_ops, |
696 | .sensor = &mt9m001_subdev_sensor_ops, | ||
681 | }; | 697 | }; |
682 | 698 | ||
683 | static int mt9m001_probe(struct i2c_client *client, | 699 | static int mt9m001_probe(struct i2c_client *client, |
@@ -714,8 +730,8 @@ static int mt9m001_probe(struct i2c_client *client, | |||
714 | 730 | ||
715 | /* Second stage probe - when a capture adapter is there */ | 731 | /* Second stage probe - when a capture adapter is there */ |
716 | icd->ops = &mt9m001_ops; | 732 | icd->ops = &mt9m001_ops; |
717 | icd->y_skip_top = 0; | ||
718 | 733 | ||
734 | mt9m001->y_skip_top = 0; | ||
719 | mt9m001->rect.left = MT9M001_COLUMN_SKIP; | 735 | mt9m001->rect.left = MT9M001_COLUMN_SKIP; |
720 | mt9m001->rect.top = MT9M001_ROW_SKIP; | 736 | mt9m001->rect.top = MT9M001_ROW_SKIP; |
721 | mt9m001->rect.width = MT9M001_MAX_WIDTH; | 737 | mt9m001->rect.width = MT9M001_MAX_WIDTH; |