aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/pvrusb2
diff options
context:
space:
mode:
authorPantelis Koukousoulas <pakt223@freemail.gr>2006-12-27 21:07:58 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-02-21 10:34:22 -0500
commit2fdf3d9c94f7f752dacbebb75bbecda3c1b082a0 (patch)
tree24d9c155095a642806cb3fee4210843936f220fe /drivers/media/video/pvrusb2
parent6fcb5b3ef758ca78461d390dc07bed5a4667c521 (diff)
V4L/DVB (5037): Pvrusb2: Implement multiple minor device number handling
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>
Diffstat (limited to 'drivers/media/video/pvrusb2')
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h6
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c14
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.h8
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-sysfs.c33
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-v4l2.c9
5 files changed, 54 insertions, 16 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
index 34b08fbcc6ea..4f69431a8f4e 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
@@ -281,9 +281,9 @@ struct pvr2_hdw {
281 int unit_number; /* ID for driver instance */ 281 int unit_number; /* ID for driver instance */
282 unsigned long serial_number; /* ID for hardware itself */ 282 unsigned long serial_number; /* ID for hardware itself */
283 283
284 /* Minor number used by v4l logic (yes, this is a hack, as there should 284 /* Minor numbers used by v4l logic (yes, this is a hack, as there
285 be no v4l junk here). Probably a better way to do this. */ 285 should be no v4l junk here). Probably a better way to do this. */
286 int v4l_minor_number; 286 int v4l_minor_number[3];
287 287
288 /* Location of eeprom or a negative number if none */ 288 /* Location of eeprom or a negative number if none */
289 int eeprom_addr; 289 int eeprom_addr;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index ca4ef95996be..4b45299e187d 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -1898,7 +1898,9 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
1898 1898
1899 hdw->eeprom_addr = -1; 1899 hdw->eeprom_addr = -1;
1900 hdw->unit_number = -1; 1900 hdw->unit_number = -1;
1901 hdw->v4l_minor_number = -1; 1901 hdw->v4l_minor_number[0] = -1;
1902 hdw->v4l_minor_number[1] = -1;
1903 hdw->v4l_minor_number[2] = -1;
1902 hdw->ctl_write_buffer = kmalloc(PVR2_CTL_BUFFSIZE,GFP_KERNEL); 1904 hdw->ctl_write_buffer = kmalloc(PVR2_CTL_BUFFSIZE,GFP_KERNEL);
1903 if (!hdw->ctl_write_buffer) goto fail; 1905 if (!hdw->ctl_write_buffer) goto fail;
1904 hdw->ctl_read_buffer = kmalloc(PVR2_CTL_BUFFSIZE,GFP_KERNEL); 1906 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,
2546} 2548}
2547 2549
2548 2550
2549int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *hdw) 2551int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *hdw,int index)
2550{ 2552{
2551 return hdw->v4l_minor_number; 2553 return hdw->v4l_minor_number[index];
2552} 2554}
2553 2555
2554 2556
2555/* Store the v4l minor device number */ 2557/* Store a v4l minor device number */
2556void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *hdw,int v) 2558void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *hdw,int index,int v)
2557{ 2559{
2558 hdw->v4l_minor_number = v; 2560 hdw->v4l_minor_number[index] = v;
2559} 2561}
2560 2562
2561 2563
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.h b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
index 29979bb2a768..b1d80bd2678c 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
@@ -205,11 +205,11 @@ int pvr2_hdw_cpufw_get_enabled(struct pvr2_hdw *);
205int pvr2_hdw_cpufw_get(struct pvr2_hdw *,unsigned int offs, 205int pvr2_hdw_cpufw_get(struct pvr2_hdw *,unsigned int offs,
206 char *buf,unsigned int cnt); 206 char *buf,unsigned int cnt);
207 207
208/* Retrieve previously stored v4l minor device number */ 208/* Retrieve a previously stored v4l minor device number */
209int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *); 209int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *,int);
210 210
211/* Store the v4l minor device number */ 211/* Store a v4l minor device number */
212void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *,int); 212void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *,int,int);
213 213
214/* Direct read/write access to chip's registers: 214/* Direct read/write access to chip's registers:
215 chip_id - unique id of chip (e.g. I2C_DRIVERD_xxxx) 215 chip_id - unique id of chip (e.g. I2C_DRIVERD_xxxx)
diff --git a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
index c294f46db9b9..d583c9777b6d 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
@@ -40,8 +40,10 @@ struct pvr2_sysfs {
40 struct pvr2_sysfs_ctl_item *item_first; 40 struct pvr2_sysfs_ctl_item *item_first;
41 struct pvr2_sysfs_ctl_item *item_last; 41 struct pvr2_sysfs_ctl_item *item_last;
42 struct class_device_attribute attr_v4l_minor_number; 42 struct class_device_attribute attr_v4l_minor_number;
43 struct class_device_attribute attr_v4l_radio_minor_number;
43 struct class_device_attribute attr_unit_number; 44 struct class_device_attribute attr_unit_number;
44 int v4l_minor_number_created_ok; 45 int v4l_minor_number_created_ok;
46 int v4l_radio_minor_number_created_ok;
45 int unit_number_created_ok; 47 int unit_number_created_ok;
46}; 48};
47 49
@@ -709,6 +711,10 @@ static void class_dev_destroy(struct pvr2_sysfs *sfp)
709 class_device_remove_file(sfp->class_dev, 711 class_device_remove_file(sfp->class_dev,
710 &sfp->attr_v4l_minor_number); 712 &sfp->attr_v4l_minor_number);
711 } 713 }
714 if (sfp->v4l_radio_minor_number_created_ok) {
715 class_device_remove_file(sfp->class_dev,
716 &sfp->attr_v4l_radio_minor_number);
717 }
712 if (sfp->unit_number_created_ok) { 718 if (sfp->unit_number_created_ok) {
713 class_device_remove_file(sfp->class_dev, 719 class_device_remove_file(sfp->class_dev,
714 &sfp->attr_unit_number); 720 &sfp->attr_unit_number);
@@ -726,7 +732,18 @@ static ssize_t v4l_minor_number_show(struct class_device *class_dev,char *buf)
726 sfp = (struct pvr2_sysfs *)class_dev->class_data; 732 sfp = (struct pvr2_sysfs *)class_dev->class_data;
727 if (!sfp) return -EINVAL; 733 if (!sfp) return -EINVAL;
728 return scnprintf(buf,PAGE_SIZE,"%d\n", 734 return scnprintf(buf,PAGE_SIZE,"%d\n",
729 pvr2_hdw_v4l_get_minor_number(sfp->channel.hdw)); 735 pvr2_hdw_v4l_get_minor_number(sfp->channel.hdw,0));
736}
737
738
739static ssize_t v4l_radio_minor_number_show(struct class_device *class_dev,
740 char *buf)
741{
742 struct pvr2_sysfs *sfp;
743 sfp = (struct pvr2_sysfs *)class_dev->class_data;
744 if (!sfp) return -EINVAL;
745 return scnprintf(buf,PAGE_SIZE,"%d\n",
746 pvr2_hdw_v4l_get_minor_number(sfp->channel.hdw,2));
730} 747}
731 748
732 749
@@ -793,6 +810,20 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
793 sfp->v4l_minor_number_created_ok = !0; 810 sfp->v4l_minor_number_created_ok = !0;
794 } 811 }
795 812
813 sfp->attr_v4l_radio_minor_number.attr.owner = THIS_MODULE;
814 sfp->attr_v4l_radio_minor_number.attr.name = "v4l_radio_minor_number";
815 sfp->attr_v4l_radio_minor_number.attr.mode = S_IRUGO;
816 sfp->attr_v4l_radio_minor_number.show = v4l_radio_minor_number_show;
817 sfp->attr_v4l_radio_minor_number.store = NULL;
818 ret = class_device_create_file(sfp->class_dev,
819 &sfp->attr_v4l_radio_minor_number);
820 if (ret < 0) {
821 printk(KERN_WARNING "%s: class_device_create_file error: %d\n",
822 __FUNCTION__, ret);
823 } else {
824 sfp->v4l_radio_minor_number_created_ok = !0;
825 }
826
796 sfp->attr_unit_number.attr.owner = THIS_MODULE; 827 sfp->attr_unit_number.attr.owner = THIS_MODULE;
797 sfp->attr_unit_number.attr.name = "unit_number"; 828 sfp->attr_unit_number.attr.name = "unit_number";
798 sfp->attr_unit_number.attr.mode = S_IRUGO; 829 sfp->attr_unit_number.attr.mode = S_IRUGO;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
index 6cf17080eb49..02a541fbeff9 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
@@ -722,7 +722,12 @@ static void pvr2_v4l2_dev_destroy(struct pvr2_v4l2_dev *dip)
722 722
723static void pvr2_v4l2_destroy_no_lock(struct pvr2_v4l2 *vp) 723static void pvr2_v4l2_destroy_no_lock(struct pvr2_v4l2 *vp)
724{ 724{
725 pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,-1); 725 pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,
726 pvr2_config_mpeg-1,-1);
727 pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,
728 pvr2_config_vbi-1,-1);
729 pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,
730 pvr2_config_radio-1,-1);
726 pvr2_v4l2_dev_destroy(vp->vdev); 731 pvr2_v4l2_dev_destroy(vp->vdev);
727 732
728 pvr2_trace(PVR2_TRACE_STRUCT,"Destroying pvr2_v4l2 id=%p",vp); 733 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,
1062 } 1067 }
1063 1068
1064 pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw, 1069 pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,
1065 dip->devbase.minor); 1070 cfg-1,dip->devbase.minor);
1066} 1071}
1067 1072
1068 1073