V4L/DVB (5410): Add VIDIOC_G/S_PRIORITY support to ivtv.
authorHans Verkuil <hverkuil@xs4all.nl>
Sat, 10 Mar 2007 20:59:15 +0000 (17:59 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Fri, 27 Apr 2007 18:44:28 +0000 (15:44 -0300)
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/ivtv/ivtv-driver.h
drivers/media/video/ivtv/ivtv-fileops.c
drivers/media/video/ivtv/ivtv-ioctl.c

index 1b2f7a6d311e823977cf66efcccb2ca70a94f36a..ce28923a5c9cea3dd3a9de4b73f41232c3fd3db3 100644 (file)
@@ -502,6 +502,7 @@ struct ivtv_stream {
 struct ivtv_open_id {
        u32 open_id;
        int type;
+       enum v4l2_priority prio;
        struct ivtv *itv;
 };
 
@@ -732,6 +733,7 @@ struct ivtv {
        u32 base_addr;
        u32 irqmask;
 
+       struct v4l2_prio_state prio;
        struct workqueue_struct *irq_work_queues;
        struct work_struct irq_work_queue;
        struct timer_list dma_timer; /* Timer used to catch unfinished DMAs */
index 2f38bb14ace9b8abdabefebcfa1e1ffa0a71269e..1637097ddec742c68ddbf2d17be485855c2b4be8 100644 (file)
@@ -766,6 +766,8 @@ int ivtv_v4l2_close(struct inode *inode, struct file *filp)
 
        IVTV_DEBUG_IOCTL("close() of %s\n", s->name);
 
+       v4l2_prio_close(&itv->prio, &id->prio);
+
        /* Easy case first: this stream was never claimed by us */
        if (s->id != id->open_id) {
                kfree(id);
@@ -849,6 +851,7 @@ int ivtv_v4l2_open(struct inode *inode, struct file *filp)
        }
        item->itv = itv;
        item->type = y;
+       v4l2_prio_open(&itv->prio, &item->prio);
 
        item->open_id = itv->open_id++;
        filp->private_data = item;
index 0e8b639de179b87675e6def137d20fbff766c52f..6f80941e49ec176768096f09ebacbbe48bdaa848 100644 (file)
@@ -703,6 +703,21 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
        if (filp) id = (struct ivtv_open_id *)filp->private_data;
 
        switch (cmd) {
+       case VIDIOC_G_PRIORITY:
+       {
+               enum v4l2_priority *p = arg;
+
+               *p = v4l2_prio_max(&itv->prio);
+               break;
+       }
+
+       case VIDIOC_S_PRIORITY:
+       {
+               enum v4l2_priority *prio = arg;
+
+               return v4l2_prio_change(&itv->prio, &id->prio, *prio);
+       }
+
        case VIDIOC_QUERYCAP:{
                struct v4l2_capability *vcap = arg;
 
@@ -1441,9 +1456,29 @@ static int ivtv_v4l2_do_ioctl(struct inode *inode, struct file *filp,
 {
        struct ivtv_open_id *id = (struct ivtv_open_id *)filp->private_data;
        struct ivtv *itv = id->itv;
+       int ret;
 
        IVTV_DEBUG_IOCTL("v4l2 ioctl 0x%08x\n", cmd);
 
+       /* check priority */
+       switch (cmd) {
+       case VIDIOC_S_CTRL:
+       case VIDIOC_S_STD:
+       case VIDIOC_S_INPUT:
+       case VIDIOC_S_OUTPUT:
+       case VIDIOC_S_TUNER:
+       case VIDIOC_S_FREQUENCY:
+       case VIDIOC_S_FMT:
+       case VIDIOC_S_CROP:
+       case VIDIOC_S_AUDIO:
+       case VIDIOC_S_AUDOUT:
+       case VIDIOC_S_EXT_CTRLS:
+       case VIDIOC_S_FBUF:
+               ret = v4l2_prio_check(&itv->prio, &id->prio);
+               if (ret)
+                       return ret;
+       }
+
        switch (cmd) {
        case VIDIOC_DBG_G_REGISTER:
        case VIDIOC_DBG_S_REGISTER:
@@ -1452,6 +1487,8 @@ static int ivtv_v4l2_do_ioctl(struct inode *inode, struct file *filp,
        case VIDIOC_INT_RESET:
                return ivtv_internal_ioctls(filp, cmd, arg);
 
+       case VIDIOC_G_PRIORITY:
+       case VIDIOC_S_PRIORITY:
        case VIDIOC_QUERYCAP:
        case VIDIOC_ENUMINPUT:
        case VIDIOC_G_INPUT: