diff options
Diffstat (limited to 'drivers/media/video/tw9910.c')
-rw-r--r-- | drivers/media/video/tw9910.c | 91 |
1 files changed, 46 insertions, 45 deletions
diff --git a/drivers/media/video/tw9910.c b/drivers/media/video/tw9910.c index 8ec1031dacc3..341d0e035cbf 100644 --- a/drivers/media/video/tw9910.c +++ b/drivers/media/video/tw9910.c | |||
@@ -251,15 +251,6 @@ static const struct regval_list tw9910_default_regs[] = | |||
251 | ENDMARKER, | 251 | ENDMARKER, |
252 | }; | 252 | }; |
253 | 253 | ||
254 | static const struct soc_camera_data_format tw9910_color_fmt[] = { | ||
255 | { | ||
256 | .name = "VYUY", | ||
257 | .fourcc = V4L2_PIX_FMT_VYUY, | ||
258 | .depth = 16, | ||
259 | .colorspace = V4L2_COLORSPACE_SMPTE170M, | ||
260 | } | ||
261 | }; | ||
262 | |||
263 | static const struct tw9910_scale_ctrl tw9910_ntsc_scales[] = { | 254 | static const struct tw9910_scale_ctrl tw9910_ntsc_scales[] = { |
264 | { | 255 | { |
265 | .name = "NTSC SQ", | 256 | .name = "NTSC SQ", |
@@ -814,11 +805,11 @@ static int tw9910_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a) | |||
814 | return 0; | 805 | return 0; |
815 | } | 806 | } |
816 | 807 | ||
817 | static int tw9910_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) | 808 | static int tw9910_g_fmt(struct v4l2_subdev *sd, |
809 | struct v4l2_mbus_framefmt *mf) | ||
818 | { | 810 | { |
819 | struct i2c_client *client = sd->priv; | 811 | struct i2c_client *client = sd->priv; |
820 | struct tw9910_priv *priv = to_tw9910(client); | 812 | struct tw9910_priv *priv = to_tw9910(client); |
821 | struct v4l2_pix_format *pix = &f->fmt.pix; | ||
822 | 813 | ||
823 | if (!priv->scale) { | 814 | if (!priv->scale) { |
824 | int ret; | 815 | int ret; |
@@ -835,74 +826,76 @@ static int tw9910_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) | |||
835 | return ret; | 826 | return ret; |
836 | } | 827 | } |
837 | 828 | ||
838 | f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 829 | mf->width = priv->scale->width; |
839 | 830 | mf->height = priv->scale->height; | |
840 | pix->width = priv->scale->width; | 831 | mf->code = V4L2_MBUS_FMT_YVYU8_2X8_BE; |
841 | pix->height = priv->scale->height; | 832 | mf->colorspace = V4L2_COLORSPACE_JPEG; |
842 | pix->pixelformat = V4L2_PIX_FMT_VYUY; | 833 | mf->field = V4L2_FIELD_INTERLACED; |
843 | pix->colorspace = V4L2_COLORSPACE_SMPTE170M; | ||
844 | pix->field = V4L2_FIELD_INTERLACED; | ||
845 | 834 | ||
846 | return 0; | 835 | return 0; |
847 | } | 836 | } |
848 | 837 | ||
849 | static int tw9910_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) | 838 | static int tw9910_s_fmt(struct v4l2_subdev *sd, |
839 | struct v4l2_mbus_framefmt *mf) | ||
850 | { | 840 | { |
851 | struct i2c_client *client = sd->priv; | 841 | struct i2c_client *client = sd->priv; |
852 | struct tw9910_priv *priv = to_tw9910(client); | 842 | struct tw9910_priv *priv = to_tw9910(client); |
853 | struct v4l2_pix_format *pix = &f->fmt.pix; | ||
854 | /* See tw9910_s_crop() - no proper cropping support */ | 843 | /* See tw9910_s_crop() - no proper cropping support */ |
855 | struct v4l2_crop a = { | 844 | struct v4l2_crop a = { |
856 | .c = { | 845 | .c = { |
857 | .left = 0, | 846 | .left = 0, |
858 | .top = 0, | 847 | .top = 0, |
859 | .width = pix->width, | 848 | .width = mf->width, |
860 | .height = pix->height, | 849 | .height = mf->height, |
861 | }, | 850 | }, |
862 | }; | 851 | }; |
863 | int i, ret; | 852 | int ret; |
853 | |||
854 | WARN_ON(mf->field != V4L2_FIELD_ANY && | ||
855 | mf->field != V4L2_FIELD_INTERLACED); | ||
864 | 856 | ||
865 | /* | 857 | /* |
866 | * check color format | 858 | * check color format |
867 | */ | 859 | */ |
868 | for (i = 0; i < ARRAY_SIZE(tw9910_color_fmt); i++) | 860 | if (mf->code != V4L2_MBUS_FMT_YVYU8_2X8_BE) |
869 | if (pix->pixelformat == tw9910_color_fmt[i].fourcc) | ||
870 | break; | ||
871 | |||
872 | if (i == ARRAY_SIZE(tw9910_color_fmt)) | ||
873 | return -EINVAL; | 861 | return -EINVAL; |
874 | 862 | ||
863 | mf->colorspace = V4L2_COLORSPACE_JPEG; | ||
864 | |||
875 | ret = tw9910_s_crop(sd, &a); | 865 | ret = tw9910_s_crop(sd, &a); |
876 | if (!ret) { | 866 | if (!ret) { |
877 | pix->width = priv->scale->width; | 867 | mf->width = priv->scale->width; |
878 | pix->height = priv->scale->height; | 868 | mf->height = priv->scale->height; |
879 | } | 869 | } |
880 | return ret; | 870 | return ret; |
881 | } | 871 | } |
882 | 872 | ||
883 | static int tw9910_try_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) | 873 | static int tw9910_try_fmt(struct v4l2_subdev *sd, |
874 | struct v4l2_mbus_framefmt *mf) | ||
884 | { | 875 | { |
885 | struct i2c_client *client = sd->priv; | 876 | struct i2c_client *client = sd->priv; |
886 | struct soc_camera_device *icd = client->dev.platform_data; | 877 | struct soc_camera_device *icd = client->dev.platform_data; |
887 | struct v4l2_pix_format *pix = &f->fmt.pix; | ||
888 | const struct tw9910_scale_ctrl *scale; | 878 | const struct tw9910_scale_ctrl *scale; |
889 | 879 | ||
890 | if (V4L2_FIELD_ANY == pix->field) { | 880 | if (V4L2_FIELD_ANY == mf->field) { |
891 | pix->field = V4L2_FIELD_INTERLACED; | 881 | mf->field = V4L2_FIELD_INTERLACED; |
892 | } else if (V4L2_FIELD_INTERLACED != pix->field) { | 882 | } else if (V4L2_FIELD_INTERLACED != mf->field) { |
893 | dev_err(&client->dev, "Field type invalid.\n"); | 883 | dev_err(&client->dev, "Field type %d invalid.\n", mf->field); |
894 | return -EINVAL; | 884 | return -EINVAL; |
895 | } | 885 | } |
896 | 886 | ||
887 | mf->code = V4L2_MBUS_FMT_YVYU8_2X8_BE; | ||
888 | mf->colorspace = V4L2_COLORSPACE_JPEG; | ||
889 | |||
897 | /* | 890 | /* |
898 | * select suitable norm | 891 | * select suitable norm |
899 | */ | 892 | */ |
900 | scale = tw9910_select_norm(icd, pix->width, pix->height); | 893 | scale = tw9910_select_norm(icd, mf->width, mf->height); |
901 | if (!scale) | 894 | if (!scale) |
902 | return -EINVAL; | 895 | return -EINVAL; |
903 | 896 | ||
904 | pix->width = scale->width; | 897 | mf->width = scale->width; |
905 | pix->height = scale->height; | 898 | mf->height = scale->height; |
906 | 899 | ||
907 | return 0; | 900 | return 0; |
908 | } | 901 | } |
@@ -930,9 +923,6 @@ static int tw9910_video_probe(struct soc_camera_device *icd, | |||
930 | return -ENODEV; | 923 | return -ENODEV; |
931 | } | 924 | } |
932 | 925 | ||
933 | icd->formats = tw9910_color_fmt; | ||
934 | icd->num_formats = ARRAY_SIZE(tw9910_color_fmt); | ||
935 | |||
936 | /* | 926 | /* |
937 | * check and show Product ID | 927 | * check and show Product ID |
938 | * So far only revisions 0 and 1 have been seen | 928 | * So far only revisions 0 and 1 have been seen |
@@ -973,14 +963,25 @@ static struct v4l2_subdev_core_ops tw9910_subdev_core_ops = { | |||
973 | #endif | 963 | #endif |
974 | }; | 964 | }; |
975 | 965 | ||
966 | static int tw9910_enum_fmt(struct v4l2_subdev *sd, int index, | ||
967 | enum v4l2_mbus_pixelcode *code) | ||
968 | { | ||
969 | if (index) | ||
970 | return -EINVAL; | ||
971 | |||
972 | *code = V4L2_MBUS_FMT_YVYU8_2X8_BE; | ||
973 | return 0; | ||
974 | } | ||
975 | |||
976 | static struct v4l2_subdev_video_ops tw9910_subdev_video_ops = { | 976 | static struct v4l2_subdev_video_ops tw9910_subdev_video_ops = { |
977 | .s_stream = tw9910_s_stream, | 977 | .s_stream = tw9910_s_stream, |
978 | .g_fmt = tw9910_g_fmt, | 978 | .g_mbus_fmt = tw9910_g_fmt, |
979 | .s_fmt = tw9910_s_fmt, | 979 | .s_mbus_fmt = tw9910_s_fmt, |
980 | .try_fmt = tw9910_try_fmt, | 980 | .try_mbus_fmt = tw9910_try_fmt, |
981 | .cropcap = tw9910_cropcap, | 981 | .cropcap = tw9910_cropcap, |
982 | .g_crop = tw9910_g_crop, | 982 | .g_crop = tw9910_g_crop, |
983 | .s_crop = tw9910_s_crop, | 983 | .s_crop = tw9910_s_crop, |
984 | .enum_mbus_fmt = tw9910_enum_fmt, | ||
984 | }; | 985 | }; |
985 | 986 | ||
986 | static struct v4l2_subdev_ops tw9910_subdev_ops = { | 987 | static struct v4l2_subdev_ops tw9910_subdev_ops = { |