From nobody Tue Nov 18 10:37:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1609586332; cv=none; d=zohomail.com; s=zohoarc; b=CUGPJNtlkQzR3oxHsprsZUzjYG9ZrJVumsdg1ODUfKlEWY92x72zq3U7d4VpiwKHQQXzH94dkdslSWrA86CX4ei6HiH5JOfHFw07AhbKZZ3lT4fROfcGtQtDR5d81OFHqyHnFPogtdj8etvXDJXZu3MdVBrEyV4B9vnimX9gdFk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609586332; 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:Reply-To:References:Sender:Subject:To; bh=7iaNAyHJLoKBibo+Bdal7qpwCsDbbkC4J6auiTR7MTk=; b=ZEXoDROfsDoYNcB20oYLBFWInZjpypR4IuBsMSZK4vFmt8Sg/MBnysSvfjrZ3MoAVMWQGtUtDqOU3t3Zq2/m6zT1fJZbamF0egAFxMt6J8i6Qg52CBvdJW3DJkbkRDYKHMPdOYWgT7Go4sP8XRKnGQ5w7vrJWyUdkKWl6RKDYNk= ARC-Authentication-Results: i=1; mx.zohomail.com; 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1609586332411665.0108977365959; Sat, 2 Jan 2021 03:18:52 -0800 (PST) Received: from localhost ([::1]:57688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kvevr-0005zK-B9 for importer@patchew.org; Sat, 02 Jan 2021 06:18:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33180) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kveqs-0000p5-DV for qemu-devel@nongnu.org; Sat, 02 Jan 2021 06:13:42 -0500 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:56500) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kveqp-00075q-H6 for qemu-devel@nongnu.org; Sat, 02 Jan 2021 06:13:42 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id AE734747640; Sat, 2 Jan 2021 12:13:30 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id E31AF7475FD; Sat, 2 Jan 2021 12:13:29 +0100 (CET) Message-Id: In-Reply-To: References: Subject: [PATCH 05/24] vt82c686: Split off via-[am]c97 into separate file in hw/audio Date: Sat, 02 Jan 2021 11:43:35 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org X-Spam-Probability: 8% 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=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Huacai Chen , f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Reply-to: BALATON Zoltan From: BALATON Zoltan via The via-[am]c97 code is supposed to implement the audio part of VIA south bridge chips so it is better placed under hw/audio/. Split it off into a separate file. Signed-off-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/audio/meson.build | 1 + hw/audio/via-ac97.c | 106 +++++++++++++++++++++++++++++++++++++++++++ hw/isa/vt82c686.c | 91 ------------------------------------- 3 files changed, 107 insertions(+), 91 deletions(-) create mode 100644 hw/audio/via-ac97.c diff --git a/hw/audio/meson.build b/hw/audio/meson.build index 549e9a0396..32c42bdebe 100644 --- a/hw/audio/meson.build +++ b/hw/audio/meson.build @@ -11,4 +11,5 @@ softmmu_ss.add(when: 'CONFIG_MILKYMIST', if_true: files('= milkymist-ac97.c')) softmmu_ss.add(when: 'CONFIG_PCSPK', if_true: files('pcspk.c')) softmmu_ss.add(when: 'CONFIG_PL041', if_true: files('pl041.c', 'lm4549.c')) softmmu_ss.add(when: 'CONFIG_SB16', if_true: files('sb16.c')) +softmmu_ss.add(when: 'CONFIG_VT82C686', if_true: files('via-ac97.c')) softmmu_ss.add(when: 'CONFIG_WM8750', if_true: files('wm8750.c')) diff --git a/hw/audio/via-ac97.c b/hw/audio/via-ac97.c new file mode 100644 index 0000000000..e617416ff7 --- /dev/null +++ b/hw/audio/via-ac97.c @@ -0,0 +1,106 @@ +/* + * VIA south bridges sound support + * + * This work is licensed under the GNU GPL license version 2 or later. + */ + +/* + * TODO: This is entirely boiler plate just registering empty PCI devices + * with the right ID guests expect, functionality should be added here. + */ + +#include "qemu/osdep.h" +#include "hw/isa/vt82c686.h" +#include "hw/pci/pci.h" + +struct VIAAC97State { + PCIDevice dev; +}; + +struct VIAMC97State { + PCIDevice dev; +}; + +OBJECT_DECLARE_SIMPLE_TYPE(VIAAC97State, VIA_AC97) +OBJECT_DECLARE_SIMPLE_TYPE(VIAMC97State, VIA_MC97) + +static void via_ac97_realize(PCIDevice *dev, Error **errp) +{ + VIAAC97State *s =3D VIA_AC97(dev); + uint8_t *pci_conf =3D s->dev.config; + + pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_INVALIDATE | + PCI_COMMAND_PARITY); + pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_CAP_LIST | + PCI_STATUS_DEVSEL_MEDIUM); + pci_set_long(pci_conf + PCI_INTERRUPT_PIN, 0x03); +} + +static void via_ac97_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); + + k->realize =3D via_ac97_realize; + k->vendor_id =3D PCI_VENDOR_ID_VIA; + k->device_id =3D PCI_DEVICE_ID_VIA_AC97; + k->revision =3D 0x50; + k->class_id =3D PCI_CLASS_MULTIMEDIA_AUDIO; + set_bit(DEVICE_CATEGORY_SOUND, dc->categories); + dc->desc =3D "AC97"; +} + +static const TypeInfo via_ac97_info =3D { + .name =3D TYPE_VIA_AC97, + .parent =3D TYPE_PCI_DEVICE, + .instance_size =3D sizeof(VIAAC97State), + .class_init =3D via_ac97_class_init, + .interfaces =3D (InterfaceInfo[]) { + { INTERFACE_CONVENTIONAL_PCI_DEVICE }, + { }, + }, +}; + +static void via_mc97_realize(PCIDevice *dev, Error **errp) +{ + VIAMC97State *s =3D VIA_MC97(dev); + uint8_t *pci_conf =3D s->dev.config; + + pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_INVALIDATE | + PCI_COMMAND_VGA_PALETTE); + pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM); + pci_set_long(pci_conf + PCI_INTERRUPT_PIN, 0x03); +} + +static void via_mc97_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); + + k->realize =3D via_mc97_realize; + k->vendor_id =3D PCI_VENDOR_ID_VIA; + k->device_id =3D PCI_DEVICE_ID_VIA_MC97; + k->class_id =3D PCI_CLASS_COMMUNICATION_OTHER; + k->revision =3D 0x30; + set_bit(DEVICE_CATEGORY_NETWORK, dc->categories); + dc->desc =3D "MC97"; +} + +static const TypeInfo via_mc97_info =3D { + .name =3D TYPE_VIA_MC97, + .parent =3D TYPE_PCI_DEVICE, + .instance_size =3D sizeof(VIAMC97State), + .class_init =3D via_mc97_class_init, + .interfaces =3D (InterfaceInfo[]) { + { INTERFACE_CONVENTIONAL_PCI_DEVICE }, + { }, + }, +}; + +static void via_ac97_register_types(void) +{ + type_register_static(&via_ac97_info); + type_register_static(&via_mc97_info); +} + +type_init(via_ac97_register_types) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index 8677a2d212..9567326d8e 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -168,14 +168,6 @@ struct VT686PMState { uint32_t smb_io_base; }; =20 -struct VIAAC97State { - PCIDevice dev; -}; - -struct VIAMC97State { - PCIDevice dev; -}; - #define TYPE_VT82C686B_PM "VT82C686B_PM" OBJECT_DECLARE_SIMPLE_TYPE(VT686PMState, VT82C686B_PM) =20 @@ -247,87 +239,6 @@ static const VMStateDescription vmstate_acpi =3D { } }; =20 -/* - * TODO: VIA_AC97 and VIA_MC97 - * just register a PCI device now, functionalities will be implemented lat= er. - */ - -OBJECT_DECLARE_SIMPLE_TYPE(VIAMC97State, VIA_MC97) -OBJECT_DECLARE_SIMPLE_TYPE(VIAAC97State, VIA_AC97) - -static void vt82c686b_ac97_realize(PCIDevice *dev, Error **errp) -{ - VIAAC97State *s =3D VIA_AC97(dev); - uint8_t *pci_conf =3D s->dev.config; - - pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_INVALIDATE | - PCI_COMMAND_PARITY); - pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_CAP_LIST | - PCI_STATUS_DEVSEL_MEDIUM); - pci_set_long(pci_conf + PCI_INTERRUPT_PIN, 0x03); -} - -static void via_ac97_class_init(ObjectClass *klass, void *data) -{ - DeviceClass *dc =3D DEVICE_CLASS(klass); - PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); - - k->realize =3D vt82c686b_ac97_realize; - k->vendor_id =3D PCI_VENDOR_ID_VIA; - k->device_id =3D PCI_DEVICE_ID_VIA_AC97; - k->revision =3D 0x50; - k->class_id =3D PCI_CLASS_MULTIMEDIA_AUDIO; - set_bit(DEVICE_CATEGORY_SOUND, dc->categories); - dc->desc =3D "AC97"; -} - -static const TypeInfo via_ac97_info =3D { - .name =3D TYPE_VIA_AC97, - .parent =3D TYPE_PCI_DEVICE, - .instance_size =3D sizeof(VIAAC97State), - .class_init =3D via_ac97_class_init, - .interfaces =3D (InterfaceInfo[]) { - { INTERFACE_CONVENTIONAL_PCI_DEVICE }, - { }, - }, -}; - -static void vt82c686b_mc97_realize(PCIDevice *dev, Error **errp) -{ - VIAMC97State *s =3D VIA_MC97(dev); - uint8_t *pci_conf =3D s->dev.config; - - pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_INVALIDATE | - PCI_COMMAND_VGA_PALETTE); - pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM); - pci_set_long(pci_conf + PCI_INTERRUPT_PIN, 0x03); -} - -static void via_mc97_class_init(ObjectClass *klass, void *data) -{ - DeviceClass *dc =3D DEVICE_CLASS(klass); - PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); - - k->realize =3D vt82c686b_mc97_realize; - k->vendor_id =3D PCI_VENDOR_ID_VIA; - k->device_id =3D PCI_DEVICE_ID_VIA_MC97; - k->class_id =3D PCI_CLASS_COMMUNICATION_OTHER; - k->revision =3D 0x30; - set_bit(DEVICE_CATEGORY_NETWORK, dc->categories); - dc->desc =3D "MC97"; -} - -static const TypeInfo via_mc97_info =3D { - .name =3D TYPE_VIA_MC97, - .parent =3D TYPE_PCI_DEVICE, - .instance_size =3D sizeof(VIAMC97State), - .class_init =3D via_mc97_class_init, - .interfaces =3D (InterfaceInfo[]) { - { INTERFACE_CONVENTIONAL_PCI_DEVICE }, - { }, - }, -}; - /* vt82c686 pm init */ static void vt82c686b_pm_realize(PCIDevice *dev, Error **errp) { @@ -516,8 +427,6 @@ static const TypeInfo via_superio_info =3D { =20 static void vt82c686b_register_types(void) { - type_register_static(&via_ac97_info); - type_register_static(&via_mc97_info); type_register_static(&via_pm_info); type_register_static(&via_superio_info); type_register_static(&via_info); --=20 2.21.3