diff options
Diffstat (limited to 'drivers/media/video/mt9t031.c')
-rw-r--r-- | drivers/media/video/mt9t031.c | 66 |
1 files changed, 35 insertions, 31 deletions
diff --git a/drivers/media/video/mt9t031.c b/drivers/media/video/mt9t031.c index e3f664f21c48..69c227f65bcb 100644 --- a/drivers/media/video/mt9t031.c +++ b/drivers/media/video/mt9t031.c | |||
@@ -60,15 +60,6 @@ | |||
60 | SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_DATA_ACTIVE_HIGH | \ | 60 | SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_DATA_ACTIVE_HIGH | \ |
61 | SOCAM_MASTER | SOCAM_DATAWIDTH_10) | 61 | SOCAM_MASTER | SOCAM_DATAWIDTH_10) |
62 | 62 | ||
63 | static const struct soc_camera_data_format mt9t031_colour_formats[] = { | ||
64 | { | ||
65 | .name = "Bayer (sRGB) 10 bit", | ||
66 | .depth = 10, | ||
67 | .fourcc = V4L2_PIX_FMT_SGRBG10, | ||
68 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
69 | } | ||
70 | }; | ||
71 | |||
72 | struct mt9t031 { | 63 | struct mt9t031 { |
73 | struct v4l2_subdev subdev; | 64 | struct v4l2_subdev subdev; |
74 | struct v4l2_rect rect; /* Sensor window */ | 65 | struct v4l2_rect rect; /* Sensor window */ |
@@ -378,27 +369,27 @@ static int mt9t031_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a) | |||
378 | return 0; | 369 | return 0; |
379 | } | 370 | } |
380 | 371 | ||
381 | static int mt9t031_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) | 372 | static int mt9t031_g_fmt(struct v4l2_subdev *sd, |
373 | struct v4l2_mbus_framefmt *mf) | ||
382 | { | 374 | { |
383 | struct i2c_client *client = sd->priv; | 375 | struct i2c_client *client = sd->priv; |
384 | struct mt9t031 *mt9t031 = to_mt9t031(client); | 376 | struct mt9t031 *mt9t031 = to_mt9t031(client); |
385 | struct v4l2_pix_format *pix = &f->fmt.pix; | ||
386 | 377 | ||
387 | pix->width = mt9t031->rect.width / mt9t031->xskip; | 378 | mf->width = mt9t031->rect.width / mt9t031->xskip; |
388 | pix->height = mt9t031->rect.height / mt9t031->yskip; | 379 | mf->height = mt9t031->rect.height / mt9t031->yskip; |
389 | pix->pixelformat = V4L2_PIX_FMT_SGRBG10; | 380 | mf->code = V4L2_MBUS_FMT_SBGGR10_1X10; |
390 | pix->field = V4L2_FIELD_NONE; | 381 | mf->colorspace = V4L2_COLORSPACE_SRGB; |
391 | pix->colorspace = V4L2_COLORSPACE_SRGB; | 382 | mf->field = V4L2_FIELD_NONE; |
392 | 383 | ||
393 | return 0; | 384 | return 0; |
394 | } | 385 | } |
395 | 386 | ||
396 | static int mt9t031_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) | 387 | static int mt9t031_s_fmt(struct v4l2_subdev *sd, |
388 | struct v4l2_mbus_framefmt *mf) | ||
397 | { | 389 | { |
398 | struct i2c_client *client = sd->priv; | 390 | struct i2c_client *client = sd->priv; |
399 | struct mt9t031 *mt9t031 = to_mt9t031(client); | 391 | struct mt9t031 *mt9t031 = to_mt9t031(client); |
400 | struct soc_camera_device *icd = client->dev.platform_data; | 392 | struct soc_camera_device *icd = client->dev.platform_data; |
401 | struct v4l2_pix_format *pix = &f->fmt.pix; | ||
402 | u16 xskip, yskip; | 393 | u16 xskip, yskip; |
403 | struct v4l2_rect rect = mt9t031->rect; | 394 | struct v4l2_rect rect = mt9t031->rect; |
404 | 395 | ||
@@ -406,8 +397,11 @@ static int mt9t031_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) | |||
406 | * try_fmt has put width and height within limits. | 397 | * try_fmt has put width and height within limits. |
407 | * S_FMT: use binning and skipping for scaling | 398 | * S_FMT: use binning and skipping for scaling |
408 | */ | 399 | */ |
409 | xskip = mt9t031_skip(&rect.width, pix->width, MT9T031_MAX_WIDTH); | 400 | xskip = mt9t031_skip(&rect.width, mf->width, MT9T031_MAX_WIDTH); |
410 | yskip = mt9t031_skip(&rect.height, pix->height, MT9T031_MAX_HEIGHT); | 401 | yskip = mt9t031_skip(&rect.height, mf->height, MT9T031_MAX_HEIGHT); |
402 | |||
403 | mf->code = V4L2_MBUS_FMT_SBGGR10_1X10; | ||
404 | mf->colorspace = V4L2_COLORSPACE_SRGB; | ||
411 | 405 | ||
412 | /* mt9t031_set_params() doesn't change width and height */ | 406 | /* mt9t031_set_params() doesn't change width and height */ |
413 | return mt9t031_set_params(icd, &rect, xskip, yskip); | 407 | return mt9t031_set_params(icd, &rect, xskip, yskip); |
@@ -417,13 +411,15 @@ static int mt9t031_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) | |||
417 | * If a user window larger than sensor window is requested, we'll increase the | 411 | * If a user window larger than sensor window is requested, we'll increase the |
418 | * sensor window. | 412 | * sensor window. |
419 | */ | 413 | */ |
420 | static int mt9t031_try_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) | 414 | static int mt9t031_try_fmt(struct v4l2_subdev *sd, |
415 | struct v4l2_mbus_framefmt *mf) | ||
421 | { | 416 | { |
422 | struct v4l2_pix_format *pix = &f->fmt.pix; | ||
423 | |||
424 | v4l_bound_align_image( | 417 | v4l_bound_align_image( |
425 | &pix->width, MT9T031_MIN_WIDTH, MT9T031_MAX_WIDTH, 1, | 418 | &mf->width, MT9T031_MIN_WIDTH, MT9T031_MAX_WIDTH, 1, |
426 | &pix->height, MT9T031_MIN_HEIGHT, MT9T031_MAX_HEIGHT, 1, 0); | 419 | &mf->height, MT9T031_MIN_HEIGHT, MT9T031_MAX_HEIGHT, 1, 0); |
420 | |||
421 | mf->code = V4L2_MBUS_FMT_SBGGR10_1X10; | ||
422 | mf->colorspace = V4L2_COLORSPACE_SRGB; | ||
427 | 423 | ||
428 | return 0; | 424 | return 0; |
429 | } | 425 | } |
@@ -684,7 +680,6 @@ static int mt9t031_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) | |||
684 | */ | 680 | */ |
685 | static int mt9t031_video_probe(struct i2c_client *client) | 681 | static int mt9t031_video_probe(struct i2c_client *client) |
686 | { | 682 | { |
687 | struct soc_camera_device *icd = client->dev.platform_data; | ||
688 | struct mt9t031 *mt9t031 = to_mt9t031(client); | 683 | struct mt9t031 *mt9t031 = to_mt9t031(client); |
689 | s32 data; | 684 | s32 data; |
690 | int ret; | 685 | int ret; |
@@ -699,8 +694,6 @@ static int mt9t031_video_probe(struct i2c_client *client) | |||
699 | switch (data) { | 694 | switch (data) { |
700 | case 0x1621: | 695 | case 0x1621: |
701 | mt9t031->model = V4L2_IDENT_MT9T031; | 696 | mt9t031->model = V4L2_IDENT_MT9T031; |
702 | icd->formats = mt9t031_colour_formats; | ||
703 | icd->num_formats = ARRAY_SIZE(mt9t031_colour_formats); | ||
704 | break; | 697 | break; |
705 | default: | 698 | default: |
706 | dev_err(&client->dev, | 699 | dev_err(&client->dev, |
@@ -741,14 +734,25 @@ static struct v4l2_subdev_core_ops mt9t031_subdev_core_ops = { | |||
741 | #endif | 734 | #endif |
742 | }; | 735 | }; |
743 | 736 | ||
737 | static int mt9t031_enum_fmt(struct v4l2_subdev *sd, int index, | ||
738 | enum v4l2_mbus_pixelcode *code) | ||
739 | { | ||
740 | if (index) | ||
741 | return -EINVAL; | ||
742 | |||
743 | *code = V4L2_MBUS_FMT_SBGGR10_1X10; | ||
744 | return 0; | ||
745 | } | ||
746 | |||
744 | static struct v4l2_subdev_video_ops mt9t031_subdev_video_ops = { | 747 | static struct v4l2_subdev_video_ops mt9t031_subdev_video_ops = { |
745 | .s_stream = mt9t031_s_stream, | 748 | .s_stream = mt9t031_s_stream, |
746 | .s_fmt = mt9t031_s_fmt, | 749 | .s_mbus_fmt = mt9t031_s_fmt, |
747 | .g_fmt = mt9t031_g_fmt, | 750 | .g_mbus_fmt = mt9t031_g_fmt, |
748 | .try_fmt = mt9t031_try_fmt, | 751 | .try_mbus_fmt = mt9t031_try_fmt, |
749 | .s_crop = mt9t031_s_crop, | 752 | .s_crop = mt9t031_s_crop, |
750 | .g_crop = mt9t031_g_crop, | 753 | .g_crop = mt9t031_g_crop, |
751 | .cropcap = mt9t031_cropcap, | 754 | .cropcap = mt9t031_cropcap, |
755 | .enum_mbus_fmt = mt9t031_enum_fmt, | ||
752 | }; | 756 | }; |
753 | 757 | ||
754 | static struct v4l2_subdev_sensor_ops mt9t031_subdev_sensor_ops = { | 758 | static struct v4l2_subdev_sensor_ops mt9t031_subdev_sensor_ops = { |