quic/qbox
Loading...
Searching...
No Matches
virtio_sound_pci.h
1/*
2 * This file is part of libqbox
3 * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8#pragma once
9
10#include <cci_configuration>
11
12#include <libgssync.h>
13#include <qemu-instance.h>
14
15#include <module_factory_registery.h>
16
17#include <qemu_gpex.h>
18
20{
21 std::string driver;
22 std::string audiodev_id;
23
24public:
25 virtio_sound_pci(const sc_core::sc_module_name& name, sc_core::sc_object* o, sc_core::sc_object* t)
26 : virtio_sound_pci(name, *(dynamic_cast<QemuInstance*>(o)), (dynamic_cast<qemu_gpex*>(t)))
27 {
28 }
29
30 virtio_sound_pci(const sc_core::sc_module_name& name, QemuInstance& inst, qemu_gpex* gpex,
31 const std::string& driver = "alsa")
32 : qemu_gpex::Device(name, inst, "virtio-sound-pci")
33 , driver(driver)
34 , audiodev_id(std::string(sc_core::sc_module::name()) + "-id")
35 {
36 std::stringstream opts;
37 opts << driver << ",id=" << audiodev_id;
38
39 m_inst.add_arg("-audiodev");
40 m_inst.add_arg(opts.str().c_str());
41
42 gpex->add_device(*this);
43 }
44
45 void before_end_of_elaboration() override
46 {
47 qemu_gpex::Device::before_end_of_elaboration();
48
49 m_dev.set_prop_str("audiodev", audiodev_id.c_str());
50 }
51};
52
53extern "C" void module_register();
This class encapsulates a libqemu-cxx qemu::LibQemu instance. It handles QEMU parameters and instance...
Definition qemu-instance.h:89
void add_arg(const char *arg)
Add a command line argument to the qemu instance.
Definition qemu-instance.h:329
Definition target.h:160
Definition qemu_gpex.h:35
Definition qemu_gpex.h:32
Definition virtio_sound_pci.h:20