OSDN Git Service

[media] pvrusb2: Transform video standard detection result into read-only control ID
authorMike Isely <isely@pobox.com>
Mon, 20 Feb 2012 05:28:56 +0000 (02:28 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 7 May 2012 19:54:15 +0000 (16:54 -0300)
Other aspects of the pvrusb2 driver - including in particular those
dealing with video standards - all use internal control IDs for
uniform access by the interfaces.  By exporting the querystd result as
another control ID, uniform access to it becomes available through the
sysfs interface.

Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
drivers/media/video/pvrusb2/pvrusb2-hdw.c
drivers/media/video/pvrusb2/pvrusb2-hdw.h
drivers/media/video/pvrusb2/pvrusb2-v4l2.c

index 305e6aa..17fc579 100644 (file)
@@ -323,6 +323,7 @@ struct pvr2_hdw {
        struct pvr2_ctl_info std_info_enum;
        struct pvr2_ctl_info std_info_avail;
        struct pvr2_ctl_info std_info_cur;
+       struct pvr2_ctl_info std_info_detect;
        struct v4l2_standard *std_defs;
        const char **std_enum_names;
 
index 534dbf3..c4bb0d1 100644 (file)
@@ -346,7 +346,7 @@ static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
                                void *write_data,unsigned int write_len,
                                void *read_data,unsigned int read_len);
 static int pvr2_hdw_check_cropcap(struct pvr2_hdw *hdw);
-
+static v4l2_std_id pvr2_hdw_get_detected_std(struct pvr2_hdw *hdw);
 
 static void trace_stbit(const char *name,int val)
 {
@@ -840,6 +840,12 @@ static int ctrl_hsm_get(struct pvr2_ctrl *cptr,int *vp)
        return 0;
 }
 
+static int ctrl_stddetect_get(struct pvr2_ctrl *cptr, int *vp)
+{
+       *vp = pvr2_hdw_get_detected_std(cptr->hdw);
+       return 0;
+}
+
 static int ctrl_stdavail_get(struct pvr2_ctrl *cptr,int *vp)
 {
        *vp = cptr->hdw->std_mask_avail;
@@ -1302,6 +1308,15 @@ static const struct pvr2_ctl_info control_defs[] = {
                .is_dirty = ctrl_stdenumcur_is_dirty,
                .clear_dirty = ctrl_stdenumcur_clear_dirty,
                .type = pvr2_ctl_enum,
+       },{
+               .desc = "Video Standards Detected Mask",
+               .name = "video_standard_mask_detected",
+               .internal_id = PVR2_CID_STDDETECT,
+               .skip_init = !0,
+               .get_value = ctrl_stddetect_get,
+               .val_to_sym = ctrl_std_val_to_sym,
+               .sym_to_val = ctrl_std_sym_to_val,
+               .type = pvr2_ctl_bitmask,
        }
 };
 
@@ -2629,7 +2644,17 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
                cptr->info = &hdw->std_info_cur;
                hdw->std_info_cur.def.type_bitmask.bit_names =
                        hdw->std_mask_ptrs;
-               hdw->std_info_avail.def.type_bitmask.valid_bits =
+               hdw->std_info_cur.def.type_bitmask.valid_bits =
+                       valid_std_mask;
+       }
+       cptr = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_STDDETECT);
+       if (cptr) {
+               memcpy(&hdw->std_info_detect,cptr->info,
+                      sizeof(hdw->std_info_detect));
+               cptr->info = &hdw->std_info_detect;
+               hdw->std_info_detect.def.type_bitmask.bit_names =
+                       hdw->std_mask_ptrs;
+               hdw->std_info_detect.def.type_bitmask.valid_bits =
                        valid_std_mask;
        }
 
@@ -2995,12 +3020,13 @@ static void pvr2_subdev_set_control(struct pvr2_hdw *hdw, int id,
                pvr2_subdev_set_control(hdw, id, #lab, (hdw)->lab##_val); \
        }
 
-int pvr2_hdw_get_detected_std(struct pvr2_hdw *hdw, v4l2_std_id *std)
+v4l2_std_id pvr2_hdw_get_detected_std(struct pvr2_hdw *hdw)
 {
-       *std = V4L2_STD_ALL;
+       v4l2_std_id std;
+       std = V4L2_STD_ALL;
        v4l2_device_call_all(&hdw->v4l2_dev, 0,
-                            video, querystd, std);
-       return 0;
+                            video, querystd, &std);
+       return std;
 }
 
 /* Execute whatever commands are required to update the state of all the
index 6654658..45ddb81 100644 (file)
@@ -46,6 +46,7 @@
 #define PVR2_CID_CROPCAPBT 16
 #define PVR2_CID_CROPCAPBW 17
 #define PVR2_CID_CROPCAPBH 18
+#define PVR2_CID_STDDETECT 19
 
 /* Legal values for the INPUT state variable */
 #define PVR2_CVAL_INPUT_TV 0
@@ -214,9 +215,6 @@ struct pvr2_stream *pvr2_hdw_get_video_stream(struct pvr2_hdw *);
 int pvr2_hdw_get_stdenum_value(struct pvr2_hdw *hdw,struct v4l2_standard *std,
                               unsigned int idx);
 
-/* Get the detected video standard */
-int pvr2_hdw_get_detected_std(struct pvr2_hdw *hdw, v4l2_std_id *std);
-
 /* Enable / disable retrieval of CPU firmware or prom contents.  This must
    be enabled before pvr2_hdw_cpufw_get() will function.  Note that doing
    this may prevent the device from running (and leaving this mode may
index 3669090..ed497bb 100644 (file)
@@ -209,8 +209,13 @@ static int pvr2_querystd(struct file *file, void *priv, v4l2_std_id *std)
 {
        struct pvr2_v4l2_fh *fh = file->private_data;
        struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
+       int val = 0;
+       int ret;
 
-       return pvr2_hdw_get_detected_std(hdw, std);
+       ret = pvr2_ctrl_get_value(
+               pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_STDDETECT), &val);
+       *std = val;
+       return ret;
 }
 
 static int pvr2_enum_input(struct file *file, void *priv, struct v4l2_input *vi)