From nobody Sun Apr 12 04:37:23 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=1771878393; cv=none; d=zohomail.com; s=zohoarc; b=NLVo7CQwJNY6TFvR+fPAay2nl/yA1pWDZKm55I4a5AFRR+TuCEdk8VOKP4/3Lz04imX0xe/EcWQCGsCzZYd3dpdEENExE+V/lMWTzXZZTw7GPfeEJf0TFJXtK3mnEqhmehZ0V5YCN2l7P7OXDzhG/FpMdH+252CVBh6PFOhmG+A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771878393; h=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=Yq0CWubq2cVL00aDsB6wDvjl/NGJ8QzW3ZUX45lNfyg=; b=bxWuehUxedrVOFNzdMJdHvPaMIzkmdTMwEwUgJrbTIDbYyEtBhulWvl5cHpMGxtKYBqpVho5H3oGs8yy1mLvUlAfKYFcSU3x7YzdExUteJqJAgefo+P1ygRwW/Tku5jAB7SFKQ9nrxqwFCExsncA3sPxyn9tyttjhpb8P1OcOL0= 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 1771878392972645.202889362038; Mon, 23 Feb 2026 12:26:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vucV9-0003Zm-PL; Mon, 23 Feb 2026 15:25:56 -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 1vucUp-0003A6-3Z for qemu-devel@nongnu.org; Mon, 23 Feb 2026 15:25:37 -0500 Received: from forwardcorp1b.mail.yandex.net ([178.154.239.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vucUi-0002Or-Qj for qemu-devel@nongnu.org; Mon, 23 Feb 2026 15:25:32 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:bf1f:0:640:c739:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTPS id 2918B8E413; Mon, 23 Feb 2026 23:25:24 +0300 (MSK) Received: from heifetz-lin.yandex-team.ru (unknown [2a02:6bf:8080:12d::1:2c]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id CPmvPN6Ap8c0-rY4DI9og; Mon, 23 Feb 2026 23:25:23 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.com; s=default; t=1771878323; bh=Yq0CWubq2cVL00aDsB6wDvjl/NGJ8QzW3ZUX45lNfyg=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=lXJxtGdHcQuI9mHVb6hc1whmnGTlx8g1IBAHkB+6ZKItvYNLC8/HrdOnXLIt6zL2V xNdGGBqp8UqTkPrWyhJSxi7lB7dB3X4wzAizfEj0bXrAuJXPxTd3rgUk/u/T/t86mJ 3WbpgSDtONUUmQsZg2OUneN+5IdkIgEISjS83WbY= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.com From: Sergei Heifetz To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , Marcel Apfelbaum , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fabiano Rosas , Laurent Vivier , Thomas Huth , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eric Blake , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , "Michael S. Tsirkin" , Markus Armbruster , "Dr. David Alan Gilbert" Subject: [PATCH v2 04/10] hw/audio/pcspk: change PCSPK behaviour with --disable-audio Date: Tue, 24 Feb 2026 01:25:06 +0500 Message-Id: <20260223202512.1308205-5-heifetz@yandex-team.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260223202512.1308205-1-heifetz@yandex-team.com> References: <20260223202512.1308205-1-heifetz@yandex-team.com> MIME-Version: 1.0 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.136; envelope-from=heifetz@yandex-team.com; helo=forwardcorp1b.mail.yandex.net X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, 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: 1771878396231158500 Content-Type: text/plain; charset="utf-8" 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 6b826507ce..54e1882265 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 0dd3fd01d9..3992553c2a 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1679,8 +1679,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