code sync against nvidia/matrox drivers: added capability to run without INT assigned, proposemode fixes for dualhead/tvout related custom flags, GET_ACCELERANT_DEV_INFO returns much more detailed info, INIT_ and CLONE_ACCELERANT now enforce correct use. Bumped version to 0.12.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16032 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rudolf Cornelissen
2006-01-21 22:11:50 +00:00
parent ccee0bb56d
commit 489527469f
7 changed files with 103 additions and 67 deletions
@@ -1,6 +1,6 @@
/* /*
Author: Author:
Rudolf Cornelissen 11/2004 Rudolf Cornelissen 1/2006
*/ */
#define MODULE_BIT 0x04000000 #define MODULE_BIT 0x04000000
@@ -15,40 +15,8 @@ status_t GET_ACCELERANT_DEVICE_INFO(accelerant_device_info * adi)
/* no info on version is provided, so presumably this is for my info */ /* no info on version is provided, so presumably this is for my info */
adi->version = 1; adi->version = 1;
sprintf(adi->name, "Neomagic chipset"); sprintf(adi->name, si->adi.name);
switch (si->ps.card_type) sprintf(adi->chipset, si->adi.chipset);
{
case NM2070:
sprintf(adi->chipset, "MagicGraph NM2070");
break;
case NM2090:
sprintf(adi->chipset, "MagicGraph NM2090");
break;
case NM2093:
sprintf(adi->chipset, "MagicGraph NM2093");
break;
case NM2097:
sprintf(adi->chipset, "MagicGraph NM2097");
break;
case NM2160:
sprintf(adi->chipset, "MagicGraph NM2160");
break;
case NM2200:
sprintf(adi->chipset, "MagicMedia NM2200");
break;
case NM2230:
sprintf(adi->chipset, "MagicMedia NM2230");
break;
case NM2360:
sprintf(adi->chipset, "MagicMedia NM2360");
break;
case NM2380:
sprintf(adi->chipset, "MagicMedia NM2380");
break;
default:
sprintf(adi->chipset, "unknown");
break;
}
sprintf(adi->serial_no, "unknown"); sprintf(adi->serial_no, "unknown");
adi->memory = (si->ps.memory_size * 1024); adi->memory = (si->ps.memory_size * 1024);
adi->dac_speed = si->ps.max_dac1_clock; adi->dac_speed = si->ps.max_dac1_clock;
@@ -3,7 +3,7 @@
This file may be used under the terms of the Be Sample Code License. This file may be used under the terms of the Be Sample Code License.
Other authors: Other authors:
Rudolf Cornelissen 4/2003-8/2003 Rudolf Cornelissen 4/2003-1/2006
*/ */
#define MODULE_BIT 0x02000000 #define MODULE_BIT 0x02000000
@@ -86,7 +86,10 @@ status_t GET_PIXEL_CLOCK_LIMITS(display_mode *dm, uint32 *low, uint32 *high)
/* Return the semaphore id that will be used to signal a vertical sync occured. */ /* Return the semaphore id that will be used to signal a vertical sync occured. */
sem_id ACCELERANT_RETRACE_SEMAPHORE(void) sem_id ACCELERANT_RETRACE_SEMAPHORE(void)
{ {
// return si->vblank; if (si->ps.int_assigned)
// return si->vblank;
//temp: //temp:
return B_ERROR; return B_ERROR;
else
return B_ERROR;
} }
@@ -4,7 +4,7 @@
Other authors: Other authors:
Mark Watson, Mark Watson,
Rudolf Cornelissen 10/2002-11/2004. Rudolf Cornelissen 10/2002-1/2006.
*/ */
#define MODULE_BIT 0x00800000 #define MODULE_BIT 0x00800000
@@ -16,7 +16,8 @@
static status_t init_common(int the_fd); static status_t init_common(int the_fd);
/* Initialization code shared between primary and cloned accelerants */ /* Initialization code shared between primary and cloned accelerants */
static status_t init_common(int the_fd) { static status_t init_common(int the_fd)
{
status_t result; status_t result;
nm_get_private_data gpd; nm_get_private_data gpd;
@@ -100,7 +101,8 @@ error0:
} }
/* Clean up code shared between primary and cloned accelrants */ /* Clean up code shared between primary and cloned accelrants */
static void uninit_common(void) { static void uninit_common(void)
{
/* release the memory mapped registers if they exist */ /* release the memory mapped registers if they exist */
if (si->ps.card_type > NM2093) if (si->ps.card_type > NM2093)
{ {
@@ -123,7 +125,8 @@ We need to determine if the kernel driver and the accelerant are compatible.
If they are, get the accelerant ready to handle other hook functions and If they are, get the accelerant ready to handle other hook functions and
report success or failure. report success or failure.
*/ */
status_t INIT_ACCELERANT(int the_fd) { status_t INIT_ACCELERANT(int the_fd)
{
status_t result; status_t result;
int cnt; //used for iteration through the overlay buffers int cnt; //used for iteration through the overlay buffers
@@ -142,7 +145,14 @@ status_t INIT_ACCELERANT(int the_fd) {
/* bail out if the common initialization failed */ /* bail out if the common initialization failed */
if (result != B_OK) goto error0; if (result != B_OK) goto error0;
// LOG now available: !NULL si // LOG now available: !NULL si
/* ensure that INIT_ACCELERANT is executed just once (copies should be clones) */
if (si->accelerant_in_use)
{
result = B_NOT_ALLOWED;
goto error1;
}
/* call the device specific init code */ /* call the device specific init code */
result = nm_general_powerup(); result = nm_general_powerup();
@@ -211,6 +221,8 @@ status_t INIT_ACCELERANT(int the_fd) {
/* a winner! */ /* a winner! */
result = B_OK; result = B_OK;
/* ensure that INIT_ACCELERANT won't be executed again (copies should be clones) */
si->accelerant_in_use = true;
goto error0; goto error0;
error1: error1:
@@ -228,7 +240,8 @@ error0:
Return the number of bytes required to hold the information required Return the number of bytes required to hold the information required
to clone the device. to clone the device.
*/ */
ssize_t ACCELERANT_CLONE_INFO_SIZE(void) { ssize_t ACCELERANT_CLONE_INFO_SIZE(void)
{
/* /*
Since we're passing the name of the device as the only required Since we're passing the name of the device as the only required
info, return the size of the name buffer info, return the size of the name buffer
@@ -241,7 +254,8 @@ ssize_t ACCELERANT_CLONE_INFO_SIZE(void) {
Return the info required to clone the device. void *data points to Return the info required to clone the device. void *data points to
a buffer at least ACCELERANT_CLONE_INFO_SIZE() bytes in length. a buffer at least ACCELERANT_CLONE_INFO_SIZE() bytes in length.
*/ */
void GET_ACCELERANT_CLONE_INFO(void *data) { void GET_ACCELERANT_CLONE_INFO(void *data)
{
nm_device_name dn; nm_device_name dn;
status_t result; status_t result;
@@ -256,7 +270,8 @@ void GET_ACCELERANT_CLONE_INFO(void *data) {
Initialize a copy of the accelerant as a clone. void *data points to Initialize a copy of the accelerant as a clone. void *data points to
a copy of the data returned by GET_ACCELERANT_CLONE_INFO(). a copy of the data returned by GET_ACCELERANT_CLONE_INFO().
*/ */
status_t CLONE_ACCELERANT(void *data) { status_t CLONE_ACCELERANT(void *data)
{
status_t result; status_t result;
char path[MAXPATHLEN]; char path[MAXPATHLEN];
@@ -291,6 +306,13 @@ status_t CLONE_ACCELERANT(void *data) {
/* bail out if the common initialization failed */ /* bail out if the common initialization failed */
if (result != B_OK) goto error1; if (result != B_OK) goto error1;
/* ensure that INIT_ACCELERANT is executed first (i.e. primary accelerant exists) */
if (!(si->accelerant_in_use))
{
result = B_NOT_ALLOWED;
goto error2;
}
/* get shared area for display modes */ /* get shared area for display modes */
result = my_mode_list_area = clone_area( result = my_mode_list_area = clone_area(
DRIVER_PREFIX " cloned display_modes", DRIVER_PREFIX " cloned display_modes",
@@ -330,6 +352,9 @@ void UNINIT_ACCELERANT(void)
/* delete benaphores ONLY if we are the primary accelerant */ /* delete benaphores ONLY if we are the primary accelerant */
DELETE_BEN(si->engine.lock); DELETE_BEN(si->engine.lock);
DELETE_BEN(si->overlay.lock); DELETE_BEN(si->overlay.lock);
/* ensure that INIT_ACCELERANT can be executed again */
si->accelerant_in_use = false;
} }
/* free our mode list area */ /* free our mode list area */
@@ -3,7 +3,7 @@
This file may be used under the terms of the Be Sample Code License. This file may be used under the terms of the Be Sample Code License.
Other authors for nm driver: Other authors for nm driver:
Rudolf Cornelissen 4/2003-11/2005 Rudolf Cornelissen 4/2003-1/2006
*/ */
#define MODULE_BIT 0x00400000 #define MODULE_BIT 0x00400000
@@ -274,7 +274,7 @@ status_t PROPOSE_DISPLAY_MODE(display_mode *target, const display_mode *low, con
//fixme: introduce dualhead_clone_only flag compatible with matrox so the same prefs //fixme: introduce dualhead_clone_only flag compatible with matrox so the same prefs
//util can be used //util can be used
target->flags &= target->flags &=
~(DUALHEAD_CAPABLE | TV_CAPABLE | B_SUPPORTS_OVERLAYS | B_IO_FB_NA); ~(DUALHEAD_CAPABLE | TV_CAPABLE | B_SUPPORTS_OVERLAYS | B_HARDWARE_CURSOR | B_IO_FB_NA);
/* we always allow parallel access (fixed), the DAC is always in 'enhanced' /* we always allow parallel access (fixed), the DAC is always in 'enhanced'
* mode (fixed), and all modes support DPMS (fixed); * mode (fixed), and all modes support DPMS (fixed);
* We support scrolling and panning in every mode, so we 'send a signal' to * We support scrolling and panning in every mode, so we 'send a signal' to
@@ -283,6 +283,21 @@ status_t PROPOSE_DISPLAY_MODE(display_mode *target, const display_mode *low, con
* BDirectWindow windowed modes. */ * BDirectWindow windowed modes. */
target->flags |= (B_PARALLEL_ACCESS | B_8_BIT_DAC | B_DPMS | B_SCROLL); target->flags |= (B_PARALLEL_ACCESS | B_8_BIT_DAC | B_DPMS | B_SCROLL);
/* if not dualhead capable card clear dualhead flags */
if (!(target->flags & DUALHEAD_CAPABLE))
{
target->flags &= ~DUALHEAD_BITS;
}
/* if not TVout capable card clear TVout flags */
if (!(target->flags & TV_CAPABLE))
{
target->flags &= ~TV_BITS;
}
/* TVout is on primary head (presumably, if we'd have that) */
target->flags |= TV_PRIMARY;
/* set HARDWARE_CURSOR mode if suitable */ /* set HARDWARE_CURSOR mode if suitable */
if (si->settings.hardcursor) if (si->settings.hardcursor)
target->flags |= B_HARDWARE_CURSOR; target->flags |= B_HARDWARE_CURSOR;
@@ -291,7 +306,7 @@ status_t PROPOSE_DISPLAY_MODE(display_mode *target, const display_mode *low, con
if (si->ps.card_type > NM2070) if (si->ps.card_type > NM2070)
target->flags |= B_SUPPORTS_OVERLAYS; target->flags |= B_SUPPORTS_OVERLAYS;
LOG(1, ("PROPOSEMODE: validated status modeflags: $%08x\n", target->flags)); LOG(1, ("PROPOSEMODE: validated modeflags: $%08x\n", target->flags));
/* overrule timing command flags to be (fixed) blank_pedestal = 0.0IRE, /* overrule timing command flags to be (fixed) blank_pedestal = 0.0IRE,
* progressive scan (fixed), and sync_on_green not used */ * progressive scan (fixed), and sync_on_green not used */
@@ -3,7 +3,7 @@
This file may be used under the terms of the Be Sample Code License. This file may be used under the terms of the Be Sample Code License.
Other authors: Other authors:
Rudolf Cornelissen 4/2003-6/2004 Rudolf Cornelissen 4/2003-1/2006
*/ */
#define MODULE_BIT 0x00200000 #define MODULE_BIT 0x00200000
@@ -14,15 +14,19 @@
Enable/Disable interrupts. Just a wrapper around the Enable/Disable interrupts. Just a wrapper around the
ioctl() to the kernel driver. ioctl() to the kernel driver.
*/ */
static void interrupt_enable(bool flag) { static void interrupt_enable(bool flag)
{
status_t result; status_t result;
nm_set_bool_state sbs; nm_set_bool_state sbs;
/* set the magic number so the driver knows we're for real */ if (si->ps.int_assigned)
sbs.magic = NM_PRIVATE_DATA_MAGIC; {
sbs.do_it = flag; /* set the magic number so the driver knows we're for real */
/* contact driver and get a pointer to the registers and shared data */ sbs.magic = NM_PRIVATE_DATA_MAGIC;
result = ioctl(fd, NM_RUN_INTERRUPTS, &sbs, sizeof(sbs)); sbs.do_it = flag;
/* contact driver and get a pointer to the registers and shared data */
result = ioctl(fd, NM_RUN_INTERRUPTS, &sbs, sizeof(sbs));
}
} }
/* First validate the mode, then call lots of bit banging stuff to set the mode(s)! */ /* First validate the mode, then call lots of bit banging stuff to set the mode(s)! */
@@ -49,6 +49,8 @@ static status_t nm_acc_wait_fifo(uint32 n)
/* snooze a bit so I do not hammer the bus */ /* snooze a bit so I do not hammer the bus */
snooze (10); snooze (10);
} }
return B_OK;
} }
/* AFAIK this must be done for every new screenmode. /* AFAIK this must be done for every new screenmode.
@@ -1,5 +1,5 @@
/* Author: /* Author:
Rudolf Cornelissen 4/2003-11/2004 Rudolf Cornelissen 4/2003-1/2006
*/ */
#define MODULE_BIT 0x00008000 #define MODULE_BIT 0x00008000
@@ -88,46 +88,64 @@ status_t nm_general_powerup()
{ {
status_t status; status_t status;
LOG(1,("POWERUP: Haiku Neomagic Accelerant 0.11 running.\n")); LOG(1,("POWERUP: Haiku Neomagic Accelerant 0.12 running.\n"));
/* log VBLANK INT usability status */
if (si->ps.int_assigned)
LOG(4,("POWERUP: Usable INT assigned to HW; Vblank semaphore enabled\n"));
else
LOG(4,("POWERUP: No (usable) INT assigned to HW; Vblank semaphore disabled\n"));
/* WARNING:
* _adi.name_ and _adi.chipset_ can contain 31 readable characters max.!!! */
/* detect card type and power it up */ /* detect card type and power it up */
switch(CFGR(DEVID)) switch(CFGR(DEVID))
{ {
case 0x000110c8: //NM2070 ISA case 0x000110c8: //NM2070 ISA
si->ps.card_type = NM2070; si->ps.card_type = NM2070;
LOG(4,("POWERUP: Detected MagicGraph 128 (NM2070)\n")); sprintf(si->adi.name, "Neomagic MagicGraph 128");
sprintf(si->adi.chipset, "NM2070 (ISA)");
break; break;
case 0x000210c8: //NM2090 ISA case 0x000210c8: //NM2090 ISA
si->ps.card_type = NM2090; si->ps.card_type = NM2090;
LOG(4,("POWERUP: Detected MagicGraph 128V (NM2090)\n")); sprintf(si->adi.name, "Neomagic MagicGraph 128V");
sprintf(si->adi.chipset, "NM2090 (ISA)");
break; break;
case 0x000310c8: //NM2093 ISA case 0x000310c8: //NM2093 ISA
si->ps.card_type = NM2093; si->ps.card_type = NM2093;
LOG(4,("POWERUP: Detected MagicGraph 128ZV (NM2093)\n")); sprintf(si->adi.name, "Neomagic MagicGraph 128ZV");
sprintf(si->adi.chipset, "NM2093 (ISA)");
break; break;
case 0x008310c8: //NM2097 PCI case 0x008310c8: //NM2097 PCI
si->ps.card_type = NM2097; si->ps.card_type = NM2097;
LOG(4,("POWERUP: Detected MagicGraph 128ZV+ (NM2097)\n")); sprintf(si->adi.name, "Neomagic MagicGraph 128ZV+");
sprintf(si->adi.chipset, "NM2097 (PCI)");
break; break;
case 0x000410c8: //NM2160 PCI case 0x000410c8: //NM2160 PCI
si->ps.card_type = NM2160; si->ps.card_type = NM2160;
LOG(4,("POWERUP: Detected MagicGraph 128XD (NM2160)\n")); sprintf(si->adi.name, "Neomagic MagicGraph 128XD");
sprintf(si->adi.chipset, "NM2160 (PCI)");
break; break;
case 0x000510c8: //NM2200 case 0x000510c8: //NM2200
si->ps.card_type = NM2200; si->ps.card_type = NM2200;
LOG(4,("POWERUP: Detected MagicMedia 256AV (NM2200)\n")); sprintf(si->adi.name, "Neomagic MagicMedia 256AV");
sprintf(si->adi.chipset, "NM2200");
break; break;
case 0x002510c8: //NM2230 case 0x002510c8: //NM2230
si->ps.card_type = NM2230; si->ps.card_type = NM2230;
LOG(4,("POWERUP: Detected MagicMedia 256AV+ (NM2230)\n")); sprintf(si->adi.name, "Neomagic MagicMedia 256AV+");
sprintf(si->adi.chipset, "NM2230");
break; break;
case 0x000610c8: //NM2360 case 0x000610c8: //NM2360
si->ps.card_type = NM2360; si->ps.card_type = NM2360;
LOG(4,("POWERUP: Detected MagicMedia 256ZX (NM2360)\n")); sprintf(si->adi.name, "Neomagic MagicMedia 256ZX");
sprintf(si->adi.chipset, "NM2360");
break; break;
case 0x001610c8: //NM2380 case 0x001610c8: //NM2380
si->ps.card_type = NM2380; si->ps.card_type = NM2380;
LOG(4,("POWERUP: Detected MagicMedia 256XL+ (NM2380)\n")); sprintf(si->adi.name, "Neomagic MagicMedia 256XL+");
sprintf(si->adi.chipset, "NM2380");
break; break;
default: default:
LOG(8,("POWERUP: Failed to detect valid card 0x%08x\n",CFGR(DEVID))); LOG(8,("POWERUP: Failed to detect valid card 0x%08x\n",CFGR(DEVID)));
@@ -204,6 +222,7 @@ static status_t nmxxxx_general_powerup()
// status_t result; // status_t result;
LOG(4, ("INIT: powerup\n")); LOG(4, ("INIT: powerup\n"));
LOG(4, ("INIT: Detected %s (%s)\n", si->adi.name, si->adi.chipset));
if (si->settings.logmask & 0x80000000) nm_dump_configuration_space(); if (si->settings.logmask & 0x80000000) nm_dump_configuration_space();
/* set ISA registermapping to VGA colormode */ /* set ISA registermapping to VGA colormode */