Message ID | 20220708160244.21933-6-aidanmacdonald.0x0@gmail.com (mailing list archive) |
---|---|
State | Handled Elsewhere |
Headers | show |
Series | ASoC: cleanups and improvements for jz4740-i2s | expand |
Hi Aidan, Le ven., juil. 8 2022 at 17:02:38 +0100, Aidan MacDonald <aidanmacdonald.0x0@gmail.com> a écrit : > Get rid of a couple of macros and improve readability by using > FIELD_PREP() and GENMASK() for the sample size setting. > > Acked-by: Paul Cercueil <paul@crapouillou.net> > Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com> Reviewed-by: Paul Cercueil <paul@crapouillou.net> Cheers, -Paul > --- > sound/soc/jz4740/jz4740-i2s.c | 17 ++++++++--------- > 1 file changed, 8 insertions(+), 9 deletions(-) > > diff --git a/sound/soc/jz4740/jz4740-i2s.c > b/sound/soc/jz4740/jz4740-i2s.c > index 043f100a9cfa..d0791dfa9c7b 100644 > --- a/sound/soc/jz4740/jz4740-i2s.c > +++ b/sound/soc/jz4740/jz4740-i2s.c > @@ -3,6 +3,7 @@ > * Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de> > */ > > +#include <linux/bitfield.h> > #include <linux/init.h> > #include <linux/io.h> > #include <linux/kernel.h> > @@ -42,8 +43,8 @@ > #define JZ_AIC_CONF_SYNC_CLK_MASTER BIT(1) > #define JZ_AIC_CONF_ENABLE BIT(0) > > -#define JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE_MASK (0x7 << 19) > -#define JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_MASK (0x7 << 16) > +#define JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE GENMASK(21, 19) > +#define JZ_AIC_CTRL_INPUT_SAMPLE_SIZE GENMASK(18, 16) > #define JZ_AIC_CTRL_ENABLE_RX_DMA BIT(15) > #define JZ_AIC_CTRL_ENABLE_TX_DMA BIT(14) > #define JZ_AIC_CTRL_MONO_TO_STEREO BIT(11) > @@ -61,9 +62,6 @@ > #define JZ4760_AIC_CTRL_TFLUSH BIT(8) > #define JZ4760_AIC_CTRL_RFLUSH BIT(7) > > -#define JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE_OFFSET 19 > -#define JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_OFFSET 16 > - > #define JZ_AIC_I2S_FMT_DISABLE_BIT_CLK BIT(12) > #define JZ_AIC_I2S_FMT_DISABLE_BIT_ICLK BIT(13) > #define JZ_AIC_I2S_FMT_ENABLE_SYS_CLK BIT(4) > @@ -248,8 +246,9 @@ static int jz4740_i2s_hw_params(struct > snd_pcm_substream *substream, > } > > if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { > - ctrl &= ~JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE_MASK; > - ctrl |= sample_size << JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE_OFFSET; > + ctrl &= ~JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE; > + ctrl |= FIELD_PREP(JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE, sample_size); > + > if (params_channels(params) == 1) > ctrl |= JZ_AIC_CTRL_MONO_TO_STEREO; > else > @@ -257,8 +256,8 @@ static int jz4740_i2s_hw_params(struct > snd_pcm_substream *substream, > > div_field = i2s->field_i2sdiv_playback; > } else { > - ctrl &= ~JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_MASK; > - ctrl |= sample_size << JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_OFFSET; > + ctrl &= ~JZ_AIC_CTRL_INPUT_SAMPLE_SIZE; > + ctrl |= FIELD_PREP(JZ_AIC_CTRL_INPUT_SAMPLE_SIZE, sample_size); > > div_field = i2s->field_i2sdiv_capture; > } > -- > 2.35.1 >
diff --git a/sound/soc/jz4740/jz4740-i2s.c b/sound/soc/jz4740/jz4740-i2s.c index 043f100a9cfa..d0791dfa9c7b 100644 --- a/sound/soc/jz4740/jz4740-i2s.c +++ b/sound/soc/jz4740/jz4740-i2s.c @@ -3,6 +3,7 @@ * Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de> */ +#include <linux/bitfield.h> #include <linux/init.h> #include <linux/io.h> #include <linux/kernel.h> @@ -42,8 +43,8 @@ #define JZ_AIC_CONF_SYNC_CLK_MASTER BIT(1) #define JZ_AIC_CONF_ENABLE BIT(0) -#define JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE_MASK (0x7 << 19) -#define JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_MASK (0x7 << 16) +#define JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE GENMASK(21, 19) +#define JZ_AIC_CTRL_INPUT_SAMPLE_SIZE GENMASK(18, 16) #define JZ_AIC_CTRL_ENABLE_RX_DMA BIT(15) #define JZ_AIC_CTRL_ENABLE_TX_DMA BIT(14) #define JZ_AIC_CTRL_MONO_TO_STEREO BIT(11) @@ -61,9 +62,6 @@ #define JZ4760_AIC_CTRL_TFLUSH BIT(8) #define JZ4760_AIC_CTRL_RFLUSH BIT(7) -#define JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE_OFFSET 19 -#define JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_OFFSET 16 - #define JZ_AIC_I2S_FMT_DISABLE_BIT_CLK BIT(12) #define JZ_AIC_I2S_FMT_DISABLE_BIT_ICLK BIT(13) #define JZ_AIC_I2S_FMT_ENABLE_SYS_CLK BIT(4) @@ -248,8 +246,9 @@ static int jz4740_i2s_hw_params(struct snd_pcm_substream *substream, } if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - ctrl &= ~JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE_MASK; - ctrl |= sample_size << JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE_OFFSET; + ctrl &= ~JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE; + ctrl |= FIELD_PREP(JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE, sample_size); + if (params_channels(params) == 1) ctrl |= JZ_AIC_CTRL_MONO_TO_STEREO; else @@ -257,8 +256,8 @@ static int jz4740_i2s_hw_params(struct snd_pcm_substream *substream, div_field = i2s->field_i2sdiv_playback; } else { - ctrl &= ~JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_MASK; - ctrl |= sample_size << JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_OFFSET; + ctrl &= ~JZ_AIC_CTRL_INPUT_SAMPLE_SIZE; + ctrl |= FIELD_PREP(JZ_AIC_CTRL_INPUT_SAMPLE_SIZE, sample_size); div_field = i2s->field_i2sdiv_capture; }