2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-24 13:13:57 +08:00

ASoC: McASP: implement a way to force BCLK/LRCLK ratios

Depending on the Codec, the the BCLK/LRCLK ratio might not be freely
chosen by the CPU DAI.

For example, some Codec might want to be supplied with 32-bit samples
for both its channels regardless of the actual audio word size the CPU
sends. In such cases, the rest of the bits on the data lines must be
padded with zeros:

          _______________________________
LRCLK    /                               \
      --'                                 `---------- .....

BCLK  ||||||||||||||||||||||||||||||||||||||||||||||| .....

DATA  ____||||||||||||||||_________________|||||||||| .....

          |<--  data  -->|<--   pads  --> |

This patch adds a new clock divider to configure the BCLK/LRCLK ratio.
If the machine code uses that divider, the driver uses the specified
value, instead of deriving that information from the audio word size.

Otherwise, the original behaviour is retained.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
Daniel Mack 2012-12-05 18:20:38 +01:00 committed by Mark Brown
parent ba764b3def
commit 1b3bc060fb
2 changed files with 16 additions and 0 deletions

View File

@ -593,6 +593,10 @@ static int davinci_mcasp_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div
ACLKRDIV(div - 1), ACLKRDIV_MASK); ACLKRDIV(div - 1), ACLKRDIV_MASK);
break; break;
case 2: /* BCLK/LRCLK ratio */
dev->bclk_lrclk_ratio = div;
break;
default: default:
return -EINVAL; return -EINVAL;
} }
@ -625,6 +629,17 @@ static int davinci_config_channel_size(struct davinci_audio_dev *dev,
u32 rotate = (32 - word_length) / 4; u32 rotate = (32 - word_length) / 4;
u32 mask = (1ULL << word_length) - 1; u32 mask = (1ULL << word_length) - 1;
/*
* if s BCLK-to-LRCLK ratio has been configured via the set_clkdiv()
* callback, take it into account here. That allows us to for example
* send 32 bits per channel to the codec, while only 16 of them carry
* audio payload.
* The clock ratio is given for a full period of data (both left and
* right channels), so it has to be divided by 2.
*/
if (dev->bclk_lrclk_ratio)
word_length = dev->bclk_lrclk_ratio / 2;
/* mapping of the XSSZ bit-field as described in the datasheet */ /* mapping of the XSSZ bit-field as described in the datasheet */
fmt = (word_length >> 1) - 1; fmt = (word_length >> 1) - 1;

View File

@ -38,6 +38,7 @@ struct davinci_audio_dev {
u8 num_serializer; u8 num_serializer;
u8 *serial_dir; u8 *serial_dir;
u8 version; u8 version;
u8 bclk_lrclk_ratio;
/* McASP FIFO related */ /* McASP FIFO related */
u8 txnumevt; u8 txnumevt;