[kernel/f20] Add patches from Pierre Ossman to fix 24Hz/24p radeon audio (rhbz 1010679)

Josh Boyer jwboyer at fedoraproject.org
Mon Nov 18 16:28:34 UTC 2013


commit 9ecd60bc7963b9fc26097e807b1a9d20e3efa1b2
Author: Josh Boyer <jwboyer at fedoraproject.org>
Date:   Mon Nov 18 11:25:28 2013 -0500

    Add patches from Pierre Ossman to fix 24Hz/24p radeon audio (rhbz 1010679)

 drm-radeon-24hz-audio-fixes.patch |  170 +++++++++++++++++++++++++++++++++++++
 kernel.spec                       |    3 +
 2 files changed, 173 insertions(+), 0 deletions(-)
---
diff --git a/drm-radeon-24hz-audio-fixes.patch b/drm-radeon-24hz-audio-fixes.patch
new file mode 100644
index 0000000..b2ecf93
--- /dev/null
+++ b/drm-radeon-24hz-audio-fixes.patch
@@ -0,0 +1,170 @@
+From 908171aa738b5bbcc6241cec46f73fcd57dd00d4 Mon Sep 17 00:00:00 2001
+From: Pierre Ossman <pierre at ossman.eu>
+Date: Wed, 6 Nov 2013 20:00:32 +0100
+Subject: [PATCH 1/2] drm/radeon/audio: correct ACR table
+
+The values were taken from the HDMI spec, but they assumed
+exact x/1.001 clocks. Since we round the clocks, we also need
+to calculate different N and CTS values.
+
+Note that the N for 25.2/1.001 MHz at 44.1 kHz audio is out of
+spec. Hopefully this mode is rarely used and/or HDMI sinks
+tolerate overly large values of N.
+
+bug:
+https://bugs.freedesktop.org/show_bug.cgi?id=69675
+
+Signed-off-by: Pierre Ossman <pierre at ossman.eu>
+Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
+---
+ drivers/gpu/drm/radeon/r600_hdmi.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/gpu/drm/radeon/r600_hdmi.c b/drivers/gpu/drm/radeon/r600_hdmi.c
+index 4140fe8..e8ca095 100644
+--- a/drivers/gpu/drm/radeon/r600_hdmi.c
++++ b/drivers/gpu/drm/radeon/r600_hdmi.c
+@@ -57,15 +57,15 @@ enum r600_hdmi_iec_status_bits {
+ static const struct radeon_hdmi_acr r600_hdmi_predefined_acr[] = {
+     /*	     32kHz	  44.1kHz	48kHz    */
+     /* Clock      N     CTS      N     CTS      N     CTS */
+-    {  25175,  4576,  28125,  7007,  31250,  6864,  28125 }, /*  25,20/1.001 MHz */
++    {  25175,  4096,  25175, 28224, 125875,  6144,  25175 }, /*  25,20/1.001 MHz */
+     {  25200,  4096,  25200,  6272,  28000,  6144,  25200 }, /*  25.20       MHz */
+     {  27000,  4096,  27000,  6272,  30000,  6144,  27000 }, /*  27.00       MHz */
+     {  27027,  4096,  27027,  6272,  30030,  6144,  27027 }, /*  27.00*1.001 MHz */
+     {  54000,  4096,  54000,  6272,  60000,  6144,  54000 }, /*  54.00       MHz */
+     {  54054,  4096,  54054,  6272,  60060,  6144,  54054 }, /*  54.00*1.001 MHz */
+-    {  74176, 11648, 210937, 17836, 234375, 11648, 140625 }, /*  74.25/1.001 MHz */
++    {  74176,  4096,  74176,  5733,  75335,  6144,  74176 }, /*  74.25/1.001 MHz */
+     {  74250,  4096,  74250,  6272,  82500,  6144,  74250 }, /*  74.25       MHz */
+-    { 148352, 11648, 421875,  8918, 234375,  5824, 140625 }, /* 148.50/1.001 MHz */
++    { 148352,  4096, 148352,  5733, 150670,  6144, 148352 }, /* 148.50/1.001 MHz */
+     { 148500,  4096, 148500,  6272, 165000,  6144, 148500 }, /* 148.50       MHz */
+     {      0,  4096,      0,  6272,      0,  6144,      0 }  /* Other */
+ };
+-- 
+1.8.3.1
+
+
+From 05e4776357fe7217e531cbaaa163e24f688d10ce Mon Sep 17 00:00:00 2001
+From: Pierre Ossman <pierre at ossman.eu>
+Date: Wed, 6 Nov 2013 20:09:08 +0100
+Subject: [PATCH 2/2] drm/radeon/audio: improve ACR calculation
+
+In order to have any realistic chance of calculating proper
+ACR values, we need to be able to calculate both N and CTS,
+not just CTS. We still aim for the ideal N as specified in
+the HDMI spec though.
+
+bug:
+https://bugs.freedesktop.org/show_bug.cgi?id=69675
+
+Signed-off-by: Pierre Ossman <pierre at ossman.eu>
+Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
+---
+ drivers/gpu/drm/radeon/r600_hdmi.c | 68 ++++++++++++++++++++++++++------------
+ 1 file changed, 46 insertions(+), 22 deletions(-)
+
+diff --git a/drivers/gpu/drm/radeon/r600_hdmi.c b/drivers/gpu/drm/radeon/r600_hdmi.c
+index e8ca095..92c6df7 100644
+--- a/drivers/gpu/drm/radeon/r600_hdmi.c
++++ b/drivers/gpu/drm/radeon/r600_hdmi.c
+@@ -24,6 +24,7 @@
+  * Authors: Christian König
+  */
+ #include <linux/hdmi.h>
++#include <linux/gcd.h>
+ #include <drm/drmP.h>
+ #include <drm/radeon_drm.h>
+ #include "radeon.h"
+@@ -67,25 +68,47 @@ static const struct radeon_hdmi_acr r600_hdmi_predefined_acr[] = {
+     {  74250,  4096,  74250,  6272,  82500,  6144,  74250 }, /*  74.25       MHz */
+     { 148352,  4096, 148352,  5733, 150670,  6144, 148352 }, /* 148.50/1.001 MHz */
+     { 148500,  4096, 148500,  6272, 165000,  6144, 148500 }, /* 148.50       MHz */
+-    {      0,  4096,      0,  6272,      0,  6144,      0 }  /* Other */
+ };
+ 
++
+ /*
+- * calculate CTS value if it's not found in the table
++ * calculate CTS and N values if they are not found in the table
+  */
+-static void r600_hdmi_calc_cts(uint32_t clock, int *CTS, int N, int freq)
++static void r600_hdmi_calc_cts(uint32_t clock, int *CTS, int *N, int freq)
+ {
+-	u64 n;
+-	u32 d;
+-
+-	if (*CTS == 0) {
+-		n = (u64)clock * (u64)N * 1000ULL;
+-		d = 128 * freq;
+-		do_div(n, d);
+-		*CTS = n;
+-	}
+-	DRM_DEBUG("Using ACR timing N=%d CTS=%d for frequency %d\n",
+-		  N, *CTS, freq);
++	int n, cts;
++	unsigned long div, mul;
++
++	/* Safe, but overly large values */
++	n = 128 * freq;
++	cts = clock * 1000;
++
++	/* Smallest valid fraction */
++	div = gcd(n, cts);
++
++	n /= div;
++	cts /= div;
++
++	/*
++	 * The optimal N is 128*freq/1000. Calculate the closest larger
++	 * value that doesn't truncate any bits.
++	 */
++	mul = ((128*freq/1000) + (n-1))/n;
++
++	n *= mul;
++	cts *= mul;
++
++	/* Check that we are in spec (not always possible) */
++	if (n < (128*freq/1500))
++		printk(KERN_WARNING "Calculated ACR N value is too small. You may experience audio problems.\n");
++	if (n > (128*freq/300))
++		printk(KERN_WARNING "Calculated ACR N value is too large. You may experience audio problems.\n");
++
++	*N = n;
++	*CTS = cts;
++
++	DRM_DEBUG("Calculated ACR timing N=%d CTS=%d for frequency %d\n",
++		  *N, *CTS, freq);
+ }
+ 
+ struct radeon_hdmi_acr r600_hdmi_acr(uint32_t clock)
+@@ -93,15 +116,16 @@ struct radeon_hdmi_acr r600_hdmi_acr(uint32_t clock)
+ 	struct radeon_hdmi_acr res;
+ 	u8 i;
+ 
+-	for (i = 0; r600_hdmi_predefined_acr[i].clock != clock &&
+-	     r600_hdmi_predefined_acr[i].clock != 0; i++)
+-		;
+-	res = r600_hdmi_predefined_acr[i];
++	/* Precalculated values for common clocks */
++	for (i = 0; i < ARRAY_SIZE(r600_hdmi_predefined_acr); i++) {
++		if (r600_hdmi_predefined_acr[i].clock == clock)
++			return r600_hdmi_predefined_acr[i];
++	}
+ 
+-	/* In case some CTS are missing */
+-	r600_hdmi_calc_cts(clock, &res.cts_32khz, res.n_32khz, 32000);
+-	r600_hdmi_calc_cts(clock, &res.cts_44_1khz, res.n_44_1khz, 44100);
+-	r600_hdmi_calc_cts(clock, &res.cts_48khz, res.n_48khz, 48000);
++	/* And odd clocks get manually calculated */
++	r600_hdmi_calc_cts(clock, &res.cts_32khz, &res.n_32khz, 32000);
++	r600_hdmi_calc_cts(clock, &res.cts_44_1khz, &res.n_44_1khz, 44100);
++	r600_hdmi_calc_cts(clock, &res.cts_48khz, &res.n_48khz, 48000);
+ 
+ 	return res;
+ }
+-- 
+1.8.3.1
+
diff --git a/kernel.spec b/kernel.spec
index fe1798b..7e551d4 100644
--- a/kernel.spec
+++ b/kernel.spec
@@ -779,6 +779,7 @@ Patch25129: cpupower-Fix-segfault-due-to-incorrect-getopt_long-a.patch
 
 #rhbz 1010679
 Patch25130: fix-radeon-sound.patch
+Patch25149: drm-radeon-24hz-audio-fixes.patch
 
 #rhbz 1011714
 Patch25131: btrfs-relocate-csums-properly-with-prealloc-ext.patch
@@ -1552,6 +1553,7 @@ ApplyPatch cpupower-Fix-segfault-due-to-incorrect-getopt_long-a.patch
 
 #rhbz 1010679
 ApplyPatch fix-radeon-sound.patch
+ApplyPatch drm-radeon-24hz-audio-fixes.patch
 
 #rhbz 1011714
 ApplyPatch btrfs-relocate-csums-properly-with-prealloc-ext.patch
@@ -2391,6 +2393,7 @@ fi
 #                 ||     ||
 %changelog
 * Mon Nov 18 2013 Josh Boyer <jwboyer at fedoraproject.org>
+- Add patches from Pierre Ossman to fix 24Hz/24p radeon audio (rhbz 1010679)
 - Add patch to fix ALX phy issues after resume (rhbz 1011362)
 - Fix ipv6 sit panic with packet size > mtu (from Michele Baldessari) (rbhz 1015905)
 


More information about the scm-commits mailing list