Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc394037 authored by Ramprasad Katkam's avatar Ramprasad Katkam
Browse files

rtac: Add mutex protection for rtac cal apis



Add mutex lock protection to synchronize rtac
calibration set and get api calls.

Change-Id: Ieb2d01642ecefff6405bb59554157c304b4b651d
Signed-off-by: default avatarRamprasad Katkam <katkam@codeaurora.org>
parent a6a60089
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -122,6 +122,10 @@ struct mutex rtac_asm_apr_mutex;
struct mutex			rtac_voice_mutex;
struct mutex			rtac_voice_apr_mutex;
struct mutex			rtac_afe_apr_mutex;
struct mutex			rtac_asm_cal_mutex;
struct mutex			rtac_adm_cal_mutex;
struct mutex			rtac_afe_cal_mutex;
struct mutex			rtac_voice_cal_mutex;

int rtac_clear_mapping(uint32_t cal_type)
{
@@ -1803,64 +1807,84 @@ static long rtac_ioctl_shared(struct file *f,
	}

	case AUDIO_GET_RTAC_ADM_CAL:
		mutex_lock(&rtac_adm_cal_mutex);
		opcode = q6common_is_instance_id_supported() ?
				 ADM_CMD_GET_PP_PARAMS_V6 :
				 ADM_CMD_GET_PP_PARAMS_V5;
		result = send_adm_apr((void *) arg, opcode);
		mutex_unlock(&rtac_adm_cal_mutex);
		break;
	case AUDIO_SET_RTAC_ADM_CAL:
		mutex_lock(&rtac_adm_cal_mutex);
		opcode = q6common_is_instance_id_supported() ?
				 ADM_CMD_SET_PP_PARAMS_V6 :
				 ADM_CMD_SET_PP_PARAMS_V5;
		result = send_adm_apr((void *) arg, opcode);
		mutex_unlock(&rtac_adm_cal_mutex);
		break;
	case AUDIO_GET_RTAC_ASM_CAL:
		mutex_lock(&rtac_asm_cal_mutex);
		opcode = q6common_is_instance_id_supported() ?
				 ASM_STREAM_CMD_GET_PP_PARAMS_V3 :
				 ASM_STREAM_CMD_GET_PP_PARAMS_V2;
		result = send_rtac_asm_apr((void *) arg, opcode);
		mutex_unlock(&rtac_asm_cal_mutex);
		break;
	case AUDIO_SET_RTAC_ASM_CAL:
		mutex_lock(&rtac_asm_cal_mutex);
		opcode = q6common_is_instance_id_supported() ?
				 ASM_STREAM_CMD_SET_PP_PARAMS_V3 :
				 ASM_STREAM_CMD_SET_PP_PARAMS_V2;
		result = send_rtac_asm_apr((void *) arg, opcode);
		mutex_unlock(&rtac_asm_cal_mutex);
		break;
	case AUDIO_GET_RTAC_CVS_CAL:
		mutex_lock(&rtac_voice_cal_mutex);
		opcode = q6common_is_instance_id_supported() ?
				 VSS_ICOMMON_CMD_GET_PARAM_V3 :
				 VSS_ICOMMON_CMD_GET_PARAM_V2;
		result = send_voice_apr(RTAC_CVS, (void *) arg, opcode);
		mutex_unlock(&rtac_voice_cal_mutex);
		break;
	case AUDIO_SET_RTAC_CVS_CAL:
		mutex_lock(&rtac_voice_cal_mutex);
		opcode = q6common_is_instance_id_supported() ?
				 VSS_ICOMMON_CMD_SET_PARAM_V3 :
				 VSS_ICOMMON_CMD_SET_PARAM_V2;
		result = send_voice_apr(RTAC_CVS, (void *) arg, opcode);
		mutex_unlock(&rtac_voice_cal_mutex);
		break;
	case AUDIO_GET_RTAC_CVP_CAL:
		mutex_lock(&rtac_voice_cal_mutex);
		opcode = q6common_is_instance_id_supported() ?
				 VSS_ICOMMON_CMD_GET_PARAM_V3 :
				 VSS_ICOMMON_CMD_GET_PARAM_V2;
		result = send_voice_apr(RTAC_CVP, (void *) arg, opcode);
		mutex_unlock(&rtac_voice_cal_mutex);
		break;
	case AUDIO_SET_RTAC_CVP_CAL:
		mutex_lock(&rtac_voice_cal_mutex);
		opcode = q6common_is_instance_id_supported() ?
				 VSS_ICOMMON_CMD_SET_PARAM_V3 :
				 VSS_ICOMMON_CMD_SET_PARAM_V2;
		result = send_voice_apr(RTAC_CVP, (void *) arg, opcode);
		mutex_unlock(&rtac_voice_cal_mutex);
		break;
	case AUDIO_GET_RTAC_AFE_CAL:
		mutex_lock(&rtac_afe_cal_mutex);
		opcode = q6common_is_instance_id_supported() ?
				 AFE_PORT_CMD_GET_PARAM_V3 :
				 AFE_PORT_CMD_GET_PARAM_V2;
		result = send_rtac_afe_apr((void __user *) arg, opcode);
		mutex_unlock(&rtac_afe_cal_mutex);
		break;
	case AUDIO_SET_RTAC_AFE_CAL:
		mutex_lock(&rtac_afe_cal_mutex);
		opcode = q6common_is_instance_id_supported() ?
				 AFE_PORT_CMD_SET_PARAM_V3 :
				 AFE_PORT_CMD_SET_PARAM_V2;
		result = send_rtac_afe_apr((void __user *) arg, opcode);
		mutex_unlock(&rtac_afe_cal_mutex);
		break;
	default:
		pr_err("%s: Invalid IOCTL, command = %d!\n",
@@ -1992,6 +2016,7 @@ int __init rtac_init(void)
	init_waitqueue_head(&rtac_adm_apr_data.cmd_wait);
	mutex_init(&rtac_adm_mutex);
	mutex_init(&rtac_adm_apr_mutex);
	mutex_init(&rtac_adm_cal_mutex);

	rtac_adm_buffer = kzalloc(
		rtac_cal[ADM_RTAC_CAL].map_data.map_size, GFP_KERNEL);
@@ -2005,6 +2030,7 @@ int __init rtac_init(void)
		init_waitqueue_head(&rtac_asm_apr_data[i].cmd_wait);
	}
	mutex_init(&rtac_asm_apr_mutex);
	mutex_init(&rtac_asm_cal_mutex);

	rtac_asm_buffer = kzalloc(
		rtac_cal[ASM_RTAC_CAL].map_data.map_size, GFP_KERNEL);
@@ -2018,6 +2044,7 @@ int __init rtac_init(void)
	atomic_set(&rtac_afe_apr_data.cmd_state, 0);
	init_waitqueue_head(&rtac_afe_apr_data.cmd_wait);
	mutex_init(&rtac_afe_apr_mutex);
	mutex_init(&rtac_afe_cal_mutex);

	rtac_afe_buffer = kzalloc(
		rtac_cal[AFE_RTAC_CAL].map_data.map_size, GFP_KERNEL);
@@ -2036,6 +2063,7 @@ int __init rtac_init(void)
	}
	mutex_init(&rtac_voice_mutex);
	mutex_init(&rtac_voice_apr_mutex);
	mutex_init(&rtac_voice_cal_mutex);

	rtac_voice_buffer = kzalloc(
		rtac_cal[VOICE_RTAC_CAL].map_data.map_size, GFP_KERNEL);