diff --git a/hardware/rockchip/audio/tinyalsa_hal/audio_hw.c b/hardware/rockchip/audio/tinyalsa_hal/audio_hw.c index 373244d2f7f..deb8a634553 100644 --- a/hardware/rockchip/audio/tinyalsa_hal/audio_hw.c +++ b/hardware/rockchip/audio/tinyalsa_hal/audio_hw.c @@ -1799,20 +1799,9 @@ static int start_input_stream(struct stream_in *in) return -EINVAL; } } else if (in->device == AUDIO_DEVICE_IN_HDMI) { - char value[PROPERTY_VALUE_MAX]; - - in->hdmiindex = 0; - if (property_get("tvinput.hdmiin.type", value, NULL) > 0) { - ALOGD("start_input_stream tvinput.hdmiin.type=%s", value); - if(atoi(value)) - in->hdmiindex = 1; - } - - if (get_hdmiin_audio_info(adev, "audio_present", &hdmiin_present, in->hdmiindex)) { - if (!hdmiin_present) { - ALOGD("hdmiin audio is no present, don't open hdmiin sound"); - return -EEXIST; - } + if (!in->hdmiin_present) { + ALOGD("hdmiin audio is no present, don't open hdmiin sound"); + return -EEXIST; } if (in->hdmiindex) { card = (int)adev->dev_in[SND_IN_SOUND_CARD_HDMI_1].card; @@ -3595,8 +3584,8 @@ static ssize_t in_read(struct audio_stream_in *stream, void* buffer, size_t frames_rd = 0; if (in->device == AUDIO_DEVICE_IN_HDMI) { - unsigned int rate = get_hdmiin_audio_rate(adev, in->hdmiindex); - if(rate != in->config->rate){ + int rate = get_hdmiin_audio_rate(adev, in->hdmiindex); + if (rate != in->config->rate) { ALOGD("HDMI-In: rate is changed: %d -> %d, restart input stream", in->config->rate, rate); pthread_mutex_lock(&in->lock); @@ -4026,7 +4015,7 @@ static int adev_open_output_stream(struct audio_hw_device *dev, bool isPcm = audio_is_linear_pcm(config->format); bool isBitstream = false; - ALOGD("audio hal adev_open_output_stream devices = 0x%x, flags = %d, samplerate = %d,format = 0x%x", + ALOGD("adev_open_output_stream: devices = 0x%x, flags = %d, samplerate = %d,format = 0x%x", devices, flags, config->sample_rate,config->format); // only support PCM or IEC61937 format @@ -4654,7 +4643,7 @@ static int adev_open_input_stream(struct audio_hw_device *dev, struct stream_in *in; int ret; - ALOGD("audio hal adev_open_input_stream devices = 0x%x, flags = %d, config->samplerate = %d,config->channel_mask = %x", + ALOGD("adev_open_input_stream: devices = 0x%x, flags = %d, config->samplerate = %d,config->channel_mask = %x", devices, flags, config->sample_rate,config->channel_mask); *stream_in = NULL; @@ -4727,10 +4716,28 @@ static int adev_open_input_stream(struct audio_hw_device *dev, in->channel_mask = config->channel_mask; in->resampler = NULL; + in->hdmiindex = 0; + char value[PROPERTY_VALUE_MAX]; + if (property_get("tvinput.hdmiin.type", value, NULL) > 0) { + ALOGD("start_input_stream tvinput.hdmiin.type=%s", value); + if (atoi(value)) + in->hdmiindex = 1; + } + + in->hdmiin_present = 0; + get_hdmiin_audio_info(adev, "audio_present", &in->hdmiin_present, in->hdmiindex); + if (in->device == AUDIO_DEVICE_IN_HDMI) { + if (in->hdmiin_present == 0) { + ALOGD("%s: hdmiin audio is not present", __func__); + ret = -ENODEV; + goto err_malloc; + } + ALOGD("HDMI-In: use low latency"); flags |= AUDIO_INPUT_FLAG_FAST; } + in->flags = flags; struct pcm_config *pcm_config = flags & AUDIO_INPUT_FLAG_FAST ? &pcm_config_in_low_latency : &pcm_config_in; @@ -4927,7 +4934,13 @@ static int adev_create_audio_patch(struct audio_hw_device *dev, return -EINVAL; } in->device = sources[0].ext.device.type; + if (in->device == AUDIO_DEVICE_IN_HDMI && in->hdmiin_present == 0) { + ALOGD("No HDMI-In audio, rejecting patch 0x%x", in->device); + device_unlock(adev); + return -ENODEV; + } device_unlock(adev); + pthread_mutex_lock(&in->lock); device_lock(adev); do_in_standby(in); diff --git a/hardware/rockchip/audio/tinyalsa_hal/audio_hw.h b/hardware/rockchip/audio/tinyalsa_hal/audio_hw.h index 58ac8ad63bf..c29fa622965 100644 --- a/hardware/rockchip/audio/tinyalsa_hal/audio_hw.h +++ b/hardware/rockchip/audio/tinyalsa_hal/audio_hw.h @@ -292,6 +292,7 @@ struct stream_in { hrkdeniose mDenioseState; #endif int hdmiindex; + int hdmiin_present; uint32_t channel_flag; int start_checkcount; uint64_t frames_read;