[media] v4l2: add support for SDR transmitter
authorAntti Palosaari <crope@iki.fi>
Sat, 10 Oct 2015 16:51:00 +0000 (13:51 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Tue, 20 Oct 2015 17:40:50 +0000 (15:40 -0200)
New IOCTL ops:
vidioc_enum_fmt_sdr_out
vidioc_g_fmt_sdr_out
vidioc_s_fmt_sdr_out
vidioc_try_fmt_sdr_out

New vb2 buffertype:
V4L2_BUF_TYPE_SDR_OUTPUT

New v4l2 capability:
V4L2_CAP_SDR_OUTPUT

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/v4l2-core/v4l2-compat-ioctl32.c
drivers/media/v4l2-core/v4l2-dev.c
drivers/media/v4l2-core/v4l2-ioctl.c
drivers/media/v4l2-core/videobuf-core.c
include/media/v4l2-ioctl.h
include/trace/events/v4l2.h
include/uapi/linux/videodev2.h

index d032e9a2b212735a25fac4297b5f51e956bf0b01..327e83ac2469ecad9d7e86aa9ca3c5c0c72cf572 100644 (file)
@@ -214,6 +214,7 @@ static int __get_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __us
        case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
                return get_v4l2_sliced_vbi_format(&kp->fmt.sliced, &up->fmt.sliced);
        case V4L2_BUF_TYPE_SDR_CAPTURE:
+       case V4L2_BUF_TYPE_SDR_OUTPUT:
                return get_v4l2_sdr_format(&kp->fmt.sdr, &up->fmt.sdr);
        default:
                pr_info("compat_ioctl32: unexpected VIDIOC_FMT type %d\n",
@@ -260,6 +261,7 @@ static int __put_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __us
        case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
                return put_v4l2_sliced_vbi_format(&kp->fmt.sliced, &up->fmt.sliced);
        case V4L2_BUF_TYPE_SDR_CAPTURE:
+       case V4L2_BUF_TYPE_SDR_OUTPUT:
                return put_v4l2_sdr_format(&kp->fmt.sdr, &up->fmt.sdr);
        default:
                pr_info("compat_ioctl32: unexpected VIDIOC_FMT type %d\n",
index 71a1b93b079071b560370bca7cbcf9cdd1d3c820..6b1eaeddbdb3c9d973866ecb28aab9f24f379e41 100644 (file)
@@ -637,8 +637,8 @@ static void determine_valid_ioctls(struct video_device *vdev)
                               ops->vidioc_try_fmt_sliced_vbi_out)))
                        set_bit(_IOC_NR(VIDIOC_TRY_FMT), valid_ioctls);
                SET_VALID_IOCTL(ops, VIDIOC_G_SLICED_VBI_CAP, vidioc_g_sliced_vbi_cap);
-       } else if (is_sdr) {
-               /* SDR specific ioctls */
+       } else if (is_sdr && is_rx) {
+               /* SDR receiver specific ioctls */
                if (ops->vidioc_enum_fmt_sdr_cap)
                        set_bit(_IOC_NR(VIDIOC_ENUM_FMT), valid_ioctls);
                if (ops->vidioc_g_fmt_sdr_cap)
@@ -647,6 +647,16 @@ static void determine_valid_ioctls(struct video_device *vdev)
                        set_bit(_IOC_NR(VIDIOC_S_FMT), valid_ioctls);
                if (ops->vidioc_try_fmt_sdr_cap)
                        set_bit(_IOC_NR(VIDIOC_TRY_FMT), valid_ioctls);
+       } else if (is_sdr && is_tx) {
+               /* SDR transmitter specific ioctls */
+               if (ops->vidioc_enum_fmt_sdr_out)
+                       set_bit(_IOC_NR(VIDIOC_ENUM_FMT), valid_ioctls);
+               if (ops->vidioc_g_fmt_sdr_out)
+                       set_bit(_IOC_NR(VIDIOC_G_FMT), valid_ioctls);
+               if (ops->vidioc_s_fmt_sdr_out)
+                       set_bit(_IOC_NR(VIDIOC_S_FMT), valid_ioctls);
+               if (ops->vidioc_try_fmt_sdr_out)
+                       set_bit(_IOC_NR(VIDIOC_TRY_FMT), valid_ioctls);
        }
 
        if (is_vid || is_vbi || is_sdr) {
index 056a5ade5870ad0e2948d3da1ee9a2e0143d18dd..073ab36b880a856bcc8b117ba187a9e36b528087 100644 (file)
@@ -153,6 +153,7 @@ const char *v4l2_type_names[] = {
        [V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE] = "vid-cap-mplane",
        [V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE] = "vid-out-mplane",
        [V4L2_BUF_TYPE_SDR_CAPTURE]        = "sdr-cap",
+       [V4L2_BUF_TYPE_SDR_OUTPUT]         = "sdr-out",
 };
 EXPORT_SYMBOL(v4l2_type_names);
 
@@ -326,6 +327,7 @@ static void v4l_print_format(const void *arg, bool write_only)
                                sliced->service_lines[1][i]);
                break;
        case V4L2_BUF_TYPE_SDR_CAPTURE:
+       case V4L2_BUF_TYPE_SDR_OUTPUT:
                sdr = &p->fmt.sdr;
                pr_cont(", pixelformat=%c%c%c%c\n",
                        (sdr->pixelformat >>  0) & 0xff,
@@ -974,6 +976,10 @@ static int check_fmt(struct file *file, enum v4l2_buf_type type)
                if (is_sdr && is_rx && ops->vidioc_g_fmt_sdr_cap)
                        return 0;
                break;
+       case V4L2_BUF_TYPE_SDR_OUTPUT:
+               if (is_sdr && is_tx && ops->vidioc_g_fmt_sdr_out)
+                       return 0;
+               break;
        default:
                break;
        }
@@ -1324,6 +1330,11 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,
                        break;
                ret = ops->vidioc_enum_fmt_sdr_cap(file, fh, arg);
                break;
+       case V4L2_BUF_TYPE_SDR_OUTPUT:
+               if (unlikely(!is_tx || !is_sdr || !ops->vidioc_enum_fmt_sdr_out))
+                       break;
+               ret = ops->vidioc_enum_fmt_sdr_out(file, fh, arg);
+               break;
        }
        if (ret == 0)
                v4l_fill_fmtdesc(p);
@@ -1418,6 +1429,10 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,
                if (unlikely(!is_rx || !is_sdr || !ops->vidioc_g_fmt_sdr_cap))
                        break;
                return ops->vidioc_g_fmt_sdr_cap(file, fh, arg);
+       case V4L2_BUF_TYPE_SDR_OUTPUT:
+               if (unlikely(!is_tx || !is_sdr || !ops->vidioc_g_fmt_sdr_out))
+                       break;
+               return ops->vidioc_g_fmt_sdr_out(file, fh, arg);
        }
        return -EINVAL;
 }
@@ -1497,6 +1512,11 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,
                        break;
                CLEAR_AFTER_FIELD(p, fmt.sdr);
                return ops->vidioc_s_fmt_sdr_cap(file, fh, arg);
+       case V4L2_BUF_TYPE_SDR_OUTPUT:
+               if (unlikely(!is_tx || !is_sdr || !ops->vidioc_s_fmt_sdr_out))
+                       break;
+               CLEAR_AFTER_FIELD(p, fmt.sdr);
+               return ops->vidioc_s_fmt_sdr_out(file, fh, arg);
        }
        return -EINVAL;
 }
@@ -1576,6 +1596,11 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops,
                        break;
                CLEAR_AFTER_FIELD(p, fmt.sdr);
                return ops->vidioc_try_fmt_sdr_cap(file, fh, arg);
+       case V4L2_BUF_TYPE_SDR_OUTPUT:
+               if (unlikely(!is_tx || !is_sdr || !ops->vidioc_try_fmt_sdr_out))
+                       break;
+               CLEAR_AFTER_FIELD(p, fmt.sdr);
+               return ops->vidioc_try_fmt_sdr_out(file, fh, arg);
        }
        return -EINVAL;
 }
index 926836d1813a0051e41f0b35ebb7f85598ca86cf..6c02989ee33f853aa8d6d485ccde23c41646f7e9 100644 (file)
@@ -576,7 +576,8 @@ int videobuf_qbuf(struct videobuf_queue *q, struct v4l2_buffer *b)
                }
                if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT
                    || q->type == V4L2_BUF_TYPE_VBI_OUTPUT
-                   || q->type == V4L2_BUF_TYPE_SLICED_VBI_OUTPUT) {
+                   || q->type == V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
+                   || q->type == V4L2_BUF_TYPE_SDR_OUTPUT) {
                        buf->size = b->bytesused;
                        buf->field = b->field;
                        buf->ts = b->timestamp;
@@ -1154,6 +1155,7 @@ unsigned int videobuf_poll_stream(struct file *file,
                        case V4L2_BUF_TYPE_VIDEO_OUTPUT:
                        case V4L2_BUF_TYPE_VBI_OUTPUT:
                        case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
+                       case V4L2_BUF_TYPE_SDR_OUTPUT:
                                rc = POLLOUT | POLLWRNORM;
                                break;
                        default:
index 8fbbd76d78e84fdea1ecc5e41a195b15bceba8fb..017ffb2220c7c66a808b5d7231350f1fa40a276c 100644 (file)
@@ -36,6 +36,8 @@ struct v4l2_ioctl_ops {
                                              struct v4l2_fmtdesc *f);
        int (*vidioc_enum_fmt_sdr_cap)     (struct file *file, void *fh,
                                            struct v4l2_fmtdesc *f);
+       int (*vidioc_enum_fmt_sdr_out)     (struct file *file, void *fh,
+                                           struct v4l2_fmtdesc *f);
 
        /* VIDIOC_G_FMT handlers */
        int (*vidioc_g_fmt_vid_cap)    (struct file *file, void *fh,
@@ -60,6 +62,8 @@ struct v4l2_ioctl_ops {
                                           struct v4l2_format *f);
        int (*vidioc_g_fmt_sdr_cap)    (struct file *file, void *fh,
                                        struct v4l2_format *f);
+       int (*vidioc_g_fmt_sdr_out)    (struct file *file, void *fh,
+                                       struct v4l2_format *f);
 
        /* VIDIOC_S_FMT handlers */
        int (*vidioc_s_fmt_vid_cap)    (struct file *file, void *fh,
@@ -84,6 +88,8 @@ struct v4l2_ioctl_ops {
                                           struct v4l2_format *f);
        int (*vidioc_s_fmt_sdr_cap)    (struct file *file, void *fh,
                                        struct v4l2_format *f);
+       int (*vidioc_s_fmt_sdr_out)    (struct file *file, void *fh,
+                                       struct v4l2_format *f);
 
        /* VIDIOC_TRY_FMT handlers */
        int (*vidioc_try_fmt_vid_cap)    (struct file *file, void *fh,
@@ -108,6 +114,8 @@ struct v4l2_ioctl_ops {
                                             struct v4l2_format *f);
        int (*vidioc_try_fmt_sdr_cap)    (struct file *file, void *fh,
                                          struct v4l2_format *f);
+       int (*vidioc_try_fmt_sdr_out)    (struct file *file, void *fh,
+                                         struct v4l2_format *f);
 
        /* Buffer handlers */
        int (*vidioc_reqbufs) (struct file *file, void *fh, struct v4l2_requestbuffers *b);
index 04ef89b15ae2f8bf09b4d036c0f6082b60161c61..22afa26e34b2f69f9df1dbf26eb95cd78bfe5986 100644 (file)
@@ -28,6 +28,7 @@
        EM( V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, "VIDEO_CAPTURE_MPLANE" ) \
        EM( V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,  "VIDEO_OUTPUT_MPLANE" ) \
        EM( V4L2_BUF_TYPE_SDR_CAPTURE,          "SDR_CAPTURE" )         \
+       EM( V4L2_BUF_TYPE_SDR_OUTPUT,           "SDR_OUTPUT" )          \
        EMe(V4L2_BUF_TYPE_PRIVATE,              "PRIVATE" )
 
 SHOW_TYPE
index fa8bf2d07a52c9e2a82c704576e71d3bf64f2659..f95e1ef0e7e6223c93cd4f3eb57d8f95fbf5a7c0 100644 (file)
@@ -145,6 +145,7 @@ enum v4l2_buf_type {
        V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE = 9,
        V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE  = 10,
        V4L2_BUF_TYPE_SDR_CAPTURE          = 11,
+       V4L2_BUF_TYPE_SDR_OUTPUT           = 12,
        /* Deprecated, do not use */
        V4L2_BUF_TYPE_PRIVATE              = 0x80,
 };
@@ -159,7 +160,8 @@ enum v4l2_buf_type {
         || (type) == V4L2_BUF_TYPE_VIDEO_OVERLAY               \
         || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY        \
         || (type) == V4L2_BUF_TYPE_VBI_OUTPUT                  \
-        || (type) == V4L2_BUF_TYPE_SLICED_VBI_OUTPUT)
+        || (type) == V4L2_BUF_TYPE_SLICED_VBI_OUTPUT           \
+        || (type) == V4L2_BUF_TYPE_SDR_OUTPUT)
 
 enum v4l2_tuner_type {
        V4L2_TUNER_RADIO             = 1,
@@ -435,6 +437,7 @@ struct v4l2_capability {
 
 #define V4L2_CAP_SDR_CAPTURE           0x00100000  /* Is a SDR capture device */
 #define V4L2_CAP_EXT_PIX_FORMAT                0x00200000  /* Supports the extended pixel format */
+#define V4L2_CAP_SDR_OUTPUT            0x00400000  /* Is a SDR output device */
 
 #define V4L2_CAP_READWRITE              0x01000000  /* read/write systemcalls */
 #define V4L2_CAP_ASYNCIO                0x02000000  /* async I/O */