aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Isely <isely@pobox.com>2007-04-08 00:11:47 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-04-27 14:45:30 -0400
commit31a1854706707dc3b67eb0d3bf0f51c67d91c82e (patch)
tree724a4659f07d8b040578da07de3f07909336116d
parent4f210e072235c3c123b068d348a1a02e624ff5be (diff)
V4L/DVB (5507): Pvrusb2: Gather USB bus address info and report it
The V4L2 API requires a unique bus_info string returned as part of the v4l2_capability structure. These changes gather up the USB address information, from the underlying device, into a string and report that out through v4l2 and via sysfs (for completeness). Signed-off-by: Mike Isely <isely@pobox.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h2
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c12
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.h3
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-sysfs.c30
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-v4l2.c2
5 files changed, 49 insertions, 0 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
index 16bd74199601..ce66ab8ff2d8 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
@@ -283,6 +283,8 @@ struct pvr2_hdw {
283 int unit_number; /* ID for driver instance */ 283 int unit_number; /* ID for driver instance */
284 unsigned long serial_number; /* ID for hardware itself */ 284 unsigned long serial_number; /* ID for hardware itself */
285 285
286 char bus_info[32]; /* Bus location info */
287
286 /* Minor numbers used by v4l logic (yes, this is a hack, as there 288 /* Minor numbers used by v4l logic (yes, this is a hack, as there
287 should be no v4l junk here). Probably a better way to do this. */ 289 should be no v4l junk here). Probably a better way to do this. */
288 int v4l_minor_number_video; 290 int v4l_minor_number_video;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index 504301ee56fe..acf651e01f94 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -1008,6 +1008,13 @@ unsigned long pvr2_hdw_get_sn(struct pvr2_hdw *hdw)
1008 return hdw->serial_number; 1008 return hdw->serial_number;
1009} 1009}
1010 1010
1011
1012const char *pvr2_hdw_get_bus_info(struct pvr2_hdw *hdw)
1013{
1014 return hdw->bus_info;
1015}
1016
1017
1011unsigned long pvr2_hdw_get_cur_freq(struct pvr2_hdw *hdw) 1018unsigned long pvr2_hdw_get_cur_freq(struct pvr2_hdw *hdw)
1012{ 1019{
1013 return hdw->freqSelector ? hdw->freqValTelevision : hdw->freqValRadio; 1020 return hdw->freqSelector ? hdw->freqValTelevision : hdw->freqValRadio;
@@ -2105,6 +2112,11 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
2105 hdw->usb_intf = intf; 2112 hdw->usb_intf = intf;
2106 hdw->usb_dev = interface_to_usbdev(intf); 2113 hdw->usb_dev = interface_to_usbdev(intf);
2107 2114
2115 scnprintf(hdw->bus_info,sizeof(hdw->bus_info),
2116 "usb %s address %d",
2117 hdw->usb_dev->dev.bus_id,
2118 hdw->usb_dev->devnum);
2119
2108 ifnum = hdw->usb_intf->cur_altsetting->desc.bInterfaceNumber; 2120 ifnum = hdw->usb_intf->cur_altsetting->desc.bInterfaceNumber;
2109 usb_set_interface(hdw->usb_dev,ifnum,0); 2121 usb_set_interface(hdw->usb_dev,ifnum,0);
2110 2122
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.h b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
index 0c9cca43ff85..4dba8d006324 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
@@ -124,6 +124,9 @@ struct usb_device *pvr2_hdw_get_dev(struct pvr2_hdw *);
124/* Retrieve serial number of device */ 124/* Retrieve serial number of device */
125unsigned long pvr2_hdw_get_sn(struct pvr2_hdw *); 125unsigned long pvr2_hdw_get_sn(struct pvr2_hdw *);
126 126
127/* Retrieve bus location info of device */
128const char *pvr2_hdw_get_bus_info(struct pvr2_hdw *);
129
127/* Called when hardware has been unplugged */ 130/* Called when hardware has been unplugged */
128void pvr2_hdw_disconnect(struct pvr2_hdw *); 131void pvr2_hdw_disconnect(struct pvr2_hdw *);
129 132
diff --git a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
index 91396fd573e4..a741c556a39a 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
@@ -42,9 +42,11 @@ struct pvr2_sysfs {
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_v4l_radio_minor_number;
44 struct class_device_attribute attr_unit_number; 44 struct class_device_attribute attr_unit_number;
45 struct class_device_attribute attr_bus_info;
45 int v4l_minor_number_created_ok; 46 int v4l_minor_number_created_ok;
46 int v4l_radio_minor_number_created_ok; 47 int v4l_radio_minor_number_created_ok;
47 int unit_number_created_ok; 48 int unit_number_created_ok;
49 int bus_info_created_ok;
48}; 50};
49 51
50#ifdef CONFIG_VIDEO_PVRUSB2_DEBUGIFC 52#ifdef CONFIG_VIDEO_PVRUSB2_DEBUGIFC
@@ -705,6 +707,10 @@ static void class_dev_destroy(struct pvr2_sysfs *sfp)
705 pvr2_sysfs_tear_down_debugifc(sfp); 707 pvr2_sysfs_tear_down_debugifc(sfp);
706#endif /* CONFIG_VIDEO_PVRUSB2_DEBUGIFC */ 708#endif /* CONFIG_VIDEO_PVRUSB2_DEBUGIFC */
707 pvr2_sysfs_tear_down_controls(sfp); 709 pvr2_sysfs_tear_down_controls(sfp);
710 if (sfp->bus_info_created_ok) {
711 class_device_remove_file(sfp->class_dev,
712 &sfp->attr_bus_info);
713 }
708 if (sfp->v4l_minor_number_created_ok) { 714 if (sfp->v4l_minor_number_created_ok) {
709 class_device_remove_file(sfp->class_dev, 715 class_device_remove_file(sfp->class_dev,
710 &sfp->attr_v4l_minor_number); 716 &sfp->attr_v4l_minor_number);
@@ -735,6 +741,16 @@ static ssize_t v4l_minor_number_show(struct class_device *class_dev,char *buf)
735} 741}
736 742
737 743
744static ssize_t bus_info_show(struct class_device *class_dev,char *buf)
745{
746 struct pvr2_sysfs *sfp;
747 sfp = (struct pvr2_sysfs *)class_dev->class_data;
748 if (!sfp) return -EINVAL;
749 return scnprintf(buf,PAGE_SIZE,"%s\n",
750 pvr2_hdw_get_bus_info(sfp->channel.hdw));
751}
752
753
738static ssize_t v4l_radio_minor_number_show(struct class_device *class_dev, 754static ssize_t v4l_radio_minor_number_show(struct class_device *class_dev,
739 char *buf) 755 char *buf)
740{ 756{
@@ -836,6 +852,20 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
836 sfp->unit_number_created_ok = !0; 852 sfp->unit_number_created_ok = !0;
837 } 853 }
838 854
855 sfp->attr_bus_info.attr.owner = THIS_MODULE;
856 sfp->attr_bus_info.attr.name = "bus_info_str";
857 sfp->attr_bus_info.attr.mode = S_IRUGO;
858 sfp->attr_bus_info.show = bus_info_show;
859 sfp->attr_bus_info.store = NULL;
860 ret = class_device_create_file(sfp->class_dev,
861 &sfp->attr_bus_info);
862 if (ret < 0) {
863 printk(KERN_WARNING "%s: class_device_create_file error: %d\n",
864 __FUNCTION__, ret);
865 } else {
866 sfp->bus_info_created_ok = !0;
867 }
868
839 pvr2_sysfs_add_controls(sfp); 869 pvr2_sysfs_add_controls(sfp);
840#ifdef CONFIG_VIDEO_PVRUSB2_DEBUGIFC 870#ifdef CONFIG_VIDEO_PVRUSB2_DEBUGIFC
841 pvr2_sysfs_add_debugifc(sfp); 871 pvr2_sysfs_add_debugifc(sfp);
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
index 25d3830b482a..4563b3df8a0d 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
@@ -203,6 +203,8 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
203 struct v4l2_capability *cap = arg; 203 struct v4l2_capability *cap = arg;
204 204
205 memcpy(cap, &pvr_capability, sizeof(struct v4l2_capability)); 205 memcpy(cap, &pvr_capability, sizeof(struct v4l2_capability));
206 strlcpy(cap->bus_info,pvr2_hdw_get_bus_info(hdw),
207 sizeof(cap->bus_info));
206 208
207 ret = 0; 209 ret = 0;
208 break; 210 break;