/* $Id$ */
/** @file
* DevSB16 - VBox SB16 Audio Controller.
*
* @todo hiccups on NT4 and Win98.
*/
/*
* Copyright (C) 2015 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
* --------------------------------------------------------------------
*
* This code is based on: sb16.c from QEMU AUDIO subsystem (r3917).
* QEMU Soundblaster 16 emulation
*
* Copyright (c) 2003-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
* 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.
*/
#ifdef IN_RING3
#endif
#include "vl_vbox.h"
#ifdef LOG_GROUP
#endif
#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
# include "AudioMixer.h"
#else
extern "C" {
#include "audio.h"
}
#endif
#ifndef VBOX
#define LENOFA(a) ((int) (sizeof(a)/sizeof(a[0])))
#else /* VBOX */
/** Current saved state version. */
/** The version used in VirtualBox version 3.0 and earlier. This didn't include the config dump. */
#endif /* VBOX */
#ifndef VBOX
#else /* VBOX */
#endif /* VBOX */
#ifndef VBOX
static struct
{
int ver_lo;
int ver_hi;
int irq;
int dma;
int hdma;
int port;
#endif /* !VBOX */
#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
typedef struct SB16OUTPUTSTREAM
{
/** PCM output stream. */
/** Mixer handle for output stream. */
/**
* Struct for maintaining a host backend driver.
*/
typedef struct SB16DRIVER
{
union
{
/** Node for storing this driver in our device driver
* list of SB16STATE. */
struct
{
} dummy;
};
/** Pointer to SB16 controller (state). */
/** Driver flags. */
/** LUN # to which this driver has been assigned. */
/** Audio connector interface to the underlying
* host backend. */
/** Stream for output. */
#endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
typedef struct SB16STATE
{
#ifdef VBOX
/** Pointer to the device instance. */
/** Pointer to the connector of the attached audio driver. */
int irqCfg;
int dmaCfg;
int hdmaCfg;
int portCfg;
int verCfg;
#endif
int irq;
int dma;
int hdma;
int port;
int ver;
int in_index;
int out_data_len;
int fmt_stereo;
int fmt_signed;
int fmt_bits;
#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
#else
#endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
int dma_auto;
int block_size;
int fifo;
int freq;
int time_const;
int speaker;
int needed_bytes;
int cmd;
int use_hdma;
int highspeed;
int v2x6;
int csp_reg83r;
int csp_reg83w;
int nzero;
int dma_running;
int bytes_per_second;
int align;
#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
/** The device' software mixer. */
/** Audio sink for PCM output. */
/** The emulation timer for handling I/O of the attached LUN drivers. */
/** Timer ticks for handling the LUN drivers. */
#else
#endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
/** LUN\#0: Base interface. */
/* mixer state */
int mixer_nreg;
#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
#endif
#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
/**
* Attach command.
*
* This is called to let the device attach to a driver for a specified LUN
* during runtime. This is not called during VM construction, the device
* constructor have to attach to all the available drivers.
*
* @returns VBox status code.
* @param pDevIns The device instance.
* @param uLUN The logical unit which is being detached.
* @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
*/
{
("AC'97 device does not support hotplugging\n"),
/*
* Attach driver.
*/
("Not enough memory for SB16 driver port description of LUN #%u\n", uLUN),
if (RT_SUCCESS(rc))
{
if (pDrv)
{
("Configuration error: LUN #%u has no host audio interface, rc=%Rrc\n",
/*
* For now we always set the driver at LUN 0 as our primary
* host backend. This might change in the future.
*/
/* Attach to driver list. */
}
else
rc = VERR_NO_MEMORY;
}
else if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
{
}
else if (RT_FAILURE(rc))
AssertMsgFailed(("Failed to attach SB16 LUN #%u (\"%s\"), rc=%Rrc\n",
return rc;
}
#endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
#else
#endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
{
switch (irq)
{
case 5:
return 2;
case 7:
return 4;
case 9:
return 1;
case 10:
return 8;
default:
break;
}
return 2;
}
{
switch (magic)
{
case 1:
return 9;
case 2:
return 5;
case 4:
return 7;
case 8:
return 10;
default:
break;
}
return -1;
}
#ifdef DEBUG
{
LogFlowFunc(("%s:%s:%d:%s:dmasize=%d:freq=%d:const=%d:speaker=%d\n",
}
#endif
{
/* AUD_enable (pThis->voice, on); */
}
{
#ifndef VBOX
if (hold)
{
}
else
{
}
#else /* VBOX */
# ifdef VBOX_WITH_PDM_AUDIO_DRIVER
# endif
if (hold)
{
# ifdef VBOX_WITH_PDM_AUDIO_DRIVER
# else
# endif
}
else
{
# ifdef VBOX_WITH_PDM_AUDIO_DRIVER
# else
# endif
}
#endif /* VBOX */
}
#ifndef VBOX
{
}
#else /* VBOX */
{
}
#endif /* VBOX */
{
{
#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
#else
pThis->audio_free = 0;
streamCfg.endianness = 0;
"sb16",
);
#endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
}
}
{
pThis->fmt_signed = 0;
{
}
else
{
}
if (dma_len != -1)
{
}
else
{
and SecondReality/FC work
r=andy Wow, actually someone who remembers Future Crew :-)
Act1 sets block size via command 0x48 and it's an odd number
SR does the same with even number
Both use stereo, and Creatives own documentation states that
0x48 sets block size in bytes less one.. go figure */
}
/* pThis->highspeed = (mask & DMA8_HIGH) != 0; */
LogFlowFunc(("warning: misaligned block size %d, alignment %d\n",
LogFlowFunc(("freq %d, stereo %d, sign %d, bits %d, dma %d, auto %d, fifo %d, high %d\n",
}
{
switch (cmd >> 4)
{
case 11:
break;
case 12:
break;
}
{
#if 1
#else
/* pThis->freq = 1000000 / ((255 - pThis->time_const) << pThis->fmt_stereo); */
#endif
}
{
/*
* It is clear that for DOOM and auto-init this value
* shouldn't take stereo into account, while Miles Sound Systems
* setsound.exe with single transfer mode wouldn't work without it
* wonders of SB16 yet again.
*/
}
LogFlowFunc(("freq %d, stereo %d, sign %d, bits %d, dma %d, auto %d, fifo %d, high %d\n",
else
{
LogFlowFunc(("warning: misaligned block size %d, alignment %d\n",
}
{
#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
#else
pThis->audio_free = 0;
streamCfg.endianness = 0;
"sb16",
);
#endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
}
}
{
}
}
{
}
else {
LogFlowFunc(("buffer underflow\n"));
return 0;
}
}
{
{
switch (cmd >> 4)
{
case 11:
case 12:
break;
default:
}
}
else
{
pThis->needed_bytes = 0;
switch (cmd)
{
case 0x03:
goto warn;
case 0x04:
goto warn;
case 0x05:
goto warn;
case 0x08:
/* __asm__ ("int3"); */
goto warn;
case 0x0e:
goto warn;
case 0x09:
goto warn;
case 0x0f:
goto warn;
case 0x10:
goto warn;
case 0x14:
pThis->block_size = 0;
break;
case 0x1c: /* Auto-Initialize DMA DAC, 8-bit */
break;
goto warn;
case 0x35:
LogFlowFunc(("0x35 - MIDI command not implemented\n"));
break;
case 0x40:
break;
case 0x41:
break;
case 0x42:
goto warn;
case 0x45:
goto warn;
case 0x47: /* Continue Auto-Initialize DMA 16bit */
break;
case 0x48:
break;
case 0x74:
LogFlowFunc(("0x75 - DMA DAC, 4-bit ADPCM not implemented\n"));
break;
case 0x75: /* DMA DAC, 4-bit ADPCM Reference */
LogFlowFunc(("0x74 - DMA DAC, 4-bit ADPCM Reference not implemented\n"));
break;
case 0x76: /* DMA DAC, 2.6-bit ADPCM */
LogFlowFunc(("0x74 - DMA DAC, 2.6-bit ADPCM not implemented\n"));
break;
case 0x77: /* DMA DAC, 2.6-bit ADPCM Reference */
LogFlowFunc(("0x74 - DMA DAC, 2.6-bit ADPCM Reference not implemented\n"));
break;
case 0x7d:
LogFlowFunc(("0x7d - Autio-Initialize DMA DAC, 4-bit ADPCM Reference\n"));
LogFlowFunc(("not implemented\n"));
break;
case 0x7f:
LogFlowFunc(("0x7d - Autio-Initialize DMA DAC, 2.6-bit ADPCM Reference\n"));
LogFlowFunc(("not implemented\n"));
break;
case 0x80:
break;
case 0x90:
case 0x91:
break;
case 0xd0: /* halt DMA operation. 8bit */
sb16Control(pThis, 0);
break;
case 0xd1: /* speaker on */
break;
case 0xd3: /* speaker off */
sb16SpeakerControl(pThis, 0);
break;
case 0xd4: /* continue DMA operation. 8bit */
/* KQ6 (or maybe Sierras audblst.drv in general) resets
break;
case 0xd5: /* halt DMA operation. 16bit */
sb16Control(pThis, 0);
break;
case 0xd6: /* continue DMA operation. 16bit */
break;
case 0xd9: /* exit auto-init DMA after this block. 16bit */
break;
case 0xda: /* exit auto-init DMA after this block. 8bit */
break;
case 0xe0: /* DSP identification */
break;
case 0xe1:
break;
case 0xe2:
goto warn;
case 0xe3:
{
for (int i = sizeof (e3) - 1; i >= 0; --i)
break;
}
case 0xe4: /* write test reg */
break;
case 0xe7:
LogFlowFunc(("Attempt to probe for ESS (0xe7)?\n"));
break;
case 0xe8: /* read test reg */
break;
case 0xf2:
case 0xf3:
#ifndef VBOX
#else
#endif
break;
case 0xf8:
/* Undocumented, used by old Creative diagnostic programs. */
dsp_out_data (pThis, 0);
goto warn;
case 0xf9:
goto warn;
case 0xfa:
dsp_out_data (pThis, 0);
goto warn;
case 0xfc: /* FIXME */
dsp_out_data (pThis, 0);
goto warn;
default:
break;
}
}
if (!pThis->needed_bytes)
LogFlow(("\n"));
exit:
if (!pThis->needed_bytes)
else
return;
warn:
LogFlowFunc(("warning: command %#x,%d is not truly understood yet\n",
goto exit;
}
{
}
{
}
{
LogFlowFunc(("complete command %#x, in_index %d, needed_bytes %d\n",
{
else
{
}
}
else
{
{
case 0x04:
pThis->csp_reg83r = 0;
pThis->csp_reg83w = 0;
break;
case 0x05:
LogFlowFunc(("CSP command 0x05: param=%#x value=%#x\n",
break;
case 0x0e:
{
if (d1 == 0x83)
{
}
else
break;
}
case 0x0f:
LogFlowFunc(("read CSP register %#x -> %#x, mode=%#x\n", d0, pThis->csp_regs[d0], pThis->csp_mode));
if (d0 == 0x83)
{
LogFlowFunc(("0x83[%d] -> %#x\n",
}
else
break;
case 0x10:
break;
case 0x14:
break;
case 0x40:
break;
case 0x42: /* FT2 sets output freq with this, go figure */
#if 0
LogFlowFunc(("cmd 0x42 might not do what it think it should\n"));
#endif
case 0x41:
break;
case 0x48:
break;
case 0x74:
case 0x75:
case 0x76:
case 0x77:
/* ADPCM stuff, ignore */
break;
case 0x80:
{
#ifndef VBOX
}
else {
);
}
}
#else /* VBOX */
else
#endif /* VBOX */
break;
}
case 0xe0:
pThis->out_data_len = 0;
break;
case 0xe2:
break;
case 0xe4:
break;
case 0xf9:
switch (d0) {
case 0x0e:
break;
case 0x0f:
break;
case 0x37:
break;
default:
break;
}
break;
default:
return;
}
}
LogFlow(("\n"));
return;
}
{
pThis->fmt_signed = 0;
pThis->fmt_stereo = 0;
#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
#else
streamCfg.endianness = 0;
"sb16",
);
#endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
/* Not sure about that... */
/* AUD_set_active_out (pThis->voice, 1); */
}
{
#ifndef VBOX
}
#else /* VBOX */
{
}
#endif /* VBOX */
pThis->out_data_len = 0;
pThis->left_till_irq = 0;
pThis->needed_bytes = 0;
sb16SpeakerControl(pThis, 0);
sb16Control(pThis, 0);
}
{
switch (iport)
{
case 0x06:
switch (val)
{
case 0x00:
{
{
{
#ifndef VBOX
#else
#endif
sb16Control(pThis, 0);
}
else
}
break;
}
case 0x01:
case 0x03: /* FreeBSD kludge */
break;
case 0xc6:
break;
case 0xb8: /* Panic */
break;
case 0x39:
break;
default:
break;
}
break;
case 0x0c: /* Write data or command | write status */
#if 0
break;
#endif
if (0 == pThis->needed_bytes)
{
#if 0
if (0 == pThis->needed_bytes) {
}
#endif
}
else
{
{
LogFlowFunc(("in data overrun\n"));
}
else
{
{
pThis->needed_bytes = 0;
#if 0
#endif
}
}
}
break;
default:
break;
}
#ifdef VBOX
return VINF_SUCCESS;
#endif
}
{
#ifdef VBOX
/** @todo reject non-byte access?
* The spec does not mention a non-byte access so we should check how real hardware behaves. */
#endif
switch (iport)
{
case 0x06: /* reset */
retval = 0xff;
break;
case 0x0a: /* read data */
if (pThis->out_data_len)
{
}
else
{
/* goto error; */
}
break;
case 0x0c: /* 0 can write */
break;
case 0x0d: /* timer interrupt clear */
/* LogFlowFunc(("timer interrupt clear\n")); */
retval = 0;
break;
case 0x0e: /* data available status | irq 8 ack */
{
ack = 1;
#ifndef VBOX
#else
#endif
}
break;
case 0x0f: /* irq 16 ack */
retval = 0xff;
{
ack = 1;
#ifndef VBOX
#else
#endif
}
break;
default:
goto error;
}
if (!ack)
#ifndef VBOX
return retval;
#else
return VINF_SUCCESS;
#endif
#ifndef VBOX
return 0xff;
#else
return VERR_IOM_IOPORT_UNUSED;
#endif
}
{
#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
{
}
#endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
/* d5=input filt, d3=lowpass filt, d1,d2=input source */
/* d5=output filt, d1=stereo switch */
/* voice volume L d5,d7, R d1,d3 */
/* master ... */
/* MIDI ... */
for (int i = 0x30; i < 0x48; i++)
#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
if (RT_SUCCESS(rc2))
{
/* Set a default audio format for our mixer. */
/* Add all required audio sinks. */
}
#endif
}
{
(void) nport;
#ifdef VBOX
return VINF_SUCCESS;
#endif
}
#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
{
u = ((u&0x55555555) + ((u>>1)&0x55555555));
u = ((u&0x33333333) + ((u>>2)&0x33333333));
u = ((u&0x0f0f0f0f) + ((u>>4)&0x0f0f0f0f));
u = ((u&0x00ff00ff) + ((u>>8)&0x00ff00ff));
u = ( u&0x0000ffff) + (u>>16);
return u;
}
{
}
#endif
{
bool fUpdateMaster = false;
bool fUpdateStream = false;
(void) nport;
switch (pThis->mixer_nreg)
{
case 0x00:
/* And update the actual volume, too. */
fUpdateMaster = true;
fUpdateStream = true;
break;
case 0x04:
/* Translate from old style stream volume (L/R). */
fUpdateStream = true;
break;
case 0x22:
/* Translate from old style master volume (L/R). */
fUpdateMaster = true;
break;
case 0x30:
/* Translate to old style master volume (L). */
fUpdateMaster = true;
break;
case 0x31:
/* Translate to old style master volume (R). */
fUpdateMaster = true;
break;
case 0x32:
/* Translate to old style stream volume (L). */
fUpdateStream = true;
break;
case 0x33:
/* Translate to old style stream volume (R). */
fUpdateStream = true;
break;
case 0x80:
{
if (irq > 0)
break;
}
case 0x81:
{
LogFlow(("SB16: attempt to change DMA 8bit %d(%d), 16bit %d(%d) (val=%#x)\n",
#if 0
#endif
break;
}
case 0x82:
#ifdef VBOX
return VINF_SUCCESS;
#endif
default:
break;
}
#ifdef VBOX
/* Update the master (mixer) volume. */
if (fUpdateMaster)
{
#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
#else
#endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
}
/* Update the stream (PCM) volume. */
if (fUpdateStream)
{
#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
#else
#endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
}
#endif /* VBOX */
#ifdef VBOX
return VINF_SUCCESS;
#endif
}
{
#ifndef VBOX
#else /* VBOX */
switch (cb)
{
case 1:
switch (iport)
{
case 4:
break;
case 5:
break;
}
break;
case 2:
break;
default:
break;
}
return VINF_SUCCESS;
#endif /* VBOX */
}
{
(void) nport;
#ifndef DEBUG_SB16_MOST
LogFlowFunc(("mixer_read[%#x] -> %#x\n",
}
#else
LogFlowFunc(("mixer_read[%#x] -> %#x\n",
#endif
#ifndef VBOX
#else
return VINF_SUCCESS;
#endif
}
{
while (cbToWrite)
{
#ifndef VBOX
int cbRead;
#else
#endif
#ifndef VBOX
#else
#endif
#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
/* Just multiplex the output to the connected backends.
* No need to utilize the virtual mixer here (yet). */
{
if (RT_FAILURE(rc2))
continue;
LogFlowFunc(("\tLUN#%RU8: cbWritten=%RU32, cWrittenMin=%RU32\n", pDrv->uLUN, cbWritten, cbWrittenMin));
}
#else
#endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
if (!cbRead || !cbWrittenMin)
break;
}
return cbWrittenTotal;
}
#ifndef VBOX
#else
static DECLCALLBACK(uint32_t) sb16DMARead(PPDMDEVINS pDevIns, void *opaque, unsigned nchan, uint32_t dma_pos, uint32_t dma_len)
#endif
{
if (pThis->block_size <= 0)
{
LogFlowFunc(("invalid block size=%d nchan=%d dma_pos=%d dma_len=%d\n",
return dma_pos;
}
if (pThis->left_till_irq < 0)
#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
{
if (RT_SUCCESS(rc2))
}
if (cbOutMin == UINT32_MAX)
{
}
else
{
return dma_pos;
}
#else
{
return dma_pos;
}
else
#endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
#ifdef DEBUG_SB16_MOST
#endif
{
{
}
else
{
}
}
if (pThis->left_till_irq <= 0)
{
#ifndef VBOX
#else
#endif
{
sb16Control(pThis, 0);
sb16SpeakerControl(pThis, 0);
}
}
#ifdef DEBUG_SB16_MOST
LogFlowFunc(("pos %5d free %5d size %5d till % 5d copy %5d written %5d size %5d\n",
pThis->block_size));
#endif
while (pThis->left_till_irq <= 0)
return dma_pos;
}
#ifndef VBOX_WITH_PDM_AUDIO_DRIVER
{
#ifdef VBOX
/* New space available, see if we can transfer more. There is no cyclic DMA timer in VBox. */
#endif
}
#else
{
{
if (RT_SUCCESS(rc))
{
if (cSamplesLive)
{
if (RT_SUCCESS(rc2))
LogFlowFunc(("LUN#%RU8: cSamplesLive=%RU32, cSamplesPlayed=%RU32\n",
if (cSamplesPlayed)
{
if (RT_SUCCESS(rc))
}
}
}
}
if (cbOutMin == UINT32_MAX)
cbOutMin = 0;
/*
* Playback.
*/
if (cbOutMin)
{
/* New space available, see if we can transfer more. */
}
/*
* Recording.
*/
/** @todo Implement recording. */
}
#endif /* !VBOX_WITH_PDM_AUDIO_DRIVER */
{
#ifndef VBOX
#else
#endif
}
{
#ifndef VBOX
if (version_id != 1) {
return -EINVAL;
}
#else
#endif
#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
{
{
}
}
#else
#endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
if (pThis->dma_running)
{
{
#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
#else
pThis->audio_free = 0;
as.endianness = 0;
"sb16",
&as
);
#endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
}
}
#ifdef VBOX
return VINF_SUCCESS;
#endif
}
#ifndef VBOX
{
int i;
if (!audio) {
LogFlowFunc(("No audio state\n"));
return -1;
}
s = qemu_mallocz (sizeof (*s));
if (!s) {
LogFlowFunc(("Could not allocate memory for SB16 (%zu bytes)\n",
sizeof (*s));
return -1;
}
LogFlowFunc(("warning: Could not create auxiliary timer\n"));
}
for (i = 0; i < LENOFA (dsp_write_ports); i++) {
}
for (i = 0; i < LENOFA (dsp_read_ports); i++) {
}
return 0;
}
#else /* VBOX */
{
return VINF_SSM_DONT_CALL_AGAIN;
}
{
return VINF_SUCCESS;
}
static DECLCALLBACK(int) sb16LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
{
("%u\n", uVersion),
{
{
}
}
if (uPass != SSM_PASS_FINAL)
return VINF_SUCCESS;
return VINF_SUCCESS;
}
#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
{
int rc = VINF_SUCCESS;
char *pszDesc;
{
{
rc = VERR_NO_MEMORY;
break;
}
{
0 /* uFlags */,
}
if (RT_FAILURE(rc2))
{
if (RT_SUCCESS(rc))
break;
}
uLUN++;
}
return rc;
}
#endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
/**
* @interface_method_impl{PDMIBASE,pfnQueryInterface}
*/
{
return NULL;
}
/**
* @interface_method_impl{PDMDEVREG,pfnDestruct}
*/
{
#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
{
}
#endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
return VINF_SUCCESS;
}
{
int rc;
/*
* Validations.
*/
"IRQ\0"
"DMA\0"
"DMA16\0"
"Port\0"
"Version\0"))
N_("Invalid configuration for sb16 device"));
/*
* Read config data.
*/
if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"IRQ\" value"));
if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"DMA\" value"));
if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"DMA16\" value"));
if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"Port\" value"));
if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"Version\" value"));
/*
* Init instance data.
*/
#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
#endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
/*
* Create timer(s), register & attach stuff.
*/
if (RT_FAILURE(rc))
if (RT_FAILURE(rc))
return rc;
if (RT_FAILURE(rc))
return rc;
if (RT_FAILURE(rc))
return rc;
if (RT_FAILURE(rc))
return rc;
rc = PDMDevHlpSSMRegister3(pDevIns, SB16_SAVE_STATE_VERSION, sizeof(SB16STATE), sb16LiveExec, sb16SaveExec, sb16LoadExec);
if (RT_FAILURE(rc))
return rc;
/*
* Attach driver.
*/
#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
{
if (RT_FAILURE(rc))
{
if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
rc = VINF_SUCCESS;
break;
}
uLUN++;
}
#else
if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
LogFunc(("SB16: No attached driver!\n"));
else if (RT_FAILURE(rc))
{
return rc;
}
#endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
uLUN = 0;
{
if (fIsOK)
{
}
if (!fIsOK)
{
/*
* Only primary drivers are critical for the VM to run. Everything else
* might not worth showing an own error message box in the GUI.
*/
continue;
N_("No audio devices could be opened. Selecting the NULL audio backend "
"with the consequence that no sound is audible"));
}
uLUN++;
}
if (RT_SUCCESS(rc))
{
if (RT_FAILURE(rc))
else
{
pThis->uTicksIO = PDMDevHlpTMTimeVirtGetFreq(pDevIns) / 200; /** Hz. @todo Make this configurable! */
/* Fire off timer. */
}
}
#else
{
LogRel (("SB16: WARNING: Unable to open PCM OUT!\n"));
N_("No audio devices could be opened. Selecting the NULL audio backend "
"with the consequence that no sound is audible"));
}
#endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
return VINF_SUCCESS;
}
const PDMDEVREG g_DeviceSB16 =
{
/* u32Version */
/* szName */
"sb16",
/* szRCMod */
"",
/* szR0Mod */
"",
/* pszDescription */
"Sound Blaster 16 Controller",
/* fFlags */
/* fClass */
/* cMaxInstances */
1,
/* cbInstance */
sizeof(SB16STATE),
/* pfnConstruct */
/* pfnDestruct */
/* pfnRelocate */
NULL,
/* pfnMemSetup */
NULL,
/* pfnPowerOn */
NULL,
/* pfnReset */
NULL,
/* pfnSuspend */
NULL,
/* pfnResume */
NULL,
/* pfnAttach */
NULL,
/* pfnDetach */
NULL,
/* pfnQueryInterface */
NULL,
/* pfnInitComplete */
NULL,
/* pfnPowerOff */
NULL,
/* pfnSoftReset */
NULL,
/* u32VersionEnd */
};
#endif /* VBOX */