linuxPackages_6_15.rt5640: fix build against linux 6.15

updated version comes from megi:
```console
$ cd src/linux
$ git fetch stable --tags
$ git checkout v6.15
$ patch -p1 <(curl https://xff.cz/kernels/6.15/patches/all.patch)
$ cp sound/soc/codecs/rt5640.c pkgs/linux-packages/rt5640/snd-soc-rt5640.c
```
This commit is contained in:
2025-07-19 03:09:03 +00:00
parent e4c6c01f8d
commit 0c791e30a0
2 changed files with 22 additions and 11 deletions

View File

@@ -1,6 +1,8 @@
# C code is taken from megi's kernel tree.
# this is a patched version of mainline driver.
# notably, it resolves some errors like "rt5640 1-001c: ASoC: error at snd_soc_dai_set_sysclk on rt5640-aif1: -22".
# notably, it resolves some errors like:
# - "rt5640 1-001c: ASoC: error at snd_soc_dai_set_sysclk on rt5640-aif1: -22" (older linux, i think pre 6.13?)
# - "rt5640: 1-001c: ASoC error (-22): at snd_soc_dai_set_sysclk() on rt5640-aif1" (linux 6.15.6+)
#
# the driver source lives at sound/soc/codecs/rt5640.c; it's renamed to sound-soc-rt5640 during build
{
@@ -21,7 +23,8 @@ stdenv.mkDerivation {
makeFlags = [
# "KERNELRELEASE=${kernel.modDirVersion}"
"KERNEL_DIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
# "KERNEL_DIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
"KERNEL_DIR=$(buildRoot)"
"INSTALL_MOD_PATH=$(out)/lib/modules/${kernel.modDirVersion}/kernel"
# from <repo:nixos/nixpkgs:pkgs/os-specific/linux/kernel/manual-config.nix>
"O=$(buildRoot)"
@@ -33,6 +36,14 @@ stdenv.mkDerivation {
"CROSS_COMPILE=${stdenv.cc.targetPrefix}"
];
preConfigure = ''
# starting with linux 6.13.0 it wants to write to `KERNEL_DIR`, so we copy that here to make it writable
cp -R ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build .
export buildRoot=$(pwd)/build
chmod u+w -R build
'';
# the modules shipped in-tree are .xz, so if i want to replace those i need to also xz this module:
postInstall = ''
find $out -name '*.ko' -exec xz {} \;

View File

@@ -1804,10 +1804,10 @@ static int rt5640_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
int dai_sel;
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBM_CFM:
case SND_SOC_DAIFMT_CBP_CFP:
rt5640->master[dai->id] = 1;
break;
case SND_SOC_DAIFMT_CBS_CFS:
case SND_SOC_DAIFMT_CBC_CFC:
reg_val |= RT5640_I2S_MS_S;
rt5640->master[dai->id] = 0;
break;
@@ -2999,19 +2999,19 @@ MODULE_DEVICE_TABLE(i2c, rt5640_i2c_id);
static const struct of_device_id rt5640_of_match[] = {
{ .compatible = "realtek,rt5639", },
{ .compatible = "realtek,rt5640", },
{},
{ }
};
MODULE_DEVICE_TABLE(of, rt5640_of_match);
#endif
#ifdef CONFIG_ACPI
static const struct acpi_device_id rt5640_acpi_match[] = {
{ "INT33CA", 0 },
{ "10EC3276", 0 },
{ "10EC5640", 0 },
{ "10EC5642", 0 },
{ "INTCCFFD", 0 },
{ },
{ "10EC3276" },
{ "10EC5640" },
{ "10EC5642" },
{ "INT33CA" },
{ "INTCCFFD" },
{ }
};
MODULE_DEVICE_TABLE(acpi, rt5640_acpi_match);
#endif