aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/mt9v022.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/mt9v022.c')
-rw-r--r--drivers/media/video/mt9v022.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/drivers/media/video/mt9v022.c b/drivers/media/video/mt9v022.c
index 2584201059d8..14a5f9c21ffa 100644
--- a/drivers/media/video/mt9v022.c
+++ b/drivers/media/video/mt9v022.c
@@ -273,6 +273,7 @@ static int mt9v022_set_bus_param(struct soc_camera_device *icd,
273 unsigned long flags) 273 unsigned long flags)
274{ 274{
275 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); 275 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
276 struct soc_camera_link *icl = mt9v022->client->dev.platform_data;
276 unsigned int width_flag = flags & SOCAM_DATAWIDTH_MASK; 277 unsigned int width_flag = flags & SOCAM_DATAWIDTH_MASK;
277 int ret; 278 int ret;
278 u16 pixclk = 0; 279 u16 pixclk = 0;
@@ -296,6 +297,8 @@ static int mt9v022_set_bus_param(struct soc_camera_device *icd,
296 mt9v022->datawidth = width_flag == SOCAM_DATAWIDTH_8 ? 8 : 10; 297 mt9v022->datawidth = width_flag == SOCAM_DATAWIDTH_8 ? 8 : 10;
297 } 298 }
298 299
300 flags = soc_camera_apply_sensor_flags(icl, flags);
301
299 if (flags & SOCAM_PCLK_SAMPLE_RISING) 302 if (flags & SOCAM_PCLK_SAMPLE_RISING)
300 pixclk |= 0x10; 303 pixclk |= 0x10;
301 304
@@ -337,14 +340,14 @@ static unsigned long mt9v022_query_bus_param(struct soc_camera_device *icd)
337 width_flag; 340 width_flag;
338} 341}
339 342
340static int mt9v022_set_fmt_cap(struct soc_camera_device *icd, 343static int mt9v022_set_fmt(struct soc_camera_device *icd,
341 __u32 pixfmt, struct v4l2_rect *rect) 344 __u32 pixfmt, struct v4l2_rect *rect)
342{ 345{
343 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); 346 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
344 int ret; 347 int ret;
345 348
346 /* The caller provides a supported format, as verified per call to 349 /* The caller provides a supported format, as verified per call to
347 * icd->try_fmt_cap(), datawidth is from our supported format list */ 350 * icd->try_fmt(), datawidth is from our supported format list */
348 switch (pixfmt) { 351 switch (pixfmt) {
349 case V4L2_PIX_FMT_GREY: 352 case V4L2_PIX_FMT_GREY:
350 case V4L2_PIX_FMT_Y16: 353 case V4L2_PIX_FMT_Y16:
@@ -400,18 +403,20 @@ static int mt9v022_set_fmt_cap(struct soc_camera_device *icd,
400 return 0; 403 return 0;
401} 404}
402 405
403static int mt9v022_try_fmt_cap(struct soc_camera_device *icd, 406static int mt9v022_try_fmt(struct soc_camera_device *icd,
404 struct v4l2_format *f) 407 struct v4l2_format *f)
405{ 408{
406 if (f->fmt.pix.height < 32 + icd->y_skip_top) 409 struct v4l2_pix_format *pix = &f->fmt.pix;
407 f->fmt.pix.height = 32 + icd->y_skip_top; 410
408 if (f->fmt.pix.height > 480 + icd->y_skip_top) 411 if (pix->height < 32 + icd->y_skip_top)
409 f->fmt.pix.height = 480 + icd->y_skip_top; 412 pix->height = 32 + icd->y_skip_top;
410 if (f->fmt.pix.width < 48) 413 if (pix->height > 480 + icd->y_skip_top)
411 f->fmt.pix.width = 48; 414 pix->height = 480 + icd->y_skip_top;
412 if (f->fmt.pix.width > 752) 415 if (pix->width < 48)
413 f->fmt.pix.width = 752; 416 pix->width = 48;
414 f->fmt.pix.width &= ~0x03; /* ? */ 417 if (pix->width > 752)
418 pix->width = 752;
419 pix->width &= ~0x03; /* ? */
415 420
416 return 0; 421 return 0;
417} 422}
@@ -538,8 +543,8 @@ static struct soc_camera_ops mt9v022_ops = {
538 .release = mt9v022_release, 543 .release = mt9v022_release,
539 .start_capture = mt9v022_start_capture, 544 .start_capture = mt9v022_start_capture,
540 .stop_capture = mt9v022_stop_capture, 545 .stop_capture = mt9v022_stop_capture,
541 .set_fmt_cap = mt9v022_set_fmt_cap, 546 .set_fmt = mt9v022_set_fmt,
542 .try_fmt_cap = mt9v022_try_fmt_cap, 547 .try_fmt = mt9v022_try_fmt,
543 .set_bus_param = mt9v022_set_bus_param, 548 .set_bus_param = mt9v022_set_bus_param,
544 .query_bus_param = mt9v022_query_bus_param, 549 .query_bus_param = mt9v022_query_bus_param,
545 .controls = mt9v022_controls, 550 .controls = mt9v022_controls,
@@ -690,6 +695,7 @@ static int mt9v022_set_control(struct soc_camera_device *icd,
690static int mt9v022_video_probe(struct soc_camera_device *icd) 695static int mt9v022_video_probe(struct soc_camera_device *icd)
691{ 696{
692 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); 697 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
698 struct soc_camera_link *icl = mt9v022->client->dev.platform_data;
693 s32 data; 699 s32 data;
694 int ret; 700 int ret;
695 701
@@ -725,7 +731,7 @@ static int mt9v022_video_probe(struct soc_camera_device *icd)
725 ret = reg_write(icd, MT9V022_PIXEL_OPERATION_MODE, 4 | 0x11); 731 ret = reg_write(icd, MT9V022_PIXEL_OPERATION_MODE, 4 | 0x11);
726 mt9v022->model = V4L2_IDENT_MT9V022IX7ATC; 732 mt9v022->model = V4L2_IDENT_MT9V022IX7ATC;
727 icd->formats = mt9v022_colour_formats; 733 icd->formats = mt9v022_colour_formats;
728 if (mt9v022->client->dev.platform_data) 734 if (gpio_is_valid(icl->gpio))
729 icd->num_formats = ARRAY_SIZE(mt9v022_colour_formats); 735 icd->num_formats = ARRAY_SIZE(mt9v022_colour_formats);
730 else 736 else
731 icd->num_formats = 1; 737 icd->num_formats = 1;
@@ -733,7 +739,7 @@ static int mt9v022_video_probe(struct soc_camera_device *icd)
733 ret = reg_write(icd, MT9V022_PIXEL_OPERATION_MODE, 0x11); 739 ret = reg_write(icd, MT9V022_PIXEL_OPERATION_MODE, 0x11);
734 mt9v022->model = V4L2_IDENT_MT9V022IX7ATM; 740 mt9v022->model = V4L2_IDENT_MT9V022IX7ATM;
735 icd->formats = mt9v022_monochrome_formats; 741 icd->formats = mt9v022_monochrome_formats;
736 if (mt9v022->client->dev.platform_data) 742 if (gpio_is_valid(icl->gpio))
737 icd->num_formats = ARRAY_SIZE(mt9v022_monochrome_formats); 743 icd->num_formats = ARRAY_SIZE(mt9v022_monochrome_formats);
738 else 744 else
739 icd->num_formats = 1; 745 icd->num_formats = 1;
@@ -760,8 +766,8 @@ static void mt9v022_video_remove(struct soc_camera_device *icd)
760 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); 766 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
761 767
762 dev_dbg(&icd->dev, "Video %x removed: %p, %p\n", mt9v022->client->addr, 768 dev_dbg(&icd->dev, "Video %x removed: %p, %p\n", mt9v022->client->addr,
763 mt9v022->icd.dev.parent, mt9v022->icd.vdev); 769 icd->dev.parent, icd->vdev);
764 soc_camera_video_stop(&mt9v022->icd); 770 soc_camera_video_stop(icd);
765} 771}
766 772
767static int mt9v022_probe(struct i2c_client *client, 773static int mt9v022_probe(struct i2c_client *client,