summaryrefslogtreecommitdiff
authorZhe Wang <Zhe.Wang@amlogic.com>2019-07-31 02:13:26 (GMT)
committer Tao Zeng <tao.zeng@amlogic.com>2019-08-05 05:28:54 (GMT)
commit8aa57f68a8d075b39977f0d47bd5bcef1e2a7a56 (patch)
tree6e46bcc7729c9a2256481dfe0f9f4610204e149f
parentdf1c2d23178ee1baca3b0fbd840656d1a6787da1 (diff)
downloadcommon-8aa57f68a8d075b39977f0d47bd5bcef1e2a7a56.zip
common-8aa57f68a8d075b39977f0d47bd5bcef1e2a7a56.tar.gz
common-8aa57f68a8d075b39977f0d47bd5bcef1e2a7a56.tar.bz2
audio: when audio hdmirx is unstable, mute all input buffer [1/2]
PD#SWPL-12104 Problem: when hdmirx timing switching, pop noise. Solution: when audio hdmirx is unstable, mute all input buffer Verify: T962x2 x301 Change-Id: I594b5bf9c1f4af45bb3653a7bfef5e0c7dab2825 Signed-off-by: Zhe Wang <Zhe.Wang@amlogic.com>
Diffstat
-rw-r--r--include/linux/amlogic/media/sound/misc.h3
-rw-r--r--sound/soc/amlogic/auge/extn.c33
-rw-r--r--sound/soc/amlogic/common/misc.c14
3 files changed, 46 insertions, 4 deletions
diff --git a/include/linux/amlogic/media/sound/misc.h b/include/linux/amlogic/media/sound/misc.h
index c9e9fbd..866644e7 100644
--- a/include/linux/amlogic/media/sound/misc.h
+++ b/include/linux/amlogic/media/sound/misc.h
@@ -75,6 +75,9 @@ extern int aml_get_hdmiin_audio_packet(
struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol);
+extern int get_hdmiin_audio_stable(void);
+extern int get_hdmi_sample_rate_index(void);
+
#endif
#endif
diff --git a/sound/soc/amlogic/auge/extn.c b/sound/soc/amlogic/auge/extn.c
index 31a208a..c8db16f 100644
--- a/sound/soc/amlogic/auge/extn.c
+++ b/sound/soc/amlogic/auge/extn.c
@@ -343,6 +343,38 @@ static int extn_mmap(struct snd_pcm_substream *substream,
return snd_pcm_lib_default_mmap(substream, vma);
}
+static int extn_copy(struct snd_pcm_substream *substream, int channel,
+ snd_pcm_uframes_t pos,
+ void __user *buf, snd_pcm_uframes_t count)
+{
+ struct snd_pcm_runtime *runtime = substream->runtime;
+ char *hwbuf = runtime->dma_area + frames_to_bytes(runtime, pos);
+ int bytes = frames_to_bytes(runtime, count);
+
+ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+ if (copy_from_user(hwbuf, buf, bytes))
+ return -EFAULT;
+ } else {
+#ifdef CONFIG_AMLOGIC_MEDIA_TVIN_HDMI
+ enum toddr_src src = toddr_src_get();
+
+ /*if hdmirx or N&CTS is unstable, clear all buffer data.*/
+ if (src == FRHDMIRX && (!get_hdmiin_audio_stable() ||
+ get_hdmi_sample_rate_index() == 0)) {
+ char *buffer = runtime->dma_area;
+ int buffer_size = snd_pcm_lib_buffer_bytes(substream);
+
+ memset(buffer, 0, buffer_size);
+ }
+#endif
+ if (copy_to_user(buf, hwbuf, bytes))
+ return -EFAULT;
+
+ memset(hwbuf, 0, bytes);
+ }
+ return 0;
+}
+
static struct snd_pcm_ops extn_ops = {
.open = extn_open,
.close = extn_close,
@@ -354,6 +386,7 @@ static struct snd_pcm_ops extn_ops = {
.pointer = extn_pointer,
.silence = extn_silence,
.mmap = extn_mmap,
+ .copy = extn_copy,
};
static int extn_new(struct snd_soc_pcm_runtime *rtd)
diff --git a/sound/soc/amlogic/common/misc.c b/sound/soc/amlogic/common/misc.c
index 1b46705..10c10a9 100644
--- a/sound/soc/amlogic/common/misc.c
+++ b/sound/soc/amlogic/common/misc.c
@@ -199,15 +199,21 @@ const struct soc_enum hdmi_in_status_enum[] = {
hdmi_in_audio_packet)
};
-int aml_get_hdmiin_audio_stable(
- struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
+int get_hdmiin_audio_stable(void)
{
struct rx_audio_stat_s aud_sts;
rx_get_audio_status(&aud_sts);
+
+ return (aud_sts.aud_rcv_packet == 0) ? 0 : 1;
+}
+
+int aml_get_hdmiin_audio_stable(
+ struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
ucontrol->value.integer.value[0] =
- (aud_sts.aud_rcv_packet == 0) ? 0 : 1;
+ get_hdmiin_audio_stable();
return 0;
}