]> err.no Git - linux-2.6/commitdiff
V4L/DVB (6695): pvrusb2: Implement functions to pass descriptive hardware info
authorMike Isely <isely@pobox.com>
Mon, 26 Nov 2007 04:58:20 +0000 (01:58 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Fri, 25 Jan 2008 21:03:02 +0000 (19:03 -0200)
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>
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 c08162cc20ae4fbda018cccc19b23bfbd93d9a4f..4ffaf3faff5b32ce2f77c43aaca27c06bf7a871c 100644 (file)
@@ -2474,6 +2474,18 @@ const char *pvr2_hdw_get_driver_name(struct pvr2_hdw *hdw)
 }
 
 
+const char *pvr2_hdw_get_desc(struct pvr2_hdw *hdw)
+{
+       return hdw->hdw_desc->description;
+}
+
+
+const char *pvr2_hdw_get_type(struct pvr2_hdw *hdw)
+{
+       return hdw->hdw_desc->shortname;
+}
+
+
 int pvr2_hdw_is_hsm(struct pvr2_hdw *hdw)
 {
        int result;
index 205fa03057e624f1a8170fbb7cace2b846431203..3ad7a13d6c391839a3135e117ae1102c20a888b1 100644 (file)
@@ -158,6 +158,12 @@ int pvr2_hdw_get_tuner_status(struct pvr2_hdw *,struct v4l2_tuner *);
 /* Query device and see if it thinks it is on a high-speed USB link */
 int pvr2_hdw_is_hsm(struct pvr2_hdw *);
 
+/* Return a string token representative of the hardware type */
+const char *pvr2_hdw_get_type(struct pvr2_hdw *);
+
+/* Return a single line description of the hardware type */
+const char *pvr2_hdw_get_desc(struct pvr2_hdw *);
+
 /* Turn streaming on/off */
 int pvr2_hdw_set_streaming(struct pvr2_hdw *,int);
 
index 3c57a7d8200bfd9724c96f50707e217b50fbb4b1..7a1cd878e31a70f8423bbdf6810914fa2ec3192c 100644 (file)
@@ -43,10 +43,14 @@ struct pvr2_sysfs {
        struct device_attribute attr_v4l_radio_minor_number;
        struct device_attribute attr_unit_number;
        struct device_attribute attr_bus_info;
+       struct device_attribute attr_hdw_name;
+       struct device_attribute attr_hdw_desc;
        int v4l_minor_number_created_ok;
        int v4l_radio_minor_number_created_ok;
        int unit_number_created_ok;
        int bus_info_created_ok;
+       int hdw_name_created_ok;
+       int hdw_desc_created_ok;
 };
 
 #ifdef CONFIG_VIDEO_PVRUSB2_DEBUGIFC
@@ -712,6 +716,14 @@ static void class_dev_destroy(struct pvr2_sysfs *sfp)
        pvr2_sysfs_tear_down_debugifc(sfp);
 #endif /* CONFIG_VIDEO_PVRUSB2_DEBUGIFC */
        pvr2_sysfs_tear_down_controls(sfp);
+       if (sfp->hdw_desc_created_ok) {
+               device_remove_file(sfp->class_dev,
+                                  &sfp->attr_hdw_desc);
+       }
+       if (sfp->hdw_name_created_ok) {
+               device_remove_file(sfp->class_dev,
+                                  &sfp->attr_hdw_name);
+       }
        if (sfp->bus_info_created_ok) {
                device_remove_file(sfp->class_dev,
                                         &sfp->attr_bus_info);
@@ -758,6 +770,28 @@ static ssize_t bus_info_show(struct device *class_dev,
 }
 
 
+static ssize_t hdw_name_show(struct device *class_dev,
+                            struct device_attribute *attr, char *buf)
+{
+       struct pvr2_sysfs *sfp;
+       sfp = (struct pvr2_sysfs *)class_dev->driver_data;
+       if (!sfp) return -EINVAL;
+       return scnprintf(buf,PAGE_SIZE,"%s\n",
+                        pvr2_hdw_get_type(sfp->channel.hdw));
+}
+
+
+static ssize_t hdw_desc_show(struct device *class_dev,
+                            struct device_attribute *attr, char *buf)
+{
+       struct pvr2_sysfs *sfp;
+       sfp = (struct pvr2_sysfs *)class_dev->driver_data;
+       if (!sfp) return -EINVAL;
+       return scnprintf(buf,PAGE_SIZE,"%s\n",
+                        pvr2_hdw_get_desc(sfp->channel.hdw));
+}
+
+
 static ssize_t v4l_radio_minor_number_show(struct device *class_dev,
                                           struct device_attribute *attr,
                                           char *buf)
@@ -871,6 +905,32 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
                sfp->bus_info_created_ok = !0;
        }
 
+       sfp->attr_hdw_name.attr.name = "device_hardware_type";
+       sfp->attr_hdw_name.attr.mode = S_IRUGO;
+       sfp->attr_hdw_name.show = hdw_name_show;
+       sfp->attr_hdw_name.store = NULL;
+       ret = device_create_file(sfp->class_dev,
+                                &sfp->attr_hdw_name);
+       if (ret < 0) {
+               printk(KERN_WARNING "%s: device_create_file error: %d\n",
+                      __FUNCTION__, ret);
+       } else {
+               sfp->hdw_name_created_ok = !0;
+       }
+
+       sfp->attr_hdw_desc.attr.name = "device_hardware_description";
+       sfp->attr_hdw_desc.attr.mode = S_IRUGO;
+       sfp->attr_hdw_desc.show = hdw_desc_show;
+       sfp->attr_hdw_desc.store = NULL;
+       ret = device_create_file(sfp->class_dev,
+                                &sfp->attr_hdw_desc);
+       if (ret < 0) {
+               printk(KERN_WARNING "%s: device_create_file error: %d\n",
+                      __FUNCTION__, ret);
+       } else {
+               sfp->hdw_desc_created_ok = !0;
+       }
+
        pvr2_sysfs_add_controls(sfp);
 #ifdef CONFIG_VIDEO_PVRUSB2_DEBUGIFC
        pvr2_sysfs_add_debugifc(sfp);
index 6f06f595b86cbbd5bde578ab693f4083b3161893..8f0587ebd4bd8609b4e97f785f3641f176b01344 100644 (file)
@@ -205,6 +205,7 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
                memcpy(cap, &pvr_capability, sizeof(struct v4l2_capability));
                strlcpy(cap->bus_info,pvr2_hdw_get_bus_info(hdw),
                        sizeof(cap->bus_info));
+               strlcpy(cap->card,pvr2_hdw_get_desc(hdw),sizeof(cap->card));
 
                ret = 0;
                break;