aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/tvp5150.c
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2010-03-14 09:59:16 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-05-19 11:58:49 -0400
commitd37dad497c77149e99cb3f4086cfc3b8d8150135 (patch)
tree247f4bb187f4ecfe1cd6edd01588860e5fc5778c /drivers/media/video/tvp5150.c
parent1dbf85397a686488b4be412af1cc069ae63a5ecc (diff)
V4L/DVB: tvp5150: support new vbi ops to set/get VBI format
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/tvp5150.c')
-rw-r--r--drivers/media/video/tvp5150.c66
1 files changed, 41 insertions, 25 deletions
diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c
index caf0a708542e..853dd6f39b97 100644
--- a/drivers/media/video/tvp5150.c
+++ b/drivers/media/video/tvp5150.c
@@ -891,29 +891,26 @@ static int tvp5150_s_routing(struct v4l2_subdev *sd,
891 return 0; 891 return 0;
892} 892}
893 893
894static int tvp5150_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt) 894static int tvp5150_s_raw_fmt(struct v4l2_subdev *sd, struct v4l2_vbi_format *fmt)
895{
896 /* this is for capturing 36 raw vbi lines
897 if there's a way to cut off the beginning 2 vbi lines
898 with the tvp5150 then the vbi line count could be lowered
899 to 17 lines/field again, although I couldn't find a register
900 which could do that cropping */
901 if (fmt->sample_format == V4L2_PIX_FMT_GREY)
902 tvp5150_write(sd, TVP5150_LUMA_PROC_CTL_1, 0x70);
903 if (fmt->count[0] == 18 && fmt->count[1] == 18) {
904 tvp5150_write(sd, TVP5150_VERT_BLANKING_START, 0x00);
905 tvp5150_write(sd, TVP5150_VERT_BLANKING_STOP, 0x01);
906 }
907 return 0;
908}
909
910static int tvp5150_s_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *svbi)
895{ 911{
896 struct v4l2_sliced_vbi_format *svbi;
897 int i; 912 int i;
898 913
899 /* raw vbi */
900 if (fmt->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
901 /* this is for capturing 36 raw vbi lines
902 if there's a way to cut off the beginning 2 vbi lines
903 with the tvp5150 then the vbi line count could be lowered
904 to 17 lines/field again, although I couldn't find a register
905 which could do that cropping */
906 if (fmt->fmt.vbi.sample_format == V4L2_PIX_FMT_GREY)
907 tvp5150_write(sd, TVP5150_LUMA_PROC_CTL_1, 0x70);
908 if (fmt->fmt.vbi.count[0] == 18 && fmt->fmt.vbi.count[1] == 18) {
909 tvp5150_write(sd, TVP5150_VERT_BLANKING_START, 0x00);
910 tvp5150_write(sd, TVP5150_VERT_BLANKING_STOP, 0x01);
911 }
912 return 0;
913 }
914 if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE)
915 return -EINVAL;
916 svbi = &fmt->fmt.sliced;
917 if (svbi->service_set != 0) { 914 if (svbi->service_set != 0) {
918 for (i = 0; i <= 23; i++) { 915 for (i = 0; i <= 23; i++) {
919 svbi->service_lines[1][i] = 0; 916 svbi->service_lines[1][i] = 0;
@@ -937,14 +934,24 @@ static int tvp5150_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
937 return 0; 934 return 0;
938} 935}
939 936
940static int tvp5150_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt) 937static int tvp5150_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
941{ 938{
942 struct v4l2_sliced_vbi_format *svbi; 939 switch (fmt->type) {
943 int i, mask = 0; 940 case V4L2_BUF_TYPE_VBI_CAPTURE:
941 return tvp5150_s_raw_fmt(sd, &fmt->fmt.vbi);
944 942
945 if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE) 943 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
944 return tvp5150_s_sliced_fmt(sd, &fmt->fmt.sliced);
945
946 default:
946 return -EINVAL; 947 return -EINVAL;
947 svbi = &fmt->fmt.sliced; 948 }
949}
950
951static int tvp5150_g_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *svbi)
952{
953 int i, mask = 0;
954
948 memset(svbi, 0, sizeof(*svbi)); 955 memset(svbi, 0, sizeof(*svbi));
949 956
950 for (i = 0; i <= 23; i++) { 957 for (i = 0; i <= 23; i++) {
@@ -956,6 +963,12 @@ static int tvp5150_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
956 return 0; 963 return 0;
957} 964}
958 965
966static int tvp5150_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
967{
968 if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE)
969 return -EINVAL;
970 return tvp5150_g_sliced_fmt(sd, &fmt->fmt.sliced);
971}
959 972
960static int tvp5150_g_chip_ident(struct v4l2_subdev *sd, 973static int tvp5150_g_chip_ident(struct v4l2_subdev *sd,
961 struct v4l2_dbg_chip_ident *chip) 974 struct v4l2_dbg_chip_ident *chip)
@@ -1050,6 +1063,9 @@ static const struct v4l2_subdev_video_ops tvp5150_video_ops = {
1050 1063
1051static const struct v4l2_subdev_vbi_ops tvp5150_vbi_ops = { 1064static const struct v4l2_subdev_vbi_ops tvp5150_vbi_ops = {
1052 .g_sliced_vbi_cap = tvp5150_g_sliced_vbi_cap, 1065 .g_sliced_vbi_cap = tvp5150_g_sliced_vbi_cap,
1066 .g_sliced_fmt = tvp5150_g_sliced_fmt,
1067 .s_sliced_fmt = tvp5150_s_sliced_fmt,
1068 .s_raw_fmt = tvp5150_s_raw_fmt,
1053}; 1069};
1054 1070
1055static const struct v4l2_subdev_ops tvp5150_ops = { 1071static const struct v4l2_subdev_ops tvp5150_ops = {