From c60b4ca00273a71a1cfcc6c04eccccc1aea35354 Mon Sep 17 00:00:00 2001 From: Rudolf Cornelissen Date: Mon, 2 Aug 2004 11:45:53 +0000 Subject: [PATCH] 2d and overlay restrictions update, 'comments doc' update git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8525 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/accelerants/neomagic/Overlay.c | 8 +- .../accelerants/neomagic/engine/nm_acc.c | 8 +- .../accelerants/neomagic/engine/nm_bes.c | 93 +++++++------------ .../accelerants/neomagic/engine/nm_general.c | 19 +--- 4 files changed, 47 insertions(+), 81 deletions(-) diff --git a/src/add-ons/accelerants/neomagic/Overlay.c b/src/add-ons/accelerants/neomagic/Overlay.c index de9c5e1b16..035aab6461 100644 --- a/src/add-ons/accelerants/neomagic/Overlay.c +++ b/src/add-ons/accelerants/neomagic/Overlay.c @@ -1,4 +1,4 @@ -/* Written by Rudolf Cornelissen 05-2002/03-2004 */ +/* Written by Rudolf Cornelissen 05-2002/08-2004 */ /* Note on 'missing features' in BeOS 5.0.3 and DANO: * BeOS needs to define more colorspaces! It would be nice if BeOS would support the FourCC 'definitions' @@ -423,11 +423,11 @@ status_t GET_OVERLAY_CONSTRAINTS } /* NeoMagic scaling restrictions */ - /* Note: NM BES does not support downscaling! */ + /* Note: official max is 8.0, and NM BES does not support downscaling! */ oc->h_scale.min = 1.0; - oc->h_scale.max = 1024/(float)(ob->width - si->overlay.myBufInfo[offset].slopspace); + oc->h_scale.max = 8.0; oc->v_scale.min = 1.0; - oc->v_scale.max = 1024/(float)ob->height; + oc->v_scale.max = 8.0; return B_OK; } diff --git a/src/add-ons/accelerants/neomagic/engine/nm_acc.c b/src/add-ons/accelerants/neomagic/engine/nm_acc.c index 1ee7e8991e..4252c9ccd3 100644 --- a/src/add-ons/accelerants/neomagic/engine/nm_acc.c +++ b/src/add-ons/accelerants/neomagic/engine/nm_acc.c @@ -1,7 +1,7 @@ /* nm Acceleration functions */ /* Author: - Rudolf Cornelissen 3/2004-7/2004. + Rudolf Cornelissen 3/2004-8/2004. */ /* @@ -170,10 +170,10 @@ status_t nm_acc_init() // so: nm_acc_wait_idle(); - /* setup engine depth and pixel pitch */ + /* setup engine depth and engine destination-pitch */ ACCW(STATUS, ((si->engine.control & 0x0000ffff) << 16)); - /* setup memory pitch */ - ACCW(2200_PITCH, + /* setup engine source-pitch */ + ACCW(2200_SRC_PITCH, ((si->fbc.bytes_per_row << 16) | (si->fbc.bytes_per_row & 0x0000ffff))); break; default: diff --git a/src/add-ons/accelerants/neomagic/engine/nm_bes.c b/src/add-ons/accelerants/neomagic/engine/nm_bes.c index f4f06cc67d..b3f0e04bad 100644 --- a/src/add-ons/accelerants/neomagic/engine/nm_bes.c +++ b/src/add-ons/accelerants/neomagic/engine/nm_bes.c @@ -1,5 +1,5 @@ /* NeoMagic Back End Scaler functions */ -/* Written by Rudolf Cornelissen 05/2002-07/2004 */ +/* Written by Rudolf Cornelissen 05/2002-08/2004 */ #define MODULE_BIT 0x00000200 @@ -197,10 +197,11 @@ status_t nm_configure_bes LOG(4,("Overlay: horizontal scaling factor is %f\n", (float)4096 / ifactor)); /* check scaling factor (and modify if needed) to be within scaling limits */ - if (((((uint32)my_ov.width) << 12) / 1024) > bi.hiscalv) + /* the upscaling limit is 8.0 (see official Neomagic specsheets) */ + if (bi.hiscalv < 0x00000200) { /* (non-inverse) factor too large, set factor to max. valid value */ - bi.hiscalv = ((((uint32)my_ov.width) << 12) / 1024); + bi.hiscalv = 0x00000200; LOG(4,("Overlay: horizontal scaling factor too large, clamping at %f\n", (float)4096 / bi.hiscalv)); } /* horizontal downscaling cannot be done by NM BES hardware */ @@ -245,8 +246,6 @@ status_t nm_configure_bes } /* take zoom into account */ bi.hsrcstv += ((uint32)my_ov.h_start) << 16; - /* AND below required by hardware */ - bi.hsrcstv &= 0x03fffffc; LOG(4,("Overlay: first hor. (sub)pixel of input bitmap contributing %f\n", bi.hsrcstv / (float)65536)); @@ -292,13 +291,6 @@ status_t nm_configure_bes LOG(4,("Overlay: last horizontal (sub)pixel of input bitmap contributing %f\n", bi.hsrcendv / (float)65536)); - /* setup horizontal source last position excluding slopspace: - * this is the last pixel that will be used for calculating interpolated pixels */ - bi.hsrclstv = ((ob->width - 1) - si->overlay.myBufInfo[offset].slopspace) << 16; - /* AND below required by hardware */ - bi.hsrclstv &= 0x03ff0000; - - /******************************************* *** setup vertical scaling and clipping *** *******************************************/ @@ -314,10 +306,11 @@ status_t nm_configure_bes bi.viscalv = ifactor; /* check scaling factor (and modify if needed) to be within scaling limits */ - if (((((uint32)my_ov.height) << 12) / 1024) > bi.viscalv) + /* the upscaling limit is 8.0 (see official Neomagic specsheets) */ + if (bi.viscalv < 0x00000200) { /* (non-inverse) factor too large, set factor to max. valid value */ - bi.viscalv = ((((uint32)my_ov.height) << 12) / 1024); + bi.viscalv = 0x00000200; LOG(4,("Overlay: vertical scaling factor too large, clamping at %f\n", (float)4096 / bi.viscalv)); } /* vertical downscaling cannot be done by NM BES hardware */ @@ -374,23 +367,15 @@ status_t nm_configure_bes /* take zoom into account */ bi.a1orgv += (my_ov.v_start * ob->bytes_per_row); bi.weight += (((uint32)my_ov.v_start) << 16); + + /* now include 'pixel precise' left clipping... + * (subpixel precision is not supported by NeoMagic cards) */ + bi.a1orgv += ((bi.hsrcstv >> 16) * 2); + /* we need to step in 4-byte (2 pixel) granularity due to the nature of yuy2 */ + bi.a1orgv &= ~0x03; LOG(4,("Overlay: 'contributing part of buffer' origin is (cardRAM offset) $%08x\n",bi.a1orgv)); LOG(4,("Overlay: first vert. (sub)pixel of input bitmap contributing %f\n", bi.weight / (float)65536)); - /* AND below is required by NM hardware. */ - /* Buffer A topleft corner of field 1 (origin)(field 1 contains our full frames) */ - bi.a1orgv &= 0x00fffff0; - - /* field 1 weight: AND below required by hardware, also make sure 'sign' is always 'positive' */ - bi.v1wghtv = bi.weight & 0x0000fffc; - - - /* setup field 1 (is our complete frame) vertical source last position. - * this is the last pixel that will be used for calculating interpolated pixels */ - bi.v1srclstv = (ob->height - 1); - /* AND below required by hardware */ - bi.v1srclstv &= 0x000003ff; - /***************************** *** log color keying info *** @@ -460,13 +445,13 @@ status_t nm_configure_bes LOG(4,("Overlay: accelerant is programming BES\n")); /* unlock card overlay sequencer registers (b5 = 1) */ PCIGRPHW(GENLOCK, (PCIGRPHR(GENLOCK) | 0x20)); - /* destination rectangle */ - PCIGRPHW(HDCOORD1L, ((bi.hcoordv >> 16) & 0xff)); - PCIGRPHW(HDCOORD2L, (bi.hcoordv & 0xff)); - PCIGRPHW(HDCOORD21H, (((bi.hcoordv >> 4) & 0xf0) | ((bi.hcoordv >> 24) & 0x0f))); - PCIGRPHW(VDCOORD1L, ((bi.vcoordv >> 16) & 0xff)); - PCIGRPHW(VDCOORD2L, (bi.vcoordv & 0xff)); - PCIGRPHW(VDCOORD21H, (((bi.vcoordv >> 4) & 0xf0) | ((bi.vcoordv >> 24) & 0x0f))); + /* destination rectangle #1 (output window position and size) */ + PCIGRPHW(HD1COORD1L, ((bi.hcoordv >> 16) & 0xff)); + PCIGRPHW(HD1COORD2L, (bi.hcoordv & 0xff)); + PCIGRPHW(HD1COORD21H, (((bi.hcoordv >> 4) & 0xf0) | ((bi.hcoordv >> 24) & 0x0f))); + PCIGRPHW(VD1COORD1L, ((bi.vcoordv >> 16) & 0xff)); + PCIGRPHW(VD1COORD2L, (bi.vcoordv & 0xff)); + PCIGRPHW(VD1COORD21H, (((bi.vcoordv >> 4) & 0xf0) | ((bi.vcoordv >> 24) & 0x0f))); /* scaling */ PCIGRPHW(XSCALEL, (bi.hiscalv & 0xff)); PCIGRPHW(XSCALEH, ((bi.hiscalv >> 8) & 0xff)); @@ -474,16 +459,11 @@ status_t nm_configure_bes PCIGRPHW(YSCALEH, ((bi.viscalv >> 8) & 0xff)); /* inputbuffer #1 origin */ /* (we don't program buffer #2 as it's unused.) */ - /* first include 'pixel precise' left clipping... - * (subpixel precision is not supported by NeoMagic cards) */ - bi.a1orgv += ((bi.hsrcstv >> 16) * 2); - /* we need to step in 4-byte (2 pixel) granularity due to the nature of yuy2 */ - bi.a1orgv &= ~0x03; - /* now setup buffer startadress and horizontal source end (minimizes used bandwidth) */ if (si->ps.card_type < NM2200) { bi.a1orgv >>= 1; /* horizontal source end does not use subpixelprecision: granularity is 8 pixels */ + /* (horizontal source end minimizes used bandwidth) */ PCIGRPHW(0xbc, (((((bi.hsrcendv >> 16) + 7) & ~8) / 8) - 1)); } else @@ -491,6 +471,7 @@ status_t nm_configure_bes /* NM2200 and later cards use bytes to define buffer pitch */ buf_pitch <<= 1; /* horizontal source end does not use subpixelprecision: granularity is 16 pixels */ + /* (horizontal source end minimizes used bandwidth) */ //fixme? divide by 16 instead of 8 (if >= NM2200 owners report trouble then use 8!) //fixme? check if overlaybuffer width should also have granularity of 16 now! PCIGRPHW(0xbc, (((((bi.hsrcendv >> 16) + 15) & ~16) / 16) - 1)); @@ -504,11 +485,8 @@ status_t nm_configure_bes /* b2 = 0: don't use horizontal mirroring (NM2160) */ /* other bits do ??? */ PCIGRPHW(0xbf, 0x02); - /* (subpixel precise) source rect clipping is not supported on NeoMagic cards; - * so we do 'pixel precise' left clipping via modification of buffer - * startadress above instead. - * (pixel precise top clipping is also done this way..) */ - //fixme: checkout real pixel precise clipping on NM2200 and later cards!!! + + /* destination rectangle #2 (output window position and size) */ /* { uint16 left = 0; @@ -516,17 +494,12 @@ status_t nm_configure_bes uint16 top = 0; uint16 bottom = 128; - left = (bi.hsrcstv >> 16); - right = (bi.hsrclstv >> 16); - top = (bi.weight >> 16); - bottom = (bi.v1srclstv >> 16); - - PCISEQW(HSCOORD1L, (left & 0xff)); - PCISEQW(HSCOORD2L, (right & 0xff)); - PCISEQW(HSCOORD21H, (((right >> 4) & 0xf0) | ((left >> 8) & 0x0f))); - PCISEQW(VSCOORD1L, (top & 0xff)); - PCISEQW(VSCOORD2L, (bottom & 0xff)); - PCISEQW(VSCOORD21H, (((bottom >> 4) & 0xf0) | ((top >> 8) & 0x0f))); + PCISEQW(HD2COORD1L, (left & 0xff)); + PCISEQW(HD2COORD2L, (right & 0xff)); + PCISEQW(HD2COORD21H, (((right >> 4) & 0xf0) | ((left >> 8) & 0x0f))); + PCISEQW(VD2COORD1L, (top & 0xff)); + PCISEQW(VD2COORD2L, (bottom & 0xff)); + PCISEQW(VD2COORD21H, (((bottom >> 4) & 0xf0) | ((top >> 8) & 0x0f))); } */ /* ??? */ @@ -537,8 +510,10 @@ status_t nm_configure_bes /* b1 = 0: disable alternating hardware buffers (NM2160) */ /* other bits do ??? */ PCISEQW(0x09, 0x11); - /* ??? */ - PCISEQW(0x0a, 0x00); + /* we don't use PCMCIA Zoomed Video port capturing, set 1:1 scale just in case */ + /* (b6-4 = Y downscale = 100%, b2-0 = X downscale = 100%; + * downscaling selectable in 12.5% steps on increasing setting by 1) */ + PCISEQW(ZVCAP_DSCAL, 0x00); /* global BES control */ PCIGRPHW(BESCTRL1, (bi.globctlv & 0xff)); PCISEQW(BESCTRL2, ((bi.globctlv >> 8) & 0xff)); diff --git a/src/add-ons/accelerants/neomagic/engine/nm_general.c b/src/add-ons/accelerants/neomagic/engine/nm_general.c index 8588a78824..ae44ca40fe 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-7/2004 + Rudolf Cornelissen 4/2003-8/2004 */ #define MODULE_BIT 0x00008000 @@ -485,8 +485,8 @@ status_t nm_general_validate_pic_size (display_mode *target, uint32 *bytes_per_r /* check if we can setup this mode with acceleration: */ *acc_mode = true; - /* NM2230 and later cards only support accelerated 24bit modes */ - if ((si->ps.card_type < NM2230) && (target->space == B_RGB24)) *acc_mode = false; + /* pre-NM2200 cards don't support accelerated 24bit modes */ + if ((si->ps.card_type < NM2200) && (target->space == B_RGB24)) *acc_mode = false; /* virtual_width */ if (si->ps.card_type == NM2070) @@ -500,17 +500,8 @@ status_t nm_general_validate_pic_size (display_mode *target, uint32 *bytes_per_r if (target->virtual_width > 1600) *acc_mode = false; } - /* virtual_height */ - if (si->ps.card_type < NM2200) - { - /* confirmed NM2070, NM2097 and NM2160 */ - if (target->virtual_height > 1024) *acc_mode = false; - } - else - { - /* fixme: needs confirmation, assuming this height will still work.. */ - if (target->virtual_height > 2048) *acc_mode = false; - } + /* virtual_height (confirmed NM2070, NM2097, NM2160 and NM2200 */ + if (target->virtual_height > 1024) *acc_mode = false; /* now check virtual_size based on CRTC constraints and modify if needed */ //fixme: checkout cardspecs here!! (NM2160 can do 8192 _bytes_ at least (in theory))