PUBLIC int drv_init_hw(void) {
int i;
int DspVersion[2];
- dprint("drv_init_hw():\n");
+ Dprint(("drv_init_hw():\n"));
if(drv_reset () != OK) {
- dprint("sb16: No SoundBlaster card detected\n");
+ Dprint(("sb16: No SoundBlaster card detected\n"));
return -1;
}
}
if(DspVersion[0] < 4) {
- dprint("sb16: No SoundBlaster 16 compatible card detected\n");
+ Dprint(("sb16: No SoundBlaster 16 compatible card detected\n"));
return -1;
}
- dprint("sb16: SoundBlaster DSP version %d.%d detected!\n", DspVersion[0], DspVersion[1]);
+ Dprint(("sb16: SoundBlaster DSP version %d.%d detected!\n", DspVersion[0], DspVersion[1]));
/* set SB to use our IRQ and DMA channels */
mixer_set(MIXER_SET_IRQ, (1 << (SB_IRQ / 2 - 1)));
PUBLIC int drv_reset(void) {
int i;
- dprint("drv_reset():\n");
+ Dprint(("drv_reset():\n"));
sb16_outb(DSP_RESET, 1);
for(i = 0; i < 1000; i++); /* wait a while */
PUBLIC int drv_start(int channel, int DmaMode) {
- dprint("drv_start():\n");
+ Dprint(("drv_start():\n"));
drv_reset();
PUBLIC int drv_stop(int sub_dev) {
if(running) {
- dprint("drv_stop():\n");
+ Dprint(("drv_stop():\n"));
dsp_command((DspBits == 8 ? DSP_CMD_DMA8HALT : DSP_CMD_DMA16HALT));
running = FALSE;
drv_reenable_int(sub_dev);
PUBLIC int drv_set_dma(u32_t dma, u32_t length, int chan) {
- dprint("drv_set_dma():\n");
+ Dprint(("drv_set_dma():\n"));
DmaPhys = dma;
return OK;
}
PUBLIC int drv_reenable_int(int chan) {
- dprint("drv_reenable_int()\n");
+ Dprint(("drv_reenable_int()\n"));
sb16_inb((DspBits == 8 ? DSP_DATA_AVL : DSP_DATA16_AVL));
return OK;
}
PUBLIC int drv_io_ctl(int request, void *val, int *len, int sub_dev) {
- dprint("dsp_ioctl: got ioctl %d, argument: %d sub_dev: %d\n", request, val, sub_dev);
+ Dprint(("dsp_ioctl: got ioctl %d, argument: %d sub_dev: %d\n", request, val, sub_dev));
if(sub_dev == AUDIO) {
return dsp_ioctl(request, val, len);
PUBLIC int drv_get_irq(char *irq) {
- dprint("drv_get_irq():\n");
+ Dprint(("drv_get_irq():\n"));
*irq = SB_IRQ;
return OK;
}
PUBLIC int drv_get_frag_size(u32_t *frag_size, int sub_dev) {
- dprint("drv_get_frag_size():\n");
+ Dprint(("drv_get_frag_size():\n"));
*frag_size = DspFragmentSize;
return OK;
}
PRIVATE void dsp_dma_setup(phys_bytes address, int count, int DmaMode) {
pvb_pair_t pvb[9];
- dprint("Setting up %d bit DMA\n", DspBits);
+ Dprint(("Setting up %d bit DMA\n", DspBits));
if(DspBits == 8) { /* 8 bit sound */
count--;
PRIVATE int dsp_set_size(unsigned int size) {
- dprint("dsp_set_size(): set fragment size to %u\n", size);
+ Dprint(("dsp_set_size(): set fragment size to %u\n", size));
/* Sanity checks */
if(size < sub_dev[AUDIO].MinFragmentSize || size > sub_dev[AUDIO].DmaSize / sub_dev[AUDIO].NrOfDmaFragments || size % 2 != 0) {
PRIVATE int dsp_set_speed(unsigned int speed) {
- dprint("sb16: setting speed to %u, stereo = %d\n", speed, DspStereo);
+ Dprint(("sb16: setting speed to %u, stereo = %d\n", speed, DspStereo));
if(speed < DSP_MIN_SPEED || speed > DSP_MAX_SPEED) {
return EPERM;
PRIVATE int dsp_set_sign(unsigned int sign) {
- dprint("sb16: set sign to %u\n", sign);
+ Dprint(("sb16: set sign to %u\n", sign));
DspSign = (sign > 0 ? 1 : 0);
}
}
- dprint("sb16: SoundBlaster: DSP Command(%x) timeout\n", value);
+ Dprint(("sb16: SoundBlaster: DSP Command(%x) timeout\n", value));
return -1;
}
msg_hardware();
break;
default:
- dprint("%s: %d uncaught notify!\n",
+ printf("%s: %d uncaught notify!\n",
drv.DriverName, mess.m_type);
}
send(caller, &repl_mess);
continue;
default:
- dprint("%s: %d uncaught msg!\n",
+ printf("%s: %d uncaught msg!\n",
drv.DriverName, mess.m_type);
continue;
}
/* initialize hardware*/
if (drv_init_hw() != OK) {
- error("%s: Could not initialize hardware\n", drv.DriverName);
+ printf("%s: Could not initialize hardware\n", drv.DriverName);
return EIO;
}
/* get irq from device driver...*/
if (drv_get_irq(&irq) != OK) {
- error("%s: init driver couldn't get IRQ", drv.DriverName);
+ printf("%s: init driver couldn't get IRQ", drv.DriverName);
return EIO;
}
/* TODO: execute the rest of this function only once
/* ...and register interrupt vector */
if ((i=sys_irqsetpolicy(irq, 0, &irq_hook_id )) != OK){
- error("%s: init driver couldn't set IRQ policy: %d", drv.DriverName, i);
+ printf("%s: init driver couldn't set IRQ policy: %d", drv.DriverName, i);
return EIO;
}
irq_hook_set = TRUE; /* now signal handler knows it must unregister policy*/
}
if (irq_hook_set) {
if (sys_irqdisable(&irq_hook_id) != OK) {
- error("Could not disable IRQ\n");
+ printf("Could not disable IRQ\n");
}
/* get irq from device driver*/
if (drv_get_irq(&irq) != OK) {
- error("Msg SIG_STOP Couldn't get IRQ");
+ printf("Msg SIG_STOP Couldn't get IRQ");
}
/* remove the policy */
if (sys_irqrmpolicy(&irq_hook_id) != OK) {
- error("%s: Could not disable IRQ\n",drv.DriverName);
+ printf("%s: Could not disable IRQ\n",drv.DriverName);
}
}
}
int r, read_chan, write_chan, io_ctl;
special_file_t* special_file_ptr;
- dprint("%s: msg_open() special file %d\n", drv.DriverName, minor_dev_nr);
-
special_file_ptr = get_special_file(minor_dev_nr);
if(special_file_ptr == NULL) {
return EIO;
io_ctl = special_file_ptr->io_ctl;
if (read_chan==NO_CHANNEL && write_chan==NO_CHANNEL && io_ctl==NO_CHANNEL) {
- error("%s: No channel specified for minor device %d!\n",
+ printf("%s: No channel specified for minor device %d!\n",
drv.DriverName, minor_dev_nr);
return EIO;
}
if (read_chan == write_chan && read_chan != NO_CHANNEL) {
- error("%s: Read and write channels are equal: %d!\n",
+ printf("%s: Read and write channels are equal: %d!\n",
drv.DriverName, minor_dev_nr);
return EIO;
}
/* init driver */
if (!device_available) {
if (init_driver() != OK) {
- error("%s: Couldn't init driver!\n", drv.DriverName);
+ printf("%s: Couldn't init driver!\n", drv.DriverName);
return EIO;
} else {
device_available = TRUE;
/* Only one open at a time per sub device */
if (sub_dev_ptr->Opened) {
- error("%s: Sub device %d is already opened\n",
+ printf("%s: Sub device %d is already opened\n",
drv.DriverName, sub_dev_nr);
return EBUSY;
}
if (sub_dev_ptr->DmaBusy) {
- error("%s: Sub device %d is still busy\n", drv.DriverName, sub_dev_nr);
+ printf("%s: Sub device %d is still busy\n", drv.DriverName, sub_dev_nr);
return EBUSY;
}
/* Setup variables */
int r, read_chan, write_chan, io_ctl;
special_file_t* special_file_ptr;
- dprint("%s: msg_close() minor device %d\n", drv.DriverName, minor_dev_nr);
-
special_file_ptr = get_special_file(minor_dev_nr);
if(special_file_ptr == NULL) {
return EIO;
sub_dev_t *sub_dev_ptr;
special_file_t* special_file_ptr;
- dprint("%s: msg_ioctl() device %d\n", drv.DriverName, m_ptr->DEVICE);
-
special_file_ptr = get_special_file(m_ptr->DEVICE);
if(special_file_ptr == NULL) {
return EIO;
chan = special_file_ptr->io_ctl;
if (chan == NO_CHANNEL) {
- error("%s: No io control channel specified!\n", drv.DriverName);
+ printf("%s: No io control channel specified!\n", drv.DriverName);
return EIO;
}
/* get pointer to sub device data */
sub_dev_ptr = &sub_dev[chan];
if(!sub_dev_ptr->Opened) {
- error("%s: io control impossible - not opened!\n", drv.DriverName);
+ printf("%s: io control impossible - not opened!\n", drv.DriverName);
return EIO;
}
int chan; sub_dev_t *sub_dev_ptr;
special_file_t* special_file_ptr;
- dprint("%s: msg_write() device %d\n", drv.DriverName, m_ptr->DEVICE);
-
special_file_ptr = get_special_file(m_ptr->DEVICE);
chan = special_file_ptr->write_chan;
if (chan == NO_CHANNEL) {
- error("%s: No write channel specified!\n", drv.DriverName);
+ printf("%s: No write channel specified!\n", drv.DriverName);
reply(DEV_REVIVE, m_ptr->m_source, m_ptr->USER_ENDPT, EIO);
return;
}
if (!sub_dev_ptr->DmaBusy) { /* get fragment size on first write */
if (drv_get_frag_size(&(sub_dev_ptr->FragSize), sub_dev_ptr->Nr) != OK){
- error("%s; Failed to get fragment size!\n", drv.DriverName);
+ printf("%s; Failed to get fragment size!\n", drv.DriverName);
return;
}
}
if(m_ptr->COUNT != sub_dev_ptr->FragSize) {
- error("Fragment size does not match user's buffer length\n");
+ printf("Fragment size does not match user's buffer length\n");
reply(DEV_REVIVE, m_ptr->m_source, m_ptr->USER_ENDPT, EINVAL);
return;
}
/* if we are busy with something else than writing, return EBUSY */
if(sub_dev_ptr->DmaBusy && sub_dev_ptr->DmaMode != DEV_WRITE_S) {
- error("Already busy with something else then writing\n");
+ printf("Already busy with something else then writing\n");
reply(DEV_REVIVE, m_ptr->m_source, m_ptr->USER_ENDPT, EBUSY);
return;
}
data_from_user(sub_dev_ptr);
if(!sub_dev_ptr->DmaBusy) { /* Dma tranfer not yet started */
- dprint("starting audio device\n");
get_started(sub_dev_ptr);
sub_dev_ptr->DmaMode = DEV_WRITE_S; /* Dma mode is writing */
}
int chan; sub_dev_t *sub_dev_ptr;
special_file_t* special_file_ptr;
- dprint("%s: msg_read() device %d\n", drv.DriverName, m_ptr->DEVICE);
-
special_file_ptr = get_special_file(m_ptr->DEVICE);
chan = special_file_ptr->read_chan;
if (chan == NO_CHANNEL) {
- error("%s: No read channel specified!\n", drv.DriverName);
+ printf("%s: No read channel specified!\n", drv.DriverName);
reply(DEV_REVIVE, m_ptr->m_source, m_ptr->USER_ENDPT, EIO);
return;
}
if (!sub_dev_ptr->DmaBusy) { /* get fragment size on first read */
if (drv_get_frag_size(&(sub_dev_ptr->FragSize), sub_dev_ptr->Nr) != OK){
- error("%s: Could not retrieve fragment size!\n", drv.DriverName);
+ printf("%s: Could not retrieve fragment size!\n", drv.DriverName);
reply(DEV_REVIVE, m_ptr->m_source, m_ptr->USER_ENDPT,
EIO);
return;
}
if(m_ptr->COUNT != sub_dev_ptr->FragSize) {
reply(DEV_REVIVE, m_ptr->m_source, m_ptr->USER_ENDPT, EINVAL);
- error("fragment size does not match message size\n");
+ printf("fragment size does not match message size\n");
return;
}
/* if we are busy with something else than reading, reply EBUSY */
u32_t i;
- dprint("%s: handling hardware message\n", drv.DriverName);
-
/* while we have an interrupt */
while ( drv_int_sum()) {
/* loop over all sub devices */
* re-enable out interrupt after every interrupt.
*/
if ((sys_irqenable(&irq_hook_id)) != OK) {
- error("%s: msg_hardware: Couldn't enable IRQ\n", drv.DriverName);
+ printf("%s: msg_hardware: Couldn't enable IRQ\n", drv.DriverName);
}
}
{
int i;
- dprint("got a status message\n");
for (i = 0; i < drv.NrOfSubDevices; i++) {
if(sub_dev[i].ReadyToRevive)
sub_dev_ptr = &sub_dev[sub_dev_nr];
- dprint("Finished playing dma[%d] ", sub_dev_ptr->DmaReadNext);
sub_dev_ptr->DmaReadNext =
(sub_dev_ptr->DmaReadNext + 1) % sub_dev_ptr->NrOfDmaFragments;
sub_dev_ptr->DmaLength -= 1;
if (sub_dev_ptr->BufLength != 0) { /* Data in extra buf, copy to Dma buf */
- dprint(" buf[%d] -> dma[%d] ",
- sub_dev_ptr->BufReadNext, sub_dev_ptr->DmaFillNext);
memcpy(sub_dev_ptr->DmaPtr +
sub_dev_ptr->DmaFillNext * sub_dev_ptr->FragSize,
sub_dev_ptr->ExtraBuf +
if(sub_dev_ptr->DmaLength == 0) { /* Dma buffer empty, stop Dma transfer */
sub_dev_ptr->OutOfData = TRUE; /* we're out of data */
- dprint("No more work...!\n");
if (!sub_dev_ptr->Opened) {
close_sub_dev(sub_dev_ptr->Nr);
- dprint("Stopping sub device %d\n", sub_dev_ptr->Nr);
return;
}
- dprint("Pausing sub device %d\n",sub_dev_ptr->Nr);
drv_pause(sub_dev_ptr->Nr);
return;
}
- dprint("\n");
-
/* confirm and reenable interrupt from this sub dev */
drv_reenable_int(sub_dev_nr);
#if 0
/* reenable irq_hook*/
if (sys_irqenable(&irq_hook_id != OK) {
- error("%s Couldn't enable IRQ\n", drv.DriverName);
+ printf("%s Couldn't enable IRQ\n", drv.DriverName);
}
#endif
}
sub_dev_ptr = &sub_dev[sub_dev_nr];
- dprint("Device filled dma[%d]\n", sub_dev_ptr->DmaFillNext);
sub_dev_ptr->DmaLength += 1;
sub_dev_ptr->DmaFillNext =
(sub_dev_ptr->DmaFillNext + 1) % sub_dev_ptr->NrOfDmaFragments;
/* if dma buffer full */
if (sub_dev_ptr->BufLength == sub_dev_ptr->NrOfExtraBuffers) {
- error("All buffers full, we have a problem.\n");
+ printf("All buffers full, we have a problem.\n");
drv_stop(sub_dev_nr); /* stop the sub device */
sub_dev_ptr->DmaBusy = FALSE;
sub_dev_ptr->ReviveStatus = 0; /* no data for user,
}
else { /* dma full, still room in extra buf;
copy from dma to extra buf */
- dprint("dma full: going to copy buf[%d] <- dma[%d]\n",
- sub_dev_ptr->BufFillNext, sub_dev_ptr->DmaReadNext);
memcpy(sub_dev_ptr->ExtraBuf +
sub_dev_ptr->BufFillNext * sub_dev_ptr->FragSize,
sub_dev_ptr->DmaPtr +
#if 0
/* reenable irq_hook*/
if (sys_irqenable(&irq_hook_id) != OK) {
- error("%s: Couldn't reenable IRQ", drv.DriverName);
+ printf("%s: Couldn't reenable IRQ", drv.DriverName);
}
#endif
}
/* enable interrupt messages from MINIX */
if ((i=sys_irqenable(&irq_hook_id)) != OK) {
- error("%s: Couldn't enable IRQs: error code %u",drv.DriverName, (unsigned int) i);
+ printf("%s: Couldn't enable IRQs: error code %u",drv.DriverName, (unsigned int) i);
return EIO;
}
/* let the lower part of the driver start the device */
if (drv_start(sub_dev_ptr->Nr, sub_dev_ptr->DmaMode) != OK) {
- error("%s: Could not start device %d\n",
+ printf("%s: Could not start device %d\n",
drv.DriverName, sub_dev_ptr->Nr);
}
(phys_bytes)subdev->FragSize, D);
- dprint(" user -> dma[%d]\n", subdev->DmaFillNext);
subdev->DmaLength += 1;
subdev->DmaFillNext =
(subdev->DmaFillNext + 1) % subdev->NrOfDmaFragments;
subdev->BufFillNext * subdev->FragSize,
(phys_bytes)subdev->FragSize, D);
- dprint(" user -> buf[%d]\n", subdev->BufFillNext);
subdev->BufLength += 1;
subdev->BufFillNext =
drv_reenable_int(subdev->Nr);
/* reenable irq_hook*/
if ((sys_irqenable(&irq_hook_id)) != OK) {
- error("%s: Couldn't enable IRQ", drv.DriverName);
+ printf("%s: Couldn't enable IRQ", drv.DriverName);
}
drv_resume(subdev->Nr); /* resume resume the sub device */
}
sub_dev_ptr->BufReadNext * sub_dev_ptr->FragSize,
(phys_bytes)sub_dev_ptr->FragSize, D);
- dprint(" copied buf[%d] to user\n", sub_dev_ptr->BufReadNext);
-
/* adjust the buffer status variables */
sub_dev_ptr->BufReadNext =
(sub_dev_ptr->BufReadNext + 1) % sub_dev_ptr->NrOfExtraBuffers;
sub_dev_ptr->DmaReadNext * sub_dev_ptr->FragSize,
(phys_bytes)sub_dev_ptr->FragSize, D);
- dprint(" copied dma[%d] to user\n", sub_dev_ptr->DmaReadNext);
-
/* adjust the buffer status variables */
sub_dev_ptr->DmaReadNext =
(sub_dev_ptr->DmaReadNext + 1) % sub_dev_ptr->NrOfDmaFragments;
size= sub_dev_ptr->DmaSize + 64 * 1024;
base= alloc_contig(size, AC_ALIGN4K, &ph);
if (!base) {
- error("%s: failed to allocate dma buffer for a channel\n",
+ printf("%s: failed to allocate dma buffer for a channel\n",
drv.DriverName);
return EIO;
}
if (!(sub_dev_ptr->ExtraBuf = malloc(sub_dev_ptr->NrOfExtraBuffers *
sub_dev_ptr->DmaSize /
sub_dev_ptr->NrOfDmaFragments))) {
- error("%s failed to allocate extra buffer for a channel\n",
+ printf("%s failed to allocate extra buffer for a channel\n",
drv.DriverName);
return EIO;
}
return OK;
#else /* CHIP != INTEL */
- error("%s: init_buffers() failed, CHIP != INTEL", drv.DriverName);
+ printf("%s: init_buffers() failed, CHIP != INTEL", drv.DriverName);
return EIO;
#endif /* CHIP == INTEL */
}
}
}
- error("%s: No subdevice specified for minor device %d!\n",
+ printf("%s: No subdevice specified for minor device %d!\n",
drv.DriverName, minor_dev_nr);
return NULL;