initial commit. mostly borrowed from ich driver.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1285 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
b1abd16faa
commit
348ee26939
34
src/add-ons/kernel/drivers/audio/echo/gals/Jamfile
Normal file
34
src/add-ons/kernel/drivers/audio/echo/gals/Jamfile
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
SubDir OBOS_TOP src add-ons kernel drivers audio echo gals ;
|
||||||
|
|
||||||
|
UsePrivateHeaders media ;
|
||||||
|
|
||||||
|
R5KernelAddon echo_gals : kernel drivers bin :
|
||||||
|
# ac97_multi.c
|
||||||
|
# config.c
|
||||||
|
debug.c
|
||||||
|
# ich.c
|
||||||
|
# io.c
|
||||||
|
# util.c
|
||||||
|
# ac97.c
|
||||||
|
;
|
||||||
|
|
||||||
|
# For OpenBeOS we should be building the driver objects this way.
|
||||||
|
#KernelObjects
|
||||||
|
# ac97_multi.c
|
||||||
|
# config.c
|
||||||
|
# debug.c
|
||||||
|
# ich.c
|
||||||
|
# io.c
|
||||||
|
# util.c
|
||||||
|
# ac97.c
|
||||||
|
# :
|
||||||
|
# -fno-pic -D_KERNEL_MODE
|
||||||
|
# ;
|
||||||
|
|
||||||
|
# Link to kernel/drivers/dev/audio/multi
|
||||||
|
{
|
||||||
|
local dir = [ FDirName $(OBOS_ADDON_DIR) kernel drivers dev audio multi ] ;
|
||||||
|
local instDriver = <kernel!drivers!dev!audio!multi>echo_gals ;
|
||||||
|
MakeLocate $(instDriver) : $(dir) ;
|
||||||
|
RelSymLink $(instDriver) : echo_gals ;
|
||||||
|
}
|
278
src/add-ons/kernel/drivers/audio/echo/gals/config.c
Normal file
278
src/add-ons/kernel/drivers/audio/echo/gals/config.c
Normal file
@ -0,0 +1,278 @@
|
|||||||
|
/*
|
||||||
|
* BeOS Driver for Intel ICH AC'97 Link interface
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002, Marcus Overhagen <marcus@overhagen.de>
|
||||||
|
*
|
||||||
|
* All rights reserved.
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* - Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||||
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include <KernelExport.h>
|
||||||
|
#include <config_manager.h>
|
||||||
|
#include <PCI.h>
|
||||||
|
#include <OS.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
|
//#define DEBUG 2
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include "ich.h"
|
||||||
|
|
||||||
|
device_config c;
|
||||||
|
device_config *config = &c;
|
||||||
|
|
||||||
|
status_t find_pci_pin_irq(uint8 pin, uint8 *irq);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* search for the ICH AC97 controller, and initialize the global config
|
||||||
|
* XXX multiple controllers not supported
|
||||||
|
*/
|
||||||
|
|
||||||
|
status_t probe_device(void)
|
||||||
|
{
|
||||||
|
pci_module_info *pcimodule;
|
||||||
|
config_manager_for_driver_module_info *configmodule;
|
||||||
|
struct device_info info;
|
||||||
|
uint64 cookie;
|
||||||
|
status_t result;
|
||||||
|
struct device_info *dinfo;
|
||||||
|
struct pci_info *pciinfo;
|
||||||
|
uint32 value;
|
||||||
|
|
||||||
|
if (get_module(B_CONFIG_MANAGER_FOR_DRIVER_MODULE_NAME,(module_info **)&configmodule) < 0) {
|
||||||
|
PRINT(("ERROR: couldn't load config manager module\n"));
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (get_module(B_PCI_MODULE_NAME,(module_info **)&pcimodule) < 0) {
|
||||||
|
PRINT(("ERROR: couldn't load pci module\n"));
|
||||||
|
put_module(B_CONFIG_MANAGER_FOR_DRIVER_MODULE_NAME);
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
config->name = 0;
|
||||||
|
config->nambar = 0;
|
||||||
|
config->nabmbar = 0;
|
||||||
|
config->mmbar = 0;
|
||||||
|
config->mbbar = 0;
|
||||||
|
config->irq = 0;
|
||||||
|
config->sample_size = 2;
|
||||||
|
config->swap_reg = false;
|
||||||
|
config->type = 0;
|
||||||
|
config->log_mmbar = 0;
|
||||||
|
config->log_mbbar = 0;
|
||||||
|
config->area_mmbar = -1;
|
||||||
|
config->area_mbbar = -1;
|
||||||
|
config->codecoffset = 0;
|
||||||
|
|
||||||
|
result = B_ERROR;
|
||||||
|
cookie = 0;
|
||||||
|
while (configmodule->get_next_device_info(B_PCI_BUS, &cookie, &info, sizeof(info)) == B_OK) {
|
||||||
|
|
||||||
|
if (info.config_status != B_OK)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
dinfo = (struct device_info *) malloc(info.size);
|
||||||
|
if (dinfo == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (configmodule->get_device_info_for(cookie, dinfo, info.size) != B_OK) {
|
||||||
|
free(dinfo);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
pciinfo = (struct pci_info *)((char *)dinfo + info.bus_dependent_info_offset);
|
||||||
|
|
||||||
|
if (pciinfo->vendor_id == 0x8086 && pciinfo->device_id == 0x7195) {
|
||||||
|
config->name = "Intel 82443MX";
|
||||||
|
} else if (pciinfo->vendor_id == 0x8086 && pciinfo->device_id == 0x2415) { /* verified */
|
||||||
|
config->name = "Intel 82801AA (ICH)";
|
||||||
|
} else if (pciinfo->vendor_id == 0x8086 && pciinfo->device_id == 0x2425) { /* verified */
|
||||||
|
config->name = "Intel 82801AB (ICH0)";
|
||||||
|
} else if (pciinfo->vendor_id == 0x8086 && pciinfo->device_id == 0x2445) { /* verified */
|
||||||
|
config->name = "Intel 82801BA (ICH2), Intel 82801BAM (ICH2-M)";
|
||||||
|
} else if (pciinfo->vendor_id == 0x8086 && pciinfo->device_id == 0x2485) { /* verified */
|
||||||
|
config->name = "Intel 82801CA (ICH3-S), Intel 82801CAM (ICH3-M)";
|
||||||
|
} else if (pciinfo->vendor_id == 0x8086 && pciinfo->device_id == 0x24C5) { /* verified */
|
||||||
|
config->name = "Intel 82801DB (ICH4)";
|
||||||
|
config->type = TYPE_ICH4;
|
||||||
|
} else if (pciinfo->vendor_id == 0x1039 && pciinfo->device_id == 0x7012) { /* verified */
|
||||||
|
config->name = "SiS SI7012";
|
||||||
|
config->swap_reg = true;
|
||||||
|
config->sample_size = 1;
|
||||||
|
} else if (pciinfo->vendor_id == 0x10DE && pciinfo->device_id == 0x01B1) {
|
||||||
|
config->name = "Nvidia nForce AC97";
|
||||||
|
} else if (pciinfo->vendor_id == 0x1022 && pciinfo->device_id == 0x764d) {
|
||||||
|
config->name = "AMD AMD8111";
|
||||||
|
} else if (pciinfo->vendor_id == 0x1022 && pciinfo->device_id == 0x7445) {
|
||||||
|
config->name = "AMD AMD768";
|
||||||
|
} else {
|
||||||
|
free(dinfo);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
LOG(("found %s\n",config->name));
|
||||||
|
LOG(("revision = %d\n",pciinfo->revision));
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
LOG(("bus = %#x, device = %#x, function = %#x\n",pciinfo->bus, pciinfo->device, pciinfo->function));
|
||||||
|
value = pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x00, 2);
|
||||||
|
LOG(("VID = %#04x\n",value));
|
||||||
|
value = pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x02, 2);
|
||||||
|
LOG(("DID = %#04x\n",value));
|
||||||
|
value = pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x08, 1);
|
||||||
|
LOG(("RID = %#02x\n",value));
|
||||||
|
value = pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x04, 2);
|
||||||
|
LOG(("PCICMD = %#04x\n",value));
|
||||||
|
value = pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x06, 2);
|
||||||
|
LOG(("PCISTS = %#04x\n",value));
|
||||||
|
value = pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x10, 4);
|
||||||
|
LOG(("NAMBAR = %#08x\n",value));
|
||||||
|
value = pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x14, 4);
|
||||||
|
LOG(("NABMBAR = %#08x\n",value));
|
||||||
|
value = pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x18, 4);
|
||||||
|
LOG(("MMBAR = %#08x\n",value));
|
||||||
|
value = pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x1C, 4);
|
||||||
|
LOG(("MBBAR = %#08x\n",value));
|
||||||
|
value = pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x3c, 1);
|
||||||
|
LOG(("INTR_LN = %#02x\n",value));
|
||||||
|
value = pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x3d, 1);
|
||||||
|
LOG(("INTR_PN = %#02x\n",value));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* for ICH4 enable memory mapped IO and busmaster access,
|
||||||
|
* for old ICHs enable programmed IO and busmaster access
|
||||||
|
*/
|
||||||
|
value = pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, PCI_PCICMD, 2);
|
||||||
|
if (config->type & TYPE_ICH4)
|
||||||
|
value |= PCI_PCICMD_MSE | PCI_PCICMD_BME;
|
||||||
|
else
|
||||||
|
value |= PCI_PCICMD_IOS | PCI_PCICMD_BME;
|
||||||
|
pcimodule->write_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, PCI_PCICMD, 2, value);
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
value = pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, PCI_PCICMD, 2);
|
||||||
|
LOG(("PCICMD = %#04x\n",value));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
config->irq = pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x3C, 1);
|
||||||
|
if (config->irq == 0 || config->irq == 0xff) {
|
||||||
|
// workaround: even if no irq is configured, we may be able to find the correct one
|
||||||
|
uint8 pin;
|
||||||
|
uint8 irq;
|
||||||
|
pin = pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x3d, 1);
|
||||||
|
LOG(("IRQ not assigned to pin %d\n",pin));
|
||||||
|
LOG(("Searching for IRQ...\n"));
|
||||||
|
if (B_OK == find_pci_pin_irq(pin, &irq)) {
|
||||||
|
LOG(("Assigning IRQ %d to pin %d\n",irq,pin));
|
||||||
|
config->irq = irq;
|
||||||
|
} else {
|
||||||
|
config->irq = 0; // always 0, not 0xff if no irq assigned
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config->type & TYPE_ICH4) {
|
||||||
|
// memory mapped access
|
||||||
|
config->mmbar = 0xfffffffe & pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x18, 4);
|
||||||
|
config->mbbar = 0xfffffffe & pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x1C, 4);
|
||||||
|
} else {
|
||||||
|
// pio access
|
||||||
|
config->nambar = 0xfffffffe & pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x10, 4);
|
||||||
|
config->nabmbar = 0xfffffffe & pcimodule->read_pci_config(pciinfo->bus, pciinfo->device, pciinfo->function, 0x14, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG(("irq = %d\n",config->irq));
|
||||||
|
LOG(("nambar = %#08x\n",config->nambar));
|
||||||
|
LOG(("nabmbar = %#08x\n",config->nabmbar));
|
||||||
|
LOG(("mmbar = %#08x\n",config->mmbar));
|
||||||
|
LOG(("mbbar = %#08x\n",config->mbbar));
|
||||||
|
|
||||||
|
free(dinfo);
|
||||||
|
result = B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result != B_OK)
|
||||||
|
LOG(("probe_device() hardware not found\n"));
|
||||||
|
//config->irq = 0;
|
||||||
|
if (config->irq == 0) {
|
||||||
|
PRINT(("WARNING: no interrupt configured\n"));
|
||||||
|
/*
|
||||||
|
* we can continue without an interrupt, as another
|
||||||
|
* workaround to handle this is also implemented
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
/* the ICH4 uses memory mapped IO */
|
||||||
|
if ((config->type & TYPE_ICH4) != 0 && ((config->mmbar == 0) || (config->mbbar == 0))) {
|
||||||
|
PRINT(("ERROR: memory mapped IO not configured\n"));
|
||||||
|
result = B_ERROR;
|
||||||
|
}
|
||||||
|
/* all other ICHs use programmed IO */
|
||||||
|
if ((config->type & TYPE_ICH4) == 0 && ((config->nambar == 0) || (config->nabmbar == 0))) {
|
||||||
|
PRINT(("ERROR: IO space not configured\n"));
|
||||||
|
result = B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
put_module(B_PCI_MODULE_NAME);
|
||||||
|
put_module(B_CONFIG_MANAGER_FOR_DRIVER_MODULE_NAME);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is another ugly workaround. If no irq has been assigned
|
||||||
|
* to our card, we try to find another card that uses the same
|
||||||
|
* interrupt pin, but has an irq assigned, and use it.
|
||||||
|
*/
|
||||||
|
status_t find_pci_pin_irq(uint8 pin, uint8 *irq)
|
||||||
|
{
|
||||||
|
pci_module_info *module;
|
||||||
|
struct pci_info info;
|
||||||
|
status_t result;
|
||||||
|
long index;
|
||||||
|
|
||||||
|
if (get_module(B_PCI_MODULE_NAME,(module_info **)&module) < 0) {
|
||||||
|
PRINT(("ERROR: couldn't load pci module\n"));
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = B_ERROR;
|
||||||
|
for (index = 0; B_OK == module->get_nth_pci_info(index, &info); index++) {
|
||||||
|
uint8 pciirq = module->read_pci_config(info.bus, info.device, info.function, PCI_interrupt_line, 1);
|
||||||
|
uint8 pcipin = module->read_pci_config(info.bus, info.device, info.function, PCI_interrupt_pin, 1);
|
||||||
|
LOG(("pin %d, irq %d\n",pcipin,pciirq));
|
||||||
|
if (pcipin == pin && pciirq != 0 && pciirq != 0xff) {
|
||||||
|
*irq = pciirq;
|
||||||
|
result = B_OK;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
if (result != B_OK) {
|
||||||
|
LOG(("Couldn't find IRQ for pin %d\n",pin));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
put_module(B_PCI_MODULE_NAME);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
55
src/add-ons/kernel/drivers/audio/echo/gals/config.h
Normal file
55
src/add-ons/kernel/drivers/audio/echo/gals/config.h
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* BeOS Driver for Intel ICH AC'97 Link interface
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002, Marcus Overhagen <marcus@overhagen.de>
|
||||||
|
*
|
||||||
|
* All rights reserved.
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* - Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||||
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifndef _CONFIG_H_
|
||||||
|
#define _CONFIG_H_
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
uint32 nambar;
|
||||||
|
uint32 nabmbar;
|
||||||
|
uint32 irq;
|
||||||
|
uint32 type;
|
||||||
|
int sample_size;
|
||||||
|
bool swap_reg;
|
||||||
|
uint32 mmbar; // ich4
|
||||||
|
uint32 mbbar; // ich4
|
||||||
|
void * log_mmbar; // ich4
|
||||||
|
void * log_mbbar; // ich4
|
||||||
|
area_id area_mmbar; // ich4
|
||||||
|
area_id area_mbbar; // ich4
|
||||||
|
uint32 codecoffset;
|
||||||
|
} device_config;
|
||||||
|
|
||||||
|
extern device_config *config;
|
||||||
|
|
||||||
|
status_t probe_device(void);
|
||||||
|
|
||||||
|
#define TYPE_ICH4 0x01
|
||||||
|
|
||||||
|
#endif
|
90
src/add-ons/kernel/drivers/audio/echo/gals/debug.c
Normal file
90
src/add-ons/kernel/drivers/audio/echo/gals/debug.c
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* BeOS Driver for Intel ICH AC'97 Link interface
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002, Marcus Overhagen <marcus@overhagen.de>
|
||||||
|
*
|
||||||
|
* All rights reserved.
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* - Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||||
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include <KernelExport.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <OS.h>
|
||||||
|
#include "debug.h"
|
||||||
|
#include "ich.h"
|
||||||
|
|
||||||
|
static const char * logfile="/boot/home/ich_ac97.log";
|
||||||
|
static sem_id loglock;
|
||||||
|
|
||||||
|
void debug_printf(const char *text,...);
|
||||||
|
void log_printf(const char *text,...);
|
||||||
|
void log_create();
|
||||||
|
|
||||||
|
void debug_printf(const char *text,...)
|
||||||
|
{
|
||||||
|
char buf[1024];
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap,text);
|
||||||
|
vsprintf(buf,text,ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
dprintf(DRIVER_NAME ": %s",buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
void log_create()
|
||||||
|
{
|
||||||
|
#if DEBUG > 0
|
||||||
|
int fd = open(logfile, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||||
|
const char *text = DRIVER_NAME ", " VERSION "\n";
|
||||||
|
loglock = create_sem(1,"logfile sem");
|
||||||
|
write(fd,text,strlen(text));
|
||||||
|
close(fd);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void log_printf(const char *text,...)
|
||||||
|
{
|
||||||
|
#if DEBUG > 0
|
||||||
|
int fd;
|
||||||
|
char buf[1024];
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap,text);
|
||||||
|
vsprintf(buf,text,ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
dprintf(DRIVER_NAME ": %s",buf);
|
||||||
|
|
||||||
|
acquire_sem(loglock);
|
||||||
|
fd = open(logfile, O_WRONLY | O_APPEND);
|
||||||
|
write(fd,buf,strlen(buf));
|
||||||
|
close(fd);
|
||||||
|
release_sem(loglock);
|
||||||
|
|
||||||
|
#if DEBUG > 1
|
||||||
|
snooze(150000);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
66
src/add-ons/kernel/drivers/audio/echo/gals/debug.h
Normal file
66
src/add-ons/kernel/drivers/audio/echo/gals/debug.h
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* BeOS Driver for Intel ICH AC'97 Link interface
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002, Marcus Overhagen <marcus@overhagen.de>
|
||||||
|
*
|
||||||
|
* All rights reserved.
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* - Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||||
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifndef _DEBUG_H_
|
||||||
|
#define _DEBUG_H_
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PRINT() executes dprintf if DEBUG = 0 (disabled), or expands to LOG() when DEBUG > 0
|
||||||
|
* TRACE() executes dprintf if DEBUG > 0
|
||||||
|
* LOG() executes dprintf and writes to the logfile if DEBUG > 0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* DEBUG == 0, no debugging, PRINT writes to syslog
|
||||||
|
* DEBUG == 1, TRACE & LOG, PRINT
|
||||||
|
* DEBUG == 2, TRACE & LOG, PRINT with snooze()
|
||||||
|
*/
|
||||||
|
#ifndef DEBUG
|
||||||
|
#define DEBUG 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef PRINT
|
||||||
|
#undef TRACE
|
||||||
|
#undef ASSERT
|
||||||
|
|
||||||
|
#if DEBUG > 0
|
||||||
|
#define PRINT(a) log_printf a
|
||||||
|
#define TRACE(a) debug_printf a
|
||||||
|
#define LOG(a) log_printf a
|
||||||
|
#define LOG_CREATE() log_create()
|
||||||
|
#define ASSERT(a) if (a) {} else LOG(("ASSERT failed! file = %s, line = %d\n",__FILE__,__LINE__))
|
||||||
|
void log_create();
|
||||||
|
void log_printf(const char *text,...);
|
||||||
|
void debug_printf(const char *text,...);
|
||||||
|
#else
|
||||||
|
#define PRINT(a) debug_printf a
|
||||||
|
#define TRACE(a) ((void)(0))
|
||||||
|
#define ASSERT(a) ((void)(0))
|
||||||
|
#define LOG(a) ((void)(0))
|
||||||
|
#define LOG_CREATE()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
93
src/add-ons/kernel/drivers/audio/echo/gals/gals.cpp
Normal file
93
src/add-ons/kernel/drivers/audio/echo/gals/gals.cpp
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
#include <KernelExport.h>
|
||||||
|
#include <Drivers.h>
|
||||||
|
#include <Errors.h>
|
||||||
|
#include <OS.h>
|
||||||
|
#include "debug.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include "../generic/OsSupportBeOS.h"
|
||||||
|
|
||||||
|
status_t
|
||||||
|
init_hardware(void)
|
||||||
|
{
|
||||||
|
LOG_CREATE();
|
||||||
|
if (B_OK == probe_device()) {
|
||||||
|
PRINT(("ALL YOUR BASE ARE BELONG TO US\n"));
|
||||||
|
return B_OK;
|
||||||
|
} else {
|
||||||
|
LOG(("hardware not found\n"));
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t
|
||||||
|
init_driver(void)
|
||||||
|
{
|
||||||
|
status_t rv;
|
||||||
|
bigtime_t start;
|
||||||
|
bool s0cr, s1cr, s2cr;
|
||||||
|
|
||||||
|
LOG_CREATE();
|
||||||
|
|
||||||
|
LOG(("init_driver\n"));
|
||||||
|
|
||||||
|
ASSERT(sizeof(ich_bd) == 8);
|
||||||
|
|
||||||
|
rv = probe_device();
|
||||||
|
if (rv != B_OK) {
|
||||||
|
LOG(("No supported audio hardware found.\n"));
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
PRINT((VERSION "\n"));
|
||||||
|
PRINT(("found %s\n", config->name));
|
||||||
|
PRINT(("IRQ = %ld, NAMBAR = %#lX, NABMBAR = %#lX, MMBAR = %#lX, MBBAR = %#lX\n",config->irq,config->nambar,config->nabmbar,config->mmbar,config->mbbar));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
uninit_driver(void)
|
||||||
|
{
|
||||||
|
LOG(("uninit_driver()\n"));
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
if (chan_po) LOG(("chan_po frames_count = %Ld\n",chan_po->played_frames_count));
|
||||||
|
if (chan_pi) LOG(("chan_pi frames_count = %Ld\n",chan_pi->played_frames_count));
|
||||||
|
if (chan_mc) LOG(("chan_mc frames_count = %Ld\n",chan_mc->played_frames_count));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
LOG(("uninit_driver() finished\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *gals_names[] = {
|
||||||
|
"audio/multi/darla20",
|
||||||
|
"audio/multi/gina20",
|
||||||
|
"audio/multi/layla20",
|
||||||
|
"audio/multi/darla24",
|
||||||
|
NULL
|
||||||
|
}
|
||||||
|
|
||||||
|
const char **
|
||||||
|
publish_devices(void) {
|
||||||
|
return gals_names;
|
||||||
|
}
|
||||||
|
|
||||||
|
device_hooks gals_hooks = {
|
||||||
|
gals_open, /* -> open entry point */
|
||||||
|
gals_close, /* -> close entry point */
|
||||||
|
gals_free, /* -> free cookie */
|
||||||
|
gals_control, /* -> control entry point */
|
||||||
|
gals_read, /* -> read entry point */
|
||||||
|
gals_write, /* -> write entry point */
|
||||||
|
NULL, /* start select */
|
||||||
|
NULL, /* stop select */
|
||||||
|
NULL, /* scatter-gather read from the device */
|
||||||
|
NULL /* scatter-gather write to the device */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
device_hooks *
|
||||||
|
find_device(const char * name) {
|
||||||
|
return &gals_hooks;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 api_version = B_CUR_DRIVER_API_VERSION;
|
Loading…
Reference in New Issue
Block a user