diff options
author | Mike Isely <isely@pobox.com> | 2006-06-25 19:04:40 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-06-26 23:17:27 -0400 |
commit | 332139635a8c0431cc2eb67adf1e983eb96728e3 (patch) | |
tree | e7646bc367486fd1b52bd80bc789fe26307ed9fe /drivers/media/video/pvrusb2/pvrusb2-sysfs.c | |
parent | 077203a7d464f6ea7c94b4f3ea4b5bd246285fcd (diff) |
V4L/DVB (4239): Handle boolean controls in pvrusb2
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/pvrusb2/pvrusb2-sysfs.c')
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-sysfs.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c index 42540627e30d..c6e6523d74b4 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c +++ b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c | |||
@@ -55,6 +55,7 @@ struct pvr2_sysfs_debugifc { | |||
55 | 55 | ||
56 | struct pvr2_sysfs_ctl_item { | 56 | struct pvr2_sysfs_ctl_item { |
57 | struct class_device_attribute attr_name; | 57 | struct class_device_attribute attr_name; |
58 | struct class_device_attribute attr_type; | ||
58 | struct class_device_attribute attr_min; | 59 | struct class_device_attribute attr_min; |
59 | struct class_device_attribute attr_max; | 60 | struct class_device_attribute attr_max; |
60 | struct class_device_attribute attr_enum; | 61 | struct class_device_attribute attr_enum; |
@@ -64,7 +65,7 @@ struct pvr2_sysfs_ctl_item { | |||
64 | struct pvr2_ctrl *cptr; | 65 | struct pvr2_ctrl *cptr; |
65 | struct pvr2_sysfs *chptr; | 66 | struct pvr2_sysfs *chptr; |
66 | struct pvr2_sysfs_ctl_item *item_next; | 67 | struct pvr2_sysfs_ctl_item *item_next; |
67 | struct attribute *attr_gen[6]; | 68 | struct attribute *attr_gen[7]; |
68 | struct attribute_group grp; | 69 | struct attribute_group grp; |
69 | char name[80]; | 70 | char name[80]; |
70 | }; | 71 | }; |
@@ -92,6 +93,33 @@ static ssize_t show_name(int id,struct class_device *class_dev,char *buf) | |||
92 | return scnprintf(buf,PAGE_SIZE,"%s\n",name); | 93 | return scnprintf(buf,PAGE_SIZE,"%s\n",name); |
93 | } | 94 | } |
94 | 95 | ||
96 | static ssize_t show_type(int id,struct class_device *class_dev,char *buf) | ||
97 | { | ||
98 | struct pvr2_ctrl *cptr; | ||
99 | struct pvr2_sysfs *sfp; | ||
100 | const char *name; | ||
101 | enum pvr2_ctl_type tp; | ||
102 | |||
103 | sfp = (struct pvr2_sysfs *)class_dev->class_data; | ||
104 | if (!sfp) return -EINVAL; | ||
105 | cptr = pvr2_hdw_get_ctrl_by_index(sfp->channel.hdw,id); | ||
106 | if (!cptr) return -EINVAL; | ||
107 | |||
108 | tp = pvr2_ctrl_get_type(cptr); | ||
109 | switch (tp) { | ||
110 | case pvr2_ctl_int: name = "integer"; break; | ||
111 | case pvr2_ctl_enum: name = "enum"; break; | ||
112 | case pvr2_ctl_bitmask: name = "bitmask"; break; | ||
113 | case pvr2_ctl_bool: name = "boolean"; break; | ||
114 | default: name = "?"; break; | ||
115 | } | ||
116 | pvr2_sysfs_trace("pvr2_sysfs(%p) show_type(cid=%d) is %s",sfp,id,name); | ||
117 | |||
118 | if (!name) return -EINVAL; | ||
119 | |||
120 | return scnprintf(buf,PAGE_SIZE,"%s\n",name); | ||
121 | } | ||
122 | |||
95 | static ssize_t show_min(int id,struct class_device *class_dev,char *buf) | 123 | static ssize_t show_min(int id,struct class_device *class_dev,char *buf) |
96 | { | 124 | { |
97 | struct pvr2_ctrl *cptr; | 125 | struct pvr2_ctrl *cptr; |
@@ -289,6 +317,7 @@ static ssize_t sf_name##_##ctl_id(struct class_device *class_dev,const char *buf | |||
289 | 317 | ||
290 | #define CREATE_BATCH(ctl_id) \ | 318 | #define CREATE_BATCH(ctl_id) \ |
291 | CREATE_SHOW_INSTANCE(show_name,ctl_id) \ | 319 | CREATE_SHOW_INSTANCE(show_name,ctl_id) \ |
320 | CREATE_SHOW_INSTANCE(show_type,ctl_id) \ | ||
292 | CREATE_SHOW_INSTANCE(show_min,ctl_id) \ | 321 | CREATE_SHOW_INSTANCE(show_min,ctl_id) \ |
293 | CREATE_SHOW_INSTANCE(show_max,ctl_id) \ | 322 | CREATE_SHOW_INSTANCE(show_max,ctl_id) \ |
294 | CREATE_SHOW_INSTANCE(show_val_norm,ctl_id) \ | 323 | CREATE_SHOW_INSTANCE(show_val_norm,ctl_id) \ |
@@ -361,6 +390,7 @@ CREATE_BATCH(59) | |||
361 | 390 | ||
362 | struct pvr2_sysfs_func_set { | 391 | struct pvr2_sysfs_func_set { |
363 | ssize_t (*show_name)(struct class_device *,char *); | 392 | ssize_t (*show_name)(struct class_device *,char *); |
393 | ssize_t (*show_type)(struct class_device *,char *); | ||
364 | ssize_t (*show_min)(struct class_device *,char *); | 394 | ssize_t (*show_min)(struct class_device *,char *); |
365 | ssize_t (*show_max)(struct class_device *,char *); | 395 | ssize_t (*show_max)(struct class_device *,char *); |
366 | ssize_t (*show_enum)(struct class_device *,char *); | 396 | ssize_t (*show_enum)(struct class_device *,char *); |
@@ -376,6 +406,7 @@ struct pvr2_sysfs_func_set { | |||
376 | #define INIT_BATCH(ctl_id) \ | 406 | #define INIT_BATCH(ctl_id) \ |
377 | [ctl_id] = { \ | 407 | [ctl_id] = { \ |
378 | .show_name = show_name_##ctl_id, \ | 408 | .show_name = show_name_##ctl_id, \ |
409 | .show_type = show_type_##ctl_id, \ | ||
379 | .show_min = show_min_##ctl_id, \ | 410 | .show_min = show_min_##ctl_id, \ |
380 | .show_max = show_max_##ctl_id, \ | 411 | .show_max = show_max_##ctl_id, \ |
381 | .show_enum = show_enum_##ctl_id, \ | 412 | .show_enum = show_enum_##ctl_id, \ |
@@ -486,6 +517,11 @@ static void pvr2_sysfs_add_control(struct pvr2_sysfs *sfp,int ctl_id) | |||
486 | cip->attr_name.attr.mode = S_IRUGO; | 517 | cip->attr_name.attr.mode = S_IRUGO; |
487 | cip->attr_name.show = fp->show_name; | 518 | cip->attr_name.show = fp->show_name; |
488 | 519 | ||
520 | cip->attr_type.attr.owner = THIS_MODULE; | ||
521 | cip->attr_type.attr.name = "type"; | ||
522 | cip->attr_type.attr.mode = S_IRUGO; | ||
523 | cip->attr_type.show = fp->show_type; | ||
524 | |||
489 | cip->attr_min.attr.owner = THIS_MODULE; | 525 | cip->attr_min.attr.owner = THIS_MODULE; |
490 | cip->attr_min.attr.name = "min_val"; | 526 | cip->attr_min.attr.name = "min_val"; |
491 | cip->attr_min.attr.mode = S_IRUGO; | 527 | cip->attr_min.attr.mode = S_IRUGO; |
@@ -521,6 +557,7 @@ static void pvr2_sysfs_add_control(struct pvr2_sysfs *sfp,int ctl_id) | |||
521 | 557 | ||
522 | acnt = 0; | 558 | acnt = 0; |
523 | cip->attr_gen[acnt++] = &cip->attr_name.attr; | 559 | cip->attr_gen[acnt++] = &cip->attr_name.attr; |
560 | cip->attr_gen[acnt++] = &cip->attr_type.attr; | ||
524 | cip->attr_gen[acnt++] = &cip->attr_val.attr; | 561 | cip->attr_gen[acnt++] = &cip->attr_val.attr; |
525 | cip->attr_val.show = fp->show_val_norm; | 562 | cip->attr_val.show = fp->show_val_norm; |
526 | cip->attr_val.store = fp->store_val_norm; | 563 | cip->attr_val.store = fp->store_val_norm; |