Linux-ARM-MSM Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio
@ 2020-02-07 20:50 Adam Serbinski
  2020-02-07 20:50 ` [PATCH 1/8] ASoC: qdsp6: dt-bindings: Add q6afe pcm dt binding Adam Serbinski
                   ` (8 more replies)
  0 siblings, 9 replies; 41+ messages in thread
From: Adam Serbinski @ 2020-02-07 20:50 UTC (permalink / raw)
  To: Mark Brown, Srini Kandagatla, Rob Herring, Bjorn Andersson
  Cc: Adam Serbinski, Andy Gross, Mark Rutland, Liam Girdwood,
	Patrick Lai, Banajit Goswami, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, linux-arm-msm, devicetree, linux-kernel

This patch set implements PCM audio support in qdsp6 and
PCM and MI2S in apq8096/db820c to enable use of bluetooth
audio codec and external MI2S port on db820c.

The db820c uses qca6174a for bluetooth, which by default
is configured to use what qualcomm refers to as "PCM"
format, which is a variation of TDM.

CC: Andy Gross <agross@kernel.org>
CC: Mark Rutland <mark.rutland@arm.com>
CC: Liam Girdwood <lgirdwood@gmail.com>
CC: Patrick Lai <plai@codeaurora.org>
CC: Banajit Goswami <bgoswami@codeaurora.org>
CC: Jaroslav Kysela <perex@perex.cz>
CC: Takashi Iwai <tiwai@suse.com>
CC: alsa-devel@alsa-project.org
CC: linux-arm-msm@vger.kernel.org
CC: devicetree@vger.kernel.org
CC: linux-kernel@vger.kernel.org

Adam Serbinski (8):
  ASoC: qdsp6: dt-bindings: Add q6afe pcm dt binding
  ASoC: qdsp6: q6afe: add support to pcm ports
  ASoC: qdsp6: q6afe-dai: add support to pcm port dais
  ASoC: qdsp6: q6routing: add pcm port routing
  ASoC: qcom: apq8096: add support for primary and quaternary I2S/PCM
  ASoC: qcom/common: Use snd-soc-dummy-dai when codec is not specified
  dts: msm8996/db820c: enable primary pcm and quaternary i2s
  ASoC: qcom: apq8096: add kcontrols to set PCM rate

 arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi | 113 +++++++++
 arch/arm64/boot/dts/qcom/msm8996-pins.dtsi   | 162 ++++++++++++
 include/dt-bindings/sound/qcom,q6afe.h       |   8 +
 sound/soc/qcom/apq8096.c                     | 172 +++++++++++--
 sound/soc/qcom/common.c                      |  22 +-
 sound/soc/qcom/qdsp6/q6afe-dai.c             | 198 ++++++++++++++-
 sound/soc/qcom/qdsp6/q6afe.c                 | 246 +++++++++++++++++++
 sound/soc/qcom/qdsp6/q6afe.h                 |   9 +-
 sound/soc/qcom/qdsp6/q6routing.c             |  44 ++++
 9 files changed, 953 insertions(+), 21 deletions(-)

-- 
2.21.1


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH 1/8] ASoC: qdsp6: dt-bindings: Add q6afe pcm dt binding
  2020-02-07 20:50 [PATCH 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio Adam Serbinski
@ 2020-02-07 20:50 ` Adam Serbinski
  2020-02-07 20:50 ` [PATCH 2/8] ASoC: qdsp6: q6afe: add support to pcm ports Adam Serbinski
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 41+ messages in thread
From: Adam Serbinski @ 2020-02-07 20:50 UTC (permalink / raw)
  To: Mark Brown, Srini Kandagatla, Rob Herring, Bjorn Andersson
  Cc: Adam Serbinski, Andy Gross, Mark Rutland, Liam Girdwood,
	Patrick Lai, Banajit Goswami, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, linux-arm-msm, devicetree, linux-kernel

This patch adds bindings required for PCM ports on AFE.

Signed-off-by: Adam Serbinski <adam@serbinski.com>
CC: Andy Gross <agross@kernel.org>
CC: Mark Rutland <mark.rutland@arm.com>
CC: Liam Girdwood <lgirdwood@gmail.com>
CC: Patrick Lai <plai@codeaurora.org>
CC: Banajit Goswami <bgoswami@codeaurora.org>
CC: Jaroslav Kysela <perex@perex.cz>
CC: Takashi Iwai <tiwai@suse.com>
CC: alsa-devel@alsa-project.org
CC: linux-arm-msm@vger.kernel.org
CC: devicetree@vger.kernel.org
CC: linux-kernel@vger.kernel.org
---
 include/dt-bindings/sound/qcom,q6afe.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/dt-bindings/sound/qcom,q6afe.h b/include/dt-bindings/sound/qcom,q6afe.h
index 1df06f8ad5c3..f3a435a112cb 100644
--- a/include/dt-bindings/sound/qcom,q6afe.h
+++ b/include/dt-bindings/sound/qcom,q6afe.h
@@ -107,6 +107,14 @@
 #define QUINARY_TDM_RX_7	102
 #define QUINARY_TDM_TX_7	103
 #define DISPLAY_PORT_RX		104
+#define PRIMARY_PCM_RX		105
+#define PRIMARY_PCM_TX		106
+#define SECONDARY_PCM_RX	107
+#define SECONDARY_PCM_TX	108
+#define TERTIARY_PCM_RX		109
+#define TERTIARY_PCM_TX		110
+#define QUATERNARY_PCM_RX	111
+#define QUATERNARY_PCM_TX	112
 
 #endif /* __DT_BINDINGS_Q6_AFE_H__ */
 
-- 
2.21.1


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH 2/8] ASoC: qdsp6: q6afe: add support to pcm ports
  2020-02-07 20:50 [PATCH 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio Adam Serbinski
  2020-02-07 20:50 ` [PATCH 1/8] ASoC: qdsp6: dt-bindings: Add q6afe pcm dt binding Adam Serbinski
@ 2020-02-07 20:50 ` Adam Serbinski
  2020-02-07 20:50 ` [PATCH 3/8] ASoC: qdsp6: q6afe-dai: add support to pcm port dais Adam Serbinski
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 41+ messages in thread
From: Adam Serbinski @ 2020-02-07 20:50 UTC (permalink / raw)
  To: Mark Brown, Srini Kandagatla, Rob Herring, Bjorn Andersson
  Cc: Adam Serbinski, Andy Gross, Mark Rutland, Liam Girdwood,
	Patrick Lai, Banajit Goswami, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, linux-arm-msm, devicetree, linux-kernel

This patch adds support to pcm ports in AFE.

Signed-off-by: Adam Serbinski <adam@serbinski.com>
CC: Andy Gross <agross@kernel.org>
CC: Mark Rutland <mark.rutland@arm.com>
CC: Liam Girdwood <lgirdwood@gmail.com>
CC: Patrick Lai <plai@codeaurora.org>
CC: Banajit Goswami <bgoswami@codeaurora.org>
CC: Jaroslav Kysela <perex@perex.cz>
CC: Takashi Iwai <tiwai@suse.com>
CC: alsa-devel@alsa-project.org
CC: linux-arm-msm@vger.kernel.org
CC: devicetree@vger.kernel.org
CC: linux-kernel@vger.kernel.org
---
 sound/soc/qcom/qdsp6/q6afe.c | 246 +++++++++++++++++++++++++++++++++++
 sound/soc/qcom/qdsp6/q6afe.h |   9 +-
 2 files changed, 254 insertions(+), 1 deletion(-)

diff --git a/sound/soc/qcom/qdsp6/q6afe.c b/sound/soc/qcom/qdsp6/q6afe.c
index e0945f7a58c8..b53ad14a78fd 100644
--- a/sound/soc/qcom/qdsp6/q6afe.c
+++ b/sound/soc/qcom/qdsp6/q6afe.c
@@ -40,6 +40,7 @@
 
 #define AFE_PARAM_ID_SLIMBUS_CONFIG    0x00010212
 #define AFE_PARAM_ID_I2S_CONFIG	0x0001020D
+#define AFE_PARAM_ID_PCM_CONFIG        0x0001020E
 #define AFE_PARAM_ID_TDM_CONFIG	0x0001029D
 #define AFE_PARAM_ID_PORT_SLOT_MAPPING_CONFIG	0x00010297
 
@@ -117,6 +118,15 @@
 #define AFE_PORT_ID_QUATERNARY_MI2S_RX      0x1006
 #define AFE_PORT_ID_QUATERNARY_MI2S_TX      0x1007
 
+#define AFE_PORT_ID_PRIMARY_PCM_RX          0x100A
+#define AFE_PORT_ID_PRIMARY_PCM_TX          0x100B
+#define AFE_PORT_ID_SECONDARY_PCM_RX        0x100C
+#define AFE_PORT_ID_SECONDARY_PCM_TX        0x100D
+#define AFE_PORT_ID_TERTIARY_PCM_RX         0x1012
+#define AFE_PORT_ID_TERTIARY_PCM_TX         0x1013
+#define AFE_PORT_ID_QUATERNARY_PCM_RX       0x1014
+#define AFE_PORT_ID_QUATERNARY_PCM_TX       0x1015
+
 /* Start of the range of port IDs for TDM devices. */
 #define AFE_PORT_ID_TDM_PORT_RANGE_START	0x9000
 
@@ -421,6 +431,166 @@ struct afe_digital_clk_cfg {
 	u16                  reserved;
 } __packed;
 
+#define AFE_API_VERSION_PCM_CONFIG	0x1
+/* Enumeration for the auxiliary PCM synchronization signal
+ * provided by an external source.
+ */
+
+#define AFE_PORT_PCM_SYNC_SRC_EXTERNAL 0x0
+/*	Enumeration for the auxiliary PCM synchronization signal
+ * provided by an internal source.
+ */
+#define AFE_PORT_PCM_SYNC_SRC_INTERNAL  0x1
+/*	Enumeration for the PCM configuration aux_mode parameter,
+ * which configures the auxiliary PCM interface to use
+ * short synchronization.
+ */
+#define AFE_PORT_PCM_AUX_MODE_PCM  0x0
+/*
+ * Enumeration for the PCM configuration aux_mode parameter,
+ * which configures the auxiliary PCM interface to use long
+ * synchronization.
+ */
+#define AFE_PORT_PCM_AUX_MODE_AUX    0x1
+/*
+ * Enumeration for setting the PCM configuration frame to 8.
+ */
+#define AFE_PORT_PCM_BITS_PER_FRAME_8  0x0
+/*
+ * Enumeration for setting the PCM configuration frame to 16.
+ */
+#define AFE_PORT_PCM_BITS_PER_FRAME_16   0x1
+
+/*	Enumeration for setting the PCM configuration frame to 32.*/
+#define AFE_PORT_PCM_BITS_PER_FRAME_32 0x2
+
+/*	Enumeration for setting the PCM configuration frame to 64.*/
+#define AFE_PORT_PCM_BITS_PER_FRAME_64   0x3
+
+/*	Enumeration for setting the PCM configuration frame to 128.*/
+#define AFE_PORT_PCM_BITS_PER_FRAME_128 0x4
+
+/*	Enumeration for setting the PCM configuration frame to 256.*/
+#define AFE_PORT_PCM_BITS_PER_FRAME_256 0x5
+
+/*	Enumeration for setting the PCM configuration
+ * quantype parameter to A-law with no padding.
+ */
+#define AFE_PORT_PCM_ALAW_NOPADDING 0x0
+
+/* Enumeration for setting the PCM configuration quantype
+ * parameter to mu-law with no padding.
+ */
+#define AFE_PORT_PCM_MULAW_NOPADDING 0x1
+/*	Enumeration for setting the PCM configuration quantype
+ * parameter to linear with no padding.
+ */
+#define AFE_PORT_PCM_LINEAR_NOPADDING 0x2
+/*	Enumeration for setting the PCM configuration quantype
+ * parameter to A-law with padding.
+ */
+#define AFE_PORT_PCM_ALAW_PADDING  0x3
+/*	Enumeration for setting the PCM configuration quantype
+ * parameter to mu-law with padding.
+ */
+#define AFE_PORT_PCM_MULAW_PADDING 0x4
+/*	Enumeration for setting the PCM configuration quantype
+ * parameter to linear with padding.
+ */
+#define AFE_PORT_PCM_LINEAR_PADDING 0x5
+/*	Enumeration for disabling the PCM configuration
+ * ctrl_data_out_enable parameter.
+ * The PCM block is the only master.
+ */
+#define AFE_PORT_PCM_CTRL_DATA_OE_DISABLE 0x0
+/*
+ * Enumeration for enabling the PCM configuration
+ * ctrl_data_out_enable parameter. The PCM block shares
+ * the signal with other masters.
+ */
+#define AFE_PORT_PCM_CTRL_DATA_OE_ENABLE  0x1
+
+/*  Payload of the #AFE_PARAM_ID_PCM_CONFIG command's
+ * (PCM configuration parameter).
+ */
+
+struct afe_param_id_pcm_cfg {
+	u32                  pcm_cfg_minor_version;
+/* Minor version used for tracking the version of the AUX PCM
+ * configuration interface.
+ * Supported values: #AFE_API_VERSION_PCM_CONFIG
+ */
+
+	u16                  aux_mode;
+/* PCM synchronization setting.
+ * Supported values:
+ * - #AFE_PORT_PCM_AUX_MODE_PCM
+ * - #AFE_PORT_PCM_AUX_MODE_AUX
+ */
+
+	u16                  sync_src;
+/* Synchronization source.
+ * Supported values:
+ * - #AFE_PORT_PCM_SYNC_SRC_EXTERNAL
+ * - #AFE_PORT_PCM_SYNC_SRC_INTERNAL
+ */
+
+	u16                  frame_setting;
+/* Number of bits per frame.
+ * Supported values:
+ * - #AFE_PORT_PCM_BITS_PER_FRAME_8
+ * - #AFE_PORT_PCM_BITS_PER_FRAME_16
+ * - #AFE_PORT_PCM_BITS_PER_FRAME_32
+ * - #AFE_PORT_PCM_BITS_PER_FRAME_64
+ * - #AFE_PORT_PCM_BITS_PER_FRAME_128
+ * - #AFE_PORT_PCM_BITS_PER_FRAME_256
+ */
+
+	u16                  quantype;
+/* PCM quantization type.
+ * Supported values:
+ * - #AFE_PORT_PCM_ALAW_NOPADDING
+ * - #AFE_PORT_PCM_MULAW_NOPADDING
+ * - #AFE_PORT_PCM_LINEAR_NOPADDING
+ * - #AFE_PORT_PCM_ALAW_PADDING
+ * - #AFE_PORT_PCM_MULAW_PADDING
+ * - #AFE_PORT_PCM_LINEAR_PADDING
+ */
+
+	u16                  ctrl_data_out_enable;
+/* Specifies whether the PCM block shares the data-out
+ * signal to the drive with other masters.
+ * Supported values:
+ * - #AFE_PORT_PCM_CTRL_DATA_OE_DISABLE
+ * - #AFE_PORT_PCM_CTRL_DATA_OE_ENABLE
+ */
+		u16                  reserved;
+	/* This field must be set to zero. */
+
+	u32                  sample_rate;
+/* Sampling rate of the port.
+ * Supported values:
+ * - #AFE_PORT_SAMPLE_RATE_8K
+ * - #AFE_PORT_SAMPLE_RATE_16K
+ */
+
+	u16                  bit_width;
+/* Bit width of the sample.
+ * Supported values: 16
+ */
+
+	u16                  num_channels;
+/* Number of channels.
+ * Supported values: 1 to 4
+ */
+
+	u16                  slot_number_mapping[4];
+/* Specifies the slot number for the each channel in
+ * multi channel scenario.
+ * Supported values: 1 to 32
+ */
+} __packed;
+
 struct afe_param_id_i2s_cfg {
 	u32	i2s_cfg_minor_version;
 	u16	bit_width;
@@ -452,6 +622,7 @@ union afe_port_config {
 	struct afe_param_id_hdmi_multi_chan_audio_cfg hdmi_multi_ch;
 	struct afe_param_id_slimbus_cfg           slim_cfg;
 	struct afe_param_id_i2s_cfg	i2s_cfg;
+	struct afe_param_id_pcm_cfg	pcm_cfg;
 	struct afe_param_id_tdm_cfg	tdm_cfg;
 } __packed;
 
@@ -707,6 +878,22 @@ static struct afe_port_map port_maps[AFE_PORT_MAX] = {
 				QUINARY_TDM_TX_7, 0, 1},
 	[DISPLAY_PORT_RX] = { AFE_PORT_ID_HDMI_OVER_DP_RX,
 				DISPLAY_PORT_RX, 1, 1},
+	[PRIMARY_PCM_RX] = { AFE_PORT_ID_PRIMARY_PCM_RX,
+				PRIMARY_PCM_RX, 1, 1},
+	[PRIMARY_PCM_TX] = { AFE_PORT_ID_PRIMARY_PCM_TX,
+				PRIMARY_PCM_RX, 0, 1},
+	[SECONDARY_PCM_RX] = { AFE_PORT_ID_SECONDARY_PCM_RX,
+				SECONDARY_PCM_RX, 1, 1},
+	[SECONDARY_PCM_TX] = { AFE_PORT_ID_SECONDARY_PCM_TX,
+				SECONDARY_PCM_TX, 0, 1},
+	[TERTIARY_PCM_RX] = { AFE_PORT_ID_TERTIARY_PCM_RX,
+				TERTIARY_PCM_RX, 1, 1},
+	[TERTIARY_PCM_TX] = { AFE_PORT_ID_TERTIARY_PCM_TX,
+				TERTIARY_PCM_TX, 0, 1},
+	[QUATERNARY_PCM_RX] = { AFE_PORT_ID_QUATERNARY_PCM_RX,
+				QUATERNARY_PCM_RX, 1, 1},
+	[QUATERNARY_PCM_TX] = { AFE_PORT_ID_QUATERNARY_PCM_TX,
+				QUATERNARY_PCM_TX, 0, 1},
 };
 
 static void q6afe_port_free(struct kref *ref)
@@ -993,6 +1180,7 @@ int q6afe_port_set_sysclk(struct q6afe_port *port, int clk_id,
 		break;
 	case Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT ... Q6AFE_LPASS_CLK_ID_QUI_MI2S_OSR:
 	case Q6AFE_LPASS_CLK_ID_MCLK_1 ... Q6AFE_LPASS_CLK_ID_INT_MCLK_1:
+	/* TDM cases overlap with PCM */
 	case Q6AFE_LPASS_CLK_ID_PRI_TDM_IBIT ... Q6AFE_LPASS_CLK_ID_QUIN_TDM_EBIT:
 		cset.clk_set_minor_version = AFE_API_VERSION_CLOCK_SET;
 		cset.clk_id = clk_id;
@@ -1145,6 +1333,54 @@ void q6afe_hdmi_port_prepare(struct q6afe_port *port,
 }
 EXPORT_SYMBOL_GPL(q6afe_hdmi_port_prepare);
 
+/**
+ * q6afe_pcm_port_prepare() - Prepare pcm afe port.
+ *
+ * @port: Instance of afe port
+ * @cfg: PCM configuration for the afe port
+ *
+ */
+int q6afe_pcm_port_prepare(struct q6afe_port *port, struct q6afe_pcm_cfg *cfg)
+{
+	union afe_port_config *pcfg = &port->port_cfg;
+
+	pcfg->pcm_cfg.pcm_cfg_minor_version = AFE_API_VERSION_PCM_CONFIG;
+	pcfg->pcm_cfg.aux_mode = AFE_PORT_PCM_AUX_MODE_PCM;
+
+	switch (cfg->fmt & SND_SOC_DAIFMT_MASTER_MASK) {
+	case SND_SOC_DAIFMT_CBS_CFS:
+		pcfg->pcm_cfg.sync_src = AFE_PORT_PCM_SYNC_SRC_INTERNAL;
+		break;
+	case SND_SOC_DAIFMT_CBM_CFM:
+		/* CPU is slave */
+		pcfg->pcm_cfg.sync_src = AFE_PORT_PCM_SYNC_SRC_EXTERNAL;
+		break;
+	default:
+		break;
+	}
+
+	switch (cfg->sample_rate) {
+	case 8000:
+		pcfg->pcm_cfg.frame_setting = AFE_PORT_PCM_BITS_PER_FRAME_128;
+		break;
+	case 16000:
+		pcfg->pcm_cfg.frame_setting = AFE_PORT_PCM_BITS_PER_FRAME_64;
+		break;
+	}
+	pcfg->pcm_cfg.quantype = AFE_PORT_PCM_LINEAR_NOPADDING;
+	pcfg->pcm_cfg.ctrl_data_out_enable = AFE_PORT_PCM_CTRL_DATA_OE_DISABLE;
+	pcfg->pcm_cfg.reserved = 0;
+	pcfg->pcm_cfg.sample_rate = cfg->sample_rate;
+
+	/* 16 bit mono */
+	pcfg->pcm_cfg.bit_width = 16;
+	pcfg->pcm_cfg.num_channels = 1;
+	pcfg->pcm_cfg.slot_number_mapping[0] = 1;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(q6afe_pcm_port_prepare);
+
 /**
  * q6afe_i2s_port_prepare() - Prepare i2s afe port.
  *
@@ -1417,6 +1653,16 @@ struct q6afe_port *q6afe_port_get_from_id(struct device *dev, int id)
 	case AFE_PORT_ID_QUATERNARY_MI2S_TX:
 		cfg_type = AFE_PARAM_ID_I2S_CONFIG;
 		break;
+	case AFE_PORT_ID_PRIMARY_PCM_RX:
+	case AFE_PORT_ID_PRIMARY_PCM_TX:
+	case AFE_PORT_ID_SECONDARY_PCM_RX:
+	case AFE_PORT_ID_SECONDARY_PCM_TX:
+	case AFE_PORT_ID_TERTIARY_PCM_RX:
+	case AFE_PORT_ID_TERTIARY_PCM_TX:
+	case AFE_PORT_ID_QUATERNARY_PCM_RX:
+	case AFE_PORT_ID_QUATERNARY_PCM_TX:
+		cfg_type = AFE_PARAM_ID_PCM_CONFIG;
+		break;
 	case AFE_PORT_ID_PRIMARY_TDM_RX ... AFE_PORT_ID_QUINARY_TDM_TX_7:
 		cfg_type = AFE_PARAM_ID_TDM_CONFIG;
 		break;
diff --git a/sound/soc/qcom/qdsp6/q6afe.h b/sound/soc/qcom/qdsp6/q6afe.h
index c7ed5422baff..c832be6d0ff5 100644
--- a/sound/soc/qcom/qdsp6/q6afe.h
+++ b/sound/soc/qcom/qdsp6/q6afe.h
@@ -5,7 +5,7 @@
 
 #include <dt-bindings/sound/qcom,q6afe.h>
 
-#define AFE_PORT_MAX		105
+#define AFE_PORT_MAX		113
 
 #define MSM_AFE_PORT_TYPE_RX 0
 #define MSM_AFE_PORT_TYPE_TX 1
@@ -170,6 +170,11 @@ struct q6afe_i2s_cfg {
 	int fmt;
 };
 
+struct q6afe_pcm_cfg {
+	u32	sample_rate;
+	int fmt;
+};
+
 struct q6afe_tdm_cfg {
 	u16	num_channels;
 	u32	sample_rate;
@@ -188,6 +193,7 @@ struct q6afe_port_config {
 	struct q6afe_hdmi_cfg hdmi;
 	struct q6afe_slim_cfg slim;
 	struct q6afe_i2s_cfg i2s_cfg;
+	struct q6afe_pcm_cfg pcm_cfg;
 	struct q6afe_tdm_cfg tdm;
 };
 
@@ -203,6 +209,7 @@ void q6afe_hdmi_port_prepare(struct q6afe_port *port,
 void q6afe_slim_port_prepare(struct q6afe_port *port,
 			  struct q6afe_slim_cfg *cfg);
 int q6afe_i2s_port_prepare(struct q6afe_port *port, struct q6afe_i2s_cfg *cfg);
+int q6afe_pcm_port_prepare(struct q6afe_port *port, struct q6afe_pcm_cfg *cfg);
 void q6afe_tdm_port_prepare(struct q6afe_port *port, struct q6afe_tdm_cfg *cfg);
 
 int q6afe_port_set_sysclk(struct q6afe_port *port, int clk_id,
-- 
2.21.1


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH 3/8] ASoC: qdsp6: q6afe-dai: add support to pcm port dais
  2020-02-07 20:50 [PATCH 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio Adam Serbinski
  2020-02-07 20:50 ` [PATCH 1/8] ASoC: qdsp6: dt-bindings: Add q6afe pcm dt binding Adam Serbinski
  2020-02-07 20:50 ` [PATCH 2/8] ASoC: qdsp6: q6afe: add support to pcm ports Adam Serbinski
@ 2020-02-07 20:50 ` Adam Serbinski
  2020-02-07 20:50 ` [PATCH 4/8] ASoC: qdsp6: q6routing: add pcm port routing Adam Serbinski
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 41+ messages in thread
From: Adam Serbinski @ 2020-02-07 20:50 UTC (permalink / raw)
  To: Mark Brown, Srini Kandagatla, Rob Herring, Bjorn Andersson
  Cc: Adam Serbinski, Andy Gross, Mark Rutland, Liam Girdwood,
	Patrick Lai, Banajit Goswami, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, linux-arm-msm, devicetree, linux-kernel

This patch adds support of AFE DAI for PCM port.

Signed-off-by: Adam Serbinski <adam@serbinski.com>
CC: Andy Gross <agross@kernel.org>
CC: Mark Rutland <mark.rutland@arm.com>
CC: Liam Girdwood <lgirdwood@gmail.com>
CC: Patrick Lai <plai@codeaurora.org>
CC: Banajit Goswami <bgoswami@codeaurora.org>
CC: Jaroslav Kysela <perex@perex.cz>
CC: Takashi Iwai <tiwai@suse.com>
CC: alsa-devel@alsa-project.org
CC: linux-arm-msm@vger.kernel.org
CC: devicetree@vger.kernel.org
CC: linux-kernel@vger.kernel.org
---
 sound/soc/qcom/qdsp6/q6afe-dai.c | 198 ++++++++++++++++++++++++++++++-
 1 file changed, 197 insertions(+), 1 deletion(-)

diff --git a/sound/soc/qcom/qdsp6/q6afe-dai.c b/sound/soc/qcom/qdsp6/q6afe-dai.c
index c1a7624eaf17..23b29591ef47 100644
--- a/sound/soc/qcom/qdsp6/q6afe-dai.c
+++ b/sound/soc/qcom/qdsp6/q6afe-dai.c
@@ -151,6 +151,28 @@ static int q6hdmi_hw_params(struct snd_pcm_substream *substream,
 	return 0;
 }
 
+static int q6pcm_hw_params(struct snd_pcm_substream *substream,
+			   struct snd_pcm_hw_params *params,
+			   struct snd_soc_dai *dai)
+{
+	struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
+	struct q6afe_pcm_cfg *pcm = &dai_data->port_config[dai->id].pcm_cfg;
+
+	pcm->sample_rate = params_rate(params);
+
+	return 0;
+}
+
+static int q6pcm_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
+{
+	struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
+	struct q6afe_pcm_cfg *pcm = &dai_data->port_config[dai->id].pcm_cfg;
+
+	pcm->fmt = fmt;
+
+	return 0;
+}
+
 static int q6i2s_hw_params(struct snd_pcm_substream *substream,
 			   struct snd_pcm_hw_params *params,
 			   struct snd_soc_dai *dai)
@@ -358,6 +380,15 @@ static int q6afe_dai_prepare(struct snd_pcm_substream *substream,
 			return rc;
 		}
 		break;
+	case PRIMARY_PCM_RX ... QUATERNARY_PCM_TX:
+		rc = q6afe_pcm_port_prepare(dai_data->port[dai->id],
+				&dai_data->port_config[dai->id].pcm_cfg);
+		if (rc < 0) {
+			dev_err(dai->dev, "fail to prepare AFE port %x\n",
+				dai->id);
+			return rc;
+		}
+		break;
 	case PRIMARY_TDM_RX_0 ... QUINARY_TDM_TX_7:
 		q6afe_tdm_port_prepare(dai_data->port[dai->id],
 					&dai_data->port_config[dai->id].tdm);
@@ -429,11 +460,32 @@ static int q6afe_mi2s_set_sysclk(struct snd_soc_dai *dai,
 					     Q6AFE_LPASS_CLK_ROOT_DEFAULT,
 					     freq, dir);
 	case Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT ... Q6AFE_LPASS_CLK_ID_QUI_MI2S_OSR:
+	case Q6AFE_LPASS_CLK_ID_PRI_PCM_IBIT ... Q6AFE_LPASS_CLK_ID_QUI_PCM_OSR:
 	case Q6AFE_LPASS_CLK_ID_MCLK_1 ... Q6AFE_LPASS_CLK_ID_INT_MCLK_1:
 		return q6afe_port_set_sysclk(port, clk_id,
 					     Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
 					     Q6AFE_LPASS_CLK_ROOT_DEFAULT,
 					     freq, dir);
+	}
+
+	return 0;
+}
+
+static int q6afe_tdm_set_sysclk(struct snd_soc_dai *dai,
+		int clk_id, unsigned int freq, int dir)
+{
+	struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
+	struct q6afe_port *port = dai_data->port[dai->id];
+
+	switch (clk_id) {
+	case LPAIF_DIG_CLK:
+		return q6afe_port_set_sysclk(port, clk_id, 0, 5, freq, dir);
+	case LPAIF_BIT_CLK:
+	case LPAIF_OSR_CLK:
+		return q6afe_port_set_sysclk(port, clk_id,
+					     Q6AFE_LPASS_CLK_SRC_INTERNAL,
+					     Q6AFE_LPASS_CLK_ROOT_DEFAULT,
+					     freq, dir);
 	case Q6AFE_LPASS_CLK_ID_PRI_TDM_IBIT ... Q6AFE_LPASS_CLK_ID_QUIN_TDM_EBIT:
 		return q6afe_port_set_sysclk(port, clk_id,
 					     Q6AFE_LPASS_CLK_ATTRIBUTE_INVERT_COUPLE_NO,
@@ -468,6 +520,11 @@ static const struct snd_soc_dapm_route q6afe_dapm_routes[] = {
 	{"Tertiary MI2S Playback", NULL, "TERT_MI2S_RX"},
 	{"Quaternary MI2S Playback", NULL, "QUAT_MI2S_RX"},
 
+	{"Primary PCM Playback", NULL, "PRI_PCM_RX"},
+	{"Secondary PCM Playback", NULL, "SEC_PCM_RX"},
+	{"Tertiary PCM Playback", NULL, "TERT_PCM_RX"},
+	{"Quaternary PCM Playback", NULL, "QUAT_PCM_RX"},
+
 	{"Primary TDM0 Playback", NULL, "PRIMARY_TDM_RX_0"},
 	{"Primary TDM1 Playback", NULL, "PRIMARY_TDM_RX_1"},
 	{"Primary TDM2 Playback", NULL, "PRIMARY_TDM_RX_2"},
@@ -562,6 +619,11 @@ static const struct snd_soc_dapm_route q6afe_dapm_routes[] = {
 	{"PRI_MI2S_TX", NULL, "Primary MI2S Capture"},
 	{"SEC_MI2S_TX", NULL, "Secondary MI2S Capture"},
 	{"QUAT_MI2S_TX", NULL, "Quaternary MI2S Capture"},
+
+	{"PRI_PCM_TX", NULL, "Primary PCM Capture"},
+	{"SEC_PCM_TX", NULL, "Secondary PCM Capture"},
+	{"TERT_PCM_TX", NULL, "Tertiary PCM Capture"},
+	{"QUAT_PCM_TX", NULL, "Quaternary PCM Capture"},
 };
 
 static const struct snd_soc_dai_ops q6hdmi_ops = {
@@ -578,6 +640,14 @@ static const struct snd_soc_dai_ops q6i2s_ops = {
 	.set_sysclk	= q6afe_mi2s_set_sysclk,
 };
 
+static const struct snd_soc_dai_ops q6pcm_ops = {
+	.prepare	= q6afe_dai_prepare,
+	.hw_params	= q6pcm_hw_params,
+	.set_fmt	= q6pcm_set_fmt,
+	.shutdown	= q6afe_dai_shutdown,
+	.set_sysclk	= q6afe_mi2s_set_sysclk,
+};
+
 static const struct snd_soc_dai_ops q6slim_ops = {
 	.prepare	= q6afe_dai_prepare,
 	.hw_params	= q6slim_hw_params,
@@ -588,7 +658,7 @@ static const struct snd_soc_dai_ops q6slim_ops = {
 static const struct snd_soc_dai_ops q6tdm_ops = {
 	.prepare	= q6afe_dai_prepare,
 	.shutdown	= q6afe_dai_shutdown,
-	.set_sysclk	= q6afe_mi2s_set_sysclk,
+	.set_sysclk	= q6afe_tdm_set_sysclk,
 	.set_tdm_slot     = q6tdm_set_tdm_slot,
 	.set_channel_map  = q6tdm_set_channel_map,
 	.hw_params        = q6tdm_hw_params,
@@ -1012,6 +1082,115 @@ static struct snd_soc_dai_driver q6afe_dais[] = {
 		.ops = &q6i2s_ops,
 		.probe = msm_dai_q6_dai_probe,
 		.remove = msm_dai_q6_dai_remove,
+	}, {
+		.playback = {
+			.stream_name = "Primary PCM Playback",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE |
+				   SNDRV_PCM_FMTBIT_S24_LE,
+			.rate_min =     8000,
+			.rate_max =     16000,
+		},
+		.id = PRIMARY_PCM_RX,
+		.name = "PRI_PCM_RX",
+		.ops = &q6pcm_ops,
+		.probe = msm_dai_q6_dai_probe,
+		.remove = msm_dai_q6_dai_remove,
+	}, {
+		.capture = {
+			.stream_name = "Primary PCM Capture",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE |
+				   SNDRV_PCM_FMTBIT_S24_LE,
+			.rate_min =     8000,
+			.rate_max =     16000,
+		},
+		.id = PRIMARY_PCM_TX,
+		.name = "PRI_PCM_TX",
+		.ops = &q6pcm_ops,
+		.probe = msm_dai_q6_dai_probe,
+		.remove = msm_dai_q6_dai_remove,
+	}, {
+		.playback = {
+			.stream_name = "Secondary PCM Playback",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE,
+			.rate_min =     8000,
+			.rate_max =     16000,
+		},
+		.name = "SEC_PCM_RX",
+		.id = SECONDARY_PCM_RX,
+		.ops = &q6pcm_ops,
+		.probe = msm_dai_q6_dai_probe,
+		.remove = msm_dai_q6_dai_remove,
+	}, {
+		.capture = {
+			.stream_name = "Secondary PCM Capture",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE |
+				   SNDRV_PCM_FMTBIT_S24_LE,
+			.rate_min =     8000,
+			.rate_max =     16000,
+		},
+		.id = SECONDARY_PCM_TX,
+		.name = "SEC_PCM_TX",
+		.ops = &q6pcm_ops,
+		.probe = msm_dai_q6_dai_probe,
+		.remove = msm_dai_q6_dai_remove,
+	}, {
+		.playback = {
+			.stream_name = "Tertiary PCM Playback",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE,
+			.rate_min =     8000,
+			.rate_max =     16000,
+		},
+		.name = "TERT_PCM_RX",
+		.id = TERTIARY_PCM_RX,
+		.ops = &q6pcm_ops,
+		.probe = msm_dai_q6_dai_probe,
+		.remove = msm_dai_q6_dai_remove,
+	}, {
+		.capture = {
+			.stream_name = "Tertiary PCM Capture",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE |
+				   SNDRV_PCM_FMTBIT_S24_LE,
+			.rate_min =     8000,
+			.rate_max =     16000,
+		},
+		.id = TERTIARY_PCM_TX,
+		.name = "TERT_PCM_TX",
+		.ops = &q6pcm_ops,
+		.probe = msm_dai_q6_dai_probe,
+		.remove = msm_dai_q6_dai_remove,
+	}, {
+		.playback = {
+			.stream_name = "Quaternary PCM Playback",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE,
+			.rate_min =     8000,
+			.rate_max =     16000,
+		},
+		.name = "QUAT_PCM_RX",
+		.id = QUATERNARY_PCM_RX,
+		.ops = &q6pcm_ops,
+		.probe = msm_dai_q6_dai_probe,
+		.remove = msm_dai_q6_dai_remove,
+	}, {
+		.capture = {
+			.stream_name = "Quaternary PCM Capture",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE |
+				   SNDRV_PCM_FMTBIT_S24_LE,
+			.rate_min =     8000,
+			.rate_max =     16000,
+		},
+		.id = QUATERNARY_PCM_TX,
+		.name = "QUAT_PCM_TX",
+		.ops = &q6pcm_ops,
+		.probe = msm_dai_q6_dai_probe,
+		.remove = msm_dai_q6_dai_remove,
 	},
 	Q6AFE_TDM_PB_DAI("Primary", 0, PRIMARY_TDM_RX_0),
 	Q6AFE_TDM_PB_DAI("Primary", 1, PRIMARY_TDM_RX_1),
@@ -1169,6 +1348,23 @@ static const struct snd_soc_dapm_widget q6afe_dai_widgets[] = {
 	SND_SOC_DAPM_AIF_OUT("PRI_MI2S_TX", NULL,
 						0, 0, 0, 0),
 
+	SND_SOC_DAPM_AIF_IN("QUAT_PCM_RX", NULL,
+			    0, 0, 0, 0),
+	SND_SOC_DAPM_AIF_OUT("QUAT_PCM_TX", NULL,
+			     0, 0, 0, 0),
+	SND_SOC_DAPM_AIF_IN("TERT_PCM_RX", NULL,
+			    0, 0, 0, 0),
+	SND_SOC_DAPM_AIF_OUT("TERT_PCM_TX", NULL,
+			     0, 0, 0, 0),
+	SND_SOC_DAPM_AIF_IN("SEC_PCM_RX", NULL,
+			    0, 0, 0, 0),
+	SND_SOC_DAPM_AIF_OUT("SEC_PCM_TX", NULL,
+			     0, 0, 0, 0),
+	SND_SOC_DAPM_AIF_IN("PRI_PCM_RX", NULL,
+			    0, 0, 0, 0),
+	SND_SOC_DAPM_AIF_OUT("PRI_PCM_TX", NULL,
+			     0, 0, 0, 0),
+
 	SND_SOC_DAPM_AIF_IN("PRIMARY_TDM_RX_0", NULL,
 			     0, 0, 0, 0),
 	SND_SOC_DAPM_AIF_IN("PRIMARY_TDM_RX_1", NULL,
-- 
2.21.1


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH 4/8] ASoC: qdsp6: q6routing: add pcm port routing
  2020-02-07 20:50 [PATCH 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio Adam Serbinski
                   ` (2 preceding siblings ...)
  2020-02-07 20:50 ` [PATCH 3/8] ASoC: qdsp6: q6afe-dai: add support to pcm port dais Adam Serbinski
@ 2020-02-07 20:50 ` Adam Serbinski
  2020-02-07 20:50 ` [PATCH 5/8] ASoC: qcom: apq8096: add support for primary and quaternary I2S/PCM Adam Serbinski
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 41+ messages in thread
From: Adam Serbinski @ 2020-02-07 20:50 UTC (permalink / raw)
  To: Mark Brown, Srini Kandagatla, Rob Herring, Bjorn Andersson
  Cc: Adam Serbinski, Andy Gross, Mark Rutland, Liam Girdwood,
	Patrick Lai, Banajit Goswami, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, linux-arm-msm, devicetree, linux-kernel

This patch adds support to PCM_PORT mixers required to
select path between ASM stream and AFE ports.

Signed-off-by: Adam Serbinski <adam@serbinski.com>
CC: Andy Gross <agross@kernel.org>
CC: Mark Rutland <mark.rutland@arm.com>
CC: Liam Girdwood <lgirdwood@gmail.com>
CC: Patrick Lai <plai@codeaurora.org>
CC: Banajit Goswami <bgoswami@codeaurora.org>
CC: Jaroslav Kysela <perex@perex.cz>
CC: Takashi Iwai <tiwai@suse.com>
CC: alsa-devel@alsa-project.org
CC: linux-arm-msm@vger.kernel.org
CC: devicetree@vger.kernel.org
CC: linux-kernel@vger.kernel.org
---
 sound/soc/qcom/qdsp6/q6routing.c | 44 ++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/sound/soc/qcom/qdsp6/q6routing.c b/sound/soc/qcom/qdsp6/q6routing.c
index 20724102e85a..3a81d2161707 100644
--- a/sound/soc/qcom/qdsp6/q6routing.c
+++ b/sound/soc/qcom/qdsp6/q6routing.c
@@ -67,6 +67,10 @@
 	{ mix_name, "SEC_MI2S_TX", "SEC_MI2S_TX" },	\
 	{ mix_name, "QUAT_MI2S_TX", "QUAT_MI2S_TX" },	\
 	{ mix_name, "TERT_MI2S_TX", "TERT_MI2S_TX" },		\
+	{ mix_name, "PRI_PCM_TX", "PRI_PCM_TX" },		\
+	{ mix_name, "SEC_PCM_TX", "SEC_PCM_TX" },		\
+	{ mix_name, "TERT_PCM_TX", "TERT_PCM_TX" },		\
+	{ mix_name, "QUAT_PCM_TX", "QUAT_PCM_TX" },		\
 	{ mix_name, "SLIMBUS_0_TX", "SLIMBUS_0_TX" },		\
 	{ mix_name, "SLIMBUS_1_TX", "SLIMBUS_1_TX" },		\
 	{ mix_name, "SLIMBUS_2_TX", "SLIMBUS_2_TX" },		\
@@ -128,6 +132,18 @@
 	SOC_SINGLE_EXT("QUAT_MI2S_TX", QUATERNARY_MI2S_TX,		\
 		id, 1, 0, msm_routing_get_audio_mixer,			\
 		msm_routing_put_audio_mixer),				\
+	SOC_SINGLE_EXT("PRI_PCM_TX", PRIMARY_PCM_TX,			\
+		id, 1, 0, msm_routing_get_audio_mixer,			\
+		msm_routing_put_audio_mixer),				\
+	SOC_SINGLE_EXT("SEC_PCM_TX", SECONDARY_PCM_TX,			\
+		id, 1, 0, msm_routing_get_audio_mixer,			\
+		msm_routing_put_audio_mixer),				\
+	SOC_SINGLE_EXT("TERT_PCM_TX", TERTIARY_PCM_TX,			\
+		id, 1, 0, msm_routing_get_audio_mixer,			\
+		msm_routing_put_audio_mixer),				\
+	SOC_SINGLE_EXT("QUAT_PCM_TX", QUATERNARY_PCM_TX,		\
+		id, 1, 0, msm_routing_get_audio_mixer,			\
+		msm_routing_put_audio_mixer),				\
 	SOC_SINGLE_EXT("SLIMBUS_0_TX", SLIMBUS_0_TX,			\
 		id, 1, 0, msm_routing_get_audio_mixer,			\
 		msm_routing_put_audio_mixer),				\
@@ -468,6 +484,18 @@ static const struct snd_kcontrol_new quaternary_mi2s_rx_mixer_controls[] = {
 static const struct snd_kcontrol_new tertiary_mi2s_rx_mixer_controls[] = {
 	Q6ROUTING_RX_MIXERS(TERTIARY_MI2S_RX) };
 
+static const struct snd_kcontrol_new primary_pcm_rx_mixer_controls[] = {
+	Q6ROUTING_RX_MIXERS(PRIMARY_PCM_RX) };
+
+static const struct snd_kcontrol_new secondary_pcm_rx_mixer_controls[] = {
+	Q6ROUTING_RX_MIXERS(SECONDARY_PCM_RX) };
+
+static const struct snd_kcontrol_new tertiary_pcm_rx_mixer_controls[] = {
+	Q6ROUTING_RX_MIXERS(TERTIARY_PCM_RX) };
+
+static const struct snd_kcontrol_new quaternary_pcm_rx_mixer_controls[] = {
+	Q6ROUTING_RX_MIXERS(QUATERNARY_PCM_RX) };
+
 static const struct snd_kcontrol_new slimbus_rx_mixer_controls[] = {
 	Q6ROUTING_RX_MIXERS(SLIMBUS_0_RX) };
 
@@ -695,6 +723,18 @@ static const struct snd_soc_dapm_widget msm_qdsp6_widgets[] = {
 	SND_SOC_DAPM_MIXER("TERT_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
 			   tertiary_mi2s_rx_mixer_controls,
 			   ARRAY_SIZE(tertiary_mi2s_rx_mixer_controls)),
+	SND_SOC_DAPM_MIXER("PRI_PCM_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
+			   primary_pcm_rx_mixer_controls,
+			   ARRAY_SIZE(primary_pcm_rx_mixer_controls)),
+	SND_SOC_DAPM_MIXER("SEC_PCM_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
+			   secondary_pcm_rx_mixer_controls,
+			   ARRAY_SIZE(secondary_pcm_rx_mixer_controls)),
+	SND_SOC_DAPM_MIXER("TERT_PCM_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
+			   tertiary_pcm_rx_mixer_controls,
+			   ARRAY_SIZE(tertiary_pcm_rx_mixer_controls)),
+	SND_SOC_DAPM_MIXER("QUAT_PCM_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
+			   quaternary_pcm_rx_mixer_controls,
+			   ARRAY_SIZE(quaternary_pcm_rx_mixer_controls)),
 	SND_SOC_DAPM_MIXER("PRIMARY_TDM_RX_0 Audio Mixer", SND_SOC_NOPM, 0, 0,
 				pri_tdm_rx_0_mixer_controls,
 				ARRAY_SIZE(pri_tdm_rx_0_mixer_controls)),
@@ -853,6 +893,10 @@ static const struct snd_soc_dapm_route intercon[] = {
 	Q6ROUTING_RX_DAPM_ROUTE("TERT_MI2S_RX Audio Mixer", "TERT_MI2S_RX"),
 	Q6ROUTING_RX_DAPM_ROUTE("SEC_MI2S_RX Audio Mixer", "SEC_MI2S_RX"),
 	Q6ROUTING_RX_DAPM_ROUTE("PRI_MI2S_RX Audio Mixer", "PRI_MI2S_RX"),
+	Q6ROUTING_RX_DAPM_ROUTE("PRI_PCM_RX Audio Mixer", "PRI_PCM_RX"),
+	Q6ROUTING_RX_DAPM_ROUTE("SEC_PCM_RX Audio Mixer", "SEC_PCM_RX"),
+	Q6ROUTING_RX_DAPM_ROUTE("TERT_PCM_RX Audio Mixer", "TERT_PCM_RX"),
+	Q6ROUTING_RX_DAPM_ROUTE("QUAT_PCM_RX Audio Mixer", "QUAT_PCM_RX"),
 	Q6ROUTING_RX_DAPM_ROUTE("PRIMARY_TDM_RX_0 Audio Mixer",
 				"PRIMARY_TDM_RX_0"),
 	Q6ROUTING_RX_DAPM_ROUTE("PRIMARY_TDM_RX_1 Audio Mixer",
-- 
2.21.1


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH 5/8] ASoC: qcom: apq8096: add support for primary and quaternary I2S/PCM
  2020-02-07 20:50 [PATCH 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio Adam Serbinski
                   ` (3 preceding siblings ...)
  2020-02-07 20:50 ` [PATCH 4/8] ASoC: qdsp6: q6routing: add pcm port routing Adam Serbinski
@ 2020-02-07 20:50 ` Adam Serbinski
  2020-02-07 20:50 ` [PATCH 6/8] ASoC: qcom/common: Use snd-soc-dummy-dai when codec is not specified Adam Serbinski
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 41+ messages in thread
From: Adam Serbinski @ 2020-02-07 20:50 UTC (permalink / raw)
  To: Mark Brown, Srini Kandagatla, Rob Herring, Bjorn Andersson
  Cc: Adam Serbinski, Andy Gross, Mark Rutland, Liam Girdwood,
	Patrick Lai, Banajit Goswami, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, linux-arm-msm, devicetree, linux-kernel

This adds support to primary and quarternary I2S and PCM ports.

Signed-off-by: Adam Serbinski <adam@serbinski.com>
CC: Andy Gross <agross@kernel.org>
CC: Mark Rutland <mark.rutland@arm.com>
CC: Liam Girdwood <lgirdwood@gmail.com>
CC: Patrick Lai <plai@codeaurora.org>
CC: Banajit Goswami <bgoswami@codeaurora.org>
CC: Jaroslav Kysela <perex@perex.cz>
CC: Takashi Iwai <tiwai@suse.com>
CC: alsa-devel@alsa-project.org
CC: linux-arm-msm@vger.kernel.org
CC: devicetree@vger.kernel.org
CC: linux-kernel@vger.kernel.org
---
 sound/soc/qcom/apq8096.c | 86 +++++++++++++++++++++++++++++++++-------
 1 file changed, 71 insertions(+), 15 deletions(-)

diff --git a/sound/soc/qcom/apq8096.c b/sound/soc/qcom/apq8096.c
index 94363fd6846a..1edcaa15234f 100644
--- a/sound/soc/qcom/apq8096.c
+++ b/sound/soc/qcom/apq8096.c
@@ -8,24 +8,13 @@
 #include <sound/soc-dapm.h>
 #include <sound/pcm.h>
 #include "common.h"
+#include "qdsp6/q6afe.h"
 
 #define SLIM_MAX_TX_PORTS 16
 #define SLIM_MAX_RX_PORTS 16
 #define WCD9335_DEFAULT_MCLK_RATE	9600000
-
-static int apq8096_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
-				      struct snd_pcm_hw_params *params)
-{
-	struct snd_interval *rate = hw_param_interval(params,
-					SNDRV_PCM_HW_PARAM_RATE);
-	struct snd_interval *channels = hw_param_interval(params,
-					SNDRV_PCM_HW_PARAM_CHANNELS);
-
-	rate->min = rate->max = 48000;
-	channels->min = channels->max = 2;
-
-	return 0;
-}
+#define MI2S_BCLK_RATE			1536000
+#define PCM_BCLK_RATE			1024000
 
 static int msm_snd_hw_params(struct snd_pcm_substream *substream,
 			     struct snd_pcm_hw_params *params)
@@ -33,10 +22,32 @@ static int msm_snd_hw_params(struct snd_pcm_substream *substream,
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
+	struct snd_interval *rate = hw_param_interval(params,
+					SNDRV_PCM_HW_PARAM_RATE);
+	struct snd_interval *channels = hw_param_interval(params,
+					SNDRV_PCM_HW_PARAM_CHANNELS);
 	u32 rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS];
 	u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
 	int ret = 0;
 
+	switch (cpu_dai->id) {
+	case PRIMARY_PCM_RX:
+	case PRIMARY_PCM_TX:
+	case QUATERNARY_PCM_RX:
+	case QUATERNARY_PCM_TX:
+		rate->min = 16000;
+		rate->max = 16000;
+		channels->min = 1;
+		channels->max = 1;
+		break;
+	default:
+		rate->min = 48000;
+		rate->max = 48000;
+		channels->min = 1;
+		channels->max = 2;
+		break;
+	}
+
 	ret = snd_soc_dai_get_channel_map(codec_dai,
 				&tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
 	if (ret != 0 && ret != -ENOTSUPP) {
@@ -60,8 +71,54 @@ static int msm_snd_hw_params(struct snd_pcm_substream *substream,
 	return ret;
 }
 
+static int msm_snd_startup(struct snd_pcm_substream *substream)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
+	struct snd_soc_dai *codec_dai = rtd->codec_dai;
+
+	switch (cpu_dai->id) {
+	case PRIMARY_MI2S_RX:
+	case PRIMARY_MI2S_TX:
+		snd_soc_dai_set_sysclk(cpu_dai,
+			Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT,
+			MI2S_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK);
+		snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBS_CFS);
+		snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_CBS_CFS);
+		break;
+	case QUATERNARY_MI2S_RX:
+	case QUATERNARY_MI2S_TX:
+		snd_soc_dai_set_sysclk(cpu_dai,
+			Q6AFE_LPASS_CLK_ID_QUAD_MI2S_IBIT,
+			MI2S_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK);
+		snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBS_CFS);
+		snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_CBS_CFS);
+		break;
+	case PRIMARY_PCM_RX:
+	case PRIMARY_PCM_TX:
+		snd_soc_dai_set_sysclk(cpu_dai,
+			Q6AFE_LPASS_CLK_ID_PRI_PCM_IBIT,
+			PCM_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK);
+		snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBS_CFS);
+		snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_CBS_CFS);
+		break;
+	case QUATERNARY_PCM_RX:
+	case QUATERNARY_PCM_TX:
+		snd_soc_dai_set_sysclk(cpu_dai,
+			Q6AFE_LPASS_CLK_ID_QUAD_PCM_IBIT,
+			PCM_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK);
+		snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBS_CFS);
+		snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_CBS_CFS);
+		break;
+	default:
+		return -1;
+	}
+	return 0;
+}
+
 static struct snd_soc_ops apq8096_ops = {
 	.hw_params = msm_snd_hw_params,
+	.startup = msm_snd_startup,
 };
 
 static int apq8096_init(struct snd_soc_pcm_runtime *rtd)
@@ -96,7 +153,6 @@ static void apq8096_add_be_ops(struct snd_soc_card *card)
 
 	for_each_card_prelinks(card, i, link) {
 		if (link->no_pcm == 1) {
-			link->be_hw_params_fixup = apq8096_be_hw_params_fixup;
 			link->init = apq8096_init;
 			link->ops = &apq8096_ops;
 		}
-- 
2.21.1


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH 6/8] ASoC: qcom/common: Use snd-soc-dummy-dai when codec is not specified
  2020-02-07 20:50 [PATCH 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio Adam Serbinski
                   ` (4 preceding siblings ...)
  2020-02-07 20:50 ` [PATCH 5/8] ASoC: qcom: apq8096: add support for primary and quaternary I2S/PCM Adam Serbinski
@ 2020-02-07 20:50 ` Adam Serbinski
  2020-02-07 20:50 ` [PATCH 7/8] dts: msm8996/db820c: enable primary pcm and quaternary i2s Adam Serbinski
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 41+ messages in thread
From: Adam Serbinski @ 2020-02-07 20:50 UTC (permalink / raw)
  To: Mark Brown, Srini Kandagatla, Rob Herring, Bjorn Andersson
  Cc: Adam Serbinski, Andy Gross, Mark Rutland, Liam Girdwood,
	Patrick Lai, Banajit Goswami, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, linux-arm-msm, devicetree, linux-kernel

When not specifying a codec, use snd-soc-dummy-dai. This supports
the case where a fixed configuration codec is attached, such as
bluetooth hfp.

Signed-off-by: Adam Serbinski <adam@serbinski.com>
CC: Andy Gross <agross@kernel.org>
CC: Mark Rutland <mark.rutland@arm.com>
CC: Liam Girdwood <lgirdwood@gmail.com>
CC: Patrick Lai <plai@codeaurora.org>
CC: Banajit Goswami <bgoswami@codeaurora.org>
CC: Jaroslav Kysela <perex@perex.cz>
CC: Takashi Iwai <tiwai@suse.com>
CC: alsa-devel@alsa-project.org
CC: linux-arm-msm@vger.kernel.org
CC: devicetree@vger.kernel.org
CC: linux-kernel@vger.kernel.org
---
 sound/soc/qcom/common.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/sound/soc/qcom/common.c b/sound/soc/qcom/common.c
index 6c20bdd850f3..aa2f2238aca0 100644
--- a/sound/soc/qcom/common.c
+++ b/sound/soc/qcom/common.c
@@ -84,7 +84,7 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
 			goto err;
 		}
 
-		if (codec && platform) {
+		if (platform) {
 			link->platforms->of_node = of_parse_phandle(platform,
 					"sound-dai",
 					0);
@@ -94,10 +94,22 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
 				goto err;
 			}
 
-			ret = snd_soc_of_get_dai_link_codecs(dev, codec, link);
-			if (ret < 0) {
-				dev_err(card->dev, "%s: codec dai not found\n", link->name);
-				goto err;
+			if (codec) {
+				ret = snd_soc_of_get_dai_link_codecs(dev, codec, link);
+				if (ret < 0) {
+					dev_err(card->dev, "%s: codec dai not found\n", link->name);
+					goto err;
+				}
+			} else {
+				dlc = devm_kzalloc(dev,
+						   sizeof(*dlc), GFP_KERNEL);
+				if (!dlc)
+					return -ENOMEM;
+
+				link->codecs = dlc;
+				link->num_codecs = 1;
+				link->codecs->dai_name = "snd-soc-dummy-dai";
+				link->codecs->name = "snd-soc-dummy";
 			}
 			link->no_pcm = 1;
 			link->ignore_pmdown_time = 1;
-- 
2.21.1


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH 7/8] dts: msm8996/db820c: enable primary pcm and quaternary i2s
  2020-02-07 20:50 [PATCH 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio Adam Serbinski
                   ` (5 preceding siblings ...)
  2020-02-07 20:50 ` [PATCH 6/8] ASoC: qcom/common: Use snd-soc-dummy-dai when codec is not specified Adam Serbinski
@ 2020-02-07 20:50 ` Adam Serbinski
  2020-02-08 23:42   ` Bjorn Andersson
  2020-02-07 20:50 ` [PATCH 8/8] ASoC: qcom: apq8096: add kcontrols to set PCM rate Adam Serbinski
  2020-02-09 15:47 ` [PATCH v2 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio Adam Serbinski
  8 siblings, 1 reply; 41+ messages in thread
From: Adam Serbinski @ 2020-02-07 20:50 UTC (permalink / raw)
  To: Mark Brown, Srini Kandagatla, Rob Herring, Bjorn Andersson
  Cc: Adam Serbinski, Andy Gross, Mark Rutland, Liam Girdwood,
	Patrick Lai, Banajit Goswami, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, linux-arm-msm, devicetree, linux-kernel

This patch adds support to primary pcm and quaternary i2s ports.

Signed-off-by: Adam Serbinski <adam@serbinski.com>
CC: Andy Gross <agross@kernel.org>
CC: Mark Rutland <mark.rutland@arm.com>
CC: Liam Girdwood <lgirdwood@gmail.com>
CC: Patrick Lai <plai@codeaurora.org>
CC: Banajit Goswami <bgoswami@codeaurora.org>
CC: Jaroslav Kysela <perex@perex.cz>
CC: Takashi Iwai <tiwai@suse.com>
CC: alsa-devel@alsa-project.org
CC: linux-arm-msm@vger.kernel.org
CC: devicetree@vger.kernel.org
CC: linux-kernel@vger.kernel.org
---
 arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi | 113 +++++++++++++
 arch/arm64/boot/dts/qcom/msm8996-pins.dtsi   | 162 +++++++++++++++++++
 2 files changed, 275 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi b/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi
index dba3488492f1..4149ac4147a0 100644
--- a/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi
+++ b/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi
@@ -683,8 +683,31 @@
 	};
 };
 
+/* PRI I2S on QCA6174 and QUAT I2S on LS each uses 2 I2S SD Lines for audio */
+&q6afedai {
+	pi2s@16 {
+		reg = <16>;
+		qcom,sd-lines = <1>;
+	};
+	pi2s@17 {
+		reg = <17>;
+		qcom,sd-lines = <0>;
+	};
+	qi2s@22 {
+		reg = <22>;
+		qcom,sd-lines = <0>;
+	};
+	qi2s@23 {
+		reg = <23>;
+		qcom,sd-lines = <1>;
+	};
+};
+
 &sound {
 	compatible = "qcom,apq8096-sndcard";
+	pinctrl-0 = <&quat_mi2s_active &quat_mi2s_sd0_active &quat_mi2s_sd1_active &pri_mi2s_active &pri_mi2s_sd0_active &pri_mi2s_sd1_active>;
+	pinctrl-names = "default";
+
 	model = "DB820c";
 	audio-routing =	"RX_BIAS", "MCLK";
 
@@ -709,6 +732,41 @@
 		};
 	};
 
+	mm4-dai-link {
+		link-name = "MultiMedia4";
+		cpu {
+			sound-dai = <&q6asmdai  MSM_FRONTEND_DAI_MULTIMEDIA4>;
+		};
+	};
+
+	mm5-dai-link {
+		link-name = "MultiMedia5";
+		cpu {
+			sound-dai = <&q6asmdai  MSM_FRONTEND_DAI_MULTIMEDIA5>;
+		};
+	};
+
+	mm6-dai-link {
+		link-name = "MultiMedia6";
+		cpu {
+			sound-dai = <&q6asmdai  MSM_FRONTEND_DAI_MULTIMEDIA6>;
+		};
+	};
+
+	mm7-dai-link {
+		link-name = "MultiMedia7";
+		cpu {
+			sound-dai = <&q6asmdai  MSM_FRONTEND_DAI_MULTIMEDIA7>;
+		};
+	};
+
+	mm8-dai-link {
+		link-name = "MultiMedia8";
+		cpu {
+			sound-dai = <&q6asmdai  MSM_FRONTEND_DAI_MULTIMEDIA8>;
+		};
+	};
+
 	hdmi-dai-link {
 		link-name = "HDMI";
 		cpu {
@@ -753,4 +811,59 @@
 			sound-dai = <&wcd9335 1>;
 		};
 	};
+
+	scoplay-dai-link {
+		link-name = "SCO-PCM-Playback";
+		cpu {
+			sound-dai = <&q6afedai PRIMARY_PCM_RX>;
+		};
+
+		platform {
+			sound-dai = <&q6routing>;
+		};
+	};
+
+	scocap-dai-link {
+		link-name = "SCO-PCM-Capture";
+		cpu {
+			sound-dai = <&q6afedai PRIMARY_PCM_TX>;
+		};
+
+		platform {
+			sound-dai = <&q6routing>;
+		};
+	};
+
+	mi2splay-dai-link {
+		link-name = "QUAT-MI2S-Playback";
+		cpu {
+			sound-dai = <&q6afedai QUATERNARY_MI2S_RX>;
+		};
+
+		platform {
+			sound-dai = <&q6routing>;
+		};
+
+//		EXAMPLE: For adding real codecs
+//		codec {
+//			sound-dai = <&pcm5142_4c>, <&pcm5142_4d>;
+//		};
+
+	};
+
+	mi2scap-dai-link {
+		link-name = "QUAT-MI2S-Capture";
+		cpu {
+			sound-dai = <&q6afedai QUATERNARY_MI2S_TX>;
+		};
+
+		platform {
+			sound-dai = <&q6routing>;
+		};
+
+//		EXAMPLE: For adding real codecs
+//		codec {
+//			sound-dai = <&pcm1865>;
+//		};
+	};
 };
diff --git a/arch/arm64/boot/dts/qcom/msm8996-pins.dtsi b/arch/arm64/boot/dts/qcom/msm8996-pins.dtsi
index ac1ede579361..e8221c4d05f7 100644
--- a/arch/arm64/boot/dts/qcom/msm8996-pins.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8996-pins.dtsi
@@ -288,6 +288,168 @@
 		};
 	};
 
+	pri_mi2s_active: pri_mi2s_active {
+		mux {
+			pins = "gpio65", "gpio66";
+			function = "pri_mi2s";
+		};
+		config {
+			pins = "gpio65", "gpio66";
+			drive-strength = <8>;   /* 8 mA */
+			bias-disable;           /* NO PULL */
+			output-high;
+		};
+	};
+
+	pri_mi2s_sleep: pri_mi2s_sleep {
+		mux {
+			pins = "gpio65", "gpio66";
+			function = "gpio";
+		};
+
+		config {
+			pins = "gpio65", "gpio66";
+			drive-strength = <2>;   /* 2 mA */
+			bias-pull-down;         /* PULL DOWN */
+			input-enable;
+		};
+	};
+
+	pri_mi2s_sd0_sleep: pri_mi2s_sd0_sleep {
+		mux {
+			pins = "gpio67";
+			function = "gpio";
+		};
+
+		config {
+			pins = "gpio67";
+			drive-strength = <2>;   /* 2 mA */
+			bias-pull-down;         /* PULL DOWN */
+			input-enable;
+		};
+	};
+
+	pri_mi2s_sd0_active: pri_mi2s_sd0_active {
+		mux {
+			pins = "gpio67";
+			function = "pri_mi2s";
+		};
+
+		config {
+			pins = "gpio67";
+			drive-strength = <8>;   /* 8 mA */
+			bias-disable;           /* NO PULL */
+		};
+	};
+
+	pri_mi2s_sd1_sleep: pri_mi2s_sd1_sleep {
+		mux {
+			pins = "gpio68";
+			function = "gpio";
+		};
+
+		config {
+			pins = "gpio68";
+			drive-strength = <2>;   /* 2 mA */
+			bias-pull-down;         /* PULL DOWN */
+			input-enable;
+		};
+	};
+
+	pri_mi2s_sd1_active: pri_mi2s_sd1_active {
+		mux {
+			pins = "gpio68";
+			function = "pri_mi2s";
+		};
+
+		config {
+			pins = "gpio68";
+			drive-strength = <8>;   /* 8 mA */
+			bias-disable;           /* NO PULL */
+		};
+	};
+
+	quat_mi2s_active: quat_mi2s_active {
+		mux {
+			pins = "gpio58", "gpio59";
+			function = "qua_mi2s";
+		};
+		config {
+			pins = "gpio58", "gpio59";
+			drive-strength = <8>;   /* 8 mA */
+			bias-disable;           /* NO PULL */
+			output-high;
+		};
+	};
+
+	quat_mi2s_sleep: quat_mi2s_sleep {
+		mux {
+			pins = "gpio58", "gpio59";
+			function = "gpio";
+		};
+
+		config {
+			pins = "gpio58", "gpio59";
+			drive-strength = <2>;   /* 2 mA */
+			bias-pull-down;         /* PULL DOWN */
+			input-enable;
+		};
+	};
+
+	quat_mi2s_sd0_sleep: quat_mi2s_sd0_sleep {
+		mux {
+			pins = "gpio60";
+			function = "gpio";
+		};
+
+		config {
+			pins = "gpio60";
+			drive-strength = <2>;   /* 2 mA */
+			bias-pull-down;         /* PULL DOWN */
+			input-enable;
+		};
+	};
+
+	quat_mi2s_sd0_active: quat_mi2s_sd0_active {
+		mux {
+			pins = "gpio60";
+			function = "qua_mi2s";
+		};
+
+		config {
+			pins = "gpio60";
+			drive-strength = <8>;   /* 8 mA */
+			bias-disable;           /* NO PULL */
+		};
+	};
+
+	quat_mi2s_sd1_sleep: quat_mi2s_sd1_sleep {
+		mux {
+			pins = "gpio61";
+			function = "gpio";
+		};
+
+		config {
+			pins = "gpio61";
+			drive-strength = <2>;   /* 2 mA */
+			bias-pull-down;         /* PULL DOWN */
+			input-enable;
+		};
+	};
+
+	quat_mi2s_sd1_active: quat_mi2s_sd1_active {
+		mux {
+			pins = "gpio61";
+			function = "qua_mi2s";
+		};
+
+		config {
+			pins = "gpio61";
+			drive-strength = <8>;   /* 8 mA */
+			bias-disable;           /* NO PULL */
+		};
+	};
+
 	sdc2_clk_on: sdc2_clk_on {
 		config {
 			pins = "sdc2_clk";
-- 
2.21.1


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH 8/8] ASoC: qcom: apq8096: add kcontrols to set PCM rate
  2020-02-07 20:50 [PATCH 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio Adam Serbinski
                   ` (6 preceding siblings ...)
  2020-02-07 20:50 ` [PATCH 7/8] dts: msm8996/db820c: enable primary pcm and quaternary i2s Adam Serbinski
@ 2020-02-07 20:50 ` Adam Serbinski
  2020-02-09 15:47 ` [PATCH v2 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio Adam Serbinski
  8 siblings, 0 replies; 41+ messages in thread
From: Adam Serbinski @ 2020-02-07 20:50 UTC (permalink / raw)
  To: Mark Brown, Srini Kandagatla, Rob Herring, Bjorn Andersson
  Cc: Adam Serbinski, Andy Gross, Mark Rutland, Liam Girdwood,
	Patrick Lai, Banajit Goswami, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, linux-arm-msm, devicetree, linux-kernel

This makes it possible for the backend sample rate to be
set to 8000 or 16000 Hz, depending on the needs of the HFP
call being set up.

Signed-off-by: Adam Serbinski <adam@serbinski.com>
CC: Andy Gross <agross@kernel.org>
CC: Mark Rutland <mark.rutland@arm.com>
CC: Liam Girdwood <lgirdwood@gmail.com>
CC: Patrick Lai <plai@codeaurora.org>
CC: Banajit Goswami <bgoswami@codeaurora.org>
CC: Jaroslav Kysela <perex@perex.cz>
CC: Takashi Iwai <tiwai@suse.com>
CC: alsa-devel@alsa-project.org
CC: linux-arm-msm@vger.kernel.org
CC: devicetree@vger.kernel.org
CC: linux-kernel@vger.kernel.org
---
 sound/soc/qcom/apq8096.c | 92 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 90 insertions(+), 2 deletions(-)

diff --git a/sound/soc/qcom/apq8096.c b/sound/soc/qcom/apq8096.c
index 1edcaa15234f..882f2c456321 100644
--- a/sound/soc/qcom/apq8096.c
+++ b/sound/soc/qcom/apq8096.c
@@ -16,6 +16,9 @@
 #define MI2S_BCLK_RATE			1536000
 #define PCM_BCLK_RATE			1024000
 
+static int pri_pcm_sample_rate = 16000;
+static int quat_pcm_sample_rate = 16000;
+
 static int msm_snd_hw_params(struct snd_pcm_substream *substream,
 			     struct snd_pcm_hw_params *params)
 {
@@ -33,10 +36,15 @@ static int msm_snd_hw_params(struct snd_pcm_substream *substream,
 	switch (cpu_dai->id) {
 	case PRIMARY_PCM_RX:
 	case PRIMARY_PCM_TX:
+		rate->min = pri_pcm_sample_rate;
+		rate->max = pri_pcm_sample_rate;
+		channels->min = 1;
+		channels->max = 1;
+		break;
 	case QUATERNARY_PCM_RX:
 	case QUATERNARY_PCM_TX:
-		rate->min = 16000;
-		rate->max = 16000;
+		rate->min = quat_pcm_sample_rate;
+		rate->max = quat_pcm_sample_rate;
 		channels->min = 1;
 		channels->max = 1;
 		break;
@@ -121,6 +129,83 @@ static struct snd_soc_ops apq8096_ops = {
 	.startup = msm_snd_startup,
 };
 
+static char const *pcm_sample_rate_text[] = {"8 kHz", "16 kHz"};
+static const struct soc_enum pcm_snd_enum =
+		SOC_ENUM_SINGLE_EXT(2, pcm_sample_rate_text);
+
+static int get_sample_rate_idx(int sample_rate)
+{
+	int sample_rate_idx = 0;
+
+	switch (sample_rate) {
+	case 8000:
+		sample_rate_idx = 0;
+		break;
+	case 16000:
+	default:
+		sample_rate_idx = 1;
+		break;
+	}
+
+	return sample_rate_idx;
+}
+
+static int pri_pcm_sample_rate_get(struct snd_kcontrol *kcontrol,
+				   struct snd_ctl_elem_value *ucontrol)
+{
+	ucontrol->value.integer.value[0] =
+		get_sample_rate_idx(pri_pcm_sample_rate);
+	return 0;
+}
+
+static int quat_pcm_sample_rate_get(struct snd_kcontrol *kcontrol,
+				    struct snd_ctl_elem_value *ucontrol)
+{
+	ucontrol->value.integer.value[0] =
+		get_sample_rate_idx(quat_pcm_sample_rate);
+	return 0;
+}
+
+static int get_sample_rate(int idx)
+{
+	int sample_rate_val = 0;
+
+	switch (idx) {
+	case 0:
+		sample_rate_val = 8000;
+		break;
+	case 1:
+	default:
+		sample_rate_val = 16000;
+		break;
+	}
+
+	return sample_rate_val;
+}
+
+static int pri_pcm_sample_rate_put(struct snd_kcontrol *kcontrol,
+				   struct snd_ctl_elem_value *ucontrol)
+{
+	pri_pcm_sample_rate =
+		get_sample_rate(ucontrol->value.integer.value[0]);
+	return 0;
+}
+
+static int quat_pcm_sample_rate_put(struct snd_kcontrol *kcontrol,
+				    struct snd_ctl_elem_value *ucontrol)
+{
+	quat_pcm_sample_rate =
+		get_sample_rate(ucontrol->value.integer.value[0]);
+	return 0;
+}
+
+static const struct snd_kcontrol_new card_controls[] = {
+	SOC_ENUM_EXT("PRI_PCM SampleRate", pcm_snd_enum,
+		     pri_pcm_sample_rate_get, pri_pcm_sample_rate_put),
+	SOC_ENUM_EXT("QUAT_PCM SampleRate", pcm_snd_enum,
+		     quat_pcm_sample_rate_get, quat_pcm_sample_rate_put),
+};
+
 static int apq8096_init(struct snd_soc_pcm_runtime *rtd)
 {
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
@@ -182,6 +267,9 @@ static int apq8096_platform_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_card_register;
 
+	snd_soc_add_card_controls(card, card_controls,
+				  ARRAY_SIZE(card_controls));
+
 	return 0;
 
 err_card_register:
-- 
2.21.1


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH 7/8] dts: msm8996/db820c: enable primary pcm and quaternary i2s
  2020-02-07 20:50 ` [PATCH 7/8] dts: msm8996/db820c: enable primary pcm and quaternary i2s Adam Serbinski
@ 2020-02-08 23:42   ` Bjorn Andersson
  0 siblings, 0 replies; 41+ messages in thread
From: Bjorn Andersson @ 2020-02-08 23:42 UTC (permalink / raw)
  To: Adam Serbinski
  Cc: Mark Brown, Srini Kandagatla, Rob Herring, Andy Gross,
	Mark Rutland, Liam Girdwood, Patrick Lai, Banajit Goswami,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-arm-msm,
	devicetree, linux-kernel

On Fri 07 Feb 12:50 PST 2020, Adam Serbinski wrote:

Please make subject

"arm64: dts: qcom: db820c: Enable primary PCM and quaternary I2S"

Regards,
Bjorn

> This patch adds support to primary pcm and quaternary i2s ports.
> 
> Signed-off-by: Adam Serbinski <adam@serbinski.com>
> CC: Andy Gross <agross@kernel.org>
> CC: Mark Rutland <mark.rutland@arm.com>
> CC: Liam Girdwood <lgirdwood@gmail.com>
> CC: Patrick Lai <plai@codeaurora.org>
> CC: Banajit Goswami <bgoswami@codeaurora.org>
> CC: Jaroslav Kysela <perex@perex.cz>
> CC: Takashi Iwai <tiwai@suse.com>
> CC: alsa-devel@alsa-project.org
> CC: linux-arm-msm@vger.kernel.org
> CC: devicetree@vger.kernel.org
> CC: linux-kernel@vger.kernel.org
> ---
>  arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi | 113 +++++++++++++
>  arch/arm64/boot/dts/qcom/msm8996-pins.dtsi   | 162 +++++++++++++++++++
>  2 files changed, 275 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi b/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi
> index dba3488492f1..4149ac4147a0 100644
> --- a/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi
> +++ b/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi
> @@ -683,8 +683,31 @@
>  	};
>  };
>  
> +/* PRI I2S on QCA6174 and QUAT I2S on LS each uses 2 I2S SD Lines for audio */
> +&q6afedai {
> +	pi2s@16 {
> +		reg = <16>;
> +		qcom,sd-lines = <1>;
> +	};
> +	pi2s@17 {
> +		reg = <17>;
> +		qcom,sd-lines = <0>;
> +	};
> +	qi2s@22 {
> +		reg = <22>;
> +		qcom,sd-lines = <0>;
> +	};
> +	qi2s@23 {
> +		reg = <23>;
> +		qcom,sd-lines = <1>;
> +	};
> +};
> +
>  &sound {
>  	compatible = "qcom,apq8096-sndcard";
> +	pinctrl-0 = <&quat_mi2s_active &quat_mi2s_sd0_active &quat_mi2s_sd1_active &pri_mi2s_active &pri_mi2s_sd0_active &pri_mi2s_sd1_active>;
> +	pinctrl-names = "default";
> +
>  	model = "DB820c";
>  	audio-routing =	"RX_BIAS", "MCLK";
>  
> @@ -709,6 +732,41 @@
>  		};
>  	};
>  
> +	mm4-dai-link {
> +		link-name = "MultiMedia4";
> +		cpu {
> +			sound-dai = <&q6asmdai  MSM_FRONTEND_DAI_MULTIMEDIA4>;
> +		};
> +	};
> +
> +	mm5-dai-link {
> +		link-name = "MultiMedia5";
> +		cpu {
> +			sound-dai = <&q6asmdai  MSM_FRONTEND_DAI_MULTIMEDIA5>;
> +		};
> +	};
> +
> +	mm6-dai-link {
> +		link-name = "MultiMedia6";
> +		cpu {
> +			sound-dai = <&q6asmdai  MSM_FRONTEND_DAI_MULTIMEDIA6>;
> +		};
> +	};
> +
> +	mm7-dai-link {
> +		link-name = "MultiMedia7";
> +		cpu {
> +			sound-dai = <&q6asmdai  MSM_FRONTEND_DAI_MULTIMEDIA7>;
> +		};
> +	};
> +
> +	mm8-dai-link {
> +		link-name = "MultiMedia8";
> +		cpu {
> +			sound-dai = <&q6asmdai  MSM_FRONTEND_DAI_MULTIMEDIA8>;
> +		};
> +	};
> +
>  	hdmi-dai-link {
>  		link-name = "HDMI";
>  		cpu {
> @@ -753,4 +811,59 @@
>  			sound-dai = <&wcd9335 1>;
>  		};
>  	};
> +
> +	scoplay-dai-link {
> +		link-name = "SCO-PCM-Playback";
> +		cpu {
> +			sound-dai = <&q6afedai PRIMARY_PCM_RX>;
> +		};
> +
> +		platform {
> +			sound-dai = <&q6routing>;
> +		};
> +	};
> +
> +	scocap-dai-link {
> +		link-name = "SCO-PCM-Capture";
> +		cpu {
> +			sound-dai = <&q6afedai PRIMARY_PCM_TX>;
> +		};
> +
> +		platform {
> +			sound-dai = <&q6routing>;
> +		};
> +	};
> +
> +	mi2splay-dai-link {
> +		link-name = "QUAT-MI2S-Playback";
> +		cpu {
> +			sound-dai = <&q6afedai QUATERNARY_MI2S_RX>;
> +		};
> +
> +		platform {
> +			sound-dai = <&q6routing>;
> +		};
> +
> +//		EXAMPLE: For adding real codecs
> +//		codec {
> +//			sound-dai = <&pcm5142_4c>, <&pcm5142_4d>;
> +//		};
> +
> +	};
> +
> +	mi2scap-dai-link {
> +		link-name = "QUAT-MI2S-Capture";
> +		cpu {
> +			sound-dai = <&q6afedai QUATERNARY_MI2S_TX>;
> +		};
> +
> +		platform {
> +			sound-dai = <&q6routing>;
> +		};
> +
> +//		EXAMPLE: For adding real codecs
> +//		codec {
> +//			sound-dai = <&pcm1865>;
> +//		};
> +	};
>  };
> diff --git a/arch/arm64/boot/dts/qcom/msm8996-pins.dtsi b/arch/arm64/boot/dts/qcom/msm8996-pins.dtsi
> index ac1ede579361..e8221c4d05f7 100644
> --- a/arch/arm64/boot/dts/qcom/msm8996-pins.dtsi
> +++ b/arch/arm64/boot/dts/qcom/msm8996-pins.dtsi
> @@ -288,6 +288,168 @@
>  		};
>  	};
>  
> +	pri_mi2s_active: pri_mi2s_active {
> +		mux {
> +			pins = "gpio65", "gpio66";
> +			function = "pri_mi2s";
> +		};
> +		config {
> +			pins = "gpio65", "gpio66";
> +			drive-strength = <8>;   /* 8 mA */
> +			bias-disable;           /* NO PULL */
> +			output-high;
> +		};
> +	};
> +
> +	pri_mi2s_sleep: pri_mi2s_sleep {
> +		mux {
> +			pins = "gpio65", "gpio66";
> +			function = "gpio";
> +		};
> +
> +		config {
> +			pins = "gpio65", "gpio66";
> +			drive-strength = <2>;   /* 2 mA */
> +			bias-pull-down;         /* PULL DOWN */
> +			input-enable;
> +		};
> +	};
> +
> +	pri_mi2s_sd0_sleep: pri_mi2s_sd0_sleep {
> +		mux {
> +			pins = "gpio67";
> +			function = "gpio";
> +		};
> +
> +		config {
> +			pins = "gpio67";
> +			drive-strength = <2>;   /* 2 mA */
> +			bias-pull-down;         /* PULL DOWN */
> +			input-enable;
> +		};
> +	};
> +
> +	pri_mi2s_sd0_active: pri_mi2s_sd0_active {
> +		mux {
> +			pins = "gpio67";
> +			function = "pri_mi2s";
> +		};
> +
> +		config {
> +			pins = "gpio67";
> +			drive-strength = <8>;   /* 8 mA */
> +			bias-disable;           /* NO PULL */
> +		};
> +	};
> +
> +	pri_mi2s_sd1_sleep: pri_mi2s_sd1_sleep {
> +		mux {
> +			pins = "gpio68";
> +			function = "gpio";
> +		};
> +
> +		config {
> +			pins = "gpio68";
> +			drive-strength = <2>;   /* 2 mA */
> +			bias-pull-down;         /* PULL DOWN */
> +			input-enable;
> +		};
> +	};
> +
> +	pri_mi2s_sd1_active: pri_mi2s_sd1_active {
> +		mux {
> +			pins = "gpio68";
> +			function = "pri_mi2s";
> +		};
> +
> +		config {
> +			pins = "gpio68";
> +			drive-strength = <8>;   /* 8 mA */
> +			bias-disable;           /* NO PULL */
> +		};
> +	};
> +
> +	quat_mi2s_active: quat_mi2s_active {
> +		mux {
> +			pins = "gpio58", "gpio59";
> +			function = "qua_mi2s";
> +		};
> +		config {
> +			pins = "gpio58", "gpio59";
> +			drive-strength = <8>;   /* 8 mA */
> +			bias-disable;           /* NO PULL */
> +			output-high;
> +		};
> +	};
> +
> +	quat_mi2s_sleep: quat_mi2s_sleep {
> +		mux {
> +			pins = "gpio58", "gpio59";
> +			function = "gpio";
> +		};
> +
> +		config {
> +			pins = "gpio58", "gpio59";
> +			drive-strength = <2>;   /* 2 mA */
> +			bias-pull-down;         /* PULL DOWN */
> +			input-enable;
> +		};
> +	};
> +
> +	quat_mi2s_sd0_sleep: quat_mi2s_sd0_sleep {
> +		mux {
> +			pins = "gpio60";
> +			function = "gpio";
> +		};
> +
> +		config {
> +			pins = "gpio60";
> +			drive-strength = <2>;   /* 2 mA */
> +			bias-pull-down;         /* PULL DOWN */
> +			input-enable;
> +		};
> +	};
> +
> +	quat_mi2s_sd0_active: quat_mi2s_sd0_active {
> +		mux {
> +			pins = "gpio60";
> +			function = "qua_mi2s";
> +		};
> +
> +		config {
> +			pins = "gpio60";
> +			drive-strength = <8>;   /* 8 mA */
> +			bias-disable;           /* NO PULL */
> +		};
> +	};
> +
> +	quat_mi2s_sd1_sleep: quat_mi2s_sd1_sleep {
> +		mux {
> +			pins = "gpio61";
> +			function = "gpio";
> +		};
> +
> +		config {
> +			pins = "gpio61";
> +			drive-strength = <2>;   /* 2 mA */
> +			bias-pull-down;         /* PULL DOWN */
> +			input-enable;
> +		};
> +	};
> +
> +	quat_mi2s_sd1_active: quat_mi2s_sd1_active {
> +		mux {
> +			pins = "gpio61";
> +			function = "qua_mi2s";
> +		};
> +
> +		config {
> +			pins = "gpio61";
> +			drive-strength = <8>;   /* 8 mA */
> +			bias-disable;           /* NO PULL */
> +		};
> +	};
> +
>  	sdc2_clk_on: sdc2_clk_on {
>  		config {
>  			pins = "sdc2_clk";
> -- 
> 2.21.1
> 

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v2 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio
  2020-02-07 20:50 [PATCH 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio Adam Serbinski
                   ` (7 preceding siblings ...)
  2020-02-07 20:50 ` [PATCH 8/8] ASoC: qcom: apq8096: add kcontrols to set PCM rate Adam Serbinski
@ 2020-02-09 15:47 ` Adam Serbinski
  2020-02-09 15:47   ` [PATCH v2 1/8] ASoC: qdsp6: dt-bindings: Add q6afe pcm dt binding Adam Serbinski
                     ` (8 more replies)
  8 siblings, 9 replies; 41+ messages in thread
From: Adam Serbinski @ 2020-02-09 15:47 UTC (permalink / raw)
  To: Mark Brown, Srini Kandagatla, Rob Herring, Bjorn Andersson
  Cc: Adam Serbinski, Andy Gross, Mark Rutland, Liam Girdwood,
	Patrick Lai, Banajit Goswami, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, linux-arm-msm, devicetree, linux-kernel

Changes from V1:

	Rename patch:
		from: dts: msm8996/db820c: enable primary pcm and quaternary i2s
		to: dts: qcom: db820c: Enable primary PCM and quaternary I2S

CC: Andy Gross <agross@kernel.org>
CC: Mark Rutland <mark.rutland@arm.com>
CC: Liam Girdwood <lgirdwood@gmail.com>
CC: Patrick Lai <plai@codeaurora.org>
CC: Banajit Goswami <bgoswami@codeaurora.org>
CC: Jaroslav Kysela <perex@perex.cz>
CC: Takashi Iwai <tiwai@suse.com>
CC: alsa-devel@alsa-project.org
CC: linux-arm-msm@vger.kernel.org
CC: devicetree@vger.kernel.org
CC: linux-kernel@vger.kernel.org

Adam Serbinski (8):
  ASoC: qdsp6: dt-bindings: Add q6afe pcm dt binding
  ASoC: qdsp6: q6afe: add support to pcm ports
  ASoC: qdsp6: q6afe-dai: add support to pcm port dais
  ASoC: qdsp6: q6routing: add pcm port routing
  ASoC: qcom: apq8096: add support for primary and quaternary I2S/PCM
  ASoC: qcom/common: Use snd-soc-dummy-dai when codec is not specified
  arm64: dts: qcom: db820c: Enable primary PCM and quaternary I2S
  ASoC: qcom: apq8096: add kcontrols to set PCM rate

 arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi | 113 +++++++++
 arch/arm64/boot/dts/qcom/msm8996-pins.dtsi   | 162 ++++++++++++
 include/dt-bindings/sound/qcom,q6afe.h       |   8 +
 sound/soc/qcom/apq8096.c                     | 172 +++++++++++--
 sound/soc/qcom/common.c                      |  22 +-
 sound/soc/qcom/qdsp6/q6afe-dai.c             | 198 ++++++++++++++-
 sound/soc/qcom/qdsp6/q6afe.c                 | 246 +++++++++++++++++++
 sound/soc/qcom/qdsp6/q6afe.h                 |   9 +-
 sound/soc/qcom/qdsp6/q6routing.c             |  44 ++++
 9 files changed, 953 insertions(+), 21 deletions(-)

-- 
2.21.1


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v2 1/8] ASoC: qdsp6: dt-bindings: Add q6afe pcm dt binding
  2020-02-09 15:47 ` [PATCH v2 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio Adam Serbinski
@ 2020-02-09 15:47   ` Adam Serbinski
  2020-02-10 17:13     ` Srinivas Kandagatla
  2020-02-09 15:47   ` [PATCH v2 2/8] ASoC: qdsp6: q6afe: add support to pcm ports Adam Serbinski
                     ` (7 subsequent siblings)
  8 siblings, 1 reply; 41+ messages in thread
From: Adam Serbinski @ 2020-02-09 15:47 UTC (permalink / raw)
  To: Mark Brown, Srini Kandagatla, Rob Herring, Bjorn Andersson
  Cc: Adam Serbinski, Andy Gross, Mark Rutland, Liam Girdwood,
	Patrick Lai, Banajit Goswami, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, linux-arm-msm, devicetree, linux-kernel

This patch adds bindings required for PCM ports on AFE.

Signed-off-by: Adam Serbinski <adam@serbinski.com>
CC: Andy Gross <agross@kernel.org>
CC: Mark Rutland <mark.rutland@arm.com>
CC: Liam Girdwood <lgirdwood@gmail.com>
CC: Patrick Lai <plai@codeaurora.org>
CC: Banajit Goswami <bgoswami@codeaurora.org>
CC: Jaroslav Kysela <perex@perex.cz>
CC: Takashi Iwai <tiwai@suse.com>
CC: alsa-devel@alsa-project.org
CC: linux-arm-msm@vger.kernel.org
CC: devicetree@vger.kernel.org
CC: linux-kernel@vger.kernel.org
---
 include/dt-bindings/sound/qcom,q6afe.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/dt-bindings/sound/qcom,q6afe.h b/include/dt-bindings/sound/qcom,q6afe.h
index 1df06f8ad5c3..f3a435a112cb 100644
--- a/include/dt-bindings/sound/qcom,q6afe.h
+++ b/include/dt-bindings/sound/qcom,q6afe.h
@@ -107,6 +107,14 @@
 #define QUINARY_TDM_RX_7	102
 #define QUINARY_TDM_TX_7	103
 #define DISPLAY_PORT_RX		104
+#define PRIMARY_PCM_RX		105
+#define PRIMARY_PCM_TX		106
+#define SECONDARY_PCM_RX	107
+#define SECONDARY_PCM_TX	108
+#define TERTIARY_PCM_RX		109
+#define TERTIARY_PCM_TX		110
+#define QUATERNARY_PCM_RX	111
+#define QUATERNARY_PCM_TX	112
 
 #endif /* __DT_BINDINGS_Q6_AFE_H__ */
 
-- 
2.21.1


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v2 2/8] ASoC: qdsp6: q6afe: add support to pcm ports
  2020-02-09 15:47 ` [PATCH v2 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio Adam Serbinski
  2020-02-09 15:47   ` [PATCH v2 1/8] ASoC: qdsp6: dt-bindings: Add q6afe pcm dt binding Adam Serbinski
@ 2020-02-09 15:47   ` Adam Serbinski
  2020-02-10 13:31     ` Mark Brown
  2020-02-10 17:13     ` Srinivas Kandagatla
  2020-02-09 15:47   ` [PATCH v2 3/8] ASoC: qdsp6: q6afe-dai: add support to pcm port dais Adam Serbinski
                     ` (6 subsequent siblings)
  8 siblings, 2 replies; 41+ messages in thread
From: Adam Serbinski @ 2020-02-09 15:47 UTC (permalink / raw)
  To: Mark Brown, Srini Kandagatla, Rob Herring, Bjorn Andersson
  Cc: Adam Serbinski, Andy Gross, Mark Rutland, Liam Girdwood,
	Patrick Lai, Banajit Goswami, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, linux-arm-msm, devicetree, linux-kernel

This patch adds support to pcm ports in AFE.

Signed-off-by: Adam Serbinski <adam@serbinski.com>
CC: Andy Gross <agross@kernel.org>
CC: Mark Rutland <mark.rutland@arm.com>
CC: Liam Girdwood <lgirdwood@gmail.com>
CC: Patrick Lai <plai@codeaurora.org>
CC: Banajit Goswami <bgoswami@codeaurora.org>
CC: Jaroslav Kysela <perex@perex.cz>
CC: Takashi Iwai <tiwai@suse.com>
CC: alsa-devel@alsa-project.org
CC: linux-arm-msm@vger.kernel.org
CC: devicetree@vger.kernel.org
CC: linux-kernel@vger.kernel.org
---
 sound/soc/qcom/qdsp6/q6afe.c | 246 +++++++++++++++++++++++++++++++++++
 sound/soc/qcom/qdsp6/q6afe.h |   9 +-
 2 files changed, 254 insertions(+), 1 deletion(-)

diff --git a/sound/soc/qcom/qdsp6/q6afe.c b/sound/soc/qcom/qdsp6/q6afe.c
index e0945f7a58c8..b53ad14a78fd 100644
--- a/sound/soc/qcom/qdsp6/q6afe.c
+++ b/sound/soc/qcom/qdsp6/q6afe.c
@@ -40,6 +40,7 @@
 
 #define AFE_PARAM_ID_SLIMBUS_CONFIG    0x00010212
 #define AFE_PARAM_ID_I2S_CONFIG	0x0001020D
+#define AFE_PARAM_ID_PCM_CONFIG        0x0001020E
 #define AFE_PARAM_ID_TDM_CONFIG	0x0001029D
 #define AFE_PARAM_ID_PORT_SLOT_MAPPING_CONFIG	0x00010297
 
@@ -117,6 +118,15 @@
 #define AFE_PORT_ID_QUATERNARY_MI2S_RX      0x1006
 #define AFE_PORT_ID_QUATERNARY_MI2S_TX      0x1007
 
+#define AFE_PORT_ID_PRIMARY_PCM_RX          0x100A
+#define AFE_PORT_ID_PRIMARY_PCM_TX          0x100B
+#define AFE_PORT_ID_SECONDARY_PCM_RX        0x100C
+#define AFE_PORT_ID_SECONDARY_PCM_TX        0x100D
+#define AFE_PORT_ID_TERTIARY_PCM_RX         0x1012
+#define AFE_PORT_ID_TERTIARY_PCM_TX         0x1013
+#define AFE_PORT_ID_QUATERNARY_PCM_RX       0x1014
+#define AFE_PORT_ID_QUATERNARY_PCM_TX       0x1015
+
 /* Start of the range of port IDs for TDM devices. */
 #define AFE_PORT_ID_TDM_PORT_RANGE_START	0x9000
 
@@ -421,6 +431,166 @@ struct afe_digital_clk_cfg {
 	u16                  reserved;
 } __packed;
 
+#define AFE_API_VERSION_PCM_CONFIG	0x1
+/* Enumeration for the auxiliary PCM synchronization signal
+ * provided by an external source.
+ */
+
+#define AFE_PORT_PCM_SYNC_SRC_EXTERNAL 0x0
+/*	Enumeration for the auxiliary PCM synchronization signal
+ * provided by an internal source.
+ */
+#define AFE_PORT_PCM_SYNC_SRC_INTERNAL  0x1
+/*	Enumeration for the PCM configuration aux_mode parameter,
+ * which configures the auxiliary PCM interface to use
+ * short synchronization.
+ */
+#define AFE_PORT_PCM_AUX_MODE_PCM  0x0
+/*
+ * Enumeration for the PCM configuration aux_mode parameter,
+ * which configures the auxiliary PCM interface to use long
+ * synchronization.
+ */
+#define AFE_PORT_PCM_AUX_MODE_AUX    0x1
+/*
+ * Enumeration for setting the PCM configuration frame to 8.
+ */
+#define AFE_PORT_PCM_BITS_PER_FRAME_8  0x0
+/*
+ * Enumeration for setting the PCM configuration frame to 16.
+ */
+#define AFE_PORT_PCM_BITS_PER_FRAME_16   0x1
+
+/*	Enumeration for setting the PCM configuration frame to 32.*/
+#define AFE_PORT_PCM_BITS_PER_FRAME_32 0x2
+
+/*	Enumeration for setting the PCM configuration frame to 64.*/
+#define AFE_PORT_PCM_BITS_PER_FRAME_64   0x3
+
+/*	Enumeration for setting the PCM configuration frame to 128.*/
+#define AFE_PORT_PCM_BITS_PER_FRAME_128 0x4
+
+/*	Enumeration for setting the PCM configuration frame to 256.*/
+#define AFE_PORT_PCM_BITS_PER_FRAME_256 0x5
+
+/*	Enumeration for setting the PCM configuration
+ * quantype parameter to A-law with no padding.
+ */
+#define AFE_PORT_PCM_ALAW_NOPADDING 0x0
+
+/* Enumeration for setting the PCM configuration quantype
+ * parameter to mu-law with no padding.
+ */
+#define AFE_PORT_PCM_MULAW_NOPADDING 0x1
+/*	Enumeration for setting the PCM configuration quantype
+ * parameter to linear with no padding.
+ */
+#define AFE_PORT_PCM_LINEAR_NOPADDING 0x2
+/*	Enumeration for setting the PCM configuration quantype
+ * parameter to A-law with padding.
+ */
+#define AFE_PORT_PCM_ALAW_PADDING  0x3
+/*	Enumeration for setting the PCM configuration quantype
+ * parameter to mu-law with padding.
+ */
+#define AFE_PORT_PCM_MULAW_PADDING 0x4
+/*	Enumeration for setting the PCM configuration quantype
+ * parameter to linear with padding.
+ */
+#define AFE_PORT_PCM_LINEAR_PADDING 0x5
+/*	Enumeration for disabling the PCM configuration
+ * ctrl_data_out_enable parameter.
+ * The PCM block is the only master.
+ */
+#define AFE_PORT_PCM_CTRL_DATA_OE_DISABLE 0x0
+/*
+ * Enumeration for enabling the PCM configuration
+ * ctrl_data_out_enable parameter. The PCM block shares
+ * the signal with other masters.
+ */
+#define AFE_PORT_PCM_CTRL_DATA_OE_ENABLE  0x1
+
+/*  Payload of the #AFE_PARAM_ID_PCM_CONFIG command's
+ * (PCM configuration parameter).
+ */
+
+struct afe_param_id_pcm_cfg {
+	u32                  pcm_cfg_minor_version;
+/* Minor version used for tracking the version of the AUX PCM
+ * configuration interface.
+ * Supported values: #AFE_API_VERSION_PCM_CONFIG
+ */
+
+	u16                  aux_mode;
+/* PCM synchronization setting.
+ * Supported values:
+ * - #AFE_PORT_PCM_AUX_MODE_PCM
+ * - #AFE_PORT_PCM_AUX_MODE_AUX
+ */
+
+	u16                  sync_src;
+/* Synchronization source.
+ * Supported values:
+ * - #AFE_PORT_PCM_SYNC_SRC_EXTERNAL
+ * - #AFE_PORT_PCM_SYNC_SRC_INTERNAL
+ */
+
+	u16                  frame_setting;
+/* Number of bits per frame.
+ * Supported values:
+ * - #AFE_PORT_PCM_BITS_PER_FRAME_8
+ * - #AFE_PORT_PCM_BITS_PER_FRAME_16
+ * - #AFE_PORT_PCM_BITS_PER_FRAME_32
+ * - #AFE_PORT_PCM_BITS_PER_FRAME_64
+ * - #AFE_PORT_PCM_BITS_PER_FRAME_128
+ * - #AFE_PORT_PCM_BITS_PER_FRAME_256
+ */
+
+	u16                  quantype;
+/* PCM quantization type.
+ * Supported values:
+ * - #AFE_PORT_PCM_ALAW_NOPADDING
+ * - #AFE_PORT_PCM_MULAW_NOPADDING
+ * - #AFE_PORT_PCM_LINEAR_NOPADDING
+ * - #AFE_PORT_PCM_ALAW_PADDING
+ * - #AFE_PORT_PCM_MULAW_PADDING
+ * - #AFE_PORT_PCM_LINEAR_PADDING
+ */
+
+	u16                  ctrl_data_out_enable;
+/* Specifies whether the PCM block shares the data-out
+ * signal to the drive with other masters.
+ * Supported values:
+ * - #AFE_PORT_PCM_CTRL_DATA_OE_DISABLE
+ * - #AFE_PORT_PCM_CTRL_DATA_OE_ENABLE
+ */
+		u16                  reserved;
+	/* This field must be set to zero. */
+
+	u32                  sample_rate;
+/* Sampling rate of the port.
+ * Supported values:
+ * - #AFE_PORT_SAMPLE_RATE_8K
+ * - #AFE_PORT_SAMPLE_RATE_16K
+ */
+
+	u16                  bit_width;
+/* Bit width of the sample.
+ * Supported values: 16
+ */
+
+	u16                  num_channels;
+/* Number of channels.
+ * Supported values: 1 to 4
+ */
+
+	u16                  slot_number_mapping[4];
+/* Specifies the slot number for the each channel in
+ * multi channel scenario.
+ * Supported values: 1 to 32
+ */
+} __packed;
+
 struct afe_param_id_i2s_cfg {
 	u32	i2s_cfg_minor_version;
 	u16	bit_width;
@@ -452,6 +622,7 @@ union afe_port_config {
 	struct afe_param_id_hdmi_multi_chan_audio_cfg hdmi_multi_ch;
 	struct afe_param_id_slimbus_cfg           slim_cfg;
 	struct afe_param_id_i2s_cfg	i2s_cfg;
+	struct afe_param_id_pcm_cfg	pcm_cfg;
 	struct afe_param_id_tdm_cfg	tdm_cfg;
 } __packed;
 
@@ -707,6 +878,22 @@ static struct afe_port_map port_maps[AFE_PORT_MAX] = {
 				QUINARY_TDM_TX_7, 0, 1},
 	[DISPLAY_PORT_RX] = { AFE_PORT_ID_HDMI_OVER_DP_RX,
 				DISPLAY_PORT_RX, 1, 1},
+	[PRIMARY_PCM_RX] = { AFE_PORT_ID_PRIMARY_PCM_RX,
+				PRIMARY_PCM_RX, 1, 1},
+	[PRIMARY_PCM_TX] = { AFE_PORT_ID_PRIMARY_PCM_TX,
+				PRIMARY_PCM_RX, 0, 1},
+	[SECONDARY_PCM_RX] = { AFE_PORT_ID_SECONDARY_PCM_RX,
+				SECONDARY_PCM_RX, 1, 1},
+	[SECONDARY_PCM_TX] = { AFE_PORT_ID_SECONDARY_PCM_TX,
+				SECONDARY_PCM_TX, 0, 1},
+	[TERTIARY_PCM_RX] = { AFE_PORT_ID_TERTIARY_PCM_RX,
+				TERTIARY_PCM_RX, 1, 1},
+	[TERTIARY_PCM_TX] = { AFE_PORT_ID_TERTIARY_PCM_TX,
+				TERTIARY_PCM_TX, 0, 1},
+	[QUATERNARY_PCM_RX] = { AFE_PORT_ID_QUATERNARY_PCM_RX,
+				QUATERNARY_PCM_RX, 1, 1},
+	[QUATERNARY_PCM_TX] = { AFE_PORT_ID_QUATERNARY_PCM_TX,
+				QUATERNARY_PCM_TX, 0, 1},
 };
 
 static void q6afe_port_free(struct kref *ref)
@@ -993,6 +1180,7 @@ int q6afe_port_set_sysclk(struct q6afe_port *port, int clk_id,
 		break;
 	case Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT ... Q6AFE_LPASS_CLK_ID_QUI_MI2S_OSR:
 	case Q6AFE_LPASS_CLK_ID_MCLK_1 ... Q6AFE_LPASS_CLK_ID_INT_MCLK_1:
+	/* TDM cases overlap with PCM */
 	case Q6AFE_LPASS_CLK_ID_PRI_TDM_IBIT ... Q6AFE_LPASS_CLK_ID_QUIN_TDM_EBIT:
 		cset.clk_set_minor_version = AFE_API_VERSION_CLOCK_SET;
 		cset.clk_id = clk_id;
@@ -1145,6 +1333,54 @@ void q6afe_hdmi_port_prepare(struct q6afe_port *port,
 }
 EXPORT_SYMBOL_GPL(q6afe_hdmi_port_prepare);
 
+/**
+ * q6afe_pcm_port_prepare() - Prepare pcm afe port.
+ *
+ * @port: Instance of afe port
+ * @cfg: PCM configuration for the afe port
+ *
+ */
+int q6afe_pcm_port_prepare(struct q6afe_port *port, struct q6afe_pcm_cfg *cfg)
+{
+	union afe_port_config *pcfg = &port->port_cfg;
+
+	pcfg->pcm_cfg.pcm_cfg_minor_version = AFE_API_VERSION_PCM_CONFIG;
+	pcfg->pcm_cfg.aux_mode = AFE_PORT_PCM_AUX_MODE_PCM;
+
+	switch (cfg->fmt & SND_SOC_DAIFMT_MASTER_MASK) {
+	case SND_SOC_DAIFMT_CBS_CFS:
+		pcfg->pcm_cfg.sync_src = AFE_PORT_PCM_SYNC_SRC_INTERNAL;
+		break;
+	case SND_SOC_DAIFMT_CBM_CFM:
+		/* CPU is slave */
+		pcfg->pcm_cfg.sync_src = AFE_PORT_PCM_SYNC_SRC_EXTERNAL;
+		break;
+	default:
+		break;
+	}
+
+	switch (cfg->sample_rate) {
+	case 8000:
+		pcfg->pcm_cfg.frame_setting = AFE_PORT_PCM_BITS_PER_FRAME_128;
+		break;
+	case 16000:
+		pcfg->pcm_cfg.frame_setting = AFE_PORT_PCM_BITS_PER_FRAME_64;
+		break;
+	}
+	pcfg->pcm_cfg.quantype = AFE_PORT_PCM_LINEAR_NOPADDING;
+	pcfg->pcm_cfg.ctrl_data_out_enable = AFE_PORT_PCM_CTRL_DATA_OE_DISABLE;
+	pcfg->pcm_cfg.reserved = 0;
+	pcfg->pcm_cfg.sample_rate = cfg->sample_rate;
+
+	/* 16 bit mono */
+	pcfg->pcm_cfg.bit_width = 16;
+	pcfg->pcm_cfg.num_channels = 1;
+	pcfg->pcm_cfg.slot_number_mapping[0] = 1;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(q6afe_pcm_port_prepare);
+
 /**
  * q6afe_i2s_port_prepare() - Prepare i2s afe port.
  *
@@ -1417,6 +1653,16 @@ struct q6afe_port *q6afe_port_get_from_id(struct device *dev, int id)
 	case AFE_PORT_ID_QUATERNARY_MI2S_TX:
 		cfg_type = AFE_PARAM_ID_I2S_CONFIG;
 		break;
+	case AFE_PORT_ID_PRIMARY_PCM_RX:
+	case AFE_PORT_ID_PRIMARY_PCM_TX:
+	case AFE_PORT_ID_SECONDARY_PCM_RX:
+	case AFE_PORT_ID_SECONDARY_PCM_TX:
+	case AFE_PORT_ID_TERTIARY_PCM_RX:
+	case AFE_PORT_ID_TERTIARY_PCM_TX:
+	case AFE_PORT_ID_QUATERNARY_PCM_RX:
+	case AFE_PORT_ID_QUATERNARY_PCM_TX:
+		cfg_type = AFE_PARAM_ID_PCM_CONFIG;
+		break;
 	case AFE_PORT_ID_PRIMARY_TDM_RX ... AFE_PORT_ID_QUINARY_TDM_TX_7:
 		cfg_type = AFE_PARAM_ID_TDM_CONFIG;
 		break;
diff --git a/sound/soc/qcom/qdsp6/q6afe.h b/sound/soc/qcom/qdsp6/q6afe.h
index c7ed5422baff..c832be6d0ff5 100644
--- a/sound/soc/qcom/qdsp6/q6afe.h
+++ b/sound/soc/qcom/qdsp6/q6afe.h
@@ -5,7 +5,7 @@
 
 #include <dt-bindings/sound/qcom,q6afe.h>
 
-#define AFE_PORT_MAX		105
+#define AFE_PORT_MAX		113
 
 #define MSM_AFE_PORT_TYPE_RX 0
 #define MSM_AFE_PORT_TYPE_TX 1
@@ -170,6 +170,11 @@ struct q6afe_i2s_cfg {
 	int fmt;
 };
 
+struct q6afe_pcm_cfg {
+	u32	sample_rate;
+	int fmt;
+};
+
 struct q6afe_tdm_cfg {
 	u16	num_channels;
 	u32	sample_rate;
@@ -188,6 +193,7 @@ struct q6afe_port_config {
 	struct q6afe_hdmi_cfg hdmi;
 	struct q6afe_slim_cfg slim;
 	struct q6afe_i2s_cfg i2s_cfg;
+	struct q6afe_pcm_cfg pcm_cfg;
 	struct q6afe_tdm_cfg tdm;
 };
 
@@ -203,6 +209,7 @@ void q6afe_hdmi_port_prepare(struct q6afe_port *port,
 void q6afe_slim_port_prepare(struct q6afe_port *port,
 			  struct q6afe_slim_cfg *cfg);
 int q6afe_i2s_port_prepare(struct q6afe_port *port, struct q6afe_i2s_cfg *cfg);
+int q6afe_pcm_port_prepare(struct q6afe_port *port, struct q6afe_pcm_cfg *cfg);
 void q6afe_tdm_port_prepare(struct q6afe_port *port, struct q6afe_tdm_cfg *cfg);
 
 int q6afe_port_set_sysclk(struct q6afe_port *port, int clk_id,
-- 
2.21.1


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v2 3/8] ASoC: qdsp6: q6afe-dai: add support to pcm port dais
  2020-02-09 15:47 ` [PATCH v2 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio Adam Serbinski
  2020-02-09 15:47   ` [PATCH v2 1/8] ASoC: qdsp6: dt-bindings: Add q6afe pcm dt binding Adam Serbinski
  2020-02-09 15:47   ` [PATCH v2 2/8] ASoC: qdsp6: q6afe: add support to pcm ports Adam Serbinski
@ 2020-02-09 15:47   ` Adam Serbinski
  2020-02-10 13:34     ` Mark Brown
  2020-02-10 17:13     ` Srinivas Kandagatla
  2020-02-09 15:47   ` [PATCH v2 4/8] ASoC: qdsp6: q6routing: add pcm port routing Adam Serbinski
                     ` (5 subsequent siblings)
  8 siblings, 2 replies; 41+ messages in thread
From: Adam Serbinski @ 2020-02-09 15:47 UTC (permalink / raw)
  To: Mark Brown, Srini Kandagatla, Rob Herring, Bjorn Andersson
  Cc: Adam Serbinski, Andy Gross, Mark Rutland, Liam Girdwood,
	Patrick Lai, Banajit Goswami, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, linux-arm-msm, devicetree, linux-kernel

This patch adds support of AFE DAI for PCM port.

Signed-off-by: Adam Serbinski <adam@serbinski.com>
CC: Andy Gross <agross@kernel.org>
CC: Mark Rutland <mark.rutland@arm.com>
CC: Liam Girdwood <lgirdwood@gmail.com>
CC: Patrick Lai <plai@codeaurora.org>
CC: Banajit Goswami <bgoswami@codeaurora.org>
CC: Jaroslav Kysela <perex@perex.cz>
CC: Takashi Iwai <tiwai@suse.com>
CC: alsa-devel@alsa-project.org
CC: linux-arm-msm@vger.kernel.org
CC: devicetree@vger.kernel.org
CC: linux-kernel@vger.kernel.org
---
 sound/soc/qcom/qdsp6/q6afe-dai.c | 198 ++++++++++++++++++++++++++++++-
 1 file changed, 197 insertions(+), 1 deletion(-)

diff --git a/sound/soc/qcom/qdsp6/q6afe-dai.c b/sound/soc/qcom/qdsp6/q6afe-dai.c
index c1a7624eaf17..23b29591ef47 100644
--- a/sound/soc/qcom/qdsp6/q6afe-dai.c
+++ b/sound/soc/qcom/qdsp6/q6afe-dai.c
@@ -151,6 +151,28 @@ static int q6hdmi_hw_params(struct snd_pcm_substream *substream,
 	return 0;
 }
 
+static int q6pcm_hw_params(struct snd_pcm_substream *substream,
+			   struct snd_pcm_hw_params *params,
+			   struct snd_soc_dai *dai)
+{
+	struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
+	struct q6afe_pcm_cfg *pcm = &dai_data->port_config[dai->id].pcm_cfg;
+
+	pcm->sample_rate = params_rate(params);
+
+	return 0;
+}
+
+static int q6pcm_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
+{
+	struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
+	struct q6afe_pcm_cfg *pcm = &dai_data->port_config[dai->id].pcm_cfg;
+
+	pcm->fmt = fmt;
+
+	return 0;
+}
+
 static int q6i2s_hw_params(struct snd_pcm_substream *substream,
 			   struct snd_pcm_hw_params *params,
 			   struct snd_soc_dai *dai)
@@ -358,6 +380,15 @@ static int q6afe_dai_prepare(struct snd_pcm_substream *substream,
 			return rc;
 		}
 		break;
+	case PRIMARY_PCM_RX ... QUATERNARY_PCM_TX:
+		rc = q6afe_pcm_port_prepare(dai_data->port[dai->id],
+				&dai_data->port_config[dai->id].pcm_cfg);
+		if (rc < 0) {
+			dev_err(dai->dev, "fail to prepare AFE port %x\n",
+				dai->id);
+			return rc;
+		}
+		break;
 	case PRIMARY_TDM_RX_0 ... QUINARY_TDM_TX_7:
 		q6afe_tdm_port_prepare(dai_data->port[dai->id],
 					&dai_data->port_config[dai->id].tdm);
@@ -429,11 +460,32 @@ static int q6afe_mi2s_set_sysclk(struct snd_soc_dai *dai,
 					     Q6AFE_LPASS_CLK_ROOT_DEFAULT,
 					     freq, dir);
 	case Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT ... Q6AFE_LPASS_CLK_ID_QUI_MI2S_OSR:
+	case Q6AFE_LPASS_CLK_ID_PRI_PCM_IBIT ... Q6AFE_LPASS_CLK_ID_QUI_PCM_OSR:
 	case Q6AFE_LPASS_CLK_ID_MCLK_1 ... Q6AFE_LPASS_CLK_ID_INT_MCLK_1:
 		return q6afe_port_set_sysclk(port, clk_id,
 					     Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
 					     Q6AFE_LPASS_CLK_ROOT_DEFAULT,
 					     freq, dir);
+	}
+
+	return 0;
+}
+
+static int q6afe_tdm_set_sysclk(struct snd_soc_dai *dai,
+		int clk_id, unsigned int freq, int dir)
+{
+	struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
+	struct q6afe_port *port = dai_data->port[dai->id];
+
+	switch (clk_id) {
+	case LPAIF_DIG_CLK:
+		return q6afe_port_set_sysclk(port, clk_id, 0, 5, freq, dir);
+	case LPAIF_BIT_CLK:
+	case LPAIF_OSR_CLK:
+		return q6afe_port_set_sysclk(port, clk_id,
+					     Q6AFE_LPASS_CLK_SRC_INTERNAL,
+					     Q6AFE_LPASS_CLK_ROOT_DEFAULT,
+					     freq, dir);
 	case Q6AFE_LPASS_CLK_ID_PRI_TDM_IBIT ... Q6AFE_LPASS_CLK_ID_QUIN_TDM_EBIT:
 		return q6afe_port_set_sysclk(port, clk_id,
 					     Q6AFE_LPASS_CLK_ATTRIBUTE_INVERT_COUPLE_NO,
@@ -468,6 +520,11 @@ static const struct snd_soc_dapm_route q6afe_dapm_routes[] = {
 	{"Tertiary MI2S Playback", NULL, "TERT_MI2S_RX"},
 	{"Quaternary MI2S Playback", NULL, "QUAT_MI2S_RX"},
 
+	{"Primary PCM Playback", NULL, "PRI_PCM_RX"},
+	{"Secondary PCM Playback", NULL, "SEC_PCM_RX"},
+	{"Tertiary PCM Playback", NULL, "TERT_PCM_RX"},
+	{"Quaternary PCM Playback", NULL, "QUAT_PCM_RX"},
+
 	{"Primary TDM0 Playback", NULL, "PRIMARY_TDM_RX_0"},
 	{"Primary TDM1 Playback", NULL, "PRIMARY_TDM_RX_1"},
 	{"Primary TDM2 Playback", NULL, "PRIMARY_TDM_RX_2"},
@@ -562,6 +619,11 @@ static const struct snd_soc_dapm_route q6afe_dapm_routes[] = {
 	{"PRI_MI2S_TX", NULL, "Primary MI2S Capture"},
 	{"SEC_MI2S_TX", NULL, "Secondary MI2S Capture"},
 	{"QUAT_MI2S_TX", NULL, "Quaternary MI2S Capture"},
+
+	{"PRI_PCM_TX", NULL, "Primary PCM Capture"},
+	{"SEC_PCM_TX", NULL, "Secondary PCM Capture"},
+	{"TERT_PCM_TX", NULL, "Tertiary PCM Capture"},
+	{"QUAT_PCM_TX", NULL, "Quaternary PCM Capture"},
 };
 
 static const struct snd_soc_dai_ops q6hdmi_ops = {
@@ -578,6 +640,14 @@ static const struct snd_soc_dai_ops q6i2s_ops = {
 	.set_sysclk	= q6afe_mi2s_set_sysclk,
 };
 
+static const struct snd_soc_dai_ops q6pcm_ops = {
+	.prepare	= q6afe_dai_prepare,
+	.hw_params	= q6pcm_hw_params,
+	.set_fmt	= q6pcm_set_fmt,
+	.shutdown	= q6afe_dai_shutdown,
+	.set_sysclk	= q6afe_mi2s_set_sysclk,
+};
+
 static const struct snd_soc_dai_ops q6slim_ops = {
 	.prepare	= q6afe_dai_prepare,
 	.hw_params	= q6slim_hw_params,
@@ -588,7 +658,7 @@ static const struct snd_soc_dai_ops q6slim_ops = {
 static const struct snd_soc_dai_ops q6tdm_ops = {
 	.prepare	= q6afe_dai_prepare,
 	.shutdown	= q6afe_dai_shutdown,
-	.set_sysclk	= q6afe_mi2s_set_sysclk,
+	.set_sysclk	= q6afe_tdm_set_sysclk,
 	.set_tdm_slot     = q6tdm_set_tdm_slot,
 	.set_channel_map  = q6tdm_set_channel_map,
 	.hw_params        = q6tdm_hw_params,
@@ -1012,6 +1082,115 @@ static struct snd_soc_dai_driver q6afe_dais[] = {
 		.ops = &q6i2s_ops,
 		.probe = msm_dai_q6_dai_probe,
 		.remove = msm_dai_q6_dai_remove,
+	}, {
+		.playback = {
+			.stream_name = "Primary PCM Playback",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE |
+				   SNDRV_PCM_FMTBIT_S24_LE,
+			.rate_min =     8000,
+			.rate_max =     16000,
+		},
+		.id = PRIMARY_PCM_RX,
+		.name = "PRI_PCM_RX",
+		.ops = &q6pcm_ops,
+		.probe = msm_dai_q6_dai_probe,
+		.remove = msm_dai_q6_dai_remove,
+	}, {
+		.capture = {
+			.stream_name = "Primary PCM Capture",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE |
+				   SNDRV_PCM_FMTBIT_S24_LE,
+			.rate_min =     8000,
+			.rate_max =     16000,
+		},
+		.id = PRIMARY_PCM_TX,
+		.name = "PRI_PCM_TX",
+		.ops = &q6pcm_ops,
+		.probe = msm_dai_q6_dai_probe,
+		.remove = msm_dai_q6_dai_remove,
+	}, {
+		.playback = {
+			.stream_name = "Secondary PCM Playback",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE,
+			.rate_min =     8000,
+			.rate_max =     16000,
+		},
+		.name = "SEC_PCM_RX",
+		.id = SECONDARY_PCM_RX,
+		.ops = &q6pcm_ops,
+		.probe = msm_dai_q6_dai_probe,
+		.remove = msm_dai_q6_dai_remove,
+	}, {
+		.capture = {
+			.stream_name = "Secondary PCM Capture",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE |
+				   SNDRV_PCM_FMTBIT_S24_LE,
+			.rate_min =     8000,
+			.rate_max =     16000,
+		},
+		.id = SECONDARY_PCM_TX,
+		.name = "SEC_PCM_TX",
+		.ops = &q6pcm_ops,
+		.probe = msm_dai_q6_dai_probe,
+		.remove = msm_dai_q6_dai_remove,
+	}, {
+		.playback = {
+			.stream_name = "Tertiary PCM Playback",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE,
+			.rate_min =     8000,
+			.rate_max =     16000,
+		},
+		.name = "TERT_PCM_RX",
+		.id = TERTIARY_PCM_RX,
+		.ops = &q6pcm_ops,
+		.probe = msm_dai_q6_dai_probe,
+		.remove = msm_dai_q6_dai_remove,
+	}, {
+		.capture = {
+			.stream_name = "Tertiary PCM Capture",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE |
+				   SNDRV_PCM_FMTBIT_S24_LE,
+			.rate_min =     8000,
+			.rate_max =     16000,
+		},
+		.id = TERTIARY_PCM_TX,
+		.name = "TERT_PCM_TX",
+		.ops = &q6pcm_ops,
+		.probe = msm_dai_q6_dai_probe,
+		.remove = msm_dai_q6_dai_remove,
+	}, {
+		.playback = {
+			.stream_name = "Quaternary PCM Playback",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE,
+			.rate_min =     8000,
+			.rate_max =     16000,
+		},
+		.name = "QUAT_PCM_RX",
+		.id = QUATERNARY_PCM_RX,
+		.ops = &q6pcm_ops,
+		.probe = msm_dai_q6_dai_probe,
+		.remove = msm_dai_q6_dai_remove,
+	}, {
+		.capture = {
+			.stream_name = "Quaternary PCM Capture",
+			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
+			.formats = SNDRV_PCM_FMTBIT_S16_LE |
+				   SNDRV_PCM_FMTBIT_S24_LE,
+			.rate_min =     8000,
+			.rate_max =     16000,
+		},
+		.id = QUATERNARY_PCM_TX,
+		.name = "QUAT_PCM_TX",
+		.ops = &q6pcm_ops,
+		.probe = msm_dai_q6_dai_probe,
+		.remove = msm_dai_q6_dai_remove,
 	},
 	Q6AFE_TDM_PB_DAI("Primary", 0, PRIMARY_TDM_RX_0),
 	Q6AFE_TDM_PB_DAI("Primary", 1, PRIMARY_TDM_RX_1),
@@ -1169,6 +1348,23 @@ static const struct snd_soc_dapm_widget q6afe_dai_widgets[] = {
 	SND_SOC_DAPM_AIF_OUT("PRI_MI2S_TX", NULL,
 						0, 0, 0, 0),
 
+	SND_SOC_DAPM_AIF_IN("QUAT_PCM_RX", NULL,
+			    0, 0, 0, 0),
+	SND_SOC_DAPM_AIF_OUT("QUAT_PCM_TX", NULL,
+			     0, 0, 0, 0),
+	SND_SOC_DAPM_AIF_IN("TERT_PCM_RX", NULL,
+			    0, 0, 0, 0),
+	SND_SOC_DAPM_AIF_OUT("TERT_PCM_TX", NULL,
+			     0, 0, 0, 0),
+	SND_SOC_DAPM_AIF_IN("SEC_PCM_RX", NULL,
+			    0, 0, 0, 0),
+	SND_SOC_DAPM_AIF_OUT("SEC_PCM_TX", NULL,
+			     0, 0, 0, 0),
+	SND_SOC_DAPM_AIF_IN("PRI_PCM_RX", NULL,
+			    0, 0, 0, 0),
+	SND_SOC_DAPM_AIF_OUT("PRI_PCM_TX", NULL,
+			     0, 0, 0, 0),
+
 	SND_SOC_DAPM_AIF_IN("PRIMARY_TDM_RX_0", NULL,
 			     0, 0, 0, 0),
 	SND_SOC_DAPM_AIF_IN("PRIMARY_TDM_RX_1", NULL,
-- 
2.21.1


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v2 4/8] ASoC: qdsp6: q6routing: add pcm port routing
  2020-02-09 15:47 ` [PATCH v2 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio Adam Serbinski
                     ` (2 preceding siblings ...)
  2020-02-09 15:47   ` [PATCH v2 3/8] ASoC: qdsp6: q6afe-dai: add support to pcm port dais Adam Serbinski
@ 2020-02-09 15:47   ` Adam Serbinski
  2020-02-10 17:19     ` Srinivas Kandagatla
  2020-02-09 15:47   ` [PATCH v2 5/8] ASoC: qcom: apq8096: add support for primary and quaternary I2S/PCM Adam Serbinski
                     ` (4 subsequent siblings)
  8 siblings, 1 reply; 41+ messages in thread
From: Adam Serbinski @ 2020-02-09 15:47 UTC (permalink / raw)
  To: Mark Brown, Srini Kandagatla, Rob Herring, Bjorn Andersson
  Cc: Adam Serbinski, Andy Gross, Mark Rutland, Liam Girdwood,
	Patrick Lai, Banajit Goswami, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, linux-arm-msm, devicetree, linux-kernel

This patch adds support to PCM_PORT mixers required to
select path between ASM stream and AFE ports.

Signed-off-by: Adam Serbinski <adam@serbinski.com>
CC: Andy Gross <agross@kernel.org>
CC: Mark Rutland <mark.rutland@arm.com>
CC: Liam Girdwood <lgirdwood@gmail.com>
CC: Patrick Lai <plai@codeaurora.org>
CC: Banajit Goswami <bgoswami@codeaurora.org>
CC: Jaroslav Kysela <perex@perex.cz>
CC: Takashi Iwai <tiwai@suse.com>
CC: alsa-devel@alsa-project.org
CC: linux-arm-msm@vger.kernel.org
CC: devicetree@vger.kernel.org
CC: linux-kernel@vger.kernel.org
---
 sound/soc/qcom/qdsp6/q6routing.c | 44 ++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/sound/soc/qcom/qdsp6/q6routing.c b/sound/soc/qcom/qdsp6/q6routing.c
index 20724102e85a..3a81d2161707 100644
--- a/sound/soc/qcom/qdsp6/q6routing.c
+++ b/sound/soc/qcom/qdsp6/q6routing.c
@@ -67,6 +67,10 @@
 	{ mix_name, "SEC_MI2S_TX", "SEC_MI2S_TX" },	\
 	{ mix_name, "QUAT_MI2S_TX", "QUAT_MI2S_TX" },	\
 	{ mix_name, "TERT_MI2S_TX", "TERT_MI2S_TX" },		\
+	{ mix_name, "PRI_PCM_TX", "PRI_PCM_TX" },		\
+	{ mix_name, "SEC_PCM_TX", "SEC_PCM_TX" },		\
+	{ mix_name, "TERT_PCM_TX", "TERT_PCM_TX" },		\
+	{ mix_name, "QUAT_PCM_TX", "QUAT_PCM_TX" },		\
 	{ mix_name, "SLIMBUS_0_TX", "SLIMBUS_0_TX" },		\
 	{ mix_name, "SLIMBUS_1_TX", "SLIMBUS_1_TX" },		\
 	{ mix_name, "SLIMBUS_2_TX", "SLIMBUS_2_TX" },		\
@@ -128,6 +132,18 @@
 	SOC_SINGLE_EXT("QUAT_MI2S_TX", QUATERNARY_MI2S_TX,		\
 		id, 1, 0, msm_routing_get_audio_mixer,			\
 		msm_routing_put_audio_mixer),				\
+	SOC_SINGLE_EXT("PRI_PCM_TX", PRIMARY_PCM_TX,			\
+		id, 1, 0, msm_routing_get_audio_mixer,			\
+		msm_routing_put_audio_mixer),				\
+	SOC_SINGLE_EXT("SEC_PCM_TX", SECONDARY_PCM_TX,			\
+		id, 1, 0, msm_routing_get_audio_mixer,			\
+		msm_routing_put_audio_mixer),				\
+	SOC_SINGLE_EXT("TERT_PCM_TX", TERTIARY_PCM_TX,			\
+		id, 1, 0, msm_routing_get_audio_mixer,			\
+		msm_routing_put_audio_mixer),				\
+	SOC_SINGLE_EXT("QUAT_PCM_TX", QUATERNARY_PCM_TX,		\
+		id, 1, 0, msm_routing_get_audio_mixer,			\
+		msm_routing_put_audio_mixer),				\
 	SOC_SINGLE_EXT("SLIMBUS_0_TX", SLIMBUS_0_TX,			\
 		id, 1, 0, msm_routing_get_audio_mixer,			\
 		msm_routing_put_audio_mixer),				\
@@ -468,6 +484,18 @@ static const struct snd_kcontrol_new quaternary_mi2s_rx_mixer_controls[] = {
 static const struct snd_kcontrol_new tertiary_mi2s_rx_mixer_controls[] = {
 	Q6ROUTING_RX_MIXERS(TERTIARY_MI2S_RX) };
 
+static const struct snd_kcontrol_new primary_pcm_rx_mixer_controls[] = {
+	Q6ROUTING_RX_MIXERS(PRIMARY_PCM_RX) };
+
+static const struct snd_kcontrol_new secondary_pcm_rx_mixer_controls[] = {
+	Q6ROUTING_RX_MIXERS(SECONDARY_PCM_RX) };
+
+static const struct snd_kcontrol_new tertiary_pcm_rx_mixer_controls[] = {
+	Q6ROUTING_RX_MIXERS(TERTIARY_PCM_RX) };
+
+static const struct snd_kcontrol_new quaternary_pcm_rx_mixer_controls[] = {
+	Q6ROUTING_RX_MIXERS(QUATERNARY_PCM_RX) };
+
 static const struct snd_kcontrol_new slimbus_rx_mixer_controls[] = {
 	Q6ROUTING_RX_MIXERS(SLIMBUS_0_RX) };
 
@@ -695,6 +723,18 @@ static const struct snd_soc_dapm_widget msm_qdsp6_widgets[] = {
 	SND_SOC_DAPM_MIXER("TERT_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
 			   tertiary_mi2s_rx_mixer_controls,
 			   ARRAY_SIZE(tertiary_mi2s_rx_mixer_controls)),
+	SND_SOC_DAPM_MIXER("PRI_PCM_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
+			   primary_pcm_rx_mixer_controls,
+			   ARRAY_SIZE(primary_pcm_rx_mixer_controls)),
+	SND_SOC_DAPM_MIXER("SEC_PCM_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
+			   secondary_pcm_rx_mixer_controls,
+			   ARRAY_SIZE(secondary_pcm_rx_mixer_controls)),
+	SND_SOC_DAPM_MIXER("TERT_PCM_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
+			   tertiary_pcm_rx_mixer_controls,
+			   ARRAY_SIZE(tertiary_pcm_rx_mixer_controls)),
+	SND_SOC_DAPM_MIXER("QUAT_PCM_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
+			   quaternary_pcm_rx_mixer_controls,
+			   ARRAY_SIZE(quaternary_pcm_rx_mixer_controls)),
 	SND_SOC_DAPM_MIXER("PRIMARY_TDM_RX_0 Audio Mixer", SND_SOC_NOPM, 0, 0,
 				pri_tdm_rx_0_mixer_controls,
 				ARRAY_SIZE(pri_tdm_rx_0_mixer_controls)),
@@ -853,6 +893,10 @@ static const struct snd_soc_dapm_route intercon[] = {
 	Q6ROUTING_RX_DAPM_ROUTE("TERT_MI2S_RX Audio Mixer", "TERT_MI2S_RX"),
 	Q6ROUTING_RX_DAPM_ROUTE("SEC_MI2S_RX Audio Mixer", "SEC_MI2S_RX"),
 	Q6ROUTING_RX_DAPM_ROUTE("PRI_MI2S_RX Audio Mixer", "PRI_MI2S_RX"),
+	Q6ROUTING_RX_DAPM_ROUTE("PRI_PCM_RX Audio Mixer", "PRI_PCM_RX"),
+	Q6ROUTING_RX_DAPM_ROUTE("SEC_PCM_RX Audio Mixer", "SEC_PCM_RX"),
+	Q6ROUTING_RX_DAPM_ROUTE("TERT_PCM_RX Audio Mixer", "TERT_PCM_RX"),
+	Q6ROUTING_RX_DAPM_ROUTE("QUAT_PCM_RX Audio Mixer", "QUAT_PCM_RX"),
 	Q6ROUTING_RX_DAPM_ROUTE("PRIMARY_TDM_RX_0 Audio Mixer",
 				"PRIMARY_TDM_RX_0"),
 	Q6ROUTING_RX_DAPM_ROUTE("PRIMARY_TDM_RX_1 Audio Mixer",
-- 
2.21.1


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v2 5/8] ASoC: qcom: apq8096: add support for primary and quaternary I2S/PCM
  2020-02-09 15:47 ` [PATCH v2 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio Adam Serbinski
                     ` (3 preceding siblings ...)
  2020-02-09 15:47   ` [PATCH v2 4/8] ASoC: qdsp6: q6routing: add pcm port routing Adam Serbinski
@ 2020-02-09 15:47   ` Adam Serbinski
  2020-02-09 15:47   ` [PATCH v2 6/8] ASoC: qcom/common: Use snd-soc-dummy-dai when codec is not specified Adam Serbinski
                     ` (3 subsequent siblings)
  8 siblings, 0 replies; 41+ messages in thread
From: Adam Serbinski @ 2020-02-09 15:47 UTC (permalink / raw)
  To: Mark Brown, Srini Kandagatla, Rob Herring, Bjorn Andersson
  Cc: Adam Serbinski, Andy Gross, Mark Rutland, Liam Girdwood,
	Patrick Lai, Banajit Goswami, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, linux-arm-msm, devicetree, linux-kernel

This adds support to primary and quarternary I2S and PCM ports.

Signed-off-by: Adam Serbinski <adam@serbinski.com>
CC: Andy Gross <agross@kernel.org>
CC: Mark Rutland <mark.rutland@arm.com>
CC: Liam Girdwood <lgirdwood@gmail.com>
CC: Patrick Lai <plai@codeaurora.org>
CC: Banajit Goswami <bgoswami@codeaurora.org>
CC: Jaroslav Kysela <perex@perex.cz>
CC: Takashi Iwai <tiwai@suse.com>
CC: alsa-devel@alsa-project.org
CC: linux-arm-msm@vger.kernel.org
CC: devicetree@vger.kernel.org
CC: linux-kernel@vger.kernel.org
---
 sound/soc/qcom/apq8096.c | 86 +++++++++++++++++++++++++++++++++-------
 1 file changed, 71 insertions(+), 15 deletions(-)

diff --git a/sound/soc/qcom/apq8096.c b/sound/soc/qcom/apq8096.c
index 94363fd6846a..1edcaa15234f 100644
--- a/sound/soc/qcom/apq8096.c
+++ b/sound/soc/qcom/apq8096.c
@@ -8,24 +8,13 @@
 #include <sound/soc-dapm.h>
 #include <sound/pcm.h>
 #include "common.h"
+#include "qdsp6/q6afe.h"
 
 #define SLIM_MAX_TX_PORTS 16
 #define SLIM_MAX_RX_PORTS 16
 #define WCD9335_DEFAULT_MCLK_RATE	9600000
-
-static int apq8096_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
-				      struct snd_pcm_hw_params *params)
-{
-	struct snd_interval *rate = hw_param_interval(params,
-					SNDRV_PCM_HW_PARAM_RATE);
-	struct snd_interval *channels = hw_param_interval(params,
-					SNDRV_PCM_HW_PARAM_CHANNELS);
-
-	rate->min = rate->max = 48000;
-	channels->min = channels->max = 2;
-
-	return 0;
-}
+#define MI2S_BCLK_RATE			1536000
+#define PCM_BCLK_RATE			1024000
 
 static int msm_snd_hw_params(struct snd_pcm_substream *substream,
 			     struct snd_pcm_hw_params *params)
@@ -33,10 +22,32 @@ static int msm_snd_hw_params(struct snd_pcm_substream *substream,
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
+	struct snd_interval *rate = hw_param_interval(params,
+					SNDRV_PCM_HW_PARAM_RATE);
+	struct snd_interval *channels = hw_param_interval(params,
+					SNDRV_PCM_HW_PARAM_CHANNELS);
 	u32 rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS];
 	u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
 	int ret = 0;
 
+	switch (cpu_dai->id) {
+	case PRIMARY_PCM_RX:
+	case PRIMARY_PCM_TX:
+	case QUATERNARY_PCM_RX:
+	case QUATERNARY_PCM_TX:
+		rate->min = 16000;
+		rate->max = 16000;
+		channels->min = 1;
+		channels->max = 1;
+		break;
+	default:
+		rate->min = 48000;
+		rate->max = 48000;
+		channels->min = 1;
+		channels->max = 2;
+		break;
+	}
+
 	ret = snd_soc_dai_get_channel_map(codec_dai,
 				&tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
 	if (ret != 0 && ret != -ENOTSUPP) {
@@ -60,8 +71,54 @@ static int msm_snd_hw_params(struct snd_pcm_substream *substream,
 	return ret;
 }
 
+static int msm_snd_startup(struct snd_pcm_substream *substream)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
+	struct snd_soc_dai *codec_dai = rtd->codec_dai;
+
+	switch (cpu_dai->id) {
+	case PRIMARY_MI2S_RX:
+	case PRIMARY_MI2S_TX:
+		snd_soc_dai_set_sysclk(cpu_dai,
+			Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT,
+			MI2S_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK);
+		snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBS_CFS);
+		snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_CBS_CFS);
+		break;
+	case QUATERNARY_MI2S_RX:
+	case QUATERNARY_MI2S_TX:
+		snd_soc_dai_set_sysclk(cpu_dai,
+			Q6AFE_LPASS_CLK_ID_QUAD_MI2S_IBIT,
+			MI2S_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK);
+		snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBS_CFS);
+		snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_CBS_CFS);
+		break;
+	case PRIMARY_PCM_RX:
+	case PRIMARY_PCM_TX:
+		snd_soc_dai_set_sysclk(cpu_dai,
+			Q6AFE_LPASS_CLK_ID_PRI_PCM_IBIT,
+			PCM_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK);
+		snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBS_CFS);
+		snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_CBS_CFS);
+		break;
+	case QUATERNARY_PCM_RX:
+	case QUATERNARY_PCM_TX:
+		snd_soc_dai_set_sysclk(cpu_dai,
+			Q6AFE_LPASS_CLK_ID_QUAD_PCM_IBIT,
+			PCM_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK);
+		snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBS_CFS);
+		snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_CBS_CFS);
+		break;
+	default:
+		return -1;
+	}
+	return 0;
+}
+
 static struct snd_soc_ops apq8096_ops = {
 	.hw_params = msm_snd_hw_params,
+	.startup = msm_snd_startup,
 };
 
 static int apq8096_init(struct snd_soc_pcm_runtime *rtd)
@@ -96,7 +153,6 @@ static void apq8096_add_be_ops(struct snd_soc_card *card)
 
 	for_each_card_prelinks(card, i, link) {
 		if (link->no_pcm == 1) {
-			link->be_hw_params_fixup = apq8096_be_hw_params_fixup;
 			link->init = apq8096_init;
 			link->ops = &apq8096_ops;
 		}
-- 
2.21.1


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v2 6/8] ASoC: qcom/common: Use snd-soc-dummy-dai when codec is not specified
  2020-02-09 15:47 ` [PATCH v2 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio Adam Serbinski
                     ` (4 preceding siblings ...)
  2020-02-09 15:47   ` [PATCH v2 5/8] ASoC: qcom: apq8096: add support for primary and quaternary I2S/PCM Adam Serbinski
@ 2020-02-09 15:47   ` Adam Serbinski
  2020-02-10 13:35     ` Mark Brown
  2020-02-09 15:47   ` [PATCH v2 7/8] arm64: dts: qcom: db820c: Enable primary PCM and quaternary I2S Adam Serbinski
                     ` (2 subsequent siblings)
  8 siblings, 1 reply; 41+ messages in thread
From: Adam Serbinski @ 2020-02-09 15:47 UTC (permalink / raw)
  To: Mark Brown, Srini Kandagatla, Rob Herring, Bjorn Andersson
  Cc: Adam Serbinski, Andy Gross, Mark Rutland, Liam Girdwood,
	Patrick Lai, Banajit Goswami, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, linux-arm-msm, devicetree, linux-kernel

When not specifying a codec, use snd-soc-dummy-dai. This supports
the case where a fixed configuration codec is attached, such as
bluetooth hfp.

Signed-off-by: Adam Serbinski <adam@serbinski.com>
CC: Andy Gross <agross@kernel.org>
CC: Mark Rutland <mark.rutland@arm.com>
CC: Liam Girdwood <lgirdwood@gmail.com>
CC: Patrick Lai <plai@codeaurora.org>
CC: Banajit Goswami <bgoswami@codeaurora.org>
CC: Jaroslav Kysela <perex@perex.cz>
CC: Takashi Iwai <tiwai@suse.com>
CC: alsa-devel@alsa-project.org
CC: linux-arm-msm@vger.kernel.org
CC: devicetree@vger.kernel.org
CC: linux-kernel@vger.kernel.org
---
 sound/soc/qcom/common.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/sound/soc/qcom/common.c b/sound/soc/qcom/common.c
index 6c20bdd850f3..aa2f2238aca0 100644
--- a/sound/soc/qcom/common.c
+++ b/sound/soc/qcom/common.c
@@ -84,7 +84,7 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
 			goto err;
 		}
 
-		if (codec && platform) {
+		if (platform) {
 			link->platforms->of_node = of_parse_phandle(platform,
 					"sound-dai",
 					0);
@@ -94,10 +94,22 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
 				goto err;
 			}
 
-			ret = snd_soc_of_get_dai_link_codecs(dev, codec, link);
-			if (ret < 0) {
-				dev_err(card->dev, "%s: codec dai not found\n", link->name);
-				goto err;
+			if (codec) {
+				ret = snd_soc_of_get_dai_link_codecs(dev, codec, link);
+				if (ret < 0) {
+					dev_err(card->dev, "%s: codec dai not found\n", link->name);
+					goto err;
+				}
+			} else {
+				dlc = devm_kzalloc(dev,
+						   sizeof(*dlc), GFP_KERNEL);
+				if (!dlc)
+					return -ENOMEM;
+
+				link->codecs = dlc;
+				link->num_codecs = 1;
+				link->codecs->dai_name = "snd-soc-dummy-dai";
+				link->codecs->name = "snd-soc-dummy";
 			}
 			link->no_pcm = 1;
 			link->ignore_pmdown_time = 1;
-- 
2.21.1


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v2 7/8] arm64: dts: qcom: db820c: Enable primary PCM and quaternary I2S
  2020-02-09 15:47 ` [PATCH v2 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio Adam Serbinski
                     ` (5 preceding siblings ...)
  2020-02-09 15:47   ` [PATCH v2 6/8] ASoC: qcom/common: Use snd-soc-dummy-dai when codec is not specified Adam Serbinski
@ 2020-02-09 15:47   ` Adam Serbinski
  2020-02-09 15:47   ` [PATCH v2 8/8] ASoC: qcom: apq8096: add kcontrols to set PCM rate Adam Serbinski
  2020-02-10 12:17   ` [PATCH v2 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio Mark Brown
  8 siblings, 0 replies; 41+ messages in thread
From: Adam Serbinski @ 2020-02-09 15:47 UTC (permalink / raw)
  To: Mark Brown, Srini Kandagatla, Rob Herring, Bjorn Andersson
  Cc: Adam Serbinski, Andy Gross, Mark Rutland, Liam Girdwood,
	Patrick Lai, Banajit Goswami, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, linux-arm-msm, devicetree, linux-kernel

This patch adds support to primary pcm and quaternary i2s ports.

Signed-off-by: Adam Serbinski <adam@serbinski.com>
CC: Andy Gross <agross@kernel.org>
CC: Mark Rutland <mark.rutland@arm.com>
CC: Liam Girdwood <lgirdwood@gmail.com>
CC: Patrick Lai <plai@codeaurora.org>
CC: Banajit Goswami <bgoswami@codeaurora.org>
CC: Jaroslav Kysela <perex@perex.cz>
CC: Takashi Iwai <tiwai@suse.com>
CC: alsa-devel@alsa-project.org
CC: linux-arm-msm@vger.kernel.org
CC: devicetree@vger.kernel.org
CC: linux-kernel@vger.kernel.org
---
 arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi | 113 +++++++++++++
 arch/arm64/boot/dts/qcom/msm8996-pins.dtsi   | 162 +++++++++++++++++++
 2 files changed, 275 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi b/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi
index dba3488492f1..4149ac4147a0 100644
--- a/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi
+++ b/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi
@@ -683,8 +683,31 @@
 	};
 };
 
+/* PRI I2S on QCA6174 and QUAT I2S on LS each uses 2 I2S SD Lines for audio */
+&q6afedai {
+	pi2s@16 {
+		reg = <16>;
+		qcom,sd-lines = <1>;
+	};
+	pi2s@17 {
+		reg = <17>;
+		qcom,sd-lines = <0>;
+	};
+	qi2s@22 {
+		reg = <22>;
+		qcom,sd-lines = <0>;
+	};
+	qi2s@23 {
+		reg = <23>;
+		qcom,sd-lines = <1>;
+	};
+};
+
 &sound {
 	compatible = "qcom,apq8096-sndcard";
+	pinctrl-0 = <&quat_mi2s_active &quat_mi2s_sd0_active &quat_mi2s_sd1_active &pri_mi2s_active &pri_mi2s_sd0_active &pri_mi2s_sd1_active>;
+	pinctrl-names = "default";
+
 	model = "DB820c";
 	audio-routing =	"RX_BIAS", "MCLK";
 
@@ -709,6 +732,41 @@
 		};
 	};
 
+	mm4-dai-link {
+		link-name = "MultiMedia4";
+		cpu {
+			sound-dai = <&q6asmdai  MSM_FRONTEND_DAI_MULTIMEDIA4>;
+		};
+	};
+
+	mm5-dai-link {
+		link-name = "MultiMedia5";
+		cpu {
+			sound-dai = <&q6asmdai  MSM_FRONTEND_DAI_MULTIMEDIA5>;
+		};
+	};
+
+	mm6-dai-link {
+		link-name = "MultiMedia6";
+		cpu {
+			sound-dai = <&q6asmdai  MSM_FRONTEND_DAI_MULTIMEDIA6>;
+		};
+	};
+
+	mm7-dai-link {
+		link-name = "MultiMedia7";
+		cpu {
+			sound-dai = <&q6asmdai  MSM_FRONTEND_DAI_MULTIMEDIA7>;
+		};
+	};
+
+	mm8-dai-link {
+		link-name = "MultiMedia8";
+		cpu {
+			sound-dai = <&q6asmdai  MSM_FRONTEND_DAI_MULTIMEDIA8>;
+		};
+	};
+
 	hdmi-dai-link {
 		link-name = "HDMI";
 		cpu {
@@ -753,4 +811,59 @@
 			sound-dai = <&wcd9335 1>;
 		};
 	};
+
+	scoplay-dai-link {
+		link-name = "SCO-PCM-Playback";
+		cpu {
+			sound-dai = <&q6afedai PRIMARY_PCM_RX>;
+		};
+
+		platform {
+			sound-dai = <&q6routing>;
+		};
+	};
+
+	scocap-dai-link {
+		link-name = "SCO-PCM-Capture";
+		cpu {
+			sound-dai = <&q6afedai PRIMARY_PCM_TX>;
+		};
+
+		platform {
+			sound-dai = <&q6routing>;
+		};
+	};
+
+	mi2splay-dai-link {
+		link-name = "QUAT-MI2S-Playback";
+		cpu {
+			sound-dai = <&q6afedai QUATERNARY_MI2S_RX>;
+		};
+
+		platform {
+			sound-dai = <&q6routing>;
+		};
+
+//		EXAMPLE: For adding real codecs
+//		codec {
+//			sound-dai = <&pcm5142_4c>, <&pcm5142_4d>;
+//		};
+
+	};
+
+	mi2scap-dai-link {
+		link-name = "QUAT-MI2S-Capture";
+		cpu {
+			sound-dai = <&q6afedai QUATERNARY_MI2S_TX>;
+		};
+
+		platform {
+			sound-dai = <&q6routing>;
+		};
+
+//		EXAMPLE: For adding real codecs
+//		codec {
+//			sound-dai = <&pcm1865>;
+//		};
+	};
 };
diff --git a/arch/arm64/boot/dts/qcom/msm8996-pins.dtsi b/arch/arm64/boot/dts/qcom/msm8996-pins.dtsi
index ac1ede579361..e8221c4d05f7 100644
--- a/arch/arm64/boot/dts/qcom/msm8996-pins.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8996-pins.dtsi
@@ -288,6 +288,168 @@
 		};
 	};
 
+	pri_mi2s_active: pri_mi2s_active {
+		mux {
+			pins = "gpio65", "gpio66";
+			function = "pri_mi2s";
+		};
+		config {
+			pins = "gpio65", "gpio66";
+			drive-strength = <8>;   /* 8 mA */
+			bias-disable;           /* NO PULL */
+			output-high;
+		};
+	};
+
+	pri_mi2s_sleep: pri_mi2s_sleep {
+		mux {
+			pins = "gpio65", "gpio66";
+			function = "gpio";
+		};
+
+		config {
+			pins = "gpio65", "gpio66";
+			drive-strength = <2>;   /* 2 mA */
+			bias-pull-down;         /* PULL DOWN */
+			input-enable;
+		};
+	};
+
+	pri_mi2s_sd0_sleep: pri_mi2s_sd0_sleep {
+		mux {
+			pins = "gpio67";
+			function = "gpio";
+		};
+
+		config {
+			pins = "gpio67";
+			drive-strength = <2>;   /* 2 mA */
+			bias-pull-down;         /* PULL DOWN */
+			input-enable;
+		};
+	};
+
+	pri_mi2s_sd0_active: pri_mi2s_sd0_active {
+		mux {
+			pins = "gpio67";
+			function = "pri_mi2s";
+		};
+
+		config {
+			pins = "gpio67";
+			drive-strength = <8>;   /* 8 mA */
+			bias-disable;           /* NO PULL */
+		};
+	};
+
+	pri_mi2s_sd1_sleep: pri_mi2s_sd1_sleep {
+		mux {
+			pins = "gpio68";
+			function = "gpio";
+		};
+
+		config {
+			pins = "gpio68";
+			drive-strength = <2>;   /* 2 mA */
+			bias-pull-down;         /* PULL DOWN */
+			input-enable;
+		};
+	};
+
+	pri_mi2s_sd1_active: pri_mi2s_sd1_active {
+		mux {
+			pins = "gpio68";
+			function = "pri_mi2s";
+		};
+
+		config {
+			pins = "gpio68";
+			drive-strength = <8>;   /* 8 mA */
+			bias-disable;           /* NO PULL */
+		};
+	};
+
+	quat_mi2s_active: quat_mi2s_active {
+		mux {
+			pins = "gpio58", "gpio59";
+			function = "qua_mi2s";
+		};
+		config {
+			pins = "gpio58", "gpio59";
+			drive-strength = <8>;   /* 8 mA */
+			bias-disable;           /* NO PULL */
+			output-high;
+		};
+	};
+
+	quat_mi2s_sleep: quat_mi2s_sleep {
+		mux {
+			pins = "gpio58", "gpio59";
+			function = "gpio";
+		};
+
+		config {
+			pins = "gpio58", "gpio59";
+			drive-strength = <2>;   /* 2 mA */
+			bias-pull-down;         /* PULL DOWN */
+			input-enable;
+		};
+	};
+
+	quat_mi2s_sd0_sleep: quat_mi2s_sd0_sleep {
+		mux {
+			pins = "gpio60";
+			function = "gpio";
+		};
+
+		config {
+			pins = "gpio60";
+			drive-strength = <2>;   /* 2 mA */
+			bias-pull-down;         /* PULL DOWN */
+			input-enable;
+		};
+	};
+
+	quat_mi2s_sd0_active: quat_mi2s_sd0_active {
+		mux {
+			pins = "gpio60";
+			function = "qua_mi2s";
+		};
+
+		config {
+			pins = "gpio60";
+			drive-strength = <8>;   /* 8 mA */
+			bias-disable;           /* NO PULL */
+		};
+	};
+
+	quat_mi2s_sd1_sleep: quat_mi2s_sd1_sleep {
+		mux {
+			pins = "gpio61";
+			function = "gpio";
+		};
+
+		config {
+			pins = "gpio61";
+			drive-strength = <2>;   /* 2 mA */
+			bias-pull-down;         /* PULL DOWN */
+			input-enable;
+		};
+	};
+
+	quat_mi2s_sd1_active: quat_mi2s_sd1_active {
+		mux {
+			pins = "gpio61";
+			function = "qua_mi2s";
+		};
+
+		config {
+			pins = "gpio61";
+			drive-strength = <8>;   /* 8 mA */
+			bias-disable;           /* NO PULL */
+		};
+	};
+
 	sdc2_clk_on: sdc2_clk_on {
 		config {
 			pins = "sdc2_clk";
-- 
2.21.1


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v2 8/8] ASoC: qcom: apq8096: add kcontrols to set PCM rate
  2020-02-09 15:47 ` [PATCH v2 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio Adam Serbinski
                     ` (6 preceding siblings ...)
  2020-02-09 15:47   ` [PATCH v2 7/8] arm64: dts: qcom: db820c: Enable primary PCM and quaternary I2S Adam Serbinski
@ 2020-02-09 15:47   ` Adam Serbinski
  2020-02-10 13:36     ` Mark Brown
  2020-02-10 16:18     ` Jaroslav Kysela
  2020-02-10 12:17   ` [PATCH v2 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio Mark Brown
  8 siblings, 2 replies; 41+ messages in thread
From: Adam Serbinski @ 2020-02-09 15:47 UTC (permalink / raw)
  To: Mark Brown, Srini Kandagatla, Rob Herring, Bjorn Andersson
  Cc: Adam Serbinski, Andy Gross, Mark Rutland, Liam Girdwood,
	Patrick Lai, Banajit Goswami, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, linux-arm-msm, devicetree, linux-kernel

This makes it possible for the backend sample rate to be
set to 8000 or 16000 Hz, depending on the needs of the HFP
call being set up.

Signed-off-by: Adam Serbinski <adam@serbinski.com>
CC: Andy Gross <agross@kernel.org>
CC: Mark Rutland <mark.rutland@arm.com>
CC: Liam Girdwood <lgirdwood@gmail.com>
CC: Patrick Lai <plai@codeaurora.org>
CC: Banajit Goswami <bgoswami@codeaurora.org>
CC: Jaroslav Kysela <perex@perex.cz>
CC: Takashi Iwai <tiwai@suse.com>
CC: alsa-devel@alsa-project.org
CC: linux-arm-msm@vger.kernel.org
CC: devicetree@vger.kernel.org
CC: linux-kernel@vger.kernel.org
---
 sound/soc/qcom/apq8096.c | 92 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 90 insertions(+), 2 deletions(-)

diff --git a/sound/soc/qcom/apq8096.c b/sound/soc/qcom/apq8096.c
index 1edcaa15234f..882f2c456321 100644
--- a/sound/soc/qcom/apq8096.c
+++ b/sound/soc/qcom/apq8096.c
@@ -16,6 +16,9 @@
 #define MI2S_BCLK_RATE			1536000
 #define PCM_BCLK_RATE			1024000
 
+static int pri_pcm_sample_rate = 16000;
+static int quat_pcm_sample_rate = 16000;
+
 static int msm_snd_hw_params(struct snd_pcm_substream *substream,
 			     struct snd_pcm_hw_params *params)
 {
@@ -33,10 +36,15 @@ static int msm_snd_hw_params(struct snd_pcm_substream *substream,
 	switch (cpu_dai->id) {
 	case PRIMARY_PCM_RX:
 	case PRIMARY_PCM_TX:
+		rate->min = pri_pcm_sample_rate;
+		rate->max = pri_pcm_sample_rate;
+		channels->min = 1;
+		channels->max = 1;
+		break;
 	case QUATERNARY_PCM_RX:
 	case QUATERNARY_PCM_TX:
-		rate->min = 16000;
-		rate->max = 16000;
+		rate->min = quat_pcm_sample_rate;
+		rate->max = quat_pcm_sample_rate;
 		channels->min = 1;
 		channels->max = 1;
 		break;
@@ -121,6 +129,83 @@ static struct snd_soc_ops apq8096_ops = {
 	.startup = msm_snd_startup,
 };
 
+static char const *pcm_sample_rate_text[] = {"8 kHz", "16 kHz"};
+static const struct soc_enum pcm_snd_enum =
+		SOC_ENUM_SINGLE_EXT(2, pcm_sample_rate_text);
+
+static int get_sample_rate_idx(int sample_rate)
+{
+	int sample_rate_idx = 0;
+
+	switch (sample_rate) {
+	case 8000:
+		sample_rate_idx = 0;
+		break;
+	case 16000:
+	default:
+		sample_rate_idx = 1;
+		break;
+	}
+
+	return sample_rate_idx;
+}
+
+static int pri_pcm_sample_rate_get(struct snd_kcontrol *kcontrol,
+				   struct snd_ctl_elem_value *ucontrol)
+{
+	ucontrol->value.integer.value[0] =
+		get_sample_rate_idx(pri_pcm_sample_rate);
+	return 0;
+}
+
+static int quat_pcm_sample_rate_get(struct snd_kcontrol *kcontrol,
+				    struct snd_ctl_elem_value *ucontrol)
+{
+	ucontrol->value.integer.value[0] =
+		get_sample_rate_idx(quat_pcm_sample_rate);
+	return 0;
+}
+
+static int get_sample_rate(int idx)
+{
+	int sample_rate_val = 0;
+
+	switch (idx) {
+	case 0:
+		sample_rate_val = 8000;
+		break;
+	case 1:
+	default:
+		sample_rate_val = 16000;
+		break;
+	}
+
+	return sample_rate_val;
+}
+
+static int pri_pcm_sample_rate_put(struct snd_kcontrol *kcontrol,
+				   struct snd_ctl_elem_value *ucontrol)
+{
+	pri_pcm_sample_rate =
+		get_sample_rate(ucontrol->value.integer.value[0]);
+	return 0;
+}
+
+static int quat_pcm_sample_rate_put(struct snd_kcontrol *kcontrol,
+				    struct snd_ctl_elem_value *ucontrol)
+{
+	quat_pcm_sample_rate =
+		get_sample_rate(ucontrol->value.integer.value[0]);
+	return 0;
+}
+
+static const struct snd_kcontrol_new card_controls[] = {
+	SOC_ENUM_EXT("PRI_PCM SampleRate", pcm_snd_enum,
+		     pri_pcm_sample_rate_get, pri_pcm_sample_rate_put),
+	SOC_ENUM_EXT("QUAT_PCM SampleRate", pcm_snd_enum,
+		     quat_pcm_sample_rate_get, quat_pcm_sample_rate_put),
+};
+
 static int apq8096_init(struct snd_soc_pcm_runtime *rtd)
 {
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
@@ -182,6 +267,9 @@ static int apq8096_platform_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_card_register;
 
+	snd_soc_add_card_controls(card, card_controls,
+				  ARRAY_SIZE(card_controls));
+
 	return 0;
 
 err_card_register:
-- 
2.21.1


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio
  2020-02-09 15:47 ` [PATCH v2 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio Adam Serbinski
                     ` (7 preceding siblings ...)
  2020-02-09 15:47   ` [PATCH v2 8/8] ASoC: qcom: apq8096: add kcontrols to set PCM rate Adam Serbinski
@ 2020-02-10 12:17   ` Mark Brown
  2020-02-10 13:44     ` Adam Serbinski
  8 siblings, 1 reply; 41+ messages in thread
From: Mark Brown @ 2020-02-10 12:17 UTC (permalink / raw)
  To: Adam Serbinski
  Cc: Srini Kandagatla, Rob Herring, Bjorn Andersson, Andy Gross,
	Mark Rutland, Liam Girdwood, Patrick Lai, Banajit Goswami,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-arm-msm,
	devicetree, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 308 bytes --]

On Sun, Feb 09, 2020 at 10:47:40AM -0500, Adam Serbinski wrote:
> Changes from V1:
> 
> 	Rename patch:
> 		from: dts: msm8996/db820c: enable primary pcm and quaternary i2s

Please don't send new serieses in reply to old ones, it can make it
confusing what's going on and what the current version is.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 2/8] ASoC: qdsp6: q6afe: add support to pcm ports
  2020-02-09 15:47   ` [PATCH v2 2/8] ASoC: qdsp6: q6afe: add support to pcm ports Adam Serbinski
@ 2020-02-10 13:31     ` Mark Brown
  2020-02-10 14:50       ` Adam Serbinski
  2020-02-10 17:13     ` Srinivas Kandagatla
  1 sibling, 1 reply; 41+ messages in thread
From: Mark Brown @ 2020-02-10 13:31 UTC (permalink / raw)
  To: Adam Serbinski
  Cc: Srini Kandagatla, Rob Herring, Bjorn Andersson, Andy Gross,
	Mark Rutland, Liam Girdwood, Patrick Lai, Banajit Goswami,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-arm-msm,
	devicetree, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1393 bytes --]

On Sun, Feb 09, 2020 at 10:47:42AM -0500, Adam Serbinski wrote:

>  
> +#define AFE_API_VERSION_PCM_CONFIG	0x1
> +/* Enumeration for the auxiliary PCM synchronization signal
> + * provided by an external source.
> + */
> +
> +#define AFE_PORT_PCM_SYNC_SRC_EXTERNAL 0x0
> +/*	Enumeration for the auxiliary PCM synchronization signal
> + * provided by an internal source.
> + */

This is a *weird* commenting style for these #defines and it's not
consistent within the block, I'm seeing at least 3 different styles.

> +/*  Payload of the #AFE_PARAM_ID_PCM_CONFIG command's
> + * (PCM configuration parameter).
> + */
> +
> +struct afe_param_id_pcm_cfg {

Similar weird commenting here, please follow coding-style.rst.

> +	switch (cfg->fmt & SND_SOC_DAIFMT_MASTER_MASK) {
> +	case SND_SOC_DAIFMT_CBS_CFS:
> +		pcfg->pcm_cfg.sync_src = AFE_PORT_PCM_SYNC_SRC_INTERNAL;
> +		break;
> +	case SND_SOC_DAIFMT_CBM_CFM:
> +		/* CPU is slave */
> +		pcfg->pcm_cfg.sync_src = AFE_PORT_PCM_SYNC_SRC_EXTERNAL;
> +		break;
> +	default:
> +		break;
> +	}

Why is this not returning an error on unsupported values?

> +
> +	switch (cfg->sample_rate) {
> +	case 8000:
> +		pcfg->pcm_cfg.frame_setting = AFE_PORT_PCM_BITS_PER_FRAME_128;
> +		break;
> +	case 16000:
> +		pcfg->pcm_cfg.frame_setting = AFE_PORT_PCM_BITS_PER_FRAME_64;
> +		break;
> +	}

Same here.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 3/8] ASoC: qdsp6: q6afe-dai: add support to pcm port dais
  2020-02-09 15:47   ` [PATCH v2 3/8] ASoC: qdsp6: q6afe-dai: add support to pcm port dais Adam Serbinski
@ 2020-02-10 13:34     ` Mark Brown
  2020-02-10 17:13     ` Srinivas Kandagatla
  1 sibling, 0 replies; 41+ messages in thread
From: Mark Brown @ 2020-02-10 13:34 UTC (permalink / raw)
  To: Adam Serbinski
  Cc: Srini Kandagatla, Rob Herring, Bjorn Andersson, Andy Gross,
	Mark Rutland, Liam Girdwood, Patrick Lai, Banajit Goswami,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-arm-msm,
	devicetree, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1310 bytes --]

On Sun, Feb 09, 2020 at 10:47:43AM -0500, Adam Serbinski wrote:

> +static int q6pcm_hw_params(struct snd_pcm_substream *substream,
> +			   struct snd_pcm_hw_params *params,
> +			   struct snd_soc_dai *dai)
> +{
> +	struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
> +	struct q6afe_pcm_cfg *pcm = &dai_data->port_config[dai->id].pcm_cfg;
> +
> +	pcm->sample_rate = params_rate(params);
> +

This and set_fmt() don't do any validation of the value being set.

>  static const struct snd_soc_dai_ops q6tdm_ops = {
>  	.prepare	= q6afe_dai_prepare,
>  	.shutdown	= q6afe_dai_shutdown,
> -	.set_sysclk	= q6afe_mi2s_set_sysclk,
> +	.set_sysclk	= q6afe_tdm_set_sysclk,
>  	.set_tdm_slot     = q6tdm_set_tdm_slot,
>  	.set_channel_map  = q6tdm_set_channel_map,
>  	.hw_params        = q6tdm_hw_params,

This looks like a separate bug fix that should be split out?

> +	}, {
> +		.playback = {
> +			.stream_name = "Primary PCM Playback",
> +			.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
> +			.formats = SNDRV_PCM_FMTBIT_S16_LE |
> +				   SNDRV_PCM_FMTBIT_S24_LE,
> +			.rate_min =     8000,
> +			.rate_max =     16000,
> +		},

It is surprising to see rate_min and rate_max specified when we're not
using _KNOT, and again there's weird formatting here with the tabs
before the rate values.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 6/8] ASoC: qcom/common: Use snd-soc-dummy-dai when codec is not specified
  2020-02-09 15:47   ` [PATCH v2 6/8] ASoC: qcom/common: Use snd-soc-dummy-dai when codec is not specified Adam Serbinski
@ 2020-02-10 13:35     ` Mark Brown
  0 siblings, 0 replies; 41+ messages in thread
From: Mark Brown @ 2020-02-10 13:35 UTC (permalink / raw)
  To: Adam Serbinski
  Cc: Srini Kandagatla, Rob Herring, Bjorn Andersson, Andy Gross,
	Mark Rutland, Liam Girdwood, Patrick Lai, Banajit Goswami,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-arm-msm,
	devicetree, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 324 bytes --]

On Sun, Feb 09, 2020 at 10:47:46AM -0500, Adam Serbinski wrote:

> When not specifying a codec, use snd-soc-dummy-dai. This supports
> the case where a fixed configuration codec is attached, such as
> bluetooth hfp.

Fixed configuration devices should still have normal drivers that say
what those fixed configurations are.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 8/8] ASoC: qcom: apq8096: add kcontrols to set PCM rate
  2020-02-09 15:47   ` [PATCH v2 8/8] ASoC: qcom: apq8096: add kcontrols to set PCM rate Adam Serbinski
@ 2020-02-10 13:36     ` Mark Brown
  2020-02-10 15:45       ` Adam Serbinski
  2020-02-10 16:18     ` Jaroslav Kysela
  1 sibling, 1 reply; 41+ messages in thread
From: Mark Brown @ 2020-02-10 13:36 UTC (permalink / raw)
  To: Adam Serbinski
  Cc: Srini Kandagatla, Rob Herring, Bjorn Andersson, Andy Gross,
	Mark Rutland, Liam Girdwood, Patrick Lai, Banajit Goswami,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-arm-msm,
	devicetree, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 298 bytes --]

On Sun, Feb 09, 2020 at 10:47:48AM -0500, Adam Serbinski wrote:
> This makes it possible for the backend sample rate to be
> set to 8000 or 16000 Hz, depending on the needs of the HFP
> call being set up.

This would seem like an excellent thing to put in the driver for the
baseband or bluetooth.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio
  2020-02-10 12:17   ` [PATCH v2 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio Mark Brown
@ 2020-02-10 13:44     ` Adam Serbinski
  0 siblings, 0 replies; 41+ messages in thread
From: Adam Serbinski @ 2020-02-10 13:44 UTC (permalink / raw)
  To: Mark Brown
  Cc: Srini Kandagatla, Rob Herring, Bjorn Andersson, Andy Gross,
	Mark Rutland, Liam Girdwood, Patrick Lai, Banajit Goswami,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-arm-msm,
	devicetree, linux-kernel

On 2020-02-10 07:17, Mark Brown wrote:
> On Sun, Feb 09, 2020 at 10:47:40AM -0500, Adam Serbinski wrote:
>> Changes from V1:
>> 
>> 	Rename patch:
>> 		from: dts: msm8996/db820c: enable primary pcm and quaternary i2s
> 
> Please don't send new serieses in reply to old ones, it can make it
> confusing what's going on and what the current version is.

My apologies. Its my first time doing this. Thank you for the advice.

-Adam

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 2/8] ASoC: qdsp6: q6afe: add support to pcm ports
  2020-02-10 13:31     ` Mark Brown
@ 2020-02-10 14:50       ` Adam Serbinski
  0 siblings, 0 replies; 41+ messages in thread
From: Adam Serbinski @ 2020-02-10 14:50 UTC (permalink / raw)
  To: Mark Brown
  Cc: Srini Kandagatla, Rob Herring, Bjorn Andersson, Andy Gross,
	Mark Rutland, Liam Girdwood, Patrick Lai, Banajit Goswami,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-arm-msm,
	devicetree, linux-kernel

On 2020-02-10 08:31, Mark Brown wrote:
> On Sun, Feb 09, 2020 at 10:47:42AM -0500, Adam Serbinski wrote:
> 
>> 
>> +#define AFE_API_VERSION_PCM_CONFIG	0x1
>> +/* Enumeration for the auxiliary PCM synchronization signal
>> + * provided by an external source.
>> + */
>> +
>> +#define AFE_PORT_PCM_SYNC_SRC_EXTERNAL 0x0
>> +/*	Enumeration for the auxiliary PCM synchronization signal
>> + * provided by an internal source.
>> + */
> 
> This is a *weird* commenting style for these #defines and it's not
> consistent within the block, I'm seeing at least 3 different styles.

I will clean up the commenting.


>> +	default:
>> +		break;
>> +	}
> 
> Why is this not returning an error on unsupported values?

Only to be consistent with the pre-existing implementation for i2s 
ports.
I will add an error return.

> 
>> +
>> +	switch (cfg->sample_rate) {
>> +	case 8000:
>> +		pcfg->pcm_cfg.frame_setting = AFE_PORT_PCM_BITS_PER_FRAME_128;
>> +		break;
>> +	case 16000:
>> +		pcfg->pcm_cfg.frame_setting = AFE_PORT_PCM_BITS_PER_FRAME_64;
>> +		break;
>> +	}
> 
> Same here.

I will also add the error return here.

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 8/8] ASoC: qcom: apq8096: add kcontrols to set PCM rate
  2020-02-10 13:36     ` Mark Brown
@ 2020-02-10 15:45       ` Adam Serbinski
  2020-02-10 18:26         ` Mark Brown
  0 siblings, 1 reply; 41+ messages in thread
From: Adam Serbinski @ 2020-02-10 15:45 UTC (permalink / raw)
  To: Mark Brown
  Cc: Srini Kandagatla, Rob Herring, Bjorn Andersson, Andy Gross,
	Mark Rutland, Liam Girdwood, Patrick Lai, Banajit Goswami,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-arm-msm,
	devicetree, linux-kernel

On 2020-02-10 08:36, Mark Brown wrote:
> On Sun, Feb 09, 2020 at 10:47:48AM -0500, Adam Serbinski wrote:
>> This makes it possible for the backend sample rate to be
>> set to 8000 or 16000 Hz, depending on the needs of the HFP
>> call being set up.
> 
> This would seem like an excellent thing to put in the driver for the
> baseband or bluetooth.

The value that must be set to this control is not available to the 
bluetooth driver. It originates from the bluetooth stack in userspace, 
typically either blueZ or fluoride, as a result of a negotiation between 
the two devices participating in the HFP call.

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 8/8] ASoC: qcom: apq8096: add kcontrols to set PCM rate
  2020-02-09 15:47   ` [PATCH v2 8/8] ASoC: qcom: apq8096: add kcontrols to set PCM rate Adam Serbinski
  2020-02-10 13:36     ` Mark Brown
@ 2020-02-10 16:18     ` Jaroslav Kysela
  2020-02-10 17:13       ` Adam Serbinski
  1 sibling, 1 reply; 41+ messages in thread
From: Jaroslav Kysela @ 2020-02-10 16:18 UTC (permalink / raw)
  To: Adam Serbinski, Mark Brown, Srini Kandagatla, Rob Herring,
	Bjorn Andersson
  Cc: Andy Gross, Mark Rutland, Liam Girdwood, Patrick Lai,
	Banajit Goswami, Takashi Iwai, alsa-devel, linux-arm-msm,
	devicetree, linux-kernel

Dne 09. 02. 20 v 16:47 Adam Serbinski napsal(a):
> This makes it possible for the backend sample rate to be
> set to 8000 or 16000 Hz, depending on the needs of the HFP
> call being set up.

Two points:

Why enum? It adds just more code than the integer value handlers.

Also, this belongs to the PCM interface, so it should be handled with 
SNDRV_CTL_ELEM_IFACE_PCM not mixer.

The name should be probably "Rate" and assigned to the corresponding PCM device.

Add this to Documentation/sound/designs/control-names.rst .

					Jaroslav

> 
> Signed-off-by: Adam Serbinski <adam@serbinski.com>
> CC: Andy Gross <agross@kernel.org>
> CC: Mark Rutland <mark.rutland@arm.com>
> CC: Liam Girdwood <lgirdwood@gmail.com>
> CC: Patrick Lai <plai@codeaurora.org>
> CC: Banajit Goswami <bgoswami@codeaurora.org>
> CC: Jaroslav Kysela <perex@perex.cz>
> CC: Takashi Iwai <tiwai@suse.com>
> CC: alsa-devel@alsa-project.org
> CC: linux-arm-msm@vger.kernel.org
> CC: devicetree@vger.kernel.org
> CC: linux-kernel@vger.kernel.org
> ---
>   sound/soc/qcom/apq8096.c | 92 +++++++++++++++++++++++++++++++++++++++-
>   1 file changed, 90 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/soc/qcom/apq8096.c b/sound/soc/qcom/apq8096.c
> index 1edcaa15234f..882f2c456321 100644
> --- a/sound/soc/qcom/apq8096.c
> +++ b/sound/soc/qcom/apq8096.c
> @@ -16,6 +16,9 @@
>   #define MI2S_BCLK_RATE			1536000
>   #define PCM_BCLK_RATE			1024000
>   
> +static int pri_pcm_sample_rate = 16000;
> +static int quat_pcm_sample_rate = 16000;
> +
>   static int msm_snd_hw_params(struct snd_pcm_substream *substream,
>   			     struct snd_pcm_hw_params *params)
>   {
> @@ -33,10 +36,15 @@ static int msm_snd_hw_params(struct snd_pcm_substream *substream,
>   	switch (cpu_dai->id) {
>   	case PRIMARY_PCM_RX:
>   	case PRIMARY_PCM_TX:
> +		rate->min = pri_pcm_sample_rate;
> +		rate->max = pri_pcm_sample_rate;
> +		channels->min = 1;
> +		channels->max = 1;
> +		break;
>   	case QUATERNARY_PCM_RX:
>   	case QUATERNARY_PCM_TX:
> -		rate->min = 16000;
> -		rate->max = 16000;
> +		rate->min = quat_pcm_sample_rate;
> +		rate->max = quat_pcm_sample_rate;
>   		channels->min = 1;
>   		channels->max = 1;
>   		break;
> @@ -121,6 +129,83 @@ static struct snd_soc_ops apq8096_ops = {
>   	.startup = msm_snd_startup,
>   };
>   
> +static char const *pcm_sample_rate_text[] = {"8 kHz", "16 kHz"};
> +static const struct soc_enum pcm_snd_enum =
> +		SOC_ENUM_SINGLE_EXT(2, pcm_sample_rate_text);
> +
> +static int get_sample_rate_idx(int sample_rate)
> +{
> +	int sample_rate_idx = 0;
> +
> +	switch (sample_rate) {
> +	case 8000:
> +		sample_rate_idx = 0;
> +		break;
> +	case 16000:
> +	default:
> +		sample_rate_idx = 1;
> +		break;
> +	}
> +
> +	return sample_rate_idx;
> +}
> +
> +static int pri_pcm_sample_rate_get(struct snd_kcontrol *kcontrol,
> +				   struct snd_ctl_elem_value *ucontrol)
> +{
> +	ucontrol->value.integer.value[0] =
> +		get_sample_rate_idx(pri_pcm_sample_rate);
> +	return 0;
> +}
> +
> +static int quat_pcm_sample_rate_get(struct snd_kcontrol *kcontrol,
> +				    struct snd_ctl_elem_value *ucontrol)
> +{
> +	ucontrol->value.integer.value[0] =
> +		get_sample_rate_idx(quat_pcm_sample_rate);
> +	return 0;
> +}
> +
> +static int get_sample_rate(int idx)
> +{
> +	int sample_rate_val = 0;
> +
> +	switch (idx) {
> +	case 0:
> +		sample_rate_val = 8000;
> +		break;
> +	case 1:
> +	default:
> +		sample_rate_val = 16000;
> +		break;
> +	}
> +
> +	return sample_rate_val;
> +}
> +
> +static int pri_pcm_sample_rate_put(struct snd_kcontrol *kcontrol,
> +				   struct snd_ctl_elem_value *ucontrol)
> +{
> +	pri_pcm_sample_rate =
> +		get_sample_rate(ucontrol->value.integer.value[0]);
> +	return 0;
> +}
> +
> +static int quat_pcm_sample_rate_put(struct snd_kcontrol *kcontrol,
> +				    struct snd_ctl_elem_value *ucontrol)
> +{
> +	quat_pcm_sample_rate =
> +		get_sample_rate(ucontrol->value.integer.value[0]);
> +	return 0;
> +}
> +
> +static const struct snd_kcontrol_new card_controls[] = {
> +	SOC_ENUM_EXT("PRI_PCM SampleRate", pcm_snd_enum,
> +		     pri_pcm_sample_rate_get, pri_pcm_sample_rate_put),
> +	SOC_ENUM_EXT("QUAT_PCM SampleRate", pcm_snd_enum,
> +		     quat_pcm_sample_rate_get, quat_pcm_sample_rate_put),
> +};
> +
>   static int apq8096_init(struct snd_soc_pcm_runtime *rtd)
>   {
>   	struct snd_soc_dai *codec_dai = rtd->codec_dai;
> @@ -182,6 +267,9 @@ static int apq8096_platform_probe(struct platform_device *pdev)
>   	if (ret)
>   		goto err_card_register;
>   
> +	snd_soc_add_card_controls(card, card_controls,
> +				  ARRAY_SIZE(card_controls));
> +
>   	return 0;
>   
>   err_card_register:
> 


-- 
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 3/8] ASoC: qdsp6: q6afe-dai: add support to pcm port dais
  2020-02-09 15:47   ` [PATCH v2 3/8] ASoC: qdsp6: q6afe-dai: add support to pcm port dais Adam Serbinski
  2020-02-10 13:34     ` Mark Brown
@ 2020-02-10 17:13     ` Srinivas Kandagatla
  2020-02-10 17:22       ` Adam Serbinski
  1 sibling, 1 reply; 41+ messages in thread
From: Srinivas Kandagatla @ 2020-02-10 17:13 UTC (permalink / raw)
  To: Adam Serbinski, Mark Brown, Rob Herring, Bjorn Andersson
  Cc: Andy Gross, Mark Rutland, Liam Girdwood, Patrick Lai,
	Banajit Goswami, Jaroslav Kysela, Takashi Iwai, alsa-devel,
	linux-arm-msm, devicetree, linux-kernel

Few minor comments

On 09/02/2020 15:47, Adam Serbinski wrote:
> This patch adds support of AFE DAI for PCM port.
> 
> Signed-off-by: Adam Serbinski <adam@serbinski.com>
> CC: Andy Gross <agross@kernel.org>
> CC: Mark Rutland <mark.rutland@arm.com>
> CC: Liam Girdwood <lgirdwood@gmail.com>
> CC: Patrick Lai <plai@codeaurora.org>
> CC: Banajit Goswami <bgoswami@codeaurora.org>
> CC: Jaroslav Kysela <perex@perex.cz>
> CC: Takashi Iwai <tiwai@suse.com>
> CC: alsa-devel@alsa-project.org
> CC: linux-arm-msm@vger.kernel.org
> CC: devicetree@vger.kernel.org
> CC: linux-kernel@vger.kernel.org
> ---
>   sound/soc/qcom/qdsp6/q6afe-dai.c | 198 ++++++++++++++++++++++++++++++-
>   1 file changed, 197 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/soc/qcom/qdsp6/q6afe-dai.c b/sound/soc/qcom/qdsp6/q6afe-dai.c
> index c1a7624eaf17..23b29591ef47 100644
> --- a/sound/soc/qcom/qdsp6/q6afe-dai.c
> +++ b/sound/soc/qcom/qdsp6/q6afe-dai.c

...

> +static int q6afe_tdm_set_sysclk(struct snd_soc_dai *dai,
> +		int clk_id, unsigned int freq, int dir)
> +{

Why are we adding exactly duplicate function of q6afe_mi2s_set_sysclk here?

> +	struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
> +	struct q6afe_port *port = dai_data->port[dai->id];
> +
> +	switch (clk_id) {
> +	case LPAIF_DIG_CLK:
> +		return q6afe_port_set_sysclk(port, clk_id, 0, 5, freq, dir);
> +	case LPAIF_BIT_CLK:
> +	case LPAIF_OSR_CLK:
> +		return q6afe_port_set_sysclk(port, clk_id,
> +					     Q6AFE_LPASS_CLK_SRC_INTERNAL,
> +					     Q6AFE_LPASS_CLK_ROOT_DEFAULT,
> +					     freq, dir);
>   	case Q6AFE_LPASS_CLK_ID_PRI_TDM_IBIT ... Q6AFE_LPASS_CLK_ID_QUIN_TDM_EBIT:
>   		return q6afe_port_set_sysclk(port, clk_id,
>   					     Q6AFE_LPASS_CLK_ATTRIBUTE_INVERT_COUPLE_NO,
> @@ -468,6 +520,11 @@ static const struct snd_soc_dapm_route q6afe_dapm_routes[] = {
>   	{"Tertiary MI2S Playback", NULL, "TERT_MI2S_RX"},
>   	{"Quaternary MI2S Playback", NULL, "QUAT_MI2S_RX"},
>   
> +	{"Primary PCM Playback", NULL, "PRI_PCM_RX"},
> +	{"Secondary PCM Playback", NULL, "SEC_PCM_RX"},
> +	{"Tertiary PCM Playback", NULL, "TERT_PCM_RX"},
> +	{"Quaternary PCM Playback", NULL, "QUAT_PCM_RX"},
> +
>   	{"Primary TDM0 Playback", NULL, "PRIMARY_TDM_RX_0"},
>   	{"Primary TDM1 Playback", NULL, "PRIMARY_TDM_RX_1"},
>   	{"Primary TDM2 Playback", NULL, "PRIMARY_TDM_RX_2"},
> @@ -562,6 +619,11 @@ static const struct snd_soc_dapm_route q6afe_dapm_routes[] = {
>   	{"PRI_MI2S_TX", NULL, "Primary MI2S Capture"},
>   	{"SEC_MI2S_TX", NULL, "Secondary MI2S Capture"},
>   	{"QUAT_MI2S_TX", NULL, "Quaternary MI2S Capture"},
> +
> +	{"PRI_PCM_TX", NULL, "Primary PCM Capture"},
> +	{"SEC_PCM_TX", NULL, "Secondary PCM Capture"},
> +	{"TERT_PCM_TX", NULL, "Tertiary PCM Capture"},
> +	{"QUAT_PCM_TX", NULL, "Quaternary PCM Capture"},
>   };
>   

...

>   
> +	SND_SOC_DAPM_AIF_IN("QUAT_PCM_RX", NULL,
> +			    0, 0, 0, 0),

This can be in single line, same for below


> +	SND_SOC_DAPM_AIF_OUT("QUAT_PCM_TX", NULL,
> +			     0, 0, 0, 0),
> +	SND_SOC_DAPM_AIF_IN("TERT_PCM_RX", NULL,
> +			    0, 0, 0, 0),
> +	SND_SOC_DAPM_AIF_OUT("TERT_PCM_TX", NULL,
> +			     0, 0, 0, 0),
> +	SND_SOC_DAPM_AIF_IN("SEC_PCM_RX", NULL,
> +			    0, 0, 0, 0),
> +	SND_SOC_DAPM_AIF_OUT("SEC_PCM_TX", NULL,
> +			     0, 0, 0, 0),
> +	SND_SOC_DAPM_AIF_IN("PRI_PCM_RX", NULL,
> +			    0, 0, 0, 0),
> +	SND_SOC_DAPM_AIF_OUT("PRI_PCM_TX", NULL,
> +			     0, 0, 0, 0),
> +

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 2/8] ASoC: qdsp6: q6afe: add support to pcm ports
  2020-02-09 15:47   ` [PATCH v2 2/8] ASoC: qdsp6: q6afe: add support to pcm ports Adam Serbinski
  2020-02-10 13:31     ` Mark Brown
@ 2020-02-10 17:13     ` Srinivas Kandagatla
  1 sibling, 0 replies; 41+ messages in thread
From: Srinivas Kandagatla @ 2020-02-10 17:13 UTC (permalink / raw)
  To: Adam Serbinski, Mark Brown, Rob Herring, Bjorn Andersson
  Cc: Andy Gross, Mark Rutland, Liam Girdwood, Patrick Lai,
	Banajit Goswami, Jaroslav Kysela, Takashi Iwai, alsa-devel,
	linux-arm-msm, devicetree, linux-kernel



On 09/02/2020 15:47, Adam Serbinski wrote:
> This patch adds support to pcm ports in AFE.
> 
> Signed-off-by: Adam Serbinski <adam@serbinski.com>
> CC: Andy Gross <agross@kernel.org>
> CC: Mark Rutland <mark.rutland@arm.com>
> CC: Liam Girdwood <lgirdwood@gmail.com>
> CC: Patrick Lai <plai@codeaurora.org>
> CC: Banajit Goswami <bgoswami@codeaurora.org>
> CC: Jaroslav Kysela <perex@perex.cz>
> CC: Takashi Iwai <tiwai@suse.com>
> CC: alsa-devel@alsa-project.org
> CC: linux-arm-msm@vger.kernel.org
> CC: devicetree@vger.kernel.org
> CC: linux-kernel@vger.kernel.org
> ---
>   sound/soc/qcom/qdsp6/q6afe.c | 246 +++++++++++++++++++++++++++++++++++
>   sound/soc/qcom/qdsp6/q6afe.h |   9 +-
>   2 files changed, 254 insertions(+), 1 deletion(-)
> 

Few general comments.

1>documentation to  "struct afe_param_id_pcm_cfg "
Either we follow kerneldoc style or not add this as we did with other 
similar afe port config structures.
Am okay either way!

2> some of the defines in this patch has no reals users, so we better 
remove all the unused constants.





> diff --git a/sound/soc/qcom/qdsp6/q6afe.c b/sound/soc/qcom/qdsp6/q6afe.c
> index e0945f7a58c8..b53ad14a78fd 100644
> --- a/sound/soc/qcom/qdsp6/q6afe.c
> +++ b/sound/soc/qcom/qdsp6/q6afe.c
> @@ -40,6 +40,7 @@
>   
...

> +/**
> + * q6afe_pcm_port_prepare() - Prepare pcm afe port.
> + *
> + * @port: Instance of afe port
> + * @cfg: PCM configuration for the afe port
> + *
> + */
> +int q6afe_pcm_port_prepare(struct q6afe_port *port, struct q6afe_pcm_cfg *cfg)
> +{
> +	union afe_port_config *pcfg = &port->port_cfg;
> +
> +	pcfg->pcm_cfg.pcm_cfg_minor_version = AFE_API_VERSION_PCM_CONFIG;
> +	pcfg->pcm_cfg.aux_mode = AFE_PORT_PCM_AUX_MODE_PCM;
> +
> +	switch (cfg->fmt & SND_SOC_DAIFMT_MASTER_MASK) {
> +	case SND_SOC_DAIFMT_CBS_CFS:
> +		pcfg->pcm_cfg.sync_src = AFE_PORT_PCM_SYNC_SRC_INTERNAL;
> +		break;
> +	case SND_SOC_DAIFMT_CBM_CFM:
> +		/* CPU is slave */
> +		pcfg->pcm_cfg.sync_src = AFE_PORT_PCM_SYNC_SRC_EXTERNAL;
> +		break;
> +	default:
> +		break;
> +	}
> +
> +	switch (cfg->sample_rate) {
> +	case 8000:
> +		pcfg->pcm_cfg.frame_setting = AFE_PORT_PCM_BITS_PER_FRAME_128;
> +		break;
> +	case 16000:
> +		pcfg->pcm_cfg.frame_setting = AFE_PORT_PCM_BITS_PER_FRAME_64;
> +		break;
> +	}
> +	pcfg->pcm_cfg.quantype = AFE_PORT_PCM_LINEAR_NOPADDING;
> +	pcfg->pcm_cfg.ctrl_data_out_enable = AFE_PORT_PCM_CTRL_DATA_OE_DISABLE;
> +	pcfg->pcm_cfg.reserved = 0;
> +	pcfg->pcm_cfg.sample_rate = cfg->sample_rate;
> +
> +	/* 16 bit mono */
> +	pcfg->pcm_cfg.bit_width = 16;
> +	pcfg->pcm_cfg.num_channels = 1;
> +	pcfg->pcm_cfg.slot_number_mapping[0] = 1;

PCM quantization type and Slot Mapping should come from device tree.



> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(q6afe_pcm_port_prepare);
> +

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 8/8] ASoC: qcom: apq8096: add kcontrols to set PCM rate
  2020-02-10 16:18     ` Jaroslav Kysela
@ 2020-02-10 17:13       ` Adam Serbinski
  0 siblings, 0 replies; 41+ messages in thread
From: Adam Serbinski @ 2020-02-10 17:13 UTC (permalink / raw)
  To: Jaroslav Kysela
  Cc: Mark Brown, Srini Kandagatla, Rob Herring, Bjorn Andersson,
	Andy Gross, Mark Rutland, Liam Girdwood, Patrick Lai,
	Banajit Goswami, Takashi Iwai, alsa-devel, linux-arm-msm,
	devicetree, linux-kernel

On 2020-02-10 11:18, Jaroslav Kysela wrote:
> Dne 09. 02. 20 v 16:47 Adam Serbinski napsal(a):
>> This makes it possible for the backend sample rate to be
>> set to 8000 or 16000 Hz, depending on the needs of the HFP
>> call being set up.
> 
> Two points:
> 
> Why enum? It adds just more code than the integer value handlers.

Because enum allows the potential values to be restricted to a set of 
distinct values rather than a range. And while yes, I understand that 
the value can be validated, or the step can in this case be set to 
correspond to the difference between the current 2 values, this approach 
would neither make it clear to the user what the permitted values are, 
nor would it scale well once additional values are required.


> Also, this belongs to the PCM interface, so it should be handled with
> SNDRV_CTL_ELEM_IFACE_PCM not mixer.
> 
> The name should be probably "Rate" and assigned to the corresponding 
> PCM device.
> 
> Add this to Documentation/sound/designs/control-names.rst .

Above 3 lines are noted, I will make these changed.

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 1/8] ASoC: qdsp6: dt-bindings: Add q6afe pcm dt binding
  2020-02-09 15:47   ` [PATCH v2 1/8] ASoC: qdsp6: dt-bindings: Add q6afe pcm dt binding Adam Serbinski
@ 2020-02-10 17:13     ` Srinivas Kandagatla
  0 siblings, 0 replies; 41+ messages in thread
From: Srinivas Kandagatla @ 2020-02-10 17:13 UTC (permalink / raw)
  To: Adam Serbinski, Mark Brown, Rob Herring, Bjorn Andersson
  Cc: Andy Gross, Mark Rutland, Liam Girdwood, Patrick Lai,
	Banajit Goswami, Jaroslav Kysela, Takashi Iwai, alsa-devel,
	linux-arm-msm, devicetree, linux-kernel



On 09/02/2020 15:47, Adam Serbinski wrote:
> This patch adds bindings required for PCM ports on AFE.
> 
> Signed-off-by: Adam Serbinski <adam@serbinski.com>
> CC: Andy Gross <agross@kernel.org>
> CC: Mark Rutland <mark.rutland@arm.com>
> CC: Liam Girdwood <lgirdwood@gmail.com>
> CC: Patrick Lai <plai@codeaurora.org>
> CC: Banajit Goswami <bgoswami@codeaurora.org>
> CC: Jaroslav Kysela <perex@perex.cz>
> CC: Takashi Iwai <tiwai@suse.com>
> CC: alsa-devel@alsa-project.org
> CC: linux-arm-msm@vger.kernel.org
> CC: devicetree@vger.kernel.org
> CC: linux-kernel@vger.kernel.org
> ---
>   include/dt-bindings/sound/qcom,q6afe.h | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 

Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>


> diff --git a/include/dt-bindings/sound/qcom,q6afe.h b/include/dt-bindings/sound/qcom,q6afe.h
> index 1df06f8ad5c3..f3a435a112cb 100644
> --- a/include/dt-bindings/sound/qcom,q6afe.h
> +++ b/include/dt-bindings/sound/qcom,q6afe.h
> @@ -107,6 +107,14 @@
>   #define QUINARY_TDM_RX_7	102
>   #define QUINARY_TDM_TX_7	103
>   #define DISPLAY_PORT_RX		104
> +#define PRIMARY_PCM_RX		105
> +#define PRIMARY_PCM_TX		106
> +#define SECONDARY_PCM_RX	107
> +#define SECONDARY_PCM_TX	108
> +#define TERTIARY_PCM_RX		109
> +#define TERTIARY_PCM_TX		110
> +#define QUATERNARY_PCM_RX	111
> +#define QUATERNARY_PCM_TX	112
>   
>   #endif /* __DT_BINDINGS_Q6_AFE_H__ */
>   
> 

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 4/8] ASoC: qdsp6: q6routing: add pcm port routing
  2020-02-09 15:47   ` [PATCH v2 4/8] ASoC: qdsp6: q6routing: add pcm port routing Adam Serbinski
@ 2020-02-10 17:19     ` Srinivas Kandagatla
  0 siblings, 0 replies; 41+ messages in thread
From: Srinivas Kandagatla @ 2020-02-10 17:19 UTC (permalink / raw)
  To: Adam Serbinski, Mark Brown, Rob Herring, Bjorn Andersson
  Cc: Andy Gross, Mark Rutland, Liam Girdwood, Patrick Lai,
	Banajit Goswami, Jaroslav Kysela, Takashi Iwai, alsa-devel,
	linux-arm-msm, devicetree, linux-kernel



On 09/02/2020 15:47, Adam Serbinski wrote:
> This patch adds support to PCM_PORT mixers required to
> select path between ASM stream and AFE ports.
> 
> Signed-off-by: Adam Serbinski <adam@serbinski.com>
> CC: Andy Gross <agross@kernel.org>
> CC: Mark Rutland <mark.rutland@arm.com>
> CC: Liam Girdwood <lgirdwood@gmail.com>
> CC: Patrick Lai <plai@codeaurora.org>
> CC: Banajit Goswami <bgoswami@codeaurora.org>
> CC: Jaroslav Kysela <perex@perex.cz>
> CC: Takashi Iwai <tiwai@suse.com>
> CC: alsa-devel@alsa-project.org
> CC: linux-arm-msm@vger.kernel.org
> CC: devicetree@vger.kernel.org
> CC: linux-kernel@vger.kernel.org
> ---
>   sound/soc/qcom/qdsp6/q6routing.c | 44 ++++++++++++++++++++++++++++++++

Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>


>   1 file changed, 44 insertions(+)
> 
> diff --git a/sound/soc/qcom/qdsp6/q6routing.c b/sound/soc/qcom/qdsp6/q6routing.c
> index 20724102e85a..3a81d2161707 100644
> --- a/sound/soc/qcom/qdsp6/q6routing.c
> +++ b/sound/soc/qcom/qdsp6/q6routing.c
> @@ -67,6 +67,10 @@
>   	{ mix_name, "SEC_MI2S_TX", "SEC_MI2S_TX" },	\
>   	{ mix_name, "QUAT_MI2S_TX", "QUAT_MI2S_TX" },	\
>   	{ mix_name, "TERT_MI2S_TX", "TERT_MI2S_TX" },		\
> +	{ mix_name, "PRI_PCM_TX", "PRI_PCM_TX" },		\
> +	{ mix_name, "SEC_PCM_TX", "SEC_PCM_TX" },		\
> +	{ mix_name, "TERT_PCM_TX", "TERT_PCM_TX" },		\
> +	{ mix_name, "QUAT_PCM_TX", "QUAT_PCM_TX" },		\
>   	{ mix_name, "SLIMBUS_0_TX", "SLIMBUS_0_TX" },		\
>   	{ mix_name, "SLIMBUS_1_TX", "SLIMBUS_1_TX" },		\
>   	{ mix_name, "SLIMBUS_2_TX", "SLIMBUS_2_TX" },		\
> @@ -128,6 +132,18 @@
>   	SOC_SINGLE_EXT("QUAT_MI2S_TX", QUATERNARY_MI2S_TX,		\
>   		id, 1, 0, msm_routing_get_audio_mixer,			\
>   		msm_routing_put_audio_mixer),				\
> +	SOC_SINGLE_EXT("PRI_PCM_TX", PRIMARY_PCM_TX,			\
> +		id, 1, 0, msm_routing_get_audio_mixer,			\
> +		msm_routing_put_audio_mixer),				\
> +	SOC_SINGLE_EXT("SEC_PCM_TX", SECONDARY_PCM_TX,			\
> +		id, 1, 0, msm_routing_get_audio_mixer,			\
> +		msm_routing_put_audio_mixer),				\
> +	SOC_SINGLE_EXT("TERT_PCM_TX", TERTIARY_PCM_TX,			\
> +		id, 1, 0, msm_routing_get_audio_mixer,			\
> +		msm_routing_put_audio_mixer),				\
> +	SOC_SINGLE_EXT("QUAT_PCM_TX", QUATERNARY_PCM_TX,		\
> +		id, 1, 0, msm_routing_get_audio_mixer,			\
> +		msm_routing_put_audio_mixer),				\
>   	SOC_SINGLE_EXT("SLIMBUS_0_TX", SLIMBUS_0_TX,			\
>   		id, 1, 0, msm_routing_get_audio_mixer,			\
>   		msm_routing_put_audio_mixer),				\
> @@ -468,6 +484,18 @@ static const struct snd_kcontrol_new quaternary_mi2s_rx_mixer_controls[] = {
>   static const struct snd_kcontrol_new tertiary_mi2s_rx_mixer_controls[] = {
>   	Q6ROUTING_RX_MIXERS(TERTIARY_MI2S_RX) };
>   
> +static const struct snd_kcontrol_new primary_pcm_rx_mixer_controls[] = {
> +	Q6ROUTING_RX_MIXERS(PRIMARY_PCM_RX) };
> +
> +static const struct snd_kcontrol_new secondary_pcm_rx_mixer_controls[] = {
> +	Q6ROUTING_RX_MIXERS(SECONDARY_PCM_RX) };
> +
> +static const struct snd_kcontrol_new tertiary_pcm_rx_mixer_controls[] = {
> +	Q6ROUTING_RX_MIXERS(TERTIARY_PCM_RX) };
> +
> +static const struct snd_kcontrol_new quaternary_pcm_rx_mixer_controls[] = {
> +	Q6ROUTING_RX_MIXERS(QUATERNARY_PCM_RX) };
> +
>   static const struct snd_kcontrol_new slimbus_rx_mixer_controls[] = {
>   	Q6ROUTING_RX_MIXERS(SLIMBUS_0_RX) };
>   
> @@ -695,6 +723,18 @@ static const struct snd_soc_dapm_widget msm_qdsp6_widgets[] = {
>   	SND_SOC_DAPM_MIXER("TERT_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
>   			   tertiary_mi2s_rx_mixer_controls,
>   			   ARRAY_SIZE(tertiary_mi2s_rx_mixer_controls)),
> +	SND_SOC_DAPM_MIXER("PRI_PCM_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
> +			   primary_pcm_rx_mixer_controls,
> +			   ARRAY_SIZE(primary_pcm_rx_mixer_controls)),
> +	SND_SOC_DAPM_MIXER("SEC_PCM_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
> +			   secondary_pcm_rx_mixer_controls,
> +			   ARRAY_SIZE(secondary_pcm_rx_mixer_controls)),
> +	SND_SOC_DAPM_MIXER("TERT_PCM_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
> +			   tertiary_pcm_rx_mixer_controls,
> +			   ARRAY_SIZE(tertiary_pcm_rx_mixer_controls)),
> +	SND_SOC_DAPM_MIXER("QUAT_PCM_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
> +			   quaternary_pcm_rx_mixer_controls,
> +			   ARRAY_SIZE(quaternary_pcm_rx_mixer_controls)),
>   	SND_SOC_DAPM_MIXER("PRIMARY_TDM_RX_0 Audio Mixer", SND_SOC_NOPM, 0, 0,
>   				pri_tdm_rx_0_mixer_controls,
>   				ARRAY_SIZE(pri_tdm_rx_0_mixer_controls)),
> @@ -853,6 +893,10 @@ static const struct snd_soc_dapm_route intercon[] = {
>   	Q6ROUTING_RX_DAPM_ROUTE("TERT_MI2S_RX Audio Mixer", "TERT_MI2S_RX"),
>   	Q6ROUTING_RX_DAPM_ROUTE("SEC_MI2S_RX Audio Mixer", "SEC_MI2S_RX"),
>   	Q6ROUTING_RX_DAPM_ROUTE("PRI_MI2S_RX Audio Mixer", "PRI_MI2S_RX"),
> +	Q6ROUTING_RX_DAPM_ROUTE("PRI_PCM_RX Audio Mixer", "PRI_PCM_RX"),
> +	Q6ROUTING_RX_DAPM_ROUTE("SEC_PCM_RX Audio Mixer", "SEC_PCM_RX"),
> +	Q6ROUTING_RX_DAPM_ROUTE("TERT_PCM_RX Audio Mixer", "TERT_PCM_RX"),
> +	Q6ROUTING_RX_DAPM_ROUTE("QUAT_PCM_RX Audio Mixer", "QUAT_PCM_RX"),
>   	Q6ROUTING_RX_DAPM_ROUTE("PRIMARY_TDM_RX_0 Audio Mixer",
>   				"PRIMARY_TDM_RX_0"),
>   	Q6ROUTING_RX_DAPM_ROUTE("PRIMARY_TDM_RX_1 Audio Mixer",
> 

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 3/8] ASoC: qdsp6: q6afe-dai: add support to pcm port dais
  2020-02-10 17:13     ` Srinivas Kandagatla
@ 2020-02-10 17:22       ` Adam Serbinski
  2020-02-10 17:40         ` Srinivas Kandagatla
  0 siblings, 1 reply; 41+ messages in thread
From: Adam Serbinski @ 2020-02-10 17:22 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: Mark Brown, Rob Herring, Bjorn Andersson, Andy Gross,
	Mark Rutland, Liam Girdwood, Patrick Lai, Banajit Goswami,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-arm-msm,
	devicetree, linux-kernel

On 2020-02-10 12:13, Srinivas Kandagatla wrote:
> Few minor comments
> 
>> +static int q6afe_tdm_set_sysclk(struct snd_soc_dai *dai,
>> +		int clk_id, unsigned int freq, int dir)
>> +{
> 
> Why are we adding exactly duplicate function of q6afe_mi2s_set_sysclk 
> here?

It isn't an exact duplicate.

The reason I split off the new function is because the clock IDs for PCM
overlap/duplicate the clock IDs for TDM, yet the parameters to
q6afe_port_set_sysclk are not the same for PCM and TDM.


>>   +	SND_SOC_DAPM_AIF_IN("QUAT_PCM_RX", NULL,
>> +			    0, 0, 0, 0),
> 
> This can be in single line, same for below

I will adjust these.

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 3/8] ASoC: qdsp6: q6afe-dai: add support to pcm port dais
  2020-02-10 17:22       ` Adam Serbinski
@ 2020-02-10 17:40         ` Srinivas Kandagatla
  0 siblings, 0 replies; 41+ messages in thread
From: Srinivas Kandagatla @ 2020-02-10 17:40 UTC (permalink / raw)
  To: Adam Serbinski
  Cc: Mark Brown, Rob Herring, Bjorn Andersson, Andy Gross,
	Mark Rutland, Liam Girdwood, Patrick Lai, Banajit Goswami,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-arm-msm,
	devicetree, linux-kernel



On 10/02/2020 17:22, Adam Serbinski wrote:
>>>
>>
>> Why are we adding exactly duplicate function of q6afe_mi2s_set_sysclk 
>> here?
> 
> It isn't an exact duplicate.
> 
> The reason I split off the new function is because the clock IDs for PCM
> overlap/duplicate the clock IDs for TDM, yet the parameters to
> q6afe_port_set_sysclk are not the same for PCM and TDM.
> 
we should be able to use dai->id to make that decision.

--srini




> 
>>>   +    SND_SOC_DAPM_AIF_IN("QUAT_PCM_RX", NULL,
>>> +                0, 0, 0, 0),

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 8/8] ASoC: qcom: apq8096: add kcontrols to set PCM rate
  2020-02-10 15:45       ` Adam Serbinski
@ 2020-02-10 18:26         ` Mark Brown
  2020-02-10 20:00           ` Adam Serbinski
  0 siblings, 1 reply; 41+ messages in thread
From: Mark Brown @ 2020-02-10 18:26 UTC (permalink / raw)
  To: Adam Serbinski
  Cc: Srini Kandagatla, Rob Herring, Bjorn Andersson, Andy Gross,
	Mark Rutland, Liam Girdwood, Patrick Lai, Banajit Goswami,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-arm-msm,
	devicetree, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 610 bytes --]

On Mon, Feb 10, 2020 at 10:45:16AM -0500, Adam Serbinski wrote:
> On 2020-02-10 08:36, Mark Brown wrote:

> > This would seem like an excellent thing to put in the driver for the
> > baseband or bluetooth.

> The value that must be set to this control is not available to the bluetooth
> driver. It originates from the bluetooth stack in userspace, typically
> either blueZ or fluoride, as a result of a negotiation between the two
> devices participating in the HFP call.

To repeat my comment on another patch in the series there should still
be some representation of the DAI for this device in the kernel.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 8/8] ASoC: qcom: apq8096: add kcontrols to set PCM rate
  2020-02-10 18:26         ` Mark Brown
@ 2020-02-10 20:00           ` Adam Serbinski
  2020-02-10 20:08             ` Mark Brown
  0 siblings, 1 reply; 41+ messages in thread
From: Adam Serbinski @ 2020-02-10 20:00 UTC (permalink / raw)
  To: Mark Brown
  Cc: Srini Kandagatla, Rob Herring, Bjorn Andersson, Andy Gross,
	Mark Rutland, Liam Girdwood, Patrick Lai, Banajit Goswami,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-arm-msm,
	devicetree, linux-kernel

On 2020-02-10 13:26, Mark Brown wrote:
> On Mon, Feb 10, 2020 at 10:45:16AM -0500, Adam Serbinski wrote:
>> On 2020-02-10 08:36, Mark Brown wrote:
> 
>> > This would seem like an excellent thing to put in the driver for the
>> > baseband or bluetooth.
> 
>> The value that must be set to this control is not available to the 
>> bluetooth
>> driver. It originates from the bluetooth stack in userspace, typically
>> either blueZ or fluoride, as a result of a negotiation between the two
>> devices participating in the HFP call.
> 
> To repeat my comment on another patch in the series there should still
> be some representation of the DAI for this device in the kernel.

Respectfully, I'm not sure I understand what it is that you are 
suggesting.

Is it your intention to suggest that instead of adding controls to the 
machine driver, I should instead write a codec driver to contain those 
controls?

Or is it your intention to suggest that something within the kernel is 
already aware of the rate to be set, and it is that which should set the 
rate rather than a control?

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 8/8] ASoC: qcom: apq8096: add kcontrols to set PCM rate
  2020-02-10 20:00           ` Adam Serbinski
@ 2020-02-10 20:08             ` Mark Brown
  2020-02-10 21:13               ` Adam Serbinski
  0 siblings, 1 reply; 41+ messages in thread
From: Mark Brown @ 2020-02-10 20:08 UTC (permalink / raw)
  To: Adam Serbinski
  Cc: Srini Kandagatla, Rob Herring, Bjorn Andersson, Andy Gross,
	Mark Rutland, Liam Girdwood, Patrick Lai, Banajit Goswami,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-arm-msm,
	devicetree, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1001 bytes --]

On Mon, Feb 10, 2020 at 03:00:55PM -0500, Adam Serbinski wrote:
> On 2020-02-10 13:26, Mark Brown wrote:

> > To repeat my comment on another patch in the series there should still
> > be some representation of the DAI for this device in the kernel.

> Respectfully, I'm not sure I understand what it is that you are suggesting.

> Is it your intention to suggest that instead of adding controls to the
> machine driver, I should instead write a codec driver to contain those
> controls?

I have already separately said that you should write a CODEC driver for
this CODEC.  I'm saying that this seems like the sort of thing that
might fit in that CODEC driver.

> Or is it your intention to suggest that something within the kernel is
> already aware of the rate to be set, and it is that which should set the
> rate rather than a control?

That would be one example of how such a CODEC driver could be
configured, and is how other baseband/BT devices have ended up going
(see cx20442.c for example).

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 8/8] ASoC: qcom: apq8096: add kcontrols to set PCM rate
  2020-02-10 20:08             ` Mark Brown
@ 2020-02-10 21:13               ` Adam Serbinski
  2020-02-11 11:42                 ` Mark Brown
  0 siblings, 1 reply; 41+ messages in thread
From: Adam Serbinski @ 2020-02-10 21:13 UTC (permalink / raw)
  To: Mark Brown
  Cc: Srini Kandagatla, Rob Herring, Bjorn Andersson, Andy Gross,
	Mark Rutland, Liam Girdwood, Patrick Lai, Banajit Goswami,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-arm-msm,
	devicetree, linux-kernel

On 2020-02-10 15:08, Mark Brown wrote:
> On Mon, Feb 10, 2020 at 03:00:55PM -0500, Adam Serbinski wrote:
>> On 2020-02-10 13:26, Mark Brown wrote:
> 
>> > To repeat my comment on another patch in the series there should still
>> > be some representation of the DAI for this device in the kernel.
> 
>> Respectfully, I'm not sure I understand what it is that you are 
>> suggesting.
> 
>> Is it your intention to suggest that instead of adding controls to the
>> machine driver, I should instead write a codec driver to contain those
>> controls?
> 
> I have already separately said that you should write a CODEC driver for
> this CODEC.  I'm saying that this seems like the sort of thing that
> might fit in that CODEC driver.

I see. My initial thought with respect to the codec driver would be just 
to use bt-sco.c, which is a dummy codec. I can certainly implement a new 
codec driver.

>> Or is it your intention to suggest that something within the kernel is
>> already aware of the rate to be set, and it is that which should set 
>> the
>> rate rather than a control?
> 
> That would be one example of how such a CODEC driver could be
> configured, and is how other baseband/BT devices have ended up going
> (see cx20442.c for example).

I am not aware of how this could be done for bluetooth, since the value 
still has to originate from userspace. The driver you referred to 
supports only a single sample rate, whereas for bluetooth, 2 sample 
rates are required, and nothing in the kernel is aware of the 
appropriate rate, at least in the case of the qca6174a I'm working with 
right now, or for that matter, TI Wilink 8, which I've also worked with.

My concern with implementing this in a new codec driver, is that this 
codec driver will be bound to qdsp6, since its purpose is to work around 
a characteristic of this DSP. Under simple-card, for instance, it would 
be redundant, since in that case, the parameters userspace uses to open 
the pcm will be propagated to the port. But under qdsp6, userspace could 
open the pcm at 44.1 kHz, yet the backend port is still set to 8 or 16 
kHz, and the DSP resamples between them, so the sole purpose of this 
change is to allow userspace to deliver the required sample rate to the 
back end of qdsp6.

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 8/8] ASoC: qcom: apq8096: add kcontrols to set PCM rate
  2020-02-10 21:13               ` Adam Serbinski
@ 2020-02-11 11:42                 ` Mark Brown
  2020-02-11 13:52                   ` Adam Serbinski
  0 siblings, 1 reply; 41+ messages in thread
From: Mark Brown @ 2020-02-11 11:42 UTC (permalink / raw)
  To: Adam Serbinski
  Cc: Srini Kandagatla, Rob Herring, Bjorn Andersson, Andy Gross,
	Mark Rutland, Liam Girdwood, Patrick Lai, Banajit Goswami,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-arm-msm,
	devicetree, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 596 bytes --]

On Mon, Feb 10, 2020 at 04:13:52PM -0500, Adam Serbinski wrote:

> I am not aware of how this could be done for bluetooth, since the value
> still has to originate from userspace. The driver you referred to supports
> only a single sample rate, whereas for bluetooth, 2 sample rates are
> required, and nothing in the kernel is aware of the appropriate rate, at
> least in the case of the qca6174a I'm working with right now, or for that
> matter, TI Wilink 8, which I've also worked with.

There's generic support in the CODEC<->CODEC link code for setting the
DAI configuration from userspace.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 8/8] ASoC: qcom: apq8096: add kcontrols to set PCM rate
  2020-02-11 11:42                 ` Mark Brown
@ 2020-02-11 13:52                   ` Adam Serbinski
  0 siblings, 0 replies; 41+ messages in thread
From: Adam Serbinski @ 2020-02-11 13:52 UTC (permalink / raw)
  To: Mark Brown
  Cc: Srini Kandagatla, Rob Herring, Bjorn Andersson, Andy Gross,
	Mark Rutland, Liam Girdwood, Patrick Lai, Banajit Goswami,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-arm-msm,
	devicetree, linux-kernel

On 2020-02-11 06:42, Mark Brown wrote:
> On Mon, Feb 10, 2020 at 04:13:52PM -0500, Adam Serbinski wrote:
> 
>> I am not aware of how this could be done for bluetooth, since the 
>> value
>> still has to originate from userspace. The driver you referred to 
>> supports
>> only a single sample rate, whereas for bluetooth, 2 sample rates are
>> required, and nothing in the kernel is aware of the appropriate rate, 
>> at
>> least in the case of the qca6174a I'm working with right now, or for 
>> that
>> matter, TI Wilink 8, which I've also worked with.
> 
> There's generic support in the CODEC<->CODEC link code for setting the
> DAI configuration from userspace.

Ok. Its going to take some time to get my head around that, so for the 
time being I'm going to drop this feature and get the rest fixed for 
inclusion.

Thanks.

^ permalink raw reply	[flat|nested] 41+ messages in thread

end of thread, back to index

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-07 20:50 [PATCH 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio Adam Serbinski
2020-02-07 20:50 ` [PATCH 1/8] ASoC: qdsp6: dt-bindings: Add q6afe pcm dt binding Adam Serbinski
2020-02-07 20:50 ` [PATCH 2/8] ASoC: qdsp6: q6afe: add support to pcm ports Adam Serbinski
2020-02-07 20:50 ` [PATCH 3/8] ASoC: qdsp6: q6afe-dai: add support to pcm port dais Adam Serbinski
2020-02-07 20:50 ` [PATCH 4/8] ASoC: qdsp6: q6routing: add pcm port routing Adam Serbinski
2020-02-07 20:50 ` [PATCH 5/8] ASoC: qcom: apq8096: add support for primary and quaternary I2S/PCM Adam Serbinski
2020-02-07 20:50 ` [PATCH 6/8] ASoC: qcom/common: Use snd-soc-dummy-dai when codec is not specified Adam Serbinski
2020-02-07 20:50 ` [PATCH 7/8] dts: msm8996/db820c: enable primary pcm and quaternary i2s Adam Serbinski
2020-02-08 23:42   ` Bjorn Andersson
2020-02-07 20:50 ` [PATCH 8/8] ASoC: qcom: apq8096: add kcontrols to set PCM rate Adam Serbinski
2020-02-09 15:47 ` [PATCH v2 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio Adam Serbinski
2020-02-09 15:47   ` [PATCH v2 1/8] ASoC: qdsp6: dt-bindings: Add q6afe pcm dt binding Adam Serbinski
2020-02-10 17:13     ` Srinivas Kandagatla
2020-02-09 15:47   ` [PATCH v2 2/8] ASoC: qdsp6: q6afe: add support to pcm ports Adam Serbinski
2020-02-10 13:31     ` Mark Brown
2020-02-10 14:50       ` Adam Serbinski
2020-02-10 17:13     ` Srinivas Kandagatla
2020-02-09 15:47   ` [PATCH v2 3/8] ASoC: qdsp6: q6afe-dai: add support to pcm port dais Adam Serbinski
2020-02-10 13:34     ` Mark Brown
2020-02-10 17:13     ` Srinivas Kandagatla
2020-02-10 17:22       ` Adam Serbinski
2020-02-10 17:40         ` Srinivas Kandagatla
2020-02-09 15:47   ` [PATCH v2 4/8] ASoC: qdsp6: q6routing: add pcm port routing Adam Serbinski
2020-02-10 17:19     ` Srinivas Kandagatla
2020-02-09 15:47   ` [PATCH v2 5/8] ASoC: qcom: apq8096: add support for primary and quaternary I2S/PCM Adam Serbinski
2020-02-09 15:47   ` [PATCH v2 6/8] ASoC: qcom/common: Use snd-soc-dummy-dai when codec is not specified Adam Serbinski
2020-02-10 13:35     ` Mark Brown
2020-02-09 15:47   ` [PATCH v2 7/8] arm64: dts: qcom: db820c: Enable primary PCM and quaternary I2S Adam Serbinski
2020-02-09 15:47   ` [PATCH v2 8/8] ASoC: qcom: apq8096: add kcontrols to set PCM rate Adam Serbinski
2020-02-10 13:36     ` Mark Brown
2020-02-10 15:45       ` Adam Serbinski
2020-02-10 18:26         ` Mark Brown
2020-02-10 20:00           ` Adam Serbinski
2020-02-10 20:08             ` Mark Brown
2020-02-10 21:13               ` Adam Serbinski
2020-02-11 11:42                 ` Mark Brown
2020-02-11 13:52                   ` Adam Serbinski
2020-02-10 16:18     ` Jaroslav Kysela
2020-02-10 17:13       ` Adam Serbinski
2020-02-10 12:17   ` [PATCH v2 0/8] ASoC: qdsp6: db820c: Add support for external and bluetooth audio Mark Brown
2020-02-10 13:44     ` Adam Serbinski

Linux-ARM-MSM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-msm/0 linux-arm-msm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-msm linux-arm-msm/ https://lore.kernel.org/linux-arm-msm \
		linux-arm-msm@vger.kernel.org
	public-inbox-index linux-arm-msm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-arm-msm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git