aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/pvrusb2
diff options
context:
space:
mode:
authorMike Isely <isely@pobox.com>2007-11-25 23:58:20 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-01-25 16:03:02 -0500
commit78a47101ac0ac75019a740d62c70ccb16ff7c7c1 (patch)
treea329cea6e4ebb8145d29e076075bad9595af5318 /drivers/media/video/pvrusb2
parentf66fbd71f24f5f0264bb8526cfb91ea5c6219f50 (diff)
V4L/DVB (6695): pvrusb2: Implement functions to pass descriptive hardware info
Implement additional pvrusb2 device info table entries for a device identifier and a device description. Export this information via the driver's internal API. Make this information available via the sysfs driver interface. Also propagate this information into the v4l2 capability structure. An app can now retrieve and report a descriptive string about the particular type of hardware device it is operating. 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.c12
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.h6
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-sysfs.c60
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-v4l2.c1
4 files changed, 79 insertions, 0 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index c08162cc20ae..4ffaf3faff5b 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -2474,6 +2474,18 @@ const char *pvr2_hdw_get_driver_name(struct pvr2_hdw *hdw)
2474} 2474}
2475 2475
2476 2476
2477const char *pvr2_hdw_get_desc(struct pvr2_hdw *hdw)
2478{
2479 return hdw->hdw_desc->description;
2480}
2481
2482
2483const char *pvr2_hdw_get_type(struct pvr2_hdw *hdw)
2484{
2485 return hdw->hdw_desc->shortname;
2486}
2487
2488
2477int pvr2_hdw_is_hsm(struct pvr2_hdw *hdw) 2489int pvr2_hdw_is_hsm(struct pvr2_hdw *hdw)
2478{ 2490{
2479 int result; 2491 int result;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.h b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
index 205fa03057e6..3ad7a13d6c39 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
@@ -158,6 +158,12 @@ int pvr2_hdw_get_tuner_status(struct pvr2_hdw *,struct v4l2_tuner *);
158/* Query device and see if it thinks it is on a high-speed USB link */ 158/* Query device and see if it thinks it is on a high-speed USB link */
159int pvr2_hdw_is_hsm(struct pvr2_hdw *); 159int pvr2_hdw_is_hsm(struct pvr2_hdw *);
160 160
161/* Return a string token representative of the hardware type */
162const char *pvr2_hdw_get_type(struct pvr2_hdw *);
163
164/* Return a single line description of the hardware type */
165const char *pvr2_hdw_get_desc(struct pvr2_hdw *);
166
161/* Turn streaming on/off */ 167/* Turn streaming on/off */
162int pvr2_hdw_set_streaming(struct pvr2_hdw *,int); 168int pvr2_hdw_set_streaming(struct pvr2_hdw *,int);
163 169
diff --git a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
index 3c57a7d8200b..7a1cd878e31a 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
@@ -43,10 +43,14 @@ struct pvr2_sysfs {
43 struct device_attribute attr_v4l_radio_minor_number; 43 struct device_attribute attr_v4l_radio_minor_number;
44 struct device_attribute attr_unit_number; 44 struct device_attribute attr_unit_number;
45 struct device_attribute attr_bus_info; 45 struct device_attribute attr_bus_info;
46 struct device_attribute attr_hdw_name;
47 struct device_attribute attr_hdw_desc;
46 int v4l_minor_number_created_ok; 48 int v4l_minor_number_created_ok;
47 int v4l_radio_minor_number_created_ok; 49 int v4l_radio_minor_number_created_ok;
48 int unit_number_created_ok; 50 int unit_number_created_ok;
49 int bus_info_created_ok; 51 int bus_info_created_ok;
52 int hdw_name_created_ok;
53 int hdw_desc_created_ok;
50}; 54};
51 55
52#ifdef CONFIG_VIDEO_PVRUSB2_DEBUGIFC 56#ifdef CONFIG_VIDEO_PVRUSB2_DEBUGIFC
@@ -712,6 +716,14 @@ static void class_dev_destroy(struct pvr2_sysfs *sfp)
712 pvr2_sysfs_tear_down_debugifc(sfp); 716 pvr2_sysfs_tear_down_debugifc(sfp);
713#endif /* CONFIG_VIDEO_PVRUSB2_DEBUGIFC */ 717#endif /* CONFIG_VIDEO_PVRUSB2_DEBUGIFC */
714 pvr2_sysfs_tear_down_controls(sfp); 718 pvr2_sysfs_tear_down_controls(sfp);
719 if (sfp->hdw_desc_created_ok) {
720 device_remove_file(sfp->class_dev,
721 &sfp->attr_hdw_desc);
722 }
723 if (sfp->hdw_name_created_ok) {
724 device_remove_file(sfp->class_dev,
725 &sfp->attr_hdw_name);
726 }
715 if (sfp->bus_info_created_ok) { 727 if (sfp->bus_info_created_ok) {
716 device_remove_file(sfp->class_dev, 728 device_remove_file(sfp->class_dev,
717 &sfp->attr_bus_info); 729 &sfp->attr_bus_info);
@@ -758,6 +770,28 @@ static ssize_t bus_info_show(struct device *class_dev,
758} 770}
759 771
760 772
773static ssize_t hdw_name_show(struct device *class_dev,
774 struct device_attribute *attr, char *buf)
775{
776 struct pvr2_sysfs *sfp;
777 sfp = (struct pvr2_sysfs *)class_dev->driver_data;
778 if (!sfp) return -EINVAL;
779 return scnprintf(buf,PAGE_SIZE,"%s\n",
780 pvr2_hdw_get_type(sfp->channel.hdw));
781}
782
783
784static ssize_t hdw_desc_show(struct device *class_dev,
785 struct device_attribute *attr, char *buf)
786{
787 struct pvr2_sysfs *sfp;
788 sfp = (struct pvr2_sysfs *)class_dev->driver_data;
789 if (!sfp) return -EINVAL;
790 return scnprintf(buf,PAGE_SIZE,"%s\n",
791 pvr2_hdw_get_desc(sfp->channel.hdw));
792}
793
794
761static ssize_t v4l_radio_minor_number_show(struct device *class_dev, 795static ssize_t v4l_radio_minor_number_show(struct device *class_dev,
762 struct device_attribute *attr, 796 struct device_attribute *attr,
763 char *buf) 797 char *buf)
@@ -871,6 +905,32 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
871 sfp->bus_info_created_ok = !0; 905 sfp->bus_info_created_ok = !0;
872 } 906 }
873 907
908 sfp->attr_hdw_name.attr.name = "device_hardware_type";
909 sfp->attr_hdw_name.attr.mode = S_IRUGO;
910 sfp->attr_hdw_name.show = hdw_name_show;
911 sfp->attr_hdw_name.store = NULL;
912 ret = device_create_file(sfp->class_dev,
913 &sfp->attr_hdw_name);
914 if (ret < 0) {
915 printk(KERN_WARNING "%s: device_create_file error: %d\n",
916 __FUNCTION__, ret);
917 } else {
918 sfp->hdw_name_created_ok = !0;
919 }
920
921 sfp->attr_hdw_desc.attr.name = "device_hardware_description";
922 sfp->attr_hdw_desc.attr.mode = S_IRUGO;
923 sfp->attr_hdw_desc.show = hdw_desc_show;
924 sfp->attr_hdw_desc.store = NULL;
925 ret = device_create_file(sfp->class_dev,
926 &sfp->attr_hdw_desc);
927 if (ret < 0) {
928 printk(KERN_WARNING "%s: device_create_file error: %d\n",
929 __FUNCTION__, ret);
930 } else {
931 sfp->hdw_desc_created_ok = !0;
932 }
933
874 pvr2_sysfs_add_controls(sfp); 934 pvr2_sysfs_add_controls(sfp);
875#ifdef CONFIG_VIDEO_PVRUSB2_DEBUGIFC 935#ifdef CONFIG_VIDEO_PVRUSB2_DEBUGIFC
876 pvr2_sysfs_add_debugifc(sfp); 936 pvr2_sysfs_add_debugifc(sfp);
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
index 6f06f595b86c..8f0587ebd4bd 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
@@ -205,6 +205,7 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
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), 206 strlcpy(cap->bus_info,pvr2_hdw_get_bus_info(hdw),
207 sizeof(cap->bus_info)); 207 sizeof(cap->bus_info));
208 strlcpy(cap->card,pvr2_hdw_get_desc(hdw),sizeof(cap->card));
208 209
209 ret = 0; 210 ret = 0;
210 break; 211 break;