aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/tw9910.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/tw9910.c')
-rw-r--r--drivers/media/video/tw9910.c45
1 files changed, 29 insertions, 16 deletions
diff --git a/drivers/media/video/tw9910.c b/drivers/media/video/tw9910.c
index 0558b22fd3fb..a39947643992 100644
--- a/drivers/media/video/tw9910.c
+++ b/drivers/media/video/tw9910.c
@@ -641,25 +641,12 @@ static int tw9910_set_register(struct soc_camera_device *icd,
641} 641}
642#endif 642#endif
643 643
644static int tw9910_set_fmt(struct soc_camera_device *icd, __u32 pixfmt, 644static int tw9910_set_crop(struct soc_camera_device *icd,
645 struct v4l2_rect *rect) 645 struct v4l2_rect *rect)
646{ 646{
647 struct tw9910_priv *priv = container_of(icd, struct tw9910_priv, icd); 647 struct tw9910_priv *priv = container_of(icd, struct tw9910_priv, icd);
648 int ret = -EINVAL; 648 int ret = -EINVAL;
649 u8 val; 649 u8 val;
650 int i;
651
652 /*
653 * check color format
654 */
655 for (i = 0 ; i < ARRAY_SIZE(tw9910_color_fmt) ; i++) {
656 if (pixfmt == tw9910_color_fmt[i].fourcc) {
657 ret = 0;
658 break;
659 }
660 }
661 if (ret < 0)
662 goto tw9910_set_fmt_error;
663 650
664 /* 651 /*
665 * select suitable norm 652 * select suitable norm
@@ -746,8 +733,33 @@ tw9910_set_fmt_error:
746 return ret; 733 return ret;
747} 734}
748 735
736static int tw9910_set_fmt(struct soc_camera_device *icd,
737 struct v4l2_format *f)
738{
739 struct v4l2_pix_format *pix = &f->fmt.pix;
740 struct v4l2_rect rect = {
741 .left = icd->x_current,
742 .top = icd->y_current,
743 .width = pix->width,
744 .height = pix->height,
745 };
746 int i;
747
748 /*
749 * check color format
750 */
751 for (i = 0; i < ARRAY_SIZE(tw9910_color_fmt); i++)
752 if (pix->pixelformat == tw9910_color_fmt[i].fourcc)
753 break;
754
755 if (i == ARRAY_SIZE(tw9910_color_fmt))
756 return -EINVAL;
757
758 return tw9910_set_crop(icd, &rect);
759}
760
749static int tw9910_try_fmt(struct soc_camera_device *icd, 761static int tw9910_try_fmt(struct soc_camera_device *icd,
750 struct v4l2_format *f) 762 struct v4l2_format *f)
751{ 763{
752 struct v4l2_pix_format *pix = &f->fmt.pix; 764 struct v4l2_pix_format *pix = &f->fmt.pix;
753 const struct tw9910_scale_ctrl *scale; 765 const struct tw9910_scale_ctrl *scale;
@@ -835,6 +847,7 @@ static struct soc_camera_ops tw9910_ops = {
835 .release = tw9910_release, 847 .release = tw9910_release,
836 .start_capture = tw9910_start_capture, 848 .start_capture = tw9910_start_capture,
837 .stop_capture = tw9910_stop_capture, 849 .stop_capture = tw9910_stop_capture,
850 .set_crop = tw9910_set_crop,
838 .set_fmt = tw9910_set_fmt, 851 .set_fmt = tw9910_set_fmt,
839 .try_fmt = tw9910_try_fmt, 852 .try_fmt = tw9910_try_fmt,
840 .set_bus_param = tw9910_set_bus_param, 853 .set_bus_param = tw9910_set_bus_param,