fixed build for non haiku platforms

fixed displayed names for some models
added untested support for CardBus models Indigo*, thanks to Patrick Lafarguette for his great help on this feature


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15571 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2005-12-16 23:44:40 +00:00
parent c544064d35
commit ec816dffe2
10 changed files with 255 additions and 20 deletions

View File

@ -2,6 +2,11 @@ SubDir HAIKU_TOP src add-ons kernel drivers audio echo 24 ;
SetSubDirSupportedPlatformsBeOSCompatible ;
if $(TARGET_PLATFORM) != haiku {
UseHeaders [ FDirName $(HAIKU_TOP) headers os drivers ] : true ;
# We need the public pcmcia headers also when not compiling for Haiku.
}
SubDirHdrs $(HAIKU_TOP) src add-ons kernel drivers audio echo ;
SubDirHdrs $(HAIKU_TOP) src add-ons kernel drivers audio echo generic ;
SubDirHdrs $(HAIKU_TOP) src add-ons kernel drivers audio echo generic DSP ;

View File

@ -2,6 +2,11 @@ SubDir HAIKU_TOP src add-ons kernel drivers audio echo 3g ;
SetSubDirSupportedPlatformsBeOSCompatible ;
if $(TARGET_PLATFORM) != haiku {
UseHeaders [ FDirName $(HAIKU_TOP) headers os drivers ] : true ;
# We need the public pcmcia headers also when not compiling for Haiku.
}
SubDirHdrs $(HAIKU_TOP) src add-ons kernel drivers audio echo ;
SubDirHdrs $(HAIKU_TOP) src add-ons kernel drivers audio echo generic ;
SubDirHdrs $(HAIKU_TOP) src add-ons kernel drivers audio echo generic DSP ;

View File

@ -3,4 +3,4 @@ SubDir HAIKU_TOP src add-ons kernel drivers audio echo ;
SubInclude HAIKU_TOP src add-ons kernel drivers audio echo gals ;
SubInclude HAIKU_TOP src add-ons kernel drivers audio echo 24 ;
SubInclude HAIKU_TOP src add-ons kernel drivers audio echo 3g ;
#SubInclude HAIKU_TOP src add-ons kernel drivers audio echo indigo ; # Indigo are CardBus based
SubInclude HAIKU_TOP src add-ons kernel drivers audio echo indigo ; # Indigo are CardBus based

View File

@ -59,7 +59,7 @@ void log_create()
{
#if DEBUG > 0
int fd = open(logfile, O_WRONLY | O_CREAT | O_TRUNC, 0666);
const char *text = DRIVER_NAME ", " VERSION "\n";
const char *text = DRIVER_NAME ", " ECHO_VERSION "\n";
loglock = create_sem(1,"logfile sem");
write(fd,text,strlen(text));
close(fd);

View File

@ -43,7 +43,7 @@
#ifdef ECHO3G_FAMILY
#define DRIVER_NAME "echo3g"
#endif
#define VERSION "0.0"
#define ECHO_VERSION "0.0"
/*
* PRINT() executes dprintf if DEBUG = 0 (disabled), or expands to LOG() when DEBUG > 0

View File

@ -44,12 +44,36 @@
#include "debug.h"
#include "util.h"
#ifdef CARDBUS
static cb_enabler_module_info *cbemi;
struct _echodevs devices;
static char *names[NUM_CARDS];
int32 num_names = 0;
static uint32 device_index = 0;
static sem_id device_lock = 0;
static const cb_device_descriptor descriptors[] = {
{VENDOR_ID, DEVICE_ID_56301, 0xff, 0xff, 0xff}
};
#define COUNT_DESCRIPTOR 1
status_t cardbus_device_added(pci_info *info, void **cookie);
void cardbus_device_removed(void *cookie);
static cb_notify_hooks cardbus_hooks = {
cardbus_device_added, // Add entry point
cardbus_device_removed // Remove entry point
};
#else // CARDBUS
static char pci_name[] = B_PCI_MODULE_NAME;
static pci_module_info *pci;
int32 num_cards;
echo_dev cards[NUM_CARDS];
int32 num_names;
char * names[NUM_CARDS*20+1];
#endif // CARDBUS
extern device_hooks multi_hooks;
#ifdef MIDI_SUPPORT
@ -424,6 +448,9 @@ echo_dump_caps(echo_dev *card)
status_t
init_hardware(void)
{
#ifdef CARDBUS
return B_OK;
#else
int ix=0;
pci_info info;
status_t err = ENODEV;
@ -477,12 +504,36 @@ init_hardware(void)
}
return err;
#endif
}
status_t
init_driver(void)
{
#ifdef CARDBUS
// Get card services client module
if (get_module(CB_ENABLER_MODULE_NAME, (module_info **)&cbemi) != B_OK) {
dprintf(DRIVER_NAME ": cardbus enabler module error\n");
goto cb_error;
}
// Create the devices lock
device_lock = create_sem(1, DRIVER_NAME " device");
if (device_lock < B_OK) {
dprintf(DRIVER_NAME ": create device semaphore error 0x%.8x\n", device_lock);
put_module(CB_ENABLER_MODULE_NAME);
goto cb_error;
}
// Register driver
cbemi->register_driver(DRIVER_NAME, descriptors, COUNT_DESCRIPTOR);
cbemi->install_notify(DRIVER_NAME, &cardbus_hooks);
LIST_INIT(&(devices));
return B_OK;
cb_error:
put_module(B_PCI_MODULE_NAME);
return B_ERROR;
#else
int ix=0;
pci_info info;
@ -548,14 +599,15 @@ init_driver(void)
}
return B_OK;
#endif
}
#ifndef CARDBUS
static void
make_device_names(
echo_dev * card)
{
#ifdef MIDI_SUPPORT
sprintf(card->midi.name, "midi/"DRIVER_NAME"/%ld", card-cards+1);
names[num_names++] = card->midi.name;
@ -565,6 +617,79 @@ make_device_names(
names[num_names] = NULL;
}
#else
status_t
cardbus_device_added(pci_info *info, void **cookie) {
echo_dev * card, *dev;
uint32 index;
char buffer[32];
LOG(("cardbus_device_added at %.2d:%.2d:%.2d\n", info->bus, info->device, info->function));
// Allocate cookie
if (!(*cookie = card = (echo_dev *)malloc(sizeof(echo_dev)))) {
return B_NO_MEMORY;
}
// Clear cookie
memset(card, 0, sizeof(echo_dev));
// Initialize cookie
card->info = *info;
card->plugged = true;
card->index = 0;
LIST_FOREACH(dev, &devices, next) {
if (dev->index == card->index) {
card->index++;
dev = LIST_FIRST(&devices);
}
}
// Format device name
sprintf(card->name, "audio/multi/" DRIVER_NAME "/%ld", card->index);
// Lock the devices
acquire_sem(device_lock);
LIST_INSERT_HEAD((&devices), card, next);
// Unlock the devices
release_sem(device_lock);
echo_setup(card);
return B_OK;
}
// cardbus_device_removed - handle cardbus device removal.
// status : OK
void
cardbus_device_removed(void *cookie)
{
echo_dev *card = (echo_dev *) cookie;
LOG((": cardbus_device_removed\n"));
// Check
if (card == NULL) {
LOG((": null device 0x%.8x\n", card));
return;
}
echo_shutdown(card);
// Lock the devices
acquire_sem(device_lock);
// Finalize
card->plugged = false;
// Check if the device is opened
if (card->opened) {
LOG(("device 0x%.8x %s still in use\n", card, card->name));
} else {
LOG(("free device 0x%.8x %s\n", card, card->name));
LIST_REMOVE(card, next);
free(card);
}
// Unlock the devices
release_sem(device_lock);
}
#endif
static status_t
@ -575,15 +700,17 @@ echo_setup(echo_dev * card)
char *name;
PRINT(("echo_setup(%p)\n", card));
#ifndef CARDBUS
(*pci->write_pci_config)(card->info.bus, card->info.device, card->info.function,
PCI_latency, 1, 0xc0 );
make_device_names(card);
#endif
card->bmbar = card->info.u.h0.base_registers[0];
card->irq = card->info.u.h0.interrupt_line;
card->pOSS = new COsSupport(card->info.device_id, card->info.revision);
if(card->pOSS == NULL)
return B_ERROR;
@ -614,7 +741,7 @@ echo_setup(echo_dev * card)
break;
case LAYLA24:
card->pEG = new CLayla24(card->pOSS);
name = "Echo Gina24";
name = "Echo Layla24";
break;
case MONA:
card->pEG = new CMona(card->pOSS);
@ -628,15 +755,15 @@ echo_setup(echo_dev * card)
#ifdef INDIGO_FAMILY
case INDIGO:
card->pEG = new CIndigo(card->pOSS);
name = "Echo Mia";
name = "Echo Indigo";
break;
case INDIGO_IO:
card->pEG = new CIndigoIO(card->pOSS);
name = "Echo Mia";
name = "Echo IndigoIO";
break;
case INDIGO_DJ:
card->pEG = new CIndigoDJ(card->pOSS);
name = "Echo Mia";
name = "Echo IndigoDJ";
break;
#endif
#ifdef ECHO3G_FAMILY
@ -662,11 +789,13 @@ echo_setup(echo_dev * card)
}
LOG(("mapping of bmbar: area %#x, phys %#x, log %#x\n", card->area_bmbar, card->bmbar, card->log_bmbar));
#ifndef CARDBUS
cmd = (*pci->read_pci_config)(card->info.bus, card->info.device, card->info.function, PCI_command, 2);
PRINT(("PCI command before: %x\n", cmd));
(*pci->write_pci_config)(card->info.bus, card->info.device, card->info.function, PCI_command, 2, cmd | PCI_command_io);
cmd = (*pci->read_pci_config)(card->info.bus, card->info.device, card->info.function, PCI_command, 2);
PRINT(("PCI command after: %x\n", cmd));
#endif
card->pEG->AssignResources(card->log_bmbar, name);
@ -734,28 +863,54 @@ echo_shutdown(echo_dev *card)
void
uninit_driver(void)
{
PRINT(("uninit_driver()\n"));
#ifdef CARDBUS
echo_dev *dev;
LIST_FOREACH(dev, &devices, next) {
echo_shutdown(dev);
}
put_module(CB_ENABLER_MODULE_NAME);
#else
int ix, cnt = num_cards;
num_cards = 0;
PRINT(("uninit_driver()\n"));
for (ix=0; ix<cnt; ix++) {
echo_shutdown(&cards[ix]);
}
memset(&cards, 0, sizeof(cards));
put_module(pci_name);
#endif
}
const char **
publish_devices(void)
{
#ifdef CARDBUS
echo_dev *dev;
int ix = 0;
// Lock the devices
acquire_sem(device_lock);
// Loop
LIST_FOREACH(dev, &devices, next) {
if (dev->plugged == true) {
names[ix] = dev->name;
ix++;
}
}
names[ix] = NULL;
release_sem(device_lock);
#else
int ix = 0;
PRINT(("publish_devices()\n"));
for (ix=0; names[ix]; ix++) {
PRINT(("publish %s\n", names[ix]));
}
#endif
return (const char **)names;
}
@ -763,6 +918,15 @@ publish_devices(void)
device_hooks *
find_device(const char * name)
{
echo_dev *dev;
#ifdef CARDBUS
LIST_FOREACH(dev, &devices, next) {
if (!strcmp(dev->name, name)) {
return &multi_hooks;
}
}
#else
int ix;
PRINT(("find_device(%s)\n", name));
@ -777,6 +941,7 @@ find_device(const char * name)
return &multi_hooks;
}
}
#endif
PRINT(("find_device(%s) failed\n", name));
return NULL;
}

View File

@ -24,7 +24,11 @@
#ifndef _ECHO_H_
#define _ECHO_H_
#ifdef CARDBUS
#include <pcmcia/cb_enabler.h>
#else
#include <PCI.h>
#endif
#include "OsSupportBeOS.h"
#include "CEchoGals.h"
#include "multi_audio.h"
@ -118,11 +122,22 @@ typedef struct _echo_dev {
multi_dev multi;
#ifdef MIDI_SUPPORT
midi_dev midi;
#endif
#endif
#ifdef CARDBUS
bool plugged; // Device plugged
bool opened; // Device opened
int32 index;
LIST_ENTRY(_echo_dev) next;
#endif
} echo_dev;
extern int32 num_cards;
#ifdef CARDBUS
LIST_HEAD(_echodevs, _echo_dev);
extern struct _echodevs devices;
#else
extern echo_dev cards[NUM_CARDS];
#endif
#ifdef __cplusplus
extern "C" {

View File

@ -2,6 +2,11 @@ SubDir HAIKU_TOP src add-ons kernel drivers audio echo gals ;
SetSubDirSupportedPlatformsBeOSCompatible ;
if $(TARGET_PLATFORM) != haiku {
UseHeaders [ FDirName $(HAIKU_TOP) headers os drivers ] : true ;
# We need the public pcmcia headers also when not compiling for Haiku.
}
SubDirHdrs $(HAIKU_TOP) src add-ons kernel drivers audio echo ;
SubDirHdrs $(HAIKU_TOP) src add-ons kernel drivers audio echo generic ;
SubDirHdrs $(HAIKU_TOP) src add-ons kernel drivers audio echo generic DSP ;

View File

@ -2,6 +2,11 @@ SubDir HAIKU_TOP src add-ons kernel drivers audio echo indigo ;
SetSubDirSupportedPlatformsBeOSCompatible ;
if $(TARGET_PLATFORM) != haiku {
UseHeaders [ FDirName $(HAIKU_TOP) headers os drivers ] : true ;
# We need the public pcmcia headers also when not compiling for Haiku.
}
SubDirHdrs $(HAIKU_TOP) src add-ons kernel drivers audio echo ;
SubDirHdrs $(HAIKU_TOP) src add-ons kernel drivers audio echo generic ;
SubDirHdrs $(HAIKU_TOP) src add-ons kernel drivers audio echo generic DSP ;
@ -10,8 +15,8 @@ SubDirHdrs $(HAIKU_TOP) src add-ons kernel drivers audio echo generic ASIC ;
UsePrivateHeaders [ FDirName kernel ] ; # For kernel_cpp.cpp
# set some additional defines
SubDirCcFlags -DECHO_BEOS -DINDIGO_FAMILY ;
SubDirC++Flags -DECHO_BEOS -DINDIGO_FAMILY -fno-rtti -DAUTO_DUCK_ALLOCATE ;
SubDirCcFlags -DECHO_BEOS -DINDIGO_FAMILY -DCARDBUS ;
SubDirC++Flags -DECHO_BEOS -DINDIGO_FAMILY -fno-rtti -DAUTO_DUCK_ALLOCATE -DCARDBUS ;
local echo_files =
CChannelMask.cpp

View File

@ -757,6 +757,14 @@ static status_t
echo_multi_control(void *cookie, uint32 op, void *data, size_t length)
{
echo_dev *card = (echo_dev *)cookie;
#ifdef CARDBUS
// Check
if (card->plugged == false) {
LOG(("device %s unplugged\n", card->name));
return B_ERROR;
}
#endif
switch (op) {
case B_MULTI_GET_DESCRIPTION:
@ -850,24 +858,45 @@ static status_t
echo_open(const char *name, uint32 flags, void** cookie)
{
echo_dev *card = NULL;
int ix, i, first_record_channel;
int i, first_record_channel;
echo_stream *stream = NULL;
LOG(("echo_open()\n"));
#ifdef CARDBUS
LIST_FOREACH(card, &devices, next) {
if (!strcmp(card->name, name)) {
break;
}
}
#else
for (i=0; i<num_cards; i++) {
if (!strcmp(cards[i].name, name)) {
card = &cards[i];
}
}
#endif
if(card == NULL) {
LOG(("open() card not found %s\n", name));
for (ix=0; ix<num_cards; ix++) {
LOG(("open() card available %s\n", cards[ix].name));
#ifdef CARDBUS
LIST_FOREACH(card, &devices, next) {
LOG(("open() card available %s\n", card->name));
}
#else
for (int ix=0; ix<num_cards; ix++) {
LOG(("open() card available %s\n", cards[ix].name));
}
#endif
return B_ERROR;
}
#ifdef CARDBUS
if (card->plugged == false) {
LOG(("device %s unplugged\n", name));
return B_ERROR;
}
#endif
LOG(("open() got card\n"));
@ -878,6 +907,9 @@ echo_open(const char *name, uint32 flags, void** cookie)
*cookie = card;
card->multi.card = card;
#ifdef CARDBUS
card->opened = true;
#endif
LOG(("creating play streams\n"));
@ -912,8 +944,11 @@ echo_open(const char *name, uint32 flags, void** cookie)
static status_t
echo_close(void* cookie)
{
//echo_dev *card = cookie;
LOG(("close()\n"));
#ifdef CARDBUS
echo_dev *card = (echo_dev *) cookie;
card->opened = false;
#endif
return B_OK;
}