diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-10-19 17:13:32 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-10-19 17:13:32 +0000 |
commit | 94deec7a3e641a845ebe7468341e902d0d2304fa (patch) | |
tree | 4865b285e5971c2a1d25662fb6d4955114964f29 | |
parent | df3ec0618a6bb62d9bcccb8f01fa899a8217ce48 (diff) | |
parent | 0201b1f2e6d701ab03beb0b641cb65564710fe39 (diff) | |
download | mcu_mic_codec-android-msm-eos-5.15-tm-wear-kr3-pixel-watch.tar.gz |
Merge cherrypicks of ['partner-android-review.googlesource.com/2636804'] into android13-msm-pixelwatch-5.15-eos-release.android-wear-13.0.0_r0.8android-wear-13.0.0_r0.6android-wear-13.0.0_r0.14android-wear-13.0.0_r0.12android-wear-13.0.0_r0.10android-msm-eos-android13-wear-kr3-pixel-watchandroid-msm-eos-5.15-tm-wear-kr3-pixel-watch
Change-Id: Icabf221fe03b370dc5082dd13b445bbc09db42c1
-rw-r--r-- | mcu_mic_codec.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/mcu_mic_codec.c b/mcu_mic_codec.c index 2c84776..319426a 100644 --- a/mcu_mic_codec.c +++ b/mcu_mic_codec.c @@ -88,7 +88,7 @@ extern void nanohub_unregister_listener(int channel_id); // [iolock]: Utilized to guarantee integrity of the data struct mcu_mic_codec_data { int mic_on; - int sample_rate_hz; + unsigned int sample_rate_hz; int gain; bool gain_user_requested; bool hw_enabled; @@ -207,7 +207,7 @@ static int dmic_mcu_sample_rate_get(struct snd_kcontrol *kcontrol, mutex_lock(&codec_data->iolock); ucontrol->value.integer.value[0] = codec_data->sample_rate_hz; - dev_info(component->dev, "%s: mcu_mic_sample_rate: %d\n", + dev_info(component->dev, "%s: mcu_mic_sample_rate: %u\n", __func__, codec_data->sample_rate_hz); mutex_unlock(&codec_data->iolock); @@ -223,7 +223,7 @@ static int dmic_mcu_sample_rate_put(struct snd_kcontrol *kcontrol, snd_soc_kcontrol_component(kcontrol); struct mcu_mic_codec_data *codec_data = snd_soc_component_get_drvdata(component); - int value = ucontrol->value.integer.value[0]; + unsigned int value = ucontrol->value.integer.value[0]; int ret; dev_dbg(component->dev, "%s\n", __func__); @@ -245,7 +245,7 @@ static int dmic_mcu_sample_rate_put(struct snd_kcontrol *kcontrol, return 0; } else { dev_err(component->dev, - "Invalid Sample Rate: %d. (Valid rates: %d, %d, %d Hz)\n", + "Invalid Sample Rate: %u. (Valid rates: %d, %d, %d Hz)\n", value, MCU_PCM_RATE_8000, MCU_PCM_RATE_16000, MCU_PCM_RATE_48000); return -EINVAL; @@ -253,13 +253,13 @@ static int dmic_mcu_sample_rate_put(struct snd_kcontrol *kcontrol, } ret = dmic_mcu_send_message(component->dev, DMIC_MCU_MESSAGE_SAMPLE_RATE_KHZ, - value / 1000); + (int)(value / 1000)); if (ret != 0) return ret; mutex_lock(&codec_data->iolock); codec_data->sample_rate_hz = value; - dev_info(component->dev, "%s: new mcu_mic_sample_rate: %d\n", + dev_info(component->dev, "%s: new mcu_mic_sample_rate: %u\n", __func__, codec_data->sample_rate_hz); mutex_unlock(&codec_data->iolock); @@ -405,7 +405,7 @@ static int dmic_mcu_hw_enabled_put(struct snd_kcontrol *kcontrol, // MCU after the crash. mutex_lock(&codec_data->iolock); codec_data->hw_enabled = value; - dev_info(component->dev, "%s: mcu_mc_hw_enabled: %d\n", + dev_info(component->dev, "%s: mcu_mic_hw_enabled: %d\n", __func__, codec_data->hw_enabled); mutex_unlock(&codec_data->iolock); @@ -497,29 +497,35 @@ static int mcu_mic_hw_params(struct snd_pcm_substream *substream, struct snd_soc_component *component = dai->component; struct mcu_mic_codec_data *codec_data = snd_soc_component_get_drvdata(component); - u32 sample_rate = 0; + unsigned int sample_rate = params_rate(params); int ret = 0; int conditionalized_value; mutex_lock(&codec_data->iolock); + if (!codec_data->pending_rec && (codec_data->mic_on == DMIC_MCU_ON_ON)) { + // In case the mic is already running, we allow new audio input + // requests without having to force the mic to first be turned off. + dev_info(component->dev, + "No pending rec request but mic is already on => Proceeding"); + codec_data->pending_rec = DMIC_MCU_ON_ON; + } + // Double checking there is indeed a pending recording going on if (codec_data->pending_rec) { - sample_rate = params_rate(params); - // Double check the requested sampling rate is a valid one. if (sample_rate != MCU_PCM_RATE_8000 && sample_rate != MCU_PCM_RATE_16000 && sample_rate != MCU_PCM_RATE_48000) { dev_err(component->dev, - "Invalid Sample Rate: %d. (Valid rates: %d, %d, %d Hz)\n", + "Invalid Sample Rate: %u. (Valid rates: %d, %d, %d Hz)\n", sample_rate, MCU_PCM_RATE_8000, MCU_PCM_RATE_16000, MCU_PCM_RATE_48000); ret = -EINVAL; goto end; } - dev_info(component->dev, "Sampling at: %lu\n", sample_rate); + dev_info(component->dev, "Sampling at: %u\n", sample_rate); // Set MCU sampling rate with the one requested by the AP to the ADSP ret = dmic_mcu_send_message(component->dev, @@ -579,7 +585,6 @@ static int mcu_mic_hw_params(struct snd_pcm_substream *substream, } else { dev_err(component->dev, "Called without calling 'DMIC_MCU On' first"); ret = -EINVAL; - goto end; } end: |