dsp: add support for aptX dual mono

Send sync mode parameter to DSP for supporting aptX dual mono.

Change-Id: I1c43b0dec6661a77644e28df45ca6c1a182745de
Signed-off-by: Aniket Kumar Lata <alata@codeaurora.org>
diff --git a/asoc/msm-dai-q6-v2.c b/asoc/msm-dai-q6-v2.c
index 2802a4f..53622e0 100644
--- a/asoc/msm-dai-q6-v2.c
+++ b/asoc/msm-dai-q6-v2.c
@@ -2249,6 +2249,10 @@
 				sizeof(struct asm_aac_enc_cfg_v2_t));
 			break;
 		case ENC_FMT_APTX:
+			memcpy(ucontrol->value.bytes.data + format_size,
+				&dai_data->enc_config.data,
+				sizeof(struct asm_aptx_enc_cfg_t));
+			break;
 		case ENC_FMT_APTX_HD:
 			memcpy(ucontrol->value.bytes.data + format_size,
 				&dai_data->enc_config.data,
@@ -2298,6 +2302,10 @@
 				sizeof(struct asm_aac_enc_cfg_v2_t));
 			break;
 		case ENC_FMT_APTX:
+			memcpy(&dai_data->enc_config.data,
+				ucontrol->value.bytes.data + format_size,
+				sizeof(struct asm_aptx_enc_cfg_t));
+			break;
 		case ENC_FMT_APTX_HD:
 			memcpy(&dai_data->enc_config.data,
 				ucontrol->value.bytes.data + format_size,
diff --git a/dsp/q6afe.c b/dsp/q6afe.c
index 8e96f6f..2bdfd10 100644
--- a/dsp/q6afe.c
+++ b/dsp/q6afe.c
@@ -2895,6 +2895,24 @@
 		goto exit;
 	}
 
+	if (format == ASM_MEDIA_FMT_APTX) {
+		config.param.payload_size =
+			payload_size + sizeof(config.port.sync_mode_param);
+		pr_debug("%s: sending AFE_PARAM_ID_APTX_SYNC_MODE to DSP",
+			__func__);
+		config.pdata.param_id = AFE_PARAM_ID_APTX_SYNC_MODE;
+		config.pdata.param_size = sizeof(config.port.sync_mode_param);
+		config.port.sync_mode_param.sync_mode =
+			config.port.enc_blk_param.enc_blk_config.aptx_config.
+				aptx_v2_cfg.sync_mode;
+		ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
+		if (ret) {
+			pr_err("%s: AFE_PARAM_ID_APTX_SYNC_MODE for port 0x%x failed %d\n",
+				__func__, port_id, ret);
+			goto exit;
+		}
+	}
+
 	config.param.payload_size =
 			payload_size + sizeof(config.port.enc_pkt_id_param);
 	pr_debug("%s:sending AFE_ENCODER_PARAM_ID_PACKETIZER to DSP payload = %d",
diff --git a/include/dsp/apr_audio-v2.h b/include/dsp/apr_audio-v2.h
index df635cc..be56d74 100644
--- a/include/dsp/apr_audio-v2.h
+++ b/include/dsp/apr_audio-v2.h
@@ -3074,6 +3074,16 @@
 	u32		topology_id;
 } __packed;
 
+#define AFE_PARAM_ID_APTX_SYNC_MODE  0x00013205
+
+struct afe_param_id_aptx_sync_mode {
+	/*
+	 * sync mode: 0x0 = stereo sync mode (default)
+	 *            0x01 = dual mono sync mode
+	 *            0x02 = dual mono with no sync on either L or R
+	 */
+	uint32_t     sync_mode;
+} __packed;
 
 /*
  * Generic encoder module ID.
@@ -3305,6 +3315,21 @@
 	uint8_t     channel_mapping[8];
 	uint32_t    custom_size;
 } __packed;
+
+struct asm_aptx_v2_enc_cfg_ext_t {
+	/*
+	 * sync mode: 0x0 = stereo sync mode (default)
+	 *            0x01 = dual mono sync mode
+	 *            0x02 = dual mono with no sync on either L or R
+	 */
+	uint32_t     sync_mode;
+} __packed;
+
+struct asm_aptx_enc_cfg_t {
+	struct asm_custom_enc_cfg_t custom_cfg;
+	struct asm_aptx_v2_enc_cfg_ext_t aptx_v2_cfg;
+} __packed;
+
 #define ASM_MEDIA_FMT_CELT 0x00013221
 struct asm_celt_specific_enc_cfg_t {
 	/*
@@ -3421,6 +3446,7 @@
 	struct asm_aac_enc_cfg_v2_t aac_config;
 	struct asm_custom_enc_cfg_t  custom_config;
 	struct asm_celt_enc_cfg_t  celt_config;
+	struct asm_aptx_enc_cfg_t  aptx_config;
 };
 
 struct afe_enc_config {
@@ -3461,6 +3487,7 @@
 	struct afe_param_id_set_topology_cfg      topology;
 	struct afe_param_id_tdm_cfg               tdm;
 	struct afe_param_id_usb_audio_cfg         usb_audio;
+	struct afe_param_id_aptx_sync_mode        sync_mode_param;
 	struct afe_enc_fmt_id_param_t             enc_fmt;
 	struct afe_port_media_type_t              media_type;
 	struct afe_enc_cfg_blk_param_t            enc_blk_param;