* init_driver() now behaves better in low memory situations.
* Some preparations to support more than one chipset, added i855G (device ID 0x3582) to test with - the accelerant_device_info is now filled with that additional data as well. * Some minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16982 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -14,8 +14,13 @@
|
||||
#include <PCI.h>
|
||||
|
||||
|
||||
#define VENDOR_ID_INTEL 0x8086
|
||||
#define DEVICE_ID_i865 0x2572
|
||||
#define VENDOR_ID_INTEL 0x8086
|
||||
|
||||
enum {
|
||||
INTEL_TYPE_7xx,
|
||||
INTEL_TYPE_8xx,
|
||||
INTEL_TYPE_9xx,
|
||||
};
|
||||
|
||||
#define DEVICE_NAME "intel_extreme"
|
||||
#define INTEL_ACCELERANT_NAME "intel_extreme.accelerant"
|
||||
@@ -46,6 +51,9 @@ struct intel_shared_info {
|
||||
uint8 *physical_frame_buffer;
|
||||
|
||||
uint32 graphics_memory_size;
|
||||
|
||||
uint32 device_type;
|
||||
char device_identifier[32];
|
||||
struct pll_info pll_info;
|
||||
};
|
||||
|
||||
@@ -60,6 +68,9 @@ struct intel_info {
|
||||
area_id shared_area;
|
||||
uint8 *frame_buffer;
|
||||
area_id frame_buffer_area;
|
||||
|
||||
const char *device_identifier;
|
||||
uint32 device_type;
|
||||
};
|
||||
|
||||
//----------------- ioctl() interface ----------------
|
||||
|
||||
@@ -258,9 +258,9 @@ intel_get_accelerant_device_info(accelerant_device_info *info)
|
||||
TRACE(("intel_get_accelerant_device_info()\n"));
|
||||
|
||||
info->version = B_ACCELERANT_VERSION;
|
||||
strcpy(info->name, "Intel Extreme Graphics 2");
|
||||
strcpy(info->chipset, "i865G");
|
||||
// TODO: provide some more insight here once we support more than that one chip...
|
||||
strcpy(info->name, gInfo->shared_info->device_type == INTEL_TYPE_7xx
|
||||
? "Intel Extreme Graphics 1" : "Intel Extreme Graphics 2");
|
||||
strcpy(info->chipset, gInfo->shared_info->device_identifier);
|
||||
strcpy(info->serial_no, "None");
|
||||
|
||||
info->memory = gInfo->shared_info->graphics_memory_size;
|
||||
|
||||
@@ -97,12 +97,6 @@ device_open(const char *name, uint32 flags, void **_cookie)
|
||||
if (info->open_count++ == 0) {
|
||||
// this device has been opened for the first time, so
|
||||
// we allocate needed resources and initialize the structure
|
||||
|
||||
info->cookie_magic = INTEL_COOKIE_MAGIC;
|
||||
info->id = id;
|
||||
info->pci = gPCIInfo[id];
|
||||
info->registers = (uint8 *)gPCIInfo[id]->u.h0.base_registers[0];
|
||||
|
||||
status = intel_extreme_init(*info);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,35 +30,43 @@
|
||||
|
||||
#define MAX_CARDS 4
|
||||
|
||||
// list of supported devices
|
||||
const struct supported_device {
|
||||
uint32 device_id;
|
||||
int32 type;
|
||||
const char *name;
|
||||
} kSupportedDevices[] = {
|
||||
{0x2572, INTEL_TYPE_8xx, "i865G"},
|
||||
{0x3582, INTEL_TYPE_8xx, "i855G"},
|
||||
};
|
||||
|
||||
int32 api_version = B_CUR_DRIVER_API_VERSION;
|
||||
|
||||
char *gDeviceNames[MAX_CARDS + 1];
|
||||
intel_info *gDeviceInfo[MAX_CARDS];
|
||||
pci_info *gPCIInfo[MAX_CARDS];
|
||||
pci_module_info *gPCI;
|
||||
lock gLock;
|
||||
|
||||
|
||||
extern "C" {
|
||||
status_t init_hardware(void);
|
||||
status_t init_driver(void);
|
||||
void uninit_driver(void);
|
||||
const char **publish_devices(void);
|
||||
device_hooks *find_device(const char *name);
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
get_next_intel_extreme(int32 *_cookie, pci_info &info)
|
||||
get_next_intel_extreme(int32 *_cookie, pci_info &info, uint32 &type)
|
||||
{
|
||||
int32 index = *_cookie;
|
||||
|
||||
// find devices
|
||||
|
||||
for (; gPCI->get_nth_pci_info(index, &info) == B_OK; index++) {
|
||||
if (info.vendor_id == VENDOR_ID_INTEL
|
||||
&& info.device_id == DEVICE_ID_i865) {
|
||||
*_cookie = index + 1;
|
||||
return B_OK;
|
||||
// check vendor
|
||||
if (info.vendor_id != VENDOR_ID_INTEL)
|
||||
continue;
|
||||
|
||||
// check device
|
||||
for (uint32 i = 0; i < sizeof(kSupportedDevices) / sizeof(kSupportedDevices[0]); i++) {
|
||||
if (info.device_id == kSupportedDevices[i].device_id) {
|
||||
type = i;
|
||||
*_cookie = index + 1;
|
||||
return B_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +74,7 @@ get_next_intel_extreme(int32 *_cookie, pci_info &info)
|
||||
}
|
||||
|
||||
|
||||
const char **
|
||||
extern "C" const char **
|
||||
publish_devices(void)
|
||||
{
|
||||
TRACE((DEVICE_NAME ": publish_devices()\n"));
|
||||
@@ -74,93 +82,102 @@ publish_devices(void)
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
extern "C" status_t
|
||||
init_hardware(void)
|
||||
{
|
||||
status_t status;
|
||||
|
||||
TRACE((DEVICE_NAME ": init_hardware()\n"));
|
||||
|
||||
if ((status = get_module(B_PCI_MODULE_NAME,(module_info **)&gPCI)) != B_OK) {
|
||||
status_t status = get_module(B_PCI_MODULE_NAME,(module_info **)&gPCI);
|
||||
if (status != B_OK) {
|
||||
TRACE((DEVICE_NAME ": pci module unavailable\n"));
|
||||
return status;
|
||||
}
|
||||
|
||||
int32 cookie = 0;
|
||||
uint32 type;
|
||||
pci_info info;
|
||||
status = get_next_intel_extreme(&cookie, info);
|
||||
dprintf("found: %s\n", strerror(status));
|
||||
status = get_next_intel_extreme(&cookie, info, type);
|
||||
|
||||
put_module(B_PCI_MODULE_NAME);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
extern "C" status_t
|
||||
init_driver(void)
|
||||
{
|
||||
status_t status;
|
||||
TRACE((DEVICE_NAME ": init_driver()\n"));
|
||||
|
||||
if ((status = get_module(B_PCI_MODULE_NAME,(module_info **)&gPCI)) != B_OK) {
|
||||
status_t status = get_module(B_PCI_MODULE_NAME,(module_info **)&gPCI);
|
||||
if (status != B_OK) {
|
||||
TRACE((DEVICE_NAME ": pci module unavailable\n"));
|
||||
return status;
|
||||
}
|
||||
|
||||
status = init_lock(&gLock, "intel extreme ksync");
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
|
||||
// find devices
|
||||
|
||||
int32 found = 0;
|
||||
|
||||
for (int32 cookie = 0; found < MAX_CARDS;) {
|
||||
pci_info *info = (pci_info *)malloc(sizeof(pci_info));
|
||||
status = get_next_intel_extreme(&cookie, *info);
|
||||
if (info == NULL)
|
||||
break;
|
||||
|
||||
uint32 type;
|
||||
status = get_next_intel_extreme(&cookie, *info, type);
|
||||
if (status < B_OK) {
|
||||
free(info);
|
||||
break;
|
||||
}
|
||||
|
||||
// enable bus mastering for device
|
||||
// pci->write_pci_config(info->bus, info->device, info->function,
|
||||
// PCI_command, 2,
|
||||
// PCI_command_master | pci->read_pci_config(
|
||||
// info->bus, info->device, info->function,
|
||||
// PCI_command, 2));
|
||||
// create device names & allocate device info structure
|
||||
|
||||
char name[64];
|
||||
sprintf(name, "graphics/%04X_%04X_%02X%02X%02X",
|
||||
info->vendor_id, info->device_id,
|
||||
info->bus, info->device,
|
||||
info->function);
|
||||
|
||||
gDeviceNames[found] = strdup(name);
|
||||
if (gDeviceNames[found] == NULL)
|
||||
break;
|
||||
|
||||
gDeviceInfo[found] = (intel_info *)malloc(sizeof(intel_info));
|
||||
if (gDeviceInfo[found] == NULL) {
|
||||
free(gDeviceNames[found]);
|
||||
break;
|
||||
}
|
||||
|
||||
// initialize the structure for later use
|
||||
|
||||
memset(gDeviceInfo[found], 0, sizeof(intel_info));
|
||||
gDeviceInfo[found]->id = found;
|
||||
gDeviceInfo[found]->pci = info;
|
||||
gDeviceInfo[found]->registers = (uint8 *)info->u.h0.base_registers[0];
|
||||
gDeviceInfo[found]->device_identifier = kSupportedDevices[type].name;
|
||||
gDeviceInfo[found]->device_type = kSupportedDevices[type].type;
|
||||
|
||||
gPCIInfo[found++] = info;
|
||||
dprintf(DEVICE_NAME ": (%ld) revision = 0x%x\n", found, info->revision);
|
||||
found++;
|
||||
}
|
||||
|
||||
gDeviceNames[found] = NULL;
|
||||
|
||||
if (found == 0) {
|
||||
uninit_lock(&gLock);
|
||||
put_module(B_PCI_MODULE_NAME);
|
||||
return ENODEV;
|
||||
}
|
||||
|
||||
// create device name list & allocate device info structure
|
||||
{
|
||||
int32 index = 0;
|
||||
char name[64];
|
||||
|
||||
for (; index < found; index++) {
|
||||
pci_info *info = gPCIInfo[index];
|
||||
sprintf(name, "graphics/%04X_%04X_%02X%02X%02X",
|
||||
info->vendor_id, info->device_id,
|
||||
info->bus, info->device,
|
||||
info->function);
|
||||
gDeviceNames[index] = strdup(name);
|
||||
|
||||
if ((gDeviceInfo[index] = (intel_info *)malloc(sizeof(intel_info))) != NULL)
|
||||
memset(gDeviceInfo[index], 0, sizeof(intel_info));
|
||||
else
|
||||
free(gDeviceNames[index]);
|
||||
}
|
||||
gDeviceNames[index] = NULL;
|
||||
}
|
||||
|
||||
return init_lock(&gLock, "intel extreme ksync");
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
extern "C" void
|
||||
uninit_driver(void)
|
||||
{
|
||||
TRACE((DEVICE_NAME ": uninit_driver()\n"));
|
||||
@@ -171,7 +188,6 @@ uninit_driver(void)
|
||||
char *name;
|
||||
for (int32 index = 0; (name = gDeviceNames[index]) != NULL; index++) {
|
||||
free(gDeviceInfo[index]);
|
||||
free(gPCIInfo[index]);
|
||||
free(name);
|
||||
}
|
||||
|
||||
@@ -179,29 +195,30 @@ uninit_driver(void)
|
||||
}
|
||||
|
||||
|
||||
device_hooks *
|
||||
extern "C" device_hooks *
|
||||
find_device(const char *name)
|
||||
{
|
||||
int index;
|
||||
|
||||
TRACE((DEVICE_NAME ": find_device()\n"));
|
||||
|
||||
for (index = 0; gDeviceNames[index] != NULL; index++)
|
||||
for (index = 0; gDeviceNames[index] != NULL; index++) {
|
||||
if (!strcmp(name, gDeviceNames[index]))
|
||||
return &gDeviceHooks;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
void
|
||||
extern "C" void
|
||||
wake_driver(void)
|
||||
{
|
||||
// for compatibility with Dano, only
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
extern "C" void
|
||||
suspend_driver(void)
|
||||
{
|
||||
// for compatibility with Dano, only
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
|
||||
extern char *gDeviceNames[];
|
||||
extern intel_info *gDeviceInfo[];
|
||||
extern pci_info *gPCIInfo[];
|
||||
extern pci_module_info *gPCI;
|
||||
extern struct lock gLock;
|
||||
|
||||
|
||||
@@ -139,6 +139,17 @@ intel_extreme_init(intel_info &info)
|
||||
info.shared_info->pll_info.max_frequency = 350000; // 350 MHz RAM DAC speed
|
||||
info.shared_info->pll_info.divisor_register = INTEL_DISPLAY_PLL_DIVISOR_0;
|
||||
|
||||
info.shared_info->device_type = info.device_type;
|
||||
#ifdef __HAIKU__
|
||||
strlcpy(info.shared_info->device_identifier, info.device_identifier,
|
||||
sizeof(info.shared_info->device_identifier));
|
||||
#else
|
||||
strcpy(info.shared_info->device_identifier, info.device_identifier);
|
||||
#endif
|
||||
|
||||
info.cookie_magic = INTEL_COOKIE_MAGIC;
|
||||
// this makes the cookie valid to be used
|
||||
|
||||
dprintf(DEVICE_NAME "intel_extreme_init() completed successfully!\n");
|
||||
|
||||
return B_OK;
|
||||
|
||||
Reference in New Issue
Block a user