diff --git a/drivers/amlogic/media/vin/tvin/hdmirx/hdmi_rx_drv.h b/drivers/amlogic/media/vin/tvin/hdmirx/hdmi_rx_drv.h index b51798c975f8..fcc09da080c6 100644 --- a/drivers/amlogic/media/vin/tvin/hdmirx/hdmi_rx_drv.h +++ b/drivers/amlogic/media/vin/tvin/hdmirx/hdmi_rx_drv.h @@ -34,7 +34,7 @@ #include "hdmi_rx_edid.h" -#define RX_VER0 "ver.2018-11-8" +#define RX_VER0 "ver.2019-01-22" /* * * diff --git a/drivers/amlogic/media/vin/tvin/hdmirx/hdmi_rx_hw.c b/drivers/amlogic/media/vin/tvin/hdmirx/hdmi_rx_hw.c index c36f4994326a..a21560b27865 100644 --- a/drivers/amlogic/media/vin/tvin/hdmirx/hdmi_rx_hw.c +++ b/drivers/amlogic/media/vin/tvin/hdmirx/hdmi_rx_hw.c @@ -913,23 +913,22 @@ if (audio_info->cts != 0) { */ void rx_get_audio_status(struct rx_audio_stat_s *aud_sts) { -if ((rx.state == FSM_SIG_READY) && - (rx.pre.sw_vic != HDMI_UNKNOWN) && - (rx.pre.sw_vic != HDMI_UNSUPPORT) && - (rx.avmute_skip == 0)) { - aud_sts->aud_rcv_flag = - (rx.aud_info.aud_packet_received == 0) ? false : true; - aud_sts->aud_stb_flag = true; - aud_sts->aud_sr = rx.aud_info.real_sr; - aud_sts->aud_channel_cnt = rx.aud_info.channel_count; - aud_sts->aud_type = rx.aud_info.coding_type; - aud_sts->afifo_thres_pass = - ((hdmirx_rd_dwc(DWC_AUD_FIFO_STS) & - THS_PASS_STS) == 0) ? false : true; -} else { - memset(aud_sts, 0, - sizeof(struct rx_audio_stat_s)); -} + if ((rx.state == FSM_SIG_READY) && + (rx.pre.sw_vic != HDMI_UNKNOWN) && + (rx.pre.sw_vic != HDMI_UNSUPPORT) && + (rx.avmute_skip == 0)) { + aud_sts->aud_rcv_packet = rx.aud_info.aud_packet_received; + aud_sts->aud_stb_flag = true; + aud_sts->aud_sr = rx.aud_info.real_sr; + aud_sts->aud_channel_cnt = rx.aud_info.channel_count; + aud_sts->aud_type = rx.aud_info.coding_type; + aud_sts->afifo_thres_pass = + ((hdmirx_rd_dwc(DWC_AUD_FIFO_STS) & + THS_PASS_STS) == 0) ? false : true; + } else { + memset(aud_sts, 0, + sizeof(struct rx_audio_stat_s)); + } } EXPORT_SYMBOL(rx_get_audio_status); diff --git a/include/linux/amlogic/media/frame_provider/tvin/tvin.h b/include/linux/amlogic/media/frame_provider/tvin/tvin.h index 3fa257f72802..181796ff88e2 100644 --- a/include/linux/amlogic/media/frame_provider/tvin/tvin.h +++ b/include/linux/amlogic/media/frame_provider/tvin/tvin.h @@ -464,7 +464,7 @@ struct dfe_adcpll_para { struct rx_audio_stat_s { /*audio packets received*/ - bool aud_rcv_flag; + int aud_rcv_packet; /*audio stable status*/ bool aud_stb_flag; /*audio sample rate*/ diff --git a/include/linux/amlogic/media/sound/misc.h b/include/linux/amlogic/media/sound/misc.h index 25341c2e18be..c9e9fbda9613 100644 --- a/include/linux/amlogic/media/sound/misc.h +++ b/include/linux/amlogic/media/sound/misc.h @@ -71,6 +71,10 @@ extern int aml_get_atmos_audio_edid( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); +extern int aml_get_hdmiin_audio_packet( + struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol); + #endif #endif diff --git a/sound/soc/amlogic/auge/extn.c b/sound/soc/amlogic/auge/extn.c index 07d31ee2e8ee..712c6aa76acf 100644 --- a/sound/soc/amlogic/auge/extn.c +++ b/sound/soc/amlogic/auge/extn.c @@ -800,6 +800,11 @@ static const struct snd_kcontrol_new extn_controls[] = { aml_get_hdmiin_audio_format, NULL), + SOC_ENUM_EXT("HDMIIN Audio Packet", + hdmi_in_status_enum[4], + aml_get_hdmiin_audio_packet, + NULL), + SOC_SINGLE_BOOL_EXT("HDMI ATMOS EDID Switch", 0, aml_get_atmos_audio_edid, diff --git a/sound/soc/amlogic/common/misc.c b/sound/soc/amlogic/common/misc.c index fc15a68f4de1..1b4670564d6e 100644 --- a/sound/soc/amlogic/common/misc.c +++ b/sound/soc/amlogic/common/misc.c @@ -176,6 +176,16 @@ static const char * const hdmi_in_format[] = { "WMA_PRO" }; +static const char * const hdmi_in_audio_packet[] = { + "None", + "AUDS", + "OBA", + "DST", + "HBR", + "OBM", + "MAS" +}; + const struct soc_enum hdmi_in_status_enum[] = { SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(audio_is_stable), audio_is_stable), @@ -184,7 +194,9 @@ const struct soc_enum hdmi_in_status_enum[] = { SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(hdmi_in_channels), hdmi_in_channels), SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(hdmi_in_format), - hdmi_in_format) + hdmi_in_format), + SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(hdmi_in_audio_packet), + hdmi_in_audio_packet) }; int aml_get_hdmiin_audio_stable( @@ -194,7 +206,8 @@ int aml_get_hdmiin_audio_stable( struct rx_audio_stat_s aud_sts; rx_get_audio_status(&aud_sts); - ucontrol->value.integer.value[0] = aud_sts.aud_rcv_flag; + ucontrol->value.integer.value[0] = + (aud_sts.aud_rcv_packet == 0) ? 0 : 1; return 0; } @@ -236,6 +249,7 @@ int aml_get_hdmiin_audio_format( return 0; } + /* call HDMI CEC API to enable arc audio */ int aml_set_atmos_audio_edid( struct snd_kcontrol *kcontrol, @@ -259,4 +273,44 @@ int aml_get_atmos_audio_edid( return 0; } +int aml_get_hdmiin_audio_packet( + struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct rx_audio_stat_s aud_sts; + int val; + + rx_get_audio_status(&aud_sts); + + switch (aud_sts.aud_rcv_packet) { + case 0: + val = 0; + break; + case 1: + val = 1; + break; + case 2: + val = 2; + break; + case 4: + val = 3; + break; + case 8: + val = 4; + break; + case 16: + val = 5; + break; + case 32: + val = 6; + break; + default: + val = 0; + break; + } + ucontrol->value.integer.value[0] = val; + + return 0; +} + #endif diff --git a/sound/soc/amlogic/meson/tv.c b/sound/soc/amlogic/meson/tv.c index a5b00f110581..7f6c4df9f7f1 100644 --- a/sound/soc/amlogic/meson/tv.c +++ b/sound/soc/amlogic/meson/tv.c @@ -285,9 +285,17 @@ static int aml_get_spdif_audio_type( int audio_type = 0; int i; int total_num = sizeof(type_texts)/sizeof(struct spdif_audio_info); - int pc = aml_audin_read(AUDIN_SPDIF_NPCM_PCPD)>>16; + int pc_ori = aml_audin_read(AUDIN_SPDIF_NPCM_PCPD)>>16; + int pc = 0; - pc = pc&0xfff; + /* data type is 0~4 bit*/ + pc = pc_ori&0x1f; + /* check whether it has stop bit + * refer to IEC61937-1 table 9 + */ + if (pc == 0) { + pc = pc_ori&0xfff; + } for (i = 0; i < total_num; i++) { if (pc == type_texts[i].pc) { audio_type = type_texts[i].aud_type; @@ -616,6 +624,9 @@ static const struct snd_kcontrol_new aml_tv_controls[] = { SOC_ENUM_EXT("HDMIIN audio format", hdmi_in_status_enum[3], aml_get_hdmiin_audio_format, NULL), + SOC_ENUM_EXT("HDMIIN Audio Packet", hdmi_in_status_enum[4], + aml_get_hdmiin_audio_packet, + NULL), SOC_SINGLE_BOOL_EXT("HDMI ATMOS EDID Switch", 0, aml_get_atmos_audio_edid, aml_set_atmos_audio_edid),