| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * QEMU Proxy for Gravis Ultrasound GF1 emulation by Tibor "TS" Schütz | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Copyright (c) 2002-2005 Vassili Karpov (malc) | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Permission is hereby granted, free of charge, to any person obtaining a copy | 
					
						
							|  |  |  |  * of this software and associated documentation files (the "Software"), to deal | 
					
						
							|  |  |  |  * in the Software without restriction, including without limitation the rights | 
					
						
							|  |  |  |  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 
					
						
							|  |  |  |  * copies of the Software, and to permit persons to whom the Software is | 
					
						
							|  |  |  |  * furnished to do so, subject to the following conditions: | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The above copyright notice and this permission notice shall be included in | 
					
						
							|  |  |  |  * all copies or substantial portions of the Software. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 
					
						
							|  |  |  |  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 
					
						
							|  |  |  |  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | 
					
						
							|  |  |  |  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 
					
						
							|  |  |  |  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 
					
						
							|  |  |  |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | 
					
						
							|  |  |  |  * THE SOFTWARE. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2019-05-23 16:35:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-18 17:33:52 +00:00
										 |  |  | #include "qemu/osdep.h"
 | 
					
						
							| 
									
										
											  
											
												include/qemu/osdep.h: Don't include qapi/error.h
Commit 57cb38b included qapi/error.h into qemu/osdep.h to get the
Error typedef.  Since then, we've moved to include qemu/osdep.h
everywhere.  Its file comment explains: "To avoid getting into
possible circular include dependencies, this file should not include
any other QEMU headers, with the exceptions of config-host.h,
compiler.h, os-posix.h and os-win32.h, all of which are doing a
similar job to this file and are under similar constraints."
qapi/error.h doesn't do a similar job, and it doesn't adhere to
similar constraints: it includes qapi-types.h.  That's in excess of
100KiB of crap most .c files don't actually need.
Add the typedef to qemu/typedefs.h, and include that instead of
qapi/error.h.  Include qapi/error.h in .c files that need it and don't
get it now.  Include qapi-types.h in qom/object.h for uint16List.
Update scripts/clean-includes accordingly.  Update it further to match
reality: replace config.h by config-target.h, add sysemu/os-posix.h,
sysemu/os-win32.h.  Update the list of includes in the qemu/osdep.h
comment quoted above similarly.
This reduces the number of objects depending on qapi/error.h from "all
of them" to less than a third.  Unfortunately, the number depending on
qapi-types.h shrinks only a little.  More work is needed for that one.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
[Fix compilation without the spice devel packages. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
											
										 
											2016-03-14 09:01:28 +01:00
										 |  |  | #include "qapi/error.h"
 | 
					
						
							| 
									
										
										
										
											2019-05-23 16:35:07 +02:00
										 |  |  | #include "qemu/module.h"
 | 
					
						
							| 
									
										
										
										
											2017-05-08 17:57:35 -03:00
										 |  |  | #include "hw/audio/soundhw.h"
 | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  | #include "audio/audio.h"
 | 
					
						
							| 
									
										
										
										
											2019-08-12 07:23:42 +02:00
										 |  |  | #include "hw/irq.h"
 | 
					
						
							| 
									
										
										
										
											2013-02-05 17:06:20 +01:00
										 |  |  | #include "hw/isa/isa.h"
 | 
					
						
							| 
									
										
										
										
											2019-08-12 07:23:51 +02:00
										 |  |  | #include "hw/qdev-properties.h"
 | 
					
						
							| 
									
										
										
										
											2019-08-12 07:23:45 +02:00
										 |  |  | #include "migration/vmstate.h"
 | 
					
						
							| 
									
										
										
										
											2013-03-18 17:36:02 +01:00
										 |  |  | #include "gusemu.h"
 | 
					
						
							|  |  |  | #include "gustate.h"
 | 
					
						
							| 
									
										
										
										
											2020-09-03 16:43:22 -04:00
										 |  |  | #include "qom/object.h"
 | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define dolog(...) AUD_log ("audio", __VA_ARGS__)
 | 
					
						
							|  |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | #define ldebug(...) dolog (__VA_ARGS__)
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | #define ldebug(...)
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-06 16:02:26 +02:00
										 |  |  | #define TYPE_GUS "gus"
 | 
					
						
							| 
									
										
										
										
											2020-09-16 14:25:19 -04:00
										 |  |  | OBJECT_DECLARE_SIMPLE_TYPE(GUSState, GUS) | 
					
						
							| 
									
										
										
										
											2013-06-06 16:02:26 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-03 16:43:22 -04:00
										 |  |  | struct GUSState { | 
					
						
							| 
									
										
										
										
											2009-09-10 11:43:32 +02:00
										 |  |  |     ISADevice dev; | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  |     GUSEmuState emu; | 
					
						
							|  |  |  |     QEMUSoundCard card; | 
					
						
							| 
									
										
										
										
											2009-09-10 11:43:32 +02:00
										 |  |  |     uint32_t freq; | 
					
						
							|  |  |  |     uint32_t port; | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  |     int pos, left, shift, irqs; | 
					
						
							| 
									
										
										
										
											2017-04-26 00:37:32 +02:00
										 |  |  |     int16_t *mixbuf; | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  |     uint8_t himem[1024 * 1024 + 32 + 4096]; | 
					
						
							|  |  |  |     int samples; | 
					
						
							|  |  |  |     SWVoiceOut *voice; | 
					
						
							|  |  |  |     int64_t last_ticks; | 
					
						
							| 
									
										
										
										
											2009-09-10 11:43:32 +02:00
										 |  |  |     qemu_irq pic; | 
					
						
							| 
									
										
										
										
											2016-02-03 11:28:58 -05:00
										 |  |  |     IsaDma *isa_dma; | 
					
						
							| 
									
										
										
										
											2016-07-13 02:11:59 +02:00
										 |  |  |     PortioList portio_list1; | 
					
						
							|  |  |  |     PortioList portio_list2; | 
					
						
							| 
									
										
										
										
											2020-09-03 16:43:22 -04:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-07 22:02:54 +05:30
										 |  |  | static uint32_t gus_readb(void *opaque, uint32_t nport) | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     GUSState *s = opaque; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return gus_read (&s->emu, nport, 1); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-07 22:02:54 +05:30
										 |  |  | static void gus_writeb(void *opaque, uint32_t nport, uint32_t val) | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     GUSState *s = opaque; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     gus_write (&s->emu, nport, 1, val); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int write_audio (GUSState *s, int samples) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int net = 0; | 
					
						
							|  |  |  |     int pos = s->pos; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     while (samples) { | 
					
						
							|  |  |  |         int nbytes, wbytes, wsampl; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         nbytes = samples << s->shift; | 
					
						
							|  |  |  |         wbytes = AUD_write ( | 
					
						
							|  |  |  |             s->voice, | 
					
						
							|  |  |  |             s->mixbuf + (pos << (s->shift - 1)), | 
					
						
							|  |  |  |             nbytes | 
					
						
							|  |  |  |             ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (wbytes) { | 
					
						
							|  |  |  |             wsampl = wbytes >> s->shift; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             samples -= wsampl; | 
					
						
							|  |  |  |             pos = (pos + wsampl) % s->samples; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             net += wsampl; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else { | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return net; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void GUS_callback (void *opaque, int free) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int samples, to_play, net = 0; | 
					
						
							|  |  |  |     GUSState *s = opaque; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     samples = free >> s->shift; | 
					
						
							| 
									
										
										
										
											2019-08-19 01:06:54 +02:00
										 |  |  |     to_play = MIN (samples, s->left); | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     while (to_play) { | 
					
						
							|  |  |  |         int written = write_audio (s, to_play); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (!written) { | 
					
						
							|  |  |  |             goto reset; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         s->left -= written; | 
					
						
							|  |  |  |         to_play -= written; | 
					
						
							|  |  |  |         samples -= written; | 
					
						
							|  |  |  |         net += written; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-19 01:06:54 +02:00
										 |  |  |     samples = MIN (samples, s->samples); | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  |     if (samples) { | 
					
						
							|  |  |  |         gus_mixvoices (&s->emu, s->freq, samples, s->mixbuf); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         while (samples) { | 
					
						
							|  |  |  |             int written = write_audio (s, samples); | 
					
						
							|  |  |  |             if (!written) { | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             samples -= written; | 
					
						
							|  |  |  |             net += written; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     s->left = samples; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-18 08:16:03 +04:00
										 |  |  |  reset: | 
					
						
							| 
									
										
										
										
											2016-05-09 15:24:58 +02:00
										 |  |  |     gus_irqgen (&s->emu, (uint64_t)net * 1000000 / s->freq); | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int GUS_irqrequest (GUSEmuState *emu, int hwirq, int n) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     GUSState *s = emu->opaque; | 
					
						
							| 
									
										
										
										
											2009-09-10 11:43:32 +02:00
										 |  |  |     /* qemu_irq_lower (s->pic); */ | 
					
						
							|  |  |  |     qemu_irq_raise (s->pic); | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  |     s->irqs += n; | 
					
						
							|  |  |  |     ldebug ("irqrequest %d %d %d\n", hwirq, n, s->irqs); | 
					
						
							|  |  |  |     return n; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GUS_irqclear (GUSEmuState *emu, int hwirq) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     GUSState *s = emu->opaque; | 
					
						
							|  |  |  |     ldebug ("irqclear %d %d\n", hwirq, s->irqs); | 
					
						
							| 
									
										
										
										
											2009-09-10 11:43:32 +02:00
										 |  |  |     qemu_irq_lower (s->pic); | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  |     s->irqs -= 1; | 
					
						
							|  |  |  | #ifdef IRQ_STORM
 | 
					
						
							|  |  |  |     if (s->irqs > 0) { | 
					
						
							|  |  |  |         qemu_irq_raise (s->pic[hwirq]); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-03 11:28:58 -05:00
										 |  |  | void GUS_dmarequest (GUSEmuState *emu) | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-02-03 11:28:58 -05:00
										 |  |  |     GUSState *s = emu->opaque; | 
					
						
							|  |  |  |     IsaDmaClass *k = ISADMA_GET_CLASS(s->isa_dma); | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  |     ldebug ("dma request %d\n", der->gusdma); | 
					
						
							| 
									
										
										
										
											2016-02-03 11:28:58 -05:00
										 |  |  |     k->hold_DREQ(s->isa_dma, s->emu.gusdma); | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-11 00:14:28 +00:00
										 |  |  | static int GUS_read_DMA (void *opaque, int nchan, int dma_pos, int dma_len) | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     GUSState *s = opaque; | 
					
						
							| 
									
										
										
										
											2016-02-03 11:28:58 -05:00
										 |  |  |     IsaDmaClass *k = ISADMA_GET_CLASS(s->isa_dma); | 
					
						
							| 
									
										
										
										
											2008-06-08 01:42:47 +00:00
										 |  |  |     char tmpbuf[4096]; | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  |     int pos = dma_pos, mode, left = dma_len - dma_pos; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ldebug ("read DMA %#x %d\n", dma_pos, dma_len); | 
					
						
							| 
									
										
										
										
											2016-02-03 11:28:58 -05:00
										 |  |  |     mode = k->has_autoinitialization(s->isa_dma, s->emu.gusdma); | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  |     while (left) { | 
					
						
							| 
									
										
										
										
											2019-08-19 01:06:54 +02:00
										 |  |  |         int to_copy = MIN ((size_t) left, sizeof (tmpbuf)); | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  |         int copied; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ldebug ("left=%d to_copy=%d pos=%d\n", left, to_copy, pos); | 
					
						
							| 
									
										
										
										
											2016-02-03 11:28:58 -05:00
										 |  |  |         copied = k->read_memory(s->isa_dma, nchan, tmpbuf, pos, to_copy); | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  |         gus_dma_transferdata (&s->emu, tmpbuf, copied, left == copied); | 
					
						
							|  |  |  |         left -= copied; | 
					
						
							|  |  |  |         pos += copied; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-11 21:00:53 +08:00
										 |  |  |     if (((mode >> 4) & 1) == 0) { | 
					
						
							| 
									
										
										
										
											2016-02-03 11:28:58 -05:00
										 |  |  |         k->release_DREQ(s->isa_dma, s->emu.gusdma); | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |     return dma_len; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-02 11:49:38 +01:00
										 |  |  | static const VMStateDescription vmstate_gus = { | 
					
						
							|  |  |  |     .name = "gus", | 
					
						
							|  |  |  |     .version_id = 2, | 
					
						
							|  |  |  |     .minimum_version_id = 2, | 
					
						
							| 
									
										
										
										
											2014-04-16 15:32:32 +02:00
										 |  |  |     .fields = (VMStateField[]) { | 
					
						
							| 
									
										
										
										
											2012-02-07 22:11:04 +04:00
										 |  |  |         VMSTATE_INT32 (pos, GUSState), | 
					
						
							|  |  |  |         VMSTATE_INT32 (left, GUSState), | 
					
						
							|  |  |  |         VMSTATE_INT32 (shift, GUSState), | 
					
						
							|  |  |  |         VMSTATE_INT32 (irqs, GUSState), | 
					
						
							|  |  |  |         VMSTATE_INT32 (samples, GUSState), | 
					
						
							|  |  |  |         VMSTATE_INT64 (last_ticks, GUSState), | 
					
						
							|  |  |  |         VMSTATE_BUFFER (himem, GUSState), | 
					
						
							|  |  |  |         VMSTATE_END_OF_LIST () | 
					
						
							| 
									
										
										
										
											2009-12-02 11:49:38 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2008-06-21 17:14:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-15 15:25:26 -07:00
										 |  |  | static const MemoryRegionPortio gus_portio_list1[] = { | 
					
						
							|  |  |  |     {0x000,  1, 1, .write = gus_writeb }, | 
					
						
							|  |  |  |     {0x006, 10, 1, .read = gus_readb, .write = gus_writeb }, | 
					
						
							|  |  |  |     {0x100,  8, 1, .read = gus_readb, .write = gus_writeb }, | 
					
						
							| 
									
										
										
										
											2012-02-07 22:11:04 +04:00
										 |  |  |     PORTIO_END_OF_LIST (), | 
					
						
							| 
									
										
										
										
											2011-08-15 15:25:26 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static const MemoryRegionPortio gus_portio_list2[] = { | 
					
						
							| 
									
										
										
										
											2015-03-30 13:12:32 +02:00
										 |  |  |     {0, 2, 1, .read = gus_readb }, | 
					
						
							| 
									
										
										
										
											2012-02-07 22:11:04 +04:00
										 |  |  |     PORTIO_END_OF_LIST (), | 
					
						
							| 
									
										
										
										
											2011-08-15 15:25:26 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-25 02:37:14 +01:00
										 |  |  | static void gus_realizefn (DeviceState *dev, Error **errp) | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-11-25 02:37:14 +01:00
										 |  |  |     ISADevice *d = ISA_DEVICE(dev); | 
					
						
							| 
									
										
										
										
											2023-02-15 15:36:42 +01:00
										 |  |  |     ISABus *bus = isa_bus_from_device(d); | 
					
						
							| 
									
										
										
										
											2013-06-06 16:02:26 +02:00
										 |  |  |     GUSState *s = GUS (dev); | 
					
						
							| 
									
										
										
										
											2016-02-03 11:28:58 -05:00
										 |  |  |     IsaDmaClass *k; | 
					
						
							| 
									
										
										
										
											2008-12-03 22:48:44 +00:00
										 |  |  |     struct audsettings as; | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-15 15:36:42 +01:00
										 |  |  |     s->isa_dma = isa_bus_get_dma(bus, s->emu.gusdma); | 
					
						
							| 
									
										
										
										
											2018-03-16 10:51:31 +01:00
										 |  |  |     if (!s->isa_dma) { | 
					
						
							|  |  |  |         error_setg(errp, "ISA controller does not support DMA"); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-14 03:11:35 +04:00
										 |  |  |     AUD_register_card ("gus", &s->card); | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-10 11:43:32 +02:00
										 |  |  |     as.freq = s->freq; | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  |     as.nchannels = 2; | 
					
						
							| 
									
										
										
										
											2019-03-08 23:34:13 +01:00
										 |  |  |     as.fmt = AUDIO_FORMAT_S16; | 
					
						
							| 
									
										
										
										
											2020-05-05 12:07:50 +02:00
										 |  |  |     as.endianness = AUDIO_HOST_ENDIANNESS; | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     s->voice = AUD_open_out ( | 
					
						
							|  |  |  |         &s->card, | 
					
						
							|  |  |  |         NULL, | 
					
						
							|  |  |  |         "gus", | 
					
						
							|  |  |  |         s, | 
					
						
							|  |  |  |         GUS_callback, | 
					
						
							|  |  |  |         &as | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (!s->voice) { | 
					
						
							|  |  |  |         AUD_remove_card (&s->card); | 
					
						
							| 
									
										
										
										
											2012-11-25 02:37:14 +01:00
										 |  |  |         error_setg(errp, "No voice"); | 
					
						
							|  |  |  |         return; | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     s->shift = 2; | 
					
						
							|  |  |  |     s->samples = AUD_get_buffer_size_out (s->voice) >> s->shift; | 
					
						
							| 
									
										
										
										
											2011-08-20 22:09:37 -05:00
										 |  |  |     s->mixbuf = g_malloc0 (s->samples << s->shift); | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-13 02:11:59 +02:00
										 |  |  |     isa_register_portio_list(d, &s->portio_list1, s->port, | 
					
						
							|  |  |  |                              gus_portio_list1, s, "gus"); | 
					
						
							|  |  |  |     isa_register_portio_list(d, &s->portio_list2, (s->port + 0x100) & 0xf00, | 
					
						
							|  |  |  |                              gus_portio_list2, s, "gus"); | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-03 11:28:58 -05:00
										 |  |  |     k = ISADMA_GET_CLASS(s->isa_dma); | 
					
						
							|  |  |  |     k->register_channel(s->isa_dma, s->emu.gusdma, GUS_read_DMA, s); | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  |     s->emu.himemaddr = s->himem; | 
					
						
							|  |  |  |     s->emu.gusdatapos = s->emu.himemaddr + 1024 * 1024 + 32; | 
					
						
							|  |  |  |     s->emu.opaque = s; | 
					
						
							| 
									
										
										
										
											2023-02-15 15:36:42 +01:00
										 |  |  |     s->pic = isa_bus_get_irq(bus, s->emu.gusirq); | 
					
						
							| 
									
										
										
										
											2008-01-14 22:09:11 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     AUD_set_active_out (s->voice, 1); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-09-10 11:43:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-07 21:34:16 -06:00
										 |  |  | static Property gus_properties[] = { | 
					
						
							| 
									
										
										
										
											2019-08-19 01:06:49 +02:00
										 |  |  |     DEFINE_AUDIO_PROPERTIES(GUSState, card), | 
					
						
							| 
									
										
										
										
											2011-12-07 21:34:16 -06:00
										 |  |  |     DEFINE_PROP_UINT32 ("freq",    GUSState, freq,        44100), | 
					
						
							| 
									
										
										
										
											2014-02-08 11:01:53 +01:00
										 |  |  |     DEFINE_PROP_UINT32 ("iobase",  GUSState, port,        0x240), | 
					
						
							| 
									
										
										
										
											2011-12-07 21:34:16 -06:00
										 |  |  |     DEFINE_PROP_UINT32 ("irq",     GUSState, emu.gusirq,  7), | 
					
						
							|  |  |  |     DEFINE_PROP_UINT32 ("dma",     GUSState, emu.gusdma,  3), | 
					
						
							|  |  |  |     DEFINE_PROP_END_OF_LIST (), | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-07 22:11:04 +04:00
										 |  |  | static void gus_class_initfn (ObjectClass *klass, void *data) | 
					
						
							| 
									
										
										
										
											2011-12-04 11:52:49 -06:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-02-07 22:11:04 +04:00
										 |  |  |     DeviceClass *dc = DEVICE_CLASS (klass); | 
					
						
							| 
									
										
										
										
											2012-11-25 02:37:14 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     dc->realize = gus_realizefn; | 
					
						
							| 
									
										
										
										
											2013-07-29 17:17:45 +03:00
										 |  |  |     set_bit(DEVICE_CATEGORY_SOUND, dc->categories); | 
					
						
							| 
									
										
										
										
											2011-12-07 21:34:16 -06:00
										 |  |  |     dc->desc = "Gravis Ultrasound GF1"; | 
					
						
							|  |  |  |     dc->vmsd = &vmstate_gus; | 
					
						
							| 
									
										
										
										
											2020-01-10 19:30:32 +04:00
										 |  |  |     device_class_set_props(dc, gus_properties); | 
					
						
							| 
									
										
										
										
											2011-12-04 11:52:49 -06:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-10 16:19:07 +01:00
										 |  |  | static const TypeInfo gus_info = { | 
					
						
							| 
									
										
										
										
											2013-06-06 16:02:26 +02:00
										 |  |  |     .name          = TYPE_GUS, | 
					
						
							| 
									
										
										
										
											2011-12-07 21:34:16 -06:00
										 |  |  |     .parent        = TYPE_ISA_DEVICE, | 
					
						
							|  |  |  |     .instance_size = sizeof (GUSState), | 
					
						
							|  |  |  |     .class_init    = gus_class_initfn, | 
					
						
							| 
									
										
										
										
											2009-09-10 11:43:32 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-09 15:20:55 +01:00
										 |  |  | static void gus_register_types (void) | 
					
						
							| 
									
										
										
										
											2009-09-10 11:43:32 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-02-07 22:11:04 +04:00
										 |  |  |     type_register_static (&gus_info); | 
					
						
							| 
									
										
										
										
											2020-07-02 15:25:13 +02:00
										 |  |  |     deprecated_register_soundhw("gus", "Gravis Ultrasound GF1", 1, TYPE_GUS); | 
					
						
							| 
									
										
										
										
											2009-09-10 11:43:32 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2012-02-09 15:20:55 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | type_init (gus_register_types) |