aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSrinivas Kandagatla <srinivas.kandagatla@linaro.org>2020-10-05 10:46:31 +0100
committerSrinivas Kandagatla <srinivas.kandagatla@linaro.org>2021-03-16 16:00:31 +0000
commitd2c1827bea9648798235fcb5b9ee50e62ff2be42 (patch)
treed41f4a776cc6134a5408a3620db6a1faa48df3f6
parent56ef9b1c3bdc5cced7f7cd08ea9bcc60612c426a (diff)
ASoC: qcom: audio-reach: add logging module parameters support
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
-rw-r--r--sound/soc/qcom/audio-reach/graph.h7
-rw-r--r--sound/soc/qcom/audio-reach/module.c168
2 files changed, 157 insertions, 18 deletions
diff --git a/sound/soc/qcom/audio-reach/graph.h b/sound/soc/qcom/audio-reach/graph.h
index 760cb567105e8..7a9a5b17b6f76 100644
--- a/sound/soc/qcom/audio-reach/graph.h
+++ b/sound/soc/qcom/audio-reach/graph.h
@@ -7,7 +7,7 @@
#define MAX_GRAPHS 8
-struct audio_reach_module{
+struct audio_reach_module {
uint32_t module_id;
uint32_t instance_id;
@@ -30,12 +30,17 @@ struct audio_reach_module{
uint32_t ws_src;
uint32_t frame_size_factor;
uint32_t data_format;
+ uint32_t hw_interface_type;
/* PCM module specific */
uint32_t interleave_type;
/* GAIN Module */
uint16_t gain;
+ /* Logging */
+ uint32_t log_code;
+ uint32_t log_tap_point_id;
+ uint32_t mode;
};
struct audio_reach_container {
diff --git a/sound/soc/qcom/audio-reach/module.c b/sound/soc/qcom/audio-reach/module.c
index 32dd5f3e8dab1..0caa9cd50f22f 100644
--- a/sound/soc/qcom/audio-reach/module.c
+++ b/sound/soc/qcom/audio-reach/module.c
@@ -50,21 +50,38 @@ struct apm_i2s_module_intf_cfg {
#define APM_I2S_INTF_CFG_PSIZE ALIGN(sizeof(struct apm_i2s_module_intf_cfg), \
8)
-struct apm_i2s_module_hw_ep_mf_cfg {
+struct apm_module_hw_ep_mf_cfg {
struct apm_module_param_data param_data;
struct param_id_hw_ep_mf mf;
}__packed;
-#define APM_I2S_HW_EP_CFG_PSIZE ALIGN( \
- sizeof(struct apm_i2s_module_hw_ep_mf_cfg), \
+#define APM_HW_EP_CFG_PSIZE ALIGN( \
+ sizeof(struct apm_module_hw_ep_mf_cfg), \
8)
-struct apm_i2s_module_frame_size_factor_cfg {
+struct apm_module_frame_size_factor_cfg {
struct apm_module_param_data param_data;
uint32_t frame_size_factor;
}__packed;
-#define APM_I2S_FS_CFG_PSIZE ALIGN( \
- sizeof(struct apm_i2s_module_frame_size_factor_cfg), \
+#define APM_FS_CFG_PSIZE ALIGN( \
+ sizeof(struct apm_module_frame_size_factor_cfg), \
8)
+
+struct apm_module_hw_ep_power_mode_cfg {
+ struct apm_module_param_data param_data;
+ struct param_id_hw_ep_power_mode_cfg power_mode;
+}__packed;
+#define APM_HW_EP_PMODE_CFG_PSIZE ALIGN( \
+ sizeof(struct apm_module_hw_ep_power_mode_cfg), \
+ 8)
+
+struct apm_module_hw_ep_dma_data_align_cfg {
+ struct apm_module_param_data param_data;
+ struct param_id_hw_ep_dma_data_align align;
+}__packed;
+#define APM_HW_EP_DALIGN_CFG_PSIZE ALIGN( \
+ sizeof(struct apm_module_hw_ep_dma_data_align_cfg), \
+ 8)
+
struct apm_rat_module_intf_cfg {
struct apm_module_param_data param_data;
struct param_id_rat_mf cfg;
@@ -88,6 +105,13 @@ struct apm_mfc_media_format_cfg {
sizeof(struct apm_mfc_media_format_cfg) + \
n * sizeof(uint16_t), 8)
+struct apm_codec_dma_module_intf_cfg {
+ struct apm_module_param_data param_data;
+ struct param_id_codec_dma_intf_cfg cfg;
+}__packed;
+#define APM_CDMA_INTF_CFG_PSIZE ALIGN( \
+ sizeof(struct apm_codec_dma_module_intf_cfg), 8)
+
static int audio_reach_graph_send_cmd_sync(struct q6apm_graph *graph,
struct gpr_pkt *pkt,
uint32_t rsp_opcode)
@@ -133,6 +157,111 @@ err:
return rc;
}
+int audio_reach_codec_dma_set_media_format(struct q6apm_graph *graph,
+ struct audio_reach_module *module,
+ int direction, uint32_t rate,
+ uint32_t num_channels,
+ u8 channel_map[PCM_MAX_NUM_CHANNEL],
+ uint16_t bits_per_sample)
+{
+ /*
+ PARAM_ID_CODEC_DMA_INTF_CFG
+ PARAM_ID_HW_EP_MF_CFG
+ PARAM_ID_HW_EP_FRAME_SIZE_FACTOR
+ PARAM_ID_HW_EP_POWER_MODE_CFG
+ PARAM_ID_HW_EP_DMA_DATA_ALIGN
+ PAR
+ */
+ struct gpr_pkt *pkt;
+ void *p;
+ int rc, payload_size;
+ struct apm_module_param_data *param_data;
+ struct apm_codec_dma_module_intf_cfg *intf_cfg;
+ struct apm_module_hw_ep_mf_cfg *hw_cfg;
+ struct apm_module_frame_size_factor_cfg *fs_cfg;
+ struct apm_module_hw_ep_power_mode_cfg *pm_cfg;
+ struct apm_module_hw_ep_dma_data_align_cfg *dl_cfg;
+ int ic_sz, ep_sz, fs_sz, pm_sz, dl_sz;
+
+ ic_sz = APM_CDMA_INTF_CFG_PSIZE;
+ ep_sz = APM_HW_EP_CFG_PSIZE;
+ fs_sz = APM_FS_CFG_PSIZE;
+ pm_sz = APM_HW_EP_PMODE_CFG_PSIZE;
+ dl_sz = 0;// FIXME APM_HW_EP_DALIGN_CFG_PSIZE;
+
+ payload_size = ic_sz + ep_sz + fs_sz + pm_sz + dl_sz;
+
+ p = audio_reach_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;
+
+
+
+ hw_cfg = p;
+ param_data = &hw_cfg->param_data;
+ param_data->module_instance_id = module->instance_id;
+ param_data->error_code = 0;
+ param_data->param_id = PARAM_ID_HW_EP_MF_CFG;
+ param_data->param_size = ep_sz - APM_MODULE_PARAM_DATA_SIZE;
+
+ hw_cfg->mf.sample_rate = rate;
+ hw_cfg->mf.bit_width = bits_per_sample;
+ hw_cfg->mf.num_channels = num_channels;
+ hw_cfg->mf.data_format = module->data_format;
+ p += ep_sz;
+
+ fs_cfg = p;
+ param_data = &fs_cfg->param_data;
+ param_data->module_instance_id = module->instance_id;
+ param_data->error_code = 0;
+ param_data->param_id = PARAM_ID_HW_EP_FRAME_SIZE_FACTOR;
+ param_data->param_size = fs_sz - APM_MODULE_PARAM_DATA_SIZE;
+ fs_cfg->frame_size_factor = 1;
+ p += fs_sz;
+
+
+ intf_cfg = p;
+ param_data = &intf_cfg->param_data;
+ param_data->module_instance_id = module->instance_id;
+ param_data->error_code = 0;
+ param_data->param_id = PARAM_ID_CODEC_DMA_INTF_CFG;
+ param_data->param_size = ic_sz - APM_MODULE_PARAM_DATA_SIZE;
+
+ intf_cfg->cfg.lpaif_type = module->hw_interface_type;
+ intf_cfg->cfg.intf_index = module->hw_interface_idx;
+ intf_cfg->cfg.active_channels_mask = (1 << num_channels) - 1;
+ p += ic_sz;
+
+
+ pm_cfg = p;
+ param_data = &pm_cfg->param_data;
+ param_data->module_instance_id = module->instance_id;
+ param_data->error_code = 0;
+ param_data->param_id = PARAM_ID_HW_EP_POWER_MODE_CFG;
+ param_data->param_size = pm_sz - APM_MODULE_PARAM_DATA_SIZE;
+ pm_cfg->power_mode.power_mode = 0; //FIXME
+#if 0
+ p += pm_sz;
+ dl_cfg = p;
+ param_data = &dl_cfg->param_data;
+ param_data->module_instance_id = module->instance_id;
+ param_data->error_code = 0;
+ param_data->param_id = PARAM_ID_HW_EP_DMA_DATA_ALIGN;
+ param_data->param_size = dl_sz - APM_MODULE_PARAM_DATA_SIZE;
+ dl_cfg->align.dma_data_align = 0; //FIXME
+#endif
+
+ //dump_set_cfg(pkt, payload_size, module->module_id);
+ rc = q6apm_send_cmd_sync(graph->apm, pkt, 0);
+
+ kfree(pkt);
+
+ return rc;
+}
+
int audio_reach_mfc_set_media_format(struct q6apm_graph *graph,
struct audio_reach_module *module,
int direction, uint32_t rate,
@@ -189,13 +318,13 @@ int audio_reach_i2s_set_media_format(struct q6apm_graph *graph,
int rc, payload_size;
struct apm_module_param_data *param_data;
struct apm_i2s_module_intf_cfg *intf_cfg;
- struct apm_i2s_module_hw_ep_mf_cfg *hw_cfg;
- struct apm_i2s_module_frame_size_factor_cfg *fs_cfg;
+ struct apm_module_hw_ep_mf_cfg *hw_cfg;
+ struct apm_module_frame_size_factor_cfg *fs_cfg;
int ic_sz, ep_sz, fs_sz;
ic_sz = APM_I2S_INTF_CFG_PSIZE;
- ep_sz = APM_I2S_HW_EP_CFG_PSIZE;
- fs_sz = APM_I2S_FS_CFG_PSIZE;
+ ep_sz = APM_HW_EP_CFG_PSIZE;
+ fs_sz = APM_FS_CFG_PSIZE;
payload_size = ic_sz + ep_sz + fs_sz;
@@ -247,9 +376,7 @@ int audio_reach_i2s_set_media_format(struct q6apm_graph *graph,
}
int audio_reach_logging_set_media_format(struct q6apm_graph *graph,
- struct audio_reach_module *module,
- uint32_t log_code,
- uint32_t log_tap_point_id)
+ struct audio_reach_module *module)
{
struct gpr_pkt *pkt;
@@ -274,9 +401,9 @@ int audio_reach_logging_set_media_format(struct q6apm_graph *graph,
p = p + APM_MODULE_PARAM_DATA_SIZE;
cfg = p;
- cfg->log_code = log_code;
- cfg->log_tap_point_id = log_tap_point_id;
- cfg->mode = 0;
+ cfg->log_code = module->log_code;
+ cfg->log_tap_point_id = module->log_tap_point_id;
+ cfg->mode = module->mode;
rc = q6apm_send_cmd_sync(graph->apm, pkt, 0);
@@ -478,7 +605,7 @@ int audio_reach_set_media_format(struct q6apm_graph *graph,
switch (module->module_id) {
case MODULE_ID_DATA_LOGGING:
- rc = audio_reach_logging_set_media_format(graph, module, 0x19af, 1);
+ rc = audio_reach_logging_set_media_format(graph, module);
break;
case MODULE_ID_RATE_ADAPTED_TIMER:
rc = audio_reach_rat_set_media_format(graph, module,
@@ -514,6 +641,13 @@ int audio_reach_set_media_format(struct q6apm_graph *graph,
channels, channel_map,
bits_per_sample);
break;
+ case MODULE_ID_CODEC_DMA_SINK:
+ case MODULE_ID_CODEC_DMA_SOURCE:
+ rc = audio_reach_codec_dma_set_media_format(graph, module,
+ direction, rate,
+ channels, channel_map,
+ bits_per_sample);
+ break;
default:
rc = 0;
}