aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMike Isely <isely@pobox.com>2008-04-22 13:45:37 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-04-24 13:07:46 -0400
commit29bf5b1d754a9a64f68c37938e1a0b7b63b724ba (patch)
treeb87e6218fcfbad0bfa023b0681cac960f6b8bfa4 /drivers
parent1aaac60fec0d3ba8043838c6eac86de987cfe5c1 (diff)
V4L/DVB (7297): pvrusb2: Dynamically control range of input selections
This follows from defining the available inputs as device attributes. This change causes the driver to adjust its list of inputs based on those attributes. Now, for example, the FM radio will appear as a choice only if the hardware supports an FM radio. Signed-off-by: Mike Isely <isely@pobox.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c26
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.h7
2 files changed, 29 insertions, 4 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index 9199b5defb6b..66945f7d2218 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -182,6 +182,7 @@ static const char *control_values_srate[] = {
182 182
183static const char *control_values_input[] = { 183static const char *control_values_input[] = {
184 [PVR2_CVAL_INPUT_TV] = "television", /*xawtv needs this name*/ 184 [PVR2_CVAL_INPUT_TV] = "television", /*xawtv needs this name*/
185 [PVR2_CVAL_INPUT_DTV] = "dtv",
185 [PVR2_CVAL_INPUT_RADIO] = "radio", 186 [PVR2_CVAL_INPUT_RADIO] = "radio",
186 [PVR2_CVAL_INPUT_SVIDEO] = "s-video", 187 [PVR2_CVAL_INPUT_SVIDEO] = "s-video",
187 [PVR2_CVAL_INPUT_COMPOSITE] = "composite", 188 [PVR2_CVAL_INPUT_COMPOSITE] = "composite",
@@ -367,6 +368,27 @@ static int ctrl_get_input(struct pvr2_ctrl *cptr,int *vp)
367 return 0; 368 return 0;
368} 369}
369 370
371static int ctrl_check_input(struct pvr2_ctrl *cptr,int v)
372{
373 struct pvr2_hdw *hdw = cptr->hdw;
374 const struct pvr2_device_desc *dsc = hdw->hdw_desc;
375
376 switch (v) {
377 case PVR2_CVAL_INPUT_TV:
378 return dsc->flag_has_analogtuner != 0;
379 case PVR2_CVAL_INPUT_DTV:
380 return dsc->flag_has_digitaltuner != 0;
381 case PVR2_CVAL_INPUT_SVIDEO:
382 return dsc->flag_has_svideo != 0;
383 case PVR2_CVAL_INPUT_COMPOSITE:
384 return dsc->flag_has_composite != 0;
385 case PVR2_CVAL_INPUT_RADIO:
386 return dsc->flag_has_fmradio != 0;
387 default:
388 return 0;
389 }
390}
391
370static int ctrl_set_input(struct pvr2_ctrl *cptr,int m,int v) 392static int ctrl_set_input(struct pvr2_ctrl *cptr,int m,int v)
371{ 393{
372 struct pvr2_hdw *hdw = cptr->hdw; 394 struct pvr2_hdw *hdw = cptr->hdw;
@@ -382,7 +404,8 @@ static int ctrl_set_input(struct pvr2_ctrl *cptr,int m,int v)
382 if (hdw->input_val == PVR2_CVAL_INPUT_RADIO) { 404 if (hdw->input_val == PVR2_CVAL_INPUT_RADIO) {
383 hdw->freqSelector = 0; 405 hdw->freqSelector = 0;
384 hdw->freqDirty = !0; 406 hdw->freqDirty = !0;
385 } else if (hdw->input_val == PVR2_CVAL_INPUT_TV) { 407 } else if ((hdw->input_val == PVR2_CVAL_INPUT_TV) ||
408 (hdw->input_val == PVR2_CVAL_INPUT_DTV)) {
386 hdw->freqSelector = 1; 409 hdw->freqSelector = 1;
387 hdw->freqDirty = !0; 410 hdw->freqDirty = !0;
388 } 411 }
@@ -803,6 +826,7 @@ static const struct pvr2_ctl_info control_defs[] = {
803 .name = "input", 826 .name = "input",
804 .internal_id = PVR2_CID_INPUT, 827 .internal_id = PVR2_CID_INPUT,
805 .default_value = PVR2_CVAL_INPUT_TV, 828 .default_value = PVR2_CVAL_INPUT_TV,
829 .check_value = ctrl_check_input,
806 DEFREF(input), 830 DEFREF(input),
807 DEFENUM(control_values_input), 831 DEFENUM(control_values_input),
808 },{ 832 },{
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.h b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
index 3ad7a13d6c39..d33b313966ef 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
@@ -40,9 +40,10 @@
40 40
41/* Legal values for the INPUT state variable */ 41/* Legal values for the INPUT state variable */
42#define PVR2_CVAL_INPUT_TV 0 42#define PVR2_CVAL_INPUT_TV 0
43#define PVR2_CVAL_INPUT_SVIDEO 1 43#define PVR2_CVAL_INPUT_DTV 1
44#define PVR2_CVAL_INPUT_COMPOSITE 2 44#define PVR2_CVAL_INPUT_SVIDEO 2
45#define PVR2_CVAL_INPUT_RADIO 3 45#define PVR2_CVAL_INPUT_COMPOSITE 3
46#define PVR2_CVAL_INPUT_RADIO 4
46 47
47enum pvr2_config { 48enum pvr2_config {
48 pvr2_config_empty, /* No configuration */ 49 pvr2_config_empty, /* No configuration */