aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/pvrusb2
diff options
context:
space:
mode:
authorMike Isely <isely@pobox.com>2006-06-25 19:04:44 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-06-26 23:17:28 -0400
commita761f4311b3e31008c7d168c3a8c254a9c7e35ac (patch)
tree03817e0334a6e019251a3483dc8147a418caabb5 /drivers/media/video/pvrusb2
parent332139635a8c0431cc2eb67adf1e983eb96728e3 (diff)
V4L/DVB (4240): Various V4L control enhancements 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')
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-ctrl.c21
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-ctrl.h7
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h2
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c26
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.h4
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-v4l2.c14
6 files changed, 71 insertions, 3 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
index d644afec5a5c..e4484f95ea9e 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
@@ -214,6 +214,27 @@ int pvr2_ctrl_get_valname(struct pvr2_ctrl *cptr,int val,
214} 214}
215 215
216 216
217/* Return V4L ID for this control or zero if none */
218int pvr2_ctrl_get_v4lid(struct pvr2_ctrl *cptr)
219{
220 if (!cptr) return 0;
221 return cptr->info->v4l_id;
222}
223
224
225unsigned int pvr2_ctrl_get_v4lflags(struct pvr2_ctrl *cptr)
226{
227 unsigned int flags = 0;
228
229 if (cptr->info->get_v4lflags) {
230 flags = cptr->info->get_v4lflags(cptr);
231 }
232
233
234 return flags;
235}
236
237
217/* Return true if control is writable */ 238/* Return true if control is writable */
218int pvr2_ctrl_is_writable(struct pvr2_ctrl *cptr) 239int pvr2_ctrl_is_writable(struct pvr2_ctrl *cptr)
219{ 240{
diff --git a/drivers/media/video/pvrusb2/pvrusb2-ctrl.h b/drivers/media/video/pvrusb2/pvrusb2-ctrl.h
index bf4cf65441fb..c1680053cd64 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-ctrl.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-ctrl.h
@@ -71,6 +71,13 @@ int pvr2_ctrl_get_valname(struct pvr2_ctrl *,int,char *,unsigned int,
71/* Return true if control is writable */ 71/* Return true if control is writable */
72int pvr2_ctrl_is_writable(struct pvr2_ctrl *); 72int pvr2_ctrl_is_writable(struct pvr2_ctrl *);
73 73
74/* Return V4L flags value for control (or zero if there is no v4l control
75 actually under this control) */
76unsigned int pvr2_ctrl_get_v4lflags(struct pvr2_ctrl *);
77
78/* Return V4L ID for this control or zero if none */
79int pvr2_ctrl_get_v4lid(struct pvr2_ctrl *);
80
74/* Return true if control has custom symbolic representation */ 81/* Return true if control has custom symbolic representation */
75int pvr2_ctrl_has_custom_symbols(struct pvr2_ctrl *); 82int pvr2_ctrl_has_custom_symbols(struct pvr2_ctrl *);
76 83
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
index 4fd5ca2f6fc9..3887190079d1 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
@@ -94,6 +94,7 @@ typedef int (*pvr2_ctlf_val_to_sym)(struct pvr2_ctrl *,int msk,int val,
94typedef int (*pvr2_ctlf_sym_to_val)(struct pvr2_ctrl *, 94typedef int (*pvr2_ctlf_sym_to_val)(struct pvr2_ctrl *,
95 const char *,unsigned int, 95 const char *,unsigned int,
96 int *mskp,int *valp); 96 int *mskp,int *valp);
97typedef unsigned int (*pvr2_ctlf_get_v4lflags)(struct pvr2_ctrl *);
97 98
98/* This structure describes a specific control. A table of these is set up 99/* This structure describes a specific control. A table of these is set up
99 in pvrusb2-hdw.c. */ 100 in pvrusb2-hdw.c. */
@@ -111,6 +112,7 @@ struct pvr2_ctl_info {
111 pvr2_ctlf_sym_to_val sym_to_val; /* Custom convert symbol->value */ 112 pvr2_ctlf_sym_to_val sym_to_val; /* Custom convert symbol->value */
112 pvr2_ctlf_is_dirty is_dirty; /* Return true if dirty */ 113 pvr2_ctlf_is_dirty is_dirty; /* Return true if dirty */
113 pvr2_ctlf_clear_dirty clear_dirty; /* Clear dirty state */ 114 pvr2_ctlf_clear_dirty clear_dirty; /* Clear dirty state */
115 pvr2_ctlf_get_v4lflags get_v4lflags;/* Retrieve v4l flags */
114 116
115 /* Control's type (int, enum, bitmask) */ 117 /* Control's type (int, enum, bitmask) */
116 enum pvr2_ctl_type type; 118 enum pvr2_ctl_type type;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index 7d46bc10179a..f461830c64c9 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -1988,7 +1988,7 @@ struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_id(struct pvr2_hdw *hdw,
1988} 1988}
1989 1989
1990 1990
1991/* Given an ID, retrieve the control structure associated with it. */ 1991/* Given a V4L ID, retrieve the control structure associated with it. */
1992struct pvr2_ctrl *pvr2_hdw_get_ctrl_v4l(struct pvr2_hdw *hdw,unsigned int ctl_id) 1992struct pvr2_ctrl *pvr2_hdw_get_ctrl_v4l(struct pvr2_hdw *hdw,unsigned int ctl_id)
1993{ 1993{
1994 struct pvr2_ctrl *cptr; 1994 struct pvr2_ctrl *cptr;
@@ -2005,6 +2005,30 @@ struct pvr2_ctrl *pvr2_hdw_get_ctrl_v4l(struct pvr2_hdw *hdw,unsigned int ctl_id
2005} 2005}
2006 2006
2007 2007
2008/* Given a V4L ID for its immediate predecessor, retrieve the control
2009 structure associated with it. */
2010struct pvr2_ctrl *pvr2_hdw_get_ctrl_nextv4l(struct pvr2_hdw *hdw,
2011 unsigned int ctl_id)
2012{
2013 struct pvr2_ctrl *cptr,*cp2;
2014 unsigned int idx;
2015 int i;
2016
2017 /* This could be made a lot more efficient, but for now... */
2018 cp2 = 0;
2019 for (idx = 0; idx < hdw->control_cnt; idx++) {
2020 cptr = hdw->controls + idx;
2021 i = cptr->info->v4l_id;
2022 if (!i) continue;
2023 if (i <= ctl_id) continue;
2024 if (cp2 && (cp2->info->v4l_id < i)) continue;
2025 cp2 = cptr;
2026 }
2027 return cp2;
2028 return 0;
2029}
2030
2031
2008static const char *get_ctrl_typename(enum pvr2_ctl_type tp) 2032static const char *get_ctrl_typename(enum pvr2_ctl_type tp)
2009{ 2033{
2010 switch (tp) { 2034 switch (tp) {
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.h b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
index e9adef93e60a..779c27ea188e 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
@@ -153,6 +153,10 @@ struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_id(struct pvr2_hdw *,unsigned int);
153/* Retrieve a control handle given its V4L ID (if any) */ 153/* Retrieve a control handle given its V4L ID (if any) */
154struct pvr2_ctrl *pvr2_hdw_get_ctrl_v4l(struct pvr2_hdw *,unsigned int ctl_id); 154struct pvr2_ctrl *pvr2_hdw_get_ctrl_v4l(struct pvr2_hdw *,unsigned int ctl_id);
155 155
156/* Retrieve a control handle given its immediate predecessor V4L ID (if any) */
157struct pvr2_ctrl *pvr2_hdw_get_ctrl_nextv4l(struct pvr2_hdw *,
158 unsigned int ctl_id);
159
156/* Commit all control changes made up to this point */ 160/* Commit all control changes made up to this point */
157int pvr2_hdw_commit_ctl(struct pvr2_hdw *); 161int pvr2_hdw_commit_ctl(struct pvr2_hdw *);
158 162
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
index 72f28a8e1fe3..9fefcdf8ffab 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
@@ -520,12 +520,19 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
520 ret = 0; 520 ret = 0;
521 cptr = pvr2_hdw_get_ctrl_v4l(hdw,vc->id); 521 cptr = pvr2_hdw_get_ctrl_v4l(hdw,vc->id);
522 if (!cptr) { 522 if (!cptr) {
523 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
524 "QUERYCTRL id=0x%x not implemented here",
525 vc->id);
523 ret = -EINVAL; 526 ret = -EINVAL;
524 break; 527 break;
525 } 528 }
526 529
527 strlcpy(vc->name,pvr2_ctrl_get_name(cptr),sizeof(vc->name)); 530 pvr2_trace(PVR2_TRACE_V4LIOCTL,
528 vc->flags = 0; 531 "QUERYCTRL id=0x%x mapping name=%s (%s)",
532 vc->id,pvr2_ctrl_get_name(cptr),
533 pvr2_ctrl_get_desc(cptr));
534 strlcpy(vc->name,pvr2_ctrl_get_desc(cptr),sizeof(vc->name));
535 vc->flags = pvr2_ctrl_get_v4lflags(cptr);
529 vc->default_value = pvr2_ctrl_get_def(cptr); 536 vc->default_value = pvr2_ctrl_get_def(cptr);
530 switch (pvr2_ctrl_get_type(cptr)) { 537 switch (pvr2_ctrl_get_type(cptr)) {
531 case pvr2_ctl_enum: 538 case pvr2_ctl_enum:
@@ -547,6 +554,9 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
547 vc->step = 1; 554 vc->step = 1;
548 break; 555 break;
549 default: 556 default:
557 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
558 "QUERYCTRL id=0x%x name=%s not mappable",
559 vc->id,pvr2_ctrl_get_name(cptr));
550 ret = -EINVAL; 560 ret = -EINVAL;
551 break; 561 break;
552 } 562 }