aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c/soc_camera/mt9m001.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/i2c/soc_camera/mt9m001.c')
-rw-r--r--drivers/media/i2c/soc_camera/mt9m001.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/drivers/media/i2c/soc_camera/mt9m001.c b/drivers/media/i2c/soc_camera/mt9m001.c
index 2e9a53502551..4fbdd1e9f7ee 100644
--- a/drivers/media/i2c/soc_camera/mt9m001.c
+++ b/drivers/media/i2c/soc_camera/mt9m001.c
@@ -205,7 +205,7 @@ static int mt9m001_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a)
205 205
206 /* 206 /*
207 * The caller provides a supported format, as verified per 207 * The caller provides a supported format, as verified per
208 * call to .try_mbus_fmt() 208 * call to .set_fmt(FORMAT_TRY).
209 */ 209 */
210 if (!ret) 210 if (!ret)
211 ret = reg_write(client, MT9M001_COLUMN_START, rect.left); 211 ret = reg_write(client, MT9M001_COLUMN_START, rect.left);
@@ -250,11 +250,16 @@ static int mt9m001_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
250 return 0; 250 return 0;
251} 251}
252 252
253static int mt9m001_g_fmt(struct v4l2_subdev *sd, 253static int mt9m001_get_fmt(struct v4l2_subdev *sd,
254 struct v4l2_mbus_framefmt *mf) 254 struct v4l2_subdev_pad_config *cfg,
255 struct v4l2_subdev_format *format)
255{ 256{
256 struct i2c_client *client = v4l2_get_subdevdata(sd); 257 struct i2c_client *client = v4l2_get_subdevdata(sd);
257 struct mt9m001 *mt9m001 = to_mt9m001(client); 258 struct mt9m001 *mt9m001 = to_mt9m001(client);
259 struct v4l2_mbus_framefmt *mf = &format->format;
260
261 if (format->pad)
262 return -EINVAL;
258 263
259 mf->width = mt9m001->rect.width; 264 mf->width = mt9m001->rect.width;
260 mf->height = mt9m001->rect.height; 265 mf->height = mt9m001->rect.height;
@@ -293,13 +298,18 @@ static int mt9m001_s_fmt(struct v4l2_subdev *sd,
293 return ret; 298 return ret;
294} 299}
295 300
296static int mt9m001_try_fmt(struct v4l2_subdev *sd, 301static int mt9m001_set_fmt(struct v4l2_subdev *sd,
297 struct v4l2_mbus_framefmt *mf) 302 struct v4l2_subdev_pad_config *cfg,
303 struct v4l2_subdev_format *format)
298{ 304{
305 struct v4l2_mbus_framefmt *mf = &format->format;
299 struct i2c_client *client = v4l2_get_subdevdata(sd); 306 struct i2c_client *client = v4l2_get_subdevdata(sd);
300 struct mt9m001 *mt9m001 = to_mt9m001(client); 307 struct mt9m001 *mt9m001 = to_mt9m001(client);
301 const struct mt9m001_datafmt *fmt; 308 const struct mt9m001_datafmt *fmt;
302 309
310 if (format->pad)
311 return -EINVAL;
312
303 v4l_bound_align_image(&mf->width, MT9M001_MIN_WIDTH, 313 v4l_bound_align_image(&mf->width, MT9M001_MIN_WIDTH,
304 MT9M001_MAX_WIDTH, 1, 314 MT9M001_MAX_WIDTH, 1,
305 &mf->height, MT9M001_MIN_HEIGHT + mt9m001->y_skip_top, 315 &mf->height, MT9M001_MIN_HEIGHT + mt9m001->y_skip_top,
@@ -317,6 +327,9 @@ static int mt9m001_try_fmt(struct v4l2_subdev *sd,
317 327
318 mf->colorspace = fmt->colorspace; 328 mf->colorspace = fmt->colorspace;
319 329
330 if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
331 return mt9m001_s_fmt(sd, mf);
332 cfg->try_fmt = *mf;
320 return 0; 333 return 0;
321} 334}
322 335
@@ -562,16 +575,17 @@ static struct v4l2_subdev_core_ops mt9m001_subdev_core_ops = {
562 .s_power = mt9m001_s_power, 575 .s_power = mt9m001_s_power,
563}; 576};
564 577
565static int mt9m001_enum_fmt(struct v4l2_subdev *sd, unsigned int index, 578static int mt9m001_enum_mbus_code(struct v4l2_subdev *sd,
566 u32 *code) 579 struct v4l2_subdev_pad_config *cfg,
580 struct v4l2_subdev_mbus_code_enum *code)
567{ 581{
568 struct i2c_client *client = v4l2_get_subdevdata(sd); 582 struct i2c_client *client = v4l2_get_subdevdata(sd);
569 struct mt9m001 *mt9m001 = to_mt9m001(client); 583 struct mt9m001 *mt9m001 = to_mt9m001(client);
570 584
571 if (index >= mt9m001->num_fmts) 585 if (code->pad || code->index >= mt9m001->num_fmts)
572 return -EINVAL; 586 return -EINVAL;
573 587
574 *code = mt9m001->fmts[index].code; 588 code->code = mt9m001->fmts[code->index].code;
575 return 0; 589 return 0;
576} 590}
577 591
@@ -611,13 +625,9 @@ static int mt9m001_s_mbus_config(struct v4l2_subdev *sd,
611 625
612static struct v4l2_subdev_video_ops mt9m001_subdev_video_ops = { 626static struct v4l2_subdev_video_ops mt9m001_subdev_video_ops = {
613 .s_stream = mt9m001_s_stream, 627 .s_stream = mt9m001_s_stream,
614 .s_mbus_fmt = mt9m001_s_fmt,
615 .g_mbus_fmt = mt9m001_g_fmt,
616 .try_mbus_fmt = mt9m001_try_fmt,
617 .s_crop = mt9m001_s_crop, 628 .s_crop = mt9m001_s_crop,
618 .g_crop = mt9m001_g_crop, 629 .g_crop = mt9m001_g_crop,
619 .cropcap = mt9m001_cropcap, 630 .cropcap = mt9m001_cropcap,
620 .enum_mbus_fmt = mt9m001_enum_fmt,
621 .g_mbus_config = mt9m001_g_mbus_config, 631 .g_mbus_config = mt9m001_g_mbus_config,
622 .s_mbus_config = mt9m001_s_mbus_config, 632 .s_mbus_config = mt9m001_s_mbus_config,
623}; 633};
@@ -626,10 +636,17 @@ static struct v4l2_subdev_sensor_ops mt9m001_subdev_sensor_ops = {
626 .g_skip_top_lines = mt9m001_g_skip_top_lines, 636 .g_skip_top_lines = mt9m001_g_skip_top_lines,
627}; 637};
628 638
639static const struct v4l2_subdev_pad_ops mt9m001_subdev_pad_ops = {
640 .enum_mbus_code = mt9m001_enum_mbus_code,
641 .get_fmt = mt9m001_get_fmt,
642 .set_fmt = mt9m001_set_fmt,
643};
644
629static struct v4l2_subdev_ops mt9m001_subdev_ops = { 645static struct v4l2_subdev_ops mt9m001_subdev_ops = {
630 .core = &mt9m001_subdev_core_ops, 646 .core = &mt9m001_subdev_core_ops,
631 .video = &mt9m001_subdev_video_ops, 647 .video = &mt9m001_subdev_video_ops,
632 .sensor = &mt9m001_subdev_sensor_ops, 648 .sensor = &mt9m001_subdev_sensor_ops,
649 .pad = &mt9m001_subdev_pad_ops,
633}; 650};
634 651
635static int mt9m001_probe(struct i2c_client *client, 652static int mt9m001_probe(struct i2c_client *client,