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>
This commit is contained in:
parent
e95a191566
commit
89ebd63fdd
2 changed files with 17 additions and 6 deletions
|
@ -43,12 +43,17 @@ int pvr2_ctrl_set_mask_value(struct pvr2_ctrl *cptr,int mask,int val)
|
|||
if (cptr->info->type == pvr2_ctl_bitmask) {
|
||||
mask &= cptr->info->def.type_bitmask.valid_bits;
|
||||
} else if (cptr->info->type == pvr2_ctl_int) {
|
||||
if (val < cptr->info->def.type_int.min_value) {
|
||||
break;
|
||||
int lim;
|
||||
lim = cptr->info->def.type_int.min_value;
|
||||
if (cptr->info->get_min_value) {
|
||||
cptr->info->get_min_value(cptr,&lim);
|
||||
}
|
||||
if (val > cptr->info->def.type_int.max_value) {
|
||||
break;
|
||||
if (val < lim) break;
|
||||
lim = cptr->info->def.type_int.max_value;
|
||||
if (cptr->info->get_max_value) {
|
||||
cptr->info->get_max_value(cptr,&lim);
|
||||
}
|
||||
if (val > lim) break;
|
||||
} else if (cptr->info->type == pvr2_ctl_enum) {
|
||||
if (val >= cptr->info->def.type_enum.count) {
|
||||
break;
|
||||
|
@ -91,7 +96,9 @@ int pvr2_ctrl_get_max(struct pvr2_ctrl *cptr)
|
|||
int ret = 0;
|
||||
if (!cptr) return 0;
|
||||
LOCK_TAKE(cptr->hdw->big_lock); do {
|
||||
if (cptr->info->type == pvr2_ctl_int) {
|
||||
if (cptr->info->get_max_value) {
|
||||
cptr->info->get_max_value(cptr,&ret);
|
||||
} else if (cptr->info->type == pvr2_ctl_int) {
|
||||
ret = cptr->info->def.type_int.max_value;
|
||||
}
|
||||
} while(0); LOCK_GIVE(cptr->hdw->big_lock);
|
||||
|
@ -105,7 +112,9 @@ int pvr2_ctrl_get_min(struct pvr2_ctrl *cptr)
|
|||
int ret = 0;
|
||||
if (!cptr) return 0;
|
||||
LOCK_TAKE(cptr->hdw->big_lock); do {
|
||||
if (cptr->info->type == pvr2_ctl_int) {
|
||||
if (cptr->info->get_min_value) {
|
||||
cptr->info->get_min_value(cptr,&ret);
|
||||
} else if (cptr->info->type == pvr2_ctl_int) {
|
||||
ret = cptr->info->def.type_int.min_value;
|
||||
}
|
||||
} while(0); LOCK_GIVE(cptr->hdw->big_lock);
|
||||
|
|
|
@ -80,6 +80,8 @@ struct pvr2_ctl_info {
|
|||
|
||||
/* Control's implementation */
|
||||
pvr2_ctlf_get_value get_value; /* Get its value */
|
||||
pvr2_ctlf_get_value get_min_value; /* Get minimum allowed value */
|
||||
pvr2_ctlf_get_value get_max_value; /* Get maximum allowed value */
|
||||
pvr2_ctlf_set_value set_value; /* Set its value */
|
||||
pvr2_ctlf_val_to_sym val_to_sym; /* Custom convert value->symbol */
|
||||
pvr2_ctlf_sym_to_val sym_to_val; /* Custom convert symbol->value */
|
||||
|
|
Loading…
Add table
Reference in a new issue