diff options
author | Térence Clastres | 2019-08-04 19:30:15 +0200 |
---|---|---|
committer | Térence Clastres | 2019-08-04 19:30:15 +0200 |
commit | c2060791d43149358912b70b24782ddcc4db1472 (patch) | |
tree | b1bc21ca410d804f9a1406fcb5137f109f4f1f8c | |
download | aur-c2060791d43149358912b70b24782ddcc4db1472.tar.gz |
Initial commit after renaming
Fix bugzilla url
-rw-r--r-- | .SRCINFO | 25 | ||||
-rw-r--r-- | Makefile | 18 | ||||
-rw-r--r-- | PKGBUILD | 64 | ||||
-rw-r--r-- | dkms.conf | 6 | ||||
-rw-r--r-- | hda_intel.diff | 101 | ||||
-rw-r--r-- | hdac_stream.diff | 15 |
6 files changed, 229 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..f792865eb70c --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,25 @@ +pkgbase = snd_hda_intel-amd-hd-audio-fix-dkms + pkgdesc = The snd_hda_intel kernel driver, patched to remove crackling on AMD HD-audio controller + pkgver = 1 + pkgrel = 1 + url = https://bugzilla.kernel.org/show_bug.cgi?id=195303 + arch = x86_64 + license = GPL2 + depends = dkms + conflicts = snd_hda_intel-alc1220-dkms + replaces = snd_hda_intel-alc1220-dkms + source = https://www.kernel.org/pub/linux/kernel/v5.x/linux-5.2.tar.xz + source = https://www.kernel.org/pub/linux/kernel/v5.x/patch-5.2.5.xz + source = hda_intel.diff + source = hdac_stream.diff + source = dkms.conf + source = Makefile + md5sums = ddf994de00d7b18395886dd9b30b9262 + md5sums = 0bfed20acab24d45232983b54339a3c9 + md5sums = 867d3d27fb1716290c76d90ffb739343 + md5sums = b5f5cf9b9a7e0c5852d290992eb73b68 + md5sums = 20495ab7a2c425ba786c44d53d458909 + md5sums = 4cf63656de83b4321d6261289735d1e1 + +pkgname = snd_hda_intel-amd-hd-audio-fix-dkms + diff --git a/Makefile b/Makefile new file mode 100644 index 000000000000..4700b2851ab0 --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ +ifndef KERNELRELEASE +KRELEASE := $(shell uname -r) +else +KRELEASE := $(KERNELRELEASE) +endif + +KDIR := /usr/lib/modules/$(KRELEASE)/build +PWD := $(shell pwd) +SRCDIR := $(PWD)/hda-src +MODULENAME := snd-hda-intel.ko + +default: + $(Q)cd $(SRCDIR) + $(MAKE) -j 1 -C $(KDIR) M=$(SRCDIR) modules + $(Q)cp $(SRCDIR)/$(MODULENAME) $(PWD) +clean: + $(MAKE) -C $(KDIR) M=$(SRCDIR) clean + $(Q)rm $(PWD)/$(MODULENAME) diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..1064f13534e3 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,64 @@ +# Maintainer: Térence Clastres <t.clastres@gmail.com> + +pkgname=snd_hda_intel-amd-hd-audio-fix-dkms +_pkgbase=${pkgname%-dkms} +_basekernel=5.2 +_sub=5 +_k_pkgver=${_basekernel}.${_sub} +pkgver=1 +pkgrel=1 +pkgdesc="The snd_hda_intel kernel driver, patched to remove crackling on AMD HD-audio controller" +arch=('x86_64') +url="https://bugzilla.kernel.org/show_bug.cgi?id=195303" +license=('GPL2') +depends=('dkms') +conflicts=(snd_hda_intel-alc1220-dkms) +replaces=(snd_hda_intel-alc1220-dkms) +source=("https://www.kernel.org/pub/linux/kernel/v5.x/linux-${_basekernel}.tar.xz" + "https://www.kernel.org/pub/linux/kernel/v5.x/patch-${_k_pkgver}.xz" + "hda_intel.diff" + "hdac_stream.diff" + 'dkms.conf' + 'Makefile') +md5sums=('ddf994de00d7b18395886dd9b30b9262' + '0bfed20acab24d45232983b54339a3c9' + '867d3d27fb1716290c76d90ffb739343' + 'b5f5cf9b9a7e0c5852d290992eb73b68' + '20495ab7a2c425ba786c44d53d458909' + '4cf63656de83b4321d6261289735d1e1') + +prepare() { + mkdir -p "${srcdir}/${_pkgbase}" && cd "${srcdir}/${_pkgbase}" + + cp ../dkms.conf ../hda*.diff ../Makefile . + + cd "${srcdir}/linux-${_basekernel}" + # add upstream patch + patch -p1 -i ../patch-"${_k_pkgver}" + + mkdir -p "${srcdir}"/hda-src/{hdacore,include/dkms/{sound,uapi/sound}} + cp -r sound/hda/* "${srcdir}/hda-src/hdacore" + cp sound/pci/hda/* "${srcdir}/hda-src" + cp -r include/{sound/hda*,sound/tlv.h} "${srcdir}/hda-src/include/dkms/sound" + cp include/uapi/sound/* "${srcdir}/hda-src/include/dkms/uapi/sound" || true + + cd "${srcdir}/hda-src" + patch -Np4 < ../hda_intel.diff + patch -Np1 < ../hdac_stream.diff + +} + +package() { + # Copy dkms.conf + install -Dm644 dkms.conf "${pkgdir}/usr/src/${_pkgbase}-${pkgver}/dkms.conf" + + # Set name and version + sed -e "s/@_PKGBASE@/${_pkgbase}/" \ + -e "s/@PKGVER@/${pkgver}/" \ + -i "${pkgdir}/usr/src/${_pkgbase}-${pkgver}/dkms.conf" + +# readlink -f . +# exit + # Copy sources (including Makefile) + cp -r "${srcdir}"/{hda*,Makefile} "${pkgdir}/usr/src/${_pkgbase}-${pkgver}/" +} diff --git a/dkms.conf b/dkms.conf new file mode 100644 index 000000000000..c2f61d9dc382 --- /dev/null +++ b/dkms.conf @@ -0,0 +1,6 @@ +PACKAGE_NAME="@_PKGBASE@" +PACKAGE_VERSION="@PKGVER@" +BUILT_MODULE_NAME[0]="snd-hda-intel" +MAKE[0]="make" +DEST_MODULE_LOCATION[0]="/kernel/sound/pci/hda/" +AUTOINSTALL="yes" diff --git a/hda_intel.diff b/hda_intel.diff new file mode 100644 index 000000000000..32d43708d934 --- /dev/null +++ b/hda_intel.diff @@ -0,0 +1,101 @@ +--- a/sound/pci/hda/hda_intel.c ++++ a/sound/pci/hda/hda_intel.c +@@ -64,6 +64,7 @@ enum { + POS_FIX_VIACOMBO, + POS_FIX_COMBO, + POS_FIX_SKL, ++ POS_FIX_AMD, + }; + + /* Defines for ATI HD Audio support in SB450 south bridge */ +@@ -258,6 +259,7 @@ enum { + AZX_DRIVER_ATI, + AZX_DRIVER_ATIHDMI, + AZX_DRIVER_ATIHDMI_NS, ++ AZX_DRIVER_AMD, + AZX_DRIVER_VIA, + AZX_DRIVER_SIS, + AZX_DRIVER_ULI, +@@ -371,6 +373,7 @@ static char *driver_short_names[] = { + [AZX_DRIVER_ATI] = "HDA ATI SB", + [AZX_DRIVER_ATIHDMI] = "HDA ATI HDMI", + [AZX_DRIVER_ATIHDMI_NS] = "HDA ATI HDMI", ++ [AZX_DRIVER_AMD] = "HD-Audio Generic", /* kept old name for compatibility */ + [AZX_DRIVER_VIA] = "HDA VIA VT82xx", + [AZX_DRIVER_SIS] = "HDA SIS966", + [AZX_DRIVER_ULI] = "HDA ULI M5461", +@@ -841,6 +844,37 @@ static unsigned int azx_via_get_position(struct azx *chip, + return bound_pos + mod_dma_pos; + } + ++/* get the current DMA position with correction on AMD chips */ ++static unsigned int azx_get_pos_amd(struct azx *chip, struct azx_dev *azx_dev) ++{ ++ unsigned int link_pos, fifo_size; ++ ++ link_pos = snd_hdac_stream_get_pos_lpib(azx_stream(azx_dev)); ++ ++#if 0 /* FIXME: do we need a correction for playback, too? */ ++ if (azx_dev->core.substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ++ return link_pos; ++#endif ++ ++#if 1 /* FIXME: is this reliably readable on AMD platform (and correct?) */ ++ fifo_size = readw(azx_bus(chip)->remap_addr + ++ VIA_IN_STREAM0_FIFO_SIZE_OFFSET); ++#else /* FIXME: ... or better to use fifo_size per stream? */ ++ fifo_size = azx_dev->core.fifo_size; ++#endif ++ ++ if (azx_dev->insufficient) { ++ if (link_pos <= fifo_size) ++ return 0; ++ azx_dev->insufficient = 0; ++ } ++ ++ if (link_pos < fifo_size) ++ link_pos += azx_dev->core.bufsize; ++ link_pos -= fifo_size; ++ return link_pos; ++} ++ + static unsigned int azx_skl_get_dpib_pos(struct azx *chip, + struct azx_dev *azx_dev) + { +@@ -1417,6 +1451,7 @@ static int check_position_fix(struct azx *chip, int fix) + case POS_FIX_VIACOMBO: + case POS_FIX_COMBO: + case POS_FIX_SKL: ++ case POS_FIX_AMD: + return fix; + } + +@@ -1432,6 +1467,9 @@ static int check_position_fix(struct azx *chip, int fix) + if (chip->driver_type == AZX_DRIVER_VIA) { + dev_dbg(chip->card->dev, "Using VIACOMBO position fix\n"); + return POS_FIX_VIACOMBO; ++ } else if (chip->driver_type == AZX_DRIVER_AMD) { ++ dev_dbg(chip->card->dev, "Using AMD position fix\n"); ++ return POS_FIX_AMD; + } + if (chip->driver_caps & AZX_DCAPS_POSFIX_LPIB) { + dev_dbg(chip->card->dev, "Using LPIB position fix\n"); +@@ -1453,6 +1491,7 @@ static void assign_position_fix(struct azx *chip, int fix) + [POS_FIX_VIACOMBO] = azx_via_get_position, + [POS_FIX_COMBO] = azx_get_pos_lpib, + [POS_FIX_SKL] = azx_get_pos_skl, ++ [POS_FIX_AMD] = azx_get_pos_amd, + }; + + chip->get_position[0] = chip->get_position[1] = callbacks[fix]; +@@ -2447,6 +2486,10 @@ static const struct pci_device_id azx_ids[] = { + /* AMD Hudson */ + { PCI_DEVICE(0x1022, 0x780d), + .driver_data = AZX_DRIVER_GENERIC | AZX_DCAPS_PRESET_ATI_SB }, ++ /* AMD X370 */ ++ { PCI_DEVICE(0x1022, 0x1457), ++ .driver_data = AZX_DRIVER_AMD | AZX_DCAPS_PRESET_ATI_SB | ++ AZX_DCAPS_PM_RUNTIME }, + /* AMD Stoney */ + { PCI_DEVICE(0x1022, 0x157a), + .driver_data = AZX_DRIVER_GENERIC | AZX_DCAPS_PRESET_ATI_SB | diff --git a/hdac_stream.diff b/hdac_stream.diff new file mode 100644 index 000000000000..45bd4c6ec141 --- /dev/null +++ b/hdac_stream.diff @@ -0,0 +1,15 @@ +--- a/hdacore/hdac_stream.c ++++ a/hdacore/hdac_stream.c +@@ -229,11 +229,7 @@ int snd_hdac_stream_setup(struct hdac_stream *azx_dev) + /* set the interrupt enable bits in the descriptor control register */ + snd_hdac_stream_updatel(azx_dev, SD_CTL, 0, SD_INT_MASK); + +- if (azx_dev->direction == SNDRV_PCM_STREAM_PLAYBACK) +- azx_dev->fifo_size = +- snd_hdac_stream_readw(azx_dev, SD_FIFOSIZE) + 1; +- else +- azx_dev->fifo_size = 0; ++ azx_dev->fifo_size = snd_hdac_stream_readw(azx_dev, SD_FIFOSIZE) + 1; + + /* when LPIB delay correction gives a small negative value, + * we ignore it; currently set the threshold statically to |