V4L/DVB: saa7115: support new vbi ops to set/get VBI format
authorHans Verkuil <hverkuil@xs4all.nl>
Sun, 14 Mar 2010 13:10:14 +0000 (10:10 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Wed, 19 May 2010 15:58:46 +0000 (12:58 -0300)
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/saa7115.c

index cfee323d9c2c9ecc74ca7f17419174ae6a079731..cf77318ede4314fcbffb5d1fcba3cc64e0c43f12 100644 (file)
@@ -1091,7 +1091,7 @@ static void saa711x_set_lcr(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_forma
                                saa7115_cfg_vbi_off);
 }
 
-static int saa711x_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
+static int saa711x_g_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *sliced)
 {
        static u16 lcr2vbi[] = {
                0, V4L2_SLICED_TELETEXT_B, 0,   /* 1 */
@@ -1100,11 +1100,8 @@ static int saa711x_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
                V4L2_SLICED_VPS, 0, 0, 0, 0,    /* 7 */
                0, 0, 0, 0
        };
-       struct v4l2_sliced_vbi_format *sliced = &fmt->fmt.sliced;
        int i;
 
-       if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE)
-               return -EINVAL;
        memset(sliced, 0, sizeof(*sliced));
        /* done if using raw VBI */
        if (saa711x_read(sd, R_80_GLOBAL_CNTL_1) & 0x10)
@@ -1120,16 +1117,31 @@ static int saa711x_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
        return 0;
 }
 
+static int saa711x_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
+{
+       if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE)
+               return -EINVAL;
+       return saa711x_g_sliced_fmt(sd, &fmt->fmt.sliced);
+}
+
+static int saa711x_s_raw_fmt(struct v4l2_subdev *sd, struct v4l2_vbi_format *fmt)
+{
+       saa711x_set_lcr(sd, NULL);
+       return 0;
+}
+
+static int saa711x_s_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *fmt)
+{
+       saa711x_set_lcr(sd, fmt);
+       return 0;
+}
+
 static int saa711x_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
 {
-       if (fmt->type == V4L2_BUF_TYPE_SLICED_VBI_CAPTURE) {
-               saa711x_set_lcr(sd, &fmt->fmt.sliced);
-               return 0;
-       }
-       if (fmt->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
-               saa711x_set_lcr(sd, NULL);
-               return 0;
-       }
+       if (fmt->type == V4L2_BUF_TYPE_SLICED_VBI_CAPTURE)
+               return saa711x_s_sliced_fmt(sd, &fmt->fmt.sliced);
+       if (fmt->type == V4L2_BUF_TYPE_VBI_CAPTURE)
+               return saa711x_s_raw_fmt(sd, &fmt->fmt.vbi);
        if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
                return -EINVAL;
 
@@ -1558,6 +1570,9 @@ static const struct v4l2_subdev_video_ops saa711x_video_ops = {
 static const struct v4l2_subdev_vbi_ops saa711x_vbi_ops = {
        .g_vbi_data = saa711x_g_vbi_data,
        .decode_vbi_line = saa711x_decode_vbi_line,
+       .g_sliced_fmt = saa711x_g_sliced_fmt,
+       .s_sliced_fmt = saa711x_s_sliced_fmt,
+       .s_raw_fmt = saa711x_s_raw_fmt,
 };
 
 static const struct v4l2_subdev_ops saa711x_ops = {