From 0a79d427705d342e4fdcdefe7dedec3e0d56f019 Mon Sep 17 00:00:00 2001 From: Zhou Song Date: Tue, 2 Jun 2020 23:30:57 +0800 Subject: [PATCH] q6afe: add support for handling rx proxy ports concurrency In case of two concurrent active rx proxy ports, add separate callback data to handle proxy reading. Change-Id: I4de631b9cfead777c970103a79578964e5950eb9 Signed-off-by: Zhou Song --- dsp/q6afe.c | 32 ++++++++++++++++++++------------ include/dsp/q6afe-v2.h | 2 ++ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/dsp/q6afe.c b/dsp/q6afe.c index cbc2035acad4..51b8919ec108 100644 --- a/dsp/q6afe.c +++ b/dsp/q6afe.c @@ -126,7 +126,7 @@ struct afe_ctl { void (*rx_cb)(uint32_t opcode, uint32_t token, uint32_t *payload, void *priv); void *tx_private_data; - void *rx_private_data; + void *rx_private_data[NUM_RX_PROXY_PORTS]; uint32_t mmap_handle; void (*pri_spdif_tx_cb)(uint32_t opcode, @@ -737,12 +737,14 @@ static int32_t afe_callback(struct apr_client_data *data, void *priv) this_afe.tx_private_data); this_afe.tx_cb = NULL; } - if (this_afe.rx_cb) { - this_afe.rx_cb(data->opcode, data->token, - data->payload, - this_afe.rx_private_data); - this_afe.rx_cb = NULL; + for (i = 0; i < NUM_RX_PROXY_PORTS; i++) { + if (this_afe.rx_cb && this_afe.rx_private_data[i]) { + this_afe.rx_cb(data->opcode, data->token, + data->payload, + this_afe.rx_private_data[i]); + } } + this_afe.rx_cb = NULL; return 0; } @@ -863,7 +865,7 @@ static int32_t afe_callback(struct apr_client_data *data, void *priv) port_id = RT_PROXY_PORT_001_TX; break; case AFE_PORT_DATA_CMD_RT_PROXY_PORT_READ_V2: - port_id = RT_PROXY_PORT_001_RX; + port_id = data->src_port; break; case AFE_CMD_ADD_TOPOLOGIES: atomic_set(&this_afe.state, 0); @@ -1011,7 +1013,7 @@ static int32_t afe_callback(struct apr_client_data *data, void *priv) if (this_afe.rx_cb) { this_afe.rx_cb(data->opcode, data->token, data->payload, - this_afe.rx_private_data); + this_afe.rx_private_data[PORTID_TO_IDX(port_id)]); } break; } @@ -7095,7 +7097,7 @@ int afe_register_get_events(u16 port_id, } else if (port_id == RT_PROXY_PORT_001_RX || port_id == RT_PROXY_PORT_002_RX) { this_afe.rx_cb = cb; - this_afe.rx_private_data = private_data; + this_afe.rx_private_data[PORTID_TO_IDX(port_id)] = private_data; } rtproxy.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, @@ -7128,6 +7130,7 @@ int afe_unregister_get_events(u16 port_id) int ret = 0; struct afe_service_cmd_unregister_rt_port_driver rtproxy; int index = 0; + uint16_t i = 0; pr_debug("%s:\n", __func__); @@ -7181,8 +7184,13 @@ int afe_unregister_get_events(u16 port_id) this_afe.tx_private_data = NULL; } else if (port_id == RT_PROXY_PORT_001_RX || port_id == RT_PROXY_PORT_002_RX) { - this_afe.rx_cb = NULL; - this_afe.rx_private_data = NULL; + this_afe.rx_private_data[PORTID_TO_IDX(port_id)] = NULL; + for (i = 0; i < NUM_RX_PROXY_PORTS; i++) { + if (this_afe.rx_private_data[i] != NULL) + break; + } + if (i == NUM_RX_PROXY_PORTS) + this_afe.rx_cb = NULL; } ret = afe_apr_send_pkt(&rtproxy, &this_afe.wait[index]); @@ -7281,7 +7289,7 @@ int afe_rt_proxy_port_read(phys_addr_t buf_addr_p, APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); afecmd_rd.hdr.pkt_size = sizeof(afecmd_rd); afecmd_rd.hdr.src_port = 0; - afecmd_rd.hdr.dest_port = 0; + afecmd_rd.hdr.dest_port = port_id; afecmd_rd.hdr.token = 0; afecmd_rd.hdr.opcode = AFE_PORT_DATA_CMD_RT_PROXY_PORT_READ_V2; afecmd_rd.port_id = port_id; diff --git a/include/dsp/q6afe-v2.h b/include/dsp/q6afe-v2.h index 808113d18ce9..c55a2a0b3cc3 100644 --- a/include/dsp/q6afe-v2.h +++ b/include/dsp/q6afe-v2.h @@ -36,6 +36,8 @@ #define RT_PROXY_DAI_002_TX 0xE1 #define RT_PROXY_DAI_003_TX 0xF2 #define VIRTUAL_ID_TO_PORTID(val) ((val & 0xF) | 0x2000) +#define PORTID_TO_IDX(val) ((val & 0xF) >> 1) +#define NUM_RX_PROXY_PORTS 2 #define AFE_CLK_VERSION_V1 1 #define AFE_CLK_VERSION_V2 2