aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/rme9652
diff options
context:
space:
mode:
authorAdrian Knoth <adi@drcomp.erfurt.thur.de>2013-03-09 18:37:26 -0500
committerTakashi Iwai <tiwai@suse.de>2013-03-11 05:11:20 -0400
commitf99c78812fcc38a32f9f1694cf75dd7f7e329ae7 (patch)
tree0b6165d423d67281e5e98b2a6d909336d4c8eacc /sound/pci/rme9652
parent345422133ae07147aa695a469bfec8f97d77a81c (diff)
ALSA: hdspm - Add ALSA controls to read the TCO LTC state
This patch adds new ALSA controls to query the LTC state from userspace. Signed-off-by: Adrian Knoth <adi@drcomp.erfurt.thur.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/rme9652')
-rw-r--r--sound/pci/rme9652/hdspm.c106
1 files changed, 106 insertions, 0 deletions
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index 8b7c9fb901c7..e23572dd0e46 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -2930,6 +2930,112 @@ static int snd_hdspm_get_autosync_ref(struct snd_kcontrol *kcontrol,
2930 return 0; 2930 return 0;
2931} 2931}
2932 2932
2933
2934
2935#define HDSPM_TCO_VIDEO_INPUT_FORMAT(xname, xindex) \
2936{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2937 .name = xname, \
2938 .access = SNDRV_CTL_ELEM_ACCESS_READ |\
2939 SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
2940 .info = snd_hdspm_info_tco_video_input_format, \
2941 .get = snd_hdspm_get_tco_video_input_format, \
2942}
2943
2944static int snd_hdspm_info_tco_video_input_format(struct snd_kcontrol *kcontrol,
2945 struct snd_ctl_elem_info *uinfo)
2946{
2947 static char *texts[] = {"No video", "NTSC", "PAL"};
2948 ENUMERATED_CTL_INFO(uinfo, texts);
2949 return 0;
2950}
2951
2952static int snd_hdspm_get_tco_video_input_format(struct snd_kcontrol *kcontrol,
2953 struct snd_ctl_elem_value *ucontrol)
2954{
2955 u32 status;
2956 int ret = 0;
2957
2958 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
2959 status = hdspm_read(hdspm, HDSPM_RD_TCO + 4);
2960 switch (status & (HDSPM_TCO1_Video_Input_Format_NTSC |
2961 HDSPM_TCO1_Video_Input_Format_PAL)) {
2962 case HDSPM_TCO1_Video_Input_Format_NTSC:
2963 /* ntsc */
2964 ret = 1;
2965 break;
2966 case HDSPM_TCO1_Video_Input_Format_PAL:
2967 /* pal */
2968 ret = 2;
2969 break;
2970 default:
2971 /* no video */
2972 ret = 0;
2973 break;
2974 }
2975 ucontrol->value.enumerated.item[0] = ret;
2976 return 0;
2977}
2978
2979
2980
2981#define HDSPM_TCO_LTC_FRAMES(xname, xindex) \
2982{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2983 .name = xname, \
2984 .access = SNDRV_CTL_ELEM_ACCESS_READ |\
2985 SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
2986 .info = snd_hdspm_info_tco_ltc_frames, \
2987 .get = snd_hdspm_get_tco_ltc_frames, \
2988}
2989
2990static int snd_hdspm_info_tco_ltc_frames(struct snd_kcontrol *kcontrol,
2991 struct snd_ctl_elem_info *uinfo)
2992{
2993 static char *texts[] = {"No lock", "24 fps", "25 fps", "29.97 fps",
2994 "30 fps"};
2995 ENUMERATED_CTL_INFO(uinfo, texts);
2996 return 0;
2997}
2998
2999static int hdspm_tco_ltc_frames(struct hdspm *hdspm)
3000{
3001 u32 status;
3002 int ret = 0;
3003
3004 status = hdspm_read(hdspm, HDSPM_RD_TCO + 4);
3005 if (status & HDSPM_TCO1_LTC_Input_valid) {
3006 switch (status & (HDSPM_TCO1_LTC_Format_LSB |
3007 HDSPM_TCO1_LTC_Format_MSB)) {
3008 case 0:
3009 /* 24 fps */
3010 ret = 1;
3011 break;
3012 case HDSPM_TCO1_LTC_Format_LSB:
3013 /* 25 fps */
3014 ret = 2;
3015 break;
3016 case HDSPM_TCO1_LTC_Format_MSB:
3017 /* 25 fps */
3018 ret = 3;
3019 break;
3020 default:
3021 /* 30 fps */
3022 ret = 4;
3023 break;
3024 }
3025 }
3026
3027 return ret;
3028}
3029
3030static int snd_hdspm_get_tco_ltc_frames(struct snd_kcontrol *kcontrol,
3031 struct snd_ctl_elem_value *ucontrol)
3032{
3033 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
3034
3035 ucontrol->value.enumerated.item[0] = hdspm_tco_ltc_frames(hdspm);
3036 return 0;
3037}
3038
2933#define HDSPM_TOGGLE_SETTING(xname, xindex) \ 3039#define HDSPM_TOGGLE_SETTING(xname, xindex) \
2934{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 3040{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2935 .name = xname, \ 3041 .name = xname, \