From patchwork Sat Feb 15 09:24:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Scherer X-Patchwork-Id: 38638 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 6FB6627BBEA; Sat, 15 Feb 2025 09:25:42 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id BC57727BBE2 for ; Sat, 15 Feb 2025 09:25:41 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tjEQ6-0006A1-Iw; Sat, 15 Feb 2025 04:25:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tjEQ3-000696-O7 for guix-patches@gnu.org; Sat, 15 Feb 2025 04:25:04 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tjEQ3-0001Ih-D0; Sat, 15 Feb 2025 04:25:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=IcjEG8FZPMpfO5cn0Tspc6YQdu+r4rugrySm4JmeJHo=; b=XJG/eSV24DFfcLXSSSRw0YjFYP16j3pGj89lB7E2SEf1dp4yCKXp8Gd9wLn4Q6FvI0e7ypFlGouxSzbq94otzS5jGwXWXuLhEXFShrWNkCu4PjRxBGtkwsZSf8oMjm9isJlz5j2ZzQ9HwXSG+XiF2q+0+95fh1HJtClf8cU6rG0MZMQDLBFUudYQbS2J3i4ZNCUDODirC7erWtQviVvihA5k2bkkg/JjugPcbSbHUnptp2K9M0dbvhmuKF1SfLSR5KcLrtik0vNaQPV0fFEXZMA38Xp13L7JYttl4ZbGa3CqzV2ss5/1ywtfGcbykHwHNo47VhV4+3f6c5rTNfWHZg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tjEQ2-0008FD-Gg; Sat, 15 Feb 2025 04:25:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#76289] [PATCH v3 2/2] services: Add speakersafetyd service. Resent-From: Roman Scherer Original-Sender: "Debbugs-submit" Resent-CC: ludo@gnu.org, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Sat, 15 Feb 2025 09:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 76289 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 76289@debbugs.gnu.org Cc: Roman Scherer , Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer X-Debbugs-Original-Xcc: Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer Received: via spool by 76289-submit@debbugs.gnu.org id=B76289.173961149431662 (code B ref 76289); Sat, 15 Feb 2025 09:25:02 +0000 Received: (at 76289) by debbugs.gnu.org; 15 Feb 2025 09:24:54 +0000 Received: from localhost ([127.0.0.1]:53364 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tjEPu-0008EX-0k for submit@debbugs.gnu.org; Sat, 15 Feb 2025 04:24:54 -0500 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]:53431) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1tjEPr-0008E7-1E for 76289@debbugs.gnu.org; Sat, 15 Feb 2025 04:24:51 -0500 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-ab7ee6f54faso330200666b.2 for <76289@debbugs.gnu.org>; Sat, 15 Feb 2025 01:24:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=burningswell-com.20230601.gappssmtp.com; s=20230601; t=1739611484; x=1740216284; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IcjEG8FZPMpfO5cn0Tspc6YQdu+r4rugrySm4JmeJHo=; b=u7XsV5nbuu+L0RdFft8Gy/Den1rmZmbopkvq6GVGemwwQIbjaiUAulbIz4zgD2ecRU RjlquFPNWJTZFtKUoDXaJI0j54YeDeeC8LUc6k2+Pj4eHE/zDxo8QPwoqe9hHAB7C/RX zYLpNSLHdZ68lZJxnUECBdVvZchAKPavBO7buqLkxLYy557ljoKvUSw4tu7s1KVskwT2 O6PUouJ/9JsCCn23IPjEk6+0SFF5yiMKcfoDTgR1YqiLFadM8DRRXdoV1KWvWKcFW4XQ 7SnsXfWaNPbSr1OFU/t01SxpX+xIgRhdgsd1wU4WUGodg15c4K6YImFKwxp6OU/gfgQo j4fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739611484; x=1740216284; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IcjEG8FZPMpfO5cn0Tspc6YQdu+r4rugrySm4JmeJHo=; b=LtfRqMyl3969SYr+V4+AHh2xChRXQT1AoExyJS4YaeXxBLgXvQYnV3zPXwBCPUM27/ 77+RMBVnfZdTnWgPGLni0TfrVSxVY3dbNHzi0nAL72azlR6dwS6edFZrze86DhCBpcxy 3u3iHmxZYFxXFpnc/9VjcTFN44eqg8yt2yIt1P6EFXDLFg3IGT8rpd2SQwiAlBFMczF0 yKbfK+qBK81+mjRIdUHUa5ZCe9uUHfyxHQNEIScZrBtIdJWCkFM96uy1zWOFHo/wH8m1 AB9ZbcrWE9rZryp5gY+iUwV0W0XUQA0z6kJSZAlBeHO0rde0fvnJzl0G3d2vfAinsXUl wfhw== X-Gm-Message-State: AOJu0YwzxsKyUvZpnRFW8dhJmLR8Q5opRPSeFnzBRqIiaZAQUfwrurZt D8LkR0PXhZOiwxxKUjdySeLQt3MHvivAtat3jjALUUPqfOwquziQHfcXlhQU4EWdo13l4RClhIz QoNA= X-Gm-Gg: ASbGncukQlt+9Jo9hlZjzNQ45LS+Yi958E0Q04k4TnpjC9AGklohUdVqrXpBQZvUMXK 82msIcVSdDXcvBWho4pdrBn4u+H1uF0TXqw0o/Umv6hgUsvbaRTfrRzrPgKNL+873bVncLuC7Cw o7kpmlB71ZSAPy0ap952Ehkk9OmHaEpsWp+NNOD5ioCZjdwZ0EHcLEzb5gvhkvftUoBcVth/oY8 QcN4zO+sKFTn+TPmcuBY5qi6zPorn1Abcmu+ZGXaaRYC4mTzBrd31ZljZYvsvMg0hdetH2pXc1d UTJhon+ijKxbL9uYo3rBKmIt1wJ7X3Rz X-Google-Smtp-Source: AGHT+IH+PHHQKREg07tewv4yqwAA/uJukAB0sEhrE8SG/hdBgkbPWp7e7ksqxKeA2xAeo/0v65LQLQ== X-Received: by 2002:a05:6402:2745:b0:5dc:5ada:e0c7 with SMTP id 4fb4d7f45d1cf-5e036155c28mr6235605a12.26.1739611483082; Sat, 15 Feb 2025 01:24:43 -0800 (PST) Received: from localhost.localdomain ([2a01:599:10b:f79:d63b:6274:c334:5aad]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aba5327fc9bsm496053866b.75.2025.02.15.01.24.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Feb 2025 01:24:42 -0800 (PST) From: Roman Scherer Date: Sat, 15 Feb 2025 10:24:35 +0100 Message-ID: X-Mailer: git-send-email 2.48.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/services/sound.scm (speakersafetyd-service-type) New variable. * doc/guix.texi: Document the speakersafetyd service. Change-Id: Ib8fa19b056a2036019ae7c199d81e1139664e951 --- doc/guix.texi | 42 +++++++++++++++++++++++++++ gnu/services/sound.scm | 65 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 106 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index bd66adf326..ec5c7ab5cf 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -26575,6 +26575,48 @@ Sound Services @end defvar +@subsubheading Speaker Safety Daemon System Service + +@uref{https://github.com/AsahiLinux/speakersafetyd, Speaker Safety +Daemon} is a user-space daemon that implements an analogue of the Texas +Instruments Smart Amp speaker protection model. It can be used to +protect the speakers on Apple Silicon devices. + +@defvar speakersafetyd-service-type +This is the type for the @code{speakersafetyd} system service, whose +value is a @command{speakersafetyd-configuration} record. + +@lisp +(service speakersafetyd-service-type) +@end lisp + +See below for details about @code{speakersafetyd-configuration}. +@end defvar + +@deftp {Data Type} speakersafetyd-configuration +Available @code{speakersafetyd-configuration} fields are: + +@table @asis +@item @code{blackbox-directory} (default: @code{"/var/lib/speakersafetyd/blackbox"}) (type: string) +The directory to which blackbox files are written when the speakers are +getting too hot. The blackbox files contain audio and debug information +which the developers of @code{speakersafetyd} might ask for when +reporting bugs. + +@item @code{configuration-directory} (type: file-like) +The base directory as a G-expression (@pxref{G-Expressions}) that +contains the configuration files of the speaker models. + +@item @code{maximum-gain-reduction} (default: @code{7}) (type: integer) +Maximum gain reduction before panicing, useful for debugging. + +@item @code{speakersafetyd} (default: @code{speakersafetyd}) (type: file-like) +The Speaker Safety Daemon package to use. + +@end table + +@end deftp + @node File Search Services @subsection File Search Services diff --git a/gnu/services/sound.scm b/gnu/services/sound.scm index 8ca7acd737..bf7d3cc6b0 100644 --- a/gnu/services/sound.scm +++ b/gnu/services/sound.scm @@ -35,6 +35,7 @@ (define-module (gnu services sound) #:use-module (gnu packages audio) #:use-module (gnu packages linux) #:use-module (gnu packages pulseaudio) + #:use-module (gnu packages rust-apps) #:use-module (ice-9 match) #:use-module (srfi srfi-1) #:export (alsa-configuration @@ -56,7 +57,15 @@ (define-module (gnu services sound) ladspa-configuration ladspa-configuration? ladspa-configuration-plugins - ladspa-service-type)) + ladspa-service-type + + speakersafetyd-configuration + speakersafetyd-configuration-blackbox-directory + speakersafetyd-configuration-configuration-directory + speakersafetyd-configuration-maximum-gain-reduction + speakersafetyd-configuration-speakersafetyd + speakersafetyd-configuration? + speakersafetyd-service-type)) ;;; Commentary: ;;; @@ -263,4 +272,58 @@ (define ladspa-service-type (default-value (ladspa-configuration)) (description "Configure LADSPA plugins."))) + +;;; +;;; Speaker Safety Daemon +;;; + +(define-configuration/no-serialization speakersafetyd-configuration + (blackbox-directory + (string "/var/lib/speakersafetyd/blackbox") + "The directory to which blackbox files are written when the speakers are +getting too hot. The blackbox files contain audio and debug information which +the developers of @code{speakersafetyd} might ask for when reporting bugs.") + (configuration-directory + (file-like (file-append speakersafetyd "/share/speakersafetyd")) + "The base directory as a G-expression (@pxref{G-Expressions}) that contains +the configuration files of the speaker models.") + (maximum-gain-reduction + (integer 7) + "Maximum gain reduction before panicing, useful for debugging.") + (speakersafetyd + (file-like speakersafetyd) + "The Speaker Safety Daemon package to use.")) + +(define speakersafetyd-shepherd-service + (match-record-lambda + (blackbox-directory configuration-directory maximum-gain-reduction speakersafetyd) + (shepherd-service + (documentation "Run the speaker safety daemon") + (provision '(speakersafetyd)) + (requirement '(udev)) + (start #~(make-forkexec-constructor + (list #$(file-append speakersafetyd "/bin/speakersafetyd") + "--config-path" #$configuration-directory + "--blackbox-path" #$blackbox-directory + "--max-reduction" (number->string #$maximum-gain-reduction)))) + (stop #~(make-kill-destructor))))) + +(define speakersafetyd-service-type + (service-type + (name 'speakersafetyd) + (description "Run @command{speakersafetyd}, a user space daemon that +implements an analogue of the Texas Instruments Smart Amp speaker protection +model. It can be used to protect the speakers on Apple Silicon devices.") + (extensions + (list (service-extension + shepherd-root-service-type + (compose list speakersafetyd-shepherd-service)) + (service-extension + udev-service-type + (compose list speakersafetyd-configuration-speakersafetyd)) + (service-extension + profile-service-type + (compose list speakersafetyd-configuration-speakersafetyd)))) + (default-value (speakersafetyd-configuration)))) + ;;; sound.scm ends here