diff mbox series

[04/14] ASoC: q6dsp: audioreach: Add support for compress offload commands

Message ID 20230201134947.1638197-5-quic_mohs@quicinc.com (mailing list archive)
State New, archived
Headers show
Series Add support for compress offload and gapless playback. | expand

Commit Message

Mohammad Rafi Shaik Feb. 1, 2023, 1:49 p.m. UTC
Add functions to send commands to the ADSP for supporting compressed
offload playback.
This includes functions to enable module ID, to remove trailing and
initial silence.
Also add functionality to send 32 bit parameter to ADSP.

Signed-off-by: Mohammad Rafi Shaik <quic_mohs@quicinc.com>
Co-developed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/qcom/qdsp6/audioreach.c | 56 +++++++++++++++++++++++++++++++
 sound/soc/qcom/qdsp6/audioreach.h |  7 ++++
 sound/soc/qcom/qdsp6/q6apm.c      | 39 +++++++++++++++++++++
 sound/soc/qcom/qdsp6/q6apm.h      |  3 ++
 4 files changed, 105 insertions(+)

Comments

kernel test robot Feb. 1, 2023, 3:18 p.m. UTC | #1
Hi Mohammad,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on broonie-sound/for-next]
[also build test WARNING on next-20230201]
[cannot apply to tiwai-sound/for-next tiwai-sound/for-linus linus/master v6.2-rc6]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Mohammad-Rafi-Shaik/ALSA-compress-Update-compress-set-params-for-gapless-playback/20230201-215622
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
patch link:    https://lore.kernel.org/r/20230201134947.1638197-5-quic_mohs%40quicinc.com
patch subject: [PATCH 04/14] ASoC: q6dsp: audioreach: Add support for compress offload commands
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230201/202302012309.BtyJn8FN-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/6a2982489303bcf32b927da80e4baffae58437e0
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Mohammad-Rafi-Shaik/ALSA-compress-Update-compress-set-params-for-gapless-playback/20230201-215622
        git checkout 6a2982489303bcf32b927da80e4baffae58437e0
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash sound/soc/qcom/qdsp6/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> sound/soc/qcom/qdsp6/audioreach.c:1262:5: warning: no previous prototype for 'audioreach_send_u32_param' [-Wmissing-prototypes]
    1262 | int audioreach_send_u32_param(struct q6apm *apm, struct audioreach_module *module,
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~


vim +/audioreach_send_u32_param +1262 sound/soc/qcom/qdsp6/audioreach.c

  1261	
> 1262	int audioreach_send_u32_param(struct q6apm *apm, struct audioreach_module *module,
  1263				      uint32_t param_id, uint32_t param_val)
  1264	{
  1265		struct apm_module_param_data *param_data;
  1266		struct gpr_pkt *pkt;
  1267		uint32_t *param;
  1268		int rc, payload_size;
  1269		void *p;
  1270	
  1271		payload_size = sizeof(uint32_t) + APM_MODULE_PARAM_DATA_SIZE;
  1272		p = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0);
  1273		if (IS_ERR(p))
  1274			return -ENOMEM;
  1275	
  1276		pkt = p;
  1277		p = p + GPR_HDR_SIZE + APM_CMD_HDR_SIZE;
  1278	
  1279		param_data = p;
  1280		param_data->module_instance_id = module->instance_id;
  1281		param_data->error_code = 0;
  1282		param_data->param_id = param_id;
  1283		param_data->param_size = payload_size - APM_MODULE_PARAM_DATA_SIZE;
  1284	
  1285		p = p + APM_MODULE_PARAM_DATA_SIZE;
  1286		param = p;
  1287		*param = param_val;
  1288		rc = q6apm_send_cmd_sync(apm, pkt, 0);
  1289	
  1290		kfree(pkt);
  1291	
  1292		return rc;
  1293	}
  1294	EXPORT_SYMBOL_GPL(audioreach_send_u32_param);
  1295
diff mbox series

Patch

diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c
index 6d3d2a04ffe8..a11bab69a676 100644
--- a/sound/soc/qcom/qdsp6/audioreach.c
+++ b/sound/soc/qcom/qdsp6/audioreach.c
@@ -1258,3 +1258,59 @@  int audioreach_shared_memory_send_eos(struct q6apm_graph *graph)
 	return rc;
 }
 EXPORT_SYMBOL_GPL(audioreach_shared_memory_send_eos);
+
+int audioreach_send_u32_param(struct q6apm *apm, struct audioreach_module *module,
+			      uint32_t param_id, uint32_t param_val)
+{
+	struct apm_module_param_data *param_data;
+	struct gpr_pkt *pkt;
+	uint32_t *param;
+	int rc, payload_size;
+	void *p;
+
+	payload_size = sizeof(uint32_t) + APM_MODULE_PARAM_DATA_SIZE;
+	p = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0);
+	if (IS_ERR(p))
+		return -ENOMEM;
+
+	pkt = p;
+	p = p + GPR_HDR_SIZE + APM_CMD_HDR_SIZE;
+
+	param_data = p;
+	param_data->module_instance_id = module->instance_id;
+	param_data->error_code = 0;
+	param_data->param_id = param_id;
+	param_data->param_size = payload_size - APM_MODULE_PARAM_DATA_SIZE;
+
+	p = p + APM_MODULE_PARAM_DATA_SIZE;
+	param = p;
+	*param = param_val;
+	rc = q6apm_send_cmd_sync(apm, pkt, 0);
+
+	kfree(pkt);
+
+	return rc;
+}
+EXPORT_SYMBOL_GPL(audioreach_send_u32_param);
+
+int audioreach_remove_trailing_silence(struct q6apm *apm, struct audioreach_module *module,
+				       uint32_t trailing_samples)
+{
+	return audioreach_send_u32_param(apm, module, PARAM_ID_REMOVE_TRAILING_SILENCE,
+					 trailing_samples);
+}
+EXPORT_SYMBOL_GPL(audioreach_remove_trailing_silence);
+
+int audioreach_remove_initial_silence(struct q6apm *apm, struct audioreach_module *module,
+				      uint32_t initial_samples)
+{
+	return audioreach_send_u32_param(apm, module, PARAM_ID_REMOVE_INITIAL_SILENCE,
+					 initial_samples);
+}
+EXPORT_SYMBOL_GPL(audioreach_remove_initial_silence);
+
+int audioreach_enable_module(struct q6apm *apm, struct audioreach_module *module, bool en)
+{
+	return audioreach_send_u32_param(apm, module, PARAM_ID_MODULE_ENABLE, en);
+}
+EXPORT_SYMBOL_GPL(audioreach_enable_module);
diff --git a/sound/soc/qcom/qdsp6/audioreach.h b/sound/soc/qcom/qdsp6/audioreach.h
index b78fd9bc8eb3..76dea97773cc 100644
--- a/sound/soc/qcom/qdsp6/audioreach.h
+++ b/sound/soc/qcom/qdsp6/audioreach.h
@@ -629,6 +629,8 @@  struct param_id_vol_ctrl_master_gain {
 } __packed;
 
 
+#define PARAM_ID_REMOVE_INITIAL_SILENCE		0x0800114B
+#define PARAM_ID_REMOVE_TRAILING_SILENCE	0x0800115D
 
 #define PARAM_ID_REAL_MODULE_ID	0x0800100B
 
@@ -779,4 +781,9 @@  int audioreach_set_media_format(struct q6apm_graph *graph,
 int audioreach_shared_memory_send_eos(struct q6apm_graph *graph);
 int audioreach_gain_set_vol_ctrl(struct q6apm *apm,
 				 struct audioreach_module *module, int vol);
+int audioreach_enable_module(struct q6apm *apm, struct audioreach_module *module, bool en);
+int audioreach_remove_initial_silence(struct q6apm *apm, struct audioreach_module *module,
+				uint32_t initial_samples);
+int audioreach_remove_trailing_silence(struct q6apm *apm, struct audioreach_module *module,
+				uint32_t trailing_samples);
 #endif /* __AUDIOREACH_H__ */
diff --git a/sound/soc/qcom/qdsp6/q6apm.c b/sound/soc/qcom/qdsp6/q6apm.c
index 8a7dfd27d3c5..78c1a7c13348 100644
--- a/sound/soc/qcom/qdsp6/q6apm.c
+++ b/sound/soc/qcom/qdsp6/q6apm.c
@@ -297,6 +297,45 @@  int q6apm_unmap_memory_regions(struct q6apm_graph *graph, unsigned int dir)
 }
 EXPORT_SYMBOL_GPL(q6apm_unmap_memory_regions);
 
+int q6apm_remove_initial_silence(struct device *dev, struct q6apm_graph *graph, uint32_t samples)
+{
+	struct q6apm *apm = dev_get_drvdata(dev->parent);
+	struct audioreach_module *module;
+
+	module = q6apm_find_module_by_mid(graph, MODULE_ID_PLACEHOLDER_DECODER);
+	if (!module)
+		return -ENODEV;
+
+	return audioreach_remove_initial_silence(apm, module, samples);
+}
+EXPORT_SYMBOL_GPL(q6apm_remove_initial_silence);
+
+int q6apm_remove_trailing_silence(struct device *dev, struct q6apm_graph *graph, uint32_t samples)
+{
+	struct q6apm *apm = dev_get_drvdata(dev->parent);
+	struct audioreach_module *module;
+
+	module = q6apm_find_module_by_mid(graph, MODULE_ID_PLACEHOLDER_DECODER);
+	if (!module)
+		return -ENODEV;
+
+	return audioreach_remove_trailing_silence(apm, module, samples);
+}
+EXPORT_SYMBOL_GPL(q6apm_remove_trailing_silence);
+
+int q6apm_enable_compress_module(struct device *dev, struct q6apm_graph *graph, bool en)
+{
+	struct q6apm *apm = dev_get_drvdata(dev->parent);
+	struct audioreach_module *module;
+
+	module = q6apm_find_module_by_mid(graph, MODULE_ID_PLACEHOLDER_DECODER);
+	if (!module)
+		return -ENODEV;
+
+	return audioreach_enable_module(apm, module, en);
+}
+EXPORT_SYMBOL_GPL(q6apm_enable_compress_module);
+
 int q6apm_graph_media_format_pcm(struct q6apm_graph *graph, struct audioreach_module_config *cfg)
 {
 	struct audioreach_graph_info *info = graph->info;
diff --git a/sound/soc/qcom/qdsp6/q6apm.h b/sound/soc/qcom/qdsp6/q6apm.h
index 7005be9b63e3..08b64f78c750 100644
--- a/sound/soc/qcom/qdsp6/q6apm.h
+++ b/sound/soc/qcom/qdsp6/q6apm.h
@@ -147,4 +147,7 @@  int q6apm_graph_get_rx_shmem_module_iid(struct q6apm_graph *graph);
 
 bool q6apm_is_adsp_ready(void);
 
+int q6apm_enable_compress_module(struct device *dev, struct q6apm_graph *graph, bool en);
+int q6apm_remove_initial_silence(struct device *dev, struct q6apm_graph *graph, uint32_t samples);
+int q6apm_remove_trailing_silence(struct device *dev, struct q6apm_graph *graph, uint32_t samples);
 #endif /* __APM_GRAPH_ */