From: Wanpeng Li <liwanp@linux.vnet.ibm.com>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: Ram Pai <pair@us.ibm.com>, "Michael S. Tsirkin" <mst@redhat.com>,
Jan Kiszka <jan.kiszka@siemens.com>,
qemu-devel@nongnu.org, Liu Ping Fan <kernelfans@gmail.com>,
Blue Swirl <blauwirbel@gmail.com>,
Stefan Weil <weil@mail.berlios.de>, Avi Kivity <avi@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Wanpeng Li <liwanp@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH 04/10] convert PCSPK as piix3 proper QOM child
Date: Thu, 8 Nov 2012 13:36:33 +0800 [thread overview]
Message-ID: <1352352999-2561-5-git-send-email-liwanp@linux.vnet.ibm.com> (raw)
In-Reply-To: <1352352999-2561-1-git-send-email-liwanp@linux.vnet.ibm.com>
convert PCSPK as piix3 proper QOM child.
PCSPK creation for the PIIX3 is done by calling object_init() with
qdev_init() being called for each child device in the PIIX3 ::init
function.
Signed-off-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>
---
hw/pcspk.c | 19 +------------------
hw/pcspk.h | 19 +++++++++++++++++++
hw/piix3.c | 8 ++++++++
hw/piix3.h | 2 ++
4 files changed, 30 insertions(+), 18 deletions(-)
diff --git a/hw/pcspk.c b/hw/pcspk.c
index ad6491b..fc8bc99 100644
--- a/hw/pcspk.c
+++ b/hw/pcspk.c
@@ -25,31 +25,14 @@
#include "hw.h"
#include "pc.h"
#include "isa.h"
-#include "audio/audio.h"
#include "qemu-timer.h"
#include "i8254.h"
#include "pcspk.h"
-#define PCSPK_BUF_LEN 1792
#define PCSPK_SAMPLE_RATE 32000
#define PCSPK_MAX_FREQ (PCSPK_SAMPLE_RATE >> 1)
#define PCSPK_MIN_COUNT ((PIT_FREQ + PCSPK_MAX_FREQ - 1) / PCSPK_MAX_FREQ)
-typedef struct {
- ISADevice dev;
- MemoryRegion ioport;
- uint32_t iobase;
- uint8_t sample_buf[PCSPK_BUF_LEN];
- QEMUSoundCard card;
- SWVoiceOut *voice;
- void *pit;
- unsigned int pit_count;
- unsigned int samples;
- unsigned int play_pos;
- int data_on;
- int dummy_refresh_clock;
-} PCSpkState;
-
static const char *s_spk = "pcspk";
static PCSpkState *pcspk_state;
@@ -188,7 +171,7 @@ static void pcspk_class_initfn(ObjectClass *klass, void *data)
}
static TypeInfo pcspk_info = {
- .name = "isa-pcspk",
+ .name = TYPE_PCSPK,
.parent = TYPE_ISA_DEVICE,
.instance_size = sizeof(PCSpkState),
.class_init = pcspk_class_initfn,
diff --git a/hw/pcspk.h b/hw/pcspk.h
index 7f42bac..07b3a8f 100644
--- a/hw/pcspk.h
+++ b/hw/pcspk.h
@@ -27,6 +27,25 @@
#include "hw.h"
#include "isa.h"
+#include "audio/audio.h"
+
+#define PCSPK_BUF_LEN 1792
+#define TYPE_PCSPK "isa-pcspk"
+
+typedef struct {
+ ISADevice dev;
+ MemoryRegion ioport;
+ uint32_t iobase;
+ uint8_t sample_buf[PCSPK_BUF_LEN];
+ QEMUSoundCard card;
+ SWVoiceOut *voice;
+ void *pit;
+ unsigned int pit_count;
+ unsigned int samples;
+ unsigned int play_pos;
+ int data_on;
+ int dummy_refresh_clock;
+} PCSpkState;
static inline ISADevice *pcspk_init(ISABus *bus, ISADevice *pit)
{
diff --git a/hw/piix3.c b/hw/piix3.c
index 41739bd..35a0de9 100644
--- a/hw/piix3.c
+++ b/hw/piix3.c
@@ -250,6 +250,11 @@ static int piix3_realize(PCIDevice *dev)
qdev_get_gpio_in(DEVICE(&s->pit), 0));
}
}
+ /* Realize the PCSPK */
+ qdev_set_parent_bus(DEVICE(&s->pcspk), BUS(s->bus));
+ qdev_prop_set_uint32(DEVICE(&s->pcspk), "iobase", 0x61);
+ qdev_prop_set_ptr(DEVICE(&s->pcspk), "pit", ISA_DEVICE(&s->pit));
+ qdev_init_nofail(DEVICE(&s->pcspk));
return 0;
}
@@ -280,6 +285,9 @@ static void piix3_initfn(Object *obj)
qdev_prop_set_int32(DEVICE(&s->pit), "iobase", 0x40);
}
}
+
+ object_initialize(&s->pcspk, TYPE_PCSPK);
+ object_property_add_child(obj, "pcspk", OBJECT(&s->pcspk), NULL);
}
static void piix3_class_init(ObjectClass *klass, void *data)
diff --git a/hw/piix3.h b/hw/piix3.h
index 58486b9..32f7a95 100644
--- a/hw/piix3.h
+++ b/hw/piix3.h
@@ -34,6 +34,7 @@
#include "hpet_emul.h"
#include "i8254.h"
#include "i8254_internal.h"
+#include "pcspk.h"
#define PIIX_NUM_PIC_IRQS 16 /* i8259 * 2 */
#define PIIX_NUM_PIRQS 4ULL /* PIRQ[A-D] */
@@ -77,6 +78,7 @@ typedef struct PIIX3State {
KVMPITState kvm_pit;
} pit;
#endif
+ PCSpkState pcspk;
qemu_irq *pic;
--
1.7.7.6
next prev parent reply other threads:[~2012-11-08 5:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-08 5:36 [Qemu-devel] [PATCH 00/10] piix3: create all child devices as proper QOM children Wanpeng Li
2012-11-08 5:36 ` [Qemu-devel] [PATCH 01/10] convert RTC as piix3 proper QOM child Wanpeng Li
2012-11-08 5:36 ` [Qemu-devel] [PATCH 02/10] convert HPET " Wanpeng Li
2012-11-08 5:36 ` [Qemu-devel] [PATCH 03/10] convert PIT " Wanpeng Li
2012-11-08 5:36 ` Wanpeng Li [this message]
2012-11-08 5:36 ` [Qemu-devel] [PATCH 05/10] convert PORT92 " Wanpeng Li
2012-11-08 5:36 ` [Qemu-devel] [PATCH 06/10] convert i8042 " Wanpeng Li
2012-11-08 5:36 ` [Qemu-devel] [PATCH 07/10] convert VMPORT " Wanpeng Li
2012-11-08 5:36 ` [Qemu-devel] [PATCH 08/10] convert VMMOUSE " Wanpeng Li
2012-11-08 5:36 ` [Qemu-devel] [PATCH 09/10] convert IDE " Wanpeng Li
2012-11-08 5:36 ` [Qemu-devel] [PATCH 10/10] convert IOAPIC " Wanpeng Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1352352999-2561-5-git-send-email-liwanp@linux.vnet.ibm.com \
--to=liwanp@linux.vnet.ibm.com \
--cc=aliguori@us.ibm.com \
--cc=avi@redhat.com \
--cc=blauwirbel@gmail.com \
--cc=jan.kiszka@siemens.com \
--cc=kernelfans@gmail.com \
--cc=mst@redhat.com \
--cc=pair@us.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=weil@mail.berlios.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).