Compare commits

...
17 Commits
Author SHA1 Message Date
Alexander Heldt c29f8c94e3 Update ndp flake input 2026-11-22 15:53:42 +01:00
Alexander Heldt f537765495 Update dagbok flake input 2026-11-20 11:30:41 +01:00
Alexander Heldt a9ffe67b8b Update dagbok flake input 2026-11-20 10:31:03 +01:00
Alexander Heldt fab534431c Update ct flake input 2026-11-20 10:30:53 +01:00
Alexander Heldt ddbeaa7b5b Update ndp flake input 2026-11-20 10:27:50 +01:00
Alexander Heldt 3a6a75bffa pinwheel: Give ndp an Anthropic API key for asking an LLM 2026-11-20 10:27:50 +01:00
Alexander Heldt ef499b0581 manatee: Remove solo-referee module and flake input 2026-11-20 08:56:34 +01:00
Alexander Heldt d469f067bd Update ndp flake input 2026-11-17 16:47:41 +01:00
Alexander Heldt cc4b41a4b0 Update dagbok flake input 2026-11-17 14:55:46 +01:00
Alexander Heldt ef21a9a785 pinwheel: Turn off code-action hints with refactor-indications
Eglot 1.25 moved code actions to the `refactor` package and made
`eglot-code-action-indications` an obsolete alias for
`refactor-indications`. The alias is set before eglot loads, so the
setting no longer applies and the `refactor` default comes back. Its
eldoc hint then takes the one-line echo area, hiding the hover
signature.
2026-11-17 14:25:42 +01:00
Alexander Heldt 0ec4085359 Update ndp flake input 2026-11-17 10:38:18 +01:00
Alexander Heldt c40dec90bd pinwheel: Fix webcam breaking after resume from hibernation
Hibernation powers off the Lattice USBIO bridge that the ov08x40
sensor and Intel CVS sit behind. usbio has no reset_resume callback,
so on restore the USB core unbinds and rebinds it, which re-creates
the sensor and CVS I2C clients. The new clients lack the fwnode graph
that ipu-bridge built at boot, and ipu-bridge never rebuilds it, so
the camera stays dead until a cold boot.

Patch usbio to redo the bridge handshake in reset_resume instead of
being rebound, and patch gpio-usbio to restore its pin configuration
and output values after such a reset. Both are built from the kernel
source and installed under updates/, sharing the build recipe with
the patched ipu6-isys module.
2026-11-17 10:36:46 +01:00
Alexander Heldt c8b2340d14 Update ndp flake input 2026-11-17 10:36:46 +01:00
Alexander Heldt 3ddba7f670 pinwheel: Install picard plugin replaygain2 from a pinned source 2026-11-17 09:07:05 +01:00
Alexander Heldt ec4d407422 Update ndp flake input 2026-11-16 22:14:11 +01:00
Alexander Heldt 301aa7c1bb pinwheel: Scale picard by 1.5 with QT_SCREEN_SCALE_FACTORS 2026-11-16 22:13:41 +01:00
Alexander Heldt a52494e39b pinwheel: Add picard with the replaygain2 plugin 2026-11-16 22:03:18 +01:00
13 changed files with 444 additions and 158 deletions

No files matched your search

Generated
+12 -68
View File
@@ -60,11 +60,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1794815051, "lastModified": 1795167012,
"narHash": "sha256-03xK+GPuyAIbUHvJXsWY2QclronkMUkxxDUegFrbYlU=", "narHash": "sha256-lrLLMUJNddmAMMDobTJVshu7ckzMTmTab4S3XPFgT1E=",
"ref": "main", "ref": "main",
"rev": "640bd1d321ea5078b1f17bf1d6e6afaf734b669f", "rev": "7be6c580cb78e8e3267b6d98e421275aacc8140b",
"revCount": 29, "revCount": 30,
"type": "git", "type": "git",
"url": "ssh://gitea@git.ppp.pm:1122/alex/ct.git" "url": "ssh://gitea@git.ppp.pm:1122/alex/ct.git"
}, },
@@ -81,11 +81,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1794813897, "lastModified": 1795169003,
"narHash": "sha256-8pxsTqBZRio6eeloNKqKaDWAK/EH7cp4qPkhG1XL7Xo=", "narHash": "sha256-He4Tde9AYNSIb8D8ZowMAUECQnUM07cSEwqc10D04xc=",
"ref": "main", "ref": "main",
"rev": "223accdfa20322a64c3ce1b934de274f82402258", "rev": "c3114be05fda532d8fbb14149a5a662550bc49f2",
"revCount": 58, "revCount": 61,
"type": "git", "type": "git",
"url": "ssh://gitea@git.ppp.pm:1122/alex/dagbok.git" "url": "ssh://gitea@git.ppp.pm:1122/alex/dagbok.git"
}, },
@@ -222,24 +222,6 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils_4": {
"inputs": {
"systems": "systems_6"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"heldtenkeltdotse-site": { "heldtenkeltdotse-site": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@@ -711,11 +693,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1794772391, "lastModified": 1795359024,
"narHash": "sha256-7OVYf6YOxg/bLjwKx6YykSYusIppUTzHTmOtDSL99cs=", "narHash": "sha256-y8QxP87mNSW+Dzb4MnTmibVkrQ9yrz+WJthJaFKr9h0=",
"ref": "main", "ref": "main",
"rev": "0c2ee19394922ebda34570ae2c4bf01e7f33c2e7", "rev": "dd0c3762e91759ebd6fb449194690bf4cddb824f",
"revCount": 35, "revCount": 48,
"type": "git", "type": "git",
"url": "ssh://gitea@git.ppp.pm:1122/alex/ndp.git" "url": "ssh://gitea@git.ppp.pm:1122/alex/ndp.git"
}, },
@@ -950,7 +932,6 @@
"pppdotpm-site": "pppdotpm-site", "pppdotpm-site": "pppdotpm-site",
"puppy-tracker": "puppy-tracker", "puppy-tracker": "puppy-tracker",
"schema": "schema", "schema": "schema",
"solo-referee": "solo-referee",
"todo": "todo", "todo": "todo",
"whib-backend": "whib-backend", "whib-backend": "whib-backend",
"whib-frontend": "whib-frontend" "whib-frontend": "whib-frontend"
@@ -977,28 +958,6 @@
"url": "ssh://gitea@git.ppp.pm:1122/alex/schema.git" "url": "ssh://gitea@git.ppp.pm:1122/alex/schema.git"
} }
}, },
"solo-referee": {
"inputs": {
"flake-utils": "flake-utils_4",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1793606847,
"narHash": "sha256-S1TQWwx1dm9Y/TWWmaxUGCuBIKmftiXx+uNshj/2K7M=",
"ref": "main",
"rev": "cf0ebe6df54fd1d3203f531d90718ca54803abb9",
"revCount": 81,
"type": "git",
"url": "ssh://gitea@git.ppp.pm:1122/alex/solo-referee.git"
},
"original": {
"ref": "main",
"type": "git",
"url": "ssh://gitea@git.ppp.pm:1122/alex/solo-referee.git"
}
},
"systems": { "systems": {
"locked": { "locked": {
"lastModified": 1689347949, "lastModified": 1689347949,
@@ -1074,21 +1033,6 @@
"type": "github" "type": "github"
} }
}, },
"systems_6": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"todo": { "todo": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
-6
View File
@@ -105,12 +105,6 @@
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
solo-referee = {
url = "git+ssh://gitea@git.ppp.pm:1122/alex/solo-referee.git?ref=main";
# url = "path:/home/alex/code/solo-referee";
inputs.nixpkgs.follows = "nixpkgs";
};
schema = { schema = {
url = "git+ssh://gitea@git.ppp.pm:1122/alex/schema.git?ref=main"; url = "git+ssh://gitea@git.ppp.pm:1122/alex/schema.git?ref=main";
# url = "path:/home/alex/code/schema"; # url = "path:/home/alex/code/schema";
-1
View File
@@ -27,7 +27,6 @@ in
homepage.enable = true; homepage.enable = true;
disk-smart.enable = true; disk-smart.enable = true;
puppy-tracker.enable = true; puppy-tracker.enable = true;
solo-referee.enable = true;
todo.enable = true; todo.enable = true;
schema.enable = true; schema.enable = true;
atuin.enable = true; atuin.enable = true;
-1
View File
@@ -105,7 +105,6 @@ let
snapshot /var/lib/jellyfin "$STATE/jellyfin" --exclude='transcodes/' --exclude='cache/' --exclude='metadata/' --exclude='log/' --exclude='data/subtitles/' snapshot /var/lib/jellyfin "$STATE/jellyfin" --exclude='transcodes/' --exclude='cache/' --exclude='metadata/' --exclude='log/' --exclude='data/subtitles/'
snapshot /var/lib/audiobookshelf "$STATE/audiobookshelf" --exclude='metadata/' snapshot /var/lib/audiobookshelf "$STATE/audiobookshelf" --exclude='metadata/'
snapshot /var/lib/puppy-tracker "$STATE/puppy-tracker" snapshot /var/lib/puppy-tracker "$STATE/puppy-tracker"
snapshot /var/lib/solo-referee "$STATE/solo-referee"
snapshot /var/lib/todo "$STATE/todo" snapshot /var/lib/todo "$STATE/todo"
snapshot /var/lib/schema "$STATE/schema" snapshot /var/lib/schema "$STATE/schema"
snapshot /var/lib/dagbok "$STATE/dagbok" snapshot /var/lib/dagbok "$STATE/dagbok"
@@ -1,46 +0,0 @@
{
inputs,
lib,
config,
...
}:
let
enabled = config.mod.solo-referee.enable;
port = 8090;
in
{
options = {
mod.solo-referee = {
enable = lib.mkEnableOption "Enable solo-referee module";
};
};
imports = [
inputs.solo-referee.nixosModules.default
];
config = lib.mkIf enabled {
mod.homepage.services = [
{
name = "Solo Referee";
port = port;
description = "Solo-RPG tool with Claude as GM";
# url omitted → homepage links to http://manatee:${port}.
}
];
services.solo-referee = {
enable = true;
inherit port;
# Reachable on the LAN / Tailscale at manatee:${port}; no public vhost.
address = "0.0.0.0";
openFirewall = true;
# Anthropic API key kept out of the store; the file holds
# `ANTHROPIC_API_KEY=...`. Without it the offline stub GM runs.
apiKeyFile = config.age.secrets."solo-referee-api-key".path;
};
age.secrets."solo-referee-api-key".file =
../../../../secrets/manatee/solo-referee-api-key.age;
};
}
+1 -1
View File
@@ -632,7 +632,7 @@ Setup prefix for keybindings.
) )
:custom :custom
(eglot-code-action-indications nil) (refactor-indications nil)
:hook ( :hook (
(eglot-managed-mode . mp-eglot-eldoc) (eglot-managed-mode . mp-eglot-eldoc)
+7
View File
@@ -49,6 +49,7 @@ in
server = "http://manatee:4533"; server = "http://manatee:4533";
user = "navi"; user = "navi";
passwordCommand = "cat ${config.age.secrets."navidrome-password".path}"; passwordCommand = "cat ${config.age.secrets."navidrome-password".path}";
anthropicKeyCommand = "cat ${config.age.secrets."ndp-llm-api-key".path}";
}; };
}; };
}; };
@@ -84,4 +85,10 @@ in
owner = "alex"; owner = "alex";
group = "users"; group = "users";
}; };
age.secrets."ndp-llm-api-key" = {
file = ../../../../secrets/pinwheel/ndp-llm-api-key.age;
owner = "alex";
group = "users";
};
} }
+35
View File
@@ -0,0 +1,35 @@
{ pkgs, ... }:
let
picard = pkgs.symlinkJoin {
name = "picard";
paths = [ pkgs.picard ];
nativeBuildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/picard --set QT_SCREEN_SCALE_FACTORS 1.5
'';
};
plugins = pkgs.linkFarm "picard-plugins" {
replaygain2 = pkgs.fetchFromGitHub {
owner = "metabrainz";
repo = "picard-plugin-replaygain2";
tag = "v2.3.1";
hash = "sha256-NBn/LgjDRVCHmbI+bU4j29UhrL33ctV9jXj6CfFRBWA=";
};
};
in
{
home-manager.users.alex = { lib, ... }: {
home.packages = [
picard
pkgs.rsgain
];
home.activation.picardReplayGainPlugin = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
if ! ${pkgs.picard}/bin/picard-cli plugins info replaygain2 2>/dev/null | grep -qF "${plugins}/replaygain2"; then
run ${pkgs.picard}/bin/picard-cli --yes plugins install --no-git --reinstall "${plugins}/replaygain2" \
|| warnEcho "Failed to install Picard plugin replaygain2"
fi
'';
};
}
+68 -34
View File
@@ -7,46 +7,77 @@
let let
inherit (config.boot.kernelPackages) kernel kernelModuleMakeFlags; inherit (config.boot.kernelPackages) kernel kernelModuleMakeFlags;
ipu6-isys = pkgs.stdenv.mkDerivation { mkPatchedModules =
{
pname,
srcPaths,
dir,
patches,
postPatch,
}:
pkgs.stdenv.mkDerivation {
inherit pname patches postPatch;
inherit (kernel) version;
__structuredAttrs = true;
nativeBuildInputs = kernel.moduleBuildDependencies;
unpackPhase = ''
tar -xf ${kernel.src} --strip-components=1 --wildcards \
${lib.escapeShellArgs (map (path: "*/${path}") srcPaths)}
'';
makeFlags = kernelModuleMakeFlags ++ [
"KERNELRELEASE=${kernel.modDirVersion}"
];
installFlags = [
"DEPMOD=true"
"INSTALL_MOD_PATH=${placeholder "out"}"
];
buildPhase = ''
runHook preBuild
make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build \
M=$(pwd)/${dir} "''${makeFlags[@]}"
runHook postBuild
'';
installPhase = ''
runHook preInstall
make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build \
M=$(pwd)/${dir} modules_install \
"''${makeFlags[@]}" "''${installFlags[@]}"
runHook postInstall
'';
};
ipu6-isys = mkPatchedModules {
pname = "ipu6-isys"; pname = "ipu6-isys";
inherit (kernel) version; srcPaths = [ "drivers/media/pci/intel/ipu6/*" ];
dir = "drivers/media/pci/intel/ipu6";
__structuredAttrs = true;
patches = [ ./ipu6-isys-runtime-pm-null-check.patch ]; patches = [ ./ipu6-isys-runtime-pm-null-check.patch ];
nativeBuildInputs = kernel.moduleBuildDependencies;
unpackPhase = ''
tar -xf ${kernel.src} --strip-components=1 --wildcards '*/drivers/media/pci/intel/ipu6/*'
'';
postPatch = '' postPatch = ''
sed -i '/+= intel-ipu6\.o/d' drivers/media/pci/intel/ipu6/Makefile sed -i '/+= intel-ipu6\.o/d' drivers/media/pci/intel/ipu6/Makefile
''; '';
};
makeFlags = kernelModuleMakeFlags ++ [ usbio = mkPatchedModules {
"KERNELRELEASE=${kernel.modDirVersion}" pname = "usbio";
srcPaths = [
"drivers/usb/misc/usbio.c"
"drivers/gpio/gpio-usbio.c"
"include/linux/usb/usbio.h"
]; ];
dir = "usbio";
installFlags = [ patches = [ ./usbio-reset-resume.patch ];
"DEPMOD=true" postPatch = ''
"INSTALL_MOD_PATH=${placeholder "out"}" mkdir -p usbio/include/linux/usb
]; cp drivers/usb/misc/usbio.c drivers/gpio/gpio-usbio.c usbio/
cp include/linux/usb/usbio.h usbio/include/linux/usb/
buildPhase = '' echo 'LINUXINCLUDE := -I$(src)/include $(LINUXINCLUDE)' > usbio/Kbuild
runHook preBuild echo 'obj-m += usbio.o gpio-usbio.o' >> usbio/Kbuild
make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build \
M=$(pwd)/drivers/media/pci/intel/ipu6 "''${makeFlags[@]}"
runHook postBuild
'';
installPhase = ''
runHook preInstall
make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build \
M=$(pwd)/drivers/media/pci/intel/ipu6 modules_install \
"''${makeFlags[@]}" "''${installFlags[@]}"
runHook postInstall
''; '';
}; };
in in
@@ -79,7 +110,10 @@ in
}) })
]; ];
boot.extraModulePackages = [ ipu6-isys ]; boot.extraModulePackages = [
ipu6-isys
usbio
];
hardware.ipu6 = { hardware.ipu6 = {
enable = true; enable = true;
@@ -0,0 +1,320 @@
--- a/drivers/usb/misc/usbio.c
+++ b/drivers/usb/misc/usbio.c
@@ -83,6 +83,7 @@
* @gpios: GPIO bank descriptors
* @nr_gpio_banks: Number of I2C busses
* @gpios: I2C bank descriptors
+ * @reset_count: Number of times the bridge was reset while bound
*/
struct usbio_device {
struct device *dev;
@@ -115,6 +116,8 @@
unsigned int nr_i2c_buses;
struct usbio_i2c_bus_desc i2cs[USBIO_MAX_I2CBUSES];
+
+ unsigned int reset_count;
};
/**
@@ -428,6 +431,21 @@
}
EXPORT_SYMBOL_NS_GPL(usbio_get_quirks, "USBIO");
+unsigned int usbio_get_reset_count(struct auxiliary_device *adev)
+{
+ struct usbio_client *client = adev_to_client(adev);
+ struct usbio_device *usbio;
+
+ guard(mutex)(&client->mutex);
+
+ usbio = client->bridge;
+ if (!usbio)
+ return 0; /* Disconnected */
+
+ return usbio->reset_count;
+}
+EXPORT_SYMBOL_NS_GPL(usbio_get_reset_count, "USBIO");
+
static void usbio_auxdev_release(struct device *dev)
{
struct auxiliary_device *adev = to_auxiliary_dev(dev);
@@ -503,6 +521,47 @@
return 0;
}
+static int usbio_init_bridge(struct usbio_device *usbio)
+{
+ struct usbio_protver protver;
+ struct usbio_fwver fwver;
+ int ret;
+
+ guard(mutex)(&usbio->ctrl_mutex);
+
+ ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_HS, NULL, 0, NULL, 0);
+ if (ret < 0)
+ return ret;
+
+ ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_PROTVER, NULL, 0,
+ &protver, sizeof(protver));
+ if (ret < 0)
+ return ret;
+
+ ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_FWVER, NULL, 0,
+ &fwver, sizeof(fwver));
+ if (ret < 0)
+ return ret;
+
+ ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_ENUMGPIO, NULL, 0,
+ usbio->gpios, sizeof(usbio->gpios));
+ if (ret < 0 || ret % sizeof(struct usbio_gpio_bank_desc))
+ return (ret < 0) ? ret : -EPROTO;
+ usbio->nr_gpio_banks = ret / sizeof(struct usbio_gpio_bank_desc);
+
+ ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_ENUMI2C, NULL, 0,
+ usbio->i2cs, sizeof(usbio->i2cs));
+ if (ret < 0 || ret % sizeof(struct usbio_i2c_bus_desc))
+ return (ret < 0) ? ret : -EPROTO;
+ usbio->nr_i2c_buses = ret / sizeof(struct usbio_i2c_bus_desc);
+
+ dev_dbg(usbio->dev, "ProtVer(BCD): %02x FwVer: %d.%d.%d.%d\n",
+ protver.ver, fwver.major, fwver.minor,
+ le16_to_cpu(fwver.patch), le16_to_cpu(fwver.build));
+
+ return 0;
+}
+
static int usbio_suspend(struct usb_interface *intf, pm_message_t msg)
{
struct usbio_device *usbio = usb_get_intfdata(intf);
@@ -519,6 +578,26 @@
return usb_submit_urb(usbio->urb, GFP_KERNEL);
}
+static int usbio_reset_resume(struct usb_interface *intf)
+{
+ struct usbio_device *usbio = usb_get_intfdata(intf);
+ int ret;
+
+ ret = usb_submit_urb(usbio->urb, GFP_KERNEL);
+ if (ret)
+ return ret;
+
+ ret = usbio_init_bridge(usbio);
+ if (ret) {
+ usb_kill_urb(usbio->urb);
+ return ret;
+ }
+
+ usbio->reset_count++;
+
+ return 0;
+}
+
static void usbio_disconnect(struct usb_interface *intf)
{
struct usbio_device *usbio = usb_get_intfdata(intf);
@@ -550,9 +629,7 @@
struct usb_device *udev = interface_to_usbdev(intf);
struct usb_endpoint_descriptor *ep_in, *ep_out;
struct device *dev = &intf->dev;
- struct usbio_protver protver;
struct usbio_device *usbio;
- struct usbio_fwver fwver;
int ret;
usbio = devm_kzalloc(dev, sizeof(*usbio), GFP_KERNEL);
@@ -623,51 +700,16 @@
goto err_free_urb;
}
- mutex_lock(&usbio->ctrl_mutex);
-
- ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_HS, NULL, 0, NULL, 0);
- if (ret < 0)
- goto err_unlock;
-
- ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_PROTVER, NULL, 0,
- &protver, sizeof(protver));
- if (ret < 0)
- goto err_unlock;
-
- ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_FWVER, NULL, 0,
- &fwver, sizeof(fwver));
- if (ret < 0)
- goto err_unlock;
-
- ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_ENUMGPIO, NULL, 0,
- usbio->gpios, sizeof(usbio->gpios));
- if (ret < 0 || ret % sizeof(struct usbio_gpio_bank_desc)) {
- ret = (ret < 0) ? ret : -EPROTO;
- goto err_unlock;
- }
- usbio->nr_gpio_banks = ret / sizeof(struct usbio_gpio_bank_desc);
-
- ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_ENUMI2C, NULL, 0,
- usbio->i2cs, sizeof(usbio->i2cs));
- if (ret < 0 || ret % sizeof(struct usbio_i2c_bus_desc)) {
- ret = (ret < 0) ? ret : -EPROTO;
- goto err_unlock;
- }
- usbio->nr_i2c_buses = ret / sizeof(struct usbio_i2c_bus_desc);
-
- mutex_unlock(&usbio->ctrl_mutex);
-
- dev_dbg(dev, "ProtVer(BCD): %02x FwVer: %d.%d.%d.%d\n",
- protver.ver, fwver.major, fwver.minor,
- le16_to_cpu(fwver.patch), le16_to_cpu(fwver.build));
+ ret = usbio_init_bridge(usbio);
+ if (ret)
+ goto err_kill_urb;
usbio_enum_gpios(usbio);
usbio_enum_i2cs(usbio);
return 0;
-err_unlock:
- mutex_unlock(&usbio->ctrl_mutex);
+err_kill_urb:
usb_kill_urb(usbio->urb);
err_free_urb:
usb_free_urb(usbio->urb);
@@ -694,6 +736,7 @@
.disconnect = usbio_disconnect,
.suspend = usbio_suspend,
.resume = usbio_resume,
+ .reset_resume = usbio_reset_resume,
.id_table = usbio_table,
.supports_autosuspend = 1,
};
--- a/drivers/gpio/gpio-usbio.c
+++ b/drivers/gpio/gpio-usbio.c
@@ -15,14 +15,16 @@
struct usbio_gpio_bank {
u8 config[USBIO_GPIOSPERBANK];
+ u32 value;
u32 bitmap;
};
struct usbio_gpio {
- struct mutex config_mutex; /* Protects banks[x].config */
+ struct mutex config_mutex; /* Protects banks[x].config and banks[x].value */
struct usbio_gpio_bank banks[USBIO_MAX_GPIOBANKS];
struct gpio_chip gc;
struct auxiliary_device *adev;
+ unsigned int reset_count;
};
static const struct acpi_device_id usbio_gpio_acpi_hids[] = {
@@ -101,6 +103,13 @@
usbio_gpio_get_bank_and_pin(gc, offset, &bank, &pin);
+ scoped_guard(mutex, &gpio->config_mutex) {
+ if (value)
+ bank->value |= BIT(pin);
+ else
+ bank->value &= ~BIT(pin);
+ }
+
gbuf.bankid = offset / USBIO_GPIOSPERBANK;
gbuf.pincount = 1;
gbuf.pin = pin;
@@ -178,6 +187,66 @@
return usbio_gpio_update_config(gc, offset, USBIO_GPIO_PINCFG_MASK, value);
}
+static int usbio_gpio_restore(struct usbio_gpio *gpio)
+{
+ struct usbio_gpio_init ginit;
+ struct usbio_gpio_rw gbuf;
+ int ret;
+
+ guard(mutex)(&gpio->config_mutex);
+
+ for (unsigned int b = 0; b < USBIO_MAX_GPIOBANKS; b++) {
+ struct usbio_gpio_bank *bank = &gpio->banks[b];
+
+ for (unsigned int pin = 0; pin < USBIO_GPIOSPERBANK; pin++) {
+ u8 mode = bank->config[pin] & USBIO_GPIO_PINMOD_MASK;
+
+ if (mode == USBIO_GPIO_PINMOD_INVAL)
+ continue;
+
+ ginit.bankid = b;
+ ginit.config = bank->config[pin];
+ ginit.pincount = 1;
+ ginit.pin = pin;
+
+ ret = usbio_control_msg(gpio->adev, USBIO_PKTTYPE_GPIO, USBIO_GPIOCMD_INIT,
+ &ginit, sizeof(ginit), NULL, 0);
+ if (ret)
+ return ret;
+
+ if (mode != USBIO_GPIO_PINMOD_OUTPUT)
+ continue;
+
+ gbuf.bankid = b;
+ gbuf.pincount = 1;
+ gbuf.pin = pin;
+ gbuf.value = cpu_to_le32(bank->value & BIT(pin));
+
+ ret = usbio_control_msg(gpio->adev, USBIO_PKTTYPE_GPIO, USBIO_GPIOCMD_WRITE,
+ &gbuf, sizeof(gbuf), NULL, 0);
+ if (ret)
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+static int usbio_gpio_resume(struct device *dev)
+{
+ struct usbio_gpio *gpio = dev_get_drvdata(dev);
+ unsigned int reset_count = usbio_get_reset_count(gpio->adev);
+
+ if (reset_count == gpio->reset_count)
+ return 0;
+
+ gpio->reset_count = reset_count;
+
+ return usbio_gpio_restore(gpio);
+}
+
+static DEFINE_SIMPLE_DEV_PM_OPS(usbio_gpio_pm_ops, NULL, usbio_gpio_resume);
+
static int usbio_gpio_probe(struct auxiliary_device *adev,
const struct auxiliary_device_id *adev_id)
{
@@ -199,6 +268,8 @@
return ret;
gpio->adev = adev;
+ gpio->reset_count = usbio_get_reset_count(adev);
+ dev_set_drvdata(dev, gpio);
usbio_acpi_bind(gpio->adev, usbio_gpio_acpi_hids);
@@ -238,7 +309,8 @@
static struct auxiliary_driver usbio_gpio_driver = {
.name = USBIO_GPIO_CLIENT,
.probe = usbio_gpio_probe,
- .id_table = usbio_gpio_id_table
+ .id_table = usbio_gpio_id_table,
+ .driver.pm = pm_sleep_ptr(&usbio_gpio_pm_ops),
};
module_auxiliary_driver(usbio_gpio_driver);
--- a/include/linux/usb/usbio.h
+++ b/include/linux/usb/usbio.h
@@ -172,6 +172,7 @@
void usbio_release(struct auxiliary_device *adev);
void usbio_get_txrxbuf_len(struct auxiliary_device *adev, u16 *txbuf_len, u16 *rxbuf_len);
unsigned long usbio_get_quirks(struct auxiliary_device *adev);
+unsigned int usbio_get_reset_count(struct auxiliary_device *adev);
void usbio_acpi_bind(struct auxiliary_device *adev, const struct acpi_device_id *hids);
#endif
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -28,6 +28,7 @@ in {
"pinwheel/work-production-ovpn.age".publicKeys = [ pinwheel alex ]; "pinwheel/work-production-ovpn.age".publicKeys = [ pinwheel alex ];
"pinwheel/naviterm-config.age".publicKeys = [ pinwheel alex ]; "pinwheel/naviterm-config.age".publicKeys = [ pinwheel alex ];
"pinwheel/navidrome-password.age".publicKeys = [ pinwheel alex ]; "pinwheel/navidrome-password.age".publicKeys = [ pinwheel alex ];
"pinwheel/ndp-llm-api-key.age".publicKeys = [ pinwheel alex ];
"pinwheel/atuin-key.age".publicKeys = [ pinwheel alex ]; "pinwheel/atuin-key.age".publicKeys = [ pinwheel alex ];
"manatee/root.manatee.age".publicKeys = [ manatee alex ]; "manatee/root.manatee.age".publicKeys = [ manatee alex ];
@@ -47,7 +48,6 @@ in {
"manatee/romm-db-password.age".publicKeys = [ manatee alex ]; "manatee/romm-db-password.age".publicKeys = [ manatee alex ];
"manatee/romm-metadata-api-keys.age".publicKeys = [ manatee alex ]; "manatee/romm-metadata-api-keys.age".publicKeys = [ manatee alex ];
"manatee/puppy-tracker-invite-code.age".publicKeys = [ manatee alex ]; "manatee/puppy-tracker-invite-code.age".publicKeys = [ manatee alex ];
"manatee/solo-referee-api-key.age".publicKeys = [ manatee alex ];
"manatee/todo-token.age".publicKeys = [ manatee alex ]; "manatee/todo-token.age".publicKeys = [ manatee alex ];
"manatee/dagbok-token.age".publicKeys = [ manatee pinwheel alex ]; "manatee/dagbok-token.age".publicKeys = [ manatee pinwheel alex ];
"manatee/schema-invite-code.age".publicKeys = [ manatee alex ]; "manatee/schema-invite-code.age".publicKeys = [ manatee alex ];