From nobody Tue Feb 10 12:42:38 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1696322034; cv=none; d=zohomail.com; s=zohoarc; b=DDGB8d0AqZaQB05T1dF1sqBjCxmPJg0tDqXwKOYv1mv03NA3Kbozg3T2zbt6zSqXECOy/zaO/7xuvLJfz8x1iyTN7Zm/hOjzd46pqX2/ZFv64ZEbRYN1HCiVJnsHOt6boghbiCEHZWoLJuTeH/qNCN8SU1AzbgZq1QUU/dw5Skg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696322034; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NGlxuLyun+dUBX7xD0BT13EOzRTwugSo2SXeCOO3kog=; b=bM+rNfwmkWPshKnnjF7eBVeqojYt0wuHDsyKGFBFU2NOnxP+EsKLeOtMFhadUEY12BhtjKfwm0ObGI+bP7yQHUsPgmNgQkKq8+wJs5NT9qOKR96mCnFAhYkLa6Whm9LX6e8gjv/9TOTLZwKDfI/G4OfIPOG+CQXCkzP9I2M/d40= 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 169632203415848.69888866455801; Tue, 3 Oct 2023 01:33:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnaoc-0003Cu-7h; Tue, 03 Oct 2023 04:31:38 -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 1qnaoY-0002xX-Ls for qemu-devel@nongnu.org; Tue, 03 Oct 2023 04:31:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qnaoW-0000NT-IV for qemu-devel@nongnu.org; Tue, 03 Oct 2023 04:31:34 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-381-bUycKeyINFaHvJncVm6KpA-1; Tue, 03 Oct 2023 04:31:24 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-9adad8f306fso51003966b.0 for ; Tue, 03 Oct 2023 01:31:24 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:1c09:f536:3de6:228c]) by smtp.gmail.com with ESMTPSA id gr11-20020a170906e2cb00b0099bc80d5575sm635517ejb.200.2023.10.03.01.31.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:31:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696321891; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NGlxuLyun+dUBX7xD0BT13EOzRTwugSo2SXeCOO3kog=; b=ArOJD125gjIuk3c515okWU9tQ7Xthn9mX816T5+yzS/rCcxnyfc5zeNZLW8w65npmsS6+g MwX2bM92mwY7KWAW94E5kN94qCqnmIrk1hMMZsQ2H9I+jB8rO3NnMd0JxQaTH1Ca24Y9S3 c/VTv2tYcC6ALrjd2RQSwg2+TcfU9A4= X-MC-Unique: bUycKeyINFaHvJncVm6KpA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696321882; x=1696926682; 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=NGlxuLyun+dUBX7xD0BT13EOzRTwugSo2SXeCOO3kog=; b=uq2ccscU/9+0N8w14XktMivnpXpt/7fEjVPJ8JnMo1xE0ul2Y91KVoq9nI4Us4W+mm +Swha7tSQRn/q6QrmAAWoEhFpoBopYvdyQEkqSEUUz4vRJxMZpudqqv9nvCODsBo2WnV ChmcPYSbq7K5oTI73Unjzyxuanukb+qq0JpaLicf5ItBUZZHR1slcvDZuxvE7He0KQ3Q U5kZIA7IdapTbAysVXLkEXpWbTXrJPKCjXHHX7Ddvpjw+qMwWQp1BXky/0H/dl3x0VF7 +I+9nl+wYY76qlDaJ6LWd1Hw/q5KVEnh21yuD8Ioz5qZ+AdQrdQziHYa0jqXqsTZiGK2 Y5MQ== X-Gm-Message-State: AOJu0YwHG4KOEJfgA+QAY1PfrSvYbKQ65dTKQ81m8DsB0RF73PGMVAfu GoWMp4D+HMg+Q3nhXRBu+pjeKGoa96T2zRYmGzKgY3y5zBbZEyKd4H4Aoealu1jfeyGJRmBkMUw syvvu9drUxZOOy5rWIkyiSyLqwYIzTdMwyxK8cmgzf680Pod/+atDtSvlCuAt9sctRf6n1wEqW3 w= X-Received: by 2002:a17:907:75f9:b0:9b6:582e:be5e with SMTP id jz25-20020a17090775f900b009b6582ebe5emr2227362ejc.60.1696321882156; Tue, 03 Oct 2023 01:31:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEBWwQbVtQBHhO28yYbWB8ucN1FkLlEbUdYyBkZR3s6tMNEga1UzrUHSk+mIXCBWE7jINQEwQ== X-Received: by 2002:a17:907:75f9:b0:9b6:582e:be5e with SMTP id jz25-20020a17090775f900b009b6582ebe5emr2227347ejc.60.1696321881871; Tue, 03 Oct 2023 01:31:21 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Martin Kletzander Subject: [PULL 19/24] Introduce machine property "audiodev" Date: Tue, 3 Oct 2023 10:30:36 +0200 Message-ID: <20231003083042.110065-20-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003083042.110065-1-pbonzini@redhat.com> References: <20231003083042.110065-1-pbonzini@redhat.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=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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 @redhat.com) X-ZM-MESSAGEID: 1696322034736100001 Content-Type: text/plain; charset="utf-8" From: Martin Kletzander Many machine types have default audio devices with no way to set the underl= ying audiodev. Instead of adding an option for each and every one of them, this= new property can be used as a default during machine initialisation when creati= ng such devices. Signed-off-by: Martin Kletzander [Make the property optional, instead of including it in all machines. - Pao= lo] Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 33 +++++++++++++++++++++++++++++++++ include/hw/boards.h | 9 +++++++++ 2 files changed, 42 insertions(+) diff --git a/hw/core/machine.c b/hw/core/machine.c index cb38b8cf4cb..6aa49c8d4f1 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -39,6 +39,7 @@ #include "hw/virtio/virtio.h" #include "hw/virtio/virtio-pci.h" #include "hw/virtio/virtio-net.h" +#include "audio/audio.h" =20 GlobalProperty hw_compat_8_1[] =3D {}; const size_t hw_compat_8_1_len =3D G_N_ELEMENTS(hw_compat_8_1); @@ -686,6 +687,26 @@ bool device_type_is_dynamic_sysbus(MachineClass *mc, c= onst char *type) return allowed; } =20 +static char *machine_get_audiodev(Object *obj, Error **errp) +{ + MachineState *ms =3D MACHINE(obj); + + return g_strdup(ms->audiodev); +} + +static void machine_set_audiodev(Object *obj, const char *value, + Error **errp) +{ + MachineState *ms =3D MACHINE(obj); + + if (!audio_state_by_name(value, errp)) { + return; + } + + g_free(ms->audiodev); + ms->audiodev =3D g_strdup(value); +} + HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine) { int i; @@ -931,6 +952,17 @@ out_free: qapi_free_BootConfiguration(config); } =20 +void machine_add_audiodev_property(MachineClass *mc) +{ + ObjectClass *oc =3D OBJECT_CLASS(mc); + + object_class_property_add_str(oc, "audiodev", + machine_get_audiodev, + machine_set_audiodev); + object_class_property_set_description(oc, "audiodev", + "Audiodev to use for default mac= hine devices"); +} + static void machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); @@ -1136,6 +1168,7 @@ static void machine_finalize(Object *obj) g_free(ms->device_memory); g_free(ms->nvdimms_state); g_free(ms->numa_state); + g_free(ms->audiodev); } =20 bool machine_usb(MachineState *machine) diff --git a/include/hw/boards.h b/include/hw/boards.h index 6c67af196a3..55a64a13fdf 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -24,6 +24,7 @@ OBJECT_DECLARE_TYPE(MachineState, MachineClass, MACHINE) =20 extern MachineState *current_machine; =20 +void machine_add_audiodev_property(MachineClass *mc); void machine_run_board_init(MachineState *machine, const char *mem_path, E= rror **errp); bool machine_usb(MachineState *machine); int machine_phandle_start(MachineState *machine); @@ -358,6 +359,14 @@ struct MachineState { MemoryRegion *ram; DeviceMemoryState *device_memory; =20 + /* + * Included in MachineState for simplicity, but not supported + * unless machine_add_audiodev_property is called. Boards + * that have embedded audio devices can call it from the + * machine init function and forward the property to the device. + */ + char *audiodev; + ram_addr_t ram_size; ram_addr_t maxram_size; uint64_t ram_slots; --=20 2.41.0