@@ -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);
@@ -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__ */
@@ -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;
@@ -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_ */