diff options
author | Troy Kisky <troy.kisky@boundarydevices.com> | 2008-12-18 14:36:43 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2008-12-20 08:05:38 -0500 |
commit | 21903c1c9ecb7a210eb985aa8d82ad68c78283cc (patch) | |
tree | 86ded4c201d830806cc8d8f21a5b508e73615752 /sound/soc/davinci | |
parent | 664b4af859d43714fd2a90aa434e454355659d0e (diff) |
ALSA: ASoC: DaVinci: davinci-i2s clean up
Just at little cleanup of davinci_i2s_set_dai_fmt
Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/davinci')
-rw-r--r-- | sound/soc/davinci/davinci-i2s.c | 85 |
1 files changed, 37 insertions, 48 deletions
diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c index 156e3e95d914..028682846f4e 100644 --- a/sound/soc/davinci/davinci-i2s.c +++ b/sound/soc/davinci/davinci-i2s.c | |||
@@ -200,36 +200,41 @@ static int davinci_i2s_startup(struct snd_pcm_substream *substream, | |||
200 | return 0; | 200 | return 0; |
201 | } | 201 | } |
202 | 202 | ||
203 | #define DEFAULT_BITPERSAMPLE 16 | ||
204 | |||
203 | static int davinci_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai, | 205 | static int davinci_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai, |
204 | unsigned int fmt) | 206 | unsigned int fmt) |
205 | { | 207 | { |
206 | struct davinci_mcbsp_dev *dev = cpu_dai->private_data; | 208 | struct davinci_mcbsp_dev *dev = cpu_dai->private_data; |
207 | u32 w; | 209 | unsigned int pcr; |
210 | unsigned int srgr; | ||
211 | unsigned int rcr; | ||
212 | unsigned int xcr; | ||
213 | srgr = DAVINCI_MCBSP_SRGR_FSGM | | ||
214 | DAVINCI_MCBSP_SRGR_FPER(DEFAULT_BITPERSAMPLE * 2 - 1) | | ||
215 | DAVINCI_MCBSP_SRGR_FWID(DEFAULT_BITPERSAMPLE - 1); | ||
208 | 216 | ||
209 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | 217 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
210 | case SND_SOC_DAIFMT_CBS_CFS: | 218 | case SND_SOC_DAIFMT_CBS_CFS: |
211 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_PCR_REG, | 219 | /* cpu is master */ |
212 | DAVINCI_MCBSP_PCR_FSXM | | 220 | pcr = DAVINCI_MCBSP_PCR_FSXM | |
213 | DAVINCI_MCBSP_PCR_FSRM | | 221 | DAVINCI_MCBSP_PCR_FSRM | |
214 | DAVINCI_MCBSP_PCR_CLKXM | | 222 | DAVINCI_MCBSP_PCR_CLKXM | |
215 | DAVINCI_MCBSP_PCR_CLKRM); | 223 | DAVINCI_MCBSP_PCR_CLKRM; |
216 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SRGR_REG, | ||
217 | DAVINCI_MCBSP_SRGR_FSGM); | ||
218 | break; | 224 | break; |
219 | case SND_SOC_DAIFMT_CBM_CFS: | 225 | case SND_SOC_DAIFMT_CBM_CFS: |
220 | /* McBSP CLKR pin is the input for the Sample Rate Generator. | 226 | /* McBSP CLKR pin is the input for the Sample Rate Generator. |
221 | * McBSP FSR and FSX are driven by the Sample Rate Generator. */ | 227 | * McBSP FSR and FSX are driven by the Sample Rate Generator. */ |
222 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_PCR_REG, | 228 | pcr = DAVINCI_MCBSP_PCR_SCLKME | |
223 | DAVINCI_MCBSP_PCR_SCLKME | | 229 | DAVINCI_MCBSP_PCR_FSXM | |
224 | DAVINCI_MCBSP_PCR_FSXM | | 230 | DAVINCI_MCBSP_PCR_FSRM; |
225 | DAVINCI_MCBSP_PCR_FSRM); | ||
226 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SRGR_REG, | ||
227 | DAVINCI_MCBSP_SRGR_FSGM); | ||
228 | break; | 231 | break; |
229 | case SND_SOC_DAIFMT_CBM_CFM: | 232 | case SND_SOC_DAIFMT_CBM_CFM: |
230 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_PCR_REG, 0); | 233 | /* codec is master */ |
234 | pcr = 0; | ||
231 | break; | 235 | break; |
232 | default: | 236 | default: |
237 | printk(KERN_ERR "%s:bad master\n", __func__); | ||
233 | return -EINVAL; | 238 | return -EINVAL; |
234 | } | 239 | } |
235 | 240 | ||
@@ -244,10 +249,7 @@ static int davinci_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai, | |||
244 | * FSRP Receive frame sync pol, 0 - active high | 249 | * FSRP Receive frame sync pol, 0 - active high |
245 | * FSXP Transmit frame sync pol, 0 - active high | 250 | * FSXP Transmit frame sync pol, 0 - active high |
246 | */ | 251 | */ |
247 | w = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_PCR_REG); | 252 | pcr |= (DAVINCI_MCBSP_PCR_CLKXP | DAVINCI_MCBSP_PCR_CLKRP); |
248 | MOD_REG_BIT(w, DAVINCI_MCBSP_PCR_CLKXP | | ||
249 | DAVINCI_MCBSP_PCR_CLKRP, 1); | ||
250 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_PCR_REG, w); | ||
251 | break; | 253 | break; |
252 | case SND_SOC_DAIFMT_NB_IF: | 254 | case SND_SOC_DAIFMT_NB_IF: |
253 | /* CLKRP Receive clock polarity, | 255 | /* CLKRP Receive clock polarity, |
@@ -259,10 +261,7 @@ static int davinci_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai, | |||
259 | * FSRP Receive frame sync pol, 1 - active low | 261 | * FSRP Receive frame sync pol, 1 - active low |
260 | * FSXP Transmit frame sync pol, 1 - active low | 262 | * FSXP Transmit frame sync pol, 1 - active low |
261 | */ | 263 | */ |
262 | w = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_PCR_REG); | 264 | pcr |= (DAVINCI_MCBSP_PCR_FSXP | DAVINCI_MCBSP_PCR_FSRP); |
263 | MOD_REG_BIT(w, DAVINCI_MCBSP_PCR_FSXP | | ||
264 | DAVINCI_MCBSP_PCR_FSRP, 1); | ||
265 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_PCR_REG, w); | ||
266 | break; | 265 | break; |
267 | case SND_SOC_DAIFMT_IB_IF: | 266 | case SND_SOC_DAIFMT_IB_IF: |
268 | /* CLKRP Receive clock polarity, | 267 | /* CLKRP Receive clock polarity, |
@@ -274,12 +273,8 @@ static int davinci_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai, | |||
274 | * FSRP Receive frame sync pol, 1 - active low | 273 | * FSRP Receive frame sync pol, 1 - active low |
275 | * FSXP Transmit frame sync pol, 1 - active low | 274 | * FSXP Transmit frame sync pol, 1 - active low |
276 | */ | 275 | */ |
277 | w = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_PCR_REG); | 276 | pcr |= (DAVINCI_MCBSP_PCR_CLKXP | DAVINCI_MCBSP_PCR_CLKRP | |
278 | MOD_REG_BIT(w, DAVINCI_MCBSP_PCR_CLKXP | | 277 | DAVINCI_MCBSP_PCR_FSXP | DAVINCI_MCBSP_PCR_FSRP); |
279 | DAVINCI_MCBSP_PCR_CLKRP | | ||
280 | DAVINCI_MCBSP_PCR_FSXP | | ||
281 | DAVINCI_MCBSP_PCR_FSRP, 1); | ||
282 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_PCR_REG, w); | ||
283 | break; | 278 | break; |
284 | case SND_SOC_DAIFMT_NB_NF: | 279 | case SND_SOC_DAIFMT_NB_NF: |
285 | /* CLKRP Receive clock polarity, | 280 | /* CLKRP Receive clock polarity, |
@@ -296,28 +291,24 @@ static int davinci_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai, | |||
296 | return -EINVAL; | 291 | return -EINVAL; |
297 | } | 292 | } |
298 | 293 | ||
294 | rcr = DAVINCI_MCBSP_RCR_RFRLEN1(1); | ||
295 | xcr = DAVINCI_MCBSP_XCR_XFIG | DAVINCI_MCBSP_XCR_XFRLEN1(1); | ||
299 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | 296 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { |
300 | case SND_SOC_DAIFMT_RIGHT_J: | 297 | case SND_SOC_DAIFMT_RIGHT_J: |
301 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_RCR_REG, | ||
302 | DAVINCI_MCBSP_RCR_RFRLEN1(1) | | ||
303 | DAVINCI_MCBSP_RCR_RDATDLY(0)); | ||
304 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_XCR_REG, | ||
305 | DAVINCI_MCBSP_XCR_XFRLEN1(1) | | ||
306 | DAVINCI_MCBSP_XCR_XDATDLY(0) | | ||
307 | DAVINCI_MCBSP_XCR_XFIG); | ||
308 | break; | 298 | break; |
309 | case SND_SOC_DAIFMT_I2S: | 299 | case SND_SOC_DAIFMT_I2S: |
310 | default: | 300 | case SND_SOC_DAIFMT_DSP_B: |
311 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_RCR_REG, | 301 | rcr |= DAVINCI_MCBSP_RCR_RDATDLY(1); |
312 | DAVINCI_MCBSP_RCR_RFRLEN1(1) | | 302 | xcr |= DAVINCI_MCBSP_XCR_XDATDLY(1); |
313 | DAVINCI_MCBSP_RCR_RDATDLY(1)); | ||
314 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_XCR_REG, | ||
315 | DAVINCI_MCBSP_XCR_XFRLEN1(1) | | ||
316 | DAVINCI_MCBSP_XCR_XDATDLY(1) | | ||
317 | DAVINCI_MCBSP_XCR_XFIG); | ||
318 | break; | 303 | break; |
304 | default: | ||
305 | printk(KERN_ERR "%s:bad format\n", __func__); | ||
306 | return -EINVAL; | ||
319 | } | 307 | } |
320 | 308 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SRGR_REG, srgr); | |
309 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_PCR_REG, pcr); | ||
310 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_RCR_REG, rcr); | ||
311 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_XCR_REG, xcr); | ||
321 | return 0; | 312 | return 0; |
322 | } | 313 | } |
323 | 314 | ||
@@ -343,12 +334,10 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream *substream, | |||
343 | } | 334 | } |
344 | 335 | ||
345 | i = hw_param_interval(params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS); | 336 | i = hw_param_interval(params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS); |
346 | w = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_SRGR_REG); | 337 | w = DAVINCI_MCBSP_SRGR_FSGM; |
347 | MOD_REG_BIT(w, DAVINCI_MCBSP_SRGR_FWID(snd_interval_value(i) - 1), 1); | 338 | MOD_REG_BIT(w, DAVINCI_MCBSP_SRGR_FWID(snd_interval_value(i) - 1), 1); |
348 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SRGR_REG, w); | ||
349 | 339 | ||
350 | i = hw_param_interval(params, SNDRV_PCM_HW_PARAM_FRAME_BITS); | 340 | i = hw_param_interval(params, SNDRV_PCM_HW_PARAM_FRAME_BITS); |
351 | w = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_SRGR_REG); | ||
352 | MOD_REG_BIT(w, DAVINCI_MCBSP_SRGR_FPER(snd_interval_value(i) - 1), 1); | 341 | MOD_REG_BIT(w, DAVINCI_MCBSP_SRGR_FPER(snd_interval_value(i) - 1), 1); |
353 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SRGR_REG, w); | 342 | davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SRGR_REG, w); |
354 | 343 | ||