ASoC: Intel: Add KeemBay ASoC platform driver
Subsystems (4)
v3 cover ASoC: Intel: Add KeemBay ASoC platform driver
The below series of patches support the KeemBay ASoC platform driver. The platform driver initialize the i2s to capture and playback the pcm data on the ARM. The i2s is running in polling mode.
There is no DSP in the KeemBay SoC. Users are rely on the Gstreamer plugin to perform Audio preprocessing.
Audio graph card is used to connect the platform driver with the tlv320aic3204 codec.
Change History:
v3:
- Adjusted header format.
- Use Audio graph card instead of custom sound card.
- Use if-else instead of conditional operator.
- Enabled .set_fmt to configure master clock.
v2:
- Corrected I2S naming for DT binding.
v1:
- Initial version.
Sia Jee Heng (3):
ASoC: Intel: Add KeemBay platform driver
ASoC: Intel: Add makefiles and kconfig changes for KeemBay
dt-bindings: sound: Add documentation for KeemBay i2s
.../bindings/sound/intel,keembay-i2s.yaml | 68 +++ sound/soc/intel/Kconfig | 7 + sound/soc/intel/Makefile | 1 + sound/soc/intel/keembay/Makefile | 4 + sound/soc/intel/keembay/kmb_platform.c | 667 +++++++++++++++++++++ sound/soc/intel/keembay/kmb_platform.h | 145 +++++ 6 files changed, 892 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/intel,keembay-i2s.yaml create mode 100644 sound/soc/intel/keembay/Makefile create mode 100644 sound/soc/intel/keembay/kmb_platform.c create mode 100644 sound/soc/intel/keembay/kmb_platform.h
Signature · 1 line
1.9.1
PATCH v3 1/3 ASoC: Intel: Add KeemBay platform driver
Add KeemBay ASoC platform driver which initialize the i2s controller and uses i2s to capture and transmit pcm data to external codec. The i2s is running in polling mode.
--- sound/soc/intel/keembay/Makefile | 4 + sound/soc/intel/keembay/kmb_platform.c | 667 +++++++++++++++++++++++++++++++++ sound/soc/intel/keembay/kmb_platform.h | 145 +++++++ 3 files changed, 816 insertions(+) create mode 100644 sound/soc/intel/keembay/Makefile create mode 100644 sound/soc/intel/keembay/kmb_platform.c create mode 100644 sound/soc/intel/keembay/kmb_platform.h
sound/soc/intel/keembay/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +snd-soc-kmb_platform-objs := \ + kmb_platform.o + +obj-$(CONFIG_SND_SOC_INTEL_KEEMBAY) += snd-soc-kmb_platform.o
sound/soc/intel/keembay/kmb_platform.c new file +667 -0
667 lines not on this page · raw message
sound/soc/intel/keembay/kmb_platform.h new file +145 -0
145 lines not on this page · raw message
Signature · 1 line
1.9.1
Cezary Rojewski
maintainerRe: [PATCH v3 1/3] ASoC: Intel: Add KeemBay platform driver
sound/soc/intel/keembay/kmb_platform.c line 20
Quoted 6 lines · Sia Jee Heng
sound/soc/intel/keembay/kmb_platform.c new file +6
-0+ +#define PERIODS_MIN 2 +#define PERIODS_MAX 48 +#define PERIOD_BYTES_MIN 4096 +#define BUFFER_BYTES_MAX (PERIODS_MAX * PERIOD_BYTES_MIN) +#define TDM_OPERATION 1
Looks as this is unused.
sound/soc/intel/keembay/kmb_platform.c line 24
Quoted 4 lines
sound/soc/intel/keembay/kmb_platform.c new file +4
-0+#define I2S_OPERATION 0 +#define DATA_WIDTH_CONFIG_BIT 6 +#define TDM_CHANNEL_CONFIG_BIT 3 +#define I2S_SAMPLE_RATES (SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000)
This defines common rates yet .formats are left alone? As .formats, .rate_min/ max and others are left alone I'd stick with this style and specify .rates directly too.
sound/soc/intel/keembay/kmb_platform.c line 31
Quoted 7 lines
sound/soc/intel/keembay/kmb_platform.c new file +7
-0+ +static const struct snd_pcm_hardware kmb_pcm_hardware = { + .info =SNDRV_PCM_INFO_INTERLEAVED | +SNDRV_PCM_INFO_MMAP | +SNDRV_PCM_INFO_MMAP_VALID | +SNDRV_PCM_INFO_BATCH | +SNDRV_PCM_INFO_BLOCK_TRANSFER ,
Several flags have been or'ed here. Have these been verified working for Keembay?
Quoted 29 lines
sound/soc/intel/keembay/kmb_platform.c new file +29
-0+ .rates = I2S_SAMPLE_RATES, + .rate_min = 16000, + .rate_max = 48000, + .formats =SNDRV_PCM_FMTBIT_S16_LE | +SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S32_LE, + .channels_min = 2, + .channels_max = 2, + .buffer_bytes_max = BUFFER_BYTES_MAX, + .period_bytes_min = PERIOD_BYTES_MIN, + .period_bytes_max = BUFFER_BYTES_MAX / PERIODS_MIN, + .periods_min = PERIODS_MIN, + .periods_max = PERIODS_MAX, + .fifo_size = 16, +}; + +static unsigned int kmb_pcm_tx_fn (struct kmb_i2s_info *kmb_i2s, +struct snd_pcm_runtime *runtime, +unsigned int tx_ptr,bool *period_elapsed) +{ +unsigned int period_pos = tx_ptr % runtime->period_size; +void __iomem *i2s_base = kmb_i2s->i2s_base; +u16 (*p16)[2 ]; +u32 (*p32)[2 ]; +int i; + +if (kmb_i2s->config.data_width ==16 ) + p16 = (void *)runtime->dma_area; +else
sound/soc/intel/keembay/kmb_platform.c line 70
Quoted 10 lines
sound/soc/intel/keembay/kmb_platform.c new file +10
-0+ p32 = (void *)runtime->dma_area; +/* KMB i2s uses two separate L/R FIFO */ +for (i =0 ; i < kmb_i2s->fifo_th; i++) { +if (kmb_i2s->config.data_width ==16 ) { +writel (p16[tx_ptr][0 ], i2s_base +LRBR_LTHR (0 )); +writel (p16[tx_ptr][1 ], i2s_base +RRBR_RTHR (0 )); + }else { +writel (p32[tx_ptr][0 ], i2s_base +LRBR_LTHR (0 )); +writel (p32[tx_ptr][1 ], i2s_base +RRBR_RTHR (0 )); + }
Looks like a refactor candidate. Both, the preceding 'if' and the 'for' - which are the body of this func - are "data_width" dependent. You could redure if-ology by defining separate variants for 16 and non-16.
Idk about naming index-variable 'rx_ptr'. This isn't a pointer, that's for sure.
Quoted 25 lines
sound/soc/intel/keembay/kmb_platform.c new file +25
-0+ + period_pos++; + +if (++tx_ptr >= runtime->buffer_size) + tx_ptr =0 ; + } + + *period_elapsed = period_pos >= runtime->period_size; + +return tx_ptr; +} + +static unsigned int kmb_pcm_rx_fn (struct kmb_i2s_info *kmb_i2s, +struct snd_pcm_runtime *runtime, +unsigned int rx_ptr,bool *period_elapsed) +{ +unsigned int period_pos = rx_ptr % runtime->period_size; +void __iomem *i2s_base = kmb_i2s->i2s_base; +u16 (*p16)[2 ]; +u32 (*p32)[2 ]; +int i; + +if (kmb_i2s->config.data_width ==16 ) + p16 = (void *)runtime->dma_area; +else
sound/soc/intel/keembay/kmb_platform.c line 105
Quoted 10 lines
sound/soc/intel/keembay/kmb_platform.c new file +10
-0+ p32 = (void *)runtime->dma_area; +/* KMB i2s uses two separate L/R FIFO */ +for (i =0 ; i < kmb_i2s->fifo_th; i++) { +if (kmb_i2s->config.data_width ==16 ) { + p16[rx_ptr][0 ] =readl (i2s_base +LRBR_LTHR (0 )); + p16[rx_ptr][1 ] =readl (i2s_base +RRBR_RTHR (0 )); + }else { + p32[rx_ptr][0 ] =readl (i2s_base +LRBR_LTHR (0 )); + p32[rx_ptr][1 ] =readl (i2s_base +RRBR_RTHR (0 )); + }
The exact same advice goes here.
Quoted 15 lines
sound/soc/intel/keembay/kmb_platform.c new file +14
-0+ + period_pos++; + +if (++rx_ptr >= runtime->buffer_size) + rx_ptr =0 ; + } + + *period_elapsed = period_pos >= runtime->period_size; + +return rx_ptr; +} + + +static void kmb_pcm_operation (struct kmb_i2s_info *kmb_i2s,bool playback)
sound/soc/intel/keembay/kmb_platform.c line 180
Quoted 10 lines
sound/soc/intel/keembay/kmb_platform.c new file +10
-0+{ +struct snd_pcm_substream *substream; +bool active, period_elapsed; + +if (playback) + substream = kmb_i2s->tx_substream; +else + substream = kmb_i2s->rx_substream; + + active = substream &&snd_pcm_running (substream);
'active' serves little to no purpose here, I'd opt for removing it.
Review
Quoted 2 lines
(quoted diff) +2
-0+ + if (active) {
When deciding between no middle func 'return' or recuded indentation, the later is more readable. Simple:
if (!substream || snd_pcm_running(substream)) return;
allows rest of the function to be shift-left'ed.
sound/soc/intel/keembay/kmb_platform.c line 184
Quoted 2 lines
sound/soc/intel/keembay/kmb_platform.c new file +2
-0+unsigned int ptr; +unsigned int new_ptr;
'ptr' and 'new_ptr' declared in local scope yet 'period_elapsed' found its way out of here. To make code look cohesive, either have all declared in function's var declaration block or make sure local scope contains all local variables declarations.
Of course this is obsolete if you decide to pursue shift-left suggestion.
Quoted 20 lines
sound/soc/intel/keembay/kmb_platform.c new file +19
-0+ +if (playback) { + ptr = kmb_i2s->tx_ptr; + new_ptr =kmb_pcm_tx_fn (kmb_i2s, substream->runtime, + ptr, &period_elapsed); +cmpxchg (&kmb_i2s->tx_ptr, ptr, new_ptr); + }else { + ptr = kmb_i2s->rx_ptr; + new_ptr =kmb_pcm_rx_fn (kmb_i2s, substream->runtime, + ptr, &period_elapsed); +cmpxchg (&kmb_i2s->rx_ptr, ptr, new_ptr); + } + +if (period_elapsed) +snd_pcm_period_elapsed (substream); + } +} + +
sound/soc/intel/keembay/kmb_platform.c line 233
Quoted 10 lines
sound/soc/intel/keembay/kmb_platform.c new file +10
-0+static int kmb_set_dai_fmt (struct snd_soc_dai *cpu_dai,unsigned int fmt) +{ +struct kmb_i2s_info *kmb_i2s =snd_soc_dai_get_drvdata (cpu_dai); +int ret; + +switch (fmt &SND_SOC_DAIFMT_MASTER_MASK ) { +case SND_SOC_DAIFMT_CBM_CFM : + kmb_i2s->master = false; + ret =0 ; +break ;
Identation is off here.
Quoted 4 lines
sound/soc/intel/keembay/kmb_platform.c new file +4
-0+case SND_SOC_DAIFMT_CBS_CFS : +writel (MASTER_MODE , kmb_i2s->pss_base +I2S_GEN_CFG_0 ); + + ret =clk_prepare_enable (kmb_i2s->clk_i2s);
sound/soc/intel/keembay/kmb_platform.c line 393
Quoted 10 lines
sound/soc/intel/keembay/kmb_platform.c new file +10
-0+if (ret <0 ) +return ret; + + ret =devm_add_action_or_reset (kmb_i2s->dev, kmb_disable_clk, + kmb_i2s->clk_i2s); +if (ret) +return ret; + + kmb_i2s->master = true; +break ;
Same here.
Quoted 35 lines
sound/soc/intel/keembay/kmb_platform.h new file +34
-0+default : +return -EINVAL ; + } + +return ret; +} + + +/* +* struct i2s_clk_config_data - represent i2s clk configuration data +* @chan_nr: number of channel +* @data_width: number of bits per sample (8/16/24/32 bit) +* @sample_rate: sampling frequency (8Khz, 16Khz, 48Khz) +*/ +struct i2s_clk_config_data { +int chan_nr; +u32 data_width; +u32 sample_rate; +}; + +struct kmb_i2s_info { +void __iomem *i2s_base; +void __iomem *pss_base; +struct clk *clk_i2s; +struct clk *clk_apb; +int active; +unsigned int capability; +unsigned int i2s_reg_comp1; +unsigned int i2s_reg_comp2; +struct device *dev; +u32 ccr; +u32 xfer_resolution; +u32 fifo_th; +bool master;
sound/soc/intel/keembay/kmb_platform.h line 142
Quoted 10 lines
sound/soc/intel/keembay/kmb_platform.h new file +10
-0+ +struct i2s_clk_config_data config; +int (*i2s_clk_cfg)(struct i2s_clk_config_data *config); + +/* data related to PIO transfers */ +bool use_pio; +struct snd_pcm_substream *tx_substream; +struct snd_pcm_substream *rx_substream; +unsigned int tx_ptr; +unsigned int rx_ptr;
As you 'if' stream's direction in several pcm handlers, how about declaring simple arrays here. You could access members based on SNDRV_PCM_STREAM_PLAYBACK/ CAPTURE i.e. direction, reducing the if-ology.
struct snd_pcm_substream *substream[2]; unsigned int ptr[2];
If the number of direction-based 'ifs' cannot be reduced even with this change, drop the suggestion.
Quoted 4 lines
sound/soc/intel/keembay/kmb_platform.h new file +3
-0+}; + +#endif /* KMB_PLATFORM_H_ */
RE: [PATCH v3 1/3] ASoC: Intel: Add KeemBay platform driver
-----Original Message-----
From: Rojewski, Cezary <[email protected]>
Sent: Tuesday, June 2, 2020 5:26 AM
To: Sia, Jee Heng <[email protected]>
Cc: [email protected]; Liam Girdwood <[email protected]>; Mark Brown <[email protected]>; Takashi Iwai <[email protected]>; Pierre-Louis Bossart <[email protected]>
Subject: Re: [PATCH v3 1/3] ASoC: Intel: Add KeemBay platform driver
sound/soc/intel/keembay/kmb_platform.c line 20
Quoted 6 lines · Sia Jee Heng
sound/soc/intel/keembay/kmb_platform.c new file +6
-0+ +#define PERIODS_MIN 2 +#define PERIODS_MAX 48 +#define PERIOD_BYTES_MIN 4096 +#define BUFFER_BYTES_MAX (PERIODS_MAX * PERIOD_BYTES_MIN) +#define TDM_OPERATION 1
Looks as this is unused.
[>>] It is needed by the TDM mode and shall submit patches in the near future.
sound/soc/intel/keembay/kmb_platform.c line 24
Quoted 4 lines
sound/soc/intel/keembay/kmb_platform.c new file +4
-0+#define I2S_OPERATION 0 +#define DATA_WIDTH_CONFIG_BIT 6 +#define TDM_CHANNEL_CONFIG_BIT 3 +#define I2S_SAMPLE_RATES (SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000)
This defines common rates yet .formats are left alone? As .formats, .rate_min/ max and others are left alone I'd stick with this style and specify .rates directly too. [>>] OK, I can specify the rate directly.
sound/soc/intel/keembay/kmb_platform.c line 31
Quoted 7 lines
sound/soc/intel/keembay/kmb_platform.c new file +7
-0+ +static const struct snd_pcm_hardware kmb_pcm_hardware = { + .info =SNDRV_PCM_INFO_INTERLEAVED | +SNDRV_PCM_INFO_MMAP | +SNDRV_PCM_INFO_MMAP_VALID | +SNDRV_PCM_INFO_BATCH | +SNDRV_PCM_INFO_BLOCK_TRANSFER ,
Several flags have been or'ed here. Have these been verified working for Keembay? [>>] Yes, tested with alsa aplay/arecord before submit patches for review.
Quoted 28 lines
sound/soc/intel/keembay/kmb_platform.c new file +28
-0+ .rates = I2S_SAMPLE_RATES, + .rate_min = 16000, + .rate_max = 48000, + .formats =SNDRV_PCM_FMTBIT_S16_LE | +SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S32_LE, + .channels_min = 2, + .channels_max = 2, + .buffer_bytes_max = BUFFER_BYTES_MAX, + .period_bytes_min = PERIOD_BYTES_MIN, + .period_bytes_max = BUFFER_BYTES_MAX / PERIODS_MIN, + .periods_min = PERIODS_MIN, + .periods_max = PERIODS_MAX, + .fifo_size = 16, +}; + +static unsigned int kmb_pcm_tx_fn (struct kmb_i2s_info *kmb_i2s, +struct snd_pcm_runtime *runtime, +unsigned int tx_ptr,bool *period_elapsed) { +unsigned int period_pos = tx_ptr % runtime->period_size; +void __iomem *i2s_base = kmb_i2s->i2s_base; +u16 (*p16)[2 ]; +u32 (*p32)[2 ]; +int i; + +if (kmb_i2s->config.data_width ==16 ) + p16 = (void *)runtime->dma_area; +else
sound/soc/intel/keembay/kmb_platform.c line 70
Quoted 10 lines
sound/soc/intel/keembay/kmb_platform.c new file +10
-0+ p32 = (void *)runtime->dma_area; +/* KMB i2s uses two separate L/R FIFO */ +for (i =0 ; i < kmb_i2s->fifo_th; i++) { +if (kmb_i2s->config.data_width ==16 ) { +writel (p16[tx_ptr][0 ], i2s_base +LRBR_LTHR (0 )); +writel (p16[tx_ptr][1 ], i2s_base +RRBR_RTHR (0 )); + }else { +writel (p32[tx_ptr][0 ], i2s_base +LRBR_LTHR (0 )); +writel (p32[tx_ptr][1 ], i2s_base +RRBR_RTHR (0 )); + }
Looks like a refactor candidate. Both, the preceding 'if' and the 'for'
- which are the body of this func - are "data_width" dependent. You could redure if-ology by defining separate variants for 16 and non-16. [>>] Got it. I can refactor the code by reduce the if-ology.
Idk about naming index-variable 'rx_ptr'. This isn't a pointer, that's for sure.
[>>] I think that tx_ptr or rx_ptr can be easily map to the nature of alsa operation. Could you suggest a better naming if you have concern?
Quoted 24 lines
sound/soc/intel/keembay/kmb_platform.c new file +24
-0+ + period_pos++; + +if (++tx_ptr >= runtime->buffer_size) + tx_ptr =0 ; + } + + *period_elapsed = period_pos >= runtime->period_size; + +return tx_ptr; +} + +static unsigned int kmb_pcm_rx_fn (struct kmb_i2s_info *kmb_i2s, +struct snd_pcm_runtime *runtime, +unsigned int rx_ptr,bool *period_elapsed) { +unsigned int period_pos = rx_ptr % runtime->period_size; +void __iomem *i2s_base = kmb_i2s->i2s_base; +u16 (*p16)[2 ]; +u32 (*p32)[2 ]; +int i; + +if (kmb_i2s->config.data_width ==16 ) + p16 = (void *)runtime->dma_area; +else
sound/soc/intel/keembay/kmb_platform.c line 105
Quoted 10 lines
sound/soc/intel/keembay/kmb_platform.c new file +10
-0+ p32 = (void *)runtime->dma_area; +/* KMB i2s uses two separate L/R FIFO */ +for (i =0 ; i < kmb_i2s->fifo_th; i++) { +if (kmb_i2s->config.data_width ==16 ) { + p16[rx_ptr][0 ] =readl (i2s_base +LRBR_LTHR (0 )); + p16[rx_ptr][1 ] =readl (i2s_base +RRBR_RTHR (0 )); + }else { + p32[rx_ptr][0 ] =readl (i2s_base +LRBR_LTHR (0 )); + p32[rx_ptr][1 ] =readl (i2s_base +RRBR_RTHR (0 )); + }
The exact same advice goes here.
[>>] I can further re-factor the code by reduce the if usage
Quoted 15 lines
sound/soc/intel/keembay/kmb_platform.c new file +14
-0+ + period_pos++; + +if (++rx_ptr >= runtime->buffer_size) + rx_ptr =0 ; + } + + *period_elapsed = period_pos >= runtime->period_size; + +return rx_ptr; +} + + +static void kmb_pcm_operation(struct kmb_i2s_info *kmb_i2s, bool
sound/soc/intel/keembay/kmb_platform.c line 180
Quoted 10 lines
sound/soc/intel/keembay/kmb_platform.c new file +10
-0+playback) { +struct snd_pcm_substream *substream; +bool active, period_elapsed; + +if (playback) + substream = kmb_i2s->tx_substream; +else + substream = kmb_i2s->rx_substream; + + active = substream &&snd_pcm_running (substream);
'active' serves little to no purpose here, I'd opt for removing it. [>>] OK.
Review
Quoted 2 lines
(quoted diff) +2
-0+ + if (active) {
When deciding between no middle func 'return' or recuded indentation, the later is more readable. Simple:
if (!substream || snd_pcm_running(substream)) return;
[>>] if (!substream && !snd_pcm_running(substream))
[>>] return;
allows rest of the function to be shift-left'ed.
sound/soc/intel/keembay/kmb_platform.c line 184
Quoted 2 lines
sound/soc/intel/keembay/kmb_platform.c new file +2
-0+unsigned int ptr; +unsigned int new_ptr;
'ptr' and 'new_ptr' declared in local scope yet 'period_elapsed' found its way out of here. To make code look cohesive, either have all declared in function's var declaration block or make sure local scope contains all local variables declarations.
Of course this is obsolete if you decide to pursue shift-left suggestion. [>>] Sure, can make it local scope for variable.
Quoted 20 lines
sound/soc/intel/keembay/kmb_platform.c new file +19
-0+ +if (playback) { + ptr = kmb_i2s->tx_ptr; + new_ptr =kmb_pcm_tx_fn (kmb_i2s, substream->runtime, + ptr, &period_elapsed); +cmpxchg (&kmb_i2s->tx_ptr, ptr, new_ptr); + }else { + ptr = kmb_i2s->rx_ptr; + new_ptr =kmb_pcm_rx_fn (kmb_i2s, substream->runtime, + ptr, &period_elapsed); +cmpxchg (&kmb_i2s->rx_ptr, ptr, new_ptr); + } + +if (period_elapsed) +snd_pcm_period_elapsed (substream); + } +} + +
sound/soc/intel/keembay/kmb_platform.c line 233
Quoted 10 lines
sound/soc/intel/keembay/kmb_platform.c new file +10
-0+static int kmb_set_dai_fmt (struct snd_soc_dai *cpu_dai,unsigned int +fmt) { +struct kmb_i2s_info *kmb_i2s =snd_soc_dai_get_drvdata (cpu_dai); +int ret; + +switch (fmt &SND_SOC_DAIFMT_MASTER_MASK ) { +case SND_SOC_DAIFMT_CBM_CFM : + kmb_i2s->master = false; + ret =0 ; +break ;
Identation is off here.
[>>] OK.
Quoted 4 lines
sound/soc/intel/keembay/kmb_platform.c new file +4
-0+case SND_SOC_DAIFMT_CBS_CFS : +writel (MASTER_MODE , kmb_i2s->pss_base +I2S_GEN_CFG_0 ); + + ret =clk_prepare_enable (kmb_i2s->clk_i2s);
sound/soc/intel/keembay/kmb_platform.c line 393
Quoted 10 lines
sound/soc/intel/keembay/kmb_platform.c new file +10
-0+if (ret <0 ) +return ret; + + ret =devm_add_action_or_reset (kmb_i2s->dev, kmb_disable_clk, + kmb_i2s->clk_i2s); +if (ret) +return ret; + + kmb_i2s->master = true; +break ;
Same here.
[>>] OK.
Quoted 34 lines
sound/soc/intel/keembay/kmb_platform.h new file +33
-0+default : +return -EINVAL ; + } + +return ret; +} + + +/* +* struct i2s_clk_config_data - represent i2s clk configuration data +* @chan_nr: number of channel +* @data_width: number of bits per sample (8/16/24/32 bit) +* @sample_rate: sampling frequency (8Khz, 16Khz, 48Khz) */ struct +i2s_clk_config_data { +int chan_nr; +u32 data_width; +u32 sample_rate; +}; + +struct kmb_i2s_info { +void __iomem *i2s_base; +void __iomem *pss_base; +struct clk *clk_i2s; +struct clk *clk_apb; +int active; +unsigned int capability; +unsigned int i2s_reg_comp1; +unsigned int i2s_reg_comp2; +struct device *dev; +u32 ccr; +u32 xfer_resolution; +u32 fifo_th; +bool master;
sound/soc/intel/keembay/kmb_platform.h line 142
Quoted 10 lines
sound/soc/intel/keembay/kmb_platform.h new file +10
-0+ +struct i2s_clk_config_data config; +int (*i2s_clk_cfg)(struct i2s_clk_config_data *config); + +/* data related to PIO transfers */ +bool use_pio; +struct snd_pcm_substream *tx_substream; +struct snd_pcm_substream *rx_substream; +unsigned int tx_ptr; +unsigned int rx_ptr;
As you 'if' stream's direction in several pcm handlers, how about declaring simple arrays here. You could access members based on SNDRV_PCM_STREAM_PLAYBACK/ CAPTURE i.e. direction, reducing the if-ology.
struct snd_pcm_substream *substream[2]; unsigned int ptr[2];
If the number of direction-based 'ifs' cannot be reduced even with this change, drop the suggestion. [>>] Thanks but it doesn't reduce the if usage.
Quoted 4 lines
sound/soc/intel/keembay/kmb_platform.h new file +3
-0+}; + +#endif /* KMB_PLATFORM_H_ */
PATCH v3 2/3 ASoC: Intel: Add makefiles and kconfig changes for KeemBay
In reply to Sia Jee HengAdd makefile and kconfig changes for Intel KeemBay platform driver.
--- sound/soc/intel/Kconfig | 7 +++++++ sound/soc/intel/Makefile | 1 + 2 files changed, 8 insertions(+)
sound/soc/intel/Kconfig +7 -0
@@ -244,6 +244,13 @@ config SND_SOC_ACPI_INTEL_MATCH endif ## SND_SOC_INTEL_SST_TOPLEVEL || SND_SOC_SOF_INTEL_TOPLEVEL +config SND_SOC_INTEL_KEEMBAY + tristate "Keembay Platforms" + depends on OF && (ARM64 || COMPILE_TEST) + depends on COMMON_CLK + help + If you have a Intel Keembay platform then enable this option + by saying Y or m. # ASoC codec drivers source "sound/soc/intel/boards/Kconfig"
sound/soc/intel/Makefile +1 -0
@@ -7,6 +7,7 @@ obj-$(CONFIG_SND_SOC_INTEL_HASWELL) += haswell/ obj-$(CONFIG_SND_SOC_INTEL_BAYTRAIL) += baytrail/ obj-$(CONFIG_SND_SST_ATOM_HIFI2_PLATFORM) += atom/ obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += skylake/ +obj-$(CONFIG_SND_SOC_INTEL_KEEMBAY) += keembay/ # Machine support obj-$(CONFIG_SND_SOC) += boards/
Signature · 1 line
1.9.1
PATCH v3 3/3 dt-bindings: sound: Add documentation for KeemBay i2s
In reply to Sia Jee HengDocument Intel KeemBay i2s DT bindings.
--- .../bindings/sound/intel,keembay-i2s.yaml | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/intel,keembay-i2s.yaml
Documentation/devicetree/bindings/sound/intel,keembay-i2s.yaml new file +68 -0
@@ -0,0 +1,68 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright 2020 Intel Corporation +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/intel,keembay-i2s.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Intel KeemBay I2S Device Tree Bindings + +maintainers: + - Sia, Jee Heng <[email protected]> + +description: | + Intel KeemBay I2S + +properties: + compatible: + enum: + - intel,keembay-i2s + + "#sound-dai-cells": + const: 0 + + reg: + items: + - description: I2S configuration + + reg-names: + items: + - const: i2s-regs + - const: i2s_gen_cfg + + interrupts: + maxItems: 1 + + clocks: + items: + - description: Bus Clock + - description: Module Clock + + clock-names: + items: + - const: osc + - const: apb_clk + +required: + - compatible + - "#sound-dai-cells" + - reg + - clocks + - clock-names + - interrupts + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + #define KEEM_BAY_PSS_AUX_I2S3 + #define KEEM_BAY_PSS_I2S3 + i2s3: i2s@20140000 { + compatible = "intel,keembay-i2s"; + #sound-dai-cells = <0>; + reg = <0x20140000 0x200 0x202a00a4 0x4>; + reg-names = "i2s-regs", "i2s_gen_cfg"; + interrupts = <GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>; + clock-names = "osc", "apb_clk"; + clocks = <&scmi_clk KEEM_BAY_PSS_AUX_I2S3>, <&scmi_clk KEEM_BAY_PSS_I2S3>; + };
Signature · 1 line
1.9.1
Cezary Rojewski
maintainerQuoted 20 lines · Sia Jee Heng
The below series of patches support the KeemBay ASoC platform driver. The platform driver initialize the i2s to capture and playback the pcm data on the ARM. The i2s is running in polling mode.
There is no DSP in the KeemBay SoC. Users are rely on the Gstreamer plugin to perform Audio preprocessing.
Audio graph card is used to connect the platform driver with the tlv320aic3204 codec.
Change History:
v3:
- Adjusted header format.
- Use Audio graph card instead of custom sound card.
- Use if-else instead of conditional operator.
- Enabled .set_fmt to configure master clock.v2:
- Corrected I2S naming for DT binding.
Quoted 8 lines
v1:
- Initial version.Sia Jee Heng (3):
ASoC: Intel: Add KeemBay platform driver
ASoC: Intel: Add makefiles and kconfig changes for KeemBay
dt-bindings: sound: Add documentation for KeemBay i2s
As these series has been given plenty of comments internally from Andy, Pierre and me, I'd be best to have all reviewers CC'ed here.
Czarek
-----Original Message-----
From: Rojewski, Cezary <[email protected]>
Sent: Tuesday, June 2, 2020 5:31 AM
To: Sia, Jee Heng <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Shevchenko, Andriy <[email protected]>
Subject: Re: [PATCH v3 0/3] ASoC: Intel: Add KeemBay ASoC platform driver
Quoted 20 lines · Sia Jee Heng
The below series of patches support the KeemBay ASoC platform driver. The platform driver initialize the i2s to capture and playback the pcm data on the ARM. The i2s is running in polling mode.
There is no DSP in the KeemBay SoC. Users are rely on the Gstreamer plugin to perform Audio preprocessing.
Audio graph card is used to connect the platform driver with the tlv320aic3204 codec.
Change History:
v3:
- Adjusted header format.
- Use Audio graph card instead of custom sound card.
- Use if-else instead of conditional operator.
- Enabled .set_fmt to configure master clock.v2:
- Corrected I2S naming for DT binding.
Quoted 8 lines
v1:
- Initial version.Sia Jee Heng (3):
ASoC: Intel: Add KeemBay platform driver
ASoC: Intel: Add makefiles and kconfig changes for KeemBay
dt-bindings: sound: Add documentation for KeemBay i2s
As these series has been given plenty of comments internally from Andy, Pierre and me, I'd be best to have all reviewers CC'ed here. [>>] Noted.
Czarek
Mark Brown
maintainerQuoted 8 lines · Sia Jee Heng
The below series of patches support the KeemBay ASoC platform driver. The platform driver initialize the i2s to capture and playback the pcm data on the ARM. The i2s is running in polling mode.
There is no DSP in the KeemBay SoC. Users are rely on the Gstreamer plugin to perform Audio preprocessing.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/3] ASoC: Intel: Add KeemBay platform driver
commit: c5477e966728f8e9d1434543d4ee677d515e1078
[2/3] ASoC: Intel: Add makefiles and kconfig changes for KeemBay
commit: c544912bcc2dc806ba71d9157ccefca4a4a885f0
[3/3] ASoC: Add documentation for KeemBay i2s
commit: e16caedf737145f74e34e45205b15695adf66f38All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark