From nobody Tue Apr 7 08:15:22 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.com ARC-Seal: i=1; a=rsa-sha256; t=1773605905; cv=none; d=zohomail.com; s=zohoarc; b=cswJ7lD14cFKGVFY6s92dOIaUFzmqxiVBAU6+ytDv+hLu+Iak767dyjBmZEBzELTkOTMmOzy82WV8JnffadzRm2pNekVIt00OJ8qiBRBtHJJZNJhwd3Lo9A2wUPdVYeiNRJ+ya0bLfmk3nAQM9de7t1HXM0k2WdsG7QuJlCTt9Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773605905; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xju9CfSPT1DfYBW2oFrwhc0C2Ax+iiriDHMYm76fAYo=; b=QVz6JKKcmwRKOc7bjXyYHRoCjPQRLqyRqoRgaHdRGVDd/Q5R2ETaLFIVsCLqRatlGO1t8D4XYTMX+RIFn+Eqes2CdVfXkWJWW13ayCoeaHcVabFVOZ+i/oazCEYRAOQAYbAyTgbvf5KRLdbd9N1nRzY59JCKTees0K5bynrmfLk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1773605905193838.7984317471224; Sun, 15 Mar 2026 13:18:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w1ruF-0006N8-14; Sun, 15 Mar 2026 16:17:49 -0400 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 1w1rtz-0006Kj-M0 for qemu-devel@nongnu.org; Sun, 15 Mar 2026 16:17:31 -0400 Received: from forwardcorp1a.mail.yandex.net ([178.154.239.72]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w1rtT-0002LX-Jt for qemu-devel@nongnu.org; Sun, 15 Mar 2026 16:17:29 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:3530:0:640:eca4:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 173CAC015D; Sun, 15 Mar 2026 23:16:58 +0300 (MSK) Received: from localhost (unknown [2a02:6bf:8080:b49::1:d]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id uGRM4I1ATSw0-x7KRZieK; Sun, 15 Mar 2026 23:16:57 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.com; s=default; t=1773605817; bh=xju9CfSPT1DfYBW2oFrwhc0C2Ax+iiriDHMYm76fAYo=; h=Cc:Message-Id:References:Date:In-Reply-To:Subject:To:From; b=fXMM/MQjWlcqP17HrrmPTqqPMvhyyZs9gQigs6Elz8sT7Z9ZyTQUFPDeEzaQ5tOT/ KP5t5EYGYfNT0AJeodvkAj6XCYiChEvIOA2PWryuHUy43U6MEu1e98UdcJPR9Nhwn/ LWIh7UNclqLU025maLwyc/LSdqyi/XQggZqRRrks= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.com From: Sergei Heifetz To: qemu-devel@nongnu.org Cc: Eric Blake , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , Paolo Bonzini , Fabiano Rosas , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Eduardo Habkost , Yanan Wang , Zhao Liu , Richard Henderson , "Dr. David Alan Gilbert" , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Laurent Vivier , Gerd Hoffmann , Sergei Heifetz Subject: [PATCH v3 04/11] hw/audio/pcspk: change PCSPK behaviour with --disable-audio Date: Mon, 16 Mar 2026 01:16:39 +0500 Message-Id: <20260315201646.96862-5-heifetz@yandex-team.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260315201646.96862-1-heifetz@yandex-team.com> References: <20260315201646.96862-1-heifetz@yandex-team.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=178.154.239.72; envelope-from=heifetz@yandex-team.com; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.com) X-ZM-MESSAGEID: 1773605910516154100 PCSPK (PC Speaker) is an embedded audio device. We don't want it to use aud= io when QEMU is configured with `--disable-audio`. This is achieved with minim= al, non-invasive changes to the code. In essence, the changes ensure that PCSPK does not have a corresponding audio backend, while functioning the same way in non-audio aspects. Signed-off-by: Sergei Heifetz Reviewed-by: Marc-Andr=C3=A9 Lureau --- hw/audio/pcspk.c | 12 +++++++++++- hw/i386/pc.c | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c index 6b826507ce3..54e18822651 100644 --- a/hw/audio/pcspk.c +++ b/hw/audio/pcspk.c @@ -48,17 +48,20 @@ struct PCSpkState { =20 MemoryRegion ioport; uint32_t iobase; + PITCommonState *pit; +#ifdef CONFIG_AUDIO uint8_t sample_buf[PCSPK_BUF_LEN]; AudioBackend *audio_be; SWVoiceOut *voice; - PITCommonState *pit; unsigned int pit_count; unsigned int samples; unsigned int play_pos; +#endif uint8_t data_on; uint8_t dummy_refresh_clock; }; =20 +#ifdef CONFIG_AUDIO static const char *s_spk =3D "pcspk"; =20 static inline void generate_samples(PCSpkState *s) @@ -130,6 +133,7 @@ static int pcspk_audio_init(PCSpkState *s) =20 return 0; } +#endif =20 static uint64_t pcspk_io_read(void *opaque, hwaddr addr, unsigned size) @@ -160,11 +164,13 @@ static void pcspk_io_write(void *opaque, hwaddr addr,= uint64_t val, =20 s->data_on =3D (val >> 1) & 1; pit_set_gate(s->pit, 2, gate); +#ifdef CONFIG_AUDIO if (s->voice) { if (gate) /* restart */ s->play_pos =3D 0; audio_be_set_active_out(s->audio_be, s->voice, gate & s->data_on); } +#endif } =20 static const MemoryRegionOps pcspk_io_ops =3D { @@ -195,10 +201,12 @@ static void pcspk_realizefn(DeviceState *dev, Error *= *errp) =20 isa_register_ioport(isadev, &s->ioport, s->iobase); =20 +#ifdef CONFIG_AUDIO if (s->audio_be && audio_be_check(&s->audio_be, errp)) { pcspk_audio_init(s); return; } +#endif } =20 static const VMStateDescription vmstate_spk =3D { @@ -213,7 +221,9 @@ static const VMStateDescription vmstate_spk =3D { }; =20 static const Property pcspk_properties[] =3D { +#ifdef CONFIG_AUDIO DEFINE_AUDIO_PROPERTIES(PCSpkState, audio_be), +#endif DEFINE_PROP_UINT32("iobase", PCSpkState, iobase, 0x61), DEFINE_PROP_LINK("pit", PCSpkState, pit, TYPE_PIT_COMMON, PITCommonSta= te *), }; diff --git a/hw/i386/pc.c b/hw/i386/pc.c index addf602da08..8a4adee78e9 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1599,8 +1599,10 @@ static void pc_machine_initfn(Object *obj) =20 pc_system_flash_create(pcms); pcms->pcspk =3D isa_new(TYPE_PC_SPEAKER); +#ifdef CONFIG_AUDIO object_property_add_alias(OBJECT(pcms), "pcspk-audiodev", OBJECT(pcms->pcspk), "audiodev"); +#endif if (pcmc->pci_enabled) { cxl_machine_init(obj, &pcms->cxl_devices_state); } --=20 2.34.1