diff options
author | Mike Isely <isely@pobox.com> | 2009-03-06 22:13:25 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-30 11:43:34 -0400 |
commit | 2641df36212ebb29aa8d7e9a9ecac7b349108c6f (patch) | |
tree | ca778a768a9de70bbdc4de4e98aeecfa3aad2974 /drivers/media/video/pvrusb2/pvrusb2-hdw.c | |
parent | 40f07111be99b71c1e8d40c13cdc38445add787f (diff) |
V4L/DVB (11167): pvrusb2: Tie in various v4l2 operations into the sub-device mechanism
This is another step in the v42l-subdev assimilation. This implements
various call-outs to sub-devices based on state changes within the
pvrusb2 driver.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/pvrusb2/pvrusb2-hdw.c')
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-hdw.c | 102 |
1 files changed, 99 insertions, 3 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c index d619e807a339..8aeccb27019b 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c | |||
@@ -2839,11 +2839,102 @@ static const char *get_ctrl_typename(enum pvr2_ctl_type tp) | |||
2839 | } | 2839 | } |
2840 | 2840 | ||
2841 | 2841 | ||
2842 | static void pvr2_subdev_set_control(struct pvr2_hdw *hdw, int id, | ||
2843 | const char *name, int val) | ||
2844 | { | ||
2845 | struct v4l2_control ctrl; | ||
2846 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 %s=%d", name, val); | ||
2847 | memset(&ctrl, 0, sizeof(ctrl)); | ||
2848 | ctrl.id = id; | ||
2849 | ctrl.value = val; | ||
2850 | v4l2_device_call_all(&hdw->v4l2_dev, 0, core, s_ctrl, &ctrl); | ||
2851 | } | ||
2852 | |||
2853 | #define PVR2_SUBDEV_SET_CONTROL(hdw, id, lab) \ | ||
2854 | if ((hdw)->lab##_dirty) { \ | ||
2855 | pvr2_subdev_set_control(hdw, id, #lab, (hdw)->lab##_val); \ | ||
2856 | } | ||
2857 | |||
2842 | /* Execute whatever commands are required to update the state of all the | 2858 | /* Execute whatever commands are required to update the state of all the |
2843 | sub-devices so that it matches our current control values. */ | 2859 | sub-devices so that they match our current control values. */ |
2844 | static void pvr2_subdev_update(struct pvr2_hdw *hdw) | 2860 | static void pvr2_subdev_update(struct pvr2_hdw *hdw) |
2845 | { | 2861 | { |
2846 | /* ????? */ | 2862 | if (hdw->input_dirty || hdw->std_dirty) { |
2863 | pvr2_trace(PVR2_TRACE_CHIPS,"subdev v4l2 set_standard"); | ||
2864 | if (hdw->input_val == PVR2_CVAL_INPUT_RADIO) { | ||
2865 | v4l2_device_call_all(&hdw->v4l2_dev, 0, | ||
2866 | tuner, s_radio); | ||
2867 | } else { | ||
2868 | v4l2_std_id vs; | ||
2869 | vs = hdw->std_mask_cur; | ||
2870 | v4l2_device_call_all(&hdw->v4l2_dev, 0, | ||
2871 | tuner, s_std, vs); | ||
2872 | } | ||
2873 | hdw->tuner_signal_stale = !0; | ||
2874 | hdw->cropcap_stale = !0; | ||
2875 | } | ||
2876 | |||
2877 | PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_BRIGHTNESS, brightness); | ||
2878 | PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_CONTRAST, contrast); | ||
2879 | PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_SATURATION, saturation); | ||
2880 | PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_HUE, hue); | ||
2881 | PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_AUDIO_MUTE, mute); | ||
2882 | PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_AUDIO_VOLUME, volume); | ||
2883 | PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_AUDIO_BALANCE, balance); | ||
2884 | PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_AUDIO_BASS, bass); | ||
2885 | PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_AUDIO_TREBLE, treble); | ||
2886 | |||
2887 | if (hdw->input_dirty || hdw->audiomode_dirty) { | ||
2888 | struct v4l2_tuner vt; | ||
2889 | memset(&vt, 0, sizeof(vt)); | ||
2890 | vt.audmode = hdw->audiomode_val; | ||
2891 | v4l2_device_call_all(&hdw->v4l2_dev, 0, tuner, s_tuner, &vt); | ||
2892 | } | ||
2893 | |||
2894 | if (hdw->freqDirty) { | ||
2895 | unsigned long fv; | ||
2896 | struct v4l2_frequency freq; | ||
2897 | fv = pvr2_hdw_get_cur_freq(hdw); | ||
2898 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_freq(%lu)", fv); | ||
2899 | if (hdw->tuner_signal_stale) pvr2_hdw_status_poll(hdw); | ||
2900 | memset(&freq, 0, sizeof(freq)); | ||
2901 | if (hdw->tuner_signal_info.capability & V4L2_TUNER_CAP_LOW) { | ||
2902 | /* ((fv * 1000) / 62500) */ | ||
2903 | freq.frequency = (fv * 2) / 125; | ||
2904 | } else { | ||
2905 | freq.frequency = fv / 62500; | ||
2906 | } | ||
2907 | /* tuner-core currently doesn't seem to care about this, but | ||
2908 | let's set it anyway for completeness. */ | ||
2909 | if (hdw->input_val == PVR2_CVAL_INPUT_RADIO) { | ||
2910 | freq.type = V4L2_TUNER_RADIO; | ||
2911 | } else { | ||
2912 | freq.type = V4L2_TUNER_ANALOG_TV; | ||
2913 | } | ||
2914 | freq.tuner = 0; | ||
2915 | v4l2_device_call_all(&hdw->v4l2_dev, 0, tuner, | ||
2916 | s_frequency, &freq); | ||
2917 | } | ||
2918 | |||
2919 | if (hdw->res_hor_dirty || hdw->res_ver_dirty) { | ||
2920 | struct v4l2_format fmt; | ||
2921 | memset(&fmt, 0, sizeof(fmt)); | ||
2922 | fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
2923 | fmt.fmt.pix.width = hdw->res_hor_val; | ||
2924 | fmt.fmt.pix.height = hdw->res_ver_val; | ||
2925 | pvr2_trace(PVR2_TRACE_CHIPS,"subdev v4l2 set_size(%dx%d)", | ||
2926 | fmt.fmt.pix.width, fmt.fmt.pix.height); | ||
2927 | v4l2_device_call_all(&hdw->v4l2_dev, 0, video, s_fmt, &fmt); | ||
2928 | } | ||
2929 | |||
2930 | /* Unable to set crop parameters; there is apparently no equivalent | ||
2931 | for VIDIOC_S_CROP */ | ||
2932 | |||
2933 | /* ????? Cover special cases for specific sub-devices. */ | ||
2934 | |||
2935 | if (hdw->tuner_signal_stale && hdw->cropcap_stale) { | ||
2936 | pvr2_hdw_status_poll(hdw); | ||
2937 | } | ||
2847 | } | 2938 | } |
2848 | 2939 | ||
2849 | 2940 | ||
@@ -4818,6 +4909,7 @@ void pvr2_hdw_status_poll(struct pvr2_hdw *hdw) | |||
4818 | { | 4909 | { |
4819 | struct v4l2_tuner *vtp = &hdw->tuner_signal_info; | 4910 | struct v4l2_tuner *vtp = &hdw->tuner_signal_info; |
4820 | memset(vtp, 0, sizeof(*vtp)); | 4911 | memset(vtp, 0, sizeof(*vtp)); |
4912 | hdw->tuner_signal_stale = 0; | ||
4821 | pvr2_i2c_core_status_poll(hdw); | 4913 | pvr2_i2c_core_status_poll(hdw); |
4822 | /* Note: There apparently is no replacement for VIDIOC_CROPCAP | 4914 | /* Note: There apparently is no replacement for VIDIOC_CROPCAP |
4823 | using v4l2-subdev - therefore we can't support that AT ALL right | 4915 | using v4l2-subdev - therefore we can't support that AT ALL right |
@@ -4825,12 +4917,16 @@ void pvr2_hdw_status_poll(struct pvr2_hdw *hdw) | |||
4825 | But now it's a a chicken and egg problem...) */ | 4917 | But now it's a a chicken and egg problem...) */ |
4826 | v4l2_device_call_all(&hdw->v4l2_dev, 0, tuner, g_tuner, | 4918 | v4l2_device_call_all(&hdw->v4l2_dev, 0, tuner, g_tuner, |
4827 | &hdw->tuner_signal_info); | 4919 | &hdw->tuner_signal_info); |
4828 | pvr2_trace(PVR2_TRACE_CHIPS, "client status poll" | 4920 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev status poll" |
4829 | " type=%u strength=%u audio=0x%x cap=0x%x" | 4921 | " type=%u strength=%u audio=0x%x cap=0x%x" |
4830 | " low=%u hi=%u", | 4922 | " low=%u hi=%u", |
4831 | vtp->type, | 4923 | vtp->type, |
4832 | vtp->signal, vtp->rxsubchans, vtp->capability, | 4924 | vtp->signal, vtp->rxsubchans, vtp->capability, |
4833 | vtp->rangelow, vtp->rangehigh); | 4925 | vtp->rangelow, vtp->rangehigh); |
4926 | |||
4927 | /* We have to do this to avoid getting into constant polling if | ||
4928 | there's nobody to answer a poll of cropcap info. */ | ||
4929 | hdw->cropcap_stale = 0; | ||
4834 | } | 4930 | } |
4835 | 4931 | ||
4836 | 4932 | ||