aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c/soc_camera/mt9v022.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/i2c/soc_camera/mt9v022.c')
-rw-r--r--drivers/media/i2c/soc_camera/mt9v022.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/drivers/media/i2c/soc_camera/mt9v022.c b/drivers/media/i2c/soc_camera/mt9v022.c
index a246d4d64b8b..f31377408550 100644
--- a/drivers/media/i2c/soc_camera/mt9v022.c
+++ b/drivers/media/i2c/soc_camera/mt9v022.c
@@ -375,12 +375,17 @@ static int mt9v022_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
375 return 0; 375 return 0;
376} 376}
377 377
378static int mt9v022_g_fmt(struct v4l2_subdev *sd, 378static int mt9v022_get_fmt(struct v4l2_subdev *sd,
379 struct v4l2_mbus_framefmt *mf) 379 struct v4l2_subdev_pad_config *cfg,
380 struct v4l2_subdev_format *format)
380{ 381{
382 struct v4l2_mbus_framefmt *mf = &format->format;
381 struct i2c_client *client = v4l2_get_subdevdata(sd); 383 struct i2c_client *client = v4l2_get_subdevdata(sd);
382 struct mt9v022 *mt9v022 = to_mt9v022(client); 384 struct mt9v022 *mt9v022 = to_mt9v022(client);
383 385
386 if (format->pad)
387 return -EINVAL;
388
384 mf->width = mt9v022->rect.width; 389 mf->width = mt9v022->rect.width;
385 mf->height = mt9v022->rect.height; 390 mf->height = mt9v022->rect.height;
386 mf->code = mt9v022->fmt->code; 391 mf->code = mt9v022->fmt->code;
@@ -407,7 +412,7 @@ static int mt9v022_s_fmt(struct v4l2_subdev *sd,
407 412
408 /* 413 /*
409 * The caller provides a supported format, as verified per call to 414 * The caller provides a supported format, as verified per call to
410 * .try_mbus_fmt(), datawidth is from our supported format list 415 * .set_fmt(FORMAT_TRY), datawidth is from our supported format list
411 */ 416 */
412 switch (mf->code) { 417 switch (mf->code) {
413 case MEDIA_BUS_FMT_Y8_1X8: 418 case MEDIA_BUS_FMT_Y8_1X8:
@@ -437,15 +442,20 @@ static int mt9v022_s_fmt(struct v4l2_subdev *sd,
437 return ret; 442 return ret;
438} 443}
439 444
440static int mt9v022_try_fmt(struct v4l2_subdev *sd, 445static int mt9v022_set_fmt(struct v4l2_subdev *sd,
441 struct v4l2_mbus_framefmt *mf) 446 struct v4l2_subdev_pad_config *cfg,
447 struct v4l2_subdev_format *format)
442{ 448{
449 struct v4l2_mbus_framefmt *mf = &format->format;
443 struct i2c_client *client = v4l2_get_subdevdata(sd); 450 struct i2c_client *client = v4l2_get_subdevdata(sd);
444 struct mt9v022 *mt9v022 = to_mt9v022(client); 451 struct mt9v022 *mt9v022 = to_mt9v022(client);
445 const struct mt9v022_datafmt *fmt; 452 const struct mt9v022_datafmt *fmt;
446 int align = mf->code == MEDIA_BUS_FMT_SBGGR8_1X8 || 453 int align = mf->code == MEDIA_BUS_FMT_SBGGR8_1X8 ||
447 mf->code == MEDIA_BUS_FMT_SBGGR10_1X10; 454 mf->code == MEDIA_BUS_FMT_SBGGR10_1X10;
448 455
456 if (format->pad)
457 return -EINVAL;
458
449 v4l_bound_align_image(&mf->width, MT9V022_MIN_WIDTH, 459 v4l_bound_align_image(&mf->width, MT9V022_MIN_WIDTH,
450 MT9V022_MAX_WIDTH, align, 460 MT9V022_MAX_WIDTH, align,
451 &mf->height, MT9V022_MIN_HEIGHT + mt9v022->y_skip_top, 461 &mf->height, MT9V022_MIN_HEIGHT + mt9v022->y_skip_top,
@@ -460,6 +470,9 @@ static int mt9v022_try_fmt(struct v4l2_subdev *sd,
460 470
461 mf->colorspace = fmt->colorspace; 471 mf->colorspace = fmt->colorspace;
462 472
473 if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
474 return mt9v022_s_fmt(sd, mf);
475 cfg->try_fmt = *mf;
463 return 0; 476 return 0;
464} 477}
465 478
@@ -758,16 +771,17 @@ static struct v4l2_subdev_core_ops mt9v022_subdev_core_ops = {
758 .s_power = mt9v022_s_power, 771 .s_power = mt9v022_s_power,
759}; 772};
760 773
761static int mt9v022_enum_fmt(struct v4l2_subdev *sd, unsigned int index, 774static int mt9v022_enum_mbus_code(struct v4l2_subdev *sd,
762 u32 *code) 775 struct v4l2_subdev_pad_config *cfg,
776 struct v4l2_subdev_mbus_code_enum *code)
763{ 777{
764 struct i2c_client *client = v4l2_get_subdevdata(sd); 778 struct i2c_client *client = v4l2_get_subdevdata(sd);
765 struct mt9v022 *mt9v022 = to_mt9v022(client); 779 struct mt9v022 *mt9v022 = to_mt9v022(client);
766 780
767 if (index >= mt9v022->num_fmts) 781 if (code->pad || code->index >= mt9v022->num_fmts)
768 return -EINVAL; 782 return -EINVAL;
769 783
770 *code = mt9v022->fmts[index].code; 784 code->code = mt9v022->fmts[code->index].code;
771 return 0; 785 return 0;
772} 786}
773 787
@@ -839,13 +853,9 @@ static int mt9v022_s_mbus_config(struct v4l2_subdev *sd,
839 853
840static struct v4l2_subdev_video_ops mt9v022_subdev_video_ops = { 854static struct v4l2_subdev_video_ops mt9v022_subdev_video_ops = {
841 .s_stream = mt9v022_s_stream, 855 .s_stream = mt9v022_s_stream,
842 .s_mbus_fmt = mt9v022_s_fmt,
843 .g_mbus_fmt = mt9v022_g_fmt,
844 .try_mbus_fmt = mt9v022_try_fmt,
845 .s_crop = mt9v022_s_crop, 856 .s_crop = mt9v022_s_crop,
846 .g_crop = mt9v022_g_crop, 857 .g_crop = mt9v022_g_crop,
847 .cropcap = mt9v022_cropcap, 858 .cropcap = mt9v022_cropcap,
848 .enum_mbus_fmt = mt9v022_enum_fmt,
849 .g_mbus_config = mt9v022_g_mbus_config, 859 .g_mbus_config = mt9v022_g_mbus_config,
850 .s_mbus_config = mt9v022_s_mbus_config, 860 .s_mbus_config = mt9v022_s_mbus_config,
851}; 861};
@@ -854,10 +864,17 @@ static struct v4l2_subdev_sensor_ops mt9v022_subdev_sensor_ops = {
854 .g_skip_top_lines = mt9v022_g_skip_top_lines, 864 .g_skip_top_lines = mt9v022_g_skip_top_lines,
855}; 865};
856 866
867static const struct v4l2_subdev_pad_ops mt9v022_subdev_pad_ops = {
868 .enum_mbus_code = mt9v022_enum_mbus_code,
869 .get_fmt = mt9v022_get_fmt,
870 .set_fmt = mt9v022_set_fmt,
871};
872
857static struct v4l2_subdev_ops mt9v022_subdev_ops = { 873static struct v4l2_subdev_ops mt9v022_subdev_ops = {
858 .core = &mt9v022_subdev_core_ops, 874 .core = &mt9v022_subdev_core_ops,
859 .video = &mt9v022_subdev_video_ops, 875 .video = &mt9v022_subdev_video_ops,
860 .sensor = &mt9v022_subdev_sensor_ops, 876 .sensor = &mt9v022_subdev_sensor_ops,
877 .pad = &mt9v022_subdev_pad_ops,
861}; 878};
862 879
863static int mt9v022_probe(struct i2c_client *client, 880static int mt9v022_probe(struct i2c_client *client,