* [PATCH v2 1/3] ALSA: ASoC: McASP: remove unused variables
@ 2012-12-05 17:20 Daniel Mack
2012-12-05 17:20 ` [PATCH v2 2/3] ALSA: ASoC: McASP: calculate values for channel size Daniel Mack
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Daniel Mack @ 2012-12-05 17:20 UTC (permalink / raw)
To: alsa-devel
Cc: mporter, broonie, nsekhar, vaibhav.bedia, Daniel Mack,
gururaja.hebbar
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;
--
1.7.11.7
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/3] ALSA: ASoC: McASP: calculate values for channel size
2012-12-05 17:20 [PATCH v2 1/3] ALSA: ASoC: McASP: remove unused variables Daniel Mack
@ 2012-12-05 17:20 ` Daniel Mack
2012-12-05 17:20 ` [PATCH v2 3/3] ALSA: ASoC: McASP: implement a way to force BCLK/LRCLK ratios Daniel Mack
2012-12-07 5:48 ` [PATCH v2 1/3] ALSA: ASoC: McASP: remove unused variables Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Daniel Mack @ 2012-12-05 17:20 UTC (permalink / raw)
To: alsa-devel
Cc: mporter, broonie, nsekhar, vaibhav.bedia, Daniel Mack,
gururaja.hebbar
Change davinci_config_channel_size() to derive the values for XSSZ and
XROT in DAVINCI_MCASP_[RT]XFMT_REG from the configured word length
rather than hard-coding them in a switch/case block.
Also, by directly passing the word length to
davinci_config_channel_size(), we can get rid of the
DAVINCI_AUDIO_WORD_* enum.
Signed-off-by: Daniel Mack <zonque@gmail.com>
---
sound/soc/davinci/davinci-mcasp.c | 63 +++++++--------------------------------
sound/soc/davinci/davinci-mcasp.h | 10 -------
2 files changed, 10 insertions(+), 63 deletions(-)
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index 023a70d..d940e01 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -619,57 +619,14 @@ 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)
+ int word_length)
{
- u32 fmt = 0;
- u32 mask, rotate;
-
- switch (channel_size) {
- case DAVINCI_AUDIO_WORD_8:
- fmt = 0x03;
- rotate = 6;
- mask = 0x000000ff;
- break;
-
- case DAVINCI_AUDIO_WORD_12:
- fmt = 0x05;
- rotate = 5;
- mask = 0x00000fff;
- break;
-
- case DAVINCI_AUDIO_WORD_16:
- fmt = 0x07;
- rotate = 4;
- mask = 0x0000ffff;
- break;
-
- case DAVINCI_AUDIO_WORD_20:
- fmt = 0x09;
- rotate = 3;
- mask = 0x000fffff;
- break;
-
- case DAVINCI_AUDIO_WORD_24:
- fmt = 0x0B;
- rotate = 2;
- mask = 0x00ffffff;
- break;
-
- case DAVINCI_AUDIO_WORD_28:
- fmt = 0x0D;
- rotate = 1;
- mask = 0x0fffffff;
- break;
-
- case DAVINCI_AUDIO_WORD_32:
- fmt = 0x0F;
- rotate = 0;
- mask = 0xffffffff;
- break;
+ u32 fmt;
+ u32 rotate = (32 - word_length) / 4;
+ u32 mask = (1ULL << word_length) - 1;
- default:
- return -EINVAL;
- }
+ /* mapping of the XSSZ bit-field as described in the datasheet */
+ fmt = (word_length >> 1) - 1;
mcasp_mod_bits(dev->base + DAVINCI_MCASP_RXFMT_REG,
RXSSZ(fmt), RXSSZ(0x0F));
@@ -856,19 +813,19 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
case SNDRV_PCM_FORMAT_U8:
case SNDRV_PCM_FORMAT_S8:
dma_params->data_type = 1;
- word_length = DAVINCI_AUDIO_WORD_8;
+ word_length = 8;
break;
case SNDRV_PCM_FORMAT_U16_LE:
case SNDRV_PCM_FORMAT_S16_LE:
dma_params->data_type = 2;
- word_length = DAVINCI_AUDIO_WORD_16;
+ word_length = 16;
break;
case SNDRV_PCM_FORMAT_U24_3LE:
case SNDRV_PCM_FORMAT_S24_3LE:
dma_params->data_type = 3;
- word_length = DAVINCI_AUDIO_WORD_24;
+ word_length = 24;
break;
case SNDRV_PCM_FORMAT_U24_LE:
@@ -876,7 +833,7 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
case SNDRV_PCM_FORMAT_U32_LE:
case SNDRV_PCM_FORMAT_S32_LE:
dma_params->data_type = 4;
- word_length = DAVINCI_AUDIO_WORD_32;
+ word_length = 32;
break;
default:
diff --git a/sound/soc/davinci/davinci-mcasp.h b/sound/soc/davinci/davinci-mcasp.h
index a42b5d9..d2449a8 100644
--- a/sound/soc/davinci/davinci-mcasp.h
+++ b/sound/soc/davinci/davinci-mcasp.h
@@ -27,16 +27,6 @@
#define DAVINCI_MCASP_I2S_DAI 0
#define DAVINCI_MCASP_DIT_DAI 1
-enum {
- DAVINCI_AUDIO_WORD_8 = 0,
- DAVINCI_AUDIO_WORD_12,
- DAVINCI_AUDIO_WORD_16,
- DAVINCI_AUDIO_WORD_20,
- DAVINCI_AUDIO_WORD_24,
- DAVINCI_AUDIO_WORD_32,
- DAVINCI_AUDIO_WORD_28, /* This is only valid for McASP */
-};
-
struct davinci_audio_dev {
struct davinci_pcm_dma_params dma_params[2];
void __iomem *base;
--
1.7.11.7
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 3/3] ALSA: ASoC: McASP: implement a way to force BCLK/LRCLK ratios
2012-12-05 17:20 [PATCH v2 1/3] ALSA: ASoC: McASP: remove unused variables Daniel Mack
2012-12-05 17:20 ` [PATCH v2 2/3] ALSA: ASoC: McASP: calculate values for channel size Daniel Mack
@ 2012-12-05 17:20 ` Daniel Mack
2012-12-07 5:48 ` [PATCH v2 1/3] ALSA: ASoC: McASP: remove unused variables Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Daniel Mack @ 2012-12-05 17:20 UTC (permalink / raw)
To: alsa-devel
Cc: mporter, broonie, nsekhar, vaibhav.bedia, Daniel Mack,
gururaja.hebbar
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 d940e01..e0c252a 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;
}
@@ -625,6 +629,17 @@ static int davinci_config_channel_size(struct davinci_audio_dev *dev,
u32 rotate = (32 - word_length) / 4;
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 */
fmt = (word_length >> 1) - 1;
diff --git a/sound/soc/davinci/davinci-mcasp.h b/sound/soc/davinci/davinci-mcasp.h
index d2449a8..0edd3b5 100644
--- a/sound/soc/davinci/davinci-mcasp.h
+++ b/sound/soc/davinci/davinci-mcasp.h
@@ -38,6 +38,7 @@ struct davinci_audio_dev {
u8 num_serializer;
u8 *serial_dir;
u8 version;
+ u8 bclk_lrclk_ratio;
/* McASP FIFO related */
u8 txnumevt;
--
1.7.11.7
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/3] ALSA: ASoC: McASP: remove unused variables
2012-12-05 17:20 [PATCH v2 1/3] ALSA: ASoC: McASP: remove unused variables Daniel Mack
2012-12-05 17:20 ` [PATCH v2 2/3] ALSA: ASoC: McASP: calculate values for channel size Daniel Mack
2012-12-05 17:20 ` [PATCH v2 3/3] ALSA: ASoC: McASP: implement a way to force BCLK/LRCLK ratios Daniel Mack
@ 2012-12-07 5:48 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2012-12-07 5:48 UTC (permalink / raw)
To: Daniel Mack; +Cc: mporter, alsa-devel, nsekhar, vaibhav.bedia, gururaja.hebbar
On Wed, Dec 05, 2012 at 06:20:36PM +0100, Daniel Mack wrote:
> codec_fmt and sample_rate variables are unused in both snd_platform_data
> and davinci_audio_dev, so drop them.
Applied all, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-12-07 5:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-05 17:20 [PATCH v2 1/3] ALSA: ASoC: McASP: remove unused variables Daniel Mack
2012-12-05 17:20 ` [PATCH v2 2/3] ALSA: ASoC: McASP: calculate values for channel size Daniel Mack
2012-12-05 17:20 ` [PATCH v2 3/3] ALSA: ASoC: McASP: implement a way to force BCLK/LRCLK ratios Daniel Mack
2012-12-07 5:48 ` [PATCH v2 1/3] ALSA: ASoC: McASP: remove unused variables Mark Brown
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.