aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Isely <isely@pobox.com>2006-08-08 08:10:07 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-09-26 10:53:20 -0400
commit89ebd63fdddc83fabb5cc751d0e59a1350c1627c (patch)
treec5d3956965dbb8b62cf9f06f480b06a7e58274fe
parente95a191566685530ef49b702bbce0a33c57c3136 (diff)
V4L/DVB (4376): Make it possible for run-time calculation of control min/max in pvrusb2
The internal control implementation in the pvrusb2 driver normally encodes integer range limits using literal values in a const structure. This change adds two function pointers, which if not null will be called through in order to determine integer min / max values. Signed-off-by: Mike Isely <isely@pobox.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-ctrl.c21
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h2
2 files changed, 17 insertions, 6 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
index fb6198f1df98..c77de859cc8e 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
@@ -43,12 +43,17 @@ int pvr2_ctrl_set_mask_value(struct pvr2_ctrl *cptr,int mask,int val)
43 if (cptr->info->type == pvr2_ctl_bitmask) { 43 if (cptr->info->type == pvr2_ctl_bitmask) {
44 mask &= cptr->info->def.type_bitmask.valid_bits; 44 mask &= cptr->info->def.type_bitmask.valid_bits;
45 } else if (cptr->info->type == pvr2_ctl_int) { 45 } else if (cptr->info->type == pvr2_ctl_int) {
46 if (val < cptr->info->def.type_int.min_value) { 46 int lim;
47 break; 47 lim = cptr->info->def.type_int.min_value;
48 if (cptr->info->get_min_value) {
49 cptr->info->get_min_value(cptr,&lim);
48 } 50 }
49 if (val > cptr->info->def.type_int.max_value) { 51 if (val < lim) break;
50 break; 52 lim = cptr->info->def.type_int.max_value;
53 if (cptr->info->get_max_value) {
54 cptr->info->get_max_value(cptr,&lim);
51 } 55 }
56 if (val > lim) break;
52 } else if (cptr->info->type == pvr2_ctl_enum) { 57 } else if (cptr->info->type == pvr2_ctl_enum) {
53 if (val >= cptr->info->def.type_enum.count) { 58 if (val >= cptr->info->def.type_enum.count) {
54 break; 59 break;
@@ -91,7 +96,9 @@ int pvr2_ctrl_get_max(struct pvr2_ctrl *cptr)
91 int ret = 0; 96 int ret = 0;
92 if (!cptr) return 0; 97 if (!cptr) return 0;
93 LOCK_TAKE(cptr->hdw->big_lock); do { 98 LOCK_TAKE(cptr->hdw->big_lock); do {
94 if (cptr->info->type == pvr2_ctl_int) { 99 if (cptr->info->get_max_value) {
100 cptr->info->get_max_value(cptr,&ret);
101 } else if (cptr->info->type == pvr2_ctl_int) {
95 ret = cptr->info->def.type_int.max_value; 102 ret = cptr->info->def.type_int.max_value;
96 } 103 }
97 } while(0); LOCK_GIVE(cptr->hdw->big_lock); 104 } while(0); LOCK_GIVE(cptr->hdw->big_lock);
@@ -105,7 +112,9 @@ int pvr2_ctrl_get_min(struct pvr2_ctrl *cptr)
105 int ret = 0; 112 int ret = 0;
106 if (!cptr) return 0; 113 if (!cptr) return 0;
107 LOCK_TAKE(cptr->hdw->big_lock); do { 114 LOCK_TAKE(cptr->hdw->big_lock); do {
108 if (cptr->info->type == pvr2_ctl_int) { 115 if (cptr->info->get_min_value) {
116 cptr->info->get_min_value(cptr,&ret);
117 } else if (cptr->info->type == pvr2_ctl_int) {
109 ret = cptr->info->def.type_int.min_value; 118 ret = cptr->info->def.type_int.min_value;
110 } 119 }
111 } while(0); LOCK_GIVE(cptr->hdw->big_lock); 120 } while(0); LOCK_GIVE(cptr->hdw->big_lock);
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
index 14800b69e60c..74c125ad4071 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
@@ -80,6 +80,8 @@ struct pvr2_ctl_info {
80 80
81 /* Control's implementation */ 81 /* Control's implementation */
82 pvr2_ctlf_get_value get_value; /* Get its value */ 82 pvr2_ctlf_get_value get_value; /* Get its value */
83 pvr2_ctlf_get_value get_min_value; /* Get minimum allowed value */
84 pvr2_ctlf_get_value get_max_value; /* Get maximum allowed value */
83 pvr2_ctlf_set_value set_value; /* Set its value */ 85 pvr2_ctlf_set_value set_value; /* Set its value */
84 pvr2_ctlf_val_to_sym val_to_sym; /* Custom convert value->symbol */ 86 pvr2_ctlf_val_to_sym val_to_sym; /* Custom convert value->symbol */
85 pvr2_ctlf_sym_to_val sym_to_val; /* Custom convert symbol->value */ 87 pvr2_ctlf_sym_to_val sym_to_val; /* Custom convert symbol->value */