aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorMike Isely <isely@pobox.com>2009-01-14 02:22:56 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:42:21 -0400
commit13a887971b6c97751fce62ab803ee93a42a23c5d (patch)
tree53923a8e8a2fba36c519788fbade0322bfbe2b3d /drivers/media
parentd166b02ea6b03766f6fd867fb1fef378a57683e5 (diff)
V4L/DVB (10237): pvrusb2: Generate a device-unique identifier
Implement a new internal function to create a string device identifier. This ID stays with the specific device, making it useful to user space to identify specific devices. We use the serial number if available; otherwise we give up and just spit out a unit/instance ID. Signed-off-by: Mike Isely <isely@pobox.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h12
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c19
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.h3
3 files changed, 34 insertions, 0 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
index de7ee7264be6..d96f0f51076e 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
@@ -195,8 +195,20 @@ struct pvr2_hdw {
195 struct mutex big_lock_mutex; 195 struct mutex big_lock_mutex;
196 int big_lock_held; /* For debugging */ 196 int big_lock_held; /* For debugging */
197 197
198 /* This is a simple string which identifies the instance of this
199 driver. It is unique within the set of existing devices, but
200 there is no attempt to keep the name consistent with the same
201 physical device each time. */
198 char name[32]; 202 char name[32];
199 203
204 /* This is a simple string which identifies the physical device
205 instance itself - if possible. (If not possible, then it is
206 based on the specific driver instance, similar to name above.)
207 The idea here is that userspace might hopefully be able to use
208 this recognize specific tuners. It will encode a serial number,
209 if available. */
210 char identifier[32];
211
200 /* I2C stuff */ 212 /* I2C stuff */
201 struct i2c_adapter i2c_adap; 213 struct i2c_adapter i2c_adap;
202 struct i2c_algorithm i2c_algo; 214 struct i2c_algorithm i2c_algo;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index fa304e5f252a..ac5dad0c5fb0 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -1283,6 +1283,12 @@ const char *pvr2_hdw_get_bus_info(struct pvr2_hdw *hdw)
1283} 1283}
1284 1284
1285 1285
1286const char *pvr2_hdw_get_device_identifier(struct pvr2_hdw *hdw)
1287{
1288 return hdw->identifier;
1289}
1290
1291
1286unsigned long pvr2_hdw_get_cur_freq(struct pvr2_hdw *hdw) 1292unsigned long pvr2_hdw_get_cur_freq(struct pvr2_hdw *hdw)
1287{ 1293{
1288 return hdw->freqSelector ? hdw->freqValTelevision : hdw->freqValRadio; 1294 return hdw->freqSelector ? hdw->freqValTelevision : hdw->freqValRadio;
@@ -2024,6 +2030,19 @@ static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw)
2024 hdw->std_mask_eeprom = V4L2_STD_ALL; 2030 hdw->std_mask_eeprom = V4L2_STD_ALL;
2025 } 2031 }
2026 2032
2033 if (hdw->serial_number) {
2034 idx = scnprintf(hdw->identifier, sizeof(hdw->identifier) - 1,
2035 "sn-%lu", hdw->serial_number);
2036 } else if (hdw->unit_number >= 0) {
2037 idx = scnprintf(hdw->identifier, sizeof(hdw->identifier) - 1,
2038 "unit-%c",
2039 hdw->unit_number + 'a');
2040 } else {
2041 idx = scnprintf(hdw->identifier, sizeof(hdw->identifier) - 1,
2042 "unit-??");
2043 }
2044 hdw->identifier[idx] = 0;
2045
2027 pvr2_hdw_setup_std(hdw); 2046 pvr2_hdw_setup_std(hdw);
2028 2047
2029 if (!get_default_tuner_type(hdw)) { 2048 if (!get_default_tuner_type(hdw)) {
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.h b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
index 1b4fec337c6b..a40f84588cd6 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
@@ -132,6 +132,9 @@ unsigned long pvr2_hdw_get_sn(struct pvr2_hdw *);
132/* Retrieve bus location info of device */ 132/* Retrieve bus location info of device */
133const char *pvr2_hdw_get_bus_info(struct pvr2_hdw *); 133const char *pvr2_hdw_get_bus_info(struct pvr2_hdw *);
134 134
135/* Retrieve per-instance string identifier for this specific device */
136const char *pvr2_hdw_get_device_identifier(struct pvr2_hdw *);
137
135/* Called when hardware has been unplugged */ 138/* Called when hardware has been unplugged */
136void pvr2_hdw_disconnect(struct pvr2_hdw *); 139void pvr2_hdw_disconnect(struct pvr2_hdw *);
137 140