Skip to content

Commit 7c1ac23

Browse files
Srinivas Kandagatlabroonie
authored andcommitted
ASoC: qcom: audioreach: Add support for shared memory push/pull modules
Push-pull graphs use MODULE_ID_SH_MEM_PULL_MODE for playback and MODULE_ID_SH_MEM_PUSH_MODE for capture instead of the legacy WR/RD shared memory endpoints. Detect these modules when opening the graph, cache their instance ID in graph->shm_iid, and use them for media format setup. Also add support for mapping the position buffer required by push-pull mode and configuring the DSP with circular buffer and position buffer addresses. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com> Link: https://patch.msgid.link/20260528185806.6316-5-srinivas.kandagatla@oss.qualcomm.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 240286e commit 7c1ac23

4 files changed

Lines changed: 231 additions & 26 deletions

File tree

sound/soc/qcom/qdsp6/audioreach.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,6 +1342,7 @@ int audioreach_set_media_format(struct q6apm_graph *graph,
13421342
rc = audioreach_i2s_set_media_format(graph, module, cfg);
13431343
break;
13441344
case MODULE_ID_WR_SHARED_MEM_EP:
1345+
case MODULE_ID_SH_MEM_PULL_MODE:
13451346
rc = audioreach_shmem_set_media_format(graph, module, cfg);
13461347
break;
13471348
case MODULE_ID_GAIN:
@@ -1401,6 +1402,44 @@ void audioreach_graph_free_buf(struct q6apm_graph *graph)
14011402
}
14021403
EXPORT_SYMBOL_GPL(audioreach_graph_free_buf);
14031404

1405+
int audioreach_setup_push_pull(struct q6apm_graph *graph, phys_addr_t bphys,
1406+
phys_addr_t pphys, uint32_t mem_map_handle,
1407+
uint32_t pos_buf_mem_map_handle, uint32_t size)
1408+
{
1409+
struct param_id_sh_mem_pull_push_mode_cfg *cfg;
1410+
struct apm_module_param_data *param_data;
1411+
int payload_size;
1412+
struct gpr_pkt *pkt __free(kfree) = NULL;
1413+
void *p;
1414+
1415+
payload_size = sizeof(*cfg) + APM_MODULE_PARAM_DATA_SIZE;
1416+
pkt = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0);
1417+
if (IS_ERR(pkt))
1418+
return PTR_ERR(pkt);
1419+
1420+
p = (void *)pkt + GPR_HDR_SIZE + APM_CMD_HDR_SIZE;
1421+
1422+
param_data = p;
1423+
param_data->module_instance_id = graph->shm_iid;
1424+
param_data->error_code = 0;
1425+
param_data->param_id = PARAM_ID_SH_MEM_PULL_PUSH_MODE_CFG;
1426+
param_data->param_size = payload_size - APM_MODULE_PARAM_DATA_SIZE;
1427+
1428+
p = p + APM_MODULE_PARAM_DATA_SIZE;
1429+
cfg = p;
1430+
1431+
cfg->shared_circ_buf_addr_lsw = lower_32_bits(bphys);
1432+
cfg->shared_circ_buf_addr_msw = upper_32_bits(bphys);
1433+
cfg->shared_circ_buf_size = size;
1434+
cfg->circ_buf_mem_map_handle = mem_map_handle;
1435+
cfg->shared_pos_buf_addr_lsw = lower_32_bits(pphys);
1436+
cfg->shared_pos_buf_addr_msw = upper_32_bits(pphys);
1437+
cfg->pos_buf_mem_map_handle = pos_buf_mem_map_handle;
1438+
1439+
return q6apm_send_cmd_sync(graph->apm, pkt, 0);
1440+
}
1441+
EXPORT_SYMBOL_GPL(audioreach_setup_push_pull);
1442+
14041443
int audioreach_shared_memory_send_eos(struct q6apm_graph *graph)
14051444
{
14061445
struct data_cmd_wr_sh_mem_ep_eos *eos;

sound/soc/qcom/qdsp6/audioreach.h

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ struct q6apm_graph;
1616
#define MODULE_ID_PCM_CNV 0x07001003
1717
#define MODULE_ID_PCM_ENC 0x07001004
1818
#define MODULE_ID_PCM_DEC 0x07001005
19+
#define MODULE_ID_SH_MEM_PULL_MODE 0x07001006
20+
#define MODULE_ID_SH_MEM_PUSH_MODE 0x07001007
1921
#define MODULE_ID_PLACEHOLDER_ENCODER 0x07001008
2022
#define MODULE_ID_PLACEHOLDER_DECODER 0x07001009
2123
#define MODULE_ID_I2S_SINK 0x0700100A
@@ -61,6 +63,9 @@ struct q6apm_graph;
6163
#define APM_CMD_SHARED_MEM_MAP_REGIONS 0x0100100C
6264
#define APM_CMD_SHARED_MEM_UNMAP_REGIONS 0x0100100D
6365
#define APM_CMD_RSP_SHARED_MEM_MAP_REGIONS 0x02001001
66+
#define APM_MMAP_TOKEN_GID_MASK GENMASK(15, 0)
67+
#define APM_MMAP_TOKEN_MAP_TYPE_POS_BUF BIT(16)
68+
#define APM_MMAP_TOKEN_MAP_TYPE_SHIFT 16
6469
#define APM_CMD_RSP_GET_CFG 0x02001000
6570
#define APM_CMD_CLOSE_ALL 0x01001013
6671
#define APM_CMD_REGISTER_SHARED_CFG 0x0100100A
@@ -710,6 +715,46 @@ struct param_id_placeholder_real_module_id {
710715
uint32_t real_module_id;
711716
} __packed;
712717

718+
719+
#define PARAM_ID_SH_MEM_PULL_PUSH_MODE_CFG 0x0800100A
720+
721+
/**
722+
* struct param_id_sh_mem_pull_push_mode_cfg - Shared memory push/pull config
723+
* @shared_circ_buf_addr_lsw: Lower 32 bits of the circular buffer address.
724+
* @shared_circ_buf_addr_msw: Upper 32 bits of the circular buffer address.
725+
* @shared_circ_buf_size: Circular buffer size in bytes.
726+
* @circ_buf_mem_map_handle: Circular buffer memory map handle.
727+
* @shared_pos_buf_addr_lsw: Lower 32 bits of the position buffer address.
728+
* @shared_pos_buf_addr_msw: Upper 32 bits of the position buffer address.
729+
* @pos_buf_mem_map_handle: Position buffer memory map handle.
730+
*/
731+
struct param_id_sh_mem_pull_push_mode_cfg {
732+
uint32_t shared_circ_buf_addr_lsw;
733+
uint32_t shared_circ_buf_addr_msw;
734+
uint32_t shared_circ_buf_size;
735+
uint32_t circ_buf_mem_map_handle;
736+
uint32_t shared_pos_buf_addr_lsw;
737+
uint32_t shared_pos_buf_addr_msw;
738+
uint32_t pos_buf_mem_map_handle;
739+
} __packed;
740+
741+
/**
742+
* struct sh_mem_pull_push_mode_position_buffer - Shared position buffer
743+
* @frame_counter: Synchronization counter.
744+
* @index: Current read/write index in bytes.
745+
* @timestamp_us_lsw: Lower 32 bits of the timestamp in microseconds.
746+
* @timestamp_us_msw: Upper 32 bits of the timestamp in microseconds.
747+
*
748+
* The frame counter should be read before and after the other fields to
749+
* ensure the DSP did not update them while they were being read.
750+
*/
751+
struct sh_mem_pull_push_mode_position_buffer {
752+
uint32_t frame_counter;
753+
uint32_t index;
754+
uint32_t timestamp_us_lsw;
755+
uint32_t timestamp_us_msw;
756+
} __packed;
757+
713758
/* Graph */
714759
struct audioreach_connection {
715760
/* Connections */
@@ -723,8 +768,10 @@ struct audioreach_connection {
723768
struct audioreach_graph_info {
724769
int id;
725770
uint32_t mem_map_handle;
771+
uint32_t pos_buf_mem_map_handle;
726772
uint32_t num_sub_graphs;
727773
struct list_head sg_list;
774+
bool is_push_pull_mode;
728775
/* DPCM connection from FE Graph to BE graph */
729776
uint32_t src_mod_inst_id;
730777
uint32_t src_mod_op_port_id;
@@ -855,5 +902,9 @@ int audioreach_send_u32_param(struct q6apm_graph *graph,
855902
uint32_t param_id, uint32_t param_val);
856903
int audioreach_compr_set_param(struct q6apm_graph *graph,
857904
const struct audioreach_module_config *mcfg);
905+
int audioreach_setup_push_pull(struct q6apm_graph *graph, phys_addr_t bphys,
906+
phys_addr_t pphys, uint32_t mem_map_handle,
907+
uint32_t pos_buf_mem_map_handle, uint32_t size);
908+
int audioreach_map_memory_position_buffer(struct q6apm_graph *graph, unsigned int dir);
858909

859910
#endif /* __AUDIOREACH_H__ */

0 commit comments

Comments
 (0)