From: smj <smj@rock-chips.com>
Date: Mon, 19 Sep 2016 03:08:35 +0000 (+0800)
Subject: video: rockchip: hdmi: v2: improved the hdmi nlpcm_mode for bitstream output
X-Git-Tag: firefly_0821_release~1521
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a8376d64f49dd280599377ecfe3374ea1936ded1;p=firefly-linux-kernel-4.4.55.git

video: rockchip: hdmi: v2: improved the hdmi nlpcm_mode for bitstream output

- Add the corresponding to samplerate for bitstream
- Add the audio type judgement when open the mode

Change-Id: Ic5bbd2ee214e707fd3695f1a1f359cd43fed9618
Signed-off-by: smj <smj@rock-chips.com>
Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
---

diff --git a/drivers/video/rockchip/hdmi/rockchip-hdmiv2/rockchip_hdmiv2_hw.c b/drivers/video/rockchip/hdmi/rockchip-hdmiv2/rockchip_hdmiv2_hw.c
index 3b75d7143337..14a3a3067cd6 100644
--- a/drivers/video/rockchip/hdmi/rockchip-hdmiv2/rockchip_hdmiv2_hw.c
+++ b/drivers/video/rockchip/hdmi/rockchip-hdmiv2/rockchip_hdmiv2_hw.c
@@ -1899,15 +1899,35 @@ static int hdmi_dev_config_audio(struct hdmi *hdmi, struct hdmi_audio *audio)
 		else
 			hdmi_writel(hdmi_dev, AUD_CONF2, 0x0);
 		usleep_range(90, 100);
-		if (channel == I2S_CHANNEL_7_8) {
-			HDMIDBG("hbr mode.\n");
-			hdmi_writel(hdmi_dev, AUD_CONF2, 0x1);
-			word_length = I2S_24BIT_SAMPLE;
-		} else if ((audio->rate == HDMI_AUDIO_FS_48000) ||
-			   (audio->rate == HDMI_AUDIO_FS_192000)) {
-			HDMIDBG("nlpcm mode.\n");
-			hdmi_writel(hdmi_dev, AUD_CONF2, 0x2);
-			word_length = I2S_24BIT_SAMPLE;
+		/*
+		 * when we try to use hdmi nlpcm mode
+		 * we should use set AUD_CONF2 to open this route and set
+		 * word_length to 24bit for b.p.c.u.v with 16bit raw data
+		 * when the bitstream data  up to 8 channel, we should use
+		 * the hdmi hbr mode
+		 * HBR Mode : Dolby TrueHD
+		 *            Dolby Atmos
+		 *            DTS-HDMA
+		 * NLPCM Mode :
+		 * FS_32000 FS_44100 FS_48000 : Dolby Digital &  DTS
+		 * FS_176400 FS_192000        : Dolby Digital Plus
+		 */
+		if (audio->type == HDMI_AUDIO_NLPCM) {
+			if (channel == I2S_CHANNEL_7_8) {
+				HDMIDBG("hbr mode.\n");
+				hdmi_writel(hdmi_dev, AUD_CONF2, 0x1);
+				word_length = I2S_24BIT_SAMPLE;
+			} else if ((audio->rate == HDMI_AUDIO_FS_32000) ||
+				   (audio->rate == HDMI_AUDIO_FS_44100) ||
+				   (audio->rate == HDMI_AUDIO_FS_48000) ||
+				   (audio->rate == HDMI_AUDIO_FS_176400) ||
+				   (audio->rate == HDMI_AUDIO_FS_192000)) {
+				HDMIDBG("nlpcm mode.\n");
+				hdmi_writel(hdmi_dev, AUD_CONF2, 0x2);
+				word_length = I2S_24BIT_SAMPLE;
+			} else {
+				hdmi_writel(hdmi_dev, AUD_CONF2, 0x0);
+			}
 		} else {
 			if (design_id >= 0x21)
 				hdmi_writel(hdmi_dev, AUD_CONF2, 0x4);