Commit ac04d00e authored by Mike Isely's avatar Mike Isely Committed by Mauro Carvalho Chehab

[media] pvrusb2: Transform video standard detection result into read-only control ID

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: default avatarMike Isely <isely@pobox.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 0927ee67
...@@ -323,6 +323,7 @@ struct pvr2_hdw { ...@@ -323,6 +323,7 @@ struct pvr2_hdw {
struct pvr2_ctl_info std_info_enum; struct pvr2_ctl_info std_info_enum;
struct pvr2_ctl_info std_info_avail; struct pvr2_ctl_info std_info_avail;
struct pvr2_ctl_info std_info_cur; struct pvr2_ctl_info std_info_cur;
struct pvr2_ctl_info std_info_detect;
struct v4l2_standard *std_defs; struct v4l2_standard *std_defs;
const char **std_enum_names; const char **std_enum_names;
......
...@@ -346,7 +346,7 @@ static int pvr2_send_request_ex(struct pvr2_hdw *hdw, ...@@ -346,7 +346,7 @@ static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
void *write_data,unsigned int write_len, void *write_data,unsigned int write_len,
void *read_data,unsigned int read_len); void *read_data,unsigned int read_len);
static int pvr2_hdw_check_cropcap(struct pvr2_hdw *hdw); 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) static void trace_stbit(const char *name,int val)
{ {
...@@ -840,6 +840,12 @@ static int ctrl_hsm_get(struct pvr2_ctrl *cptr,int *vp) ...@@ -840,6 +840,12 @@ static int ctrl_hsm_get(struct pvr2_ctrl *cptr,int *vp)
return 0; 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) static int ctrl_stdavail_get(struct pvr2_ctrl *cptr,int *vp)
{ {
*vp = cptr->hdw->std_mask_avail; *vp = cptr->hdw->std_mask_avail;
...@@ -1302,6 +1308,15 @@ static const struct pvr2_ctl_info control_defs[] = { ...@@ -1302,6 +1308,15 @@ static const struct pvr2_ctl_info control_defs[] = {
.is_dirty = ctrl_stdenumcur_is_dirty, .is_dirty = ctrl_stdenumcur_is_dirty,
.clear_dirty = ctrl_stdenumcur_clear_dirty, .clear_dirty = ctrl_stdenumcur_clear_dirty,
.type = pvr2_ctl_enum, .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, ...@@ -2629,7 +2644,17 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
cptr->info = &hdw->std_info_cur; cptr->info = &hdw->std_info_cur;
hdw->std_info_cur.def.type_bitmask.bit_names = hdw->std_info_cur.def.type_bitmask.bit_names =
hdw->std_mask_ptrs; 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; valid_std_mask;
} }
...@@ -2995,12 +3020,13 @@ static void pvr2_subdev_set_control(struct pvr2_hdw *hdw, int id, ...@@ -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); \ 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, v4l2_device_call_all(&hdw->v4l2_dev, 0,
video, querystd, std); video, querystd, &std);
return 0; return std;
} }
/* Execute whatever commands are required to update the state of all the /* Execute whatever commands are required to update the state of all the
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#define PVR2_CID_CROPCAPBT 16 #define PVR2_CID_CROPCAPBT 16
#define PVR2_CID_CROPCAPBW 17 #define PVR2_CID_CROPCAPBW 17
#define PVR2_CID_CROPCAPBH 18 #define PVR2_CID_CROPCAPBH 18
#define PVR2_CID_STDDETECT 19
/* Legal values for the INPUT state variable */ /* Legal values for the INPUT state variable */
#define PVR2_CVAL_INPUT_TV 0 #define PVR2_CVAL_INPUT_TV 0
...@@ -214,9 +215,6 @@ struct pvr2_stream *pvr2_hdw_get_video_stream(struct pvr2_hdw *); ...@@ -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, int pvr2_hdw_get_stdenum_value(struct pvr2_hdw *hdw,struct v4l2_standard *std,
unsigned int idx); 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 /* Enable / disable retrieval of CPU firmware or prom contents. This must
be enabled before pvr2_hdw_cpufw_get() will function. Note that doing be enabled before pvr2_hdw_cpufw_get() will function. Note that doing
this may prevent the device from running (and leaving this mode may this may prevent the device from running (and leaving this mode may
......
...@@ -209,8 +209,13 @@ static int pvr2_querystd(struct file *file, void *priv, v4l2_std_id *std) ...@@ -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_v4l2_fh *fh = file->private_data;
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw; 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) static int pvr2_enum_input(struct file *file, void *priv, struct v4l2_input *vi)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment