aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/saa7134
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2010-05-09 08:39:58 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-06-01 00:21:25 -0400
commit51623ef9aedd8b786a12a4475201827ee85d285c (patch)
treee0263f0cb8dc227f2c5a49d64aed287b63f3d86e /drivers/media/video/saa7134
parent3a21ceed7f373894a7c537b4dbbe484f36e7ae24 (diff)
V4L/DVB: saa6752hs: add g/s_mbus_fmt support
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/saa7134')
-rw-r--r--drivers/media/video/saa7134/saa6752hs.c64
1 files changed, 46 insertions, 18 deletions
diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c
index 1eabff6b2456..852040b6b5a6 100644
--- a/drivers/media/video/saa7134/saa6752hs.c
+++ b/drivers/media/video/saa7134/saa6752hs.c
@@ -846,24 +846,38 @@ static int saa6752hs_g_ext_ctrls(struct v4l2_subdev *sd, struct v4l2_ext_control
846 return 0; 846 return 0;
847} 847}
848 848
849static int saa6752hs_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) 849static int saa6752hs_g_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *f)
850{ 850{
851 struct saa6752hs_state *h = to_state(sd); 851 struct saa6752hs_state *h = to_state(sd);
852 852
853 if (h->video_format == SAA6752HS_VF_UNKNOWN) 853 if (h->video_format == SAA6752HS_VF_UNKNOWN)
854 h->video_format = SAA6752HS_VF_D1; 854 h->video_format = SAA6752HS_VF_D1;
855 f->fmt.pix.width = 855 f->width = v4l2_format_table[h->video_format].fmt.pix.width;
856 v4l2_format_table[h->video_format].fmt.pix.width; 856 f->height = v4l2_format_table[h->video_format].fmt.pix.height;
857 f->fmt.pix.height = 857 f->code = V4L2_MBUS_FMT_FIXED;
858 v4l2_format_table[h->video_format].fmt.pix.height; 858 f->field = V4L2_FIELD_INTERLACED;
859 f->colorspace = V4L2_COLORSPACE_SMPTE170M;
859 return 0; 860 return 0;
860} 861}
861 862
862static int saa6752hs_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f) 863static int saa6752hs_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
864{
865 struct v4l2_mbus_framefmt mbus_fmt;
866 int err = saa6752hs_g_mbus_fmt(sd, &mbus_fmt);
867
868 f->fmt.pix.width = mbus_fmt.width;
869 f->fmt.pix.height = mbus_fmt.height;
870 return err;
871}
872
873static int saa6752hs_s_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *f)
863{ 874{
864 struct saa6752hs_state *h = to_state(sd); 875 struct saa6752hs_state *h = to_state(sd);
865 int dist_352, dist_480, dist_720; 876 int dist_352, dist_480, dist_720;
866 877
878 if (f->code != V4L2_MBUS_FMT_FIXED)
879 return -EINVAL;
880
867 /* 881 /*
868 FIXME: translate and round width/height into EMPRESS 882 FIXME: translate and round width/height into EMPRESS
869 subsample type: 883 subsample type:
@@ -876,31 +890,43 @@ static int saa6752hs_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
876 D1 | 720x576 | 720x480 890 D1 | 720x576 | 720x480
877 */ 891 */
878 892
879 dist_352 = abs(f->fmt.pix.width - 352); 893 dist_352 = abs(f->width - 352);
880 dist_480 = abs(f->fmt.pix.width - 480); 894 dist_480 = abs(f->width - 480);
881 dist_720 = abs(f->fmt.pix.width - 720); 895 dist_720 = abs(f->width - 720);
882 if (dist_720 < dist_480) { 896 if (dist_720 < dist_480) {
883 f->fmt.pix.width = 720; 897 f->width = 720;
884 f->fmt.pix.height = 576; 898 f->height = 576;
885 h->video_format = SAA6752HS_VF_D1; 899 h->video_format = SAA6752HS_VF_D1;
886 } else if (dist_480 < dist_352) { 900 } else if (dist_480 < dist_352) {
887 f->fmt.pix.width = 480; 901 f->width = 480;
888 f->fmt.pix.height = 576; 902 f->height = 576;
889 h->video_format = SAA6752HS_VF_2_3_D1; 903 h->video_format = SAA6752HS_VF_2_3_D1;
890 } else { 904 } else {
891 f->fmt.pix.width = 352; 905 f->width = 352;
892 if (abs(f->fmt.pix.height - 576) < 906 if (abs(f->height - 576) <
893 abs(f->fmt.pix.height - 288)) { 907 abs(f->height - 288)) {
894 f->fmt.pix.height = 576; 908 f->height = 576;
895 h->video_format = SAA6752HS_VF_1_2_D1; 909 h->video_format = SAA6752HS_VF_1_2_D1;
896 } else { 910 } else {
897 f->fmt.pix.height = 288; 911 f->height = 288;
898 h->video_format = SAA6752HS_VF_SIF; 912 h->video_format = SAA6752HS_VF_SIF;
899 } 913 }
900 } 914 }
915 f->field = V4L2_FIELD_INTERLACED;
916 f->colorspace = V4L2_COLORSPACE_SMPTE170M;
901 return 0; 917 return 0;
902} 918}
903 919
920static int saa6752hs_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
921{
922 struct v4l2_mbus_framefmt mbus_fmt;
923
924 mbus_fmt.width = f->fmt.pix.width;
925 mbus_fmt.height = f->fmt.pix.height;
926 mbus_fmt.code = V4L2_MBUS_FMT_FIXED;
927 return saa6752hs_s_mbus_fmt(sd, &mbus_fmt);
928}
929
904static int saa6752hs_s_std(struct v4l2_subdev *sd, v4l2_std_id std) 930static int saa6752hs_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
905{ 931{
906 struct saa6752hs_state *h = to_state(sd); 932 struct saa6752hs_state *h = to_state(sd);
@@ -934,6 +960,8 @@ static const struct v4l2_subdev_core_ops saa6752hs_core_ops = {
934static const struct v4l2_subdev_video_ops saa6752hs_video_ops = { 960static const struct v4l2_subdev_video_ops saa6752hs_video_ops = {
935 .s_fmt = saa6752hs_s_fmt, 961 .s_fmt = saa6752hs_s_fmt,
936 .g_fmt = saa6752hs_g_fmt, 962 .g_fmt = saa6752hs_g_fmt,
963 .s_mbus_fmt = saa6752hs_s_mbus_fmt,
964 .g_mbus_fmt = saa6752hs_g_mbus_fmt,
937}; 965};
938 966
939static const struct v4l2_subdev_ops saa6752hs_ops = { 967static const struct v4l2_subdev_ops saa6752hs_ops = {