mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
hw/audio: use better naming for -audio model handling code
All the functions are about "-audio model=" handling, a simpler way to setup audio. Rename functions/variables to reflect this better. audio_register_model_with_cb() dropped "pci" from the name, since it will be generalized next. deprecated_register_soundhw() was actually not a function to be removed since it's used for "-audio model=" aliasing. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
This commit is contained in:
+2
-3
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "hw/audio/soundhw.h"
|
||||
#include "hw/audio/model.h"
|
||||
#include "audio/audio.h"
|
||||
#include "hw/pci/pci_device.h"
|
||||
#include "hw/qdev-properties.h"
|
||||
@@ -1362,8 +1362,7 @@ static const TypeInfo ac97_info = {
|
||||
static void ac97_register_types(void)
|
||||
{
|
||||
type_register_static(&ac97_info);
|
||||
deprecated_register_soundhw("ac97", "Intel 82801AA AC97 Audio",
|
||||
0, TYPE_AC97);
|
||||
audio_register_model("ac97", "Intel 82801AA AC97 Audio", 0, TYPE_AC97);
|
||||
}
|
||||
|
||||
type_init(ac97_register_types)
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qemu/module.h"
|
||||
#include "hw/audio/soundhw.h"
|
||||
#include "hw/audio/model.h"
|
||||
#include "audio/audio.h"
|
||||
#include "hw/isa/isa.h"
|
||||
#include "hw/qdev-properties.h"
|
||||
@@ -323,7 +323,7 @@ static const TypeInfo adlib_info = {
|
||||
static void adlib_register_types (void)
|
||||
{
|
||||
type_register_static (&adlib_info);
|
||||
deprecated_register_soundhw("adlib", ADLIB_DESC, 1, TYPE_ADLIB);
|
||||
audio_register_model("adlib", ADLIB_DESC, 1, TYPE_ADLIB);
|
||||
}
|
||||
|
||||
type_init (adlib_register_types)
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "hw/audio/soundhw.h"
|
||||
#include "hw/audio/model.h"
|
||||
#include "audio/audio.h"
|
||||
#include "hw/irq.h"
|
||||
#include "hw/isa/isa.h"
|
||||
@@ -723,7 +723,7 @@ static const TypeInfo cs4231a_info = {
|
||||
static void cs4231a_register_types (void)
|
||||
{
|
||||
type_register_static (&cs4231a_info);
|
||||
deprecated_register_soundhw("cs4231a", "CS4231A", 1, TYPE_CS4231A);
|
||||
audio_register_model("cs4231a", "CS4231A", 1, TYPE_CS4231A);
|
||||
}
|
||||
|
||||
type_init (cs4231a_register_types)
|
||||
|
||||
+2
-3
@@ -26,7 +26,7 @@
|
||||
#define VERBOSE_ES1370 0
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "hw/audio/soundhw.h"
|
||||
#include "hw/audio/model.h"
|
||||
#include "audio/audio.h"
|
||||
#include "hw/pci/pci_device.h"
|
||||
#include "migration/vmstate.h"
|
||||
@@ -905,8 +905,7 @@ static const TypeInfo es1370_info = {
|
||||
static void es1370_register_types (void)
|
||||
{
|
||||
type_register_static (&es1370_info);
|
||||
deprecated_register_soundhw("es1370", "ENSONIQ AudioPCI ES1370",
|
||||
0, TYPE_ES1370);
|
||||
audio_register_model("es1370", "ENSONIQ AudioPCI ES1370", 0, TYPE_ES1370);
|
||||
}
|
||||
|
||||
type_init (es1370_register_types)
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qemu/module.h"
|
||||
#include "hw/audio/soundhw.h"
|
||||
#include "hw/audio/model.h"
|
||||
#include "audio/audio.h"
|
||||
#include "hw/irq.h"
|
||||
#include "hw/isa/isa.h"
|
||||
@@ -320,7 +320,7 @@ static const TypeInfo gus_info = {
|
||||
static void gus_register_types (void)
|
||||
{
|
||||
type_register_static (&gus_info);
|
||||
deprecated_register_soundhw("gus", "Gravis Ultrasound GF1", 1, TYPE_GUS);
|
||||
audio_register_model("gus", "Gravis Ultrasound GF1", 1, TYPE_GUS);
|
||||
}
|
||||
|
||||
type_init (gus_register_types)
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "qemu/log.h"
|
||||
#include "qemu/module.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "hw/audio/soundhw.h"
|
||||
#include "hw/audio/model.h"
|
||||
#include "intel-hda.h"
|
||||
#include "migration/vmstate.h"
|
||||
#include "intel-hda-defs.h"
|
||||
@@ -1324,7 +1324,7 @@ static void intel_hda_register_types(void)
|
||||
type_register_static(&intel_hda_info_ich6);
|
||||
type_register_static(&intel_hda_info_ich9);
|
||||
type_register_static(&hda_codec_device_type_info);
|
||||
pci_register_soundhw("hda", "Intel HD Audio", intel_hda_and_codec_init);
|
||||
audio_register_model_with_cb("hda", "Intel HD Audio", intel_hda_and_codec_init);
|
||||
}
|
||||
|
||||
type_init(intel_hda_register_types)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
system_ss.add(files('soundhw.c'))
|
||||
system_ss.add(files('model.c'))
|
||||
system_ss.add(when: 'CONFIG_AC97', if_true: files('ac97.c'))
|
||||
system_ss.add(when: 'CONFIG_ADLIB', if_true: files('fmopl.c', 'adlib.c'))
|
||||
system_ss.add(when: 'CONFIG_ASC', if_true: files('asc.c'))
|
||||
|
||||
@@ -32,9 +32,9 @@
|
||||
#include "hw/qdev-properties.h"
|
||||
#include "hw/isa/isa.h"
|
||||
#include "hw/pci/pci.h"
|
||||
#include "hw/audio/soundhw.h"
|
||||
#include "hw/audio/model.h"
|
||||
|
||||
struct soundhw {
|
||||
struct audio_model {
|
||||
const char *name;
|
||||
const char *descr;
|
||||
const char *typename;
|
||||
@@ -42,38 +42,38 @@ struct soundhw {
|
||||
int (*init_pci) (PCIBus *bus, const char *audiodev);
|
||||
};
|
||||
|
||||
static struct soundhw soundhw[9];
|
||||
static int soundhw_count;
|
||||
static struct audio_model audio_models[9];
|
||||
static int audio_models_count;
|
||||
|
||||
void pci_register_soundhw(const char *name, const char *descr,
|
||||
int (*init_pci)(PCIBus *bus, const char *audiodev))
|
||||
void audio_register_model_with_cb(const char *name, const char *descr,
|
||||
int (*init_pci)(PCIBus *bus, const char *audiodev))
|
||||
{
|
||||
assert(soundhw_count < ARRAY_SIZE(soundhw) - 1);
|
||||
soundhw[soundhw_count].name = name;
|
||||
soundhw[soundhw_count].descr = descr;
|
||||
soundhw[soundhw_count].isa = 0;
|
||||
soundhw[soundhw_count].init_pci = init_pci;
|
||||
soundhw_count++;
|
||||
assert(audio_models_count < ARRAY_SIZE(audio_models) - 1);
|
||||
audio_models[audio_models_count].name = name;
|
||||
audio_models[audio_models_count].descr = descr;
|
||||
audio_models[audio_models_count].isa = 0;
|
||||
audio_models[audio_models_count].init_pci = init_pci;
|
||||
audio_models_count++;
|
||||
}
|
||||
|
||||
void deprecated_register_soundhw(const char *name, const char *descr,
|
||||
int isa, const char *typename)
|
||||
void audio_register_model(const char *name, const char *descr,
|
||||
int isa, const char *typename)
|
||||
{
|
||||
assert(soundhw_count < ARRAY_SIZE(soundhw) - 1);
|
||||
soundhw[soundhw_count].name = name;
|
||||
soundhw[soundhw_count].descr = descr;
|
||||
soundhw[soundhw_count].isa = isa;
|
||||
soundhw[soundhw_count].typename = typename;
|
||||
soundhw_count++;
|
||||
assert(audio_models_count < ARRAY_SIZE(audio_models) - 1);
|
||||
audio_models[audio_models_count].name = name;
|
||||
audio_models[audio_models_count].descr = descr;
|
||||
audio_models[audio_models_count].isa = isa;
|
||||
audio_models[audio_models_count].typename = typename;
|
||||
audio_models_count++;
|
||||
}
|
||||
|
||||
void audio_print_available_models(void)
|
||||
{
|
||||
struct soundhw *c;
|
||||
struct audio_model *c;
|
||||
|
||||
if (soundhw_count) {
|
||||
if (audio_models_count) {
|
||||
printf("Valid audio device model names:\n");
|
||||
for (c = soundhw; c->name; ++c) {
|
||||
for (c = audio_models; c->name; ++c) {
|
||||
printf("%-11s %s\n", c->name, c->descr);
|
||||
}
|
||||
} else {
|
||||
@@ -82,19 +82,19 @@ void audio_print_available_models(void)
|
||||
}
|
||||
}
|
||||
|
||||
static struct soundhw *selected = NULL;
|
||||
static struct audio_model *selected;
|
||||
static const char *audiodev_id;
|
||||
|
||||
void select_soundhw(const char *name, const char *audiodev)
|
||||
void audio_set_model(const char *name, const char *audiodev)
|
||||
{
|
||||
struct soundhw *c;
|
||||
struct audio_model *c;
|
||||
|
||||
if (selected) {
|
||||
error_report("only one -audio option is allowed");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (c = soundhw; c->name; ++c) {
|
||||
for (c = audio_models; c->name; ++c) {
|
||||
if (g_str_equal(c->name, name)) {
|
||||
selected = c;
|
||||
audiodev_id = audiodev;
|
||||
@@ -109,9 +109,9 @@ void select_soundhw(const char *name, const char *audiodev)
|
||||
}
|
||||
}
|
||||
|
||||
void soundhw_init(void)
|
||||
void audio_model_init(void)
|
||||
{
|
||||
struct soundhw *c = selected;
|
||||
struct audio_model *c = selected;
|
||||
|
||||
if (!c) {
|
||||
return;
|
||||
+1
-1
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "hw/isa/isa.h"
|
||||
#include "hw/audio/soundhw.h"
|
||||
#include "hw/audio/model.h"
|
||||
#include "audio/audio.h"
|
||||
#include "qemu/module.h"
|
||||
#include "qemu/timer.h"
|
||||
|
||||
+2
-3
@@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "hw/audio/soundhw.h"
|
||||
#include "hw/audio/model.h"
|
||||
#include "audio/audio.h"
|
||||
#include "hw/irq.h"
|
||||
#include "hw/isa/isa.h"
|
||||
@@ -1470,8 +1470,7 @@ static const TypeInfo sb16_info = {
|
||||
static void sb16_register_types (void)
|
||||
{
|
||||
type_register_static (&sb16_info);
|
||||
deprecated_register_soundhw("sb16", "Creative Sound Blaster 16",
|
||||
1, TYPE_SB16);
|
||||
audio_register_model("sb16", "Creative Sound Blaster 16", 1, TYPE_SB16);
|
||||
}
|
||||
|
||||
type_init (sb16_register_types)
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "qom/object.h"
|
||||
#include "qapi/error.h"
|
||||
#include "hw/audio/soundhw.h"
|
||||
#include "hw/audio/model.h"
|
||||
#include "hw/virtio/virtio-pci.h"
|
||||
#include "hw/audio/virtio-snd.h"
|
||||
|
||||
@@ -88,7 +88,7 @@ static int virtio_snd_pci_init(PCIBus *bus, const char *audiodev)
|
||||
static void virtio_snd_pci_register(void)
|
||||
{
|
||||
virtio_pci_types_register(&virtio_snd_pci_info);
|
||||
pci_register_soundhw("virtio", "Virtio Sound", virtio_snd_pci_init);
|
||||
audio_register_model_with_cb("virtio", "Virtio Sound", virtio_snd_pci_init);
|
||||
}
|
||||
|
||||
type_init(virtio_snd_pci_register);
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
#ifndef HW_AUDIO_MODEL_H
|
||||
#define HW_AUDIO_MODEL_H
|
||||
|
||||
void audio_register_model_with_cb(const char *name, const char *descr,
|
||||
int (*init_pci)(PCIBus *bus, const char *audiodev));
|
||||
void audio_register_model(const char *name, const char *descr,
|
||||
int isa, const char *typename);
|
||||
|
||||
void audio_model_init(void);
|
||||
void audio_print_available_models(void);
|
||||
void audio_set_model(const char *name, const char *audiodev);
|
||||
|
||||
#endif
|
||||
@@ -1,13 +0,0 @@
|
||||
#ifndef HW_SOUNDHW_H
|
||||
#define HW_SOUNDHW_H
|
||||
|
||||
void pci_register_soundhw(const char *name, const char *descr,
|
||||
int (*init_pci)(PCIBus *bus, const char *audiodev));
|
||||
void deprecated_register_soundhw(const char *name, const char *descr,
|
||||
int isa, const char *typename);
|
||||
|
||||
void soundhw_init(void);
|
||||
void audio_print_available_models(void);
|
||||
void select_soundhw(const char *name, const char *audiodev);
|
||||
|
||||
#endif
|
||||
@@ -264,7 +264,7 @@ def test_initial_includes():
|
||||
#define SILENT_ES1370
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "hw/audio/soundhw.h"
|
||||
#include "hw/audio/model.h"
|
||||
#include "audio/audio.h"
|
||||
#include "hw/pci/pci.h"
|
||||
#include "migration/vmstate.h"
|
||||
|
||||
+3
-3
@@ -86,7 +86,7 @@
|
||||
#include "migration/snapshot.h"
|
||||
#include "system/tpm.h"
|
||||
#include "system/dma.h"
|
||||
#include "hw/audio/soundhw.h"
|
||||
#include "hw/audio/model.h"
|
||||
#include "audio/audio.h"
|
||||
#include "system/cpus.h"
|
||||
#include "system/cpu-timers.h"
|
||||
@@ -2732,7 +2732,7 @@ static void qemu_create_cli_devices(void)
|
||||
{
|
||||
DeviceOption *opt;
|
||||
|
||||
soundhw_init();
|
||||
audio_model_init();
|
||||
|
||||
qemu_opts_foreach(qemu_find_opts("fw_cfg"),
|
||||
parse_fw_cfg, fw_cfg_find(), &error_fatal);
|
||||
@@ -3088,7 +3088,7 @@ void qemu_init(int argc, char **argv)
|
||||
visit_free(v);
|
||||
if (model) {
|
||||
audio_add_audiodev(dev);
|
||||
select_soundhw(model, dev->id);
|
||||
audio_set_model(model, dev->id);
|
||||
g_free(model);
|
||||
} else {
|
||||
audio_add_default_audiodev(dev, &error_fatal);
|
||||
|
||||
Reference in New Issue
Block a user