diff options
Diffstat (limited to 'drivers/media/video/mt9m001.c')
-rw-r--r-- | drivers/media/video/mt9m001.c | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/drivers/media/video/mt9m001.c b/drivers/media/video/mt9m001.c index 0c524376b67e..1a1a12453672 100644 --- a/drivers/media/video/mt9m001.c +++ b/drivers/media/video/mt9m001.c | |||
@@ -272,21 +272,20 @@ static int mt9m001_set_bus_param(struct soc_camera_device *icd, | |||
272 | static unsigned long mt9m001_query_bus_param(struct soc_camera_device *icd) | 272 | static unsigned long mt9m001_query_bus_param(struct soc_camera_device *icd) |
273 | { | 273 | { |
274 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); | 274 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); |
275 | unsigned int width_flag = SOCAM_DATAWIDTH_10; | 275 | struct soc_camera_link *icl = mt9m001->client->dev.platform_data; |
276 | /* MT9M001 has all capture_format parameters fixed */ | ||
277 | unsigned long flags = SOCAM_DATAWIDTH_10 | SOCAM_PCLK_SAMPLE_RISING | | ||
278 | SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_HIGH | | ||
279 | SOCAM_MASTER; | ||
276 | 280 | ||
277 | if (bus_switch_possible(mt9m001)) | 281 | if (bus_switch_possible(mt9m001)) |
278 | width_flag |= SOCAM_DATAWIDTH_8; | 282 | flags |= SOCAM_DATAWIDTH_8; |
279 | 283 | ||
280 | /* MT9M001 has all capture_format parameters fixed */ | 284 | return soc_camera_apply_sensor_flags(icl, flags); |
281 | return SOCAM_PCLK_SAMPLE_RISING | | ||
282 | SOCAM_HSYNC_ACTIVE_HIGH | | ||
283 | SOCAM_VSYNC_ACTIVE_HIGH | | ||
284 | SOCAM_MASTER | | ||
285 | width_flag; | ||
286 | } | 285 | } |
287 | 286 | ||
288 | static int mt9m001_set_fmt_cap(struct soc_camera_device *icd, | 287 | static int mt9m001_set_fmt(struct soc_camera_device *icd, |
289 | __u32 pixfmt, struct v4l2_rect *rect) | 288 | __u32 pixfmt, struct v4l2_rect *rect) |
290 | { | 289 | { |
291 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); | 290 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); |
292 | int ret; | 291 | int ret; |
@@ -298,7 +297,7 @@ static int mt9m001_set_fmt_cap(struct soc_camera_device *icd, | |||
298 | ret = reg_write(icd, MT9M001_VERTICAL_BLANKING, vblank); | 297 | ret = reg_write(icd, MT9M001_VERTICAL_BLANKING, vblank); |
299 | 298 | ||
300 | /* The caller provides a supported format, as verified per | 299 | /* The caller provides a supported format, as verified per |
301 | * call to icd->try_fmt_cap() */ | 300 | * call to icd->try_fmt() */ |
302 | if (!ret) | 301 | if (!ret) |
303 | ret = reg_write(icd, MT9M001_COLUMN_START, rect->left); | 302 | ret = reg_write(icd, MT9M001_COLUMN_START, rect->left); |
304 | if (!ret) | 303 | if (!ret) |
@@ -325,18 +324,20 @@ static int mt9m001_set_fmt_cap(struct soc_camera_device *icd, | |||
325 | return ret; | 324 | return ret; |
326 | } | 325 | } |
327 | 326 | ||
328 | static int mt9m001_try_fmt_cap(struct soc_camera_device *icd, | 327 | static int mt9m001_try_fmt(struct soc_camera_device *icd, |
329 | struct v4l2_format *f) | 328 | struct v4l2_format *f) |
330 | { | 329 | { |
331 | if (f->fmt.pix.height < 32 + icd->y_skip_top) | 330 | struct v4l2_pix_format *pix = &f->fmt.pix; |
332 | f->fmt.pix.height = 32 + icd->y_skip_top; | 331 | |
333 | if (f->fmt.pix.height > 1024 + icd->y_skip_top) | 332 | if (pix->height < 32 + icd->y_skip_top) |
334 | f->fmt.pix.height = 1024 + icd->y_skip_top; | 333 | pix->height = 32 + icd->y_skip_top; |
335 | if (f->fmt.pix.width < 48) | 334 | if (pix->height > 1024 + icd->y_skip_top) |
336 | f->fmt.pix.width = 48; | 335 | pix->height = 1024 + icd->y_skip_top; |
337 | if (f->fmt.pix.width > 1280) | 336 | if (pix->width < 48) |
338 | f->fmt.pix.width = 1280; | 337 | pix->width = 48; |
339 | f->fmt.pix.width &= ~0x01; /* has to be even, unsure why was ~3 */ | 338 | if (pix->width > 1280) |
339 | pix->width = 1280; | ||
340 | pix->width &= ~0x01; /* has to be even, unsure why was ~3 */ | ||
340 | 341 | ||
341 | return 0; | 342 | return 0; |
342 | } | 343 | } |
@@ -447,8 +448,8 @@ static struct soc_camera_ops mt9m001_ops = { | |||
447 | .release = mt9m001_release, | 448 | .release = mt9m001_release, |
448 | .start_capture = mt9m001_start_capture, | 449 | .start_capture = mt9m001_start_capture, |
449 | .stop_capture = mt9m001_stop_capture, | 450 | .stop_capture = mt9m001_stop_capture, |
450 | .set_fmt_cap = mt9m001_set_fmt_cap, | 451 | .set_fmt = mt9m001_set_fmt, |
451 | .try_fmt_cap = mt9m001_try_fmt_cap, | 452 | .try_fmt = mt9m001_try_fmt, |
452 | .set_bus_param = mt9m001_set_bus_param, | 453 | .set_bus_param = mt9m001_set_bus_param, |
453 | .query_bus_param = mt9m001_query_bus_param, | 454 | .query_bus_param = mt9m001_query_bus_param, |
454 | .controls = mt9m001_controls, | 455 | .controls = mt9m001_controls, |
@@ -578,6 +579,7 @@ static int mt9m001_set_control(struct soc_camera_device *icd, struct v4l2_contro | |||
578 | static int mt9m001_video_probe(struct soc_camera_device *icd) | 579 | static int mt9m001_video_probe(struct soc_camera_device *icd) |
579 | { | 580 | { |
580 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); | 581 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); |
582 | struct soc_camera_link *icl = mt9m001->client->dev.platform_data; | ||
581 | s32 data; | 583 | s32 data; |
582 | int ret; | 584 | int ret; |
583 | 585 | ||
@@ -588,7 +590,7 @@ static int mt9m001_video_probe(struct soc_camera_device *icd) | |||
588 | return -ENODEV; | 590 | return -ENODEV; |
589 | 591 | ||
590 | /* Enable the chip */ | 592 | /* Enable the chip */ |
591 | data = reg_write(&mt9m001->icd, MT9M001_CHIP_ENABLE, 1); | 593 | data = reg_write(icd, MT9M001_CHIP_ENABLE, 1); |
592 | dev_dbg(&icd->dev, "write: %d\n", data); | 594 | dev_dbg(&icd->dev, "write: %d\n", data); |
593 | 595 | ||
594 | /* Read out the chip version register */ | 596 | /* Read out the chip version register */ |
@@ -600,7 +602,7 @@ static int mt9m001_video_probe(struct soc_camera_device *icd) | |||
600 | case 0x8421: | 602 | case 0x8421: |
601 | mt9m001->model = V4L2_IDENT_MT9M001C12ST; | 603 | mt9m001->model = V4L2_IDENT_MT9M001C12ST; |
602 | icd->formats = mt9m001_colour_formats; | 604 | icd->formats = mt9m001_colour_formats; |
603 | if (mt9m001->client->dev.platform_data) | 605 | if (gpio_is_valid(icl->gpio)) |
604 | icd->num_formats = ARRAY_SIZE(mt9m001_colour_formats); | 606 | icd->num_formats = ARRAY_SIZE(mt9m001_colour_formats); |
605 | else | 607 | else |
606 | icd->num_formats = 1; | 608 | icd->num_formats = 1; |
@@ -608,7 +610,7 @@ static int mt9m001_video_probe(struct soc_camera_device *icd) | |||
608 | case 0x8431: | 610 | case 0x8431: |
609 | mt9m001->model = V4L2_IDENT_MT9M001C12STM; | 611 | mt9m001->model = V4L2_IDENT_MT9M001C12STM; |
610 | icd->formats = mt9m001_monochrome_formats; | 612 | icd->formats = mt9m001_monochrome_formats; |
611 | if (mt9m001->client->dev.platform_data) | 613 | if (gpio_is_valid(icl->gpio)) |
612 | icd->num_formats = ARRAY_SIZE(mt9m001_monochrome_formats); | 614 | icd->num_formats = ARRAY_SIZE(mt9m001_monochrome_formats); |
613 | else | 615 | else |
614 | icd->num_formats = 1; | 616 | icd->num_formats = 1; |
@@ -640,8 +642,8 @@ static void mt9m001_video_remove(struct soc_camera_device *icd) | |||
640 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); | 642 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); |
641 | 643 | ||
642 | dev_dbg(&icd->dev, "Video %x removed: %p, %p\n", mt9m001->client->addr, | 644 | dev_dbg(&icd->dev, "Video %x removed: %p, %p\n", mt9m001->client->addr, |
643 | mt9m001->icd.dev.parent, mt9m001->icd.vdev); | 645 | icd->dev.parent, icd->vdev); |
644 | soc_camera_video_stop(&mt9m001->icd); | 646 | soc_camera_video_stop(icd); |
645 | } | 647 | } |
646 | 648 | ||
647 | static int mt9m001_probe(struct i2c_client *client, | 649 | static int mt9m001_probe(struct i2c_client *client, |