ALSA: hda - set intel audio clock to a properly value
PATCH 1/1 ALSA: hda - set intel audio clock to a properly value
From: Libin Yang <[email protected]>
On some Intel platforms, the audio clock may not be set correctly with initial setting. This will cause the audio playback/capture rates wrong.
This patch checks the audio clock setting and will set it to a properly value if it is not set correct.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188411
--- include/sound/hda_register.h | 12 +++-- sound/hda/ext/hdac_ext_controller.c | 6 +-- sound/pci/hda/hda_intel.c | 91 +++++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 6 deletions(-)
include/sound/hda_register.h +9 -3
@@ -227,6 +227,8 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };#define AZX_REG_PPLCLLPU 0xC/* registers for Multiple Links Capability Structure */ +/* Multiple Links Capability */ +#define AZX_REG_ML_CAP_BASE 0xc00#define AZX_ML_CAP_ID 0x2#define AZX_REG_ML_MLCH 0x00#define AZX_REG_ML_MLCD 0x04
@@ -243,9 +245,13 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };#define AZX_REG_ML_LOUTPAY 0x20#define AZX_REG_ML_LINPAY 0x30 -#define AZX_MLCTL_SPA (1<<16) -#define AZX_MLCTL_CPA 23 - +#define AZX_REG_ML_LCAPx (x) (AZX_REG_ML_CAP_BASE + (0x40 + 0x40 * x)) +#define AZX_REG_ML_LCTLx (x) (AZX_REG_ML_CAP_BASE + (0x44 + 0x40 * x)) +#define ML_LCTL_SCF_MASK 0xF +#define AZX_MLCTL_SPA (0x1 << 16) +#define AZX_MLCTL_CPA (0x1 << 23) +#define AZX_MLCTL_SPA_SHIFT 16 +#define AZX_MLCTL_CPA_SHIFT 23/* registers for DMA Resume Capability Structure */ #define AZX_DRSM_CAP_ID 0x5
sound/hda/ext/hdac_ext_controller.c +3 -3
@@ -171,7 +171,7 @@ static int check_hdac_link_power_active(struct hdac_ext_link *link, bool enable) {int timeout;u32 val; -int mask = (1 <<AZX_MLCTL_CPA ); +int mask = (1 <<AZX_MLCTL_CPA_SHIFT );udelay (3 ); timeout =150 ;
@@ -179,10 +179,10 @@ static int check_hdac_link_power_active(struct hdac_ext_link *link, bool enable) do { val = readl(link->ml_addr + AZX_REG_ML_LCTL); if (enable) { - if (((val & mask) >> AZX_MLCTL_CPA)) + if (((val & mask) >> AZX_MLCTL_CPA_SHIFT)) return 0; } else { - if (!((val & mask) >> AZX_MLCTL_CPA)) + if (!((val & mask) >> AZX_MLCTL_CPA_SHIFT)) return 0; } udelay(3);
sound/pci/hda/hda_intel.c +91 -0
103 lines not on this page · raw message
Signature · 1 line
2.7.4
Quoted 65 lines · On Tue, 07 Mar 2017 07:20:22 +0100, [email protected] wrote:
From: Libin Yang <[email protected]>
On some Intel platforms, the audio clock may not be set correctly with initial setting. This will cause the audio playback/capture rates wrong.
This patch checks the audio clock setting and will set it to a properly value if it is not set correct.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188411
Signed-off-by Libin Yang <[email protected]>--- include/sound/hda_register.h | 12 +++-- sound/hda/ext/hdac_ext_controller.c | 6 +-- sound/pci/hda/hda_intel.c | 91 +++++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 6 deletions(-)include/sound/hda_register.h +9
-3@@ -227,6 +227,8 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };#define AZX_REG_PPLCLLPU 0xC/* registers for Multiple Links Capability Structure */ +/* Multiple Links Capability */ +#define AZX_REG_ML_CAP_BASE 0xc00#define AZX_ML_CAP_ID 0x2#define AZX_REG_ML_MLCH 0x00#define AZX_REG_ML_MLCD 0x04@@ -243,9 +245,13 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };#define AZX_REG_ML_LOUTPAY 0x20#define AZX_REG_ML_LINPAY 0x30 -#define AZX_MLCTL_SPA (1<<16) -#define AZX_MLCTL_CPA 23 - +#define AZX_REG_ML_LCAPx (x) (AZX_REG_ML_CAP_BASE + (0x40 + 0x40 * x)) +#define AZX_REG_ML_LCTLx (x) (AZX_REG_ML_CAP_BASE + (0x44 + 0x40 * x)) +#define ML_LCTL_SCF_MASK 0xF +#define AZX_MLCTL_SPA (0x1 << 16) +#define AZX_MLCTL_CPA (0x1 << 23) +#define AZX_MLCTL_SPA_SHIFT 16 +#define AZX_MLCTL_CPA_SHIFT 23/* registers for DMA Resume Capability Structure */ #define AZX_DRSM_CAP_ID 0x5sound/hda/ext/hdac_ext_controller.c +1
-1@@ -171,7 +171,7 @@ static int check_hdac_link_power_active(struct hdac_ext_link *link, bool enable) {int timeout;u32 val; -int mask = (1 <<AZX_MLCTL_CPA ); +int mask = (1 <<AZX_MLCTL_CPA_SHIFT );udelay (3 ); timeout =150 ;@@ -179,10 +179,10 @@ static int check_hdac_link_power_active(struct hdac_ext_link *link, bool enable) do { val = readl(link->ml_addr + AZX_REG_ML_LCTL);
sound/hda/ext/hdac_ext_controller.c static int check_hdac_link_power_active(struct hdac_ext_link *link, bool enable) · line 188
Quoted 10 lines
sound/hda/ext/hdac_ext_controller.c +2
-2if (enable) { -if (((val & mask) >>AZX_MLCTL_CPA )) +if (((val & mask) >>AZX_MLCTL_CPA_SHIFT ))return 0 ; }else { -if (!((val & mask) >>AZX_MLCTL_CPA )) +if (!((val & mask) >>AZX_MLCTL_CPA_SHIFT ))return 0 ; }udelay (3 );
These changes are rather to fix the inconsistencies between CPA and SPA register definitions. Better to split as a preliminary cleanup patch (i.e. define AZX_MLCTL_SPA, *_CPA and *_SHIFT properly and adapt to them).
Quoted 23 lines
sound/pci/hda/hda_intel.c +15
-0@@ -539,6 +539,94 @@ static void bxt_reduce_dma_latency(struct azx *chip)azx_writel (chip,SKL_EM4L , val); } +/* +* ML_LCAP bits: +* bit 0: 6 MHz Supported +* bit 1: 12 MHz Supported +* bit 2: 24 MHz Supported +* bit 3: 48 MHz Supported +* bit 4: 96 MHz Supported +* bit 5: 192 MHz Supported +*/ +static int intel_get_lctl_scf (struct azx *chip) +{ +u32 val; + + val =azx_readl (chip,ML_LCAPx (0 )); +
sound/pci/hda/hda_intel.c static void bxt_reduce_dma_latency(struct azx *chip) · line 566
Quoted 10 lines
sound/pci/hda/hda_intel.c +10
-0+if (val & (1 <<2 )) +return 2 ; +else if (val & (1 <<3 )) +return 3 ; +else if (val & (1 <<1 )) +return 1 ; +else if (val & (1 <<4 )) +return 4 ; +else if (val & (1 <<5 )) +return 5 ;
I guess a loop is cleaner and error-prone, e.g.:
static int preferred_bits[] = { 2, 3, 1, 4, 5 };
int i;
for (i = 0; i < ARRAY_SIZE(preferred_bits); i++)
if (val & (1 << i))
return i;
return 0;Quoted 9 lines
sound/pci/hda/hda_intel.c +9
-0+ +dev_warn (chip->card->dev,"set audio clock frequency to 6MHz" ); +return 0 ; +} + +static void intel_init_lctl (struct azx *chip) +{ +u32 val; +int timeout;
sound/pci/hda/hda_intel.c static void bxt_reduce_dma_latency(struct azx *chip) · line 585
Quoted 10 lines
sound/pci/hda/hda_intel.c +10
-0+ +/* 0. check lctl register value is correct or not */ +/* the codecs are sharing the first link setting by default */ + val =azx_readl (chip,ML_LCTLx (0 )); +/* if SCF is already set, let's use it */ +if ((val &ML_LCTL_SCF_MASK ) !=0 ) +return ; + +/* +* Before operatiing on SPA, CPA must match SPA.
operating.
sound/pci/hda/hda_intel.c static void bxt_reduce_dma_latency(struct azx *chip) · line 589
Quoted 4 lines
sound/pci/hda/hda_intel.c +4
-0+* Any deviation may result in undefined behavior. +*/ +if (((val &AZX_MLCTL_SPA ) >>AZX_MLCTL_SPA_SHIFT ) ^ + ((val &AZX_MLCTL_CPA ) >>AZX_MLCTL_CPA_SHIFT ))
Should it be better with "==" instead of XOR here?
Quoted 15 lines
sound/pci/hda/hda_intel.c +15
-0+return ; + +/* 1. turn link down: set SPA to 0 and wait CPA to 0 */ + val =azx_readl (chip,ML_LCTLx (0 )); + val &= ~AZX_MLCTL_SPA ; +azx_writel (chip,ML_LCTLx (0 ), val); +/* wait for CPA */ + timeout =50 ; +while (timeout) { +if ((azx_readl (chip,ML_LCTLx (0 )) &AZX_MLCTL_CPA ) ==0 ) +break ; + timeout--; +udelay (10 ); + } +if (!timeout)
sound/pci/hda/hda_intel.c static void bxt_reduce_dma_latency(struct azx *chip) · line 614
Quoted 10 lines
sound/pci/hda/hda_intel.c +10
-0+ goto SET_SPA; +/* need add 100ns delay for hardware ready */ +udelay (100 ); + +/* 2. update SCF to select a properly audio clock*/ + val &= ~ML_LCTL_SCF_MASK ; + val |=intel_get_lctl_scf (chip); +azx_writel (chip,ML_LCTLx (0 ), val); + +SET_SPA:
Use lower letters for a label.
sound/pci/hda/hda_intel.c static void bxt_reduce_dma_latency(struct azx *chip) · line 627
Quoted 13 lines
sound/pci/hda/hda_intel.c +13
-0+/* 4. turn link up: set SPA to 1 and wait CPA to 1 */ + val =azx_readl (chip,ML_LCTLx (0 )); + val |=AZX_MLCTL_SPA ; +azx_writel (chip,ML_LCTLx (0 ), val); + timeout =50 ; +while (timeout) { +if ((azx_readl (chip,ML_LCTLx (0 )) &AZX_MLCTL_CPA ) !=0 ) +break ; + timeout--; +udelay (10 ); + } +/* need add 100ns delay for hardware ready */ +udelay (100 );
Well, both clearing and setting SPA are almost the same procedure, so better to factor out a small function for that, IMO.
thanks,
Takashi
Hi Takashi,
Thanks for review and please see my comments inline.
I'm OOO currently and I will send the updated one next week.
Quoted 81 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Monday, March 20, 2017 5:51 PM
To: Yang, Libin <[email protected]>
Cc: [email protected]; Lin, Mengdong <[email protected]>; [email protected]
Subject: Re: [alsa-devel] [PATCH] ALSA: hda - set intel audio clock to a properly valueQuoted 10 lines · On Tue, 07 Mar 2017 07:20:22 +0100, [email protected] wrote:
From: Libin Yang <[email protected]>
On some Intel platforms, the audio clock may not be set correctly with initial setting. This will cause the audio playback/capture rates wrong.
This patch checks the audio clock setting and will set it to a properly value if it is not set correct.
Quoted 7 lines
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188411
Signed-off-by Libin Yang <[email protected]>--- include/sound/hda_register.h | 12 +++-- sound/hda/ext/hdac_ext_controller.c | 6 +-- sound/pci/hda/hda_intel.c | 91+++++++++++++++++++++++++++++++++++++
include/sound/hda_register.h enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2,
Quoted 7 lines
3 files changed, 103 insertions(+), 6 deletions(-)(quoted diff) +0
-0
b/include/sound/hda_register.hindex 0013063..7ea16cb 100644include/sound/hda_register.h +0
-0@@ -227,6 +227,8 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2,SDO3 };
include/sound/hda_register.h enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2,
Quoted 9 lines
include/sound/hda_register.h +2
-0#define AZX_REG_PPLCLLPU 0xC/* registers for Multiple Links Capability Structure */ +/* Multiple Links Capability */ +#define AZX_REG_ML_CAP_BASE 0xc00#define AZX_ML_CAP_ID 0x2#define AZX_REG_ML_MLCH 0x00#define AZX_REG_ML_MLCD 0x04@@ -243,9 +245,13 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2,SDO3 };
include/sound/hda_register.h enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
Quoted 7 lines
include/sound/hda_register.h +1
-3#define AZX_REG_ML_LOUTPAY 0x20#define AZX_REG_ML_LINPAY 0x30 -#define AZX_MLCTL_SPA (1<<16) -#define AZX_MLCTL_CPA 23 - +#define AZX_REG_ML_LCAPx (x) (AZX_REG_ML_CAP_BASE + (0x40 +
0x40* x))include/sound/hda_register.h enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, · line 249
Quoted 1 line
include/sound/hda_register.h +1
-0+#define AZX_REG_ML_LCTLx (x) (AZX_REG_ML_CAP_BASE + (0x44 +
0x40* x))sound/hda/ext/hdac_ext_controller.c static int check_hdac_link_power_active(struct
Quoted 23 lines
include/sound/hda_register.h +5
-0+#define ML_LCTL_SCF_MASK 0xF +#define AZX_MLCTL_SPA (0x1 << 16) +#define AZX_MLCTL_CPA (0x1 << 23) +#define AZX_MLCTL_SPA_SHIFT 16 +#define AZX_MLCTL_CPA_SHIFT 23/* registers for DMA Resume Capability Structure */ #define AZX_DRSM_CAP_ID 0x5sound/hda/ext/hdac_ext_controller.c +1
-1@@ -171,7 +171,7 @@ static int check_hdac_link_power_active(struct hdac_ext_link *link, bool enable) { int timeout;u32 val; -int mask = (1 <<AZX_MLCTL_CPA ); +int mask = (1 <<AZX_MLCTL_CPA_SHIFT );udelay (3 ); timeout =150 ;@@ -179,10 +179,10 @@ static int check_hdac_link_power_active(struct
hdac_ext_link*link, bool enable)
Quoted 16 lines
sound/hda/ext/hdac_ext_controller.c static int check_hdac_link_power_active(struct hdac_ext_link *link, bool enable) · line 188
Quoted 12 lines
sound/hda/ext/hdac_ext_controller.c +2
-2do { val = readl(link->ml_addr + AZX_REG_ML_LCTL); if (enable) { - if (((val & mask) >> AZX_MLCTL_CPA)) + if (((val & mask) >> AZX_MLCTL_CPA_SHIFT)) return 0; } else { - if (!((val & mask) >> AZX_MLCTL_CPA)) + if (!((val & mask) >> AZX_MLCTL_CPA_SHIFT)) return 0; } udelay(3);These changes are rather to fix the inconsistencies between CPA and SPA register definitions. Better to split as a preliminary cleanup patch (i.e. define
AZX_MLCTL_SPA,*_CPAand*_SHIFTproperly and adapt to them).
Yes. I will do it.
Quoted 38 lines
sound/pci/hda/hda_intel.c static void bxt_reduce_dma_latency(struct azx
Quoted 7 lines
sound/pci/hda/hda_intel.c +0
-0@@ -539,6 +539,94 @@ static void bxt_reduce_dma_latency(struct azx*chip)
Quoted 17 lines
sound/pci/hda/hda_intel.c +14
-0azx_writel (chip,SKL_EM4L , val); } +/* +* ML_LCAP bits: +* bit 0: 6 MHz Supported +* bit 1: 12 MHz Supported +* bit 2: 24 MHz Supported +* bit 3: 48 MHz Supported +* bit 4: 96 MHz Supported +* bit 5: 192 MHz Supported +*/ +static int intel_get_lctl_scf (struct azx *chip) { +u32 val; + + val =azx_readl (chip,ML_LCAPx (0 )); +sound/pci/hda/hda_intel.c static void bxt_reduce_dma_latency(struct azx *chip) · line 566
Quoted 10 lines
sound/pci/hda/hda_intel.c +10
-0+if (val & (1 <<2 )) +return 2 ; +else if (val & (1 <<3 )) +return 3 ; +else if (val & (1 <<1 )) +return 1 ; +else if (val & (1 <<4 )) +return 4 ; +else if (val & (1 <<5 )) +return 5 ;I guess a loop is cleaner and error-prone, e.g.:
Quoted 8 lines
static int preferred_bits[] = { 2, 3, 1, 4, 5 };
int i;
for (i = 0; i < ARRAY_SIZE(preferred_bits); i++)
if (val & (1 << i))
return i;
return 0;OK. I will do it.
Quoted 13 lines
Quoted 13 lines
sound/pci/hda/hda_intel.c +12
-0+ +dev_warn (chip->card->dev,"set audio clock frequency to 6MHz" ); +return 0 ; +} + +static void intel_init_lctl (struct azx *chip) { +u32 val; +int timeout; + +/* 0. check lctl register value is correct or not */ +/* the codecs are sharing the first link setting by default */ + val =azx_readl (chip,ML_LCTLx (0 ));
Quoted 8 lines
sound/pci/hda/hda_intel.c static void bxt_reduce_dma_latency(struct azx *chip) · line 585
Quoted 6 lines
sound/pci/hda/hda_intel.c +6
-0+/* if SCF is already set, let's use it */ +if ((val &ML_LCTL_SCF_MASK ) !=0 ) +return ; + +/* +* Before operatiing on SPA, CPA must match SPA. operating.
Yes, my typo.
Quoted 7 lines
sound/pci/hda/hda_intel.c static void bxt_reduce_dma_latency(struct azx *chip) · line 589
Quoted 5 lines
sound/pci/hda/hda_intel.c +4
-0+* Any deviation may result in undefined behavior. +*/ +if (((val &AZX_MLCTL_SPA ) >>AZX_MLCTL_SPA_SHIFT ) ^ + ((val &AZX_MLCTL_CPA ) >>AZX_MLCTL_CPA_SHIFT ))Should it be better with "==" instead of XOR here?
AZX_MLCTL_SPA bit value should be the same with AZX_MLCTL_CPA bit value before operation. If they are different, we should not touch this register. So if XOR is true, we should return directly.
Quoted 20 lines
Quoted 20 lines
sound/pci/hda/hda_intel.c +19
-0+return ; + +/* 1. turn link down: set SPA to 0 and wait CPA to 0 */ + val =azx_readl (chip,ML_LCTLx (0 )); + val &= ~AZX_MLCTL_SPA ; +azx_writel (chip,ML_LCTLx (0 ), val); +/* wait for CPA */ + timeout =50 ; +while (timeout) { +if ((azx_readl (chip,ML_LCTLx (0 )) &AZX_MLCTL_CPA ) ==0 ) +break ; + timeout--; +udelay (10 ); + } +if (!timeout) + goto SET_SPA; +/* need add 100ns delay for hardware ready */ +udelay (100 ); +
Quoted 8 lines
sound/pci/hda/hda_intel.c static void bxt_reduce_dma_latency(struct azx *chip) · line 614
Quoted 6 lines
sound/pci/hda/hda_intel.c +6
-0+/* 2. update SCF to select a properly audio clock*/ + val &= ~ML_LCTL_SCF_MASK ; + val |=intel_get_lctl_scf (chip); +azx_writel (chip,ML_LCTLx (0 ), val); + +SET_SPA:Use lower letters for a label.
OK.
Quoted 18 lines
Quoted 5 lines
sound/pci/hda/hda_intel.c +3
-0+/* 4. turn link up: set SPA to 1 and wait CPA to 1 */ + val =azx_readl (chip,ML_LCTLx (0 )); + val |=AZX_MLCTL_SPA ;sound/pci/hda/hda_intel.c static void bxt_reduce_dma_latency(struct azx *chip) · line 627
Quoted 10 lines
sound/pci/hda/hda_intel.c +10
-0+azx_writel (chip,ML_LCTLx (0 ), val); + timeout =50 ; +while (timeout) { +if ((azx_readl (chip,ML_LCTLx (0 )) &AZX_MLCTL_CPA ) !=0 ) +break ; + timeout--; +udelay (10 ); + } +/* need add 100ns delay for hardware ready */ +udelay (100 );Well, both clearing and setting SPA are almost the same procedure, so better to factor out a small function for that, IMO.
OK, I will do it. Thanks for suggestion
Best Regards,
Libin
Quoted 5 lines
thanks,
Takashi
Hi Libin,
One generic comment.
This patch uses the enhanced capability structure and so instead of using IS_SKL_PLUS() to check the capability it is better to check the ppcap. All the SKL platforms may not be having the enhanced capability structure.
Regards,
Rakesh
Quoted 267 lines
-----Original Message-----
From: [email protected] [mailto:alsa-devel-bounces@alsa- project.org] On Behalf Of Yang, Libin
Sent: Tuesday, March 21, 2017 9:11 AM
To: Takashi Iwai <[email protected]>
Cc: Lin, Mengdong <[email protected]>; [email protected]; [email protected]
Subject: Re: [alsa-devel] [PATCH] ALSA: hda - set intel audio clock to a properly valueHi Takashi,
Thanks for review and please see my comments inline.
I'm OOO currently and I will send the updated one next week.
Quoted 7 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Monday, March 20, 2017 5:51 PM
To: Yang, Libin <[email protected]>
Cc: [email protected]; Lin, Mengdong <[email protected]>; [email protected]
Subject: Re: [alsa-devel] [PATCH] ALSA: hda - set intel audio clock to aproperly
Quoted 32 lines
value
Quoted 10 lines · On Tue, 07 Mar 2017 07:20:22 +0100, [email protected] wrote:
From: Libin Yang <[email protected]>
On some Intel platforms, the audio clock may not be set correctly with initial setting. This will cause the audio playback/capture rates wrong.
This patch checks the audio clock setting and will set it to a properly value if it is not set correct.
Quoted 7 lines
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188411
Signed-off-by Libin Yang <[email protected]>--- include/sound/hda_register.h | 12 +++-- sound/hda/ext/hdac_ext_controller.c | 6 +-- sound/pci/hda/hda_intel.c | 91+++++++++++++++++++++++++++++++++++++
include/sound/hda_register.h enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2,
Quoted 7 lines
3 files changed, 103 insertions(+), 6 deletions(-)(quoted diff) +0
-0
b/include/sound/hda_register.hindex 0013063..7ea16cb 100644include/sound/hda_register.h +0
-0@@ -227,6 +227,8 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2,SDO3 };
Quoted 2 lines
include/sound/hda_register.h +0
-0#define AZX_REG_PPLCLLPU 0xCQuoted 7 lines
include/sound/hda_register.h enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1,
Quoted 7 lines
include/sound/hda_register.h +2
-0/* registers for Multiple Links Capability Structure */ +/* Multiple Links Capability */ +#define AZX_REG_ML_CAP_BASE 0xc00#define AZX_ML_CAP_ID 0x2#define AZX_REG_ML_MLCH 0x00#define AZX_REG_ML_MLCD 0x04@@ -243,9 +245,13 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1,SDO2,
Quoted 35 lines
SDO3 };
include/sound/hda_register.h enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
Quoted 7 lines
include/sound/hda_register.h +1
-3#define AZX_REG_ML_LOUTPAY 0x20#define AZX_REG_ML_LINPAY 0x30 -#define AZX_MLCTL_SPA (1<<16) -#define AZX_MLCTL_CPA 23 - +#define AZX_REG_ML_LCAPx (x) (AZX_REG_ML_CAP_BASE + (0x40 +
0x40* x))include/sound/hda_register.h enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, · line 249
Quoted 1 line
include/sound/hda_register.h +1
-0+#define AZX_REG_ML_LCTLx (x) (AZX_REG_ML_CAP_BASE + (0x44 +
0x40* x))sound/hda/ext/hdac_ext_controller.c static int check_hdac_link_power_active(struct
Quoted 23 lines
include/sound/hda_register.h +5
-0+#define ML_LCTL_SCF_MASK 0xF +#define AZX_MLCTL_SPA (0x1 << 16) +#define AZX_MLCTL_CPA (0x1 << 23) +#define AZX_MLCTL_SPA_SHIFT 16 +#define AZX_MLCTL_CPA_SHIFT 23/* registers for DMA Resume Capability Structure */ #define AZX_DRSM_CAP_ID 0x5sound/hda/ext/hdac_ext_controller.c +1
-1@@ -171,7 +171,7 @@ static int check_hdac_link_power_active(struct hdac_ext_link *link, bool enable) { int timeout;u32 val; -int mask = (1 <<AZX_MLCTL_CPA ); +int mask = (1 <<AZX_MLCTL_CPA_SHIFT );udelay (3 ); timeout =150 ;@@ -179,10 +179,10 @@ static int check_hdac_link_power_active(struct
hdac_ext_link*link, bool enable)Quoted 16 lines
sound/hda/ext/hdac_ext_controller.c static int check_hdac_link_power_active(struct hdac_ext_link *link, bool enable) · line 188
Quoted 12 lines
sound/hda/ext/hdac_ext_controller.c +2
-2do { val = readl(link->ml_addr + AZX_REG_ML_LCTL); if (enable) { - if (((val & mask) >> AZX_MLCTL_CPA)) + if (((val & mask) >> AZX_MLCTL_CPA_SHIFT)) return 0; } else { - if (!((val & mask) >> AZX_MLCTL_CPA)) + if (!((val & mask) >> AZX_MLCTL_CPA_SHIFT)) return 0; } udelay(3);These changes are rather to fix the inconsistencies between CPA and SPA register definitions. Better to split as a preliminary cleanup patch (i.e. define
AZX_MLCTL_SPA,*_CPAand*_SHIFTproperly and adapt to them).Yes. I will do it.
Quoted 38 lines
sound/pci/hda/hda_intel.c static void bxt_reduce_dma_latency(struct azx
Quoted 7 lines
sound/pci/hda/hda_intel.c +0
-0@@ -539,6 +539,94 @@ static void bxt_reduce_dma_latency(struct azx*chip)
Quoted 17 lines
sound/pci/hda/hda_intel.c +14
-0azx_writel (chip,SKL_EM4L , val); } +/* +* ML_LCAP bits: +* bit 0: 6 MHz Supported +* bit 1: 12 MHz Supported +* bit 2: 24 MHz Supported +* bit 3: 48 MHz Supported +* bit 4: 96 MHz Supported +* bit 5: 192 MHz Supported +*/ +static int intel_get_lctl_scf (struct azx *chip) { +u32 val; + + val =azx_readl (chip,ML_LCAPx (0 )); +sound/pci/hda/hda_intel.c static void bxt_reduce_dma_latency(struct azx *chip) · line 566
Quoted 10 lines
sound/pci/hda/hda_intel.c +10
-0+if (val & (1 <<2 )) +return 2 ; +else if (val & (1 <<3 )) +return 3 ; +else if (val & (1 <<1 )) +return 1 ; +else if (val & (1 <<4 )) +return 4 ; +else if (val & (1 <<5 )) +return 5 ;I guess a loop is cleaner and error-prone, e.g.:
Quoted 8 lines
static int preferred_bits[] = { 2, 3, 1, 4, 5 }; int i; for (i = 0; i < ARRAY_SIZE(preferred_bits); i++) if (val & (1 << i)) return i; return 0;OK. I will do it.
Quoted 13 lines
Quoted 13 lines
sound/pci/hda/hda_intel.c +12
-0+ +dev_warn (chip->card->dev,"set audio clock frequency to 6MHz" ); +return 0 ; +} + +static void intel_init_lctl (struct azx *chip) { +u32 val; +int timeout; + +/* 0. check lctl register value is correct or not */ +/* the codecs are sharing the first link setting by default */ + val =azx_readl (chip,ML_LCTLx (0 ));Quoted 8 lines
sound/pci/hda/hda_intel.c static void bxt_reduce_dma_latency(struct azx *chip) · line 585
Quoted 6 lines
sound/pci/hda/hda_intel.c +6
-0+/* if SCF is already set, let's use it */ +if ((val &ML_LCTL_SCF_MASK ) !=0 ) +return ; + +/* +* Before operatiing on SPA, CPA must match SPA. operating.
Yes, my typo.
Quoted 7 lines
sound/pci/hda/hda_intel.c static void bxt_reduce_dma_latency(struct azx *chip) · line 589
Quoted 5 lines
sound/pci/hda/hda_intel.c +4
-0+* Any deviation may result in undefined behavior. +*/ +if (((val &AZX_MLCTL_SPA ) >>AZX_MLCTL_SPA_SHIFT ) ^ + ((val &AZX_MLCTL_CPA ) >>AZX_MLCTL_CPA_SHIFT ))Should it be better with "==" instead of XOR here?
AZX_MLCTL_SPAbit value should be the same withAZX_MLCTL_CPAbit value before operation. If they are different, we should not touch this register. So if XOR is true, we should return directly.Quoted 20 lines
Quoted 20 lines
sound/pci/hda/hda_intel.c +19
-0+return ; + +/* 1. turn link down: set SPA to 0 and wait CPA to 0 */ + val =azx_readl (chip,ML_LCTLx (0 )); + val &= ~AZX_MLCTL_SPA ; +azx_writel (chip,ML_LCTLx (0 ), val); +/* wait for CPA */ + timeout =50 ; +while (timeout) { +if ((azx_readl (chip,ML_LCTLx (0 )) &AZX_MLCTL_CPA ) ==0 ) +break ; + timeout--; +udelay (10 ); + } +if (!timeout) + goto SET_SPA; +/* need add 100ns delay for hardware ready */ +udelay (100 ); +Quoted 8 lines
sound/pci/hda/hda_intel.c static void bxt_reduce_dma_latency(struct azx *chip) · line 614
Quoted 6 lines
sound/pci/hda/hda_intel.c +6
-0+/* 2. update SCF to select a properly audio clock*/ + val &= ~ML_LCTL_SCF_MASK ; + val |=intel_get_lctl_scf (chip); +azx_writel (chip,ML_LCTLx (0 ), val); + +SET_SPA:Use lower letters for a label.
OK.
Quoted 18 lines
Quoted 5 lines
sound/pci/hda/hda_intel.c +3
-0+/* 4. turn link up: set SPA to 1 and wait CPA to 1 */ + val =azx_readl (chip,ML_LCTLx (0 )); + val |=AZX_MLCTL_SPA ;sound/pci/hda/hda_intel.c static void bxt_reduce_dma_latency(struct azx *chip) · line 627
Quoted 10 lines
sound/pci/hda/hda_intel.c +10
-0+azx_writel (chip,ML_LCTLx (0 ), val); + timeout =50 ; +while (timeout) { +if ((azx_readl (chip,ML_LCTLx (0 )) &AZX_MLCTL_CPA ) !=0 ) +break ; + timeout--; +udelay (10 ); + } +/* need add 100ns delay for hardware ready */ +udelay (100 );Well, both clearing and setting SPA are almost the same procedure, so better to factor out a small function for that, IMO.
OK, I will do it. Thanks for suggestion
Best Regards,
LibinQuoted 5 lines
thanks,
Takashi
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
HI Rakesh,
Get it. Thanks. I will check it.
Regards,
Libin
Quoted 290 lines
-----Original Message-----
From: Ughreja, Rakesh A
Sent: Wednesday, March 22, 2017 12:35 AM
To: Yang, Libin <[email protected]>; Takashi Iwai <[email protected]>
Cc: Lin, Mengdong <[email protected]>; [email protected]; [email protected]
Subject: RE: [alsa-devel] [PATCH] ALSA: hda - set intel audio clock to a properly valueHi Libin,
One generic comment.
This patch uses the enhanced capability structure and so instead of using
IS_SKL_PLUS()to check the capability it is better to check the ppcap. All the SKL platforms may not be having the enhanced capability structure.Regards,
RakeshQuoted 57 lines
-----Original Message-----
From: [email protected] [mailto:alsa-devel-bounces@alsa- project.org] On Behalf Of Yang, Libin
Sent: Tuesday, March 21, 2017 9:11 AM
To: Takashi Iwai <[email protected]>
Cc: Lin, Mengdong <[email protected]>; [email protected]; [email protected]
Subject: Re: [alsa-devel] [PATCH] ALSA: hda - set intel audio clock to a properly valueHi Takashi,
Thanks for review and please see my comments inline.
I'm OOO currently and I will send the updated one next week.
Quoted 8 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Monday, March 20, 2017 5:51 PM
To: Yang, Libin <[email protected]>
Cc: [email protected]; Lin, Mengdong <[email protected]>; [email protected]
Subject: Re: [alsa-devel] [PATCH] ALSA: hda - set intel audio clock to aproperly
Quoted 32 lines
value
Quoted 10 lines · On Tue, 07 Mar 2017 07:20:22 +0100, [email protected] wrote:
From: Libin Yang <[email protected]>
On some Intel platforms, the audio clock may not be set correctly with initial setting. This will cause the audio playback/capture rates wrong.
This patch checks the audio clock setting and will set it to a properly value if it is not set correct.
Quoted 7 lines
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188411
Signed-off-by Libin Yang <[email protected]>--- include/sound/hda_register.h | 12 +++-- sound/hda/ext/hdac_ext_controller.c | 6 +-- sound/pci/hda/hda_intel.c | 91+++++++++++++++++++++++++++++++++++++
include/sound/hda_register.h enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2,
Quoted 7 lines
3 files changed, 103 insertions(+), 6 deletions(-)(quoted diff) +0
-0
b/include/sound/hda_register.hindex 0013063..7ea16cb 100644include/sound/hda_register.h +0
-0@@ -227,6 +227,8 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2,SDO3 };
Quoted 2 lines
include/sound/hda_register.h +0
-0#define AZX_REG_PPLCLLPU 0xCQuoted 59 lines
Quoted 7 lines
include/sound/hda_register.h enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1,
Quoted 7 lines
include/sound/hda_register.h +2
-0/* registers for Multiple Links Capability Structure */ +/* Multiple Links Capability */ +#define AZX_REG_ML_CAP_BASE 0xc00#define AZX_ML_CAP_ID 0x2#define AZX_REG_ML_MLCH 0x00#define AZX_REG_ML_MLCD 0x04@@ -243,9 +245,13 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1,SDO2,
Quoted 51 lines
SDO3 };
include/sound/hda_register.h enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
Quoted 7 lines
include/sound/hda_register.h +1
-3#define AZX_REG_ML_LOUTPAY 0x20#define AZX_REG_ML_LINPAY 0x30 -#define AZX_MLCTL_SPA (1<<16) -#define AZX_MLCTL_CPA 23 - +#define AZX_REG_ML_LCAPx (x) (AZX_REG_ML_CAP_BASE + (0x40 +
0x40* x))include/sound/hda_register.h enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, · line 249
Quoted 1 line
include/sound/hda_register.h +1
-0+#define AZX_REG_ML_LCTLx (x) (AZX_REG_ML_CAP_BASE + (0x44 +
0x40* x))sound/hda/ext/hdac_ext_controller.c static int check_hdac_link_power_active(struct
Quoted 23 lines
include/sound/hda_register.h +5
-0+#define ML_LCTL_SCF_MASK 0xF +#define AZX_MLCTL_SPA (0x1 << 16) +#define AZX_MLCTL_CPA (0x1 << 23) +#define AZX_MLCTL_SPA_SHIFT 16 +#define AZX_MLCTL_CPA_SHIFT 23/* registers for DMA Resume Capability Structure */ #define AZX_DRSM_CAP_ID 0x5sound/hda/ext/hdac_ext_controller.c +1
-1@@ -171,7 +171,7 @@ static int check_hdac_link_power_active(struct hdac_ext_link *link, bool enable) { int timeout;u32 val; -int mask = (1 <<AZX_MLCTL_CPA ); +int mask = (1 <<AZX_MLCTL_CPA_SHIFT );udelay (3 ); timeout =150 ;@@ -179,10 +179,10 @@ static int check_hdac_link_power_active(struct
hdac_ext_link*link, bool enable)sound/hda/ext/hdac_ext_controller.c static int check_hdac_link_power_active(struct hdac_ext_link *link, bool enable) · line 188
Quoted 12 lines
sound/hda/ext/hdac_ext_controller.c +2
-2do { val = readl(link->ml_addr + AZX_REG_ML_LCTL); if (enable) { - if (((val & mask) >> AZX_MLCTL_CPA)) + if (((val & mask) >> AZX_MLCTL_CPA_SHIFT)) return 0; } else { - if (!((val & mask) >> AZX_MLCTL_CPA)) + if (!((val & mask) >> AZX_MLCTL_CPA_SHIFT)) return 0; } udelay(3);These changes are rather to fix the inconsistencies between CPA and SPA register definitions. Better to split as a preliminary cleanup patch (i.e. define
AZX_MLCTL_SPA,*_CPAand*_SHIFTproperly and adaptto them).
Quoted 152 lines
Yes. I will do it.
Quoted 38 lines
sound/pci/hda/hda_intel.c static void bxt_reduce_dma_latency(struct azx
Quoted 7 lines
sound/pci/hda/hda_intel.c +0
-0@@ -539,6 +539,94 @@ static void bxt_reduce_dma_latency(struct azx*chip)
Quoted 17 lines
sound/pci/hda/hda_intel.c +14
-0azx_writel (chip,SKL_EM4L , val); } +/* +* ML_LCAP bits: +* bit 0: 6 MHz Supported +* bit 1: 12 MHz Supported +* bit 2: 24 MHz Supported +* bit 3: 48 MHz Supported +* bit 4: 96 MHz Supported +* bit 5: 192 MHz Supported +*/ +static int intel_get_lctl_scf (struct azx *chip) { +u32 val; + + val =azx_readl (chip,ML_LCAPx (0 )); +sound/pci/hda/hda_intel.c static void bxt_reduce_dma_latency(struct azx *chip) · line 566
Quoted 10 lines
sound/pci/hda/hda_intel.c +10
-0+if (val & (1 <<2 )) +return 2 ; +else if (val & (1 <<3 )) +return 3 ; +else if (val & (1 <<1 )) +return 1 ; +else if (val & (1 <<4 )) +return 4 ; +else if (val & (1 <<5 )) +return 5 ;I guess a loop is cleaner and error-prone, e.g.:
Quoted 8 lines
static int preferred_bits[] = { 2, 3, 1, 4, 5 }; int i; for (i = 0; i < ARRAY_SIZE(preferred_bits); i++) if (val & (1 << i)) return i; return 0;OK. I will do it.
Quoted 13 lines
Quoted 13 lines
sound/pci/hda/hda_intel.c +12
-0+ +dev_warn (chip->card->dev,"set audio clock frequency to 6MHz" ); +return 0 ; +} + +static void intel_init_lctl (struct azx *chip) { +u32 val; +int timeout; + +/* 0. check lctl register value is correct or not */ +/* the codecs are sharing the first link setting by default */ + val =azx_readl (chip,ML_LCTLx (0 ));Quoted 8 lines
sound/pci/hda/hda_intel.c static void bxt_reduce_dma_latency(struct azx *chip) · line 585
Quoted 6 lines
sound/pci/hda/hda_intel.c +6
-0+/* if SCF is already set, let's use it */ +if ((val &ML_LCTL_SCF_MASK ) !=0 ) +return ; + +/* +* Before operatiing on SPA, CPA must match SPA. operating.
Yes, my typo.
Quoted 7 lines
sound/pci/hda/hda_intel.c static void bxt_reduce_dma_latency(struct azx *chip) · line 589
Quoted 5 lines
sound/pci/hda/hda_intel.c +4
-0+* Any deviation may result in undefined behavior. +*/ +if (((val &AZX_MLCTL_SPA ) >>AZX_MLCTL_SPA_SHIFT ) ^ + ((val &AZX_MLCTL_CPA ) >>AZX_MLCTL_CPA_SHIFT ))Should it be better with "==" instead of XOR here?
AZX_MLCTL_SPAbit value should be the same withAZX_MLCTL_CPAbit value before operation. If they are different, we should not touch this register. So if XOR is true, we should return directly.Quoted 20 lines
Quoted 20 lines
sound/pci/hda/hda_intel.c +19
-0+return ; + +/* 1. turn link down: set SPA to 0 and wait CPA to 0 */ + val =azx_readl (chip,ML_LCTLx (0 )); + val &= ~AZX_MLCTL_SPA ; +azx_writel (chip,ML_LCTLx (0 ), val); +/* wait for CPA */ + timeout =50 ; +while (timeout) { +if ((azx_readl (chip,ML_LCTLx (0 )) &AZX_MLCTL_CPA ) ==0 ) +break ; + timeout--; +udelay (10 ); + } +if (!timeout) + goto SET_SPA; +/* need add 100ns delay for hardware ready */ +udelay (100 ); +Quoted 8 lines
sound/pci/hda/hda_intel.c static void bxt_reduce_dma_latency(struct azx *chip) · line 614
Quoted 6 lines
sound/pci/hda/hda_intel.c +6
-0+/* 2. update SCF to select a properly audio clock*/ + val &= ~ML_LCTL_SCF_MASK ; + val |=intel_get_lctl_scf (chip); +azx_writel (chip,ML_LCTLx (0 ), val); + +SET_SPA:Use lower letters for a label.
OK.
Quoted 18 lines
Quoted 5 lines
sound/pci/hda/hda_intel.c +3
-0+/* 4. turn link up: set SPA to 1 and wait CPA to 1 */ + val =azx_readl (chip,ML_LCTLx (0 )); + val |=AZX_MLCTL_SPA ;sound/pci/hda/hda_intel.c static void bxt_reduce_dma_latency(struct azx *chip) · line 627
Quoted 10 lines
sound/pci/hda/hda_intel.c +10
-0+azx_writel (chip,ML_LCTLx (0 ), val); + timeout =50 ; +while (timeout) { +if ((azx_readl (chip,ML_LCTLx (0 )) &AZX_MLCTL_CPA ) !=0 ) +break ; + timeout--; +udelay (10 ); + } +/* need add 100ns delay for hardware ready */ +udelay (100 );Well, both clearing and setting SPA are almost the same procedure, so better to factor out a small function for that, IMO.
OK, I will do it. Thanks for suggestion
Best Regards,
LibinQuoted 5 lines
thanks,
Takashi
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 11 lines · Libin
Quoted 7 lines
sound/pci/hda/hda_intel.c static void bxt_reduce_dma_latency(struct azx *chip) · line 589
Quoted 5 lines
sound/pci/hda/hda_intel.c +4
-0+* Any deviation may result in undefined behavior. +*/ +if (((val &AZX_MLCTL_SPA ) >>AZX_MLCTL_SPA_SHIFT ) ^ + ((val &AZX_MLCTL_CPA ) >>AZX_MLCTL_CPA_SHIFT ))Should it be better with "==" instead of XOR here?
AZX_MLCTL_SPAbit value should be the same withAZX_MLCTL_CPAbit value before operation. If they are different, we should not touch this register. So if XOR is true, we should return directly.
I meant that (A != B) is more understandable than (A ^ B).
Takashi
Quoted 20 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Wednesday, March 22, 2017 12:51 AM
To: Yang, Libin <[email protected]>
Cc: [email protected]; Lin, Mengdong <[email protected]>; [email protected]
Subject: Re: [alsa-devel] [PATCH] ALSA: hda - set intel audio clock to a properly valueQuoted 8 lines · Libin
Quoted 7 lines
sound/pci/hda/hda_intel.c static void bxt_reduce_dma_latency(struct azx *chip) · line 589
Quoted 5 lines
sound/pci/hda/hda_intel.c +4
-0+* Any deviation may result in undefined behavior. +*/ +if (((val &AZX_MLCTL_SPA ) >>AZX_MLCTL_SPA_SHIFT ) ^ + ((val &AZX_MLCTL_CPA ) >>AZX_MLCTL_CPA_SHIFT ))Should it be better with "==" instead of XOR here?
Quoted 5 lines
Quoted 3 lines
AZX_MLCTL_SPAbit value should be the same withAZX_MLCTL_CPAbit value before operation. If they are different, we should not touch this register. So if XOR is true, we should return directly.I meant that (A != B) is more understandable than (A ^ B).
Get it. I will use (A != B)
Regards,
Libin
Quoted 3 lines
Takashi
Quoted 33 lines
-----Original Message-----
From: [email protected] [mailto:alsa-devel- [email protected]] On Behalf Of Yang, Libin
Sent: Tuesday, March 7, 2017 11:50 AM
To: [email protected]; [email protected]
Cc: Yang, Libin <[email protected]>; Lin, Mengdong <[email protected]>; [email protected]
Subject: [alsa-devel] [PATCH] ALSA: hda - set intel audio clock to a properly valueFrom: Libin Yang <[email protected]>
On some Intel platforms, the audio clock may not be set correctly with initial setting. This will cause the audio playback/capture rates wrong.
This patch checks the audio clock setting and will set it to a properly value if it is not set correct.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188411
Signed-off-by Libin Yang <[email protected]>--- include/sound/hda_register.h | 12 +++-- sound/hda/ext/hdac_ext_controller.c | 6 +-- sound/pci/hda/hda_intel.c | 91 +++++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 6 deletions(-)include/sound/hda_register.h +0
-0
include/sound/hda_register.h enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, · line 232
Quoted 6 lines
include/sound/hda_register.h +2
-0@@ -227,6 +227,8 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };#define AZX_REG_PPLCLLPU 0xC/* registers for Multiple Links Capability Structure */ +/* Multiple Links Capability */ +#define AZX_REG_ML_CAP_BASE 0xc00
Base is already available as part of bus, use bus->mlcap
Quoted 4 lines
include/sound/hda_register.h +2
-0+#define AZX_REG_ML_LCAPx (x) (AZX_REG_ML_CAP_BASE + (0x40 + 0x40 * x)) +#define AZX_REG_ML_LCTLx (x) (AZX_REG_ML_CAP_BASE + (0x44 +
0x40* x))
This is specific to the had legacy driver as only link0 is used, I think this can be moved to driver
As define. If it required to use all the link, then need to use ext functions to initialize the address
per link.
Quoted 10 lines
include/sound/hda_register.h +6
-0+#define ML_LCTL_SCF_MASK 0xF +#define AZX_MLCTL_SPA (0x1 << 16) +#define AZX_MLCTL_CPA (0x1 << 23) +#define AZX_MLCTL_SPA_SHIFT 16 +#define AZX_MLCTL_CPA_SHIFT 23 +static void hda_intel_init_chip (struct azx *chip,bool full_reset) {struct hdac_bus *bus =azx_bus (chip);
include/sound/hda_register.h static void hda_intel_init_chip(struct azx *chip, bool · line 655
Quoted 4 lines
include/sound/hda_register.h +3
-0@@ -564,6 +652,9 @@ static void hda_intel_init_chip(struct azx *chip, bool full_reset) + +if (IS_SKL_PLUS (pci)) +intel_init_lctl (chip);
Use bus->mlcap to check for multilink capability is present.
Hi Jeeja,
Quoted 51 lines
-----Original Message-----
From: Kp, Jeeja
Sent: Thursday, March 23, 2017 9:11 PM
To: Yang, Libin <[email protected]>; [email protected]; [email protected]
Cc: Lin, Mengdong <[email protected]>; [email protected]
Subject: RE: [alsa-devel] [PATCH] ALSA: hda - set intel audio clock to a properly valueQuoted 33 lines
-----Original Message-----
From: [email protected] [mailto:alsa-devel- [email protected]] On Behalf Of Yang, Libin
Sent: Tuesday, March 7, 2017 11:50 AM
To: [email protected]; [email protected]
Cc: Yang, Libin <[email protected]>; Lin, Mengdong <[email protected]>; [email protected]
Subject: [alsa-devel] [PATCH] ALSA: hda - set intel audio clock to a properly valueFrom: Libin Yang <[email protected]>
On some Intel platforms, the audio clock may not be set correctly with initial setting. This will cause the audio playback/capture rates wrong.
This patch checks the audio clock setting and will set it to a properly value if it is not set correct.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188411
Signed-off-by Libin Yang <[email protected]>--- include/sound/hda_register.h | 12 +++-- sound/hda/ext/hdac_ext_controller.c | 6 +-- sound/pci/hda/hda_intel.c | 91 +++++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 6 deletions(-)(quoted diff) +0
-0
b/include/sound/hda_register.hindex 0013063..7ea16cb 100644include/sound/hda_register.h enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, · line 232
Quoted 6 lines
include/sound/hda_register.h +2
-0@@ -227,6 +227,8 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };#define AZX_REG_PPLCLLPU 0xC/* registers for Multiple Links Capability Structure */ +/* Multiple Links Capability */ +#define AZX_REG_ML_CAP_BASE 0xc00Base is already available as part of bus, use
bus->mlcap
Quoted 7 lines
Quoted 4 lines
include/sound/hda_register.h +2
-0+#define AZX_REG_ML_LCAPx (x) (AZX_REG_ML_CAP_BASE + (0x40 + 0x40 * x)) +#define AZX_REG_ML_LCTLx (x) (AZX_REG_ML_CAP_BASE + (0x44 +
0x40* x))This is specific to the had legacy driver as only link0 is used, I think this can be moved to driver As define. If it required to use all the link, then need to use ext functions to initialize the address per link.
I'm not very sure what's your meaning. Do you mean using
+#define AZX_REG_ML_LCAP0 (AZX_REG_ML_CAP_BASE + 0x40)
Quoted 7 lines
Quoted 7 lines
include/sound/hda_register.h +5
-0+#define ML_LCTL_SCF_MASK 0xF +#define AZX_MLCTL_SPA (0x1 << 16) +#define AZX_MLCTL_CPA (0x1 << 23) +#define AZX_MLCTL_SPA_SHIFT 16 +#define AZX_MLCTL_CPA_SHIFT 23
Quoted 9 lines
include/sound/hda_register.h
Quoted 8 lines
include/sound/hda_register.h +1
-0+static void hda_intel_init_chip (struct azx *chip,bool full_reset) { struct hdac_bus *bus = azx_bus(chip); @@ -564,6 +652,9 @@ staticvoid hda_intel_init_chip(struct azx *chip, bool
full_reset)include/sound/hda_register.h +3
-0+ +if (IS_SKL_PLUS (pci)) +intel_init_lctl (chip);Use
bus->mlcapto check for multilink capability is present.
Get it.
Thanks,
Libin
Quoted 59 lines
Quoted 51 lines
-----Original Message-----
From: Kp, Jeeja
Sent: Thursday, March 23, 2017 9:11 PM
To: Yang, Libin <[email protected]>; [email protected]; [email protected]
Cc: Lin, Mengdong <[email protected]>; [email protected]
Subject: RE: [alsa-devel] [PATCH] ALSA: hda - set intel audio clock to a properly valueQuoted 33 lines
-----Original Message-----
From: [email protected] [mailto:alsa-devel- [email protected]] On Behalf Of Yang, Libin
Sent: Tuesday, March 7, 2017 11:50 AM
To: [email protected]; [email protected]
Cc: Yang, Libin <[email protected]>; Lin, Mengdong <[email protected]>; [email protected]
Subject: [alsa-devel] [PATCH] ALSA: hda - set intel audio clock to a properly valueFrom: Libin Yang <[email protected]>
On some Intel platforms, the audio clock may not be set correctly with initial setting. This will cause the audio playback/capture rates wrong.
This patch checks the audio clock setting and will set it to a properly value if it is not set correct.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188411
Signed-off-by Libin Yang <[email protected]>--- include/sound/hda_register.h | 12 +++-- sound/hda/ext/hdac_ext_controller.c | 6 +-- sound/pci/hda/hda_intel.c | 91 +++++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 6 deletions(-)(quoted diff) +0
-0
b/include/sound/hda_register.hindex 0013063..7ea16cb 100644include/sound/hda_register.h enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, · line 232
Quoted 6 lines
include/sound/hda_register.h +2
-0@@ -227,6 +227,8 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };#define AZX_REG_PPLCLLPU 0xC/* registers for Multiple Links Capability Structure */ +/* Multiple Links Capability */ +#define AZX_REG_ML_CAP_BASE 0xc00Base is already available as part of bus, use
bus->mlcapQuoted 7 lines
Quoted 4 lines
include/sound/hda_register.h +2
-0+#define AZX_REG_ML_LCAPx (x) (AZX_REG_ML_CAP_BASE + (0x40 + 0x40 * x)) +#define AZX_REG_ML_LCTLx (x) (AZX_REG_ML_CAP_BASE + (0x44 +
0x40* x))This is specific to the had legacy driver as only link0 is used, I think this can be moved to driver As define. If it required to use all the link, then need to use ext functions to initialize the address per link.
Quoted 1 line
I'm not very sure what's your meaning. Do you mean using
Use bus->mlcap + 0x44 as you are always using link0 (add offset, no need to define explicitly - AZX_REG_ML_LCTLx(x)).
Hi Jeeja,
Quoted 69 lines
-----Original Message-----
From: Kp, Jeeja
Sent: Thursday, March 30, 2017 4:07 PM
To: Yang, Libin <[email protected]>; [email protected]; [email protected]
Cc: Lin, Mengdong <[email protected]>; [email protected]
Subject: RE: [alsa-devel] [PATCH] ALSA: hda - set intel audio clock to a properly valueQuoted 60 lines
Quoted 59 lines
-----Original Message-----
From: Kp, Jeeja
Sent: Thursday, March 23, 2017 9:11 PM
To: Yang, Libin <[email protected]>; [email protected]; [email protected]
Cc: Lin, Mengdong <[email protected]>; [email protected]
Subject: RE: [alsa-devel] [PATCH] ALSA: hda - set intel audio clock to a properly valueQuoted 33 lines
-----Original Message-----
From: [email protected] [mailto:alsa-devel- [email protected]] On Behalf Of Yang, Libin
Sent: Tuesday, March 7, 2017 11:50 AM
To: [email protected]; [email protected]
Cc: Yang, Libin <[email protected]>; Lin, Mengdong <[email protected]>; [email protected]
Subject: [alsa-devel] [PATCH] ALSA: hda - set intel audio clock to a properly valueFrom: Libin Yang <[email protected]>
On some Intel platforms, the audio clock may not be set correctly with initial setting. This will cause the audio playback/capture rates wrong.
This patch checks the audio clock setting and will set it to a properly value if it is not set correct.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188411
Signed-off-by Libin Yang <[email protected]>--- include/sound/hda_register.h | 12 +++-- sound/hda/ext/hdac_ext_controller.c | 6 +-- sound/pci/hda/hda_intel.c | 91 +++++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 6 deletions(-)(quoted diff) +0
-0
b/include/sound/hda_register.hindex 0013063..7ea16cb 100644include/sound/hda_register.h enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, · line 233
Quoted 7 lines
include/sound/hda_register.h +2
-0@@ -227,6 +227,8 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1,SDO2 , SDO3 };#define AZX_REG_PPLCLLPU 0xC/* registers for Multiple Links Capability Structure */ +/* Multiple Links Capability */ +#define AZX_REG_ML_CAP_BASE 0xc00Base is already available as part of bus, use
bus->mlcapQuoted 4 lines
include/sound/hda_register.h +1
-0+#define AZX_REG_ML_LCAPx (x) (AZX_REG_ML_CAP_BASE + (0x40 +
0x40* x))
+#defineAZX_REG_ML_LCTLx(x)(AZX_REG_ML_CAP_BASE+ (0x44+0x40* x))This is specific to the had legacy driver as only link0 is used, I think this can be moved to driver As define. If it required to use all the link, then need to use ext functions to initialize the address per link.
Quoted 4 lines
Quoted 1 line
I'm not very sure what's your meaning. Do you mean using
Use
bus->mlcap+0x44as you are always using link0 (add offset, no need to define explicitly -AZX_REG_ML_LCTLx(x)).
OK. Thanks for suggestion. It can avoid new definition. Thanks for suggestion.
Regards,
Libin