summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'linux/drivers/media/video/pvrusb2/pvrusb2-sysfs.c')
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-sysfs.c120
1 files changed, 57 insertions, 63 deletions
diff --git a/linux/drivers/media/video/pvrusb2/pvrusb2-sysfs.c b/linux/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
index 6b81def26..0ded41fcb 100644
--- a/linux/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
@@ -30,41 +30,6 @@
#define pvr2_sysfs_trace(...) pvr2_trace(PVR2_TRACE_SYSFS,__VA_ARGS__)
-static char *item_names[] = {
- [PVR2_CID_BRIGHTNESS] = "ctl_brightness",
- [PVR2_CID_CONTRAST] = "ctl_contrast",
- [PVR2_CID_SATURATION] = "ctl_saturation",
- [PVR2_CID_HUE] = "ctl_hue",
- [PVR2_CID_VOLUME] = "ctl_volume",
- [PVR2_CID_BALANCE] = "ctl_balance",
- [PVR2_CID_BASS] = "ctl_bass",
- [PVR2_CID_TREBLE] = "ctl_treble",
- [PVR2_CID_MUTE] = "ctl_mute",
- [PVR2_CID_SRATE] = "ctl_srate",
- [PVR2_CID_AUDIOBITRATE] = "ctl_audio_bitrate",
- [PVR2_CID_AUDIOCRC] = "ctl_audio_crc",
- [PVR2_CID_AUDIOEMPHASIS] = "ctl_audio_emphasis",
- [PVR2_CID_VBR] = "ctl_vbr",
- [PVR2_CID_AVERAGEVIDEOBITRATE] = "ctl_video_average_bitrate",
- [PVR2_CID_PEAKVIDEOBITRATE] = "ctl_video_peak_bitrate",
- [PVR2_CID_VIDEOSTANDARD] = "ctl_video_standard",
- [PVR2_CID_INPUT] = "ctl_input",
- [PVR2_CID_AUDIOMODE] = "ctl_audio_mode",
- [PVR2_CID_FREQUENCY] = "ctl_frequency",
- [PVR2_CID_HRES] = "ctl_resolution_hor",
- [PVR2_CID_VRES] = "ctl_resolution_ver",
- [PVR2_CID_INTERLACE] = "ctl_interlace",
- [PVR2_CID_AUDIOLAYER] = "ctl_audio_layer",
- [PVR2_CID_CHANNEL] = "ctl_channel",
- [PVR2_CID_CHANPROG_ID] = "ctl_freq_table_channel",
- [PVR2_CID_CHANPROG_FREQ] = "ctl_freq_table_value",
- [PVR2_CID_SIGNAL_PRESENT] = "ctl_signal_present",
- [PVR2_CID_STREAMING_ENABLED] = "ctl_streaming_enabled",
- [PVR2_CID_HSM] = "ctl_usb_speed",
- [PVR2_CID_SUBSYS_MASK] = "ctl_debug_subsys_mask",
- [PVR2_CID_SUBSYS_STREAM_MASK] = "ctl_debug_subsys_stream_mask",
-};
-
struct pvr2_sysfs {
struct pvr2_channel channel;
struct class_device *class_dev;
@@ -88,11 +53,12 @@ struct pvr2_sysfs_ctl_item {
struct class_device_attribute attr_max;
struct class_device_attribute attr_enum;
struct class_device_attribute attr_val;
- int attr_id;
+ struct pvr2_ctrl *cptr;
struct pvr2_sysfs *chptr;
struct pvr2_sysfs_ctl_item *item_next;
struct attribute *attr_gen[5];
struct attribute_group grp;
+ char name[25];
};
struct pvr2_sysfs_class {
@@ -101,13 +67,16 @@ struct pvr2_sysfs_class {
static ssize_t show_name(int id,struct class_device *class_dev,char *buf)
{
+ struct pvr2_ctrl *cptr;
struct pvr2_sysfs *sfp;
const char *name;
sfp = (struct pvr2_sysfs *)class_dev->class_data;
if (!sfp) return -EINVAL;
- name = pvr2_hdw_get_ctl_name(sfp->channel.hdw,id);
+ cptr = pvr2_hdw_get_ctrl_by_index(sfp->channel.hdw,id);
+ if (!pvr2_ctrl_is_valid(cptr)) return -EINVAL;
+ name = pvr2_ctrl_get_desc(cptr);
pvr2_sysfs_trace("pvr2_sysfs(%p) show_name(cid=%d) is %s",sfp,id,name);
if (!name) return -EINVAL;
@@ -117,13 +86,15 @@ static ssize_t show_name(int id,struct class_device *class_dev,char *buf)
static ssize_t show_min(int id,struct class_device *class_dev,char *buf)
{
+ struct pvr2_ctrl *cptr;
struct pvr2_sysfs *sfp;
int val;
sfp = (struct pvr2_sysfs *)class_dev->class_data;
if (!sfp) return -EINVAL;
- val = pvr2_hdw_get_ctl_min_value(sfp->channel.hdw,id);
-
+ cptr = pvr2_hdw_get_ctrl_by_index(sfp->channel.hdw,id);
+ if (!pvr2_ctrl_is_valid(cptr)) return -EINVAL;
+ val = pvr2_ctrl_get_min_value(cptr);
pvr2_sysfs_trace("pvr2_sysfs(%p) show_min(cid=%d) is %d",sfp,id,val);
return scnprintf(buf,PAGE_SIZE,"%d\n",val);
@@ -131,12 +102,15 @@ static ssize_t show_min(int id,struct class_device *class_dev,char *buf)
static ssize_t show_max(int id,struct class_device *class_dev,char *buf)
{
+ struct pvr2_ctrl *cptr;
struct pvr2_sysfs *sfp;
int val;
sfp = (struct pvr2_sysfs *)class_dev->class_data;
if (!sfp) return -EINVAL;
- val = pvr2_hdw_get_ctl_max_value(sfp->channel.hdw,id);
+ cptr = pvr2_hdw_get_ctrl_by_index(sfp->channel.hdw,id);
+ if (!pvr2_ctrl_is_valid(cptr)) return -EINVAL;
+ val = pvr2_ctrl_get_max_value(cptr);
pvr2_sysfs_trace("pvr2_sysfs(%p) show_max(cid=%d) is %d",sfp,id,val);
@@ -145,12 +119,15 @@ static ssize_t show_max(int id,struct class_device *class_dev,char *buf)
static ssize_t show_val_int(int id,struct class_device *class_dev,char *buf)
{
+ struct pvr2_ctrl *cptr;
struct pvr2_sysfs *sfp;
int val;
sfp = (struct pvr2_sysfs *)class_dev->class_data;
if (!sfp) return -EINVAL;
- val = pvr2_hdw_get_ctl_value(sfp->channel.hdw,id);
+ cptr = pvr2_hdw_get_ctrl_by_index(sfp->channel.hdw,id);
+ if (!pvr2_ctrl_is_valid(cptr)) return -EINVAL;
+ val = pvr2_ctrl_get_value(cptr);
pvr2_sysfs_trace("pvr2_sysfs(%p) show_val_int(cid=%d) is %d",
sfp,id,val);
@@ -160,15 +137,18 @@ static ssize_t show_val_int(int id,struct class_device *class_dev,char *buf)
static ssize_t show_val_enum(int id,struct class_device *class_dev,char *buf)
{
+ struct pvr2_ctrl *cptr;
struct pvr2_sysfs *sfp;
int val;
const char *name;
sfp = (struct pvr2_sysfs *)class_dev->class_data;
if (!sfp) return -EINVAL;
- val = pvr2_hdw_get_ctl_value(sfp->channel.hdw,id);
+ cptr = pvr2_hdw_get_ctrl_by_index(sfp->channel.hdw,id);
+ if (!pvr2_ctrl_is_valid(cptr)) return -EINVAL;
- name = pvr2_hdw_get_ctl_value_name(sfp->channel.hdw,id,val);
+ val = pvr2_ctrl_get_value(cptr);
+ name = pvr2_ctrl_get_value_name(cptr,val);
pvr2_sysfs_trace("pvr2_sysfs(%p) show_val_enum(cid=%d) is %s (%d)",
sfp,id,name,val);
@@ -178,6 +158,7 @@ static ssize_t show_val_enum(int id,struct class_device *class_dev,char *buf)
static ssize_t show_enum(int id,struct class_device *class_dev,char *buf)
{
+ struct pvr2_ctrl *cptr;
struct pvr2_sysfs *sfp;
int minval,maxval,val;
const char *name;
@@ -185,10 +166,12 @@ static ssize_t show_enum(int id,struct class_device *class_dev,char *buf)
sfp = (struct pvr2_sysfs *)class_dev->class_data;
if (!sfp) return -EINVAL;
- minval = pvr2_hdw_get_ctl_min_value(sfp->channel.hdw,id);
- maxval = pvr2_hdw_get_ctl_max_value(sfp->channel.hdw,id);
+ cptr = pvr2_hdw_get_ctrl_by_index(sfp->channel.hdw,id);
+ if (!pvr2_ctrl_is_valid(cptr)) return -EINVAL;
+ minval = pvr2_ctrl_get_min_value(cptr);
+ maxval = pvr2_ctrl_get_max_value(cptr);
for (val = minval; val <= maxval; val++) {
- name = pvr2_hdw_get_ctl_value_name(sfp->channel.hdw,id,val);
+ name = pvr2_ctrl_get_value_name(cptr,val);
cnt += scnprintf(buf+cnt,PAGE_SIZE-cnt,"%s\n",name);
}
pvr2_sysfs_trace("pvr2_sysfs(%p) show_enum(cid=%d)",sfp,id);
@@ -198,6 +181,7 @@ static ssize_t show_enum(int id,struct class_device *class_dev,char *buf)
static int store_val_any(int id,struct pvr2_sysfs *sfp,
const char *buf,unsigned int count)
{
+ struct pvr2_ctrl *cptr;
int val,minval,maxval;
int ch,ret;
const char *nv;
@@ -217,11 +201,14 @@ static int store_val_any(int id,struct pvr2_sysfs *sfp,
count--;
}
+ cptr = pvr2_hdw_get_ctrl_by_index(sfp->channel.hdw,id);
+ if (!pvr2_ctrl_is_valid(cptr)) return -EINVAL;
+
/* Is this an enum? Look for a string value */
- minval = pvr2_hdw_get_ctl_min_value(sfp->channel.hdw,id);
- maxval = pvr2_hdw_get_ctl_max_value(sfp->channel.hdw,id);
+ minval = pvr2_ctrl_get_min_value(cptr);
+ maxval = pvr2_ctrl_get_max_value(cptr);
for (val = minval; val <= maxval; val++) {
- nv = pvr2_hdw_get_ctl_value_name(sfp->channel.hdw,id,val);
+ nv = pvr2_ctrl_get_value_name(cptr,val);
if ((!nv) && (val == minval)) break; /* Not an enum */
pvr2_sysfs_trace("pvr2_sysfs(%p) trying ctl_id %d val %d",
sfp,id,val);
@@ -246,7 +233,7 @@ static int store_val_any(int id,struct pvr2_sysfs *sfp,
pvr2_sysfs_trace("pvr2_sysfs(%p) store_val_any(cid=%d)"
" is enum %s",
sfp,id,nv);
- ret = pvr2_hdw_set_ctl_value(sfp->channel.hdw,id,val);
+ ret = pvr2_ctrl_set_value(cptr,val);
pvr2_hdw_commit_ctl(sfp->channel.hdw);
return 0;
}
@@ -284,7 +271,7 @@ static int store_val_any(int id,struct pvr2_sysfs *sfp,
" int is %d",
sfp,id,val);
- ret = pvr2_hdw_set_ctl_value(sfp->channel.hdw,id,val);
+ ret = pvr2_ctrl_set_value(cptr,val);
pvr2_hdw_commit_ctl(sfp->channel.hdw);
return ret;
}
@@ -395,6 +382,8 @@ CREATE_BATCH(28)
CREATE_BATCH(29)
CREATE_BATCH(30)
CREATE_BATCH(31)
+CREATE_BATCH(32)
+CREATE_BATCH(33)
struct pvr2_sysfs_func_set {
ssize_t (*show_name)(struct class_device *,char *);
@@ -454,6 +443,8 @@ static struct pvr2_sysfs_func_set funcs[] = {
INIT_BATCH(29),
INIT_BATCH(30),
INIT_BATCH(31),
+ INIT_BATCH(32),
+ INIT_BATCH(33),
};
@@ -461,19 +452,23 @@ static void pvr2_sysfs_add_control(struct pvr2_sysfs *sfp,int ctl_id)
{
struct pvr2_sysfs_ctl_item *cip;
struct pvr2_sysfs_func_set *fp;
+ struct pvr2_ctrl *cptr;
+ unsigned int cnt;
if ((ctl_id < 0) || (ctl_id >= (sizeof(funcs)/sizeof(funcs[0])))) {
return;
}
fp = funcs + ctl_id;
+ cptr = pvr2_hdw_get_ctrl_by_index(sfp->channel.hdw,ctl_id);
+ if (!cptr) return;
cip = kmalloc(sizeof(*cip),GFP_KERNEL);
if (!cip) return;
memset(cip,0,sizeof(*cip));
pvr2_sysfs_trace("Creating pvr2_sysfs_ctl_item id=%p",cip);
- cip->attr_id = ctl_id;
+ cip->cptr = cptr;
cip->chptr = sfp;
cip->item_next = 0;
@@ -508,15 +503,13 @@ static void pvr2_sysfs_add_control(struct pvr2_sysfs *sfp,int ctl_id)
cip->attr_enum.attr.mode = S_IRUGO;
cip->attr_enum.show = fp->show_enum;
- if (pvr2_hdw_get_ctl_rw(sfp->channel.hdw,ctl_id)) {
+ if (pvr2_ctrl_is_writeable(cptr)) {
cip->attr_val.attr.mode |= S_IWUSR|S_IWGRP;
}
cip->attr_gen[0] = &cip->attr_name.attr;
cip->attr_gen[1] = &cip->attr_val.attr;
- if (pvr2_hdw_get_ctl_value_name(
- sfp->channel.hdw,ctl_id,
- pvr2_hdw_get_ctl_min_value(sfp->channel.hdw,ctl_id))) {
+ if (pvr2_ctrl_get_type(cptr) == PVR2_CTRL_TYPE_ENUM) {
// Control is an enumeration
cip->attr_gen[2] = &cip->attr_enum.attr;
cip->attr_val.show = fp->show_val_enum;
@@ -529,7 +522,10 @@ static void pvr2_sysfs_add_control(struct pvr2_sysfs *sfp,int ctl_id)
cip->attr_gen[3] = &cip->attr_max.attr;
}
- cip->grp.name = item_names[ctl_id];
+ cnt = scnprintf(cip->name,sizeof(cip->name)-1,"ctl_%s",
+ pvr2_ctrl_get_name(cptr));
+ cip->name[cnt] = 0;
+ cip->grp.name = cip->name;
cip->grp.attrs = cip->attr_gen;
sysfs_create_group(&sfp->class_dev->kobj,&cip->grp);
@@ -573,12 +569,10 @@ static void pvr2_sysfs_tear_down_debugifc(struct pvr2_sysfs *sfp)
static void pvr2_sysfs_add_controls(struct pvr2_sysfs *sfp)
{
- unsigned int ctl_id;
-
- for (ctl_id = 0;
- ctl_id < (sizeof(item_names)/sizeof(item_names[0])); ctl_id++) {
- if (!item_names[ctl_id]) continue;
- pvr2_sysfs_add_control(sfp,ctl_id);
+ unsigned int idx,cnt;
+ cnt = pvr2_hdw_get_ctrl_count(sfp->channel.hdw);
+ for (idx = 0; idx < cnt; idx++) {
+ pvr2_sysfs_add_control(sfp,idx);
}
}