moby: ship megis rt5640 sound driver (experimental. it still boots, but pipewire/wireplumber still crash-loops)
This commit is contained in:
@@ -189,7 +189,8 @@ in
|
|||||||
|
|
||||||
boot.extraModulePackages = [
|
boot.extraModulePackages = [
|
||||||
config.boot.kernelPackages.rk818-charger #< rk818 battery/charger isn't mainline as of 2024-10-01
|
config.boot.kernelPackages.rk818-charger #< rk818 battery/charger isn't mainline as of 2024-10-01
|
||||||
config.boot.kernelPackages.imx258 #< mainline imx258 camera driver has some power-on and data rate issues on PPP
|
config.boot.kernelPackages.imx258 #< mainline imx258 camera driver has some power-on issues on PPP (imx258 1-001a: Error reading reg 0x0016: -6)
|
||||||
|
config.boot.kernelPackages.rt5640 #< mainline rt5640 generally works. possibly bad interplay with the imx258 camera, that i'm debugging, so use megi's patched rt5640.
|
||||||
];
|
];
|
||||||
|
|
||||||
# default nixos behavior is to error if a kernel module is provided by more than one package.
|
# default nixos behavior is to error if a kernel module is provided by more than one package.
|
||||||
|
7
pkgs/linux-packages/rt5640/Makefile
Normal file
7
pkgs/linux-packages/rt5640/Makefile
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
obj-m := snd-soc-rt5640.o
|
||||||
|
|
||||||
|
all:
|
||||||
|
$(MAKE) -C "$(KERNEL_DIR)" M="$(PWD)" modules
|
||||||
|
install:
|
||||||
|
install -Dm444 snd-soc-rt5640.ko $(INSTALL_MOD_PATH)/sound/soc/codecs/snd-soc-rt5640.ko
|
||||||
|
|
45
pkgs/linux-packages/rt5640/package.nix
Normal file
45
pkgs/linux-packages/rt5640/package.nix
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
# 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".
|
||||||
|
#
|
||||||
|
# the driver source lives at sound/soc/codecs/rt5640.c; it's renamed to sound-soc-rt5640 during build
|
||||||
|
{
|
||||||
|
buildPackages,
|
||||||
|
kernel,
|
||||||
|
lib,
|
||||||
|
stdenv,
|
||||||
|
}:
|
||||||
|
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
pname = "rt5640";
|
||||||
|
version = "0-unstable-2024-02-21";
|
||||||
|
|
||||||
|
src = ./.;
|
||||||
|
|
||||||
|
hardeningDisable = [ "pic" ];
|
||||||
|
nativeBuildInputs = kernel.moduleBuildDependencies;
|
||||||
|
|
||||||
|
makeFlags = [
|
||||||
|
# "KERNELRELEASE=${kernel.modDirVersion}"
|
||||||
|
"KERNEL_DIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
|
||||||
|
"INSTALL_MOD_PATH=$(out)/lib/modules/${kernel.modDirVersion}/kernel"
|
||||||
|
# from <repo:nixos/nixpkgs:pkgs/os-specific/linux/kernel/manual-config.nix>
|
||||||
|
"O=$(buildRoot)"
|
||||||
|
"CC=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"
|
||||||
|
"HOSTCC=${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}cc"
|
||||||
|
"HOSTLD=${buildPackages.stdenv.cc.bintools}/bin/${buildPackages.stdenv.cc.targetPrefix}ld"
|
||||||
|
"ARCH=${stdenv.hostPlatform.linuxArch}"
|
||||||
|
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
||||||
|
"CROSS_COMPILE=${stdenv.cc.targetPrefix}"
|
||||||
|
];
|
||||||
|
|
||||||
|
# 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 {} \;
|
||||||
|
'';
|
||||||
|
|
||||||
|
passthru.moduleNames = [
|
||||||
|
"sound-soc-rt5640" #< mainline, patched module
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
33
pkgs/linux-packages/rt5640/rl6231.h
Normal file
33
pkgs/linux-packages/rt5640/rl6231.h
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
|
/*
|
||||||
|
* rl6231.h - RL6231 class device shared support
|
||||||
|
*
|
||||||
|
* Copyright 2014 Realtek Semiconductor Corp.
|
||||||
|
*
|
||||||
|
* Author: Oder Chiou <oder_chiou@realtek.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __RL6231_H__
|
||||||
|
#define __RL6231_H__
|
||||||
|
|
||||||
|
#define RL6231_PLL_INP_MAX 50000000
|
||||||
|
#define RL6231_PLL_INP_MIN 256000
|
||||||
|
#define RL6231_PLL_N_MAX 0x1ff
|
||||||
|
#define RL6231_PLL_K_MAX 0x1f
|
||||||
|
#define RL6231_PLL_M_MAX 0xf
|
||||||
|
|
||||||
|
struct rl6231_pll_code {
|
||||||
|
bool m_bp; /* Indicates bypass m code or not. */
|
||||||
|
bool k_bp; /* Indicates bypass k code or not. */
|
||||||
|
int m_code;
|
||||||
|
int n_code;
|
||||||
|
int k_code;
|
||||||
|
};
|
||||||
|
|
||||||
|
int rl6231_calc_dmic_clk(int rate);
|
||||||
|
int rl6231_pll_calc(const unsigned int freq_in,
|
||||||
|
const unsigned int freq_out, struct rl6231_pll_code *pll_code);
|
||||||
|
int rl6231_get_clk_info(int sclk, int rate);
|
||||||
|
int rl6231_get_pre_div(struct regmap *map, unsigned int reg, int sft);
|
||||||
|
|
||||||
|
#endif /* __RL6231_H__ */
|
2189
pkgs/linux-packages/rt5640/rt5640.h
Normal file
2189
pkgs/linux-packages/rt5640/rt5640.h
Normal file
File diff suppressed because it is too large
Load Diff
3104
pkgs/linux-packages/rt5640/snd-soc-rt5640.c
Normal file
3104
pkgs/linux-packages/rt5640/snd-soc-rt5640.c
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user