gus.c (11c7549d836b3d3a4ccd903bbfdbdc942b9add52) | gus.c (db895a1e6a97e919f9b86d60c969377357b05066) |
---|---|
1/* 2 * QEMU Proxy for Gravis Ultrasound GF1 emulation by Tibor "TS" Schütz 3 * 4 * Copyright (c) 2002-2005 Vassili Karpov (malc) 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 237 unchanged lines hidden (view full) --- 246}; 247 248static const MemoryRegionPortio gus_portio_list2[] = { 249 {0, 1, 1, .read = gus_readb }, 250 {0, 1, 2, .read = gus_readw }, 251 PORTIO_END_OF_LIST (), 252}; 253 | 1/* 2 * QEMU Proxy for Gravis Ultrasound GF1 emulation by Tibor "TS" Schütz 3 * 4 * Copyright (c) 2002-2005 Vassili Karpov (malc) 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 237 unchanged lines hidden (view full) --- 246}; 247 248static const MemoryRegionPortio gus_portio_list2[] = { 249 {0, 1, 1, .read = gus_readb }, 250 {0, 1, 2, .read = gus_readw }, 251 PORTIO_END_OF_LIST (), 252}; 253 |
254static int gus_initfn (ISADevice *dev) | 254static void gus_realizefn (DeviceState *dev, Error **errp) |
255{ | 255{ |
256 ISADevice *d = ISA_DEVICE(dev); |
|
256 GUSState *s = GUS (dev); 257 struct audsettings as; 258 259 AUD_register_card ("gus", &s->card); 260 261 as.freq = s->freq; 262 as.nchannels = 2; 263 as.fmt = AUD_FMT_S16; --- 5 unchanged lines hidden (view full) --- 269 "gus", 270 s, 271 GUS_callback, 272 &as 273 ); 274 275 if (!s->voice) { 276 AUD_remove_card (&s->card); | 257 GUSState *s = GUS (dev); 258 struct audsettings as; 259 260 AUD_register_card ("gus", &s->card); 261 262 as.freq = s->freq; 263 as.nchannels = 2; 264 as.fmt = AUD_FMT_S16; --- 5 unchanged lines hidden (view full) --- 270 "gus", 271 s, 272 GUS_callback, 273 &as 274 ); 275 276 if (!s->voice) { 277 AUD_remove_card (&s->card); |
277 return -1; | 278 error_setg(errp, "No voice"); 279 return; |
278 } 279 280 s->shift = 2; 281 s->samples = AUD_get_buffer_size_out (s->voice) >> s->shift; 282 s->mixbuf = g_malloc0 (s->samples << s->shift); 283 | 280 } 281 282 s->shift = 2; 283 s->samples = AUD_get_buffer_size_out (s->voice) >> s->shift; 284 s->mixbuf = g_malloc0 (s->samples << s->shift); 285 |
284 isa_register_portio_list (dev, s->port, gus_portio_list1, s, "gus"); 285 isa_register_portio_list (dev, (s->port + 0x100) & 0xf00, | 286 isa_register_portio_list (d, s->port, gus_portio_list1, s, "gus"); 287 isa_register_portio_list (d, (s->port + 0x100) & 0xf00, |
286 gus_portio_list2, s, "gus"); 287 288 DMA_register_channel (s->emu.gusdma, GUS_read_DMA, s); 289 s->emu.himemaddr = s->himem; 290 s->emu.gusdatapos = s->emu.himemaddr + 1024 * 1024 + 32; 291 s->emu.opaque = s; | 288 gus_portio_list2, s, "gus"); 289 290 DMA_register_channel (s->emu.gusdma, GUS_read_DMA, s); 291 s->emu.himemaddr = s->himem; 292 s->emu.gusdatapos = s->emu.himemaddr + 1024 * 1024 + 32; 293 s->emu.opaque = s; |
292 isa_init_irq (dev, &s->pic, s->emu.gusirq); | 294 isa_init_irq (d, &s->pic, s->emu.gusirq); |
293 294 AUD_set_active_out (s->voice, 1); | 295 296 AUD_set_active_out (s->voice, 1); |
295 296 return 0; | |
297} 298 299static int GUS_init (ISABus *bus) 300{ 301 isa_create_simple (bus, TYPE_GUS); 302 return 0; 303} 304 305static Property gus_properties[] = { 306 DEFINE_PROP_UINT32 ("freq", GUSState, freq, 44100), 307 DEFINE_PROP_HEX32 ("iobase", GUSState, port, 0x240), 308 DEFINE_PROP_UINT32 ("irq", GUSState, emu.gusirq, 7), 309 DEFINE_PROP_UINT32 ("dma", GUSState, emu.gusdma, 3), 310 DEFINE_PROP_END_OF_LIST (), 311}; 312 313static void gus_class_initfn (ObjectClass *klass, void *data) 314{ 315 DeviceClass *dc = DEVICE_CLASS (klass); | 297} 298 299static int GUS_init (ISABus *bus) 300{ 301 isa_create_simple (bus, TYPE_GUS); 302 return 0; 303} 304 305static Property gus_properties[] = { 306 DEFINE_PROP_UINT32 ("freq", GUSState, freq, 44100), 307 DEFINE_PROP_HEX32 ("iobase", GUSState, port, 0x240), 308 DEFINE_PROP_UINT32 ("irq", GUSState, emu.gusirq, 7), 309 DEFINE_PROP_UINT32 ("dma", GUSState, emu.gusdma, 3), 310 DEFINE_PROP_END_OF_LIST (), 311}; 312 313static void gus_class_initfn (ObjectClass *klass, void *data) 314{ 315 DeviceClass *dc = DEVICE_CLASS (klass); |
316 ISADeviceClass *ic = ISA_DEVICE_CLASS (klass); 317 ic->init = gus_initfn; | 316 317 dc->realize = gus_realizefn; |
318 dc->desc = "Gravis Ultrasound GF1"; 319 dc->vmsd = &vmstate_gus; 320 dc->props = gus_properties; 321} 322 323static const TypeInfo gus_info = { 324 .name = TYPE_GUS, 325 .parent = TYPE_ISA_DEVICE, 326 .instance_size = sizeof (GUSState), 327 .class_init = gus_class_initfn, 328}; 329 330static void gus_register_types (void) 331{ 332 type_register_static (&gus_info); 333 isa_register_soundhw("gus", "Gravis Ultrasound GF1", GUS_init); 334} 335 336type_init (gus_register_types) | 318 dc->desc = "Gravis Ultrasound GF1"; 319 dc->vmsd = &vmstate_gus; 320 dc->props = gus_properties; 321} 322 323static const TypeInfo gus_info = { 324 .name = TYPE_GUS, 325 .parent = TYPE_ISA_DEVICE, 326 .instance_size = sizeof (GUSState), 327 .class_init = gus_class_initfn, 328}; 329 330static void gus_register_types (void) 331{ 332 type_register_static (&gus_info); 333 isa_register_soundhw("gus", "Gravis Ultrasound GF1", GUS_init); 334} 335 336type_init (gus_register_types) |