aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/mt9m001.c
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2009-08-25 10:53:23 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-09-18 23:19:20 -0400
commit96c75399544838e1752001c8abdde36dd459cf8f (patch)
treead2dfa46e1f83d3b9b3de07f835618b15b90b0a5 /drivers/media/video/mt9m001.c
parenta4c56fd8892e51d675f7665ddee4fd9d7e5c2cc3 (diff)
V4L/DVB (12536): soc-camera: remove .gain and .exposure struct soc_camera_device members
This makes the soc-camera interface for V4L2 subdevices thinner yet. Handle gain and exposure internally in each driver just like all other controls. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/mt9m001.c')
-rw-r--r--drivers/media/video/mt9m001.c43
1 files changed, 28 insertions, 15 deletions
diff --git a/drivers/media/video/mt9m001.c b/drivers/media/video/mt9m001.c
index 4b394798a293..45388d2ce2fd 100644
--- a/drivers/media/video/mt9m001.c
+++ b/drivers/media/video/mt9m001.c
@@ -80,6 +80,8 @@ struct mt9m001 {
80 struct v4l2_rect rect; /* Sensor window */ 80 struct v4l2_rect rect; /* Sensor window */
81 __u32 fourcc; 81 __u32 fourcc;
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;
84 unsigned int exposure;
83 unsigned char autoexposure; 85 unsigned char autoexposure;
84}; 86};
85 87
@@ -129,8 +131,8 @@ static int mt9m001_init(struct i2c_client *client)
129 dev_dbg(&client->dev, "%s\n", __func__); 131 dev_dbg(&client->dev, "%s\n", __func__);
130 132
131 /* 133 /*
132 * We don't know, whether platform provides reset, 134 * We don't know, whether platform provides reset, issue a soft reset
133 * issue a soft reset too 135 * too. This returns all registers to their default values.
134 */ 136 */
135 ret = reg_write(client, MT9M001_RESET, 1); 137 ret = reg_write(client, MT9M001_RESET, 1);
136 if (!ret) 138 if (!ret)
@@ -200,6 +202,7 @@ static int mt9m001_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
200 struct soc_camera_device *icd = client->dev.platform_data; 202 struct soc_camera_device *icd = client->dev.platform_data;
201 int ret; 203 int ret;
202 const u16 hblank = 9, vblank = 25; 204 const u16 hblank = 9, vblank = 25;
205 unsigned int total_h;
203 206
204 if (mt9m001->fourcc == V4L2_PIX_FMT_SBGGR8 || 207 if (mt9m001->fourcc == V4L2_PIX_FMT_SBGGR8 ||
205 mt9m001->fourcc == V4L2_PIX_FMT_SBGGR16) 208 mt9m001->fourcc == V4L2_PIX_FMT_SBGGR16)
@@ -219,6 +222,8 @@ static int mt9m001_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
219 soc_camera_limit_side(&rect.top, &rect.height, 222 soc_camera_limit_side(&rect.top, &rect.height,
220 MT9M001_ROW_SKIP, MT9M001_MIN_HEIGHT, MT9M001_MAX_HEIGHT); 223 MT9M001_ROW_SKIP, MT9M001_MIN_HEIGHT, MT9M001_MAX_HEIGHT);
221 224
225 total_h = rect.height + icd->y_skip_top + vblank;
226
222 /* Blanking and start values - default... */ 227 /* Blanking and start values - default... */
223 ret = reg_write(client, MT9M001_HORIZONTAL_BLANKING, hblank); 228 ret = reg_write(client, MT9M001_HORIZONTAL_BLANKING, hblank);
224 if (!ret) 229 if (!ret)
@@ -236,15 +241,13 @@ static int mt9m001_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
236 ret = reg_write(client, MT9M001_WINDOW_HEIGHT, 241 ret = reg_write(client, MT9M001_WINDOW_HEIGHT,
237 rect.height + icd->y_skip_top - 1); 242 rect.height + icd->y_skip_top - 1);
238 if (!ret && mt9m001->autoexposure) { 243 if (!ret && mt9m001->autoexposure) {
239 ret = reg_write(client, MT9M001_SHUTTER_WIDTH, 244 ret = reg_write(client, MT9M001_SHUTTER_WIDTH, total_h);
240 rect.height + icd->y_skip_top + vblank);
241 if (!ret) { 245 if (!ret) {
242 const struct v4l2_queryctrl *qctrl = 246 const struct v4l2_queryctrl *qctrl =
243 soc_camera_find_qctrl(icd->ops, 247 soc_camera_find_qctrl(icd->ops,
244 V4L2_CID_EXPOSURE); 248 V4L2_CID_EXPOSURE);
245 icd->exposure = (524 + (rect.height + icd->y_skip_top + 249 mt9m001->exposure = (524 + (total_h - 1) *
246 vblank - 1) * 250 (qctrl->maximum - qctrl->minimum)) /
247 (qctrl->maximum - qctrl->minimum)) /
248 1048 + qctrl->minimum; 251 1048 + qctrl->minimum;
249 } 252 }
250 } 253 }
@@ -457,6 +460,12 @@ static int mt9m001_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
457 case V4L2_CID_EXPOSURE_AUTO: 460 case V4L2_CID_EXPOSURE_AUTO:
458 ctrl->value = mt9m001->autoexposure; 461 ctrl->value = mt9m001->autoexposure;
459 break; 462 break;
463 case V4L2_CID_GAIN:
464 ctrl->value = mt9m001->gain;
465 break;
466 case V4L2_CID_EXPOSURE:
467 ctrl->value = mt9m001->exposure;
468 break;
460 } 469 }
461 return 0; 470 return 0;
462} 471}
@@ -518,7 +527,7 @@ static int mt9m001_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
518 } 527 }
519 528
520 /* Success */ 529 /* Success */
521 icd->gain = ctrl->value; 530 mt9m001->gain = ctrl->value;
522 break; 531 break;
523 case V4L2_CID_EXPOSURE: 532 case V4L2_CID_EXPOSURE:
524 /* mt9m001 has maximum == default */ 533 /* mt9m001 has maximum == default */
@@ -535,21 +544,21 @@ static int mt9m001_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
535 shutter); 544 shutter);
536 if (reg_write(client, MT9M001_SHUTTER_WIDTH, shutter) < 0) 545 if (reg_write(client, MT9M001_SHUTTER_WIDTH, shutter) < 0)
537 return -EIO; 546 return -EIO;
538 icd->exposure = ctrl->value; 547 mt9m001->exposure = ctrl->value;
539 mt9m001->autoexposure = 0; 548 mt9m001->autoexposure = 0;
540 } 549 }
541 break; 550 break;
542 case V4L2_CID_EXPOSURE_AUTO: 551 case V4L2_CID_EXPOSURE_AUTO:
543 if (ctrl->value) { 552 if (ctrl->value) {
544 const u16 vblank = 25; 553 const u16 vblank = 25;
554 unsigned int total_h = mt9m001->rect.height +
555 icd->y_skip_top + vblank;
545 if (reg_write(client, MT9M001_SHUTTER_WIDTH, 556 if (reg_write(client, MT9M001_SHUTTER_WIDTH,
546 mt9m001->rect.height + 557 total_h) < 0)
547 icd->y_skip_top + vblank) < 0)
548 return -EIO; 558 return -EIO;
549 qctrl = soc_camera_find_qctrl(icd->ops, V4L2_CID_EXPOSURE); 559 qctrl = soc_camera_find_qctrl(icd->ops, V4L2_CID_EXPOSURE);
550 icd->exposure = (524 + (mt9m001->rect.height + 560 mt9m001->exposure = (524 + (total_h - 1) *
551 icd->y_skip_top + vblank - 1) * 561 (qctrl->maximum - qctrl->minimum)) /
552 (qctrl->maximum - qctrl->minimum)) /
553 1048 + qctrl->minimum; 562 1048 + qctrl->minimum;
554 mt9m001->autoexposure = 1; 563 mt9m001->autoexposure = 1;
555 } else 564 } else
@@ -629,6 +638,10 @@ static int mt9m001_video_probe(struct soc_camera_device *icd,
629 if (ret < 0) 638 if (ret < 0)
630 dev_err(&client->dev, "Failed to initialise the camera\n"); 639 dev_err(&client->dev, "Failed to initialise the camera\n");
631 640
641 /* mt9m001_init() has reset the chip, returning registers to defaults */
642 mt9m001->gain = 64;
643 mt9m001->exposure = 255;
644
632 return ret; 645 return ret;
633} 646}
634 647
@@ -701,7 +714,7 @@ static int mt9m001_probe(struct i2c_client *client,
701 714
702 /* Second stage probe - when a capture adapter is there */ 715 /* Second stage probe - when a capture adapter is there */
703 icd->ops = &mt9m001_ops; 716 icd->ops = &mt9m001_ops;
704 icd->y_skip_top = 1; 717 icd->y_skip_top = 0;
705 718
706 mt9m001->rect.left = MT9M001_COLUMN_SKIP; 719 mt9m001->rect.left = MT9M001_COLUMN_SKIP;
707 mt9m001->rect.top = MT9M001_ROW_SKIP; 720 mt9m001->rect.top = MT9M001_ROW_SKIP;