diff options
author | Mike Isely <isely@pobox.com> | 2007-01-19 22:19:23 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-02-21 10:34:39 -0500 |
commit | 644afdb9cc05107f3090817b6d00e90daa9a034b (patch) | |
tree | 0a0ef0fb88527f15229b41fa4bf13bf1cab333fb /drivers | |
parent | 7c74e57e6fb2ce986134e74634aeb78b3ea41a97 (diff) |
V4L/DVB (5084): Pvrusb2: Stop hardcoding frequency ranges
Rather than hardcoding frequency ranges everywhere, rely on
VIDIOC_G_TUNER results wherever we can.
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.c | 58 |
1 files changed, 33 insertions, 25 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c index 11890a0a72af..819564c825c0 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c | |||
@@ -39,8 +39,6 @@ | |||
39 | 39 | ||
40 | #define TV_MIN_FREQ 55250000L | 40 | #define TV_MIN_FREQ 55250000L |
41 | #define TV_MAX_FREQ 850000000L | 41 | #define TV_MAX_FREQ 850000000L |
42 | #define RADIO_MIN_FREQ 87000000L | ||
43 | #define RADIO_MAX_FREQ 108000000L | ||
44 | 42 | ||
45 | struct usb_device_id pvr2_device_table[] = { | 43 | struct usb_device_id pvr2_device_table[] = { |
46 | [PVR2_HDW_TYPE_29XXX] = { USB_DEVICE(0x2040, 0x2900) }, | 44 | [PVR2_HDW_TYPE_29XXX] = { USB_DEVICE(0x2040, 0x2900) }, |
@@ -432,34 +430,48 @@ static void ctrl_cleardirty_input(struct pvr2_ctrl *cptr) | |||
432 | cptr->hdw->input_dirty = 0; | 430 | cptr->hdw->input_dirty = 0; |
433 | } | 431 | } |
434 | 432 | ||
435 | static int ctrl_freq_check(struct pvr2_ctrl *cptr,int v) | ||
436 | { | ||
437 | /* Both ranges are simultaneously considered legal, in order to | ||
438 | permit implicit mode switching, i.e. set a frequency in the | ||
439 | other range and the mode will switch */ | ||
440 | return (((v >= RADIO_MIN_FREQ) && (v <= RADIO_MAX_FREQ)) || | ||
441 | ((v >= TV_MIN_FREQ) && (v <= TV_MAX_FREQ))); | ||
442 | } | ||
443 | 433 | ||
444 | static int ctrl_freq_max_get(struct pvr2_ctrl *cptr, int *vp) | 434 | static int ctrl_freq_max_get(struct pvr2_ctrl *cptr, int *vp) |
445 | { | 435 | { |
446 | /* Actual maximum depends on radio/tv mode */ | 436 | unsigned long fv; |
447 | if (cptr->hdw->input_val == PVR2_CVAL_INPUT_RADIO) { | 437 | struct pvr2_hdw *hdw = cptr->hdw; |
448 | *vp = RADIO_MAX_FREQ; | 438 | if (hdw->tuner_signal_stale) { |
449 | } else { | 439 | pvr2_i2c_core_status_poll(hdw); |
440 | } | ||
441 | fv = hdw->tuner_signal_info.rangehigh; | ||
442 | if (!fv) { | ||
443 | /* Safety fallback */ | ||
450 | *vp = TV_MAX_FREQ; | 444 | *vp = TV_MAX_FREQ; |
445 | return 0; | ||
451 | } | 446 | } |
447 | if (hdw->tuner_signal_info.capability & V4L2_TUNER_CAP_LOW) { | ||
448 | fv = (fv * 125) / 2; | ||
449 | } else { | ||
450 | fv = fv * 62500; | ||
451 | } | ||
452 | *vp = fv; | ||
452 | return 0; | 453 | return 0; |
453 | } | 454 | } |
454 | 455 | ||
455 | static int ctrl_freq_min_get(struct pvr2_ctrl *cptr, int *vp) | 456 | static int ctrl_freq_min_get(struct pvr2_ctrl *cptr, int *vp) |
456 | { | 457 | { |
457 | /* Actual minimum depends on radio/tv mode */ | 458 | unsigned long fv; |
458 | if (cptr->hdw->input_val == PVR2_CVAL_INPUT_RADIO) { | 459 | struct pvr2_hdw *hdw = cptr->hdw; |
459 | *vp = RADIO_MIN_FREQ; | 460 | if (hdw->tuner_signal_stale) { |
460 | } else { | 461 | pvr2_i2c_core_status_poll(hdw); |
462 | } | ||
463 | fv = hdw->tuner_signal_info.rangelow; | ||
464 | if (!fv) { | ||
465 | /* Safety fallback */ | ||
461 | *vp = TV_MIN_FREQ; | 466 | *vp = TV_MIN_FREQ; |
467 | return 0; | ||
462 | } | 468 | } |
469 | if (hdw->tuner_signal_info.capability & V4L2_TUNER_CAP_LOW) { | ||
470 | fv = (fv * 125) / 2; | ||
471 | } else { | ||
472 | fv = fv * 62500; | ||
473 | } | ||
474 | *vp = fv; | ||
463 | return 0; | 475 | return 0; |
464 | } | 476 | } |
465 | 477 | ||
@@ -630,9 +642,7 @@ static int ctrl_audio_modes_present_get(struct pvr2_ctrl *cptr,int *vp) | |||
630 | int val = 0; | 642 | int val = 0; |
631 | unsigned int subchan; | 643 | unsigned int subchan; |
632 | struct pvr2_hdw *hdw = cptr->hdw; | 644 | struct pvr2_hdw *hdw = cptr->hdw; |
633 | if (hdw->tuner_signal_stale) { | 645 | pvr2_i2c_core_status_poll(hdw); |
634 | pvr2_i2c_core_status_poll(hdw); | ||
635 | } | ||
636 | subchan = hdw->tuner_signal_info.rxsubchans; | 646 | subchan = hdw->tuner_signal_info.rxsubchans; |
637 | if (subchan & V4L2_TUNER_SUB_MONO) { | 647 | if (subchan & V4L2_TUNER_SUB_MONO) { |
638 | val |= (1 << V4L2_TUNER_MODE_MONO); | 648 | val |= (1 << V4L2_TUNER_MODE_MONO); |
@@ -870,10 +880,9 @@ static const struct pvr2_ctl_info control_defs[] = { | |||
870 | .get_value = ctrl_freq_get, | 880 | .get_value = ctrl_freq_get, |
871 | .is_dirty = ctrl_freq_is_dirty, | 881 | .is_dirty = ctrl_freq_is_dirty, |
872 | .clear_dirty = ctrl_freq_clear_dirty, | 882 | .clear_dirty = ctrl_freq_clear_dirty, |
873 | DEFINT(TV_MIN_FREQ,TV_MAX_FREQ), | 883 | DEFINT(0,0), |
874 | /* Hook in check for input value (tv/radio) and adjust | 884 | /* Hook in check for input value (tv/radio) and adjust |
875 | max/min values accordingly */ | 885 | max/min values accordingly */ |
876 | .check_value = ctrl_freq_check, | ||
877 | .get_max_value = ctrl_freq_max_get, | 886 | .get_max_value = ctrl_freq_max_get, |
878 | .get_min_value = ctrl_freq_min_get, | 887 | .get_min_value = ctrl_freq_min_get, |
879 | },{ | 888 | },{ |
@@ -887,10 +896,9 @@ static const struct pvr2_ctl_info control_defs[] = { | |||
887 | .name = "freq_table_value", | 896 | .name = "freq_table_value", |
888 | .set_value = ctrl_channelfreq_set, | 897 | .set_value = ctrl_channelfreq_set, |
889 | .get_value = ctrl_channelfreq_get, | 898 | .get_value = ctrl_channelfreq_get, |
890 | DEFINT(TV_MIN_FREQ,TV_MAX_FREQ), | 899 | DEFINT(0,0), |
891 | /* Hook in check for input value (tv/radio) and adjust | 900 | /* Hook in check for input value (tv/radio) and adjust |
892 | max/min values accordingly */ | 901 | max/min values accordingly */ |
893 | .check_value = ctrl_freq_check, | ||
894 | .get_max_value = ctrl_freq_max_get, | 902 | .get_max_value = ctrl_freq_max_get, |
895 | .get_min_value = ctrl_freq_min_get, | 903 | .get_min_value = ctrl_freq_min_get, |
896 | },{ | 904 | },{ |