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,
.pointer = extn_pointer,
.silence = extn_silence,
.mmap = extn_mmap,
+ .copy = extn_copy,
};
static int extn_new(struct snd_soc_pcm_runtime *rtd)
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;
}