[Sound-open-firmware] [PATCH 5/5] dai: add dai_cmd support for loopback mode switch

Xiuli Pan xiuli.pan at linux.intel.com
Tue Jun 19 11:22:11 CEST 2018


From: Pan Xiuli <xiuli.pan at linux.intel.com>

use dai_cmd to handle ssp dai loopback mode switch support

Signed-off-by: Pan Xiuli <xiuli.pan at linux.intel.com>
---
Work with patch set:
SOF-Kernel(6):
  ASoC: SOF: Add debug_mode flag in sof dev
  ASoC: SOF: debug: add debugmode debugfs for sof_dev debug_mode
  ASoC: SOF: uapi: topology: Add SOF_TKN_DAI_SSP_LBM for ssp loopback mode
  ASoC: SOF: add headers for lbm control callback functions
  ASoC: SOF: add lbm kcontrol callback functions
  ASoC: SOF: topology: Add topology handler for dai ssp loopback mode

SOF(5):
  dai: add lbm status for dai ssp
  dai: add get_loopback_mode function
  DMIC: add empty get_loopback_mode function
  SSP: support for get/set_loopback_mode functions
  dai: add dai_cmd support for loopback mode switch

SOF-Tools(3):
  topology: Add SOF_TKN_DAI_SSP_LBM for ssp loopback mode
  topology: m4: Add DAI_OUT_SSP_LOOPBACK marco for SSP LOOPBACK dai comp
  topology: test: Add loopback topology

test & santity test with:
Mininow max rt5651 and UP2 Hifiberry PRO and CNL nocodec
SOF master: 48d2a1c551d7b3c8f76d44f3c04dd59a37ff6a8f
SOF-Tool master: bd7dc88231f31d385340310cef467f211a739eeb
https://github.com/plbossart/sound/tree/topic/sof-v4.14:
0d51a5ed28c5e97f09b59c4cafaddfb9d3b24b77
---
 src/audio/dai.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)

diff --git a/src/audio/dai.c b/src/audio/dai.c
index 21a3b80..53acbd8 100644
--- a/src/audio/dai.c
+++ b/src/audio/dai.c
@@ -663,6 +663,81 @@ static int dai_config(struct comp_dev *dev, struct sof_ipc_dai_config *config)
 	return 0;
 }
 
+static int dai_ctrl_set_cmd(struct comp_dev *dev,
+			    struct sof_ipc_ctrl_data *cdata)
+{
+	struct dai_data *dd = comp_get_drvdata(dev);
+	int ret = 0;
+	int val;
+
+	/* validate */
+	if (cdata->num_elems != 1) {
+		trace_dai_error("xs0");
+		return -EINVAL;
+	}
+
+	switch (cdata->cmd) {
+	case SOF_CTRL_CMD_SWITCH:
+		val = cdata->compv[0].uvalue;
+		trace_dai("dcs");
+		trace_value(cdata->comp_id);
+		trace_value(val);
+		dai_set_loopback_mode(dd->dai, val);
+		break;
+
+	default:
+		trace_dai_error("gs1");
+		return -EINVAL;
+	}
+
+	return ret;
+}
+
+static int dai_ctrl_get_cmd(struct comp_dev *dev,
+			    struct sof_ipc_ctrl_data *cdata)
+{
+	struct dai_data *dd = comp_get_drvdata(dev);
+	int val;
+
+	/* validate */
+	if (cdata->num_elems != 1) {
+		trace_dai_error("xg0");
+		return -EINVAL;
+	}
+	switch (cdata->cmd) {
+	case SOF_CTRL_CMD_SWITCH:
+		val = dai_get_loopback_mode(dd->dai);
+		trace_dai("dcg");
+		trace_value(cdata->comp_id);
+		trace_value(val);
+		cdata->compv[0].uvalue = val;
+		break;
+
+	default:
+		trace_dai_error("xcc");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+/* used to pass standard and bespoke commands (with data) to component */
+static int dai_cmd(struct comp_dev *dev, int cmd, void *data)
+{
+	struct sof_ipc_ctrl_data *cdata = data;
+
+	trace_dai("cmd");
+
+	switch (cmd) {
+	case COMP_CMD_SET_VALUE:
+		return dai_ctrl_set_cmd(dev, cdata);
+	case COMP_CMD_GET_VALUE:
+		return dai_ctrl_get_cmd(dev, cdata);
+	default:
+		return -EINVAL;
+	}
+}
+
 static struct comp_driver comp_dai = {
 	.type	= SOF_COMP_DAI,
 	.ops	= {
@@ -675,6 +750,7 @@ static struct comp_driver comp_dai = {
 		.reset		= dai_reset,
 		.dai_config	= dai_config,
 		.position	= dai_position,
+		.cmd		= dai_cmd,
 	},
 };
 
-- 
2.7.4



More information about the Sound-open-firmware mailing list