]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
V4L/DVB (5037): Pvrusb2: Implement multiple minor device number handling
authorPantelis Koukousoulas <pakt223@freemail.gr>
Thu, 28 Dec 2006 02:07:58 +0000 (23:07 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Wed, 21 Feb 2007 15:34:22 +0000 (13:34 -0200)
This is the first patch in preparation of the V4L2/IVTV radio interface.
It does away with the assumption of only one minor per device. It also
adds a file to show the radio minor as well. This can be useful for a
program like pvr-radio.c (when it grows up), since this way it can search
for the minor of the /dev/radioX device it opened and use the video minor
of the same driver instance to get to the actual stream.

The implementation looks kinda ugly. Feel free to improve (that is the
reason behind separate patches anyway).

Signed-off-by: Pantelis Koukousoulas <pakt223@freemail.gr>
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
drivers/media/video/pvrusb2/pvrusb2-hdw.c
drivers/media/video/pvrusb2/pvrusb2-hdw.h
drivers/media/video/pvrusb2/pvrusb2-sysfs.c
drivers/media/video/pvrusb2/pvrusb2-v4l2.c

index 34b08fbcc6eaf8ca0beb49417408a8c17f66cfad..4f69431a8f4ee5c2b5a0d86012f0851c8c54f28f 100644 (file)
@@ -281,9 +281,9 @@ struct pvr2_hdw {
        int unit_number;             /* ID for driver instance */
        unsigned long serial_number; /* ID for hardware itself */
 
-       /* Minor number used by v4l logic (yes, this is a hack, as there should
-          be no v4l junk here).  Probably a better way to do this. */
-       int v4l_minor_number;
+       /* Minor numbers used by v4l logic (yes, this is a hack, as there
+          should be no v4l junk here).  Probably a better way to do this. */
+       int v4l_minor_number[3];
 
        /* Location of eeprom or a negative number if none */
        int eeprom_addr;
index ca4ef95996bec513812a32c84b6184464233626f..4b45299e187d2dc3a6bfc75fd8b7aa2bc2cfb97f 100644 (file)
@@ -1898,7 +1898,9 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
 
        hdw->eeprom_addr = -1;
        hdw->unit_number = -1;
-       hdw->v4l_minor_number = -1;
+       hdw->v4l_minor_number[0] = -1;
+       hdw->v4l_minor_number[1] = -1;
+       hdw->v4l_minor_number[2] = -1;
        hdw->ctl_write_buffer = kmalloc(PVR2_CTL_BUFFSIZE,GFP_KERNEL);
        if (!hdw->ctl_write_buffer) goto fail;
        hdw->ctl_read_buffer = kmalloc(PVR2_CTL_BUFFSIZE,GFP_KERNEL);
@@ -2546,16 +2548,16 @@ int pvr2_hdw_cpufw_get(struct pvr2_hdw *hdw,unsigned int offs,
 }
 
 
-int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *hdw)
+int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *hdw,int index)
 {
-       return hdw->v4l_minor_number;
+       return hdw->v4l_minor_number[index];
 }
 
 
-/* Store the v4l minor device number */
-void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *hdw,int v)
+/* Store a v4l minor device number */
+void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *hdw,int index,int v)
 {
-       hdw->v4l_minor_number = v;
+       hdw->v4l_minor_number[index] = v;
 }
 
 
index 29979bb2a7689fd3d43bb9d2f5634ade6fb4c1c1..b1d80bd2678cb6eebea5c199e5780a34bf624651 100644 (file)
@@ -205,11 +205,11 @@ int pvr2_hdw_cpufw_get_enabled(struct pvr2_hdw *);
 int pvr2_hdw_cpufw_get(struct pvr2_hdw *,unsigned int offs,
                       char *buf,unsigned int cnt);
 
-/* Retrieve previously stored v4l minor device number */
-int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *);
+/* Retrieve previously stored v4l minor device number */
+int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *,int);
 
-/* Store the v4l minor device number */
-void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *,int);
+/* Store a v4l minor device number */
+void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *,int,int);
 
 /* Direct read/write access to chip's registers:
    chip_id - unique id of chip (e.g. I2C_DRIVERD_xxxx)
index c294f46db9b9f421c0a7648ec3cdc9e567098fe1..d583c9777b6deb0537a8777ff0413ab6b9da5aab 100644 (file)
@@ -40,8 +40,10 @@ struct pvr2_sysfs {
        struct pvr2_sysfs_ctl_item *item_first;
        struct pvr2_sysfs_ctl_item *item_last;
        struct class_device_attribute attr_v4l_minor_number;
+       struct class_device_attribute attr_v4l_radio_minor_number;
        struct class_device_attribute attr_unit_number;
        int v4l_minor_number_created_ok;
+       int v4l_radio_minor_number_created_ok;
        int unit_number_created_ok;
 };
 
@@ -709,6 +711,10 @@ static void class_dev_destroy(struct pvr2_sysfs *sfp)
                class_device_remove_file(sfp->class_dev,
                                         &sfp->attr_v4l_minor_number);
        }
+       if (sfp->v4l_radio_minor_number_created_ok) {
+               class_device_remove_file(sfp->class_dev,
+                                        &sfp->attr_v4l_radio_minor_number);
+       }
        if (sfp->unit_number_created_ok) {
                class_device_remove_file(sfp->class_dev,
                                         &sfp->attr_unit_number);
@@ -726,7 +732,18 @@ static ssize_t v4l_minor_number_show(struct class_device *class_dev,char *buf)
        sfp = (struct pvr2_sysfs *)class_dev->class_data;
        if (!sfp) return -EINVAL;
        return scnprintf(buf,PAGE_SIZE,"%d\n",
-                        pvr2_hdw_v4l_get_minor_number(sfp->channel.hdw));
+                        pvr2_hdw_v4l_get_minor_number(sfp->channel.hdw,0));
+}
+
+
+static ssize_t v4l_radio_minor_number_show(struct class_device *class_dev,
+                                          char *buf)
+{
+       struct pvr2_sysfs *sfp;
+       sfp = (struct pvr2_sysfs *)class_dev->class_data;
+       if (!sfp) return -EINVAL;
+       return scnprintf(buf,PAGE_SIZE,"%d\n",
+                        pvr2_hdw_v4l_get_minor_number(sfp->channel.hdw,2));
 }
 
 
@@ -793,6 +810,20 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
                sfp->v4l_minor_number_created_ok = !0;
        }
 
+       sfp->attr_v4l_radio_minor_number.attr.owner = THIS_MODULE;
+       sfp->attr_v4l_radio_minor_number.attr.name = "v4l_radio_minor_number";
+       sfp->attr_v4l_radio_minor_number.attr.mode = S_IRUGO;
+       sfp->attr_v4l_radio_minor_number.show = v4l_radio_minor_number_show;
+       sfp->attr_v4l_radio_minor_number.store = NULL;
+       ret = class_device_create_file(sfp->class_dev,
+                                      &sfp->attr_v4l_radio_minor_number);
+       if (ret < 0) {
+               printk(KERN_WARNING "%s: class_device_create_file error: %d\n",
+                      __FUNCTION__, ret);
+       } else {
+               sfp->v4l_radio_minor_number_created_ok = !0;
+       }
+
        sfp->attr_unit_number.attr.owner = THIS_MODULE;
        sfp->attr_unit_number.attr.name = "unit_number";
        sfp->attr_unit_number.attr.mode = S_IRUGO;
index 6cf17080eb49c5deaf29f53d2feb40700612800e..02a541fbeff9e32c118be57fc424b5831614ddc1 100644 (file)
@@ -722,7 +722,12 @@ static void pvr2_v4l2_dev_destroy(struct pvr2_v4l2_dev *dip)
 
 static void pvr2_v4l2_destroy_no_lock(struct pvr2_v4l2 *vp)
 {
-       pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,-1);
+       pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,
+                                       pvr2_config_mpeg-1,-1);
+       pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,
+                                       pvr2_config_vbi-1,-1);
+       pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,
+                                       pvr2_config_radio-1,-1);
        pvr2_v4l2_dev_destroy(vp->vdev);
 
        pvr2_trace(PVR2_TRACE_STRUCT,"Destroying pvr2_v4l2 id=%p",vp);
@@ -1062,7 +1067,7 @@ static void pvr2_v4l2_dev_init(struct pvr2_v4l2_dev *dip,
        }
 
        pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,
-                                       dip->devbase.minor);
+                                       cfg-1,dip->devbase.minor);
 }