aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/mt9v022.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-10-13 17:03:59 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-13 17:03:59 -0400
commitcf2fa66055d718ae13e62451bb546505f63906a2 (patch)
treee206d3f04e74a34e9aa88d21af6c26eea21d4121 /drivers/media/video/mt9v022.c
parent4501a466f28788485604ee42641d7a5fe7258d16 (diff)
parent57f51dbc45f65f7ee1e8c8f77200bb8000e3e271 (diff)
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6
* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6: (313 commits) V4L/DVB (9186): Added support for Prof 7300 DVB-S/S2 cards V4L/DVB (9185): S2API: Ensure we have a reasonable ROLLOFF default V4L/DVB (9184): cx24116: Change the default SNR units back to percentage by default. V4L/DVB (9183): S2API: Return error of the caller provides 0 commands. V4L/DVB (9182): S2API: Added support for DTV_HIERARCHY V4L/DVB (9181): S2API: Add support fot DTV_GUARD_INTERVAL and DTV_TRANSMISSION_MODE V4L/DVB (9180): S2API: Added support for DTV_CODE_RATE_HP/LP V4L/DVB (9179): S2API: frontend.h cleanup V4L/DVB (9178): cx24116: Add module parameter to return SNR as ESNO. V4L/DVB (9177): S2API: Change _8PSK / _16APSK to PSK_8 and APSK_16 V4L/DVB (9176): Add support for DvbWorld USB cards with STV0288 demodulator. V4L/DVB (9175): Remove NULL pointer in stb6000 driver. V4L/DVB (9174): Allow custom inittab for ST STV0288 demodulator. V4L/DVB (9173): S2API: Remove the hardcoded command limit during validation V4L/DVB (9172): S2API: Bugfix related to DVB-S / DVB-S2 tuning for the legacy API. V4L/DVB (9171): S2API: Stop an OOPS if illegal commands are dumped in S2API. V4L/DVB (9170): cx24116: Sanity checking to data input via S2API to the cx24116 demod. V4L/DVB (9169): uvcvideo: Support two new Bison Electronics webcams. V4L/DVB (9168): Add support for MSI TV@nywhere Plus remote V4L/DVB: v4l2-dev: remove duplicated #include ...
Diffstat (limited to 'drivers/media/video/mt9v022.c')
-rw-r--r--drivers/media/video/mt9v022.c52
1 files changed, 37 insertions, 15 deletions
diff --git a/drivers/media/video/mt9v022.c b/drivers/media/video/mt9v022.c
index 56808cd2f8a9..2584201059d8 100644
--- a/drivers/media/video/mt9v022.c
+++ b/drivers/media/video/mt9v022.c
@@ -134,34 +134,56 @@ static int reg_clear(struct soc_camera_device *icd, const u8 reg,
134static int mt9v022_init(struct soc_camera_device *icd) 134static int mt9v022_init(struct soc_camera_device *icd)
135{ 135{
136 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); 136 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
137 struct soc_camera_link *icl = mt9v022->client->dev.platform_data;
137 int ret; 138 int ret;
138 139
140 if (icl->power) {
141 ret = icl->power(&mt9v022->client->dev, 1);
142 if (ret < 0) {
143 dev_err(icd->vdev->parent,
144 "Platform failed to power-on the camera.\n");
145 return ret;
146 }
147 }
148
149 /*
150 * The camera could have been already on, we hard-reset it additionally,
151 * if available. Soft reset is done in video_probe().
152 */
153 if (icl->reset)
154 icl->reset(&mt9v022->client->dev);
155
139 /* Almost the default mode: master, parallel, simultaneous, and an 156 /* Almost the default mode: master, parallel, simultaneous, and an
140 * undocumented bit 0x200, which is present in table 7, but not in 8, 157 * undocumented bit 0x200, which is present in table 7, but not in 8,
141 * plus snapshot mode to disable scan for now */ 158 * plus snapshot mode to disable scan for now */
142 mt9v022->chip_control |= 0x10; 159 mt9v022->chip_control |= 0x10;
143 ret = reg_write(icd, MT9V022_CHIP_CONTROL, mt9v022->chip_control); 160 ret = reg_write(icd, MT9V022_CHIP_CONTROL, mt9v022->chip_control);
144 if (ret >= 0) 161 if (!ret)
145 reg_write(icd, MT9V022_READ_MODE, 0x300); 162 ret = reg_write(icd, MT9V022_READ_MODE, 0x300);
146 163
147 /* All defaults */ 164 /* All defaults */
148 if (ret >= 0) 165 if (!ret)
149 /* AEC, AGC on */ 166 /* AEC, AGC on */
150 ret = reg_set(icd, MT9V022_AEC_AGC_ENABLE, 0x3); 167 ret = reg_set(icd, MT9V022_AEC_AGC_ENABLE, 0x3);
151 if (ret >= 0) 168 if (!ret)
152 ret = reg_write(icd, MT9V022_MAX_TOTAL_SHUTTER_WIDTH, 480); 169 ret = reg_write(icd, MT9V022_MAX_TOTAL_SHUTTER_WIDTH, 480);
153 if (ret >= 0) 170 if (!ret)
154 /* default - auto */ 171 /* default - auto */
155 ret = reg_clear(icd, MT9V022_BLACK_LEVEL_CALIB_CTRL, 1); 172 ret = reg_clear(icd, MT9V022_BLACK_LEVEL_CALIB_CTRL, 1);
156 if (ret >= 0) 173 if (!ret)
157 ret = reg_write(icd, MT9V022_DIGITAL_TEST_PATTERN, 0); 174 ret = reg_write(icd, MT9V022_DIGITAL_TEST_PATTERN, 0);
158 175
159 return ret >= 0 ? 0 : -EIO; 176 return ret;
160} 177}
161 178
162static int mt9v022_release(struct soc_camera_device *icd) 179static int mt9v022_release(struct soc_camera_device *icd)
163{ 180{
164 /* Nothing? */ 181 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
182 struct soc_camera_link *icl = mt9v022->client->dev.platform_data;
183
184 if (icl->power)
185 icl->power(&mt9v022->client->dev, 0);
186
165 return 0; 187 return 0;
166} 188}
167 189
@@ -352,21 +374,21 @@ static int mt9v022_set_fmt_cap(struct soc_camera_device *icd,
352 rect->height + icd->y_skip_top + 43); 374 rect->height + icd->y_skip_top + 43);
353 } 375 }
354 /* Setup frame format: defaults apart from width and height */ 376 /* Setup frame format: defaults apart from width and height */
355 if (ret >= 0) 377 if (!ret)
356 ret = reg_write(icd, MT9V022_COLUMN_START, rect->left); 378 ret = reg_write(icd, MT9V022_COLUMN_START, rect->left);
357 if (ret >= 0) 379 if (!ret)
358 ret = reg_write(icd, MT9V022_ROW_START, rect->top); 380 ret = reg_write(icd, MT9V022_ROW_START, rect->top);
359 if (ret >= 0) 381 if (!ret)
360 /* Default 94, Phytec driver says: 382 /* Default 94, Phytec driver says:
361 * "width + horizontal blank >= 660" */ 383 * "width + horizontal blank >= 660" */
362 ret = reg_write(icd, MT9V022_HORIZONTAL_BLANKING, 384 ret = reg_write(icd, MT9V022_HORIZONTAL_BLANKING,
363 rect->width > 660 - 43 ? 43 : 385 rect->width > 660 - 43 ? 43 :
364 660 - rect->width); 386 660 - rect->width);
365 if (ret >= 0) 387 if (!ret)
366 ret = reg_write(icd, MT9V022_VERTICAL_BLANKING, 45); 388 ret = reg_write(icd, MT9V022_VERTICAL_BLANKING, 45);
367 if (ret >= 0) 389 if (!ret)
368 ret = reg_write(icd, MT9V022_WINDOW_WIDTH, rect->width); 390 ret = reg_write(icd, MT9V022_WINDOW_WIDTH, rect->width);
369 if (ret >= 0) 391 if (!ret)
370 ret = reg_write(icd, MT9V022_WINDOW_HEIGHT, 392 ret = reg_write(icd, MT9V022_WINDOW_HEIGHT,
371 rect->height + icd->y_skip_top); 393 rect->height + icd->y_skip_top);
372 394
@@ -717,7 +739,7 @@ static int mt9v022_video_probe(struct soc_camera_device *icd)
717 icd->num_formats = 1; 739 icd->num_formats = 1;
718 } 740 }
719 741
720 if (ret >= 0) 742 if (!ret)
721 ret = soc_camera_video_start(icd); 743 ret = soc_camera_video_start(icd);
722 if (ret < 0) 744 if (ret < 0)
723 goto eisis; 745 goto eisis;