Prechádzať zdrojové kódy

Merge "q6afe: add support for handling rx proxy ports concurrency"

qctecmdr 4 rokov pred
rodič
commit
e0a48cd1e5
2 zmenil súbory, kde vykonal 22 pridanie a 12 odobranie
  1. 20 12
      dsp/q6afe.c
  2. 2 0
      include/dsp/q6afe-v2.h

+ 20 - 12
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,
@@ -738,12 +738,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;
 	}
@@ -864,7 +866,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);
@@ -1012,7 +1014,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;
 		}
@@ -7229,7 +7231,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,
@@ -7262,6 +7264,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__);
 
@@ -7315,8 +7318,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]);
@@ -7415,7 +7423,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;

+ 2 - 0
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