Loading include/uapi/linux/msm_audio_calibration.h +4 −0 Original line number Diff line number Diff line Loading @@ -99,6 +99,8 @@ enum { AFE_FB_SPKR_PROT_TH_VI_CAL_TYPE, AFE_FB_SPKR_PROT_EX_VI_CAL_TYPE, AFE_SIDETONE_IIR_CAL_TYPE, AFE_LSM_TOPOLOGY_CAL_TYPE, AFE_LSM_TX_CAL_TYPE, MAX_CAL_TYPES, }; Loading @@ -106,6 +108,8 @@ enum { #define AFE_FB_SPKR_PROT_EX_VI_CAL_TYPE AFE_FB_SPKR_PROT_EX_VI_CAL_TYPE #define AFE_SIDETONE_IIR_CAL_TYPE AFE_SIDETONE_IIR_CAL_TYPE #define AFE_LSM_TOPOLOGY_CAL_TYPE AFE_LSM_TOPOLOGY_CAL_TYPE #define AFE_LSM_TX_CAL_TYPE AFE_LSM_TX_CAL_TYPE enum { VERSION_0_0, Loading sound/soc/msm/qdsp6v2/audio_cal_utils.c +4 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,7 @@ size_t get_cal_info_size(int32_t cal_type) size = sizeof(struct audio_cal_info_audstrm); break; case AFE_TOPOLOGY_CAL_TYPE: case AFE_LSM_TOPOLOGY_CAL_TYPE: size = sizeof(struct audio_cal_info_afe_top); break; case AFE_CUST_TOPOLOGY_CAL_TYPE: Loading @@ -86,6 +87,7 @@ size_t get_cal_info_size(int32_t cal_type) size = sizeof(struct audio_cal_info_afe); break; case AFE_COMMON_TX_CAL_TYPE: case AFE_LSM_TX_CAL_TYPE: size = sizeof(struct audio_cal_info_afe); break; case AFE_FB_SPKR_PROT_CAL_TYPE: Loading Loading @@ -223,6 +225,7 @@ size_t get_user_cal_type_size(int32_t cal_type) size = sizeof(struct audio_cal_type_audstrm); break; case AFE_TOPOLOGY_CAL_TYPE: case AFE_LSM_TOPOLOGY_CAL_TYPE: size = sizeof(struct audio_cal_type_afe_top); break; case AFE_CUST_TOPOLOGY_CAL_TYPE: Loading @@ -232,6 +235,7 @@ size_t get_user_cal_type_size(int32_t cal_type) size = sizeof(struct audio_cal_type_afe); break; case AFE_COMMON_TX_CAL_TYPE: case AFE_LSM_TX_CAL_TYPE: size = sizeof(struct audio_cal_type_afe); break; case AFE_FB_SPKR_PROT_CAL_TYPE: Loading sound/soc/msm/qdsp6v2/q6afe.c +45 −10 Original line number Diff line number Diff line Loading @@ -32,12 +32,14 @@ enum { AFE_COMMON_RX_CAL = 0, AFE_COMMON_TX_CAL, AFE_LSM_TX_CAL, AFE_AANC_CAL, AFE_FB_SPKR_PROT_CAL, AFE_HW_DELAY_CAL, AFE_SIDETONE_CAL, AFE_SIDETONE_IIR_CAL, AFE_TOPOLOGY_CAL, AFE_LSM_TOPOLOGY_CAL, AFE_CUST_TOPOLOGY_CAL, AFE_FB_SPKR_PROT_TH_VI_CAL, AFE_FB_SPKR_PROT_EX_VI_CAL, Loading Loading @@ -1324,14 +1326,15 @@ err_exit: return NULL; } static int afe_get_cal_topology_id(u16 port_id, u32 *topology_id) static int afe_get_cal_topology_id(u16 port_id, u32 *topology_id, int cal_type_index) { int ret = 0; struct cal_block_data *cal_block = NULL; struct audio_cal_info_afe_top *afe_top_info = NULL; if (this_afe.cal_data[AFE_TOPOLOGY_CAL] == NULL) { if (this_afe.cal_data[cal_type_index] == NULL) { pr_err("%s: [AFE_TOPOLOGY_CAL] not initialized\n", __func__); return -EINVAL; } Loading @@ -1341,9 +1344,9 @@ static int afe_get_cal_topology_id(u16 port_id, u32 *topology_id) } *topology_id = 0; mutex_lock(&this_afe.cal_data[AFE_TOPOLOGY_CAL]->lock); mutex_lock(&this_afe.cal_data[cal_type_index]->lock); cal_block = afe_find_cal_topo_id_by_port( this_afe.cal_data[AFE_TOPOLOGY_CAL], port_id); this_afe.cal_data[cal_type_index], port_id); if (cal_block == NULL) { pr_err("%s: [AFE_TOPOLOGY_CAL] not initialized for this port %d\n", __func__, port_id); Loading @@ -1365,7 +1368,7 @@ static int afe_get_cal_topology_id(u16 port_id, u32 *topology_id) __func__, port_id, afe_top_info->acdb_id, afe_top_info->topology, ret); unlock: mutex_unlock(&this_afe.cal_data[AFE_TOPOLOGY_CAL]->lock); mutex_unlock(&this_afe.cal_data[cal_type_index]->lock); return ret; } Loading @@ -1383,7 +1386,12 @@ static int afe_send_port_topology_id(u16 port_id) return -EINVAL; } ret = afe_get_cal_topology_id(port_id, &topology_id); ret = afe_get_cal_topology_id(port_id, &topology_id, AFE_TOPOLOGY_CAL); if (ret < 0) { pr_debug("%s: Check for LSM topology\n", __func__); ret = afe_get_cal_topology_id(port_id, &topology_id, AFE_LSM_TOPOLOGY_CAL); } if (ret || !topology_id) { pr_debug("%s: AFE port[%d] get_cal_topology[%d] invalid!\n", __func__, port_id, topology_id); Loading Loading @@ -1500,7 +1508,7 @@ exit: return cal_block; } static void send_afe_cal_type(int cal_index, int port_id) static int send_afe_cal_type(int cal_index, int port_id) { struct cal_block_data *cal_block = NULL; int ret; Loading @@ -1511,19 +1519,22 @@ static void send_afe_cal_type(int cal_index, int port_id) if (this_afe.cal_data[cal_index] == NULL) { pr_warn("%s: cal_index %d not allocated!\n", __func__, cal_index); ret = -EINVAL; goto done; } if (afe_port_index < 0) { pr_err("%s: Error getting AFE port index %d\n", __func__, afe_port_index); ret = -EINVAL; goto done; } mutex_lock(&this_afe.cal_data[cal_index]->lock); if (((cal_index == AFE_COMMON_RX_CAL) || (cal_index == AFE_COMMON_TX_CAL)) && (cal_index == AFE_COMMON_TX_CAL) || (cal_index == AFE_LSM_TX_CAL)) && (this_afe.dev_acdb_id[afe_port_index] > 0)) cal_block = afe_find_cal(cal_index, port_id); else Loading @@ -1532,6 +1543,7 @@ static void send_afe_cal_type(int cal_index, int port_id) if (cal_block == NULL) { pr_err("%s cal_block not found!!\n", __func__); ret = -EINVAL; goto unlock; } Loading @@ -1541,6 +1553,7 @@ static void send_afe_cal_type(int cal_index, int port_id) if (ret) { pr_err("%s: Remap_cal_data failed for cal %d!\n", __func__, cal_index); ret = -EINVAL; goto unlock; } ret = afe_send_cal_block(port_id, cal_block); Loading @@ -1550,16 +1563,20 @@ static void send_afe_cal_type(int cal_index, int port_id) unlock: mutex_unlock(&this_afe.cal_data[cal_index]->lock); done: return; return ret; } void afe_send_cal(u16 port_id) { int ret; pr_debug("%s: port_id=0x%x\n", __func__, port_id); if (afe_get_port_type(port_id) == MSM_AFE_PORT_TYPE_TX) { afe_send_cal_spkr_prot_tx(port_id); send_afe_cal_type(AFE_COMMON_TX_CAL, port_id); ret = send_afe_cal_type(AFE_COMMON_TX_CAL, port_id); if (ret < 0) send_afe_cal_type(AFE_LSM_TX_CAL, port_id); } else if (afe_get_port_type(port_id) == MSM_AFE_PORT_TYPE_RX) { afe_send_cal_spkr_prot_rx(port_id); send_afe_cal_type(AFE_COMMON_RX_CAL, port_id); Loading Loading @@ -6430,6 +6447,9 @@ static int get_cal_type_index(int32_t cal_type) case AFE_COMMON_TX_CAL_TYPE: ret = AFE_COMMON_TX_CAL; break; case AFE_LSM_TX_CAL_TYPE: ret = AFE_LSM_TX_CAL; break; case AFE_AANC_CAL_TYPE: ret = AFE_AANC_CAL; break; Loading @@ -6448,6 +6468,9 @@ static int get_cal_type_index(int32_t cal_type) case AFE_TOPOLOGY_CAL_TYPE: ret = AFE_TOPOLOGY_CAL; break; case AFE_LSM_TOPOLOGY_CAL_TYPE: ret = AFE_LSM_TOPOLOGY_CAL; break; case AFE_CUST_TOPOLOGY_CAL_TYPE: ret = AFE_CUST_TOPOLOGY_CAL; break; Loading Loading @@ -6945,6 +6968,12 @@ static int afe_init_cal_data(void) {afe_map_cal_data, afe_unmap_cal_data, cal_utils_match_buf_num} }, {{AFE_LSM_TX_CAL_TYPE, {afe_alloc_cal, afe_dealloc_cal, NULL, afe_set_cal, NULL, NULL} }, {afe_map_cal_data, afe_unmap_cal_data, cal_utils_match_buf_num} }, {{AFE_AANC_CAL_TYPE, {afe_alloc_cal, afe_dealloc_cal, NULL, afe_set_cal, NULL, NULL} }, Loading Loading @@ -6977,6 +7006,12 @@ static int afe_init_cal_data(void) {NULL, NULL, cal_utils_match_buf_num} }, {{AFE_LSM_TOPOLOGY_CAL_TYPE, {NULL, NULL, NULL, afe_set_cal, NULL, NULL} }, {NULL, NULL, cal_utils_match_buf_num} }, {{AFE_CUST_TOPOLOGY_CAL_TYPE, {afe_alloc_cal, afe_dealloc_cal, NULL, afe_set_cal, NULL, NULL} }, Loading Loading
include/uapi/linux/msm_audio_calibration.h +4 −0 Original line number Diff line number Diff line Loading @@ -99,6 +99,8 @@ enum { AFE_FB_SPKR_PROT_TH_VI_CAL_TYPE, AFE_FB_SPKR_PROT_EX_VI_CAL_TYPE, AFE_SIDETONE_IIR_CAL_TYPE, AFE_LSM_TOPOLOGY_CAL_TYPE, AFE_LSM_TX_CAL_TYPE, MAX_CAL_TYPES, }; Loading @@ -106,6 +108,8 @@ enum { #define AFE_FB_SPKR_PROT_EX_VI_CAL_TYPE AFE_FB_SPKR_PROT_EX_VI_CAL_TYPE #define AFE_SIDETONE_IIR_CAL_TYPE AFE_SIDETONE_IIR_CAL_TYPE #define AFE_LSM_TOPOLOGY_CAL_TYPE AFE_LSM_TOPOLOGY_CAL_TYPE #define AFE_LSM_TX_CAL_TYPE AFE_LSM_TX_CAL_TYPE enum { VERSION_0_0, Loading
sound/soc/msm/qdsp6v2/audio_cal_utils.c +4 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,7 @@ size_t get_cal_info_size(int32_t cal_type) size = sizeof(struct audio_cal_info_audstrm); break; case AFE_TOPOLOGY_CAL_TYPE: case AFE_LSM_TOPOLOGY_CAL_TYPE: size = sizeof(struct audio_cal_info_afe_top); break; case AFE_CUST_TOPOLOGY_CAL_TYPE: Loading @@ -86,6 +87,7 @@ size_t get_cal_info_size(int32_t cal_type) size = sizeof(struct audio_cal_info_afe); break; case AFE_COMMON_TX_CAL_TYPE: case AFE_LSM_TX_CAL_TYPE: size = sizeof(struct audio_cal_info_afe); break; case AFE_FB_SPKR_PROT_CAL_TYPE: Loading Loading @@ -223,6 +225,7 @@ size_t get_user_cal_type_size(int32_t cal_type) size = sizeof(struct audio_cal_type_audstrm); break; case AFE_TOPOLOGY_CAL_TYPE: case AFE_LSM_TOPOLOGY_CAL_TYPE: size = sizeof(struct audio_cal_type_afe_top); break; case AFE_CUST_TOPOLOGY_CAL_TYPE: Loading @@ -232,6 +235,7 @@ size_t get_user_cal_type_size(int32_t cal_type) size = sizeof(struct audio_cal_type_afe); break; case AFE_COMMON_TX_CAL_TYPE: case AFE_LSM_TX_CAL_TYPE: size = sizeof(struct audio_cal_type_afe); break; case AFE_FB_SPKR_PROT_CAL_TYPE: Loading
sound/soc/msm/qdsp6v2/q6afe.c +45 −10 Original line number Diff line number Diff line Loading @@ -32,12 +32,14 @@ enum { AFE_COMMON_RX_CAL = 0, AFE_COMMON_TX_CAL, AFE_LSM_TX_CAL, AFE_AANC_CAL, AFE_FB_SPKR_PROT_CAL, AFE_HW_DELAY_CAL, AFE_SIDETONE_CAL, AFE_SIDETONE_IIR_CAL, AFE_TOPOLOGY_CAL, AFE_LSM_TOPOLOGY_CAL, AFE_CUST_TOPOLOGY_CAL, AFE_FB_SPKR_PROT_TH_VI_CAL, AFE_FB_SPKR_PROT_EX_VI_CAL, Loading Loading @@ -1324,14 +1326,15 @@ err_exit: return NULL; } static int afe_get_cal_topology_id(u16 port_id, u32 *topology_id) static int afe_get_cal_topology_id(u16 port_id, u32 *topology_id, int cal_type_index) { int ret = 0; struct cal_block_data *cal_block = NULL; struct audio_cal_info_afe_top *afe_top_info = NULL; if (this_afe.cal_data[AFE_TOPOLOGY_CAL] == NULL) { if (this_afe.cal_data[cal_type_index] == NULL) { pr_err("%s: [AFE_TOPOLOGY_CAL] not initialized\n", __func__); return -EINVAL; } Loading @@ -1341,9 +1344,9 @@ static int afe_get_cal_topology_id(u16 port_id, u32 *topology_id) } *topology_id = 0; mutex_lock(&this_afe.cal_data[AFE_TOPOLOGY_CAL]->lock); mutex_lock(&this_afe.cal_data[cal_type_index]->lock); cal_block = afe_find_cal_topo_id_by_port( this_afe.cal_data[AFE_TOPOLOGY_CAL], port_id); this_afe.cal_data[cal_type_index], port_id); if (cal_block == NULL) { pr_err("%s: [AFE_TOPOLOGY_CAL] not initialized for this port %d\n", __func__, port_id); Loading @@ -1365,7 +1368,7 @@ static int afe_get_cal_topology_id(u16 port_id, u32 *topology_id) __func__, port_id, afe_top_info->acdb_id, afe_top_info->topology, ret); unlock: mutex_unlock(&this_afe.cal_data[AFE_TOPOLOGY_CAL]->lock); mutex_unlock(&this_afe.cal_data[cal_type_index]->lock); return ret; } Loading @@ -1383,7 +1386,12 @@ static int afe_send_port_topology_id(u16 port_id) return -EINVAL; } ret = afe_get_cal_topology_id(port_id, &topology_id); ret = afe_get_cal_topology_id(port_id, &topology_id, AFE_TOPOLOGY_CAL); if (ret < 0) { pr_debug("%s: Check for LSM topology\n", __func__); ret = afe_get_cal_topology_id(port_id, &topology_id, AFE_LSM_TOPOLOGY_CAL); } if (ret || !topology_id) { pr_debug("%s: AFE port[%d] get_cal_topology[%d] invalid!\n", __func__, port_id, topology_id); Loading Loading @@ -1500,7 +1508,7 @@ exit: return cal_block; } static void send_afe_cal_type(int cal_index, int port_id) static int send_afe_cal_type(int cal_index, int port_id) { struct cal_block_data *cal_block = NULL; int ret; Loading @@ -1511,19 +1519,22 @@ static void send_afe_cal_type(int cal_index, int port_id) if (this_afe.cal_data[cal_index] == NULL) { pr_warn("%s: cal_index %d not allocated!\n", __func__, cal_index); ret = -EINVAL; goto done; } if (afe_port_index < 0) { pr_err("%s: Error getting AFE port index %d\n", __func__, afe_port_index); ret = -EINVAL; goto done; } mutex_lock(&this_afe.cal_data[cal_index]->lock); if (((cal_index == AFE_COMMON_RX_CAL) || (cal_index == AFE_COMMON_TX_CAL)) && (cal_index == AFE_COMMON_TX_CAL) || (cal_index == AFE_LSM_TX_CAL)) && (this_afe.dev_acdb_id[afe_port_index] > 0)) cal_block = afe_find_cal(cal_index, port_id); else Loading @@ -1532,6 +1543,7 @@ static void send_afe_cal_type(int cal_index, int port_id) if (cal_block == NULL) { pr_err("%s cal_block not found!!\n", __func__); ret = -EINVAL; goto unlock; } Loading @@ -1541,6 +1553,7 @@ static void send_afe_cal_type(int cal_index, int port_id) if (ret) { pr_err("%s: Remap_cal_data failed for cal %d!\n", __func__, cal_index); ret = -EINVAL; goto unlock; } ret = afe_send_cal_block(port_id, cal_block); Loading @@ -1550,16 +1563,20 @@ static void send_afe_cal_type(int cal_index, int port_id) unlock: mutex_unlock(&this_afe.cal_data[cal_index]->lock); done: return; return ret; } void afe_send_cal(u16 port_id) { int ret; pr_debug("%s: port_id=0x%x\n", __func__, port_id); if (afe_get_port_type(port_id) == MSM_AFE_PORT_TYPE_TX) { afe_send_cal_spkr_prot_tx(port_id); send_afe_cal_type(AFE_COMMON_TX_CAL, port_id); ret = send_afe_cal_type(AFE_COMMON_TX_CAL, port_id); if (ret < 0) send_afe_cal_type(AFE_LSM_TX_CAL, port_id); } else if (afe_get_port_type(port_id) == MSM_AFE_PORT_TYPE_RX) { afe_send_cal_spkr_prot_rx(port_id); send_afe_cal_type(AFE_COMMON_RX_CAL, port_id); Loading Loading @@ -6430,6 +6447,9 @@ static int get_cal_type_index(int32_t cal_type) case AFE_COMMON_TX_CAL_TYPE: ret = AFE_COMMON_TX_CAL; break; case AFE_LSM_TX_CAL_TYPE: ret = AFE_LSM_TX_CAL; break; case AFE_AANC_CAL_TYPE: ret = AFE_AANC_CAL; break; Loading @@ -6448,6 +6468,9 @@ static int get_cal_type_index(int32_t cal_type) case AFE_TOPOLOGY_CAL_TYPE: ret = AFE_TOPOLOGY_CAL; break; case AFE_LSM_TOPOLOGY_CAL_TYPE: ret = AFE_LSM_TOPOLOGY_CAL; break; case AFE_CUST_TOPOLOGY_CAL_TYPE: ret = AFE_CUST_TOPOLOGY_CAL; break; Loading Loading @@ -6945,6 +6968,12 @@ static int afe_init_cal_data(void) {afe_map_cal_data, afe_unmap_cal_data, cal_utils_match_buf_num} }, {{AFE_LSM_TX_CAL_TYPE, {afe_alloc_cal, afe_dealloc_cal, NULL, afe_set_cal, NULL, NULL} }, {afe_map_cal_data, afe_unmap_cal_data, cal_utils_match_buf_num} }, {{AFE_AANC_CAL_TYPE, {afe_alloc_cal, afe_dealloc_cal, NULL, afe_set_cal, NULL, NULL} }, Loading Loading @@ -6977,6 +7006,12 @@ static int afe_init_cal_data(void) {NULL, NULL, cal_utils_match_buf_num} }, {{AFE_LSM_TOPOLOGY_CAL_TYPE, {NULL, NULL, NULL, afe_set_cal, NULL, NULL} }, {NULL, NULL, cal_utils_match_buf_num} }, {{AFE_CUST_TOPOLOGY_CAL_TYPE, {afe_alloc_cal, afe_dealloc_cal, NULL, afe_set_cal, NULL, NULL} }, Loading