V4L/DVB (4264): Cx88-blackbird: implement VIDIOC_QUERYCTRL and VIDIOC_QUERYMENU
authorMichael Krufky <mkrufky@linuxtv.org>
Tue, 27 Jun 2006 02:42:39 +0000 (23:42 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Fri, 30 Jun 2006 18:59:27 +0000 (15:59 -0300)
This patch implements the newer v4l2 control features to make the
standard user controls and mpeg encoder controls of cx88-blackbird
video encoder boards available to userspace.

Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/cx88/cx88-blackbird.c
drivers/media/video/cx88/cx88-video.c
drivers/media/video/cx88/cx88.h

index 4ff81582ec56ee5f71b17ec2e402c51730ce4698..349632b48e931a2dff360965703754ba0a3b1d19 100644 (file)
@@ -686,6 +686,39 @@ static struct videobuf_queue_ops blackbird_qops = {
 
 /* ------------------------------------------------------------------ */
 
+static const u32 *ctrl_classes[] = {
+       cx88_user_ctrls,
+       cx2341x_mpeg_ctrls,
+       NULL
+};
+
+static int blackbird_queryctrl(struct cx8802_dev *dev, struct v4l2_queryctrl *qctrl)
+{
+       qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id);
+       if (qctrl->id == 0)
+               return -EINVAL;
+
+       /* Standard V4L2 controls */
+       if (cx8800_ctrl_query(qctrl) == 0)
+               return 0;
+
+       /* MPEG V4L2 controls */
+       if (cx2341x_ctrl_query(&dev->params, qctrl))
+               qctrl->flags |= V4L2_CTRL_FLAG_DISABLED;
+       return 0;
+}
+
+static int blackbird_querymenu(struct cx8802_dev *dev, struct v4l2_querymenu *qmenu)
+{
+       struct v4l2_queryctrl qctrl;
+
+       qctrl.id = qmenu->id;
+       blackbird_queryctrl(dev, &qctrl);
+       return v4l2_ctrl_query_menu(qmenu, &qctrl, cx2341x_ctrl_get_menu(qmenu->id));
+}
+
+/* ------------------------------------------------------------------ */
+
 static int mpeg_do_ioctl(struct inode *inode, struct file *file,
                         unsigned int cmd, void *arg)
 {
@@ -866,6 +899,16 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file,
                       core->name);
                return 0;
        }
+       case VIDIOC_QUERYMENU:
+               return blackbird_querymenu(dev, arg);
+       case VIDIOC_QUERYCTRL:
+       {
+               struct v4l2_queryctrl *c = arg;
+
+               if (blackbird_queryctrl(dev, c) == 0)
+                       return 0;
+               return cx88_do_ioctl(inode, file, 0, dev->core, cmd, arg, mpeg_do_ioctl);
+       }
 
        default:
                return cx88_do_ioctl(inode, file, 0, dev->core, cmd, arg, mpeg_do_ioctl);
index 8d5cf474b68e817c9729d40ad3f5745092290d9c..fe147e3aaa705172df149d0df56aedb33adb1857 100644 (file)
@@ -327,6 +327,51 @@ static struct cx88_ctrl cx8800_ctls[] = {
 };
 static const int CX8800_CTLS = ARRAY_SIZE(cx8800_ctls);
 
+const u32 cx88_user_ctrls[] = {
+       V4L2_CID_USER_CLASS,
+       V4L2_CID_BRIGHTNESS,
+       V4L2_CID_CONTRAST,
+       V4L2_CID_SATURATION,
+       V4L2_CID_HUE,
+       V4L2_CID_AUDIO_VOLUME,
+       V4L2_CID_AUDIO_BALANCE,
+       V4L2_CID_AUDIO_MUTE,
+       0
+};
+EXPORT_SYMBOL(cx88_user_ctrls);
+
+static const u32 *ctrl_classes[] = {
+       cx88_user_ctrls,
+       NULL
+};
+
+int cx8800_ctrl_query(struct v4l2_queryctrl *qctrl)
+{
+       int i;
+
+       if (qctrl->id < V4L2_CID_BASE ||
+           qctrl->id >= V4L2_CID_LASTP1)
+               return -EINVAL;
+       for (i = 0; i < CX8800_CTLS; i++)
+               if (cx8800_ctls[i].v.id == qctrl->id)
+                       break;
+       if (i == CX8800_CTLS) {
+               *qctrl = no_ctl;
+               return 0;
+       }
+       *qctrl = cx8800_ctls[i].v;
+       return 0;
+}
+EXPORT_SYMBOL(cx8800_ctrl_query);
+
+static int cx88_queryctrl(struct v4l2_queryctrl *qctrl)
+{
+       qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id);
+       if (qctrl->id == 0)
+               return -EINVAL;
+       return cx8800_ctrl_query(qctrl);
+}
+
 /* ------------------------------------------------------------------- */
 /* resource management                                                 */
 
@@ -1362,20 +1407,8 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
        case VIDIOC_QUERYCTRL:
        {
                struct v4l2_queryctrl *c = arg;
-               int i;
 
-               if (c->id <  V4L2_CID_BASE ||
-                   c->id >= V4L2_CID_LASTP1)
-                       return -EINVAL;
-               for (i = 0; i < CX8800_CTLS; i++)
-                       if (cx8800_ctls[i].v.id == c->id)
-                               break;
-               if (i == CX8800_CTLS) {
-                       *c = no_ctl;
-                       return 0;
-               }
-               *c = cx8800_ctls[i].v;
-               return 0;
+               return cx88_queryctrl(c);
        }
        case VIDIOC_G_CTRL:
                return get_control(core,arg);
index 9a9a0fc7a41ad26a6df000c15e3a053033cdf749..336e823c7588d1b5ed28d40beb25dab1cbe06197 100644 (file)
@@ -590,6 +590,8 @@ int cx8802_resume_common(struct pci_dev *pci_dev);
 extern int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
                                struct cx88_core *core, unsigned int cmd,
                                void *arg, v4l2_kioctl driver_ioctl);
+extern const u32 cx88_user_ctrls[];
+extern int cx8800_ctrl_query(struct v4l2_queryctrl *qctrl);
 
 /*
  * Local variables: