diff options
author | Adrian Knoth <adi@drcomp.erfurt.thur.de> | 2013-07-05 05:28:17 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2013-07-05 08:52:57 -0400 |
commit | 2336142fc0470db2ac831225936b8e37b3ecb2bd (patch) | |
tree | b0715bfee5dfba29cbf3c873eadcacb105ae5a5c /sound/pci/rme9652 | |
parent | 194062daba00688dfd47caaf01f3131700cd726f (diff) |
ALSA: hdspm - Introduce hdspm_external_rate_to_enum() helper function
This patch refactors the code to query the external sample rate and its
translation into the corresponding enum into a helper function to
prevent future code duplication.
A later commit will make use of this new helper function.
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.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index f6e922cf3fd3..26f10fdbfcd6 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c | |||
@@ -2303,6 +2303,21 @@ static void snd_hdspm_set_infotext(struct snd_ctl_elem_info *uinfo, | |||
2303 | snd_hdspm_set_infotext(info, texts, ARRAY_SIZE(texts)) | 2303 | snd_hdspm_set_infotext(info, texts, ARRAY_SIZE(texts)) |
2304 | 2304 | ||
2305 | 2305 | ||
2306 | /* Helper function to query the external sample rate and return the | ||
2307 | * corresponding enum to be returned to userspace. | ||
2308 | */ | ||
2309 | static int hdspm_external_rate_to_enum(struct hdspm *hdspm) | ||
2310 | { | ||
2311 | int rate = hdspm_external_sample_rate(hdspm); | ||
2312 | int i, selected_rate = 0; | ||
2313 | for (i = 1; i < 10; i++) | ||
2314 | if (HDSPM_bit2freq(i) == rate) { | ||
2315 | selected_rate = i; | ||
2316 | break; | ||
2317 | } | ||
2318 | return selected_rate; | ||
2319 | } | ||
2320 | |||
2306 | 2321 | ||
2307 | #define HDSPM_AUTOSYNC_SAMPLE_RATE(xname, xindex) \ | 2322 | #define HDSPM_AUTOSYNC_SAMPLE_RATE(xname, xindex) \ |
2308 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | 2323 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
@@ -2396,18 +2411,9 @@ static int snd_hdspm_get_autosync_sample_rate(struct snd_kcontrol *kcontrol, | |||
2396 | 2411 | ||
2397 | case MADI: | 2412 | case MADI: |
2398 | case MADIface: | 2413 | case MADIface: |
2399 | { | 2414 | ucontrol->value.enumerated.item[0] = |
2400 | int rate = hdspm_external_sample_rate(hdspm); | 2415 | hdspm_external_rate_to_enum(hdspm); |
2401 | int i, selected_rate = 0; | ||
2402 | for (i = 1; i < 10; i++) | ||
2403 | if (HDSPM_bit2freq(i) == rate) { | ||
2404 | selected_rate = i; | ||
2405 | break; | ||
2406 | } | ||
2407 | ucontrol->value.enumerated.item[0] = selected_rate; | ||
2408 | } | ||
2409 | break; | 2416 | break; |
2410 | |||
2411 | default: | 2417 | default: |
2412 | break; | 2418 | break; |
2413 | } | 2419 | } |