From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:40294) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPcLF-0007fD-1r for qemu-devel@nongnu.org; Tue, 09 Apr 2013 13:28:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UPcL7-0000nq-Nd for qemu-devel@nongnu.org; Tue, 09 Apr 2013 13:28:20 -0400 Received: from cantor2.suse.de ([195.135.220.15]:40644 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPcL7-0000nW-Dy for qemu-devel@nongnu.org; Tue, 09 Apr 2013 13:28:13 -0400 Message-ID: <51644FAB.1090908@suse.de> Date: Tue, 09 Apr 2013 19:28:11 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1364914261-4237-1-git-send-email-pbonzini@redhat.com> <1364914261-4237-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1364914261-4237-2-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [RFC PATCH 1/6] adlib: qdev-ify List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: av1474@comtv.ru, qemu-devel@nongnu.org Am 02.04.2013 16:50, schrieb Paolo Bonzini: > Signed-off-by: Paolo Bonzini > --- > hw/adlib.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++------= -------- > 1 file changed, 64 insertions(+), 18 deletions(-) >=20 > diff --git a/hw/adlib.c b/hw/adlib.c > index e6bce59..ca47b55 100644 > --- a/hw/adlib.c > +++ b/hw/adlib.c > @@ -31,6 +31,12 @@ > =20 > #define ADLIB_KILL_TIMERS 1 > =20 > +#ifdef HAS_YMF262 > +#define ADLIB_DESC "Yamaha YMF262 (OPL3)" > +#else > +#define ADLIB_DESC "Yamaha YM3812 (OPL2)" > +#endif Shouldn't in the process of QOM'ifying this be split into two devices? Is HAS_YMF262 user-selected or dependent on libraries or something? > + > #ifdef DEBUG > #include "qemu/timer.h" > #endif > @@ -56,13 +62,11 @@ void YMF262UpdateOneQEMU (int which, INT16 *dst, in= t length); > #define IO_WRITE_PROTO(name) \ > void name (void *opaque, uint32_t nport, uint32_t val) > =20 > -static struct { > - int port; > - int freq; > -} conf =3D {0x220, 44100}; > - > typedef struct { > + ISADevice dev; parent_obj and white line please. :) > QEMUSoundCard card; > + uint32_t freq; > + uint32_t port; > int ticking[2]; > int enabled; > int active; > @@ -80,7 +84,7 @@ typedef struct { > #endif > } AdlibState; > =20 > -static AdlibState glob_adlib; > +static AdlibState *glob_adlib; > =20 > static void adlib_stop_opl_timer (AdlibState *s, size_t n) > { > @@ -150,7 +154,7 @@ static IO_READ_PROTO (adlib_read) > =20 > static void timer_handler (int c, double interval_Sec) > { > - AdlibState *s =3D &glob_adlib; > + AdlibState *s =3D glob_adlib; > unsigned n =3D c & 1; > #ifdef DEBUG > double interval; > @@ -275,14 +279,21 @@ static void Adlib_fini (AdlibState *s) > AUD_remove_card (&s->card); > } > =20 > -int Adlib_init (ISABus *bus) > +static int Adlib_initfn (ISADevice *dev) Hm, obviously that conflicts with my series converting ISADevices to QOM realize that I was hoping to still get into 1.5... > { > - AdlibState *s =3D &glob_adlib; > + AdlibState *s; > struct audsettings as; > =20 > + if (glob_adlib) { > + dolog ("Cannot create more than 1 adlib device\n"); > + return -1; > + } > + s =3D DO_UPCAST (AdlibState, dev, dev); No new DO_UPCAST() for QOM objects please! > + glob_adlib =3D s; > + > #ifdef HAS_YMF262 > - if (YMF262Init (1, 14318180, conf.freq)) { > - dolog ("YMF262Init %d failed\n", conf.freq); > + if (YMF262Init (1, 14318180, s->freq)) { > + dolog ("YMF262Init %d failed\n", s->freq); > return -1; > } > else { > @@ -290,9 +301,9 @@ int Adlib_init (ISABus *bus) > s->enabled =3D 1; > } > #else > - s->opl =3D OPLCreate (OPL_TYPE_YM3812, 3579545, conf.freq); > + s->opl =3D OPLCreate (OPL_TYPE_YM3812, 3579545, s->freq); > if (!s->opl) { > - dolog ("OPLCreate %d failed\n", conf.freq); > + dolog ("OPLCreate %d failed\n", s->freq); > return -1; > } > else { > @@ -301,7 +312,7 @@ int Adlib_init (ISABus *bus) > } > #endif > =20 > - as.freq =3D conf.freq; > + as.freq =3D s->freq; > as.nchannels =3D SHIFT; > as.fmt =3D AUD_FMT_S16; > as.endianness =3D AUDIO_HOST_ENDIANNESS; > @@ -327,11 +338,46 @@ int Adlib_init (ISABus *bus) > register_ioport_read (0x388, 4, 1, adlib_read, s); > register_ioport_write (0x388, 4, 1, adlib_write, s); > =20 > - register_ioport_read (conf.port, 4, 1, adlib_read, s); > - register_ioport_write (conf.port, 4, 1, adlib_write, s); > + register_ioport_read (s->port, 4, 1, adlib_read, s); > + register_ioport_write (s->port, 4, 1, adlib_write, s); > =20 > - register_ioport_read (conf.port + 8, 2, 1, adlib_read, s); > - register_ioport_write (conf.port + 8, 2, 1, adlib_write, s); > + register_ioport_read (s->port + 8, 2, 1, adlib_read, s); > + register_ioport_write (s->port + 8, 2, 1, adlib_write, s); > =20 > return 0; > } > + > +static Property adlib_properties[] =3D { > + DEFINE_PROP_HEX32 ("iobase", AdlibState, port, 0x220), > + DEFINE_PROP_UINT32 ("freq", AdlibState, freq, 44100), > + DEFINE_PROP_END_OF_LIST (), > +}; > + > +static void adlib_class_initfn (ObjectClass *klass, void *data) > +{ > + DeviceClass *dc =3D DEVICE_CLASS (klass); > + ISADeviceClass *ic =3D ISA_DEVICE_CLASS (klass); > + ic->init =3D Adlib_initfn; > + dc->desc =3D ADLIB_DESC; > + dc->props =3D adlib_properties; > +} > + > +static TypeInfo adlib_info =3D { static const please. > + .name =3D "adlib", > + .parent =3D TYPE_ISA_DEVICE, > + .instance_size =3D sizeof (AdlibState), > + .class_init =3D adlib_class_initfn, > +}; > + > +int Adlib_init (ISABus *bus) > +{ > + isa_create_simple (bus, "adlib"); > + return 0; > +} > + > +static void adlib_register_types (void) > +{ > + type_register_static (&adlib_info); > +} > + > +type_init (adlib_register_types) Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg