The attached patch is an attempt at 8bpp texture support for the matrox
driver.
For some reason I was unable to load the texture LUT via ILOAD so I had to
do it with a BITBLT. So 512 bytes of video memory is reserved for that
purpose.
Unfortunately there is something wrong with the whole thing. The
resulting image is missing every other vertical line. I'm not sure if that
is due to a bug in the code or if it's supposed to look like that (I would
think not). So can someone spot a bug in the code?
Here's a screenshot of it in action:
http://www.sci.fi/~syrjala/directfb/matrox_tlut_rgb332.jpg
--
Ville Syrj�l�
[EMAIL PROTECTED]
http://www.sci.fi/~syrjala/
Index: matrox.c
===================================================================
RCS file: /cvs/directfb/DirectFB/gfxdrivers/matrox/matrox.c,v
retrieving revision 1.74
diff -u -r1.74 matrox.c
--- matrox.c 8 Jun 2004 18:51:02 -0000 1.74
+++ matrox.c 18 Sep 2004 18:26:57 -0000
@@ -48,6 +48,7 @@
#include <core/state.h>
#include <core/gfxcard.h>
#include <core/surfaces.h>
+#include <core/palette.h>
#include <gfx/util.h>
@@ -250,6 +254,10 @@
case DSPF_ARGB:
case DSPF_A8:
break;
+ case DSPF_LUT8:
+ if (DFB_BLITTING_FUNCTION( accel ))
+ return;
+ break;
default:
return;
}
@@ -298,6 +306,10 @@
case DSPF_ARGB:
case DSPF_A8:
break;
+ case DSPF_LUT8:
+ if (DFB_BLITTING_FUNCTION( accel ))
+ return;
+ break;
default:
return;
}
@@ -346,6 +358,10 @@
case DSPF_ARGB:
case DSPF_A8:
break;
+ case DSPF_LUT8:
+ if (DFB_BLITTING_FUNCTION( accel ))
+ return;
+ break;
default:
return;
}
@@ -364,6 +380,8 @@
if (MATROX_USE_TMU( state, accel )) {
/* TMU has no 32bit support */
switch (state->source->format) {
+ case DSPF_LUT8:
+ case DSPF_RGB332:
case DSPF_ARGB1555:
case DSPF_RGB16:
break;
@@ -416,6 +434,10 @@
case DSPF_RGB32:
case DSPF_ARGB:
break;
+ case DSPF_LUT8:
+ if (DFB_BLITTING_FUNCTION( accel ) || (state->drawingflags &
DSDRAW_BLEND))
+ return;
+ break;
default:
return;
}
@@ -439,9 +461,8 @@
if (state->destination->format != DSPF_I420 &&
state->destination->format != DSPF_YV12)
return;
+ case DSPF_LUT8:
case DSPF_RGB332:
- if (use_tmu)
- return;
case DSPF_ARGB1555:
case DSPF_RGB16:
case DSPF_RGB32:
@@ -497,6 +518,11 @@
case DSPF_ARGB:
case DSPF_A8:
break;
+ case DSPF_LUT8:
+ case DSPF_ALUT44:
+ if (DFB_BLITTING_FUNCTION( accel ) || (state->drawingflags &
DSDRAW_BLEND))
+ return;
+ break;
default:
return;
}
@@ -515,9 +541,8 @@
bool use_tmu = MATROX_USE_TMU( state, accel );
switch (state->source->format) {
+ case DSPF_LUT8:
case DSPF_RGB332:
- if (use_tmu)
- return;
case DSPF_ARGB1555:
case DSPF_RGB16:
case DSPF_RGB32:
@@ -1612,6 +1637,13 @@
mdev->atype_blk_rstr = (sgram || dfb_config->matrox_sgram) ? ATYPE_BLK :
ATYPE_RSTR;
+
+ if ((ret = dfb_palette_create( NULL, 256, &mdev->rgb332_palette )) != DFB_OK)
+ return ret;
+ dfb_palette_generate_rgb332_map( mdev->rgb332_palette );
+
+ mdev->tlut_offset = dfb_gfxcard_reserve_memory( device, 2 * 256 );
+
return DFB_OK;
}
Index: matrox.h
===================================================================
RCS file: /cvs/directfb/DirectFB/gfxdrivers/matrox/matrox.h,v
retrieving revision 1.33
diff -u -r1.33 matrox.h
--- matrox.h 8 Jun 2004 18:51:02 -0000 1.33
+++ matrox.h 18 Sep 2004 18:26:57 -0000
@@ -115,6 +115,8 @@
unsigned long offset;
unsigned long physical;
} fb;
+ unsigned int tlut_offset;
+ CorePalette *rgb332_palette;
} MatroxDeviceData;
typedef struct {
Index: matrox_state.c
===================================================================
RCS file: /cvs/directfb/DirectFB/gfxdrivers/matrox/matrox_state.c,v
retrieving revision 1.48
diff -u -r1.48 matrox_state.c
--- matrox_state.c 1 Jun 2004 21:49:17 -0000 1.48
+++ matrox_state.c 18 Sep 2004 18:26:58 -0000
@@ -36,6 +36,7 @@
#include <core/state.h>
#include <core/gfxcard.h>
#include <core/surfaces.h>
+#include <core/palette.h>
#include <gfx/convert.h>
#include <misc/util.h>
@@ -101,6 +102,8 @@
switch (buffer->format) {
case DSPF_A8:
+ case DSPF_ALUT44:
+ case DSPF_LUT8:
case DSPF_RGB332:
mga_out32( mmio, PW8, MACCESS );
break;
@@ -181,6 +184,16 @@
return;
switch (state->destination->format) {
+ case DSPF_ALUT44:
+ color = (state->color.a & 0xF0) | state->color_index;
+ color |= color << 8;
+ color |= color << 16;
+ break;
+ case DSPF_LUT8:
+ color = state->color_index;
+ color |= color << 8;
+ color |= color << 16;
+ break;
case DSPF_RGB332:
color = PIXEL_RGB332( state->color.r,
state->color.g,
@@ -347,6 +360,41 @@
MGA_INVALIDATE( m_drawBlend );
}
+static void matrox_tlutload( MatroxDriverData *mdrv,
+ MatroxDeviceData *mdev,
+ CardState *state,
+ CorePalette *palette )
+{
+ volatile __u8 *mmio = mdrv->mmio_base;
+ volatile __u16 *dst = dfb_gfxcard_memory_virtual( NULL, mdev->tlut_offset );
+ int i;
+
+ for (i = 0; i < palette->num_entries; i++)
+ *dst++ = PIXEL_RGB16( palette->entries[i].r,
+ palette->entries[i].g,
+ palette->entries[i].b );
+
+ mga_waitfifo( mdrv, mdev, 9 );
+ mga_out32( mmio, BLTMOD_BU32RGB | BOP_COPY | SHFTZERO |
+ SGNZERO | LINEAR | ATYPE_RSTR | OP_BITBLT, DWGCTL );
+ mga_out32( mmio, 1024, PITCH );
+ if (mdev->old_matrox) {
+ mga_out32( mmio, mdev->tlut_offset / 2, AR3 );
+ mga_out32( mmio, palette->num_entries, AR0 );
+ mga_out32( mmio, 0, YDSTORG );
+ } else {
+ mga_out32( mmio, 0, AR3 );
+ mga_out32( mmio, palette->num_entries, AR0 );
+ mga_out32( mmio, mdev->fb.offset + mdev->tlut_offset, SRCORG );
+ mga_out32( mmio, 0, DSTORG );
+ }
+ mga_out32( mmio, 0, FXBNDRY );
+ mga_out32( mmio, PW16 | TLUTLOAD, MACCESS );
+ mga_out32( mmio, palette->num_entries, YDSTLEN | EXECUTE );
+
+ state->modified |= SMF_DESTINATION;
+}
+
void matrox_validate_Source( MatroxDriverData *mdrv,
MatroxDeviceData *mdev,
CardState *state )
@@ -425,6 +473,14 @@
case DSPF_ARGB:
texctl |= TW32;
break;
+ case DSPF_LUT8:
+ matrox_tlutload( mdrv, mdev, state, surface->palette );
+ texctl |= TW8;
+ break;
+ case DSPF_RGB332:
+ matrox_tlutload( mdrv, mdev, state, mdev->rgb332_palette );
+ texctl |= TW8;
+ break;
default:
D_BUG( "unexpected pixelformat!" );
break;
Index: regs.h
===================================================================
RCS file: /cvs/directfb/DirectFB/gfxdrivers/matrox/regs.h,v
retrieving revision 1.22
diff -u -r1.22 regs.h
--- regs.h 21 May 2004 09:33:28 -0000 1.22
+++ regs.h 18 Sep 2004 18:26:58 -0000
@@ -224,6 +224,7 @@
# define ZW15 0x00000010
# define ZW24 0x00000018
# define BYPASS332 0x10000000
+# define TLUTLOAD 0x20000000
# define NODITHER 0x40000000
# define DIT555 0x80000000