ALSA: ASoC: McASP: remove unused variables
PATCH 1/3 ALSA: ASoC: McASP: remove unused variables
codec_fmt and sample_rate variables are unused in both snd_platform_data and davinci_audio_dev, so drop them.
--- include/linux/platform_data/davinci_asp.h | 1 - sound/soc/davinci/davinci-mcasp.c | 1 - sound/soc/davinci/davinci-mcasp.h | 2 -- 3 files changed, 4 deletions(-)
include/linux/platform_data/davinci_asp.h +0 -1
@@ -23,7 +23,6 @@ struct snd_platform_data {u32 rx_dma_offset;int asp_chan_q;/* event queue number for ASP channel */ int ram_chan_q;/* event queue number for RAM channel */ -unsigned int codec_fmt;/* * Allowing this is more efficient and eliminates left and right swaps * caused by underruns, but will swap the left and right channels
sound/soc/davinci/davinci-mcasp.c +0 -1
@@ -1174,7 +1174,6 @@ static int davinci_mcasp_probe(struct platform_device *pdev) dev->tdm_slots = pdata->tdm_slots; dev->num_serializer = pdata->num_serializer; dev->serial_dir = pdata->serial_dir; - dev->codec_fmt = pdata->codec_fmt; dev->version = pdata->version; dev->txnumevt = pdata->txnumevt; dev->rxnumevt = pdata->rxnumevt;
sound/soc/davinci/davinci-mcasp.h +0 -2
@@ -40,9 +40,7 @@ enum {struct davinci_audio_dev {struct davinci_pcm_dma_params dma_params[2 ];void __iomem *base; -int sample_rate;struct device *dev; -unsigned int codec_fmt;/* McASP specific data */ int tdm_slots;
Signature · 1 line
1.7.11.7
PATCH 2/3 ALSA: ASoC: McASP: determine XSSZ value programatically
This shouldn't change any functionality and is just a preparation a special case handling.
--- sound/soc/davinci/davinci-mcasp.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
sound/soc/davinci/davinci-mcasp.c +12 -9
@@ -621,48 +621,48 @@ static int davinci_mcasp_set_sysclk(struct snd_soc_dai *dai, int clk_id,static int davinci_config_channel_size (struct davinci_audio_dev *dev,int channel_size) { -u32 fmt =0 ; -u32 mask, rotate; +u32 fmt, mask, rotate; +u8 n_bits =0 ;switch (channel_size) {case DAVINCI_AUDIO_WORD_8 : - fmt =0x03 ; + n_bits =8 ; rotate =6 ; mask =0x000000ff ;break ;case DAVINCI_AUDIO_WORD_12 : - fmt =0x05 ; + n_bits =12 ; rotate =5 ; mask =0x00000fff ;break ;case DAVINCI_AUDIO_WORD_16 : - fmt =0x07 ; + n_bits =16 ; rotate =4 ; mask =0x0000ffff ;break ;case DAVINCI_AUDIO_WORD_20 : - fmt =0x09 ; + n_bits =20 ; rotate =3 ; mask =0x000fffff ;break ;case DAVINCI_AUDIO_WORD_24 : - fmt =0x0B ; + n_bits =24 ; rotate =2 ; mask =0x00ffffff ;break ;case DAVINCI_AUDIO_WORD_28 : - fmt =0x0D ; + n_bits =28 ; rotate =1 ; mask =0x0fffffff ;break ;case DAVINCI_AUDIO_WORD_32 : - fmt =0x0F ; + n_bits =32 ; rotate =0 ; mask =0xffffffff ;break ;
@@ -671,6 +671,9 @@ static int davinci_config_channel_size(struct davinci_audio_dev *dev,return -EINVAL ; } +/* mapping of the XSSZ bit-field as described in the datasheet */ + fmt = (n_bits >>1 ) -1 ; +mcasp_mod_bits (dev->base +DAVINCI_MCASP_RXFMT_REG ,RXSSZ (fmt),RXSSZ (0x0F )); mcasp_mod_bits(dev->base + DAVINCI_MCASP_TXFMT_REG,
Signature · 1 line
1.7.11.7
PATCH 3/3 ALSA: ASoC: McASP: implement a way to force BCLK/LRCLK ratios
In reply to Daniel MackDepending 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.
--- sound/soc/davinci/davinci-mcasp.c | 15 +++++++++++++++ sound/soc/davinci/davinci-mcasp.h | 1 + 2 files changed, 16 insertions(+)
sound/soc/davinci/davinci-mcasp.c +15 -0
@@ -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);break ; +case 2 :/* BCLK/LRCLK ratio */ + dev->bclk_lrclk_ratio = div; +break ; +default :return -EINVAL ; }
@@ -671,6 +675,17 @@ static int davinci_config_channel_size(struct davinci_audio_dev *dev,return -EINVAL ; } +/* +* 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) + n_bits = dev->bclk_lrclk_ratio /2 ; +/* mapping of the XSSZ bit-field as described in the datasheet */ fmt = (n_bits >>1 ) -1 ;
sound/soc/davinci/davinci-mcasp.h +1 -0
@@ -48,6 +48,7 @@ struct davinci_audio_dev {u8 num_serializer;u8 *serial_dir;u8 version; +u8 bclk_lrclk_ratio;/* McASP FIFO related */ u8 txnumevt;
Signature · 1 line
1.7.11.7
Re: [PATCH 2/3] ALSA: ASoC: McASP: determine XSSZ value programatically
In reply to Daniel MackQuoted 4 lines · Daniel Mack
This shouldn't change any functionality and is just a preparation a special case handling.
Signed-off-by Daniel Mack <[email protected]>
Hold on - I found another way that even does more cleanups. I'll resubmit a v2.
Daniel
Re: [PATCH 2/3] ALSA: ASoC: McASP: determine XSSZ value programatically
Quoted 8 lines · Daniel Mack
Quoted 4 lines · Daniel Mack
This shouldn't change any functionality and is just a preparation a special case handling.
Signed-off-by Daniel Mack <[email protected]>Hold on - I found another way that even does more cleanups. I'll resubmit a v2.
Kindly add a cover letter and mention what is/will be changed in V2 so that it will help the reviewers.
Quoted 5 lines
Daniel
Regards,
Gururaja
Re: [PATCH 2/3] ALSA: ASoC: McASP: determine XSSZ value programatically
Quoted 5 lines · Gururaja
Quoted 4 lines · Daniel Mack
Quoted 3 lines · Daniel Mack
This shouldn't change any functionality and is just a preparation a special case handling.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Daniel Mack <[email protected]>Hold on - I found another way that even does more cleanups. I'll resubmit a v2.
Kindly add a cover letter and mention what is/will be changed in V2 so that it will help the reviewers.
You're right - will do next time. Too late for this, as I already sent out v2. But as there was no feedback to the first round, you can just ignore it entirely and just look at v2.
Thanks,
Daniel