Loading dsp/q6adm.c +103 −108 Original line number Diff line number Diff line Loading @@ -96,6 +96,7 @@ struct adm_ctl { struct param_outband outband_memmap; struct source_tracking_data sourceTrackingData; struct mutex adm_apr_lock; int set_custom_topology; int ec_ref_rx; int num_ec_ref_rx_chans; Loading Loading @@ -904,6 +905,71 @@ int adm_set_custom_chmix_cfg(int port_id, int copp_idx, } EXPORT_SYMBOL(adm_set_custom_chmix_cfg); /* * adm_apr_send_pkt : returns 0 on success, negative otherwise. */ int adm_apr_send_pkt(void *data, wait_queue_head_t *wait, int port_idx, int copp_idx, int opcode) { int ret = 0; atomic_t *copp_stat = NULL; int32_t time_out = msecs_to_jiffies(TIMEOUT_MS); wait = &this_adm.copp.wait[port_idx][copp_idx]; if (!wait) return -EINVAL; mutex_lock(&this_adm.adm_apr_lock); pr_debug("%s: port idx %d copp idx %d\n", __func__, port_idx, copp_idx); copp_stat = &this_adm.copp.stat[port_idx][copp_idx]; atomic_set(copp_stat, -1); if (opcode != ADM_CMD_DEVICE_OPEN_V8 && opcode != ADM_CMD_DEVICE_OPEN_V6 && opcode != ADM_CMD_DEVICE_OPEN_V5 && opcode != ADM_CMD_DEVICE_CLOSE_V5) { if (atomic_read(&this_adm.copp.cnt[port_idx][copp_idx]) == 0) { pr_err("%s: port[0x%x] copp[0x%x] inactive\n", __func__, port_idx, copp_idx); mutex_unlock(&this_adm.adm_apr_lock); return -EINVAL; } } if (opcode == ADM_CMD_DEVICE_OPEN_V8 || opcode == ADM_CMD_DEVICE_OPEN_V6 || opcode == ADM_CMD_DEVICE_OPEN_V5) { time_out = msecs_to_jiffies(2 * TIMEOUT_MS); } ret = apr_send_pkt(this_adm.apr, data); if (ret > 0) { ret = wait_event_timeout(*wait, atomic_read(copp_stat) >= 0, time_out); if (atomic_read(copp_stat) > 0) { pr_err("%s: DSP returned error[%s]\n", __func__, adsp_err_get_err_str(atomic_read(copp_stat))); ret = adsp_err_get_lnx_err_code(atomic_read(copp_stat)); } else if (!ret) { pr_err_ratelimited("%s: request timedout\n", __func__); ret = -ETIMEDOUT; } else { ret = 0; } } else if (ret == 0) { pr_err("%s: packet not transmitted\n", __func__); /* apr_send_pkt can return 0 when nothing is transmitted */ ret = -EINVAL; } mutex_unlock(&this_adm.adm_apr_lock); return ret; } /* * With pre-packed data, only the opcode differes from V5 and V6. * Use q6common_pack_pp_params to pack the data correctly. Loading @@ -915,7 +981,6 @@ int adm_set_pp_params(int port_id, int copp_idx, struct adm_cmd_set_pp_params *adm_set_params = NULL; int size = 0; int port_idx = 0; atomic_t *copp_stat = NULL; int ret = 0; port_id = afe_convert_virtual_to_portid(port_id); Loading Loading @@ -973,32 +1038,9 @@ int adm_set_pp_params(int port_id, int copp_idx, ret = -EINVAL; goto done; } copp_stat = &this_adm.copp.stat[port_idx][copp_idx]; atomic_set(copp_stat, -1); ret = apr_send_pkt(this_adm.apr, (uint32_t *) adm_set_params); if (ret < 0) { pr_err("%s: Set params APR send failed port = 0x%x ret %d\n", __func__, port_id, ret); goto done; } ret = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx], atomic_read(copp_stat) >= 0, msecs_to_jiffies(TIMEOUT_MS)); if (!ret) { pr_err("%s: Set params timed out port = 0x%x\n", __func__, port_id); ret = -ETIMEDOUT; goto done; } if (atomic_read(copp_stat) > 0) { pr_err("%s: DSP returned error[%s]\n", __func__, adsp_err_get_err_str(atomic_read(copp_stat))); ret = adsp_err_get_lnx_err_code(atomic_read(copp_stat)); goto done; } ret = 0; ret = adm_apr_send_pkt((uint32_t *) adm_set_params, &this_adm.copp.wait[port_idx][copp_idx], port_idx, copp_idx, adm_set_params->apr_hdr.opcode); done: kfree(adm_set_params); return ret; Loading Loading @@ -1051,7 +1093,6 @@ int adm_get_pp_params(int port_id, int copp_idx, uint32_t client_id, int returned_param_size_in_bytes = 0; int port_idx = 0; int idx = 0; atomic_t *copp_stat = NULL; int ret = 0; if (param_hdr == NULL) { Loading Loading @@ -1099,33 +1140,9 @@ int adm_get_pp_params(int port_id, int copp_idx, uint32_t client_id, else adm_get_params.apr_hdr.opcode = ADM_CMD_GET_PP_PARAMS_V5; copp_stat = &this_adm.copp.stat[port_idx][copp_idx]; atomic_set(copp_stat, -1); ret = apr_send_pkt(this_adm.apr, (uint32_t *) &adm_get_params); if (ret < 0) { pr_err("%s: Get params APR send failed port = 0x%x ret %d\n", __func__, port_id, ret); ret = -EINVAL; goto done; } ret = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx], atomic_read(copp_stat) >= 0, msecs_to_jiffies(TIMEOUT_MS)); if (!ret) { pr_err("%s: Get params timed out port = 0x%x\n", __func__, port_id); ret = -ETIMEDOUT; goto done; } if (atomic_read(copp_stat) > 0) { pr_err("%s: DSP returned error[%s]\n", __func__, adsp_err_get_err_str(atomic_read(copp_stat))); ret = adsp_err_get_lnx_err_code(atomic_read(copp_stat)); goto done; } ret = 0; ret = adm_apr_send_pkt((uint32_t *) &adm_get_params, &this_adm.copp.wait[port_idx][copp_idx], port_idx, copp_idx, adm_get_params.apr_hdr.opcode); /* Copy data to caller if sent in band */ if (!returned_param_data) { Loading Loading @@ -1153,7 +1170,6 @@ int adm_get_pp_params(int port_id, int copp_idx, uint32_t client_id, memcpy(returned_param_data, &adm_get_parameters[idx + 1], returned_param_size_in_bytes); done: return ret; } EXPORT_SYMBOL(adm_get_pp_params); Loading Loading @@ -1636,7 +1652,14 @@ static int32_t adm_callback(struct apr_client_data *data, void *priv) this_adm.sourceTrackingData. apr_cmd_status = payload[1]; else if (rtac_make_adm_callback(payload, data->payload_size)) data->payload_size)) { pr_debug("%s: rtac cmd response\n", __func__); } atomic_set(&this_adm.copp.stat[port_idx] [copp_idx], payload[1]); wake_up( &this_adm.copp.wait[port_idx][copp_idx]); break; /* * if soft volume is called and already Loading @@ -1646,8 +1669,8 @@ static int32_t adm_callback(struct apr_client_data *data, void *priv) case ADM_CMD_DEVICE_CLOSE_V5: case ADM_CMD_DEVICE_OPEN_V6: case ADM_CMD_DEVICE_OPEN_V8: pr_debug("%s: Basic callback received, wake up.\n", __func__); pr_debug("%s: Basic callback received for 0x%x, wake up.\n", __func__, payload[0]); atomic_set(&this_adm.copp.stat[port_idx] [copp_idx], payload[1]); wake_up( Loading Loading @@ -1780,8 +1803,13 @@ static int32_t adm_callback(struct apr_client_data *data, void *priv) this_adm.sourceTrackingData.apr_cmd_status = payload[0]; else if (rtac_make_adm_callback(payload, data->payload_size)) data->payload_size)) { pr_debug("%s: rtac cmd response\n", __func__); atomic_set(&this_adm.copp.stat[port_idx][copp_idx], payload[0]); wake_up(&this_adm.copp.wait[port_idx][copp_idx]); break; } idx = ADM_GET_PARAMETER_LENGTH * copp_idx; if (payload[0] == 0 && data->payload_size > 0) { Loading Loading @@ -3403,8 +3431,9 @@ int adm_open(int port_id, int path, int rate, int channel_mode, int topology, ep2_payload_size); } ret = apr_send_pkt(this_adm.apr, (uint32_t *)adm_params); ret = adm_apr_send_pkt((uint32_t *) adm_params, &this_adm.copp.wait[port_idx][copp_idx], port_idx, copp_idx, open_v8.hdr.opcode); if (ret < 0) { pr_err("%s: port_id: 0x%x for[0x%x] failed %d for open_v8\n", __func__, tmp_port, port_id, ret); Loading Loading @@ -3490,11 +3519,13 @@ int adm_open(int port_id, int path, int rate, int channel_mode, int topology, if (ret) return ret; ret = apr_send_pkt(this_adm.apr, (uint32_t *)&open_v6); ret = adm_apr_send_pkt((uint32_t *) &open_v6, &this_adm.copp.wait[port_idx][copp_idx], port_idx, copp_idx, open_v6.hdr.opcode); } else { ret = apr_send_pkt(this_adm.apr, (uint32_t *)&open); ret = adm_apr_send_pkt((uint32_t *) &open, &this_adm.copp.wait[port_idx][copp_idx], port_idx, copp_idx, open.hdr.opcode); } if (ret < 0) { pr_err("%s: port_id: 0x%x for[0x%x] failed %d\n", Loading @@ -3502,26 +3533,6 @@ int adm_open(int port_id, int path, int rate, int channel_mode, int topology, return -EINVAL; } } /* Wait for the callback with copp id */ ret = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx], atomic_read(&this_adm.copp.stat [port_idx][copp_idx]) >= 0, msecs_to_jiffies(2 * TIMEOUT_MS)); if (!ret) { pr_err("%s: ADM open timedout for port_id: 0x%x for [0x%x]\n", __func__, tmp_port, port_id); return -EINVAL; } else if (atomic_read(&this_adm.copp.stat [port_idx][copp_idx]) > 0) { pr_err("%s: DSP returned error[%s]\n", __func__, adsp_err_get_err_str( atomic_read(&this_adm.copp.stat [port_idx][copp_idx]))); return adsp_err_get_lnx_err_code( atomic_read(&this_adm.copp.stat [port_idx][copp_idx])); } } atomic_inc(&this_adm.copp.cnt[port_idx][copp_idx]); Loading Loading @@ -4036,8 +4047,9 @@ int adm_close(int port_id, int perf_mode, int copp_idx) clear_bit(ADM_STATUS_CALIBRATION_REQUIRED, (void *)&this_adm.copp.adm_status[port_idx][copp_idx]); ret = apr_send_pkt(this_adm.apr, (uint32_t *)&close); ret = adm_apr_send_pkt((uint32_t *) &close, &this_adm.copp.wait[port_idx][copp_idx], port_idx, copp_idx, close.opcode); if (ret < 0) { pr_err("%s: ADM close failed %d\n", __func__, ret); if (this_adm.tx_port_id == port_id) { Loading Loading @@ -4104,25 +4116,6 @@ int adm_close(int port_id, int perf_mode, int copp_idx) } return -EINVAL; } ret = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx], atomic_read(&this_adm.copp.stat [port_idx][copp_idx]) >= 0, msecs_to_jiffies(TIMEOUT_MS)); if (!ret) { pr_err("%s: ADM cmd Route timedout for port 0x%x\n", __func__, port_id); return -EINVAL; } else if (atomic_read(&this_adm.copp.stat [port_idx][copp_idx]) > 0) { pr_err("%s: DSP returned error[%s]\n", __func__, adsp_err_get_err_str( atomic_read(&this_adm.copp.stat [port_idx][copp_idx]))); return adsp_err_get_lnx_err_code( atomic_read(&this_adm.copp.stat [port_idx][copp_idx])); } } if (perf_mode != ULTRA_LOW_LATENCY_PCM_MODE) { Loading Loading @@ -5755,6 +5748,7 @@ int __init adm_init(void) this_adm.fnn_app_type = -1; init_waitqueue_head(&this_adm.matrix_map_wait); init_waitqueue_head(&this_adm.adm_wait); mutex_init(&this_adm.adm_apr_lock); for (i = 0; i < AFE_MAX_PORTS; i++) { for (j = 0; j < MAX_COPPS_PER_PORT; j++) { Loading @@ -5779,6 +5773,7 @@ int __init adm_init(void) void adm_exit(void) { mutex_destroy(&this_adm.adm_apr_lock); if (this_adm.apr) adm_reset_data(); adm_delete_cal_data(); Loading dsp/rtac.c +5 −27 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. */ #include <linux/fs.h> Loading Loading @@ -728,7 +728,6 @@ bool rtac_make_adm_callback(uint32_t *payload, u32 payload_size) atomic_set(&rtac_common.apr_err_code, payload[1]); atomic_set(&rtac_adm_apr_data.cmd_state, 0); wake_up(&rtac_adm_apr_data.cmd_wait); return true; } Loading Loading @@ -880,33 +879,12 @@ int send_adm_apr(void *buf, u32 opcode) pr_debug("%s: Sending RTAC command ioctl 0x%x, paddr 0x%pK\n", __func__, opcode, &rtac_cal[ADM_RTAC_CAL].cal_data.paddr); mutex_unlock(&rtac_adm_apr_mutex); result = apr_send_pkt(rtac_adm_apr_data.apr_handle, (uint32_t *)rtac_adm_buffer); if (result < 0) { pr_err("%s: Set params failed copp = %d\n", __func__, copp_id); goto err; } /* Wait for the callback */ result = wait_event_timeout(rtac_adm_apr_data.cmd_wait, (atomic_read(&rtac_adm_apr_data.cmd_state) == 0), msecs_to_jiffies(TIMEOUT_MS)); if (!result) { pr_err("%s: Set params timed out copp = %d\n", __func__, copp_id); goto err; } if (atomic_read(&rtac_common.apr_err_code)) { pr_err("%s: DSP returned error code = [%s], opcode = 0x%x\n", __func__, adsp_err_get_err_str(atomic_read( &rtac_common.apr_err_code)), opcode); result = adsp_err_get_lnx_err_code( atomic_read( &rtac_common.apr_err_code)); goto err; } result = adm_apr_send_pkt((uint32_t *)rtac_adm_buffer, NULL, port_idx, copp_idx, adm_params.opcode); mutex_lock(&rtac_adm_apr_mutex); if (opcode == ADM_CMD_GET_PP_PARAMS_V5) { bytes_returned = ((u32 *)rtac_cal[ADM_RTAC_CAL].cal_data. kvaddr)[2] + 3 * sizeof(u32); Loading include/dsp/q6adm-v2.h +2 −0 Original line number Diff line number Diff line Loading @@ -229,4 +229,6 @@ void msm_dts_srs_acquire_lock(void); void msm_dts_srs_release_lock(void); void adm_set_native_mode(int mode); int adm_set_ffecns_freeze_event(bool ffecns_freeze_event); int adm_apr_send_pkt(void *data, wait_queue_head_t *wait, int port_idx, int copp_idx, int opcode); #endif /* __Q6_ADM_V2_H__ */ Loading
dsp/q6adm.c +103 −108 Original line number Diff line number Diff line Loading @@ -96,6 +96,7 @@ struct adm_ctl { struct param_outband outband_memmap; struct source_tracking_data sourceTrackingData; struct mutex adm_apr_lock; int set_custom_topology; int ec_ref_rx; int num_ec_ref_rx_chans; Loading Loading @@ -904,6 +905,71 @@ int adm_set_custom_chmix_cfg(int port_id, int copp_idx, } EXPORT_SYMBOL(adm_set_custom_chmix_cfg); /* * adm_apr_send_pkt : returns 0 on success, negative otherwise. */ int adm_apr_send_pkt(void *data, wait_queue_head_t *wait, int port_idx, int copp_idx, int opcode) { int ret = 0; atomic_t *copp_stat = NULL; int32_t time_out = msecs_to_jiffies(TIMEOUT_MS); wait = &this_adm.copp.wait[port_idx][copp_idx]; if (!wait) return -EINVAL; mutex_lock(&this_adm.adm_apr_lock); pr_debug("%s: port idx %d copp idx %d\n", __func__, port_idx, copp_idx); copp_stat = &this_adm.copp.stat[port_idx][copp_idx]; atomic_set(copp_stat, -1); if (opcode != ADM_CMD_DEVICE_OPEN_V8 && opcode != ADM_CMD_DEVICE_OPEN_V6 && opcode != ADM_CMD_DEVICE_OPEN_V5 && opcode != ADM_CMD_DEVICE_CLOSE_V5) { if (atomic_read(&this_adm.copp.cnt[port_idx][copp_idx]) == 0) { pr_err("%s: port[0x%x] copp[0x%x] inactive\n", __func__, port_idx, copp_idx); mutex_unlock(&this_adm.adm_apr_lock); return -EINVAL; } } if (opcode == ADM_CMD_DEVICE_OPEN_V8 || opcode == ADM_CMD_DEVICE_OPEN_V6 || opcode == ADM_CMD_DEVICE_OPEN_V5) { time_out = msecs_to_jiffies(2 * TIMEOUT_MS); } ret = apr_send_pkt(this_adm.apr, data); if (ret > 0) { ret = wait_event_timeout(*wait, atomic_read(copp_stat) >= 0, time_out); if (atomic_read(copp_stat) > 0) { pr_err("%s: DSP returned error[%s]\n", __func__, adsp_err_get_err_str(atomic_read(copp_stat))); ret = adsp_err_get_lnx_err_code(atomic_read(copp_stat)); } else if (!ret) { pr_err_ratelimited("%s: request timedout\n", __func__); ret = -ETIMEDOUT; } else { ret = 0; } } else if (ret == 0) { pr_err("%s: packet not transmitted\n", __func__); /* apr_send_pkt can return 0 when nothing is transmitted */ ret = -EINVAL; } mutex_unlock(&this_adm.adm_apr_lock); return ret; } /* * With pre-packed data, only the opcode differes from V5 and V6. * Use q6common_pack_pp_params to pack the data correctly. Loading @@ -915,7 +981,6 @@ int adm_set_pp_params(int port_id, int copp_idx, struct adm_cmd_set_pp_params *adm_set_params = NULL; int size = 0; int port_idx = 0; atomic_t *copp_stat = NULL; int ret = 0; port_id = afe_convert_virtual_to_portid(port_id); Loading Loading @@ -973,32 +1038,9 @@ int adm_set_pp_params(int port_id, int copp_idx, ret = -EINVAL; goto done; } copp_stat = &this_adm.copp.stat[port_idx][copp_idx]; atomic_set(copp_stat, -1); ret = apr_send_pkt(this_adm.apr, (uint32_t *) adm_set_params); if (ret < 0) { pr_err("%s: Set params APR send failed port = 0x%x ret %d\n", __func__, port_id, ret); goto done; } ret = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx], atomic_read(copp_stat) >= 0, msecs_to_jiffies(TIMEOUT_MS)); if (!ret) { pr_err("%s: Set params timed out port = 0x%x\n", __func__, port_id); ret = -ETIMEDOUT; goto done; } if (atomic_read(copp_stat) > 0) { pr_err("%s: DSP returned error[%s]\n", __func__, adsp_err_get_err_str(atomic_read(copp_stat))); ret = adsp_err_get_lnx_err_code(atomic_read(copp_stat)); goto done; } ret = 0; ret = adm_apr_send_pkt((uint32_t *) adm_set_params, &this_adm.copp.wait[port_idx][copp_idx], port_idx, copp_idx, adm_set_params->apr_hdr.opcode); done: kfree(adm_set_params); return ret; Loading Loading @@ -1051,7 +1093,6 @@ int adm_get_pp_params(int port_id, int copp_idx, uint32_t client_id, int returned_param_size_in_bytes = 0; int port_idx = 0; int idx = 0; atomic_t *copp_stat = NULL; int ret = 0; if (param_hdr == NULL) { Loading Loading @@ -1099,33 +1140,9 @@ int adm_get_pp_params(int port_id, int copp_idx, uint32_t client_id, else adm_get_params.apr_hdr.opcode = ADM_CMD_GET_PP_PARAMS_V5; copp_stat = &this_adm.copp.stat[port_idx][copp_idx]; atomic_set(copp_stat, -1); ret = apr_send_pkt(this_adm.apr, (uint32_t *) &adm_get_params); if (ret < 0) { pr_err("%s: Get params APR send failed port = 0x%x ret %d\n", __func__, port_id, ret); ret = -EINVAL; goto done; } ret = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx], atomic_read(copp_stat) >= 0, msecs_to_jiffies(TIMEOUT_MS)); if (!ret) { pr_err("%s: Get params timed out port = 0x%x\n", __func__, port_id); ret = -ETIMEDOUT; goto done; } if (atomic_read(copp_stat) > 0) { pr_err("%s: DSP returned error[%s]\n", __func__, adsp_err_get_err_str(atomic_read(copp_stat))); ret = adsp_err_get_lnx_err_code(atomic_read(copp_stat)); goto done; } ret = 0; ret = adm_apr_send_pkt((uint32_t *) &adm_get_params, &this_adm.copp.wait[port_idx][copp_idx], port_idx, copp_idx, adm_get_params.apr_hdr.opcode); /* Copy data to caller if sent in band */ if (!returned_param_data) { Loading Loading @@ -1153,7 +1170,6 @@ int adm_get_pp_params(int port_id, int copp_idx, uint32_t client_id, memcpy(returned_param_data, &adm_get_parameters[idx + 1], returned_param_size_in_bytes); done: return ret; } EXPORT_SYMBOL(adm_get_pp_params); Loading Loading @@ -1636,7 +1652,14 @@ static int32_t adm_callback(struct apr_client_data *data, void *priv) this_adm.sourceTrackingData. apr_cmd_status = payload[1]; else if (rtac_make_adm_callback(payload, data->payload_size)) data->payload_size)) { pr_debug("%s: rtac cmd response\n", __func__); } atomic_set(&this_adm.copp.stat[port_idx] [copp_idx], payload[1]); wake_up( &this_adm.copp.wait[port_idx][copp_idx]); break; /* * if soft volume is called and already Loading @@ -1646,8 +1669,8 @@ static int32_t adm_callback(struct apr_client_data *data, void *priv) case ADM_CMD_DEVICE_CLOSE_V5: case ADM_CMD_DEVICE_OPEN_V6: case ADM_CMD_DEVICE_OPEN_V8: pr_debug("%s: Basic callback received, wake up.\n", __func__); pr_debug("%s: Basic callback received for 0x%x, wake up.\n", __func__, payload[0]); atomic_set(&this_adm.copp.stat[port_idx] [copp_idx], payload[1]); wake_up( Loading Loading @@ -1780,8 +1803,13 @@ static int32_t adm_callback(struct apr_client_data *data, void *priv) this_adm.sourceTrackingData.apr_cmd_status = payload[0]; else if (rtac_make_adm_callback(payload, data->payload_size)) data->payload_size)) { pr_debug("%s: rtac cmd response\n", __func__); atomic_set(&this_adm.copp.stat[port_idx][copp_idx], payload[0]); wake_up(&this_adm.copp.wait[port_idx][copp_idx]); break; } idx = ADM_GET_PARAMETER_LENGTH * copp_idx; if (payload[0] == 0 && data->payload_size > 0) { Loading Loading @@ -3403,8 +3431,9 @@ int adm_open(int port_id, int path, int rate, int channel_mode, int topology, ep2_payload_size); } ret = apr_send_pkt(this_adm.apr, (uint32_t *)adm_params); ret = adm_apr_send_pkt((uint32_t *) adm_params, &this_adm.copp.wait[port_idx][copp_idx], port_idx, copp_idx, open_v8.hdr.opcode); if (ret < 0) { pr_err("%s: port_id: 0x%x for[0x%x] failed %d for open_v8\n", __func__, tmp_port, port_id, ret); Loading Loading @@ -3490,11 +3519,13 @@ int adm_open(int port_id, int path, int rate, int channel_mode, int topology, if (ret) return ret; ret = apr_send_pkt(this_adm.apr, (uint32_t *)&open_v6); ret = adm_apr_send_pkt((uint32_t *) &open_v6, &this_adm.copp.wait[port_idx][copp_idx], port_idx, copp_idx, open_v6.hdr.opcode); } else { ret = apr_send_pkt(this_adm.apr, (uint32_t *)&open); ret = adm_apr_send_pkt((uint32_t *) &open, &this_adm.copp.wait[port_idx][copp_idx], port_idx, copp_idx, open.hdr.opcode); } if (ret < 0) { pr_err("%s: port_id: 0x%x for[0x%x] failed %d\n", Loading @@ -3502,26 +3533,6 @@ int adm_open(int port_id, int path, int rate, int channel_mode, int topology, return -EINVAL; } } /* Wait for the callback with copp id */ ret = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx], atomic_read(&this_adm.copp.stat [port_idx][copp_idx]) >= 0, msecs_to_jiffies(2 * TIMEOUT_MS)); if (!ret) { pr_err("%s: ADM open timedout for port_id: 0x%x for [0x%x]\n", __func__, tmp_port, port_id); return -EINVAL; } else if (atomic_read(&this_adm.copp.stat [port_idx][copp_idx]) > 0) { pr_err("%s: DSP returned error[%s]\n", __func__, adsp_err_get_err_str( atomic_read(&this_adm.copp.stat [port_idx][copp_idx]))); return adsp_err_get_lnx_err_code( atomic_read(&this_adm.copp.stat [port_idx][copp_idx])); } } atomic_inc(&this_adm.copp.cnt[port_idx][copp_idx]); Loading Loading @@ -4036,8 +4047,9 @@ int adm_close(int port_id, int perf_mode, int copp_idx) clear_bit(ADM_STATUS_CALIBRATION_REQUIRED, (void *)&this_adm.copp.adm_status[port_idx][copp_idx]); ret = apr_send_pkt(this_adm.apr, (uint32_t *)&close); ret = adm_apr_send_pkt((uint32_t *) &close, &this_adm.copp.wait[port_idx][copp_idx], port_idx, copp_idx, close.opcode); if (ret < 0) { pr_err("%s: ADM close failed %d\n", __func__, ret); if (this_adm.tx_port_id == port_id) { Loading Loading @@ -4104,25 +4116,6 @@ int adm_close(int port_id, int perf_mode, int copp_idx) } return -EINVAL; } ret = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx], atomic_read(&this_adm.copp.stat [port_idx][copp_idx]) >= 0, msecs_to_jiffies(TIMEOUT_MS)); if (!ret) { pr_err("%s: ADM cmd Route timedout for port 0x%x\n", __func__, port_id); return -EINVAL; } else if (atomic_read(&this_adm.copp.stat [port_idx][copp_idx]) > 0) { pr_err("%s: DSP returned error[%s]\n", __func__, adsp_err_get_err_str( atomic_read(&this_adm.copp.stat [port_idx][copp_idx]))); return adsp_err_get_lnx_err_code( atomic_read(&this_adm.copp.stat [port_idx][copp_idx])); } } if (perf_mode != ULTRA_LOW_LATENCY_PCM_MODE) { Loading Loading @@ -5755,6 +5748,7 @@ int __init adm_init(void) this_adm.fnn_app_type = -1; init_waitqueue_head(&this_adm.matrix_map_wait); init_waitqueue_head(&this_adm.adm_wait); mutex_init(&this_adm.adm_apr_lock); for (i = 0; i < AFE_MAX_PORTS; i++) { for (j = 0; j < MAX_COPPS_PER_PORT; j++) { Loading @@ -5779,6 +5773,7 @@ int __init adm_init(void) void adm_exit(void) { mutex_destroy(&this_adm.adm_apr_lock); if (this_adm.apr) adm_reset_data(); adm_delete_cal_data(); Loading
dsp/rtac.c +5 −27 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. */ #include <linux/fs.h> Loading Loading @@ -728,7 +728,6 @@ bool rtac_make_adm_callback(uint32_t *payload, u32 payload_size) atomic_set(&rtac_common.apr_err_code, payload[1]); atomic_set(&rtac_adm_apr_data.cmd_state, 0); wake_up(&rtac_adm_apr_data.cmd_wait); return true; } Loading Loading @@ -880,33 +879,12 @@ int send_adm_apr(void *buf, u32 opcode) pr_debug("%s: Sending RTAC command ioctl 0x%x, paddr 0x%pK\n", __func__, opcode, &rtac_cal[ADM_RTAC_CAL].cal_data.paddr); mutex_unlock(&rtac_adm_apr_mutex); result = apr_send_pkt(rtac_adm_apr_data.apr_handle, (uint32_t *)rtac_adm_buffer); if (result < 0) { pr_err("%s: Set params failed copp = %d\n", __func__, copp_id); goto err; } /* Wait for the callback */ result = wait_event_timeout(rtac_adm_apr_data.cmd_wait, (atomic_read(&rtac_adm_apr_data.cmd_state) == 0), msecs_to_jiffies(TIMEOUT_MS)); if (!result) { pr_err("%s: Set params timed out copp = %d\n", __func__, copp_id); goto err; } if (atomic_read(&rtac_common.apr_err_code)) { pr_err("%s: DSP returned error code = [%s], opcode = 0x%x\n", __func__, adsp_err_get_err_str(atomic_read( &rtac_common.apr_err_code)), opcode); result = adsp_err_get_lnx_err_code( atomic_read( &rtac_common.apr_err_code)); goto err; } result = adm_apr_send_pkt((uint32_t *)rtac_adm_buffer, NULL, port_idx, copp_idx, adm_params.opcode); mutex_lock(&rtac_adm_apr_mutex); if (opcode == ADM_CMD_GET_PP_PARAMS_V5) { bytes_returned = ((u32 *)rtac_cal[ADM_RTAC_CAL].cal_data. kvaddr)[2] + 3 * sizeof(u32); Loading
include/dsp/q6adm-v2.h +2 −0 Original line number Diff line number Diff line Loading @@ -229,4 +229,6 @@ void msm_dts_srs_acquire_lock(void); void msm_dts_srs_release_lock(void); void adm_set_native_mode(int mode); int adm_set_ffecns_freeze_event(bool ffecns_freeze_event); int adm_apr_send_pkt(void *data, wait_queue_head_t *wait, int port_idx, int copp_idx, int opcode); #endif /* __Q6_ADM_V2_H__ */