diff --git a/src/add-ons/accelerants/neomagic/GetDeviceInfo.c b/src/add-ons/accelerants/neomagic/GetDeviceInfo.c index 31dd29734d..5d4ee47aa8 100644 --- a/src/add-ons/accelerants/neomagic/GetDeviceInfo.c +++ b/src/add-ons/accelerants/neomagic/GetDeviceInfo.c @@ -1,6 +1,6 @@ /* Author: - Rudolf Cornelissen 11/2004 + Rudolf Cornelissen 1/2006 */ #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 */ adi->version = 1; - sprintf(adi->name, "Neomagic chipset"); - switch (si->ps.card_type) - { - 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->name, si->adi.name); + sprintf(adi->chipset, si->adi.chipset); sprintf(adi->serial_no, "unknown"); adi->memory = (si->ps.memory_size * 1024); adi->dac_speed = si->ps.max_dac1_clock; diff --git a/src/add-ons/accelerants/neomagic/GetModeInfo.c b/src/add-ons/accelerants/neomagic/GetModeInfo.c index 65318b7464..bc0a9bb048 100644 --- a/src/add-ons/accelerants/neomagic/GetModeInfo.c +++ b/src/add-ons/accelerants/neomagic/GetModeInfo.c @@ -3,7 +3,7 @@ This file may be used under the terms of the Be Sample Code License. Other authors: - Rudolf Cornelissen 4/2003-8/2003 + Rudolf Cornelissen 4/2003-1/2006 */ #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. */ sem_id ACCELERANT_RETRACE_SEMAPHORE(void) { -// return si->vblank; + if (si->ps.int_assigned) +// return si->vblank; //temp: - return B_ERROR; + return B_ERROR; + else + return B_ERROR; } diff --git a/src/add-ons/accelerants/neomagic/InitAccelerant.c b/src/add-ons/accelerants/neomagic/InitAccelerant.c index c034d68c6e..532fd3ba25 100644 --- a/src/add-ons/accelerants/neomagic/InitAccelerant.c +++ b/src/add-ons/accelerants/neomagic/InitAccelerant.c @@ -4,7 +4,7 @@ Other authors: Mark Watson, - Rudolf Cornelissen 10/2002-11/2004. + Rudolf Cornelissen 10/2002-1/2006. */ #define MODULE_BIT 0x00800000 @@ -16,7 +16,8 @@ static status_t init_common(int the_fd); /* 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; nm_get_private_data gpd; @@ -100,7 +101,8 @@ error0: } /* 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 */ 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 report success or failure. */ -status_t INIT_ACCELERANT(int the_fd) { +status_t INIT_ACCELERANT(int the_fd) +{ status_t result; 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 */ if (result != B_OK) goto error0; // 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 */ result = nm_general_powerup(); @@ -211,6 +221,8 @@ status_t INIT_ACCELERANT(int the_fd) { /* a winner! */ result = B_OK; + /* ensure that INIT_ACCELERANT won't be executed again (copies should be clones) */ + si->accelerant_in_use = true; goto error0; error1: @@ -228,7 +240,8 @@ error0: Return the number of bytes required to hold the information required 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 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 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; 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 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; char path[MAXPATHLEN]; @@ -291,6 +306,13 @@ status_t CLONE_ACCELERANT(void *data) { /* bail out if the common initialization failed */ 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 */ result = my_mode_list_area = clone_area( DRIVER_PREFIX " cloned display_modes", @@ -330,6 +352,9 @@ void UNINIT_ACCELERANT(void) /* delete benaphores ONLY if we are the primary accelerant */ DELETE_BEN(si->engine.lock); DELETE_BEN(si->overlay.lock); + + /* ensure that INIT_ACCELERANT can be executed again */ + si->accelerant_in_use = false; } /* free our mode list area */ diff --git a/src/add-ons/accelerants/neomagic/ProposeDisplayMode.c b/src/add-ons/accelerants/neomagic/ProposeDisplayMode.c index a510938bf8..fdea8f1217 100644 --- a/src/add-ons/accelerants/neomagic/ProposeDisplayMode.c +++ b/src/add-ons/accelerants/neomagic/ProposeDisplayMode.c @@ -3,7 +3,7 @@ This file may be used under the terms of the Be Sample Code License. Other authors for nm driver: - Rudolf Cornelissen 4/2003-11/2005 + Rudolf Cornelissen 4/2003-1/2006 */ #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 //util can be used 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' * mode (fixed), and all modes support DPMS (fixed); * 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. */ 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 */ if (si->settings.hardcursor) 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) 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, * progressive scan (fixed), and sync_on_green not used */ diff --git a/src/add-ons/accelerants/neomagic/SetDisplayMode.c b/src/add-ons/accelerants/neomagic/SetDisplayMode.c index c58476cb42..3650e648e4 100644 --- a/src/add-ons/accelerants/neomagic/SetDisplayMode.c +++ b/src/add-ons/accelerants/neomagic/SetDisplayMode.c @@ -3,7 +3,7 @@ This file may be used under the terms of the Be Sample Code License. Other authors: - Rudolf Cornelissen 4/2003-6/2004 + Rudolf Cornelissen 4/2003-1/2006 */ #define MODULE_BIT 0x00200000 @@ -14,15 +14,19 @@ Enable/Disable interrupts. Just a wrapper around the ioctl() to the kernel driver. */ -static void interrupt_enable(bool flag) { +static void interrupt_enable(bool flag) +{ status_t result; nm_set_bool_state sbs; - /* set the magic number so the driver knows we're for real */ - sbs.magic = NM_PRIVATE_DATA_MAGIC; - 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)); + if (si->ps.int_assigned) + { + /* set the magic number so the driver knows we're for real */ + sbs.magic = NM_PRIVATE_DATA_MAGIC; + 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)! */ diff --git a/src/add-ons/accelerants/neomagic/engine/nm_acc.c b/src/add-ons/accelerants/neomagic/engine/nm_acc.c index 91e06e69ea..b15404c154 100644 --- a/src/add-ons/accelerants/neomagic/engine/nm_acc.c +++ b/src/add-ons/accelerants/neomagic/engine/nm_acc.c @@ -49,6 +49,8 @@ static status_t nm_acc_wait_fifo(uint32 n) /* snooze a bit so I do not hammer the bus */ snooze (10); } + + return B_OK; } /* AFAIK this must be done for every new screenmode. diff --git a/src/add-ons/accelerants/neomagic/engine/nm_general.c b/src/add-ons/accelerants/neomagic/engine/nm_general.c index 8695b56219..d9d0e040c9 100644 --- a/src/add-ons/accelerants/neomagic/engine/nm_general.c +++ b/src/add-ons/accelerants/neomagic/engine/nm_general.c @@ -1,5 +1,5 @@ /* Author: - Rudolf Cornelissen 4/2003-11/2004 + Rudolf Cornelissen 4/2003-1/2006 */ #define MODULE_BIT 0x00008000 @@ -88,46 +88,64 @@ status_t nm_general_powerup() { 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 */ switch(CFGR(DEVID)) { case 0x000110c8: //NM2070 ISA 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; case 0x000210c8: //NM2090 ISA 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; case 0x000310c8: //NM2093 ISA 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; case 0x008310c8: //NM2097 PCI 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; case 0x000410c8: //NM2160 PCI 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; case 0x000510c8: //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; case 0x002510c8: //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; case 0x000610c8: //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; case 0x001610c8: //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; default: 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; 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(); /* set ISA registermapping to VGA colormode */