Skip to content

Commit 50279d9

Browse files
gune42tiwai
authored andcommitted
ALSA - hda: Add support for parsing new HDA capabilities
Skylake onwards HDA controller supports new capabilities like Global Time Stamping (GTS) capability. So add support to parse these new capabilities. Signed-off-by: Guneshwor Singh <[email protected]> Signed-off-by: Hardik T Shah <[email protected]> Signed-off-by: Vinod Koul <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
1 parent 404735c commit 50279d9

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed

include/sound/hda_register.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,19 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
8989
#define AZX_REG_SD_BDLPL 0x18
9090
#define AZX_REG_SD_BDLPU 0x1c
9191

92+
/* GTS registers */
93+
#define AZX_REG_LLCH 0x14
94+
95+
#define AZX_REG_GTS_BASE 0x520
96+
97+
#define AZX_REG_GTSCC (AZX_REG_GTS_BASE + 0x00)
98+
#define AZX_REG_WALFCC (AZX_REG_GTS_BASE + 0x04)
99+
#define AZX_REG_TSCCL (AZX_REG_GTS_BASE + 0x08)
100+
#define AZX_REG_TSCCU (AZX_REG_GTS_BASE + 0x0C)
101+
#define AZX_REG_LLPFOC (AZX_REG_GTS_BASE + 0x14)
102+
#define AZX_REG_LLPCL (AZX_REG_GTS_BASE + 0x18)
103+
#define AZX_REG_LLPCU (AZX_REG_GTS_BASE + 0x1C)
104+
92105
/* Haswell/Broadwell display HD-A controller Extended Mode registers */
93106
#define AZX_REG_HSW_EM4 0x100c
94107
#define AZX_REG_HSW_EM5 0x1010
@@ -242,6 +255,29 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
242255
/* Interval used to calculate the iterating register offset */
243256
#define AZX_DRSM_INTERVAL 0x08
244257

258+
/* Global time synchronization registers */
259+
#define GTSCC_TSCCD_MASK 0x80000000
260+
#define GTSCC_TSCCD_SHIFT BIT(31)
261+
#define GTSCC_TSCCI_MASK 0x20
262+
#define GTSCC_CDMAS_DMA_DIR_SHIFT 4
263+
264+
#define WALFCC_CIF_MASK 0x1FF
265+
#define WALFCC_FN_SHIFT 9
266+
#define HDA_CLK_CYCLES_PER_FRAME 512
267+
268+
/*
269+
* An error occurs near frame "rollover". The clocks in frame value indicates
270+
* whether this error may have occurred. Here we use the value of 10. Please
271+
* see the errata for the right number [<10]
272+
*/
273+
#define HDA_MAX_CYCLE_VALUE 499
274+
#define HDA_MAX_CYCLE_OFFSET 10
275+
#define HDA_MAX_CYCLE_READ_RETRY 10
276+
277+
#define TSCCU_CCU_SHIFT 32
278+
#define LLPC_CCU_SHIFT 32
279+
280+
245281
/*
246282
* helpers to read the stream position
247283
*/

sound/pci/hda/hda_controller.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,11 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
412412
goto unlock;
413413
}
414414
runtime->private_data = azx_dev;
415+
416+
if (chip->gts_present)
417+
azx_pcm_hw.info = azx_pcm_hw.info |
418+
SNDRV_PCM_INFO_HAS_LINK_SYNCHRONIZED_ATIME;
419+
415420
runtime->hw = azx_pcm_hw;
416421
runtime->hw.channels_min = hinfo->channels_min;
417422
runtime->hw.channels_max = hinfo->channels_max;

sound/pci/hda/hda_controller.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ struct azx {
159159
unsigned int region_requested:1;
160160
unsigned int disabled:1; /* disabled by vga_switcheroo */
161161

162+
/* GTS present */
163+
unsigned int gts_present:1;
164+
162165
#ifdef CONFIG_SND_HDA_DSP_LOADER
163166
struct azx_dev saved_azx_dev;
164167
#endif

sound/pci/hda/hda_intel.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
/* for snoop control */
5555
#include <asm/pgtable.h>
5656
#include <asm/cacheflush.h>
57+
#include <asm/cpufeature.h>
5758
#endif
5859
#include <sound/core.h>
5960
#include <sound/initval.h>
@@ -1655,6 +1656,22 @@ static int azx_first_init(struct azx *chip)
16551656
return -ENXIO;
16561657
}
16571658

1659+
if (IS_SKL_PLUS(pci))
1660+
snd_hdac_bus_parse_capabilities(bus);
1661+
1662+
/*
1663+
* Some Intel CPUs has always running timer (ART) feature and
1664+
* controller may have Global time sync reporting capability, so
1665+
* check both of these before declaring synchronized time reporting
1666+
* capability SNDRV_PCM_INFO_HAS_LINK_SYNCHRONIZED_ATIME
1667+
*/
1668+
chip->gts_present = false;
1669+
1670+
#ifdef CONFIG_X86
1671+
if (bus->ppcap && boot_cpu_has(X86_FEATURE_ART))
1672+
chip->gts_present = true;
1673+
#endif
1674+
16581675
if (chip->msi) {
16591676
if (chip->driver_caps & AZX_DCAPS_NO_MSI64) {
16601677
dev_dbg(card->dev, "Disabling 64bit MSI\n");

0 commit comments

Comments
 (0)