diff options
author | Pantelis Koukousoulas <pakt223@freemail.gr> | 2006-12-27 21:06:04 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-02-21 10:34:22 -0500 |
commit | 25d8527a441760c333c41ec7197ba0750780b371 (patch) | |
tree | 9c0904bf4c220e2fbcb821cf200c366af8b70cce /drivers/media/video/pvrusb2/pvrusb2-hdw.c | |
parent | 275b2e283b139bee19e7de5929d01484b8e3ee51 (diff) |
V4L/DVB (5035): Pvrusb2: Enable radio mode round #2
This is the logic that:
a) Ensures /sys/class/pvrusb2/sn-*/ctl_frequency/{max,min}_val are
"automagically" reset to sane values on each mode change.
b) Allows tuning to a radio frequency by something like:
echo `perl -e "print int(94.9*16000 + 0.5)"` \
> /sys/class/pvrusb2/sn-*/ctl_input/cur_val
The trick was to take advantage of the already existing .get_{min,max}_value
function pointers in pvr2_ctrl, to "dynamically override" the hardcoded values
for min/max frequency at runtime.
For a moment I thought to dispose of the hardcoded MIN/MAX_FREQ and use the
hirange/lowrange fields of the v4l2_tuner struct instead, but then I see that
tuner-core.c kinda hardcodes these as well, so I decided to not bother.
Signed-off-by: Pantelis Koukousoulas <pakt223@freemail.gr>
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/pvrusb2/pvrusb2-hdw.c')
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-hdw.c | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c index 5f6ab998bbe7..ca4ef95996be 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c | |||
@@ -37,6 +37,12 @@ | |||
37 | #include "pvrusb2-encoder.h" | 37 | #include "pvrusb2-encoder.h" |
38 | #include "pvrusb2-debug.h" | 38 | #include "pvrusb2-debug.h" |
39 | 39 | ||
40 | #define TV_MIN_FREQ 55250000L | ||
41 | #define TV_MAX_FREQ 850000000L | ||
42 | |||
43 | #define RADIO_MIN_FREQ 1392000L //87MHz | ||
44 | #define RADIO_MAX_FREQ 1728000L //108MHz | ||
45 | |||
40 | struct usb_device_id pvr2_device_table[] = { | 46 | struct usb_device_id pvr2_device_table[] = { |
41 | [PVR2_HDW_TYPE_29XXX] = { USB_DEVICE(0x2040, 0x2900) }, | 47 | [PVR2_HDW_TYPE_29XXX] = { USB_DEVICE(0x2040, 0x2900) }, |
42 | [PVR2_HDW_TYPE_24XXX] = { USB_DEVICE(0x2040, 0x2400) }, | 48 | [PVR2_HDW_TYPE_24XXX] = { USB_DEVICE(0x2040, 0x2400) }, |
@@ -375,6 +381,28 @@ static int ctrl_vres_min_get(struct pvr2_ctrl *cptr,int *vp) | |||
375 | return 0; | 381 | return 0; |
376 | } | 382 | } |
377 | 383 | ||
384 | static int ctrl_freq_max_get(struct pvr2_ctrl *cptr, int *vp) | ||
385 | { | ||
386 | /* Actual maximum depends on radio/tv mode */ | ||
387 | if (cptr->hdw->input_val == PVR2_CVAL_INPUT_RADIO) { | ||
388 | *vp = RADIO_MAX_FREQ; | ||
389 | } else { | ||
390 | *vp = TV_MAX_FREQ; | ||
391 | } | ||
392 | return 0; | ||
393 | } | ||
394 | |||
395 | static int ctrl_freq_min_get(struct pvr2_ctrl *cptr, int *vp) | ||
396 | { | ||
397 | /* Actual minimum depends on radio/tv mode */ | ||
398 | if (cptr->hdw->input_val == PVR2_CVAL_INPUT_RADIO) { | ||
399 | *vp = RADIO_MIN_FREQ; | ||
400 | } else { | ||
401 | *vp = TV_MIN_FREQ; | ||
402 | } | ||
403 | return 0; | ||
404 | } | ||
405 | |||
378 | static int ctrl_cx2341x_is_dirty(struct pvr2_ctrl *cptr) | 406 | static int ctrl_cx2341x_is_dirty(struct pvr2_ctrl *cptr) |
379 | { | 407 | { |
380 | return cptr->hdw->enc_stale != 0; | 408 | return cptr->hdw->enc_stale != 0; |
@@ -644,9 +672,6 @@ VCREATE_FUNCS(res_hor) | |||
644 | VCREATE_FUNCS(res_ver) | 672 | VCREATE_FUNCS(res_ver) |
645 | VCREATE_FUNCS(srate) | 673 | VCREATE_FUNCS(srate) |
646 | 674 | ||
647 | #define MIN_FREQ 55250000L | ||
648 | #define MAX_FREQ 850000000L | ||
649 | |||
650 | /* Table definition of all controls which can be manipulated */ | 675 | /* Table definition of all controls which can be manipulated */ |
651 | static const struct pvr2_ctl_info control_defs[] = { | 676 | static const struct pvr2_ctl_info control_defs[] = { |
652 | { | 677 | { |
@@ -760,7 +785,11 @@ static const struct pvr2_ctl_info control_defs[] = { | |||
760 | .get_value = ctrl_freq_get, | 785 | .get_value = ctrl_freq_get, |
761 | .is_dirty = ctrl_freq_is_dirty, | 786 | .is_dirty = ctrl_freq_is_dirty, |
762 | .clear_dirty = ctrl_freq_clear_dirty, | 787 | .clear_dirty = ctrl_freq_clear_dirty, |
763 | DEFINT(MIN_FREQ,MAX_FREQ), | 788 | DEFINT(TV_MIN_FREQ,TV_MAX_FREQ), |
789 | /* Hook in check for input value (tv/radio) and adjust | ||
790 | max/min values accordingly */ | ||
791 | .get_max_value = ctrl_freq_max_get, | ||
792 | .get_min_value = ctrl_freq_min_get, | ||
764 | },{ | 793 | },{ |
765 | .desc = "Channel", | 794 | .desc = "Channel", |
766 | .name = "channel", | 795 | .name = "channel", |
@@ -772,7 +801,7 @@ static const struct pvr2_ctl_info control_defs[] = { | |||
772 | .name = "freq_table_value", | 801 | .name = "freq_table_value", |
773 | .set_value = ctrl_channelfreq_set, | 802 | .set_value = ctrl_channelfreq_set, |
774 | .get_value = ctrl_channelfreq_get, | 803 | .get_value = ctrl_channelfreq_get, |
775 | DEFINT(MIN_FREQ,MAX_FREQ), | 804 | DEFINT(TV_MIN_FREQ,TV_MAX_FREQ), |
776 | },{ | 805 | },{ |
777 | .desc = "Channel Program ID", | 806 | .desc = "Channel Program ID", |
778 | .name = "freq_table_channel", | 807 | .name = "freq_table_channel", |