From patchwork Fri Feb 14 13:58:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Scherer X-Patchwork-Id: 38603 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 0ECBE27BBE2; Fri, 14 Feb 2025 13:59:30 +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=unavailable 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 93EF527BBE9 for ; Fri, 14 Feb 2025 13:59:28 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tiwE0-0006Ga-6t; Fri, 14 Feb 2025 08:59:25 -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 1tiwDg-000689-Tf for guix-patches@gnu.org; Fri, 14 Feb 2025 08:59: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 1tiwDf-0001fw-5V; Fri, 14 Feb 2025 08:59: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=05yI693V+sfz1B8ed6ythrdeuZAj0zcKv3dkmkLfHMI=; b=abv4+AJnVNiw0/JmTqKcHdnuRGL+PkYwxFpsWzWivFNwtfk6wtDtw3MwRRKG4zTQxyNVxackoKX6xblN90VN5CZbBhGdZ8JYUn0ihkIWU41apf9rB4JtGu/qljXXwUIlIHVRA9ZVpTuQrjNW7pl1obEMVQwF15zpuGx3HYXeTnXjldm6Xg+jnNX28NrTgtoyv4jSorLVhlxhpQZ04s4nt38WOAi2Hjr58iMZnKWJD4Z8Phgot10eJN0M8VHKlyLUZSLYvyYmnqsS9rgizKViXm/JDmpTZelTNCOpi+UdC8u83/CA6twHQ1Gx50pEvQ0lNmwSNqMZMzphKZ7CwB4/oA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tiwDe-0002tZ-L8; Fri, 14 Feb 2025 08:59:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#76289] [PATCH 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: Fri, 14 Feb 2025 13:59: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 , efraim@flashner.co.il, 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.173954150811075 (code B ref 76289); Fri, 14 Feb 2025 13:59:02 +0000 Received: (at 76289) by debbugs.gnu.org; 14 Feb 2025 13:58:28 +0000 Received: from localhost ([127.0.0.1]:47672 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tiwD5-0002sY-Pm for submit@debbugs.gnu.org; Fri, 14 Feb 2025 08:58:28 -0500 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]:48535) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1tiwD1-0002s5-HS for 76289@debbugs.gnu.org; Fri, 14 Feb 2025 08:58:24 -0500 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-5de6e26d4e4so3938588a12.1 for <76289@debbugs.gnu.org>; Fri, 14 Feb 2025 05:58:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=burningswell-com.20230601.gappssmtp.com; s=20230601; t=1739541497; x=1740146297; 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=05yI693V+sfz1B8ed6ythrdeuZAj0zcKv3dkmkLfHMI=; b=z+b84criGt/qeMqx4+MseIk3G8M7QznojvJeCVgm2VdeKAy5y42nfJHmcbvNrPvRJh fka42hrP9vY+b299BMhDAidkzeQoRE0qkvXWFiKHnQbHY28Oa7mZI9T589EGoPqEz044 FTRM7/yAHR/3q5UGqWNcCzDaSUX2L0VEJPHQP83LyLQaCulT2aZDy0MwAMUlijFeeXvu ITcNhrHBjt5qoksqYyr+ZV51xz9AWLQaE33lz6cgu1B0yAWAsMJ7Kg1/ImGlwbqa6eIc D+YWL8Edy4ZBgENzHhMqJHZHGSV1twJZPuA5HTCqKgprEDmtIW7SAnZlr+M2KaCCBLgy 1Gwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739541497; x=1740146297; 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=05yI693V+sfz1B8ed6ythrdeuZAj0zcKv3dkmkLfHMI=; b=gcsLsAadmIyEREJZQnfVsyLpBTK6GOwb7W/kKD1wDSLWJZsQwZsibT0uIm+tR++q4L yxtXcHYGJ0N5TR7alB6VkHvL7I0qJjtLTi++7savovjiZYEQ7QPIQGurGRARz5HoTuLv isjz9F9T68ASG4ruZIpUAUb5QjJ/Eegc/SXcw6qYI/yORG8CSGIu0NtUx+aj/BbkyUM4 rsLfcbB0LRoSWEQFMP1iAfAT64+PeKWMK6fOdyoxLtW+4lGG685EBkomzBdQNVj3pfk8 9JLfkMesmcVSDKJ5GltQrzCk3xxI7trdKoyOOzUfkOoHt8yegJiquClhSraDtdyMxjXi aRHA== X-Gm-Message-State: AOJu0YxqIVhZeL49yvF99SwtioUVdNCL5IUXd9V357d4AxKEJvNdzPKL PkkVvB9iXwYFD4MwvmZ6bWpHwaZo6cIVHiGduDZNXyPw2VEmNJ2UGq/l1VbYiE4UmheFyUbxtyg GIKY= X-Gm-Gg: ASbGnctf2n18yQQMjv97iJJsUQWC02Fg9LE0KLojeQlLdmhzMR8mXXdJBzIMTgH9sNJ jU/6CtIzvRnQaR2Pci4t7qeiLBe+ETR+3ZR5vYMMPWEXEcrvSLgWcLcT8SvAtfi6y/c75WdH+Ru Q2xSpqsKz8QGTM9bCbNiUd6bQt46T014l+p/7qVIaqRGKiiwiqcDZIyViPPF7sT6/H4yM/Gfzf/ 64VSS9bPhV8GIXxRLpsX6uR/Ybzq/sC2SBFLs54LbdenhyX7A6J8cHKROBjtIODPwRyVoUu0+k0 9HRKAP1XrJG/Ddwz1SzCex4ePw5tUJEt X-Google-Smtp-Source: AGHT+IHFAweKRoxSarbyxmutAIMpXITarR195BRsvcUomG3HGvxhQaV/eEiE8GlVM6eBYTim25rm7A== X-Received: by 2002:a05:6402:a001:b0:5de:cc6f:43d0 with SMTP id 4fb4d7f45d1cf-5decc6f46aamr4522298a12.31.1739541496958; Fri, 14 Feb 2025 05:58:16 -0800 (PST) Received: from localhost.localdomain ([2a01:599:10b:f79:d63b:6274:c334:5aad]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5dece270967sm2950587a12.55.2025.02.14.05.58.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Feb 2025 05:58:16 -0800 (PST) From: Roman Scherer Date: Fri, 14 Feb 2025 14:58:10 +0100 Message-ID: <6bdfd356508e8f643f2c63cb796548f36e0abb87.1739540583.git.roman@burningswell.com> 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 | 41 ++++++++++++++++++++++++++++ gnu/services/sound.scm | 61 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 101 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index bd66adf326..3b82df5196 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -26575,6 +26575,47 @@ Sound Services @end defvar +@subsubheading Speaker Safety Daemon System Service + +@uref{https://github.com/AsahiLinux/speakersafetyd, Speaker Safety +Daemon} is a userspace 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 +Data type representing the configuration for @code{speakersafetyd-service}. + +@table @asis +@item @code{blackbox-path} (default: @code{"/var/lib/speakersafetyd/blackbox"}) +The path to a 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{config-path} (default: @code{(file-append speakersafetyd "/share/speakersafetyd")}) +Path to the base directory as a G-expression (@pxref{G-Expressions}) +that contains the configuration files of the speaker models. + +@item @code{max-reduction} (default: @code{7}) +Maximum gain reduction before panicing, useful for debugging. + +@item @code{package} (default: @var{speakersafetyd}) +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..fb8a8d3d17 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-path + speakersafetyd-configuration-config-path + speakersafetyd-configuration-max-reduction + speakersafetyd-configuration-package + speakersafetyd-configuration? + speakersafetyd-service-type)) ;;; Commentary: ;;; @@ -263,4 +272,54 @@ (define ladspa-service-type (default-value (ladspa-configuration)) (description "Configure LADSPA plugins."))) + +;;; +;;; Speaker Safety Daemon +;;; + +(define-record-type* + speakersafetyd-configuration + make-speakersafetyd-configuration + speakersafetyd-configuration? + (blackbox-path speakersafetyd-configuration-blackbox-path + (default "/var/lib/speakersafetyd/blackbox")) + (config-path speakersafetyd-configuration-config-path + (default (file-append speakersafetyd "/share/speakersafetyd"))) + (max-reduction speakersafetyd-configuration-max-reduction + (default 7)) + (package speakersafetyd-configuration-package + (default speakersafetyd))) + +(define (speakersafetyd-shepherd-service config) + (let ((blackbox-path (speakersafetyd-configuration-blackbox-path config)) + (config-path (speakersafetyd-configuration-config-path config)) + (max-reduction (speakersafetyd-configuration-max-reduction config)) + (package (speakersafetyd-configuration-package config))) + (shepherd-service + (documentation "Speaker saftey daemon") + (provision '(speakersafetyd)) + (requirement '(udev)) + (start #~(make-forkexec-constructor + (list #$(file-append package "/bin/speakersafetyd") + "--config-path" #$config-path + "--blackbox-path" #$blackbox-path + "--max-reduction" (number->string #$max-reduction)))) + (stop #~(make-kill-destructor))))) + +(define speakersafetyd-service-type + (service-type + (name 'speakersafetyd) + (description "Speaker Saftey Daemon") + (extensions + (list (service-extension + profile-service-type + (compose list speakersafetyd-configuration-package)) + (service-extension + shepherd-root-service-type + (compose list speakersafetyd-shepherd-service)) + (service-extension + udev-service-type + (compose list speakersafetyd-configuration-package)))) + (default-value (speakersafetyd-configuration)))) + ;;; sound.scm ends here