diff options
author | Daniel Ribeiro <drwyrm@gmail.com> | 2009-06-15 20:44:31 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-08-06 10:52:24 -0400 |
commit | a5479e389e989acfeca9c32eeb0083d086202280 (patch) | |
tree | 5bcc8940b9e7981916d1e9812957b72d6b82b8af | |
parent | 9029bb316bb99ccc7f0518c4d3e0d6adc0729c4f (diff) |
ASoC: change set_tdm_slot api to allow slot_width override.
Extend set_tdm_slot to allow the user to arbitrarily set the frame width
and active TX/RX slots.
Updates magician.c and wm9081.c for the new set_tdm_slot(). wm9081.c
still doesn't handle the slot_width override.
While being there, correct an incorrect use of SlotsPerFrm(7) use in
bitmask on pxa-ssp.c (SSCR0_SlotsPerFrm(x) is (((x) - 1) << 24)) ).
(this series is meant for Mark's for-2.6.32 branch)
Signed-off-by: Daniel Ribeiro <drwyrm@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r-- | include/sound/soc-dai.h | 5 | ||||
-rw-r--r-- | sound/soc/codecs/wm9081.c | 5 | ||||
-rw-r--r-- | sound/soc/pxa/magician.c | 2 | ||||
-rw-r--r-- | sound/soc/pxa/pxa-ssp.c | 27 | ||||
-rw-r--r-- | sound/soc/soc-core.c | 9 |
5 files changed, 33 insertions, 15 deletions
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h index 25d62ac53fc5..2d3fa2950aa1 100644 --- a/include/sound/soc-dai.h +++ b/include/sound/soc-dai.h | |||
@@ -106,7 +106,7 @@ int snd_soc_dai_set_pll(struct snd_soc_dai *dai, | |||
106 | int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt); | 106 | int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt); |
107 | 107 | ||
108 | int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai, | 108 | int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai, |
109 | unsigned int mask, int slots); | 109 | unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width); |
110 | 110 | ||
111 | int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate); | 111 | int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate); |
112 | 112 | ||
@@ -140,7 +140,8 @@ struct snd_soc_dai_ops { | |||
140 | */ | 140 | */ |
141 | int (*set_fmt)(struct snd_soc_dai *dai, unsigned int fmt); | 141 | int (*set_fmt)(struct snd_soc_dai *dai, unsigned int fmt); |
142 | int (*set_tdm_slot)(struct snd_soc_dai *dai, | 142 | int (*set_tdm_slot)(struct snd_soc_dai *dai, |
143 | unsigned int mask, int slots); | 143 | unsigned int tx_mask, unsigned int rx_mask, |
144 | int slots, int slot_width); | ||
144 | int (*set_tristate)(struct snd_soc_dai *dai, int tristate); | 145 | int (*set_tristate)(struct snd_soc_dai *dai, int tristate); |
145 | 146 | ||
146 | /* | 147 | /* |
diff --git a/sound/soc/codecs/wm9081.c b/sound/soc/codecs/wm9081.c index 156f2a4a5930..c96532351193 100644 --- a/sound/soc/codecs/wm9081.c +++ b/sound/soc/codecs/wm9081.c | |||
@@ -1214,8 +1214,9 @@ static int wm9081_set_sysclk(struct snd_soc_dai *codec_dai, | |||
1214 | return 0; | 1214 | return 0; |
1215 | } | 1215 | } |
1216 | 1216 | ||
1217 | /* FIXME: Needs to handle slot_width */ | ||
1217 | static int wm9081_set_tdm_slot(struct snd_soc_dai *dai, | 1218 | static int wm9081_set_tdm_slot(struct snd_soc_dai *dai, |
1218 | unsigned int mask, int slots) | 1219 | unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) |
1219 | { | 1220 | { |
1220 | struct snd_soc_codec *codec = dai->codec; | 1221 | struct snd_soc_codec *codec = dai->codec; |
1221 | unsigned int aif1 = wm9081_read(codec, WM9081_AUDIO_INTERFACE_1); | 1222 | unsigned int aif1 = wm9081_read(codec, WM9081_AUDIO_INTERFACE_1); |
@@ -1227,7 +1228,7 @@ static int wm9081_set_tdm_slot(struct snd_soc_dai *dai, | |||
1227 | 1228 | ||
1228 | aif1 |= (slots - 1) << WM9081_AIFDAC_TDM_MODE_SHIFT; | 1229 | aif1 |= (slots - 1) << WM9081_AIFDAC_TDM_MODE_SHIFT; |
1229 | 1230 | ||
1230 | switch (mask) { | 1231 | switch (rx_mask) { |
1231 | case 1: | 1232 | case 1: |
1232 | break; | 1233 | break; |
1233 | case 2: | 1234 | case 2: |
diff --git a/sound/soc/pxa/magician.c b/sound/soc/pxa/magician.c index 8889cd371608..9f7c61e23daf 100644 --- a/sound/soc/pxa/magician.c +++ b/sound/soc/pxa/magician.c | |||
@@ -190,7 +190,7 @@ static int magician_playback_hw_params(struct snd_pcm_substream *substream, | |||
190 | if (ret < 0) | 190 | if (ret < 0) |
191 | return ret; | 191 | return ret; |
192 | 192 | ||
193 | ret = snd_soc_dai_set_tdm_slot(cpu_dai, 1, 1); | 193 | ret = snd_soc_dai_set_tdm_slot(cpu_dai, 1, 0, 1, width); |
194 | if (ret < 0) | 194 | if (ret < 0) |
195 | return ret; | 195 | return ret; |
196 | 196 | ||
diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c index e22c5cef8fec..5b9ed6464789 100644 --- a/sound/soc/pxa/pxa-ssp.c +++ b/sound/soc/pxa/pxa-ssp.c | |||
@@ -375,21 +375,34 @@ static int pxa_ssp_set_dai_pll(struct snd_soc_dai *cpu_dai, | |||
375 | * Set the active slots in TDM/Network mode | 375 | * Set the active slots in TDM/Network mode |
376 | */ | 376 | */ |
377 | static int pxa_ssp_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, | 377 | static int pxa_ssp_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, |
378 | unsigned int mask, int slots) | 378 | unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) |
379 | { | 379 | { |
380 | struct ssp_priv *priv = cpu_dai->private_data; | 380 | struct ssp_priv *priv = cpu_dai->private_data; |
381 | struct ssp_device *ssp = priv->dev.ssp; | 381 | struct ssp_device *ssp = priv->dev.ssp; |
382 | u32 sscr0; | 382 | u32 sscr0; |
383 | 383 | ||
384 | sscr0 = ssp_read_reg(ssp, SSCR0) & ~SSCR0_SlotsPerFrm(7); | 384 | sscr0 = ssp_read_reg(ssp, SSCR0); |
385 | sscr0 &= ~(SSCR0_MOD | SSCR0_SlotsPerFrm(8) | SSCR0_EDSS | SSCR0_DSS); | ||
386 | |||
387 | /* set slot width */ | ||
388 | if (slot_width > 16) | ||
389 | sscr0 |= SSCR0_EDSS | SSCR0_DataSize(slot_width - 16); | ||
390 | else | ||
391 | sscr0 |= SSCR0_DataSize(slot_width); | ||
385 | 392 | ||
386 | /* set number of active slots */ | 393 | if (slots > 1) { |
387 | sscr0 |= SSCR0_SlotsPerFrm(slots); | 394 | /* enable network mode */ |
395 | sscr0 |= SSCR0_MOD; | ||
396 | |||
397 | /* set number of active slots */ | ||
398 | sscr0 |= SSCR0_SlotsPerFrm(slots); | ||
399 | |||
400 | /* set active slot mask */ | ||
401 | ssp_write_reg(ssp, SSTSA, tx_mask); | ||
402 | ssp_write_reg(ssp, SSRSA, rx_mask); | ||
403 | } | ||
388 | ssp_write_reg(ssp, SSCR0, sscr0); | 404 | ssp_write_reg(ssp, SSCR0, sscr0); |
389 | 405 | ||
390 | /* set active slot mask */ | ||
391 | ssp_write_reg(ssp, SSTSA, mask); | ||
392 | ssp_write_reg(ssp, SSRSA, mask); | ||
393 | return 0; | 406 | return 0; |
394 | } | 407 | } |
395 | 408 | ||
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index fb8d7a766155..e984a17cd656 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -2223,17 +2223,20 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_fmt); | |||
2223 | /** | 2223 | /** |
2224 | * snd_soc_dai_set_tdm_slot - configure DAI TDM. | 2224 | * snd_soc_dai_set_tdm_slot - configure DAI TDM. |
2225 | * @dai: DAI | 2225 | * @dai: DAI |
2226 | * @mask: DAI specific mask representing used slots. | 2226 | * @tx_mask: bitmask representing active TX slots. |
2227 | * @rx_mask: bitmask representing active RX slots. | ||
2227 | * @slots: Number of slots in use. | 2228 | * @slots: Number of slots in use. |
2229 | * @slot_width: Width in bits for each slot. | ||
2228 | * | 2230 | * |
2229 | * Configures a DAI for TDM operation. Both mask and slots are codec and DAI | 2231 | * Configures a DAI for TDM operation. Both mask and slots are codec and DAI |
2230 | * specific. | 2232 | * specific. |
2231 | */ | 2233 | */ |
2232 | int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai, | 2234 | int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai, |
2233 | unsigned int mask, int slots) | 2235 | unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) |
2234 | { | 2236 | { |
2235 | if (dai->ops && dai->ops->set_tdm_slot) | 2237 | if (dai->ops && dai->ops->set_tdm_slot) |
2236 | return dai->ops->set_tdm_slot(dai, mask, slots); | 2238 | return dai->ops->set_tdm_slot(dai, tx_mask, rx_mask, |
2239 | slots, slot_width); | ||
2237 | else | 2240 | else |
2238 | return -EINVAL; | 2241 | return -EINVAL; |
2239 | } | 2242 | } |