]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
V4L/DVB (8898): pvrusb2: Be able to programmatically retrieve a control's default...
authorMike Isely <isely@pobox.com>
Sun, 31 Aug 2008 23:55:03 +0000 (20:55 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Sun, 12 Oct 2008 11:36:57 +0000 (09:36 -0200)
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>
drivers/media/video/pvrusb2/pvrusb2-ctrl.c
drivers/media/video/pvrusb2/pvrusb2-ctrl.h
drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
drivers/media/video/pvrusb2/pvrusb2-v4l2.c

index 0764fbfffb73b036c0687b34c94afd1a9d3b58a3..2741c7b0b537818b5e7302ee479f5c5ff31db5e1 100644 (file)
@@ -134,13 +134,19 @@ int pvr2_ctrl_get_min(struct pvr2_ctrl *cptr)
 
 
 /* Retrieve control's default value (any type) */
-int pvr2_ctrl_get_def(struct pvr2_ctrl *cptr)
+int pvr2_ctrl_get_def(struct pvr2_ctrl *cptr, int *valptr)
 {
        int ret = 0;
        if (!cptr) return 0;
        LOCK_TAKE(cptr->hdw->big_lock); do {
                if (cptr->info->type == pvr2_ctl_int) {
-                       ret = cptr->info->default_value;
+                       if (cptr->info->get_def_value) {
+                               /* Comment to keep checkpatch.pl quiet */
+                               ret = cptr->info->get_def_value(cptr, valptr);
+                       } else {
+                               /* Comment to keep checkpatch.pl quiet */
+                               *valptr = cptr->info->default_value;
+                       }
                }
        } while(0); LOCK_GIVE(cptr->hdw->big_lock);
        return ret;
index 0371ae6e6e4eb61b1e42e8799f92598d5a86e1ff..794ff90121c7d367ee221507f72a12d4ea8aca58 100644 (file)
@@ -49,7 +49,7 @@ int pvr2_ctrl_get_max(struct pvr2_ctrl *);
 int pvr2_ctrl_get_min(struct pvr2_ctrl *);
 
 /* Retrieve control's default value (any type) */
-int pvr2_ctrl_get_def(struct pvr2_ctrl *);
+int pvr2_ctrl_get_def(struct pvr2_ctrl *, int *valptr);
 
 /* Retrieve control's enumeration count (enum only) */
 int pvr2_ctrl_get_cnt(struct pvr2_ctrl *);
index 0453244b7fa2ea860f679ec7fe5212521f4547ac..8bc9669733df193ed8f219bddb9c3d44cdde0c1d 100644 (file)
@@ -82,6 +82,7 @@ struct pvr2_ctl_info {
 
        /* Control's implementation */
        pvr2_ctlf_get_value get_value;      /* Get its value */
+       pvr2_ctlf_get_value get_def_value;  /* Get its default 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 */
index 00306faeac015f1ab9a99c8aaf32b894032bc444..c53037a255700c4df55696133a5e86f5e037091e 100644 (file)
@@ -533,7 +533,7 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
 
                        lmin = pvr2_ctrl_get_min(hcp);
                        lmax = pvr2_ctrl_get_max(hcp);
-                       ldef = pvr2_ctrl_get_def(hcp);
+                       pvr2_ctrl_get_def(hcp, &ldef);
                        if (w == -1) {
                                w = ldef;
                        } else if (w < lmin) {
@@ -543,7 +543,7 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
                        }
                        lmin = pvr2_ctrl_get_min(vcp);
                        lmax = pvr2_ctrl_get_max(vcp);
-                       ldef = pvr2_ctrl_get_def(vcp);
+                       pvr2_ctrl_get_def(vcp, &ldef);
                        if (h == -1) {
                                h = ldef;
                        } else if (h < lmin) {
@@ -604,6 +604,7 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
        case VIDIOC_QUERYCTRL:
        {
                struct pvr2_ctrl *cptr;
+               int val;
                struct v4l2_queryctrl *vc = (struct v4l2_queryctrl *)arg;
                ret = 0;
                if (vc->id & V4L2_CTRL_FLAG_NEXT_CTRL) {
@@ -627,7 +628,8 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
                           pvr2_ctrl_get_desc(cptr));
                strlcpy(vc->name,pvr2_ctrl_get_desc(cptr),sizeof(vc->name));
                vc->flags = pvr2_ctrl_get_v4lflags(cptr);
-               vc->default_value = pvr2_ctrl_get_def(cptr);
+               pvr2_ctrl_get_def(cptr, &val);
+               vc->default_value = val;
                switch (pvr2_ctrl_get_type(cptr)) {
                case pvr2_ctl_enum:
                        vc->type = V4L2_CTRL_TYPE_MENU;