diff options
author | Moise Gergaud <moise.gergaud@st.com> | 2016-04-07 05:25:34 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-04-11 23:59:09 -0400 |
commit | 72199787662612a7747248f8b56bc5d42694538f (patch) | |
tree | 74a4db62ade332a182bd10634400b7e6f076ed40 /sound/soc | |
parent | 44f948bdb175bf326911c9ba0e47389918161ce5 (diff) |
ASoC: sti: helper functions to fix tdm runtime params
Signed-off-by: Moise Gergaud <moise.gergaud@st.com>
Acked-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc')
-rw-r--r-- | sound/soc/sti/sti_uniperif.c | 46 | ||||
-rw-r--r-- | sound/soc/sti/uniperif.h | 6 |
2 files changed, 52 insertions, 0 deletions
diff --git a/sound/soc/sti/sti_uniperif.c b/sound/soc/sti/sti_uniperif.c index 0c2474c16c11..d49badec9e62 100644 --- a/sound/soc/sti/sti_uniperif.c +++ b/sound/soc/sti/sti_uniperif.c | |||
@@ -59,6 +59,52 @@ int sti_uniperiph_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, | |||
59 | return 0; | 59 | return 0; |
60 | } | 60 | } |
61 | 61 | ||
62 | int sti_uniperiph_fix_tdm_chan(struct snd_pcm_hw_params *params, | ||
63 | struct snd_pcm_hw_rule *rule) | ||
64 | { | ||
65 | struct uniperif *uni = rule->private; | ||
66 | struct snd_interval t; | ||
67 | |||
68 | t.min = uni->tdm_slot.avail_slots; | ||
69 | t.max = uni->tdm_slot.avail_slots; | ||
70 | t.openmin = 0; | ||
71 | t.openmax = 0; | ||
72 | t.integer = 0; | ||
73 | |||
74 | return snd_interval_refine(hw_param_interval(params, rule->var), &t); | ||
75 | } | ||
76 | |||
77 | int sti_uniperiph_fix_tdm_format(struct snd_pcm_hw_params *params, | ||
78 | struct snd_pcm_hw_rule *rule) | ||
79 | { | ||
80 | struct uniperif *uni = rule->private; | ||
81 | struct snd_mask *maskp = hw_param_mask(params, rule->var); | ||
82 | u64 format; | ||
83 | |||
84 | switch (uni->tdm_slot.slot_width) { | ||
85 | case 16: | ||
86 | format = SNDRV_PCM_FMTBIT_S16_LE; | ||
87 | break; | ||
88 | case 32: | ||
89 | format = SNDRV_PCM_FMTBIT_S32_LE; | ||
90 | break; | ||
91 | default: | ||
92 | dev_err(uni->dev, "format not supported: %d bits\n", | ||
93 | uni->tdm_slot.slot_width); | ||
94 | return -EINVAL; | ||
95 | } | ||
96 | |||
97 | maskp->bits[0] &= (u_int32_t)format; | ||
98 | maskp->bits[1] &= (u_int32_t)(format >> 32); | ||
99 | /* clear remaining indexes */ | ||
100 | memset(maskp->bits + 2, 0, (SNDRV_MASK_MAX - 64) / 8); | ||
101 | |||
102 | if (!maskp->bits[0] && !maskp->bits[1]) | ||
103 | return -EINVAL; | ||
104 | |||
105 | return 0; | ||
106 | } | ||
107 | |||
62 | int sti_uniperiph_get_tdm_word_pos(struct uniperif *uni, | 108 | int sti_uniperiph_get_tdm_word_pos(struct uniperif *uni, |
63 | unsigned int *word_pos) | 109 | unsigned int *word_pos) |
64 | { | 110 | { |
diff --git a/sound/soc/sti/uniperif.h b/sound/soc/sti/uniperif.h index fb8e427754b6..17d5d1030741 100644 --- a/sound/soc/sti/uniperif.h +++ b/sound/soc/sti/uniperif.h | |||
@@ -1396,4 +1396,10 @@ int sti_uniperiph_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, | |||
1396 | int sti_uniperiph_get_tdm_word_pos(struct uniperif *uni, | 1396 | int sti_uniperiph_get_tdm_word_pos(struct uniperif *uni, |
1397 | unsigned int *word_pos); | 1397 | unsigned int *word_pos); |
1398 | 1398 | ||
1399 | int sti_uniperiph_fix_tdm_chan(struct snd_pcm_hw_params *params, | ||
1400 | struct snd_pcm_hw_rule *rule); | ||
1401 | |||
1402 | int sti_uniperiph_fix_tdm_format(struct snd_pcm_hw_params *params, | ||
1403 | struct snd_pcm_hw_rule *rule); | ||
1404 | |||
1399 | #endif | 1405 | #endif |