Skip to content

Commit 603d3af

Browse files
authored
Merge pull request #1865 from toastal/asus-px13
asus/proart/px13/hn7306eac: init
2 parents 875776f + 3de9124 commit 603d3af

10 files changed

Lines changed: 498 additions & 0 deletions

File tree

asus/proart/px13/default.nix

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{ lib, ... }:
2+
3+
{
4+
imports = [
5+
../../../common/cpu/amd
6+
../../../common/cpu/amd/pstate.nix
7+
../../../common/gpu/amd
8+
../../../common/pc/laptop
9+
../../../common/pc/ssd
10+
../../../common/hidpi.nix
11+
../../battery.nix
12+
];
13+
14+
hardware.enableRedistributableFirmware = lib.mkDefault true;
15+
security.tpm2.enable = lib.mkDefault true;
16+
hardware.sensor.iio.enable = lib.mkDefault true;
17+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
pkgs,
3+
lib,
4+
...
5+
}:
6+
7+
{
8+
imports = [
9+
../default.nix
10+
./tas2783-kernel-patches.nix
11+
];
12+
13+
hardware = {
14+
alsa.enablePersistence = lib.mkDefault true;
15+
firmware = lib.optional (lib.versionOlder pkgs.linux-firmware.version "20260519") (
16+
pkgs.callPackage ./tas2783-firmware.nix { }
17+
);
18+
};
19+
20+
environment.etc = {
21+
"alsa/ucm2/codecs/tas2783/init.conf".source = ./ucm2/codecs/tas2783/init.conf;
22+
"alsa/ucm2/sof-soundwire/acp-dmic.conf".source = ./ucm2/sof-soundwire/acp-dmic.conf;
23+
"alsa/ucm2/sof-soundwire/tas2783.conf".source = ./ucm2/sof-soundwire/tas2783.conf;
24+
"alsa/ucm2/sof-soundwire/sof-soundwire.conf".source = ./ucm2/sof-soundwire/sof-soundwire.conf;
25+
};
26+
27+
# WirePlumber config for TAS2783 smart amp speakers.
28+
# UCM doesn’t expose a Speakers port for this card, so force pro-audio and
29+
# prevent the speaker sink from suspending (prevents desync on idle).
30+
# Firmware extraction recipe and original config:
31+
# https://gist.github.com/cryptob1/f62aaf8517df2e540f447347f42c7a03
32+
services.pipewire.wireplumber.extraConfig."51-strix-halo-audio" = {
33+
"monitor.alsa.rules" = [
34+
{
35+
matches = [
36+
{ "device.name" = "alsa_card.pci-0000_c4_00.5-platform-amd_sdw"; }
37+
];
38+
actions."update-props" = {
39+
"device.profile" = "pro-audio";
40+
};
41+
}
42+
{
43+
matches = [
44+
{ "node.name" = "alsa_output.pci-0000_c4_00.5-platform-amd_sdw.pro-output-2"; }
45+
];
46+
actions."update-props" = {
47+
"session.suspend-timeout-seconds" = 0;
48+
"node.description" = "Internal Speakers (TAS2783)";
49+
"priority.session" = 2300;
50+
};
51+
}
52+
];
53+
};
54+
55+
# Unmute the TAS2783 once detected.
56+
services.udev.extraRules =
57+
let
58+
amixer = "${lib.getBin pkgs.alsa-utils}/bin/amixer";
59+
in
60+
/* udev */ ''
61+
ACTION=="add", SUBSYSTEM=="sound", ATTR{id}=="sofsoundwire", RUN+="${amixer} -c $attr{number} set 'tas2783-1 Amp Playback Switch' 1"
62+
63+
ACTION=="add", SUBSYSTEM=="sound", ATTR{id}=="amdsoundwire", RUN+="${amixer} -c $attr{number} set 'tas2783-1 Amp' on"
64+
ACTION=="add", SUBSYSTEM=="sound", ATTR{id}=="amdsoundwire", RUN+="${amixer} -c $attr{number} set 'tas2783-2 Amp' on"
65+
ACTION=="add", SUBSYSTEM=="sound", ATTR{id}=="amdsoundwire", RUN+="${amixer} -c $attr{number} set 'tas2783-1 Speaker' on"
66+
ACTION=="add", SUBSYSTEM=="sound", ATTR{id}=="amdsoundwire", RUN+="${amixer} -c $attr{number} set 'tas2783-2 Speaker' on"
67+
'';
68+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
diff --git a/sound/soc/codecs/tas2783-sdw.c b/sound/soc/codecs/tas2783-sdw.c
2+
--- a/sound/soc/codecs/tas2783-sdw.c
3+
+++ b/sound/soc/codecs/tas2783-sdw.c
4+
@@ -1120,7 +1120,7 @@ static void tas_generate_fw_name(struct sdw_slave *slave, char *name, size_t siz
5+
for (; dev; dev = dev->parent) {
6+
if (dev->bus == &pci_bus_type) {
7+
pci = to_pci_dev(dev);
8+
- scnprintf(name, size, "%04X-%1X-%1X.bin",
9+
+ scnprintf(name, size, "%04X-%1X-0x%X.bin",
10+
pci->subsystem_device, bus->link_id, unique_id);
11+
pci_found = true;
12+
break;
13+
@@ -1129,7 +1129,7 @@ static void tas_generate_fw_name(struct sdw_slave *slave, char *name, size_t siz
14+
#endif
15+
16+
if (!pci_found)
17+
- scnprintf(name, size, "tas2783-%1X-%1X.bin",
18+
+ scnprintf(name, size, "tas2783-%1X-0x%X.bin",
19+
bus->link_id, unique_id);
20+
}
21+
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
lib,
3+
stdenvNoCC,
4+
fetchurl,
5+
icoutils,
6+
p7zip,
7+
}:
8+
9+
stdenvNoCC.mkDerivation (finalAttrs: {
10+
pname = "asus-px13-tas2783-firmware";
11+
version = "6.3.1.15";
12+
13+
src = fetchurl {
14+
url = "https://dlcdnets.asus.com/pub/ASUS/nb/Image/Driver/Audio/47519/SmartAMP_TI_DCH_TexasInstruments_Z_V${finalAttrs.version}_47519.exe?model=HN7306EAC";
15+
hash = "sha256-hyiDV5W+Rn05xyG2JF5uA41E/L8NDklxjvRctE64o84=";
16+
};
17+
18+
nativeBuildInputs = [
19+
icoutils
20+
p7zip
21+
];
22+
23+
unpackPhase = ''
24+
wrestool -x --raw -t ZIP -n 103 "$src" > driver.7z 2>/dev/null
25+
7z x driver.7z -ozip_out -y >/dev/null 2>&1
26+
'';
27+
28+
installPhase = ''
29+
install -D -m 644 $(find zip_out -name "1714-1-0x8.bin" | head -1) $out/lib/firmware/1714-1-0x8.bin
30+
install -D -m 644 $(find zip_out -name "1714-1-0xB.bin" | head -1) $out/lib/firmware/1714-1-0xB.bin
31+
'';
32+
33+
meta = {
34+
description = "TAS2783 Smart Amp firmware for ASUS ProArt PX13 HN7306EAC";
35+
homepage = "https://www.asus.com/support/download/HN7306EAC/";
36+
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
37+
license = with lib.licenses; [ unfreeRedistributableFirmware ];
38+
platforms = [ "x86_64-linux" ];
39+
};
40+
})
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
pkgs,
3+
lib,
4+
config,
5+
...
6+
}:
7+
8+
# See CachyOS’s discussion:
9+
# https://github.com/CachyOS/linux-cachyos/issues/737
10+
let
11+
mkPatch = name: hash: {
12+
inherit name;
13+
patch = pkgs.fetchpatch {
14+
inherit name;
15+
url = "https://aur.archlinux.org/cgit/aur.git/plain/${name}.patch?h=linux-cachyos-px13";
16+
inherit hash;
17+
};
18+
};
19+
in
20+
{
21+
assertions = [
22+
{
23+
assertion = lib.versionAtLeast config.boot.kernelPackages.kernel.version "7.0";
24+
message = "tas2783 patches require Linux ≥ 7.0 (found ${config.boot.kernelPackages.kernel.version})";
25+
}
26+
];
27+
28+
boot.kernelPatches = [
29+
(mkPatch "0001-ALSA-tas2783-sdw-add-Playback-to-volume-control" "sha512-IdIy81PXtmQAQ+MVChYDYkoa5RDhQwP2L5efN8cz+tST3nM0Oc0x4SJ4sBnVL7QDJc/WBB0OEnFfTkEt9Id+cQ==")
30+
(mkPatch "0002-Names-to-match-snd_soc_dai_driver-playback-capturest" "sha512-SrCgzceh3rhyYz5tNWHY2jNWyG/qgmU7ZVLtV71iir8HwOrSES7JsunV2E7mb8R66dShY+loV8ovNeMkyuDB7w==")
31+
(mkPatch "0003-removed-unused-fields" "sha512-mWKqFg8AG00TE3oPy5usPPxWf6aIvhxMLDGI+/0+vvjBIFwWv6qh9jSUeid6CAKgAcluPSA8Sag4ESguCeinyw==")
32+
(mkPatch "0004-SOC_SINGLE_RANGE_TLV-uses-snd_soc_get_volsw-snd_soc_" "sha512-G51v725q17UHvfPg4H8V92eSbZ5lcuiF97Zt1EbAtuwrhXefeaZy+hl79sSpVlzzY8pvzIwf6wodAuvp44M01A==")
33+
(mkPatch "0005-dev_set_drvdata-already-called-intas_sdw_probe" "sha512-zk+rKZ/l0oB7JdABtb89x6tUzggP99TSy+3cr+q6QjZFdjGsLPXHxre0YACuKBNx6+JazZE/zEilIvahS4wOLQ==")
34+
(mkPatch "0006-refactor-setting-sa_func_data" "sha512-8djgIJV1LCzDhFLFn/PNfDkE+U0mh2h4Rm2LJMeLUYKQlwzgPMbICh5B3HhCgEVTaUd54OGOSFEf0i6AIm2SIQ==")
35+
(mkPatch "0007-check-AF01-for-init-data" "sha512-gjpdnJDzve37MnyVE52+E9sRkXF9+HtA4XTrBZQiV8ozFwWgIzhO2ZDKSpWbE/kd23PdaUcKX/fPj3J7ZD5YqA==")
36+
(mkPatch "0008-setup-ports" "sha512-uuDa92VXlCsszswv8PHcDbbyfseL6Jt7DWPc5ajG1WSM/FGojRIbbl/2smQyGfE2jPquy5GQfJps7k1cRfpl8w==")
37+
(mkPatch "0009-Already-set-by-SOC_SINGLE_RANGE_TLV-Speaker-Playback" "sha512-qBveCsmwezD13oWF5jBlUybdns5OsDDZji0y0smaKWi9GPAvhw/v66WUnEyC77UF1mvq+OyrWpA4yXwxAFza3Q==")
38+
(mkPatch "0010-control-to-set-channel" "sha512-pL8Ol1ml2QhyKnzZvD+oTaVUPyqOO49uuiEUzyKdnskFwVH+jIluY3IDsmzWv5wTg/9D+CTGC4J8gW55xKwWfg==")
39+
(mkPatch "0011-mute-unmute-using-SND_SOC_DAPM_SWITCH" "sha512-6aB8mBACTIQxU7CTrpR3UXJFdR4KbUOT9/AymyGiuV/9PfWdXZoW/0A09SHFptxRwCv4FG5tZSDZRtKvvYNQdQ==")
40+
(mkPatch "0012-use-SND_SOC_DAPM_REG-to-power-on-off" "sha512-mJ93TxZQ1GuDGar0/6tBd/dlJ3B/41AVhRsViuSaEhykPC4NlIAOWaN9eJj4bxjEEyEQ3REfjHXVnJ3wdCRK9w==")
41+
(mkPatch "0013-reattach-after-resume" "sha512-OdkYPzRDkd4FCd1OTOAfRrQW6JQ9D3Opic/X+sg+pLNGoEEXfph/sLXVYGo9u6DGPJndQZNrXyS4qhJMGPWVMw==")
42+
(mkPatch "0014-defer-check" "sha512-ABSrwsOB+KU39LMxh3N47Ji+edhu5rDQMKMi5rEVXtCU8W56qANpU+ui+bJmOLYyq8c9H1qme+b5nQ6u9zv01w==")
43+
(mkPatch "0015-to-help-alsa-find-them" "sha512-gVJ+0ZO9Oz15/rC08moVSlVglbishJctjH5SnDdI8m3s9hkEY56o8v+R/PlRS3rL+mOa9q3VuO5J40+LrcxDKw==")
44+
(mkPatch "0016-cleanup-controls" "sha512-Jkp7kdi0FmVMlBL/VVzq7hYkCmKoELO0epnExP7ggQuopCzRbVpUQ3giMlj10O69aUBZJ4z3gaMkb1HTYjIXmA==")
45+
# Upstream linux-firmware took a different naming approach to the original patches
46+
{
47+
name = "0017-fix-tas2783-fw-name-0x";
48+
patch = ./fix-tas2783-fw-name-0x.patch;
49+
}
50+
];
51+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# TAS2783 specific switch control settings
2+
3+
Define.SpeakerMixerElem "tas2783-1 Speaker Playback"
4+
5+
If.twoAmpsStereoToOne {
6+
Condition {
7+
Type RegexMatch
8+
Regex "2"
9+
String "${var:SpeakerAmps}"
10+
}
11+
True {
12+
Define.SpeakerMixerElem "tas2783 Speaker"
13+
LibraryConfig.remap.Config {
14+
ctl.default.map {
15+
"name='tas2783 Speaker Playback Switch'" {
16+
"name='tas2783-1 Speaker Playback Switch'".vindex.0 0
17+
"name='tas2783-2 Speaker Playback Switch'".vindex.1 0
18+
}
19+
"name='tas2783 Speaker Playback Volume'" {
20+
"name='tas2783-1 Speaker Playback Volume'".vindex.0 0
21+
"name='tas2783-2 Speaker Playback Volume'".vindex.1 0
22+
}
23+
}
24+
}
25+
}
26+
}
27+
28+
If.oneAmp {
29+
Condition {
30+
Type ControlExists
31+
Control "name='tas2783-1 Speaker Playback Switch'"
32+
}
33+
True.Macro[{ SetLED { LED="speaker" Action="attach" CtlId="tas2783-1 Speaker Playback Switch" } }]
34+
}
35+
36+
If.twoAmps {
37+
Condition {
38+
Type ControlExists
39+
Control "name='tas2783-2 Speaker Playback Switch'"
40+
}
41+
True.Macro[{ SetLED { LED="speaker" Action="attach" CtlId="tas2783-2 Speaker Playback Switch" } }]
42+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
SectionDevice."Mic" {
2+
Comment "Digital Microphone"
3+
4+
Value {
5+
CapturePriority 100
6+
CapturePCM "hw:${CardId},4"
7+
}
8+
}

0 commit comments

Comments
 (0)