xref: /openbmc/qemu/hw/audio/adlib.c (revision 6086a565b0efe3eb66c5bf65a715a2c84425e47f)
149ab747fSPaolo Bonzini /*
249ab747fSPaolo Bonzini  * QEMU Proxy for OPL2/3 emulation by MAME team
349ab747fSPaolo Bonzini  *
449ab747fSPaolo Bonzini  * Copyright (c) 2004-2005 Vassili Karpov (malc)
549ab747fSPaolo Bonzini  *
649ab747fSPaolo Bonzini  * Permission is hereby granted, free of charge, to any person obtaining a copy
749ab747fSPaolo Bonzini  * of this software and associated documentation files (the "Software"), to deal
849ab747fSPaolo Bonzini  * in the Software without restriction, including without limitation the rights
949ab747fSPaolo Bonzini  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1049ab747fSPaolo Bonzini  * copies of the Software, and to permit persons to whom the Software is
1149ab747fSPaolo Bonzini  * furnished to do so, subject to the following conditions:
1249ab747fSPaolo Bonzini  *
1349ab747fSPaolo Bonzini  * The above copyright notice and this permission notice shall be included in
1449ab747fSPaolo Bonzini  * all copies or substantial portions of the Software.
1549ab747fSPaolo Bonzini  *
1649ab747fSPaolo Bonzini  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1749ab747fSPaolo Bonzini  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1849ab747fSPaolo Bonzini  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1949ab747fSPaolo Bonzini  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2049ab747fSPaolo Bonzini  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2149ab747fSPaolo Bonzini  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2249ab747fSPaolo Bonzini  * THE SOFTWARE.
2349ab747fSPaolo Bonzini  */
2449ab747fSPaolo Bonzini 
25*6086a565SPeter Maydell #include "qemu/osdep.h"
2649ab747fSPaolo Bonzini #include "hw/hw.h"
2749ab747fSPaolo Bonzini #include "hw/audio/audio.h"
2849ab747fSPaolo Bonzini #include "audio/audio.h"
2949ab747fSPaolo Bonzini #include "hw/isa/isa.h"
3049ab747fSPaolo Bonzini 
3149ab747fSPaolo Bonzini //#define DEBUG
3249ab747fSPaolo Bonzini 
3349ab747fSPaolo Bonzini #define ADLIB_KILL_TIMERS 1
3449ab747fSPaolo Bonzini 
358c444a19SPaolo Bonzini #ifdef HAS_YMF262
368c444a19SPaolo Bonzini #define ADLIB_DESC "Yamaha YMF262 (OPL3)"
378c444a19SPaolo Bonzini #else
388c444a19SPaolo Bonzini #define ADLIB_DESC "Yamaha YM3812 (OPL2)"
398c444a19SPaolo Bonzini #endif
408c444a19SPaolo Bonzini 
4149ab747fSPaolo Bonzini #ifdef DEBUG
4249ab747fSPaolo Bonzini #include "qemu/timer.h"
4349ab747fSPaolo Bonzini #endif
4449ab747fSPaolo Bonzini 
4549ab747fSPaolo Bonzini #define dolog(...) AUD_log ("adlib", __VA_ARGS__)
4649ab747fSPaolo Bonzini #ifdef DEBUG
4749ab747fSPaolo Bonzini #define ldebug(...) dolog (__VA_ARGS__)
4849ab747fSPaolo Bonzini #else
4949ab747fSPaolo Bonzini #define ldebug(...)
5049ab747fSPaolo Bonzini #endif
5149ab747fSPaolo Bonzini 
5249ab747fSPaolo Bonzini #ifdef HAS_YMF262
5349ab747fSPaolo Bonzini #include "ymf262.h"
5449ab747fSPaolo Bonzini void YMF262UpdateOneQEMU (int which, INT16 *dst, int length);
5549ab747fSPaolo Bonzini #define SHIFT 2
5649ab747fSPaolo Bonzini #else
5747b43a1fSPaolo Bonzini #include "fmopl.h"
5849ab747fSPaolo Bonzini #define SHIFT 1
5949ab747fSPaolo Bonzini #endif
6049ab747fSPaolo Bonzini 
618c444a19SPaolo Bonzini #define TYPE_ADLIB "adlib"
628c444a19SPaolo Bonzini #define ADLIB(obj) OBJECT_CHECK(AdlibState, (obj), TYPE_ADLIB)
6349ab747fSPaolo Bonzini 
6449ab747fSPaolo Bonzini typedef struct {
658c444a19SPaolo Bonzini     ISADevice parent_obj;
668c444a19SPaolo Bonzini 
6749ab747fSPaolo Bonzini     QEMUSoundCard card;
688c444a19SPaolo Bonzini     uint32_t freq;
698c444a19SPaolo Bonzini     uint32_t port;
7049ab747fSPaolo Bonzini     int ticking[2];
7149ab747fSPaolo Bonzini     int enabled;
7249ab747fSPaolo Bonzini     int active;
7349ab747fSPaolo Bonzini     int bufpos;
7449ab747fSPaolo Bonzini #ifdef DEBUG
7549ab747fSPaolo Bonzini     int64_t exp[2];
7649ab747fSPaolo Bonzini #endif
7749ab747fSPaolo Bonzini     int16_t *mixbuf;
7849ab747fSPaolo Bonzini     uint64_t dexp[2];
7949ab747fSPaolo Bonzini     SWVoiceOut *voice;
8049ab747fSPaolo Bonzini     int left, pos, samples;
8149ab747fSPaolo Bonzini     QEMUAudioTimeStamp ats;
8249ab747fSPaolo Bonzini #ifndef HAS_YMF262
8349ab747fSPaolo Bonzini     FM_OPL *opl;
8449ab747fSPaolo Bonzini #endif
85848696bfSKirill Batuzov     PortioList port_list;
8649ab747fSPaolo Bonzini } AdlibState;
8749ab747fSPaolo Bonzini 
888c444a19SPaolo Bonzini static AdlibState *glob_adlib;
8949ab747fSPaolo Bonzini 
9049ab747fSPaolo Bonzini static void adlib_stop_opl_timer (AdlibState *s, size_t n)
9149ab747fSPaolo Bonzini {
9249ab747fSPaolo Bonzini #ifdef HAS_YMF262
9349ab747fSPaolo Bonzini     YMF262TimerOver (0, n);
9449ab747fSPaolo Bonzini #else
9549ab747fSPaolo Bonzini     OPLTimerOver (s->opl, n);
9649ab747fSPaolo Bonzini #endif
9749ab747fSPaolo Bonzini     s->ticking[n] = 0;
9849ab747fSPaolo Bonzini }
9949ab747fSPaolo Bonzini 
10049ab747fSPaolo Bonzini static void adlib_kill_timers (AdlibState *s)
10149ab747fSPaolo Bonzini {
10249ab747fSPaolo Bonzini     size_t i;
10349ab747fSPaolo Bonzini 
10449ab747fSPaolo Bonzini     for (i = 0; i < 2; ++i) {
10549ab747fSPaolo Bonzini         if (s->ticking[i]) {
10649ab747fSPaolo Bonzini             uint64_t delta;
10749ab747fSPaolo Bonzini 
10849ab747fSPaolo Bonzini             delta = AUD_get_elapsed_usec_out (s->voice, &s->ats);
10949ab747fSPaolo Bonzini             ldebug (
11049ab747fSPaolo Bonzini                 "delta = %f dexp = %f expired => %d\n",
11149ab747fSPaolo Bonzini                 delta / 1000000.0,
11249ab747fSPaolo Bonzini                 s->dexp[i] / 1000000.0,
11349ab747fSPaolo Bonzini                 delta >= s->dexp[i]
11449ab747fSPaolo Bonzini                 );
11549ab747fSPaolo Bonzini             if (ADLIB_KILL_TIMERS || delta >= s->dexp[i]) {
11649ab747fSPaolo Bonzini                 adlib_stop_opl_timer (s, i);
11749ab747fSPaolo Bonzini                 AUD_init_time_stamp_out (s->voice, &s->ats);
11849ab747fSPaolo Bonzini             }
11949ab747fSPaolo Bonzini         }
12049ab747fSPaolo Bonzini     }
12149ab747fSPaolo Bonzini }
12249ab747fSPaolo Bonzini 
1238307c294SNutan Shinde static void adlib_write(void *opaque, uint32_t nport, uint32_t val)
12449ab747fSPaolo Bonzini {
12549ab747fSPaolo Bonzini     AdlibState *s = opaque;
12649ab747fSPaolo Bonzini     int a = nport & 3;
12749ab747fSPaolo Bonzini 
12849ab747fSPaolo Bonzini     s->active = 1;
12949ab747fSPaolo Bonzini     AUD_set_active_out (s->voice, 1);
13049ab747fSPaolo Bonzini 
13149ab747fSPaolo Bonzini     adlib_kill_timers (s);
13249ab747fSPaolo Bonzini 
13349ab747fSPaolo Bonzini #ifdef HAS_YMF262
13449ab747fSPaolo Bonzini     YMF262Write (0, a, val);
13549ab747fSPaolo Bonzini #else
13649ab747fSPaolo Bonzini     OPLWrite (s->opl, a, val);
13749ab747fSPaolo Bonzini #endif
13849ab747fSPaolo Bonzini }
13949ab747fSPaolo Bonzini 
1408307c294SNutan Shinde static uint32_t adlib_read(void *opaque, uint32_t nport)
14149ab747fSPaolo Bonzini {
14249ab747fSPaolo Bonzini     AdlibState *s = opaque;
14349ab747fSPaolo Bonzini     uint8_t data;
14449ab747fSPaolo Bonzini     int a = nport & 3;
14549ab747fSPaolo Bonzini 
14649ab747fSPaolo Bonzini     adlib_kill_timers (s);
14749ab747fSPaolo Bonzini 
14849ab747fSPaolo Bonzini #ifdef HAS_YMF262
14949ab747fSPaolo Bonzini     data = YMF262Read (0, a);
15049ab747fSPaolo Bonzini #else
15149ab747fSPaolo Bonzini     data = OPLRead (s->opl, a);
15249ab747fSPaolo Bonzini #endif
15349ab747fSPaolo Bonzini     return data;
15449ab747fSPaolo Bonzini }
15549ab747fSPaolo Bonzini 
15649ab747fSPaolo Bonzini static void timer_handler (int c, double interval_Sec)
15749ab747fSPaolo Bonzini {
1588c444a19SPaolo Bonzini     AdlibState *s = glob_adlib;
15949ab747fSPaolo Bonzini     unsigned n = c & 1;
16049ab747fSPaolo Bonzini #ifdef DEBUG
16149ab747fSPaolo Bonzini     double interval;
16249ab747fSPaolo Bonzini     int64_t exp;
16349ab747fSPaolo Bonzini #endif
16449ab747fSPaolo Bonzini 
16549ab747fSPaolo Bonzini     if (interval_Sec == 0.0) {
16649ab747fSPaolo Bonzini         s->ticking[n] = 0;
16749ab747fSPaolo Bonzini         return;
16849ab747fSPaolo Bonzini     }
16949ab747fSPaolo Bonzini 
17049ab747fSPaolo Bonzini     s->ticking[n] = 1;
17149ab747fSPaolo Bonzini #ifdef DEBUG
17249ab747fSPaolo Bonzini     interval = get_ticks_per_sec () * interval_Sec;
173bc72ad67SAlex Bligh     exp = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + interval;
17449ab747fSPaolo Bonzini     s->exp[n] = exp;
17549ab747fSPaolo Bonzini #endif
17649ab747fSPaolo Bonzini 
17749ab747fSPaolo Bonzini     s->dexp[n] = interval_Sec * 1000000.0;
17849ab747fSPaolo Bonzini     AUD_init_time_stamp_out (s->voice, &s->ats);
17949ab747fSPaolo Bonzini }
18049ab747fSPaolo Bonzini 
18149ab747fSPaolo Bonzini static int write_audio (AdlibState *s, int samples)
18249ab747fSPaolo Bonzini {
18349ab747fSPaolo Bonzini     int net = 0;
18449ab747fSPaolo Bonzini     int pos = s->pos;
18549ab747fSPaolo Bonzini 
18649ab747fSPaolo Bonzini     while (samples) {
18749ab747fSPaolo Bonzini         int nbytes, wbytes, wsampl;
18849ab747fSPaolo Bonzini 
18949ab747fSPaolo Bonzini         nbytes = samples << SHIFT;
19049ab747fSPaolo Bonzini         wbytes = AUD_write (
19149ab747fSPaolo Bonzini             s->voice,
19249ab747fSPaolo Bonzini             s->mixbuf + (pos << (SHIFT - 1)),
19349ab747fSPaolo Bonzini             nbytes
19449ab747fSPaolo Bonzini             );
19549ab747fSPaolo Bonzini 
19649ab747fSPaolo Bonzini         if (wbytes) {
19749ab747fSPaolo Bonzini             wsampl = wbytes >> SHIFT;
19849ab747fSPaolo Bonzini 
19949ab747fSPaolo Bonzini             samples -= wsampl;
20049ab747fSPaolo Bonzini             pos = (pos + wsampl) % s->samples;
20149ab747fSPaolo Bonzini 
20249ab747fSPaolo Bonzini             net += wsampl;
20349ab747fSPaolo Bonzini         }
20449ab747fSPaolo Bonzini         else {
20549ab747fSPaolo Bonzini             break;
20649ab747fSPaolo Bonzini         }
20749ab747fSPaolo Bonzini     }
20849ab747fSPaolo Bonzini 
20949ab747fSPaolo Bonzini     return net;
21049ab747fSPaolo Bonzini }
21149ab747fSPaolo Bonzini 
21249ab747fSPaolo Bonzini static void adlib_callback (void *opaque, int free)
21349ab747fSPaolo Bonzini {
21449ab747fSPaolo Bonzini     AdlibState *s = opaque;
21549ab747fSPaolo Bonzini     int samples, net = 0, to_play, written;
21649ab747fSPaolo Bonzini 
21749ab747fSPaolo Bonzini     samples = free >> SHIFT;
21849ab747fSPaolo Bonzini     if (!(s->active && s->enabled) || !samples) {
21949ab747fSPaolo Bonzini         return;
22049ab747fSPaolo Bonzini     }
22149ab747fSPaolo Bonzini 
22249ab747fSPaolo Bonzini     to_play = audio_MIN (s->left, samples);
22349ab747fSPaolo Bonzini     while (to_play) {
22449ab747fSPaolo Bonzini         written = write_audio (s, to_play);
22549ab747fSPaolo Bonzini 
22649ab747fSPaolo Bonzini         if (written) {
22749ab747fSPaolo Bonzini             s->left -= written;
22849ab747fSPaolo Bonzini             samples -= written;
22949ab747fSPaolo Bonzini             to_play -= written;
23049ab747fSPaolo Bonzini             s->pos = (s->pos + written) % s->samples;
23149ab747fSPaolo Bonzini         }
23249ab747fSPaolo Bonzini         else {
23349ab747fSPaolo Bonzini             return;
23449ab747fSPaolo Bonzini         }
23549ab747fSPaolo Bonzini     }
23649ab747fSPaolo Bonzini 
23749ab747fSPaolo Bonzini     samples = audio_MIN (samples, s->samples - s->pos);
23849ab747fSPaolo Bonzini     if (!samples) {
23949ab747fSPaolo Bonzini         return;
24049ab747fSPaolo Bonzini     }
24149ab747fSPaolo Bonzini 
24249ab747fSPaolo Bonzini #ifdef HAS_YMF262
24349ab747fSPaolo Bonzini     YMF262UpdateOneQEMU (0, s->mixbuf + s->pos * 2, samples);
24449ab747fSPaolo Bonzini #else
24549ab747fSPaolo Bonzini     YM3812UpdateOne (s->opl, s->mixbuf + s->pos, samples);
24649ab747fSPaolo Bonzini #endif
24749ab747fSPaolo Bonzini 
24849ab747fSPaolo Bonzini     while (samples) {
24949ab747fSPaolo Bonzini         written = write_audio (s, samples);
25049ab747fSPaolo Bonzini 
25149ab747fSPaolo Bonzini         if (written) {
25249ab747fSPaolo Bonzini             net += written;
25349ab747fSPaolo Bonzini             samples -= written;
25449ab747fSPaolo Bonzini             s->pos = (s->pos + written) % s->samples;
25549ab747fSPaolo Bonzini         }
25649ab747fSPaolo Bonzini         else {
25749ab747fSPaolo Bonzini             s->left = samples;
25849ab747fSPaolo Bonzini             return;
25949ab747fSPaolo Bonzini         }
26049ab747fSPaolo Bonzini     }
26149ab747fSPaolo Bonzini }
26249ab747fSPaolo Bonzini 
26349ab747fSPaolo Bonzini static void Adlib_fini (AdlibState *s)
26449ab747fSPaolo Bonzini {
26549ab747fSPaolo Bonzini #ifdef HAS_YMF262
26649ab747fSPaolo Bonzini     YMF262Shutdown ();
26749ab747fSPaolo Bonzini #else
26849ab747fSPaolo Bonzini     if (s->opl) {
26949ab747fSPaolo Bonzini         OPLDestroy (s->opl);
27049ab747fSPaolo Bonzini         s->opl = NULL;
27149ab747fSPaolo Bonzini     }
27249ab747fSPaolo Bonzini #endif
27349ab747fSPaolo Bonzini 
27449ab747fSPaolo Bonzini     g_free(s->mixbuf);
27549ab747fSPaolo Bonzini 
27649ab747fSPaolo Bonzini     s->active = 0;
27749ab747fSPaolo Bonzini     s->enabled = 0;
27849ab747fSPaolo Bonzini     AUD_remove_card (&s->card);
27949ab747fSPaolo Bonzini }
28049ab747fSPaolo Bonzini 
281a8aec295SJan Kiszka static MemoryRegionPortio adlib_portio_list[] = {
282a8aec295SJan Kiszka     { 0, 4, 1, .read = adlib_read, .write = adlib_write, },
283a8aec295SJan Kiszka     { 0, 2, 1, .read = adlib_read, .write = adlib_write, },
2842b21fb57SHervé Poussineau     { 0x388, 4, 1, .read = adlib_read, .write = adlib_write, },
285a8aec295SJan Kiszka     PORTIO_END_OF_LIST(),
286a8aec295SJan Kiszka };
287a8aec295SJan Kiszka 
288db895a1eSAndreas Färber static void adlib_realizefn (DeviceState *dev, Error **errp)
28949ab747fSPaolo Bonzini {
2908c444a19SPaolo Bonzini     AdlibState *s = ADLIB(dev);
29149ab747fSPaolo Bonzini     struct audsettings as;
29249ab747fSPaolo Bonzini 
2938c444a19SPaolo Bonzini     if (glob_adlib) {
294db895a1eSAndreas Färber         error_setg (errp, "Cannot create more than 1 adlib device");
295db895a1eSAndreas Färber         return;
2968c444a19SPaolo Bonzini     }
2978c444a19SPaolo Bonzini     glob_adlib = s;
2988c444a19SPaolo Bonzini 
29949ab747fSPaolo Bonzini #ifdef HAS_YMF262
3008c444a19SPaolo Bonzini     if (YMF262Init (1, 14318180, s->freq)) {
301db895a1eSAndreas Färber         error_setg (errp, "YMF262Init %d failed", s->freq);
302db895a1eSAndreas Färber         return;
30349ab747fSPaolo Bonzini     }
30449ab747fSPaolo Bonzini     else {
30549ab747fSPaolo Bonzini         YMF262SetTimerHandler (0, timer_handler, 0);
30649ab747fSPaolo Bonzini         s->enabled = 1;
30749ab747fSPaolo Bonzini     }
30849ab747fSPaolo Bonzini #else
3098c444a19SPaolo Bonzini     s->opl = OPLCreate (OPL_TYPE_YM3812, 3579545, s->freq);
31049ab747fSPaolo Bonzini     if (!s->opl) {
311db895a1eSAndreas Färber         error_setg (errp, "OPLCreate %d failed", s->freq);
312db895a1eSAndreas Färber         return;
31349ab747fSPaolo Bonzini     }
31449ab747fSPaolo Bonzini     else {
31549ab747fSPaolo Bonzini         OPLSetTimerHandler (s->opl, timer_handler, 0);
31649ab747fSPaolo Bonzini         s->enabled = 1;
31749ab747fSPaolo Bonzini     }
31849ab747fSPaolo Bonzini #endif
31949ab747fSPaolo Bonzini 
3208c444a19SPaolo Bonzini     as.freq = s->freq;
32149ab747fSPaolo Bonzini     as.nchannels = SHIFT;
32249ab747fSPaolo Bonzini     as.fmt = AUD_FMT_S16;
32349ab747fSPaolo Bonzini     as.endianness = AUDIO_HOST_ENDIANNESS;
32449ab747fSPaolo Bonzini 
32549ab747fSPaolo Bonzini     AUD_register_card ("adlib", &s->card);
32649ab747fSPaolo Bonzini 
32749ab747fSPaolo Bonzini     s->voice = AUD_open_out (
32849ab747fSPaolo Bonzini         &s->card,
32949ab747fSPaolo Bonzini         s->voice,
33049ab747fSPaolo Bonzini         "adlib",
33149ab747fSPaolo Bonzini         s,
33249ab747fSPaolo Bonzini         adlib_callback,
33349ab747fSPaolo Bonzini         &as
33449ab747fSPaolo Bonzini         );
33549ab747fSPaolo Bonzini     if (!s->voice) {
33649ab747fSPaolo Bonzini         Adlib_fini (s);
337db895a1eSAndreas Färber         error_setg (errp, "Initializing audio voice failed");
338db895a1eSAndreas Färber         return;
33949ab747fSPaolo Bonzini     }
34049ab747fSPaolo Bonzini 
34149ab747fSPaolo Bonzini     s->samples = AUD_get_buffer_size_out (s->voice) >> SHIFT;
34249ab747fSPaolo Bonzini     s->mixbuf = g_malloc0 (s->samples << SHIFT);
34349ab747fSPaolo Bonzini 
3447f0ba7bbSPaolo Bonzini     adlib_portio_list[0].offset = s->port;
3457f0ba7bbSPaolo Bonzini     adlib_portio_list[1].offset = s->port + 8;
346848696bfSKirill Batuzov     portio_list_init (&s->port_list, OBJECT(s), adlib_portio_list, s, "adlib");
347848696bfSKirill Batuzov     portio_list_add (&s->port_list, isa_address_space_io(&s->parent_obj), 0);
34849ab747fSPaolo Bonzini }
3498c444a19SPaolo Bonzini 
3508c444a19SPaolo Bonzini static Property adlib_properties[] = {
351c7bcc85dSPaolo Bonzini     DEFINE_PROP_UINT32 ("iobase",  AdlibState, port, 0x220),
3528c444a19SPaolo Bonzini     DEFINE_PROP_UINT32 ("freq",    AdlibState, freq,  44100),
3538c444a19SPaolo Bonzini     DEFINE_PROP_END_OF_LIST (),
3548c444a19SPaolo Bonzini };
3558c444a19SPaolo Bonzini 
3568c444a19SPaolo Bonzini static void adlib_class_initfn (ObjectClass *klass, void *data)
3578c444a19SPaolo Bonzini {
3588c444a19SPaolo Bonzini     DeviceClass *dc = DEVICE_CLASS (klass);
359db895a1eSAndreas Färber 
360db895a1eSAndreas Färber     dc->realize = adlib_realizefn;
361125ee0edSMarcel Apfelbaum     set_bit(DEVICE_CATEGORY_SOUND, dc->categories);
3628c444a19SPaolo Bonzini     dc->desc = ADLIB_DESC;
3638c444a19SPaolo Bonzini     dc->props = adlib_properties;
3648c444a19SPaolo Bonzini }
3658c444a19SPaolo Bonzini 
3668c444a19SPaolo Bonzini static const TypeInfo adlib_info = {
3678c444a19SPaolo Bonzini     .name          = TYPE_ADLIB,
3688c444a19SPaolo Bonzini     .parent        = TYPE_ISA_DEVICE,
3698c444a19SPaolo Bonzini     .instance_size = sizeof (AdlibState),
3708c444a19SPaolo Bonzini     .class_init    = adlib_class_initfn,
3718c444a19SPaolo Bonzini };
3728c444a19SPaolo Bonzini 
37336cd6f6fSPaolo Bonzini static int Adlib_init (ISABus *bus)
3748c444a19SPaolo Bonzini {
3758c444a19SPaolo Bonzini     isa_create_simple (bus, TYPE_ADLIB);
3768c444a19SPaolo Bonzini     return 0;
3778c444a19SPaolo Bonzini }
3788c444a19SPaolo Bonzini 
3798c444a19SPaolo Bonzini static void adlib_register_types (void)
3808c444a19SPaolo Bonzini {
3818c444a19SPaolo Bonzini     type_register_static (&adlib_info);
38236cd6f6fSPaolo Bonzini     isa_register_soundhw("adlib", ADLIB_DESC, Adlib_init);
3838c444a19SPaolo Bonzini }
3848c444a19SPaolo Bonzini 
3858c444a19SPaolo Bonzini type_init (adlib_register_types)
386