Skip to contentSkip to conversation

ASoC: hda - ASoC DSP widget event handlers

RFC In review Vinod Koul 3 participants 22 messages Apr 18, 2015 – Apr 30, 2015

Subsystems (2)
lore
Share & tools
lore

Vinod Koul

author
#0 lore raw

cover ASoC: hda - ASoC DSP widget event handlers

The aDSP is triggered by DAPM. The DAPM code is atm dependent upon the DFW aka tplg RFC send by Liam. We will post missing tplg to driver links once that series is accepted

This series is dependent upon
a) Takashi topic/hda which has core hdac splitup
b) SKL PCM driver series, which adds the SKL HDA Platform driver
c) SKL IPC series which sends IPCs to aDSP

This last series adds the missing link between b) and c).

Comments most welcome

Signature · 29 lines
~Vinod

Jeeja KP (7):
  ASoC: hda: Add skl dsp init and registering with SST IPC lib
  ASoC: hda: add hepler to configure module params
  ASoC: hda: add FW module init/bind IPC
  ASoC: hda: add FW pipe create/delete/set_pipe_state IPC
  ASOC: hda: add DSP platfrom controls widget event handlers
  ASoC: hda: Add support for SSP register settings
  ASoC: hda: Apply dai params_fixup for DSP widgets

 include/sound/soc-hda-sst-dsp.h    |    3 +
 sound/soc/hda/Kconfig              |    1 +
 sound/soc/hda/Makefile             |    3 +-
 sound/soc/hda/hda_dsp_controls.c   |  913 ++++++++++++++++++++++++++++++++++++
 sound/soc/hda/hda_dsp_controls.h   |  338 +++++++++++++
 sound/soc/hda/hda_dsp_ssp_config.c |  290 ++++++++++++
 sound/soc/hda/hda_dsp_ssp_config.h |  423 +++++++++++++++++
 sound/soc/hda/hda_skl.h            |  108 ++++-
 sound/soc/hda/hda_soc_dsp.c        |  702 +++++++++++++++++++++++++++
 9 files changed, 2767 insertions(+), 14 deletions(-)
 create mode 100644 sound/soc/hda/hda_dsp_controls.c
 create mode 100644 sound/soc/hda/hda_dsp_controls.h
 create mode 100644 sound/soc/hda/hda_dsp_ssp_config.c
 create mode 100644 sound/soc/hda/hda_dsp_ssp_config.h
 create mode 100644 sound/soc/hda/hda_soc_dsp.c

-- 
1.7.9.5
author
#1 lore raw

RFC 1/7 ASoC: hda: Add skl dsp init and registering with SST IPC lib

From: Jeeja KP <[email protected]>

This will be used by the controller to register/unregister with the SST IPC lib if processing pipe caps is supported

---
 include/sound/soc-hda-sst-dsp.h |    3 ++
 sound/soc/hda/Kconfig           |    1 +
 sound/soc/hda/Makefile          |    2 +-
 sound/soc/hda/hda_skl.h         |   16 ++--------
 sound/soc/hda/hda_soc_dsp.c     |   62 +++++++++++++++++++++++++++++++++++++++
 5 files changed, 70 insertions(+), 14 deletions(-)
 create mode 100644 sound/soc/hda/hda_soc_dsp.c
include/sound/soc-hda-sst-dsp.h +3 -0
index 9adeb49cf126..a85f95be13c1 100644
@@ -263,4 +263,7 @@ int ssth_cl_dma_prepare(struct ssth_lib *ctx);
 void ssth_process_cl_dma(struct work_struct *work);
 void ssth_cldma_int_disable(struct ssth_lib *ctx);
 
+int ssth_skl_init(struct device *dev, void __iomem *mmio_base, int irq,
+		struct ssth_dsp_loader_ops dsp_ops, struct ssth_lib **dsp);
+void ssth_skl_cleanup(struct device *dev, struct ssth_lib *ctx);
 #endif /*__HDA_SST_DSP_H__*/
sound/soc/hda/Kconfig +1 -0
index 841ea5276fe3..445fa9842127 100644
@@ -29,6 +29,7 @@ config SND_SOC_HDA_SKL
 
 config SND_SOC_I2S_SKL_MACH
         tristate "SOC Machine Audio driver for SKL Onboard I2S"
+	 select SND_HDA_DSP_LOADER
         select SND_SOC_HDA_SKL
         select SND_SOC_RT286
         select SND_SOC_HDMI
sound/soc/hda/Makefile +1 -1
index d318d4acb8a7..2be667dc0724 100644
@@ -1,4 +1,4 @@
-snd-soc-hda-skl-objs := hda_skl.o hda_skl_pcm.o
+snd-soc-hda-skl-objs := hda_skl.o hda_skl_pcm.o hda_soc_dsp.o
 
 obj-$(CONFIG_SND_SOC_HDA_SKL) += snd-soc-hda-skl.o
 
sound/soc/hda/hda_skl.h +3 -13
index 0cc2ac69a9ab..914ea05da6aa 100644
@@ -1,15 +1,3 @@
-/*
- *  This program is free software; you can redistribute it and/or modify it
- *  under the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *
- *  This program is distributed in the hope that it will be useful, but WITHOUT
- *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- *  more details.
- */
-
 #ifndef __SOUND_SOC_HDA_SKL_H
 #define __SOUND_SOC_HDA_SKL_H
 
@@ -22,13 +10,15 @@
 
 struct hda_soc_bus {
 	struct hdac_bus chip;
+	struct device *dev;
 	struct pci_dev *pci;
 
 	unsigned int init_failed:1; /* delayed init failed */
 	unsigned int msi:1;
+	struct ssth_lib *dsp; /* ssth lib ctx */
 };
 
-/* to pass dai dma data */
+/*to pass dai dma data */
 struct soc_hda_dma_params {
 	u32 format;
 	u8 stream_tag;
sound/soc/hda/hda_soc_dsp.c new file +62 -0

62 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer
#2 lore raw

Re: [RFC 1/7] ASoC: hda: Add skl dsp init and registering with SST IPC lib

sound/soc/hda/Kconfig config SND_SOC_HDA_SKL · line 32

Quoted 3 lines · Vinod Koul

config SND_SOC_I2S_SKL_MACH
tristate "SOC Machine Audio driver for SKL Onboard I2S"

sound/soc/hda/Kconfig +1 -0
+	 select SND_HDA_DSP_LOADER

Looking at what this is modifying it really looks like there's some other patch series I wanted to look at first?

Quoted 7 lines
sound/soc/hda/hda_skl.h +0 -2
index 0cc2ac69a9ab..914ea05da6aa 100644
@@ -1,15 +1,3 @@
-/*
- *  This program is free software; you can redistribute it and/or modify it

sound/soc/hda/hda_skl.h line 12

Quoted 10 lines
sound/soc/hda/hda_skl.h +0 -10
- *  under the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *
- *  This program is distributed in the hope that it will be useful, but WITHOUT
- *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- *  more details.
- */
-

Oh?

author
#3 lore raw

Re: [RFC 1/7] ASoC: hda: Add skl dsp init and registering with SST IPC lib

Quoted 8 lines · Mark Brown

sound/soc/hda/Kconfig config SND_SOC_HDA_SKL · line 32

Quoted 3 lines · Vinod Koul

config SND_SOC_I2S_SKL_MACH
tristate "SOC Machine Audio driver for SKL Onboard I2S"

sound/soc/hda/Kconfig +1 -0
+	 select SND_HDA_DSP_LOADER

Looking at what this is modifying it really looks like there's some other patch series I wanted to look at first?

Yes that was the SKL PCM driver series. I will repost that in this week along with few more changes, so you can look at updated series.

Quoted 12 lines
Quoted 12 lines
sound/soc/hda/hda_skl.h +0 -6
index 0cc2ac69a9ab..914ea05da6aa 100644
@@ -1,15 +1,3 @@
-/*
- *  This program is free software; you can redistribute it and/or modify it
- *  under the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *
Quoted 8 lines

sound/soc/hda/hda_skl.h line 12

Quoted 6 lines
sound/soc/hda/hda_skl.h +0 -6
- *  This program is distributed in the hope that it will be useful, but WITHOUT
- *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- *  more details.
- */
-

Oh?

Terrible :(

Will try to see these dont creep in patches

Thanks

Signature · 1 line
~Vinod
author
#4 lore raw

RFC 2/7 ASoC: hda: add helper to configure module params

In reply to Vinod Koul

From: Jeeja KP <[email protected]>

This add helper functions to create module
parameter for module IPC msg

---
 sound/soc/hda/hda_dsp_controls.h |  338 ++++++++++++++++++++++++++++++++
 sound/soc/hda/hda_soc_dsp.c      |  395 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 733 insertions(+)
 create mode 100644 sound/soc/hda/hda_dsp_controls.h
sound/soc/hda/hda_dsp_controls.h new file +338 -0
new file mode 100644
index 000000000000..6bd83db94009
@@ -0,0 +1,338 @@
+/*
+ *  soc-hda-controls.h - Intel HDA Platform controls header file
+ *
+ *  Copyright (C) 2014-15 Intel Corp
+ *  Author: Jeeja KP <[email protected]>
+ *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  General Public License for more details.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ */
+
+#ifndef __SOC_HDA_DSP_CONTROLS_H__
+#define __SOC_HDA_DSP_CONTROLS_H__
+
+#include <linux/types.h>
+
+#define BITS_PER_BYTE 8
+
+/* Maximum number of coefficients up down mixer module */
+#define UP_DOWN_MIXER_MAX_COEFF		6
+
+enum ssth_channel_index {
+	SSTH_CHANNEL_LEFT = 0,
+	SSTH_CHANNEL_CENTER = 1,
+	SSTH_CHANNEL_RIGHT = 2,
+	SSTH_CHANNEL_LEFT_SURROUND = 3,
+	SSTH_CHANNEL_CENTER_SURROUND = 3,
+	SSTH_CHANNEL_RIGHT_SURROUND = 4,
+	SSTH_CHANNEL_LFE = 7,
+	SSTH_CHANNEL_INVALID = 0xF,
+};
+
+enum ssth_channel_config {
+	SSTH_CHANNEL_CONFIG_MONO = 0, /* One channel only. */
+	SSTH_CHANNEL_CONFIG_STEREO = 1, /* L & R. */
+	SSTH_CHANNEL_CONFIG_2_1 = 2, /* L, R & LFE; PCM only. */
+	SSTH_CHANNEL_CONFIG_3_0 = 3, /* L, C & R; MP3 & AAC only. */
+	SSTH_CHANNEL_CONFIG_3_1 = 4, /* L, C, R & LFE; PCM only. */
+	SSTH_CHANNEL_CONFIG_QUATRO = 5, /* L, R, Ls & Rs; PCM only. */
+	SSTH_CHANNEL_CONFIG_4_0 = 6, /* L, C, R & Cs; MP3 & AAC only. */
+	SSTH_CHANNEL_CONFIG_5_0 = 7, /* L, C, R, Ls & Rs. */
+	SSTH_CHANNEL_CONFIG_5_1 = 8, /* L, C, R, Ls, Rs & LFE. */
+	SSTH_CHANNEL_CONFIG_DUAL_MONO = 9, /* One channel replicated in two. */
+	SSTH_CHANNEL_CONFIG_I2S_DUAL_STEREO_0 = 10, /* Stereo(L,R) in 4 slots,
+						    1st stream:[ L, R, -, - ]
+						    */
+	SSTH_CHANNEL_CONFIG_I2S_DUAL_STEREO_1 = 11, /* Stereo(L,R) in 4 slots,
+						    2nd stream:[ -, -, L, R ]
+						    */
+	SSTH_CHANNEL_CONFIG_INVALID
+};
+
+enum ssth_bitdepth {
+	SSTH_DEPTH_8BIT = 8,
+	SSTH_DEPTH_16BIT = 16,
+	SSTH_DEPTH_24BIT = 24, /**< Default. */
+	SSTH_DEPTH_32BIT = 32,
+	SSTH_DEPTH_INVALID
+};
+
+enum ssth_interleaving_style {
+	SSTH_INTERLEAVING_PER_CHANNEL = 0, /* [s1_ch1...s1_chN,...,sM_ch1...sM_chN] */
+	SSTH_INTERLEAVING_PER_SAMPLE = 1, /* [s1_ch1...sM_ch1,...,s1_chN...sM_chN] */
+};
+
+enum ssth_sampling_frequency {
+	SSTH_FS_8000HZ = 8000,
+	SSTH_FS_11025HZ = 11025,
+	SSTH_FS_12000HZ = 12000, /** Mp3, AAC, SRC only. */
+	SSTH_FS_16000HZ = 16000,
+	SSTH_FS_22050HZ = 22050,
+	SSTH_FS_24000HZ = 24000, /** Mp3, AAC, SRC only. */
+	SSTH_FS_32000HZ = 32000,
+	SSTH_FS_44100HZ = 44100,
+	SSTH_FS_48000HZ = 48000, /**< Default. */
+	SSTH_FS_64000HZ = 64000, /** AAC, SRC only. */
+	SSTH_FS_88200HZ = 88200, /** AAC, SRC only. */
+	SSTH_FS_96000HZ = 96000, /** AAC, SRC only. */
+	SSTH_FS_128000HZ = 128000, /** SRC only. */
+	SSTH_FS_176400HZ = 176400, /** SRC only. */
+	SSTH_FS_192000HZ = 192000, /** SRC only. */
+	SSTH_FS_INVALID
+};
+
+enum ssth_widget_type {
+	SSTH_WIDGET_VMIXER = 1,
+	SSTH_WIDGET_MIXER = 2,
+	SSTH_WIDGET_PGA = 3,
+	SSTH_WIDGET_MUX = 4
+};
+
+struct ssth_audio_data_format {
+	enum ssth_sampling_frequency sampling_frequency;
+	enum ssth_bitdepth bit_depth;
+	u32 channel_map;
+	enum ssth_channel_config channel_config;
+	enum ssth_interleaving_style interleaving_style;
+	u8 number_of_channels;
+	u8 valid_bit_depth;
+	u8 sample_type;
+	u8 reserved[1];
+} __packed;
+
+struct ssth_base_module_config {
+	u32 cps;
+	u32 ibs;
+	u32 obs;
+	u32 is_pages;
+	struct ssth_audio_data_format audio_fmt;
+};
+
+struct ssth_copiergateway_cfg {
+	u32 node_id;
+	u32 dma_buffer_size;
+	u32 config_length;
+	u32 config_data[1]; /*not mandatory; required only for DMIC/I2S */
+} __packed;
+
+struct ssth_copier_module_config {
+	struct ssth_base_module_config base_module_config;
+	struct ssth_audio_data_format out_fmt;
+	u32 cpr_feature_mask;
+	struct ssth_copiergateway_cfg gtw_cfg;
+} __packed;
+
+struct ssth_src_config {
+	enum ssth_sampling_frequency s_freq;
+} __packed;
+
+struct ssth_src_module_config {
+	struct ssth_base_module_config base_module_config;
+	struct ssth_src_config src_config;
+} __packed;
+
+struct ssth_up_down_mixer_module_config {
+	struct ssth_base_module_config base_module_config;
+	enum ssth_channel_config out_channel_config;
+	/* This should be set to 1 if user coefficients are required */
+	u32 coeff_sel;
+	/* Pass the user coeff in this array */
+	s32 coeff[UP_DOWN_MIXER_MAX_COEFF];
+} __packed;
+
+enum ssth_dma_type {
+	SSTH_DMA_TYPE_HDA_HOST_OUTPUT_CLASS = 0,
+	SSTH_DMA_TYPE_HDA_HOST_INPUT_CLASS = 1,
+	SSTH_DMA_TYPE_HDA_HOST_INOUT_CLASS = 2,
+	SSTH_DMA_TYPE_HDA_LINK_OUTPUT_CLASS = 8,
+	SSTH_DMA_TYPE_HDA_LINK_INPUT_CLASS = 9,
+	SSTH_DMA_TYPE_HDA_LINK_INOUT_CLASS = 0xA,
+	SSTH_DMA_TYPE_DMIC_LINK_INPUT_CLASS = 0xB,
+	SSTH_DMA_TYPE_I2S_LINK_OUTPUT_CLASS = 0xC,
+	SSTH_DMA_TYPE_I2S_LINK_INPUT_CLASS = 0xD,
+};
+
+union ssth_ssp_dma_node {
+	u8 val;
+	struct {
+		u8 dual_mono:1;
+		u8 time_slot:3;
+		u8 i2s_instance:4;
+	} dma_node;
+};
+
+union ssth_connector_node_id {
+	u32 val;
+	struct {
+		u32 dma_id:8; /* DMA engine ID */
+		u32 dma_type:4;
+		u32 rsvd:20;
+	} node;
+};
+
+enum ssth_fw_pipeline_type {
+	SSTH_PIPELINE_TYPE_DECODE = 0,
+	SSTH_PIPELINE_TYPE_MIXER = 1,
+	SSTH_PIPELINE_TYPE_REFERENCE = 2,
+	SSTH_PIPELINE_TYPE_CAPTURE = 3
+};
+
+enum ssth_core_affinity {
+	SSTH_AFFINITY_CORE_0 = 0,
+	SSTH_AFFINITY_CORE_1,
+	SSTH_AFFINITY_CORE_MAX
+};
+
+struct ssth_module_format {
+	u32 channels;
+	u32 sampling_freq;
+	u32 bit_depth;
+	u32 valid_bit_depth;
+	u32 channel_config;
+};
+
+struct ssth_module_instance_id {
+	u32 module_id;
+	u32 instance_id;
+};
+
+struct ssth_specific_config {
+	u32 caps_size;
+	u32 *caps;
+};
+
+enum ssth_pipe_state {
+	SSTH_PIPE_STATE_INVALID = 0,
+	SSTH_PIPE_STATE_CREATED = 1,
+	SSTH_PIPE_STATE_PAUSED = 2,
+	SSTH_PIPE_STATE_STARTED = 3
+};
+
+struct ssth_pipe_module {
+	struct snd_soc_dapm_widget *w;
+	struct list_head node;
+};
+
+struct ssth_pipe {
+	u8 ppl_id;
+	u8 pipe_priority;
+	u16 conn_type;
+	u32 memory_pages;
+	enum ssth_pipe_state state;
+	struct list_head w_list;
+};
+
+enum ssth_module_state {
+	SSTH_MODULE_STATE_UNINIT = 0,
+	SSTH_MODULE_STATE_INIT_DONE = 1,
+	SSTH_MODULE_STATE_LOADED = 2,
+	SSTH_MODULE_STATE_UNLOADED = 3,
+	SSTH_MODULE_STATE_BIND_DONE = 4
+};
+
+enum ssth_module_type {
+	SSTH_BASE_FW_MODULE = 0,
+	SSTH_BASE_MIX_IN_MODULE,
+	SSTH_BASE_MIX_OUT_MODULE,
+	SSTH_COPIER_MODULE,
+	SSTH_UPDWMIX_MODULE,
+	SSTH_SRCINT_MODULE,
+	SSTH_MAX_MODULE
+};
+
+enum ssth_dev_type {
+	SSTH_DEVICE_BT = 0x0,
+	SSTH_DEVICE_DMIC = 0x1,
+	SSTH_DEVICE_I2S = 0x2,
+	SSTH_DEVICE_SLIMBUS = 0x3,
+	SSTH_DEVICE_HDALINK = 0x4,
+	SSTH_DEVICE_NONE
+};
+
+enum ssth_pipe_conn_type {
+	SSTH_PIPE_CONN_TYPE_NONE = 0,
+	SSTH_PIPE_CONN_TYPE_FE,
+	SSTH_PIPE_CONN_TYPE_BE
+};
+
+enum ssth_module_conn_type {
+	SSTH_CONN_NONE = 0,
+	SSTH_CONN_SOURCE = 1,
+	SSTH_CONN_SINK = 2
+};
+
+struct ssth_sink_module {
+	struct list_head node;
+	struct ssth_module_instance_id id;
+	u8 in_queue;
+};
+
+struct ssth_module_config {
+	struct ssth_module_instance_id id;
+	struct ssth_module_format in_fmt;
+	struct ssth_module_format out_fmt;
+	u8 max_in_queue;
+	u8 max_out_queue;
+	u8 in_queue_mask;
+	u8 out_queue_mask;
+	u8 in_queue;
+	u8 out_queue;
+	u32 mcps;
+	u32 ibs;
+	u32 obs;
+	u8 is_loadable;
+	u8 core_id;
+	u8 conn_type;
+	u8 dev_type;
+	u8 dma_id;
+	u8 time_slot;
+	u32 params_fixup;
+	u32 converter;
+	struct list_head sink_list;
+	enum ssth_module_conn_type  hw_conn_type;
+	enum ssth_module_state m_state;
+	struct ssth_pipe *pipe;
+	struct ssth_specific_config formats_config;
+};
+
+/* Event types goes here */
+/* Reserve event type 0 for no event handlers */
+enum ssth_event_types {
+	HDA_SST_EVENT_TYPE_NONE = 0,
+	HDA_SST_SET_MIXER,
+	HDA_SST_SET_MUX,
+	HDA_SST_SET_VMIXER,
+	HDA_SST_SET_PGA
+};
+
+struct hda_sst_algo_data {
+	u32 max;
+	char *params;
+};
+
+struct ssth_pipeline {
+	struct ssth_pipe *pipe;
+	struct list_head node;
+};
+
+int ssth_create_pipeline(struct ssth_lib *ctx, struct ssth_pipe *pipe);
+int ssth_run_pipe(struct ssth_lib *ctx, struct ssth_pipe *pipe);
+int ssth_pause_pipe(struct ssth_lib *ctx, struct ssth_pipe *pipe);
+int ssth_delete_pipe(struct ssth_lib *ctx, struct ssth_pipe *pipe);
+int ssth_stop_pipe(struct ssth_lib *ctx, struct ssth_pipe *pipe);
+int ssth_init_module(struct ssth_lib *ctx, struct ssth_module_config *module_config,
+	struct hda_sst_algo_data *ac);
+int ssth_bind_unbind_modules(struct ssth_lib *ctx, struct ssth_module_config
+	*src_module, struct ssth_module_config *dst_module, bool bind);
+enum ssth_bitdepth ssth_get_bit_depth(struct snd_pcm_hw_params *params);
+#endif
sound/soc/hda/hda_soc_dsp.c +395 -0

404 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer
#5 lore raw

Re: [RFC 2/7] ASoC: hda: add helper to configure module params

Quoted 4 lines · Vinod Koul

From: Jeeja KP <[email protected]>

This add helper functions to create module
parameter for module IPC msg

This feels like it's abstracting between two different driver internal formats but it's not entirely clear to me. I'm lacking some big picture stuff here.

author
#6 lore raw

Re: [RFC 2/7] ASoC: hda: add helper to configure module params

Quoted 9 lines · Mark Brown
Quoted 4 lines · Vinod Koul

From: Jeeja KP <[email protected]>

This add helper functions to create module
parameter for module IPC msg

This feels like it's abstracting between two different driver internal formats but it's not entirely clear to me. I'm lacking some big picture stuff here.

Okay, let me try :)

So before this we had posted SKL base PCM driver which was doing HDA stuff only. Earlier this week you reviewed the SST-IPC driver series, that was sending IPCs to DSP.
The other series you reviewed with this invokes those IPCs from SKL platform driver. This series is about DAPM widget handlers and driver changes for handling DSP.

The SKL supports HDA + DSP and HDA/I2S codecs.

We have one more series which will be missing link. Since we use the topology/DFW for defining the widgets and map, they are not coded in driver. That will be sent once topology patches are accepted

Thanks for reviewing the RFCs, I will rework the series and post them in sequence which would be:
- SKL PCM driver first
- ASoC bus handling wrapper code
- IPC driver
- SKL dapm widget handling and aDSP support
- lastly support for topology to load the DAIs/widgets/map

One more would be ASoC HDA codecs but that can merged independent of these

The core HDA changes are mostly done so that dependency is no longer issue. Though that code is targeted for next merge window, I think we need to merge topic/hda from Takashi's tree to yours as well or whatever way you both feel comfortable..

Do let me know if you have more questions, yes that is a lot of code coming you way

Thanks

Signature · 1 line
~Vinod
author
#7 lore raw

RFC 3/7 ASoC: hda: add FW module init/bind IPC

In reply to Vinod Koul

From: Jeeja KP <[email protected]>

This helper function creates module init and bind IPC message based on module parameter and calls IPC interface to send the IPC to FW.

---
 sound/soc/hda/hda_soc_dsp.c |  133 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 133 insertions(+)
sound/soc/hda/hda_soc_dsp.c +133 -0
index fea47645368e..5a9927b82852 100644
@@ -455,3 +455,136 @@ static int ssth_free_queue(u8 *queue_mask, u8 queue_index)
 	else
 		return queue_index;
 }
+
+int ssth_init_module(struct ssth_lib *ctx,
+			struct ssth_module_config *mconfig,
+			struct hda_sst_algo_data *ac)
+{
+	u16 module_config_size = 0;
+	void *param_data = NULL;
+	int ret = 0;
+	struct ssth_init_instance_msg msg;
+	struct ssth_dxstate_info dx;
+
+	dev_dbg(ctx->dev, "%s: module_id = %d instance=%d\n", __func__,
+		 mconfig->id.module_id, mconfig->id.instance_id);
+
+	ret = ssth_set_module_format(ctx, mconfig,
+			&module_config_size, &param_data);
+	if (ret < 0) {
+		dev_err(ctx->dev, "Failed to set module format ret=%d\n", ret);
+		goto exit;
+	}
+
+	if (mconfig->core_id != SSTH_AFFINITY_CORE_0) {
+		dx.core_mask = mconfig->core_id;
+		dx.dx_mask = mconfig->core_id;
+		/*SET core to D0 */
+		ret = ssth_ipc_set_dx(ctx->ipc, 0, 0, &dx);
+		if (ret < 0)
+			return ret;
+
+	}
+	msg.module_id = mconfig->id.module_id;
+	msg.instance_id = mconfig->id.instance_id;
+	msg.ppl_instance_id = mconfig->pipe->ppl_id;
+	msg.param_data_size = module_config_size;
+	msg.core_id = mconfig->core_id;
+
+	if (mconfig->pipe->state != SSTH_PIPE_STATE_CREATED) {
+		dev_err(ctx->dev, "Pipe not created for Module state= %d pipe_id= %d\n",
+				 mconfig->pipe->state, mconfig->pipe->ppl_id);
+		return -EIO;
+	}
+
+	ret = ssth_ipc_init_instance(ctx->ipc, &msg, param_data);
+	if (ret < 0) {
+		dev_err(ctx->dev, "Failed to init instance ret=%d\n", ret);
+		goto exit;
+	}
+	mconfig->m_state = SSTH_MODULE_STATE_INIT_DONE;
+
+exit:
+	if (param_data != NULL)
+		kfree(param_data);
+
+	return ret;
+}
+
+int ssth_bind_unbind_modules(struct ssth_lib *ctx, struct ssth_module_config
+	*src_module, struct ssth_module_config *dst_module, bool bind)
+{
+	int ret = 0;
+	struct ssth_bind_unbind_msg msg;
+	struct ssth_sink_module *sink_module, *__sink_module;
+
+	dev_dbg(ctx->dev, "%s: src module_id = %d  src_instance=%d dst_module=%d \
+		dst_instacne=%d\n", __func__, src_module->id.module_id,
+		src_module->id.instance_id, dst_module->id.module_id,
+		dst_module->id.instance_id);
+
+	dev_dbg(ctx->dev, "src_module state = %d dst module state = %d\n",
+		src_module->m_state, dst_module->m_state);
+	/*if module is not bind, then don't send unbind */
+	if (!bind) {
+		if (src_module->m_state != SSTH_MODULE_STATE_BIND_DONE)
+			return ret;
+		/* if intra module unbind, check if both modules are BIND,
+		then send unbind
+		*/
+		if ((src_module->pipe->ppl_id != dst_module->pipe->ppl_id) &&
+			dst_module->m_state != SSTH_MODULE_STATE_BIND_DONE)
+			return ret;
+	} else if (src_module->m_state != SSTH_MODULE_STATE_INIT_DONE &&
+			 dst_module->m_state != SSTH_MODULE_STATE_INIT_DONE)
+		return ret;
+
+	msg.module_id = src_module->id.module_id;
+	msg.instance_id = src_module->id.instance_id;
+	msg.dst_module_id = dst_module->id.module_id;
+	msg.dst_instance_id = dst_module->id.instance_id;
+	if (bind) {
+		src_module->out_queue = ssth_alloc_queue(&src_module->out_queue_mask,
+				 src_module->max_out_queue, src_module->out_queue);
+		dst_module->in_queue = ssth_alloc_queue(&dst_module->in_queue_mask,
+				 dst_module->max_in_queue, dst_module->in_queue);
+		sink_module = devm_kzalloc(ctx->dev, sizeof(struct ssth_sink_module), GFP_KERNEL);
+		if (!sink_module) {
+			dev_err(ctx->dev, "Unable to allocate mem\n");
+			return -ENOMEM;
+		}
+		sink_module->id.instance_id = dst_module->id.instance_id;
+		sink_module->id.module_id = dst_module->id.module_id;
+		sink_module->in_queue = dst_module->in_queue;
+		list_add_tail(&sink_module->node, &src_module->sink_list);
+	} else {
+		src_module->out_queue = ssth_free_queue(&src_module->out_queue_mask,
+				 src_module->out_queue);
+		list_for_each_entry_safe(sink_module, __sink_module, &src_module->sink_list, node) {
+			if ((sink_module->id.module_id == dst_module->id.module_id) &&
+				((sink_module->id.instance_id == dst_module->id.instance_id))) {
+				list_del(&sink_module->node);
+				dst_module->in_queue = sink_module->in_queue;
+				devm_kfree(ctx->dev, sink_module);
+				break;
+			}
+		}
+		dst_module->in_queue = ssth_free_queue(&dst_module->in_queue_mask,
+				dst_module->in_queue);
+	}
+	dev_dbg(ctx->dev, "in queque = %d out_queue =%d\n",
+		 src_module->out_queue, dst_module->in_queue);
+	msg.src_queue = src_module->out_queue;
+	msg.dst_queue = dst_module->in_queue;
+	msg.bind = bind;
+
+	ret = ssth_ipc_bind_unbind(ctx->ipc, &msg);
+
+	if (!ret) {
+		if (bind)
+			src_module->m_state = SSTH_MODULE_STATE_BIND_DONE;
+		else
+			src_module->m_state = SSTH_MODULE_STATE_UNINIT;
+	}
+	return ret;
+}
Signature · 1 line
1.7.9.5
author
#8 lore raw

RFC 4/7 ASoC: hda: add FW pipe create/delete/set_pipe_state IPC

In reply to Vinod Koul

From: Jeeja KP <[email protected]>

This helper function is called when FW pipeline has to created/deleted/ to set the pipe to run/pause and uses IPC lib to send the msg to dsp.

---
 sound/soc/hda/hda_soc_dsp.c |  112 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 112 insertions(+)
sound/soc/hda/hda_soc_dsp.c +112 -0
index 5a9927b82852..5f36ebdc0fba 100644
@@ -588,3 +588,115 @@ int ssth_bind_unbind_modules(struct ssth_lib *ctx, struct ssth_module_config
 	}
 	return ret;
 }
+
+static int ssth_set_pipe_state(struct ssth_lib *ctx, struct ssth_pipe *pipe,
+	enum ssth_pipe_state state)
+{
+	int ret = 0;
+
+	dev_dbg(ctx->dev, "%s: pipe_satate = %d\n", __func__, state);
+	ret = ssth_ipc_set_pipeline_state(ctx->ipc, pipe->ppl_id, state);
+	return ret;
+}
+
+/*
+ * Creates pipeline, by sending IPC messages to FW
+ */
+int ssth_create_pipeline(struct ssth_lib *ctx, struct ssth_pipe *pipe)
+{
+	int ret = 0;
+
+	dev_dbg(ctx->dev, "%s: pipe_id = %d\n", __func__, pipe->ppl_id);
+
+	ret = ssth_ipc_create_pipeline(ctx->ipc, pipe->memory_pages,
+				pipe->pipe_priority, pipe->ppl_id);
+	if (ret < 0) {
+		dev_err(ctx->dev, "Failed to create pipeline\n");
+		return ret;
+	}
+	pipe->state = SSTH_PIPE_STATE_CREATED;
+	return ret;
+}
+
+/*
+ * Sets pipe state to RUNNING
+ */
+int ssth_run_pipe(struct ssth_lib *ctx, struct ssth_pipe *pipe)
+{
+	int ret = 0;
+
+	dev_dbg(ctx->dev, "%s: pipe = %d\n", __func__, pipe->ppl_id);
+
+	/* If pipe was not created in FW, do not try to pause or delete */
+	if (pipe->state < SSTH_PIPE_STATE_CREATED)
+		return ret;
+
+	/* Pipe has to be paused before it is started */
+	ret = ssth_set_pipe_state(ctx, pipe, PPL_PAUSED);
+	if (ret < 0) {
+		dev_err(ctx->dev, "Failed to pause pipe\n");
+		return ret;
+	}
+	pipe->state = SSTH_PIPE_STATE_PAUSED;
+	ret = ssth_set_pipe_state(ctx, pipe, PPL_RUNNING);
+	if (ret < 0) {
+		dev_err(ctx->dev, "Failed to start pipe\n");
+		return ret;
+	}
+
+	pipe->state = SSTH_PIPE_STATE_STARTED;
+
+	return ret;
+}
+
+/*
+ * Sets pipe state to PAUSED in FW, stops DMA engines and releases resources
+ */
+int hda_sst_delete_pipe(struct ssth_lib *ctx, struct ssth_pipe *pipe)
+{
+	int ret = 0;
+
+	dev_dbg(ctx->dev, "%s: pipe = %d\n", __func__, pipe->ppl_id);
+
+	/* If pipe is not started, do not try to stop the pipe in FW. */
+	if (pipe->state < SSTH_PIPE_STATE_STARTED)
+		goto delete_pipe;
+
+	ret = ssth_set_pipe_state(ctx, pipe, PPL_PAUSED);
+	if (ret < 0) {
+		dev_err(ctx->dev, "Failed to stop pipeline\n");
+		return ret;
+	}
+	pipe->state = SSTH_PIPE_STATE_PAUSED;
+
+delete_pipe:
+	/* If pipe was not created in FW, do not try to delete it */
+	if (pipe->state < SSTH_PIPE_STATE_CREATED)
+		return ret;
+
+	ret = ssth_ipc_delete_pipeline(ctx->ipc, pipe->ppl_id);
+	if (ret < 0) {
+		dev_err(ctx->dev, "Failed to delete pipeline\n");
+		return ret;
+	}
+	return ret;
+}
+
+int hda_sst_stop_pipe(struct ssth_lib *ctx, struct ssth_pipe *pipe)
+{
+	int ret = 0;
+
+	dev_dbg(ctx->dev, "In %s pipe=%d\n", __func__, pipe->ppl_id);
+
+	/* If pipe was not created in FW, do not try to pause or delete */
+	if (pipe->state < SSTH_PIPE_STATE_PAUSED)
+		return ret;
+	ret = ssth_set_pipe_state(ctx, pipe, PPL_PAUSED);
+	if (ret < 0) {
+		dev_dbg(ctx->dev, "Failed to stop pipe\n");
+		return ret;
+	}
+	pipe->state = SSTH_PIPE_STATE_CREATED;
+
+	return ret;
+}
Signature · 1 line
1.7.9.5
author
#9 lore raw

RFC 5/7 ASOC: hda: add DSP platfrom controls widget event handlers

In reply to Vinod Koul

From: Jeeja KP <[email protected]>

This add widget event handlers for PRE/POST PMU event and PRE/POST PMD event. event handlers functions implement the FW sequence to enable path from source to sink.

---
 sound/soc/hda/Makefile           |    3 +-
 sound/soc/hda/hda_dsp_controls.c |  702 ++++++++++++++++++++++++++++++++++++++
 sound/soc/hda/hda_skl.h          |   17 +
 sound/soc/hda/hda_soc_dsp.c      |    4 +-
 4 files changed, 723 insertions(+), 3 deletions(-)
 create mode 100644 sound/soc/hda/hda_dsp_controls.c
sound/soc/hda/Makefile +2 -1
index 2be667dc0724..668c831b196e 100644
@@ -1,4 +1,5 @@
-snd-soc-hda-skl-objs := hda_skl.o hda_skl_pcm.o hda_soc_dsp.o
+snd-soc-hda-skl-objs := hda_skl.o hda_skl_pcm.o hda_soc_dsp.o \
+hda_dsp_controls.o
 
 obj-$(CONFIG_SND_SOC_HDA_SKL) += snd-soc-hda-skl.o
 
sound/soc/hda/hda_dsp_controls.c new file +702 -0

702 lines not on this page · raw message

sound/soc/hda/hda_skl.h +17 -0
index 914ea05da6aa..f6d9c629a8e3 100644
@@ -15,7 +15,9 @@ struct hda_soc_bus {
 
 	unsigned int init_failed:1; /* delayed init failed */
 	unsigned int msi:1;
+
 	struct ssth_lib *dsp; /* ssth lib ctx */
+	struct hda_platform_info *pinfo; /* platform component info*/
 };
 
 /*to pass dai dma data */
@@ -24,6 +26,21 @@ struct soc_hda_dma_params {
 	u8 stream_tag;
 };
 
+struct ssth_dsp_resource {
+	u32 max_mcps;
+	u32 max_mem;
+	u32 mcps;
+	u32 mem;
+};
+
+struct hda_platform_info {
+	struct hda_soc_bus schip;
+	struct device *dev;
+	struct ssth_dsp_resource resource;
+	struct list_head ppl_list;
+	struct list_head ppl_start_list;
+};
+
 int azx_get_delay_from_lpib(struct hdac_bus *chip,
 				struct hdac_stream *azx_dev,
 				unsigned int pos);
sound/soc/hda/hda_soc_dsp.c +2 -2
index 5f36ebdc0fba..ce1527602e00 100644
@@ -652,7 +652,7 @@ int ssth_run_pipe(struct ssth_lib *ctx, struct ssth_pipe *pipe)
 /*
  * Sets pipe state to PAUSED in FW, stops DMA engines and releases resources
  */
-int hda_sst_delete_pipe(struct ssth_lib *ctx, struct ssth_pipe *pipe)
+int ssth_delete_pipe(struct ssth_lib *ctx, struct ssth_pipe *pipe)
 {
 	int ret = 0;
 
@@ -682,7 +682,7 @@ delete_pipe:
 	return ret;
 }
 
-int hda_sst_stop_pipe(struct ssth_lib *ctx, struct ssth_pipe *pipe)
+int ssth_stop_pipe(struct ssth_lib *ctx, struct ssth_pipe *pipe)
 {
 	int ret = 0;
 
Signature · 1 line
1.7.9.5
maintainer
#10 lore raw

Re: [RFC 5/7] ASOC: hda: add DSP platfrom controls widget event handlers

sound/soc/hda/hda_dsp_controls.c line 36

Quoted 7 lines · Vinod Koul
sound/soc/hda/hda_dsp_controls.c new file +7 -0
+static int is_hda_widget_type(struct snd_soc_dapm_widget *w)
+{
+	return ((w->id == snd_soc_dapm_dai_link) ||
+		(w->id == snd_soc_dapm_dai_in) ||
+		(w->id == snd_soc_dapm_aif_in) ||
+		(w->id == snd_soc_dapm_aif_out) ||
+		(w->id == snd_soc_dapm_dai_out)) ? 1 : 0;

Please use switch statements, and again no need to convert logic values into logic values.

sound/soc/hda/hda_dsp_controls.c line 321

Quoted 12 lines
sound/soc/hda/hda_dsp_controls.c new file +12 -0
+static int hda_sst_dapm_pre_pmu_event(struct snd_soc_dapm_widget *w,
+	int w_type, struct ssth_lib *ctx, struct hda_platform_info *pinfo)
+{
+	int ret = 0;
+	struct ssth_module_config *mconfig = w->priv;
+	struct ssth_pipe *s_pipe = mconfig->pipe;
+
+	dev_dbg(ctx->dev, "%s: widget =%s type=%d\n", __func__, w->name, w_type);
+
+	/*check resource available */
+	if (!hda_sst_is_pipe_mcps_available(pinfo, ctx, mconfig))
+		return -1;

Proper error code please.

Review

Quoted 2 lines
(quoted diff) +2 -0
+	if (w_type == SSTH_WIDGET_VMIXER ||
+		w_type == SSTH_WIDGET_MIXER) {

switch.

Quoted 5 lines
sound/soc/hda/hda_dsp_controls.c new file +5 -0
+
+		if (!hda_sst_is_pipe_mem_available(pinfo, ctx, mconfig))
+			return -ENOMEM;
+
+		ret = ssth_create_pipeline(ctx, mconfig->pipe);

sound/soc/hda/hda_dsp_controls.c line 339

Quoted 10 lines
sound/soc/hda/hda_dsp_controls.c new file +10 -0
+		if (ret < 0)
+			return ret;
+		if (list_empty(&s_pipe->w_list)) {
+			ret = hda_sst_get_pipe_widget(ctx->dev, w, s_pipe);
+			if (ret < 0)
+				return ret;
+		}
+		ret = hda_init_pipe_modules(ctx, s_pipe, pinfo);
+		if (ret < 0)
+			return ret;

The error handling here appears to be a bit incomplete, we don't unwind anything we did.

sound/soc/hda/hda_dsp_controls.c line 442

Quoted 4 lines
sound/soc/hda/hda_dsp_controls.c new file +4 -0
+	switch (event) {
+	case SND_SOC_DAPM_PRE_PMU:
+		return hda_sst_dapm_pre_pmu_event(w, w_type, ctx, pinfo);
+	break;

Please follow the kernel coding style.

Quoted 8 lines
sound/soc/hda/hda_dsp_controls.c new file +8 -0
+static int hda_sst_vmixer_event(struct snd_soc_dapm_widget *w,
+		struct snd_kcontrol *k, int event)
+{
+	struct snd_soc_dapm_context *dapm = w->dapm;
+
+	dev_dbg(dapm->dev, "%s: widget = %s\n", __func__, w->name);
+	return hda_sst_event_handler(w, event, SSTH_WIDGET_VMIXER);
+}

sound/soc/hda/hda_dsp_controls.c line 474

Quoted 10 lines
sound/soc/hda/hda_dsp_controls.c new file +10 -0
+
+static int hda_sst_mixer_event(struct snd_soc_dapm_widget *w,
+			struct snd_kcontrol *k, int event)
+{
+	struct snd_soc_dapm_context *dapm = w->dapm;
+
+	dev_dbg(dapm->dev, "%s: widget = %s\n", __func__, w->name);
+
+	return hda_sst_event_handler(w, event, SSTH_WIDGET_MIXER);
+}

Lots of indirection and wrapping going on here which seems to make things more confusing. Can you try writing out the event handling directly and having it call common functions to perform the shared operations rather than having a single event handler with per type cases? Or alternatively use the DAPM widget type rather than your own ones.

sound/soc/hda/hda_dsp_controls.c line 555

Quoted 3 lines
sound/soc/hda/hda_dsp_controls.c new file +3 -0
+	/* if FE - Playback, then parse sink list , Capture then source list
+	if BE - Playback, then parse source list , Capture then sink list
+	*/

Coding style on comments too BTW.

sound/soc/hda/hda_dsp_controls.c line 558

Quoted 3 lines
sound/soc/hda/hda_dsp_controls.c new file +3 -0
+	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		w = dai->playback_widget;
+		(is_fe) ? (dir = 1) : (dir = 0);

This looks like a very complicated way of writing dir = is_fe.

author
#11 lore raw

Re: [RFC 5/7] ASOC: hda: add DSP platfrom controls widget event handlers

Quoted 12 lines · Mark Brown

sound/soc/hda/hda_dsp_controls.c line 36

Quoted 7 lines · Vinod Koul
sound/soc/hda/hda_dsp_controls.c new file +7 -0
+static int is_hda_widget_type(struct snd_soc_dapm_widget *w)
+{
+	return ((w->id == snd_soc_dapm_dai_link) ||
+		(w->id == snd_soc_dapm_dai_in) ||
+		(w->id == snd_soc_dapm_aif_in) ||
+		(w->id == snd_soc_dapm_aif_out) ||
+		(w->id == snd_soc_dapm_dai_out)) ? 1 : 0;

Please use switch statements, and again no need to convert logic values into logic values.

OK

Quoted 15 lines

sound/soc/hda/hda_dsp_controls.c line 321

Quoted 13 lines
sound/soc/hda/hda_dsp_controls.c new file +12 -0
+static int hda_sst_dapm_pre_pmu_event(struct snd_soc_dapm_widget *w,
+	int w_type, struct ssth_lib *ctx, struct hda_platform_info *pinfo)
+{
+	int ret = 0;
+	struct ssth_module_config *mconfig = w->priv;
+	struct ssth_pipe *s_pipe = mconfig->pipe;
+
+	dev_dbg(ctx->dev, "%s: widget =%s type=%d\n", __func__, w->name, w_type);
+
+	/*check resource available */
+	if (!hda_sst_is_pipe_mcps_available(pinfo, ctx, mconfig))
+		return -1;

Proper error code please.

Sure

Quoted 5 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+	if (w_type == SSTH_WIDGET_VMIXER ||
+		w_type == SSTH_WIDGET_MIXER) {

switch.

Since this is checking for these two types only, I think if maybe fine, but dont mind swicth too.

Quoted 10 lines
Quoted 10 lines
sound/soc/hda/hda_dsp_controls.c new file +10 -0
+
+		if (!hda_sst_is_pipe_mem_available(pinfo, ctx, mconfig))
+			return -ENOMEM;
+
+		ret = ssth_create_pipeline(ctx, mconfig->pipe);
+		if (ret < 0)
+			return ret;
+		if (list_empty(&s_pipe->w_list)) {
+			ret = hda_sst_get_pipe_widget(ctx->dev, w, s_pipe);
+			if (ret < 0)
Quoted 8 lines

sound/soc/hda/hda_dsp_controls.c line 339

Quoted 5 lines
sound/soc/hda/hda_dsp_controls.c new file +5 -0
+				return ret;
+		}
+		ret = hda_init_pipe_modules(ctx, s_pipe, pinfo);
+		if (ret < 0)
+			return ret;

The error handling here appears to be a bit incomplete, we don't unwind anything we did.

Yes let me check that.

Quoted 6 lines

sound/soc/hda/hda_dsp_controls.c line 442

Quoted 4 lines
sound/soc/hda/hda_dsp_controls.c new file +4 -0
+	switch (event) {
+	case SND_SOC_DAPM_PRE_PMU:
+		return hda_sst_dapm_pre_pmu_event(w, w_type, ctx, pinfo);
+	break;

Please follow the kernel coding style.

oops, will fix

Quoted 17 lines
Quoted 17 lines
sound/soc/hda/hda_dsp_controls.c new file +17 -0
+static int hda_sst_vmixer_event(struct snd_soc_dapm_widget *w,
+		struct snd_kcontrol *k, int event)
+{
+	struct snd_soc_dapm_context *dapm = w->dapm;
+
+	dev_dbg(dapm->dev, "%s: widget = %s\n", __func__, w->name);
+	return hda_sst_event_handler(w, event, SSTH_WIDGET_VMIXER);
+}
+
+static int hda_sst_mixer_event(struct snd_soc_dapm_widget *w,
+			struct snd_kcontrol *k, int event)
+{
+	struct snd_soc_dapm_context *dapm = w->dapm;
+
+	dev_dbg(dapm->dev, "%s: widget = %s\n", __func__, w->name);
+
+	return hda_sst_event_handler(w, event, SSTH_WIDGET_MIXER);
Quoted 8 lines
Quoted 1 line

+}

Lots of indirection and wrapping going on here which seems to make things more confusing. Can you try writing out the event handling directly and having it call common functions to perform the shared operations rather than having a single event handler with per type cases? Or alternatively use the DAPM widget type rather than your own ones.

Okay let me cleanup this code is next series

Quoted 6 lines

sound/soc/hda/hda_dsp_controls.c line 555

Quoted 4 lines
sound/soc/hda/hda_dsp_controls.c new file +3 -0
+	/* if FE - Playback, then parse sink list , Capture then source list
+	if BE - Playback, then parse source list , Capture then sink list
+	*/

Coding style on comments too BTW.

will fix

Quoted 6 lines

sound/soc/hda/hda_dsp_controls.c line 558

Quoted 4 lines
sound/soc/hda/hda_dsp_controls.c new file +3 -0
+	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		w = dai->playback_widget;
+		(is_fe) ? (dir = 1) : (dir = 0);

This looks like a very complicated way of writing dir = is_fe.

Yes for sure :)

Signature · 2 lines
~Vinod
-- 
author
#12 lore raw

RFC 6/7 ASoC: hda: Add support for SSP register settings

In reply to Vinod Koul

From: Jeeja KP <[email protected]>

SSP registers needs to be updated for the SSP copier module. Add support to update the registers based on dai configuration.

---
 sound/soc/hda/hda_dsp_ssp_config.c |  285 ++++++++++++++++++++++++
 sound/soc/hda/hda_dsp_ssp_config.h |  423 ++++++++++++++++++++++++++++++++++++
 2 files changed, 708 insertions(+)
 create mode 100644 sound/soc/hda/hda_dsp_ssp_config.c
 create mode 100644 sound/soc/hda/hda_dsp_ssp_config.h
sound/soc/hda/hda_dsp_ssp_config.c new file +285 -0
new file mode 100644
index 000000000000..8b79777fb8be
@@ -0,0 +1,285 @@
+/*
+ *  hda_dsp_ssp_config.c - HDA DSP SSP register configuration functionality
+ *
+ *  Copyright (C) 2015 Intel Corp
+ *  Author:  Hardik Shah <[email protected]>
+ *
+ *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  General Public License for more details.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ */
+#include "hda_dsp_ssp_config.h"
+#include "hda_skl.h"
+
+#define HDA_SSP_MAX_FREQ_192 19200000
+
+struct hda_ssp_regs {
+	u32 hda_ssc0;
+	u32 hda_ssc1;
+	u32 hda_ssto;
+	u32 hda_sspsp;
+	u32 hda_sstsa;
+	u32 hda_ssrsa;
+	u32 hda_ssc2;
+	u32 hda_sspsp2;
+	u32 hda_ssc3;
+	u32 hda_ssioc;
+};
+
+
+static void azx_set_default_ssp_regs_v1(struct hda_ssp_regs *regs)
+{
+	regs->hda_ssc0 = 0;
+	regs->hda_ssc0 = (HDA_SSC0_FRF_DEF_V1 << HDA_SSC0_FRF_SHIFT) |
+			(HDA_SSC0_ECS_DEF_V1 << HDA_SSC0_ECS_SHIFT) |
+			(HDA_SSC0_SSE_DEF_V1 << HDA_SSC0_SSE_SHIFT) |
+			(HDA_SSC0_NCS_DEF_V1 << HDA_SSC0_NCS_SHIFT) |
+			(HDA_SSC0_RIM_DEF_V1 << HDA_SSC0_RIM_SHIFT) |
+			(HDA_SSC0_ACS_DEF_V1 << HDA_SSC0_ACS_SHIFT) |
+			(HDA_SSC0_MOD_DEF_V1 << HDA_SSC0_MOD_SHIFT);
+
+	regs->hda_ssc1 = 0;
+	regs->hda_ssc1 = (HDA_SSC1_RIE_DEF_V1 << HDA_SSC1_RIE_SHIFT) |
+			(HDA_SSC1_TIE_DEF_V1 << HDA_SSC1_TIE_SHIFT) |
+			(HDA_SSC1_LBM_DEF_V1 << HDA_SSC1_LBM_SHIFT) |
+			(HDA_SSC1_SPO_DEF_V1 << HDA_SSC1_SPO_SHIFT) |
+			(HDA_SSC1_SPH_DEF_V1 << HDA_SSC1_SPH_SHIFT) |
+			(HDA_SSC1_MWDS_DEF_V1 << HDA_SSC1_MWDS_SHIFT) |
+			(HDA_SSC1_EFWR_DEF_V1 << HDA_SSC1_EFWR_SHIFT) |
+			(HDA_SSC1_STRF_DEF_V1 << HDA_SSC1_STRF_SHIFT) |
+			(HDA_SSC1_IFS_DEF_V1 << HDA_SSC1_IFS_SHIFT) |
+			(HDA_SSC1_PINTE_DEF_V1 << HDA_SSC1_PINTE_SHIFT) |
+			(HDA_SSC1_TINTE_DEF_V1 << HDA_SSC1_TINTE_SHIFT) |
+			(HDA_SSC1_RSRE_DEF_V1 << HDA_SSC1_RSRE_SHIFT) |
+			(HDA_SSC1_TSRE_DEF_V1 << HDA_SSC1_TSRE_SHIFT) |
+			(HDA_SSC1_TRAIL_DEF_V1 << HDA_SSC1_TRAIL_SHIFT) |
+			(HDA_SSC1_RWOT_DEF_V1 << HDA_SSC1_RWOT_SHIFT) |
+			(HDA_SSC1_ECRB_DEF_V1 << HDA_SSC1_ECRB_SHIFT) |
+			(HDA_SSC1_ECRA_DEF_V1 << HDA_SSC1_ECRA_SHIFT) |
+			(HDA_SSC1_SCFR_DEF_V1 << HDA_SSC1_SCFR_SHIFT) |
+			(HDA_SSC1_EBCEI_DEF_V1 << HDA_SSC1_EBCEI_SHIFT) |
+			(HDA_SSC1_TTE_DEF_V1 << HDA_SSC1_TTE_SHIFT) |
+			(HDA_SSC1_TTELP_DEF_V1 << HDA_SSC1_TTELP_SHIFT);
+
+	regs->hda_ssto = 0;
+	regs->hda_ssto = HDA_SST0_TIMEOUT_DEF_V1 << HDA_SST0_TIMEOUT_SHIFT;
+
+	regs->hda_sspsp = 0;
+	regs->hda_sspsp = (HDA_SSPSP_ETDS_DEF_V1 << HDA_SSPSP_ETDS_SHIFT) |
+			(HDA_SSPSP_STRTDLY_DEF_V1 << HDA_SSPSP_STRTDLY_SHIFT) |
+			(HDA_SSPSP_DMYSTRT_DEF_V1 << HDA_SSPSP_DMYSTRT_SHIFT) |
+			(HDA_SSPSP_SFRMDLY_DEF_V1 << HDA_SSPSP_SFRMDLY_SHIFT) |
+			(HDA_SSPSP_DMYSTOP_DEF_V1 << HDA_SSPSP_DMYSTOP_SHIFT) |
+			(HDA_SSPSP_EDMYSTOP_DEF_V1 << HDA_SSPSP_EDMYSTOP_SHIFT);
+
+	regs->hda_sstsa = 0;
+	regs->hda_sstsa = (HDA_SSTSA_TXEN_DEF_V1 << HDA_SSTSA_TXEN_SHIFT) |
+			(HDA_SSTSA_TTSA_DEF_V1 << HDA_SSTSA_TTSA_SHIFT);
+
+	regs->hda_ssrsa = 0;
+	regs->hda_ssrsa = (HDA_SSRSA_RXEN_DEF_V1 << HDA_SSRSA_RXEN_SHIFT) |
+			(HDA_SSTSA_RTSA_DEF_V1 << HDA_SSRSA_RTSA_SHIFT);
+
+	regs->hda_ssc2 = 0;
+	regs->hda_ssc2 = (HDA_SSC2_TURM0_DEF_V1 << HDA_SSC2_TURM0_SHIFT) |
+		(HDA_SSC2_TURM1_DEF_V1 << HDA_SSC2_TURM1_SHIFT) |
+		(HDA_SSC2_PSPMB2BFMFD_DEF_V1 << HDA_SSC2_PSPMB2BFMFD_SHIFT) |
+		(HDA_SSC2_PSPSRWFDFD_DEF_V1 << HDA_SSC2_PSPSRWFDFD_SHIFT) |
+		(HDA_SSC2_PSPSTWFDFD_DEF_V1 << HDA_SSC2_PSPSTWFDFD_SHIFT) |
+		(HDA_SSC2_PSPMFSRTPFD_DEF_V1 << HDA_SSC2_PSPMFSRTPFD_SHIFT) |
+		(HDA_SSC2_ROFD_DEF_V1 << HDA_SSC2_ROFD_SHIFT) |
+		(HDA_SSC2_C2DFFD_DEF_V1 << HDA_SSC2_C2DFFD_SHIFT) |
+		(HDA_SSC2_TSAFD_DEF_V1 << HDA_SSC2_TSAFD_SHIFT) |
+		(HDA_SSC2_RSAFD_DEF_V1 << HDA_SSC2_RSAFD_SHIFT) |
+		(HDA_SSC2_RMFGFD_DEF_V1 << HDA_SSC2_RMFGFD_SHIFT) |
+		(HDA_SSC2_TURFD_DEF_V1 << HDA_SSC2_TURFD_SHIFT) |
+		(HDA_SSC2_TUDFD_DEF_V1 << HDA_SSC2_TUDFD_SHIFT) |
+		(HDA_SSC2_BCEFD_DEF_V1 << HDA_SSC2_BCEFD_SHIFT) |
+		(HDA_SSC2_SDFD_DEF_V1 << HDA_SSC2_SDFD_SHIFT) |
+		(HDA_SSC2_SDHFD_DEF_V1 << HDA_SSC2_SDHFD_SHIFT) |
+		(HDA_SSC2_SDPM_DEF_V1 << HDA_SSC2_SDPM_SHIFT) |
+		(HDA_SSC2_LJDFD_DEF_V1 << HDA_SSC2_LJDFD_SHIFT) |
+		(HDA_SSC2_MMRATF_DEF_V1 << HDA_SSC2_MMRATF_SHIFT) |
+		(HDA_SSC2_SMTATF_DEF_V1 << HDA_SSC2_SMTATF_SHIFT);
+
+	regs->hda_ssc3 = 0;
+	regs->hda_ssc3 = (HDA_SSC3_TFT_DEF_V1 << HDA_SSC3_TFT_SHIFT) |
+			(HDA_SSC3_RFT_DEF_V1 << HDA_SSC3_RFT_SHIFT);
+
+	regs->hda_ssioc = 0;
+	regs->hda_ssioc = (HDA_SSIOC_RXDPDEB_DEF_V1 << HDA_SSIOC_RXDPDEB_SHIFT) |
+		(HDA_SSIOC_TXDPDEB_DEF_V1 << HDA_SSIOC_TXDPDEB_SHIFT) |
+		(HDA_SSIOC_SFRMPDEB_DEF_V1 << HDA_SSIOC_SFRMPDEB_SHIFT) |
+		(HDA_SSIOC_SCLKPDEB_DEF_V1 << HDA_SSIOC_SCLKPDEB_SHIFT) |
+		(HDA_SSIOC_SFCR_DEF_V1 << HDA_SSIOC_SFCR_SHIFT) |
+		(HDA_SSIOC_SCOE_DEF_V1 << HDA_SSIOC_SCOE_SHIFT);
+
+	regs->hda_sspsp2 = 0;
+
+}
+
+static void azx_print_ssp_regs(struct sst_dsp_ctx *ctx,
+						struct hda_ssp_regs *regs)
+{
+	dev_dbg(ctx->dev, "ssc0\t\t %x\n", regs->hda_ssc0);
+	dev_dbg(ctx->dev, "ssc1\t\t %x\n", regs->hda_ssc1);
+	dev_dbg(ctx->dev, "sst0\t\t %x\n", regs->hda_ssto);
+	dev_dbg(ctx->dev, "sspsp\t\t %x\n", regs->hda_sspsp);
+	dev_dbg(ctx->dev, "sstsa\t\t %x\n", regs->hda_sstsa);
+	dev_dbg(ctx->dev, "ssrsa\t\t %x\n", regs->hda_ssrsa);
+	dev_dbg(ctx->dev, "ssc2\t\t %x\n", regs->hda_ssc2);
+	dev_dbg(ctx->dev, "sspsp2\t\t %x\n", regs->hda_sspsp2);
+	dev_dbg(ctx->dev, "ssc3\t\t %x\n", regs->hda_ssc3);
+	dev_dbg(ctx->dev, "ssioc\t\t %x\n", regs->hda_ssioc);
+}
+
+static int azx_find_ssp_clk_divisor(struct sst_dsp_ctx *ctx, int fs,
+			int slots, int s_fmt, int *div, int *dummy_bits)
+{
+	int divisor, mod;
+	int found = 0;
+	int req_bclk;
+	int dummy = 0;
+
+	dev_dbg(ctx->dev, "fs = %d, slots = %d s_fmt = %d\n", fs, slots, s_fmt);
+	req_bclk = fs * slots * s_fmt;
+	if (req_bclk == 0) {
+		dev_err(ctx->dev, "Required bit clock = 0\n");
+		return -EINVAL;
+	}
+	if (req_bclk > HDA_SSP_MAX_FREQ_192) {
+		dev_err(ctx->dev, "Bit clock is %d, greater than max SSP freq\n", req_bclk);
+		return -EINVAL;
+	}
+	dummy = 0;
+	/* Find the lowest bit clock possible for particular configuration */
+	do {
+		req_bclk = ((s_fmt * fs * slots) + (fs * dummy));
+		mod = HDA_SSP_MAX_FREQ_192 % req_bclk;
+		divisor = HDA_SSP_MAX_FREQ_192 / req_bclk;
+		if (!mod) {
+			found = 1;
+			break;
+		}
+		/* Dont add odd number of dummy bits, since I2S requires
+		 * dummy bit after each slot/channel
+		 */
+		dummy += 2;
+		if (dummy > (HDA_SSPSP2_FEP_MASK >> HDA_SSPSP2_FEP_SHIFT)) {
+			dev_err(ctx->dev, "Dummy bit greater than what SSP can support\n");
+			return -EINVAL;
+		}
+
+	} while (divisor > 0);
+	if (found) {
+		*div = divisor;
+		*dummy_bits = dummy;
+		return 0;
+	}
+	dev_err(ctx->dev, "Suitable divisor not found for SSP configuration\n");
+
+	return -EINVAL;
+}
+int azx_calculate_ssp_regs(struct sst_dsp_ctx *ctx, struct azx_dai_config *cfg,
+						void *ssp_regs)
+{
+	struct hda_ssp_regs regs;
+	int ret = 0;
+	int div, dummy;
+	int dss, edss;
+	int edmystop, dmystop;
+	struct azx_ssp_dai_config *ssp_cfg = &cfg->ssp_dai_config;
+
+	azx_set_default_ssp_regs_v1(&regs);
+	dev_dbg(ctx->dev, "Default value of registers set to:\n");
+	azx_print_ssp_regs(ctx, &regs);
+
+	if (ssp_cfg->fs_slave)
+		regs.hda_ssc1 |= HDA_SSC1_SFRMDIR_MASK;
+	if (ssp_cfg->bclk_slave)
+		regs.hda_ssc1 |= HDA_SSC1_SCLKDIR_MASK;
+	if (!ssp_cfg->fs_invert)
+		regs.hda_sspsp |= ((0x1 << HDA_SSPSP_SFRMP_SHIFT) &
+				HDA_SSPSP_SFRMP_MASK);
+	if (ssp_cfg->bclk_invert)
+		regs.hda_sspsp |= ((0x1 << HDA_SSPSP_SCMODE_SHIFT) &
+				HDA_SSPSP_SCMODE_MASK);
+
+	if (ssp_cfg->ssp_mode == HDA_SSP_MODE_I2S)
+		/* I2S mode, means 2 slots */
+		ssp_cfg->slots = 2;
+
+	ret = azx_find_ssp_clk_divisor(ctx, cfg->sampling_rate, ssp_cfg->slots,
+					cfg->s_fmt, &div, &dummy);
+	if (ret) {
+		dev_err(ctx->dev, "Clock disior not possible\n");
+		return -EINVAL;
+	}
+	/* Program dividier */
+	regs.hda_ssc0 |= ((div - 1) << HDA_SSC0_SRC_SHIFT) & HDA_SSC0_SCR_MASK;
+
+
+	if (ssp_cfg->slot_width != cfg->s_fmt) {
+		dev_err(ctx->dev, "slot_width must be equal to format bits\n");
+		return -EINVAL;
+	}
+
+	if (cfg->s_fmt > 16) {
+		edss = 1;
+		dss = cfg->s_fmt - 16;
+	} else {
+		edss = 0;
+		dss = cfg->s_fmt;
+	}
+	dss -= 1;
+	regs.hda_ssc0 |= ((dss << HDA_SSC0_DSS_SHIFT) & HDA_SSC0_DSS_MASK);
+	regs.hda_ssc0 |= ((edss << HDA_SSC0_EDSS_SHIFT) & HDA_SSC0_EDSS_MASK);
+
+	if (ssp_cfg->ssp_mode != HDA_SSP_MODE_I2S) {
+		regs.hda_sspsp2 |= (dummy << HDA_SSPSP2_FEP_SHIFT) &
+							HDA_SSPSP2_FEP_MASK;
+		regs.hda_sspsp |= (0x1 << HDA_SSPSP_SFRMWDTH_SHIFT) &
+					HDA_SSPSP_SFRMWDTH_MASK;
+		if (ssp_cfg->ssp_mode == HDA_SSP_MODE_DSP_A)
+			regs.hda_sspsp |= (0x1 << HDA_SSPSP_FSRT_SHIFT) &
+					HDA_SSPSP_FSRT_MASK;
+		else
+			regs.hda_sspsp &= ~(HDA_SSPSP_FSRT_MASK);
+	} else {
+		/* Divide dummy bits / 2 */
+		regs.hda_sspsp |= (0x1 << HDA_SSPSP_FSRT_SHIFT) &
+				HDA_SSPSP_FSRT_MASK;
+		dummy = dummy >> 1;
+		dmystop = dummy & 0x3;
+		edmystop = (dummy >> 2);
+		regs.hda_sspsp |= (dmystop << HDA_SSPSP_DMYSTOP_SHIFT) &
+							HDA_SSPSP_DMYSTOP_MASK;
+		regs.hda_sspsp |= (edmystop << HDA_SSPSP_EDMYSTOP_SHIFT) &
+						HDA_SSPSP_EDMYSTOP_MASK;
+		regs.hda_sspsp |= ((cfg->s_fmt + dummy) << HDA_SSPSP_SFRMWDTH_SHIFT) &
+							HDA_SSPSP_SFRMWDTH_MASK;
+		ssp_cfg->slots = 2;
+	}
+	if (ssp_cfg->slots > HDA_SSP_MAX_SLOTS) {
+		dev_err(ctx->dev, "Max slots = %d\n", HDA_SSP_MAX_SLOTS);
+		return -EINVAL;
+	}
+	regs.hda_ssc0 |= ((ssp_cfg->slots - 1) << HDA_SSC0_FRDC_SHIFT) &
+			HDA_SSC0_FRDC_MASK;
+
+	memcpy(ssp_regs, &regs, sizeof(struct hda_ssp_regs));
+	dev_dbg(ctx->dev, "Registers updated to\n");
+	azx_print_ssp_regs(ctx, &regs);
+	return 0;
+
+}
sound/soc/hda/hda_dsp_ssp_config.h new file +423 -0

423 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer
#13 lore raw

Re: [RFC 6/7] ASoC: hda: Add support for SSP register settings

sound/soc/hda/hda_dsp_ssp_config.c line 155

Quoted 1 line · Vinod Koul
sound/soc/hda/hda_dsp_ssp_config.c new file +1 -0
+	req_bclk = fs * slots * s_fmt;

We have a helper for this.

sound/soc/hda/hda_dsp_ssp_config.c line 176

Quoted 13 lines
sound/soc/hda/hda_dsp_ssp_config.c new file +13 -0
+	dummy = 0;
+	/* Find the lowest bit clock possible for particular configuration */
+	do {
+		req_bclk = ((s_fmt * fs * slots) + (fs * dummy));
+		mod = HDA_SSP_MAX_FREQ_192 % req_bclk;
+		divisor = HDA_SSP_MAX_FREQ_192 / req_bclk;
+		if (!mod) {
+			found = 1;
+			break;
+		}
+		/* Dont add odd number of dummy bits, since I2S requires
+		 * dummy bit after each slot/channel
+		 */

It does?

sound/soc/hda/hda_dsp_ssp_config.c line 183

Quoted 7 lines
sound/soc/hda/hda_dsp_ssp_config.c new file +7 -0
+		dummy += 2;
+		if (dummy > (HDA_SSPSP2_FEP_MASK >> HDA_SSPSP2_FEP_SHIFT)) {
+			dev_err(ctx->dev, "Dummy bit greater than what SSP can support\n");
+			return -EINVAL;
+		}
+
+	} while (divisor > 0);

Aside from the limits this all looks like it could be generic?

author
#14 lore raw

Re: [RFC 6/7] ASoC: hda: Add support for SSP register settings

Quoted 5 lines · Mark Brown

sound/soc/hda/hda_dsp_ssp_config.c line 155

Quoted 1 line · Vinod Koul
sound/soc/hda/hda_dsp_ssp_config.c new file +1 -0
+	req_bclk = fs * slots * s_fmt;

We have a helper for this.

will use

Quoted 16 lines
Quoted 4 lines
sound/soc/hda/hda_dsp_ssp_config.c new file +3 -0
+	dummy = 0;
+	/* Find the lowest bit clock possible for particular configuration */
+	do {

sound/soc/hda/hda_dsp_ssp_config.c line 176

Quoted 10 lines
sound/soc/hda/hda_dsp_ssp_config.c new file +10 -0
+		req_bclk = ((s_fmt * fs * slots) + (fs * dummy));
+		mod = HDA_SSP_MAX_FREQ_192 % req_bclk;
+		divisor = HDA_SSP_MAX_FREQ_192 / req_bclk;
+		if (!mod) {
+			found = 1;
+			break;
+		}
+		/* Dont add odd number of dummy bits, since I2S requires
+		 * dummy bit after each slot/channel
+		 */

It does?

For us unfortuntely yes. We send 24 bit audio to codec and clock divider doesn't give us 48clocks per frame, so we have to add dummy clocks in each slot and send 25 clocks per slot

Quoted 9 lines

sound/soc/hda/hda_dsp_ssp_config.c line 183

Quoted 7 lines
sound/soc/hda/hda_dsp_ssp_config.c new file +7 -0
+		dummy += 2;
+		if (dummy > (HDA_SSPSP2_FEP_MASK >> HDA_SSPSP2_FEP_SHIFT)) {
+			dev_err(ctx->dev, "Dummy bit greater than what SSP can support\n");
+			return -EINVAL;
+		}
+
+	} while (divisor > 0);

Aside from the limits this all looks like it could be generic?

sure will try to do that.

Thanks

Signature · 1 line
~Vinod
maintainer
#15 lore raw

Re: [RFC 6/7] ASoC: hda: Add support for SSP register settings

Quoted 11 lines · Vinod Koul
Quoted 5 lines · Mark Brown

sound/soc/hda/hda_dsp_ssp_config.c line 176

Quoted 3 lines
sound/soc/hda/hda_dsp_ssp_config.c new file +3 -0
+		/* Dont add odd number of dummy bits, since I2S requires
+		 * dummy bit after each slot/channel
+		 */

It does?

For us unfortuntely yes. We send 24 bit audio to codec and clock divider doesn't give us 48clocks per frame, so we have to add dummy clocks in each slot and send 25 clocks per slot

So it's the hardware rather than I2S itself :)

#16 lore raw

Re: [RFC 6/7] ASoC: hda: Add support for SSP register settings

Quoted 9 lines · Mark Brown
Quoted 7 lines · Vinod Koul
Quoted 5 lines · Mark Brown

sound/soc/hda/hda_dsp_ssp_config.c line 176

Quoted 3 lines
sound/soc/hda/hda_dsp_ssp_config.c new file +3 -0
+		/* Dont add odd number of dummy bits, since I2S requires
+		 * dummy bit after each slot/channel
+		 */

It does?

Quoted 5 lines
Quoted 3 lines

For us unfortuntely yes. We send 24 bit audio to codec and clock divider doesn't give us 48clocks per frame, so we have to add dummy clocks in each slot and send 25 clocks per slot

So it's the hardware rather than I2S itself :)

It depends on the clock reference used to drive the SSP. With a 19.2 reference we typically divide by 50 and pad with a trailing bit.

That said I am not sure how this code would work on SKL. Vinod, isn't this for BXT only? how do you get 19.2 on SKL, shouldn't you guys use a 24 MHz root frequency to find the divider?

#17 lore raw

Re: [RFC 6/7] ASoC: hda: Add support for SSP register settings

Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 6 lines

sound/soc/hda/hda_dsp_ssp_config.c line 176

Quoted 4 lines
sound/soc/hda/hda_dsp_ssp_config.c new file +3 -0
+        /* Dont add odd number of dummy bits, since I2S requires
+         * dummy bit after each slot/channel
+         */

It does?

For us unfortuntely yes. We send 24 bit audio to codec and clock divider doesn't give us 48clocks per frame, so we have to add dummy clocks in each
slot and send 25 clocks per slot

Quoted 8 lines
Quoted 1 line

So it's the hardware rather than I2S itself :)

It depends on the clock reference used to drive the SSP. With a 19.2 reference we typically divide by 50 and pad with a trailing bit.

That said I am not sure how this code would work on SKL. Vinod, isn't this for BXT only? how do you get 19.2 on SKL, shouldn't you guys use a 24 MHz root frequency to find the divider?

And regardless you should make sure that the actual blck does not exceed the maximum serial bit-rate supported by the SOC (AC timing).

author
#18 lore raw

Re: [RFC 6/7] ASoC: hda: Add support for SSP register settings

Quoted 17 lines · Pierre-Louis Bossart
Quoted 17 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
sound/soc/hda/hda_dsp_ssp_config.c new file +3 -0
+        /* Dont add odd number of dummy bits, since I2S requires
+         * dummy bit after each slot/channel
+         */
Quoted 8 lines
Quoted 6 lines
Quoted 1 line

It does?

For us unfortuntely yes. We send 24 bit audio to codec and clock divider doesn't give us 48clocks per frame, so we have to add dummy clocks in each
slot and send 25 clocks per slot

So it's the hardware rather than I2S itself :)

It depends on the clock reference used to drive the SSP. With a 19.2 reference we typically divide by 50 and pad with a trailing bit.

Quoted 6 lines
Quoted 3 lines

That said I am not sure how this code would work on SKL. Vinod, isn't this for BXT only? how do you get 19.2 on SKL, shouldn't you guys use a 24 MHz root frequency to find the divider?

And regardless you should make sure that the actual blck does not exceed the maximum serial bit-rate supported by the SOC (AC timing).

Yes botha re valid points. But I do rember one of the platforms has 10.2 and another has 25, so we need to be agnostic here and do compare, or use ACPI blobs :)

Signature · 1 line
~Vinod
maintainer
#19 lore raw

Re: [RFC 6/7] ASoC: hda: Add support for SSP register settings

Quoted 6 lines · Vinod Koul
Quoted 3 lines · Pierre-Louis Bossart
Quoted 3 lines

That said I am not sure how this code would work on SKL. Vinod, isn't this for BXT only? how do you get 19.2 on SKL, shouldn't you guys use a 24 MHz root frequency to find the divider?

Quoted 6 lines
Quoted 2 lines

And regardless you should make sure that the actual blck does not exceed the maximum serial bit-rate supported by the SOC (AC timing).

Yes botha re valid points. But I do rember one of the platforms has 10.2 and another has 25, so we need to be agnostic here and do compare, or use ACPI blobs :)

If this is under the control of the system integrators then I'd suggest you're going to see the configuration being used.

#20 lore raw

Re: [RFC 6/7] ASoC: hda: Add support for SSP register settings

Quoted 10 lines · Mark Brown
Quoted 8 lines · Vinod Koul
Quoted 6 lines · Pierre-Louis Bossart
Quoted 3 lines

That said I am not sure how this code would work on SKL. Vinod, isn't this for BXT only? how do you get 19.2 on SKL, shouldn't you guys use a 24 MHz root frequency to find the divider?

And regardless you should make sure that the actual blck does not exceed the maximum serial bit-rate supported by the SOC (AC timing).

Quoted 6 lines
Quoted 3 lines

Yes botha re valid points. But I do rember one of the platforms has 10.2 and another has 25, so we need to be agnostic here and do compare, or use ACPI blobs :)

If this is under the control of the system integrators then I'd suggest you're going to see the configuration being used.

It's an SOC/chipset parameter that can't be changed, not sure why it would come from ACPI - it's really frozen in silicon. The code can remain generic but needs to have an initialization for the root frequency that depends on the SOC/chipset. Rethinking on the bclock check, I withdraw my comment, it's impractical since there can be all sorts of 'optimizations' or limitations that can't be modeled here in this generic code. This check should be done elsewhere with additional platform information.

author
#21 lore raw

RFC 7/7 ASoC: hda: Apply dai params_fixup for DSP widgets

In reply to Vinod Koul

From: Jeeja KP <[email protected]>

DSP widgets configuration needs to be changed based on hw_params or hw_params_fixup. Add support where dai configuration is store in private data and apply to widget based on fixup.

---
 sound/soc/hda/Makefile             |    2 +-
 sound/soc/hda/hda_dsp_controls.c   |  213 +++++++++++++++++++++++++++++++++++-
 sound/soc/hda/hda_dsp_ssp_config.c |   15 ++-
 sound/soc/hda/hda_skl.h            |   75 +++++++++++++
 4 files changed, 298 insertions(+), 7 deletions(-)
sound/soc/hda/Makefile +1 -1
index 668c831b196e..c8be01816157 100644
@@ -1,5 +1,5 @@
 snd-soc-hda-skl-objs := hda_skl.o hda_skl_pcm.o hda_soc_dsp.o \
-hda_dsp_controls.o
+hda_dsp_controls.o hda_dsp_ssp_config.o
 
 obj-$(CONFIG_SND_SOC_HDA_SKL) += snd-soc-hda-skl.o
 
sound/soc/hda/hda_dsp_controls.c +212 -1

245 lines not on this page · raw message

sound/soc/hda/hda_dsp_ssp_config.c +10 -5
index 8b79777fb8be..aa9d5542dc59 100644
@@ -18,9 +18,14 @@
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *
  */
+
+#include <sound/pcm_params.h>
+#include <sound/soc-hda-sst-dsp.h>
+#include "hda_dsp_controls.h"
 #include "hda_dsp_ssp_config.h"
 #include "hda_skl.h"
 
+
 #define HDA_SSP_MAX_FREQ_192 19200000
 
 struct hda_ssp_regs {
@@ -128,8 +133,8 @@ static void azx_set_default_ssp_regs_v1(struct hda_ssp_regs *regs)
 
 }
 
-static void azx_print_ssp_regs(struct sst_dsp_ctx *ctx,
-						struct hda_ssp_regs *regs)
+static void azx_print_ssp_regs(struct ssth_lib *ctx,
+				struct hda_ssp_regs *regs)
 {
 	dev_dbg(ctx->dev, "ssc0\t\t %x\n", regs->hda_ssc0);
 	dev_dbg(ctx->dev, "ssc1\t\t %x\n", regs->hda_ssc1);
@@ -143,7 +148,7 @@ static void azx_print_ssp_regs(struct sst_dsp_ctx *ctx,
 	dev_dbg(ctx->dev, "ssioc\t\t %x\n", regs->hda_ssioc);
 }
 
-static int azx_find_ssp_clk_divisor(struct sst_dsp_ctx *ctx, int fs,
+static int azx_find_ssp_clk_divisor(struct ssth_lib *ctx, int fs,
 			int slots, int s_fmt, int *div, int *dummy_bits)
 {
 	int divisor, mod;
@@ -190,7 +195,7 @@ static int azx_find_ssp_clk_divisor(struct sst_dsp_ctx *ctx, int fs,
 
 	return -EINVAL;
 }
-int azx_calculate_ssp_regs(struct sst_dsp_ctx *ctx, struct azx_dai_config *cfg,
+int hda_calculate_ssp_regs(struct ssth_lib *ctx, struct hda_dai_config *cfg,
 						void *ssp_regs)
 {
 	struct hda_ssp_regs regs;
@@ -198,7 +203,7 @@ int azx_calculate_ssp_regs(struct sst_dsp_ctx *ctx, struct azx_dai_config *cfg,
 	int div, dummy;
 	int dss, edss;
 	int edmystop, dmystop;
-	struct azx_ssp_dai_config *ssp_cfg = &cfg->ssp_dai_config;
+	struct hda_ssp_dai_config *ssp_cfg = &cfg->ssp_dai_config;
 
 	azx_set_default_ssp_regs_v1(&regs);
 	dev_dbg(ctx->dev, "Default value of registers set to:\n");
sound/soc/hda/hda_skl.h +75 -0

91 lines not on this page · raw message

Signature · 1 line
1.7.9.5