[alsa-devel] [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.
Signed-off-by: Daniel Mack zonque@gmail.com --- 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(-)
diff --git a/include/linux/platform_data/davinci_asp.h b/include/linux/platform_data/davinci_asp.h index f3d6e4f..8db5ae0 100644 --- a/include/linux/platform_data/davinci_asp.h +++ b/include/linux/platform_data/davinci_asp.h @@ -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 diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 46350b8..023a70d 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -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; diff --git a/sound/soc/davinci/davinci-mcasp.h b/sound/soc/davinci/davinci-mcasp.h index 156f15f..a42b5d9 100644 --- a/sound/soc/davinci/davinci-mcasp.h +++ b/sound/soc/davinci/davinci-mcasp.h @@ -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;
This shouldn't change any functionality and is just a preparation a special case handling.
Signed-off-by: Daniel Mack zonque@gmail.com --- sound/soc/davinci/davinci-mcasp.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 023a70d..68a2ea0 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -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,
On 05.12.2012 16:37, Daniel Mack wrote:
This shouldn't change any functionality and is just a preparation a special case handling.
Signed-off-by: Daniel Mack zonque@gmail.com
Hold on - I found another way that even does more cleanups. I'll resubmit a v2.
Daniel
On Wed, Dec 05, 2012 at 22:48:04, Daniel Mack wrote:
On 05.12.2012 16:37, Daniel Mack wrote:
This shouldn't change any functionality and is just a preparation a special case handling.
Signed-off-by: Daniel Mack zonque@gmail.com
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.
Daniel
Regards, Gururaja
On 06.12.2012 04:18, Hebbar, Gururaja wrote:
On Wed, Dec 05, 2012 at 22:48:04, Daniel Mack wrote:
On 05.12.2012 16:37, Daniel Mack wrote:
This shouldn't change any functionality and is just a preparation a special case handling.
Signed-off-by: Daniel Mack zonque@gmail.com
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
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 --- sound/soc/davinci/davinci-mcasp.c | 15 +++++++++++++++ sound/soc/davinci/davinci-mcasp.h | 1 + 2 files changed, 16 insertions(+)
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 68a2ea0..7d92708 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -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;
diff --git a/sound/soc/davinci/davinci-mcasp.h b/sound/soc/davinci/davinci-mcasp.h index a42b5d9..6f7c945 100644 --- a/sound/soc/davinci/davinci-mcasp.h +++ b/sound/soc/davinci/davinci-mcasp.h @@ -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;
participants (2)
-
Daniel Mack
-
Hebbar, Gururaja