diff options
author | Mike Isely <isely@pobox.com> | 2008-08-31 19:55:03 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-10-12 07:36:57 -0400 |
commit | 26dd1c57a05f5c6d339d55d5317d47576fd2fbc5 (patch) | |
tree | b1aebbbc3f6701c6caa718cfc92d91b657cf7433 /drivers/media | |
parent | 755879c66bb820ec27e2e02b22b13d3896583efe (diff) |
V4L/DVB (8898): pvrusb2: Be able to programmatically retrieve a control's default value
The pvrusb2 control mechanism up until now has used a constant int to
hold a control's default value. This change makes it possible to
retrieve the control's default through some other means, e.g. as a
result of a query from lower level software.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-ctrl.c | 10 | ||||
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-ctrl.h | 2 | ||||
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h | 1 | ||||
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-v4l2.c | 8 |
4 files changed, 15 insertions, 6 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c index 0764fbfffb73..2741c7b0b537 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c +++ b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c | |||
@@ -134,13 +134,19 @@ int pvr2_ctrl_get_min(struct pvr2_ctrl *cptr) | |||
134 | 134 | ||
135 | 135 | ||
136 | /* Retrieve control's default value (any type) */ | 136 | /* Retrieve control's default value (any type) */ |
137 | int pvr2_ctrl_get_def(struct pvr2_ctrl *cptr) | 137 | int pvr2_ctrl_get_def(struct pvr2_ctrl *cptr, int *valptr) |
138 | { | 138 | { |
139 | int ret = 0; | 139 | int ret = 0; |
140 | if (!cptr) return 0; | 140 | if (!cptr) return 0; |
141 | LOCK_TAKE(cptr->hdw->big_lock); do { | 141 | LOCK_TAKE(cptr->hdw->big_lock); do { |
142 | if (cptr->info->type == pvr2_ctl_int) { | 142 | if (cptr->info->type == pvr2_ctl_int) { |
143 | ret = cptr->info->default_value; | 143 | if (cptr->info->get_def_value) { |
144 | /* Comment to keep checkpatch.pl quiet */ | ||
145 | ret = cptr->info->get_def_value(cptr, valptr); | ||
146 | } else { | ||
147 | /* Comment to keep checkpatch.pl quiet */ | ||
148 | *valptr = cptr->info->default_value; | ||
149 | } | ||
144 | } | 150 | } |
145 | } while(0); LOCK_GIVE(cptr->hdw->big_lock); | 151 | } while(0); LOCK_GIVE(cptr->hdw->big_lock); |
146 | return ret; | 152 | return ret; |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-ctrl.h b/drivers/media/video/pvrusb2/pvrusb2-ctrl.h index 0371ae6e6e4e..794ff90121c7 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-ctrl.h +++ b/drivers/media/video/pvrusb2/pvrusb2-ctrl.h | |||
@@ -49,7 +49,7 @@ int pvr2_ctrl_get_max(struct pvr2_ctrl *); | |||
49 | int pvr2_ctrl_get_min(struct pvr2_ctrl *); | 49 | int pvr2_ctrl_get_min(struct pvr2_ctrl *); |
50 | 50 | ||
51 | /* Retrieve control's default value (any type) */ | 51 | /* Retrieve control's default value (any type) */ |
52 | int pvr2_ctrl_get_def(struct pvr2_ctrl *); | 52 | int pvr2_ctrl_get_def(struct pvr2_ctrl *, int *valptr); |
53 | 53 | ||
54 | /* Retrieve control's enumeration count (enum only) */ | 54 | /* Retrieve control's enumeration count (enum only) */ |
55 | int pvr2_ctrl_get_cnt(struct pvr2_ctrl *); | 55 | int pvr2_ctrl_get_cnt(struct pvr2_ctrl *); |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h index 0453244b7fa2..8bc9669733df 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h | |||
@@ -82,6 +82,7 @@ struct pvr2_ctl_info { | |||
82 | 82 | ||
83 | /* Control's implementation */ | 83 | /* Control's implementation */ |
84 | pvr2_ctlf_get_value get_value; /* Get its value */ | 84 | pvr2_ctlf_get_value get_value; /* Get its value */ |
85 | pvr2_ctlf_get_value get_def_value; /* Get its default value */ | ||
85 | pvr2_ctlf_get_value get_min_value; /* Get minimum allowed value */ | 86 | pvr2_ctlf_get_value get_min_value; /* Get minimum allowed value */ |
86 | pvr2_ctlf_get_value get_max_value; /* Get maximum allowed value */ | 87 | pvr2_ctlf_get_value get_max_value; /* Get maximum allowed value */ |
87 | pvr2_ctlf_set_value set_value; /* Set its value */ | 88 | pvr2_ctlf_set_value set_value; /* Set its value */ |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c index 00306faeac01..c53037a25570 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c +++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c | |||
@@ -533,7 +533,7 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file, | |||
533 | 533 | ||
534 | lmin = pvr2_ctrl_get_min(hcp); | 534 | lmin = pvr2_ctrl_get_min(hcp); |
535 | lmax = pvr2_ctrl_get_max(hcp); | 535 | lmax = pvr2_ctrl_get_max(hcp); |
536 | ldef = pvr2_ctrl_get_def(hcp); | 536 | pvr2_ctrl_get_def(hcp, &ldef); |
537 | if (w == -1) { | 537 | if (w == -1) { |
538 | w = ldef; | 538 | w = ldef; |
539 | } else if (w < lmin) { | 539 | } else if (w < lmin) { |
@@ -543,7 +543,7 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file, | |||
543 | } | 543 | } |
544 | lmin = pvr2_ctrl_get_min(vcp); | 544 | lmin = pvr2_ctrl_get_min(vcp); |
545 | lmax = pvr2_ctrl_get_max(vcp); | 545 | lmax = pvr2_ctrl_get_max(vcp); |
546 | ldef = pvr2_ctrl_get_def(vcp); | 546 | pvr2_ctrl_get_def(vcp, &ldef); |
547 | if (h == -1) { | 547 | if (h == -1) { |
548 | h = ldef; | 548 | h = ldef; |
549 | } else if (h < lmin) { | 549 | } else if (h < lmin) { |
@@ -604,6 +604,7 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file, | |||
604 | case VIDIOC_QUERYCTRL: | 604 | case VIDIOC_QUERYCTRL: |
605 | { | 605 | { |
606 | struct pvr2_ctrl *cptr; | 606 | struct pvr2_ctrl *cptr; |
607 | int val; | ||
607 | struct v4l2_queryctrl *vc = (struct v4l2_queryctrl *)arg; | 608 | struct v4l2_queryctrl *vc = (struct v4l2_queryctrl *)arg; |
608 | ret = 0; | 609 | ret = 0; |
609 | if (vc->id & V4L2_CTRL_FLAG_NEXT_CTRL) { | 610 | if (vc->id & V4L2_CTRL_FLAG_NEXT_CTRL) { |
@@ -627,7 +628,8 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file, | |||
627 | pvr2_ctrl_get_desc(cptr)); | 628 | pvr2_ctrl_get_desc(cptr)); |
628 | strlcpy(vc->name,pvr2_ctrl_get_desc(cptr),sizeof(vc->name)); | 629 | strlcpy(vc->name,pvr2_ctrl_get_desc(cptr),sizeof(vc->name)); |
629 | vc->flags = pvr2_ctrl_get_v4lflags(cptr); | 630 | vc->flags = pvr2_ctrl_get_v4lflags(cptr); |
630 | vc->default_value = pvr2_ctrl_get_def(cptr); | 631 | pvr2_ctrl_get_def(cptr, &val); |
632 | vc->default_value = val; | ||
631 | switch (pvr2_ctrl_get_type(cptr)) { | 633 | switch (pvr2_ctrl_get_type(cptr)) { |
632 | case pvr2_ctl_enum: | 634 | case pvr2_ctl_enum: |
633 | vc->type = V4L2_CTRL_TYPE_MENU; | 635 | vc->type = V4L2_CTRL_TYPE_MENU; |