aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/pvrusb2
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:47 -0400
commit7fb20fa38caaf5c9d1b1d60b181c99ca30122520 (patch)
tree9b342c2709fef6671c1e5f8b66fbf18230848647 /drivers/media/video/pvrusb2
parent895c3e8bfec9738251da9a2a8592dab15ec3a1bd (diff)
V4L/DVB (7299): pvrusb2: Improve logic which handles input choice availability
Signed-off-by: Mike Isely <isely@pobox.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/pvrusb2')
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h3
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c35
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.h4
3 files changed, 24 insertions, 18 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
index d7a216b41b72..aa374c7e08fd 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
@@ -323,6 +323,9 @@ struct pvr2_hdw {
323 int v4l_minor_number_vbi; 323 int v4l_minor_number_vbi;
324 int v4l_minor_number_radio; 324 int v4l_minor_number_radio;
325 325
326 /* Bit mask of PVR2_CVAL_INPUT choices which are valid */
327 unsigned int input_avail_mask;
328
326 /* Location of eeprom or a negative number if none */ 329 /* Location of eeprom or a negative number if none */
327 int eeprom_addr; 330 int eeprom_addr;
328 331
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index 66945f7d2218..94cb0a76e77e 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -370,23 +370,7 @@ static int ctrl_get_input(struct pvr2_ctrl *cptr,int *vp)
370 370
371static int ctrl_check_input(struct pvr2_ctrl *cptr,int v) 371static int ctrl_check_input(struct pvr2_ctrl *cptr,int v)
372{ 372{
373 struct pvr2_hdw *hdw = cptr->hdw; 373 return ((1 << v) & cptr->hdw->input_avail_mask) != 0;
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} 374}
391 375
392static int ctrl_set_input(struct pvr2_ctrl *cptr,int m,int v) 376static int ctrl_set_input(struct pvr2_ctrl *cptr,int m,int v)
@@ -1834,7 +1818,7 @@ static void pvr2_hdw_setup(struct pvr2_hdw *hdw)
1834struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, 1818struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
1835 const struct usb_device_id *devid) 1819 const struct usb_device_id *devid)
1836{ 1820{
1837 unsigned int idx,cnt1,cnt2; 1821 unsigned int idx,cnt1,cnt2,m;
1838 struct pvr2_hdw *hdw; 1822 struct pvr2_hdw *hdw;
1839 int valid_std_mask; 1823 int valid_std_mask;
1840 struct pvr2_ctrl *cptr; 1824 struct pvr2_ctrl *cptr;
@@ -1865,6 +1849,15 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
1865 hdw->tuner_signal_stale = !0; 1849 hdw->tuner_signal_stale = !0;
1866 cx2341x_fill_defaults(&hdw->enc_ctl_state); 1850 cx2341x_fill_defaults(&hdw->enc_ctl_state);
1867 1851
1852 /* Calculate which inputs are OK */
1853 m = 0;
1854 if (hdw_desc->flag_has_analogtuner) m |= 1 << PVR2_CVAL_INPUT_TV;
1855 if (hdw_desc->flag_has_digitaltuner) m |= 1 << PVR2_CVAL_INPUT_DTV;
1856 if (hdw_desc->flag_has_svideo) m |= 1 << PVR2_CVAL_INPUT_SVIDEO;
1857 if (hdw_desc->flag_has_composite) m |= 1 << PVR2_CVAL_INPUT_COMPOSITE;
1858 if (hdw_desc->flag_has_fmradio) m |= 1 << PVR2_CVAL_INPUT_RADIO;
1859 hdw->input_avail_mask = m;
1860
1868 hdw->control_cnt = CTRLDEF_COUNT; 1861 hdw->control_cnt = CTRLDEF_COUNT;
1869 hdw->control_cnt += MPEGDEF_COUNT; 1862 hdw->control_cnt += MPEGDEF_COUNT;
1870 hdw->controls = kzalloc(sizeof(struct pvr2_ctrl) * hdw->control_cnt, 1863 hdw->controls = kzalloc(sizeof(struct pvr2_ctrl) * hdw->control_cnt,
@@ -3780,6 +3773,12 @@ int pvr2_hdw_gpio_chg_out(struct pvr2_hdw *hdw,u32 msk,u32 val)
3780} 3773}
3781 3774
3782 3775
3776unsigned int pvr2_hdw_get_input_available(struct pvr2_hdw *hdw)
3777{
3778 return hdw->input_avail_mask;
3779}
3780
3781
3783/* Find I2C address of eeprom */ 3782/* Find I2C address of eeprom */
3784static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw) 3783static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw)
3785{ 3784{
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.h b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
index d33b313966ef..59f385878ef2 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
@@ -147,6 +147,10 @@ struct pvr2_ctrl *pvr2_hdw_get_ctrl_nextv4l(struct pvr2_hdw *,
147/* Commit all control changes made up to this point */ 147/* Commit all control changes made up to this point */
148int pvr2_hdw_commit_ctl(struct pvr2_hdw *); 148int pvr2_hdw_commit_ctl(struct pvr2_hdw *);
149 149
150/* Return a bit mask of valid input selections for this device. Mask bits
151 * will be according to PVR_CVAL_INPUT_xxxx definitions. */
152unsigned int pvr2_hdw_get_input_available(struct pvr2_hdw *);
153
150/* Return name for this driver instance */ 154/* Return name for this driver instance */
151const char *pvr2_hdw_get_driver_name(struct pvr2_hdw *); 155const char *pvr2_hdw_get_driver_name(struct pvr2_hdw *);
152 156