summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2006-06-25 22:16:47 -0300
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-06-25 22:16:47 -0300
commit6e3e1d3647a8df0faa85e8f74e42c0adfa97fb57 (patch)
tree4727e713cc778c7c1f466ed0bfb5f2a6b20e9193 /linux/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
parente27b9707f11774d40fd1e1278b5a11d4683313d5 (diff)
parent0217d884320494197ce193e3a7be37d2aadb298b (diff)
downloadmediapointer-dvb-s2-6e3e1d3647a8df0faa85e8f74e42c0adfa97fb57.tar.gz
mediapointer-dvb-s2-6e3e1d3647a8df0faa85e8f74e42c0adfa97fb57.tar.bz2
merge: http://linuxtv.org/hg/~mcisely/pvrusb2
From: Mauro Carvalho Chehab <mchehab@infradead.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'linux/drivers/media/video/pvrusb2/pvrusb2-ctrl.c')
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-ctrl.c59
1 files changed, 54 insertions, 5 deletions
diff --git a/linux/drivers/media/video/pvrusb2/pvrusb2-ctrl.c b/linux/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
index e55f43e44..20a1c7af7 100644
--- a/linux/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
@@ -58,6 +58,8 @@ int pvr2_ctrl_set_mask_value(struct pvr2_ctrl *cptr,int mask,int val)
if (val >= cptr->info->def.type_enum.count) {
break;
}
+ } else if (cptr->info->type != pvr2_ctl_bool) {
+ break;
}
ret = cptr->info->set_value(cptr,mask,val);
} else {
@@ -217,6 +219,32 @@ int pvr2_ctrl_get_valname(struct pvr2_ctrl *cptr,int val,
}
+/* Return V4L ID for this control or zero if none */
+int pvr2_ctrl_get_v4lid(struct pvr2_ctrl *cptr)
+{
+ if (!cptr) return 0;
+ return cptr->info->v4l_id;
+}
+
+
+unsigned int pvr2_ctrl_get_v4lflags(struct pvr2_ctrl *cptr)
+{
+ unsigned int flags = 0;
+
+ if (cptr->info->get_v4lflags) {
+ flags = cptr->info->get_v4lflags(cptr);
+ }
+
+ if (cptr->info->set_value) {
+ flags &= ~V4L2_CTRL_FLAG_READ_ONLY;
+ } else {
+ flags |= V4L2_CTRL_FLAG_READ_ONLY;
+ }
+
+ return flags;
+}
+
+
/* Return true if control is writable */
int pvr2_ctrl_is_writable(struct pvr2_ctrl *cptr)
{
@@ -313,6 +341,14 @@ static unsigned int gen_bitmask_string(int msk,int val,int msk_only,
}
+static const char *boolNames[] = {
+ "false",
+ "true",
+ "no",
+ "yes",
+};
+
+
static int parse_token(const char *ptr,unsigned int len,
int *valptr,
const char **names,unsigned int namecnt)
@@ -343,7 +379,7 @@ static int parse_token(const char *ptr,unsigned int len,
*valptr = simple_strtol(buf,&p2,0);
if (negfl) *valptr = -(*valptr);
if (*p2) return -EINVAL;
- return 0;
+ return 1;
}
@@ -458,21 +494,31 @@ int pvr2_ctrl_sym_to_value(struct pvr2_ctrl *cptr,
LOCK_TAKE(cptr->hdw->big_lock); do {
if (cptr->info->type == pvr2_ctl_int) {
ret = parse_token(ptr,len,valptr,0,0);
- if ((ret == 0) &&
+ if ((ret >= 0) &&
((*valptr < cptr->info->def.type_int.min_value) ||
(*valptr > cptr->info->def.type_int.max_value))) {
- ret = -EINVAL;
+ ret = -ERANGE;
}
if (maskptr) *maskptr = ~0;
+ } else if (cptr->info->type == pvr2_ctl_bool) {
+ ret = parse_token(
+ ptr,len,valptr,boolNames,
+ sizeof(boolNames)/sizeof(boolNames[0]));
+ if (ret == 1) {
+ *valptr = *valptr ? !0 : 0;
+ } else if (ret == 0) {
+ *valptr = (*valptr & 1) ? !0 : 0;
+ }
+ if (maskptr) *maskptr = 1;
} else if (cptr->info->type == pvr2_ctl_enum) {
ret = parse_token(
ptr,len,valptr,
cptr->info->def.type_enum.value_names,
cptr->info->def.type_enum.count);
- if ((ret == 0) &&
+ if ((ret >= 0) &&
((*valptr < 0) ||
(*valptr >= cptr->info->def.type_enum.count))) {
- ret = -EINVAL;
+ ret = -ERANGE;
}
if (maskptr) *maskptr = ~0;
} else if (cptr->info->type == pvr2_ctl_bitmask) {
@@ -498,6 +544,9 @@ int pvr2_ctrl_value_to_sym_internal(struct pvr2_ctrl *cptr,
if (cptr->info->type == pvr2_ctl_int) {
*len = scnprintf(buf,maxlen,"%d",val);
ret = 0;
+ } else if (cptr->info->type == pvr2_ctl_bool) {
+ *len = scnprintf(buf,maxlen,"%s",val ? "true" : "false");
+ ret = 0;
} else if (cptr->info->type == pvr2_ctl_enum) {
const char **names;
names = cptr->info->def.type_enum.value_names;