On Thu, 2001-12-20 at 22:56, Denis Oliver Kropp wrote:
> Great work, a friend has an i810 on-board and I hope to test it this weekend.
> I had a quick look at the attached source, looks clean. There's only one
> thing so far that needs to be changed. SetState is called before operations
> if 'state->modified' is non-zero or if 'state->set' does not contain the bit
> passed via 'accel'. So you should clear the bit in 'state->modified' after
> programming the specific entry. In addition you should OR the 'accel'
> into 'state->set'. These changes will affect the performance of the driver.
>
Thanks for pointing that out. I did actually wonder why a lot of state
variables are being repeatedly called when nothing has really changed
:) I did not give it a second thought though.
Anyway here's the patch I made. It also includes fixes where variables
that should belong to DriverData were in DeviceData.
Thanks!
Tony
--- i810-orig.c Thu Dec 20 11:05:56 2001
+++ i810.c Thu Dec 20 17:07:21 2001
@@ -1,4 +1,4 @@
-/*
+/*
(c) Copyright 2000 convergence integrated media GmbH.
All rights reserved.
@@ -53,7 +53,7 @@
(DSDRAW_NOFX)
#define I810_SUPPORTED_DRAWINGFUNCTIONS \
- (DFXL_DRAWRECTANGLE | DFXL_FILLRECTANGLE)
+ (DFXL_DRAWRECTANGLE | DFXL_FILLRECTANGLE)
#define I810_SUPPORTED_BLITTINGFLAGS \
(DSBLIT_SRC_COLORKEY | DSBLIT_DST_COLORKEY)
@@ -63,9 +63,11 @@
typedef struct {
- int srcaddr, destaddr, srcpitch, destpitch;
- int color_value, pixeldepth, blit_color;
- int colorkey_bit, colorkey;
+ /* state validation */
+ int i_src;
+ int i_dst;
+ int i_color;
+ int i_colorkey;
} I810DeviceData;
typedef struct {
@@ -76,6 +78,9 @@
u32 *dma_buffer;
u32 *pattern_buffer;
i810_command cmd;
+ int srcaddr, destaddr, srcpitch, destpitch;
+ int color_value, pixeldepth, blit_color;
+ int colorkey_bit, colorkey;
} I810DriverData;
/*
@@ -138,74 +143,91 @@
/*
* Set State routines
*/
-static void i810_set_source(I810DriverData *i810drv,
- I810DeviceData *i810dev,
- CardState *state)
+static inline void i810_set_source(I810DriverData *i810drv,
+ I810DeviceData *i810dev,
+ CardState *state)
{
CoreSurface *source = state->source;
- SurfaceBuffer *buffer = source->front_buffer;
+ SurfaceBuffer *buffer = source->front_buffer;
- i810dev->srcaddr = gfxcard_memory_physical(buffer->video.offset);
- i810dev->srcpitch = buffer->video.pitch;
+ if (i810dev->i_src)
+ return;
+ i810drv->srcaddr = gfxcard_memory_physical(buffer->video.offset);
+ i810drv->srcpitch = buffer->video.pitch;
+
+ i810dev->i_src = 1;
}
-static void i810_set_destination(I810DriverData *i810drv,
- I810DeviceData *i810dev,
- CardState *state)
+static inline void i810_set_destination(I810DriverData *i810drv,
+ I810DeviceData *i810dev,
+ CardState *state)
{
CoreSurface *destination = state->destination;
SurfaceBuffer *buffer = destination->back_buffer;
- i810dev->destaddr = gfxcard_memory_physical(buffer->video.offset);
- i810dev->destpitch = buffer->video.pitch;
+ if (i810dev->i_dst)
+ return;
+ i810drv->destaddr = gfxcard_memory_physical(buffer->video.offset);
+ i810drv->destpitch = buffer->video.pitch;
+ i810dev->i_dst = 1;
}
-static void i810_set_colorkey(I810DriverData *i810drv,
- I810DeviceData *i810dev,
- CardState *state)
+static inline void i810_set_colorkey(I810DriverData *i810drv,
+ I810DeviceData *i810dev,
+ CardState *state)
{
+ if (i810dev->i_colorkey)
+ return;
+
+ i810drv->colorkey_bit = 0;
if (state->blittingflags & DSBLIT_SRC_COLORKEY) {
- i810dev->colorkey_bit = 1 << 8;
- i810dev->colorkey = state->src_colorkey;
+ i810drv->colorkey_bit = 1 << 8;
+ i810drv->colorkey = state->src_colorkey;
}
else {
- i810dev->colorkey_bit = 7 << 8;
- i810dev->colorkey = state->dst_colorkey;
+ i810drv->colorkey_bit = 7 << 8;
+ i810drv->colorkey = state->dst_colorkey;
}
-
+
+ i810dev->i_colorkey = 1;
}
-static void i810_set_color(I810DriverData *i810drv,
- I810DeviceData *i810dev,
- CardState *state)
+static inline void i810_set_color(I810DriverData *i810drv,
+ I810DeviceData *i810dev,
+ CardState *state)
{
+ if (i810dev->i_color)
+ return;
+
switch (state->destination->format) {
case DSPF_RGB15:
- i810dev->color_value = PIXEL_RGB15(state->color.r,
+ i810drv->color_value = PIXEL_RGB15(state->color.r,
state->color.g,
state->color.b);
- i810dev->pixeldepth = 2;
- i810dev->blit_color = BPP16;
+ i810drv->pixeldepth = 2;
+ i810drv->blit_color = BPP16;
break;
case DSPF_RGB16:
- i810dev->color_value = PIXEL_RGB16(state->color.r,
+ i810drv->color_value = PIXEL_RGB16(state->color.r,
state->color.g,
state->color.b);
- i810dev->pixeldepth = 2;
- i810dev->blit_color = BPP16;
+ i810drv->pixeldepth = 2;
+ i810drv->blit_color = BPP16;
break;
case DSPF_RGB24:
- i810dev->color_value = PIXEL_RGB24(state->color.r,
+ i810drv->color_value = PIXEL_RGB24(state->color.r,
state->color.g,
state->color.b);
- i810dev->pixeldepth = 3;
- i810dev->blit_color = BPP24;
+ i810drv->pixeldepth = 3;
+ i810drv->blit_color = BPP24;
break;
default:
BUG("unexpected pixelformat~");
}
+ i810dev->i_color = 1;
+
}
static void i810CheckState(void *drv, void *dev,
@@ -245,34 +267,53 @@
if (state->modified) {
if ((state->modified & SMF_SOURCE) && state->source)
- i810_set_source( i810drv, i810dev, state);
+ i810dev->i_src = 0;
if (state->modified & SMF_DESTINATION)
- i810_set_destination(i810drv, i810dev, state);
+ i810dev->i_dst = 0;
if (state->modified & SMF_COLOR)
- i810_set_color(i810drv, i810dev, state);
- if (state->modified & SMF_BLITTING_FLAGS) {
- i810dev->colorkey_bit = 0;
- if (state->blittingflags & (DSBLIT_SRC_COLORKEY |
DSBLIT_DST_COLORKEY))
- i810_set_colorkey(i810drv, i810dev, state);
+ i810dev->i_color = 0;
+ if (state->modified & SMF_SRC_COLORKEY ||
+ state->modified & SMF_DST_COLORKEY) {
+ i810dev->i_colorkey = 0;
}
}
+
+ switch (accel) {
+ case DFXL_FILLRECTANGLE:
+ case DFXL_DRAWRECTANGLE:
+ i810_set_destination(i810drv, i810dev, state);
+ i810_set_color(i810drv, i810dev, state);
+ state->set |= DFXL_FILLRECTANGLE | DFXL_DRAWRECTANGLE;
+ break;
+ case DFXL_BLIT:
+ i810_set_source( i810drv, i810dev, state);
+ i810_set_destination(i810drv, i810dev, state);
+ i810_set_color(i810drv, i810dev, state);
+ if (state->blittingflags & DSBLIT_SRC_COLORKEY ||
+ state->blittingflags & DSBLIT_DST_COLORKEY)
+ i810_set_colorkey(i810drv, i810dev, state);
+ state->set |= DFXL_BLIT;
+ break;
+ default:
+ BUG("unexpected drawing/blitting function");
+ }
+ state->modified = 0;
}
static void i810FillRectangle( void *drv, void *dev, DFBRectangle *rect )
{
I810DriverData *i810drv = (I810DriverData *) drv;
- I810DeviceData *i810dev = (I810DeviceData *) dev;
int dest;
- rect->x *= i810dev->pixeldepth;
- rect->w *= i810dev->pixeldepth;
- dest = i810dev->destaddr + rect->x + (rect->y * i810dev->destpitch);
+ rect->x *= i810drv->pixeldepth;
+ rect->w *= i810drv->pixeldepth;
+ dest = i810drv->destaddr + rect->x + (rect->y * i810drv->destpitch);
i810drv->dma_buffer[0] = BLIT | COLOR_BLT | 3;
- i810drv->dma_buffer[1] = COLOR_COPY_ROP << 16 | i810dev->destpitch |
SOLIDPATTERN;
+ i810drv->dma_buffer[1] = COLOR_COPY_ROP << 16 | i810drv->destpitch |
+SOLIDPATTERN;
i810drv->dma_buffer[2] = rect->h << 16 | rect->w;
i810drv->dma_buffer[3] = dest;
- i810drv->dma_buffer[4] = i810dev->color_value;
+ i810drv->dma_buffer[4] = i810drv->color_value;
i810drv->cmd.dma_cmd_start = 0;
i810drv->cmd.dma_cmd_dsize = 5;
@@ -284,43 +325,42 @@
static void i810DrawRectangle( void *drv, void *dev, DFBRectangle *rect )
{
I810DriverData *i810drv = (I810DriverData *) drv;
- I810DeviceData *i810dev = (I810DeviceData *) dev;
u32 dest;
- rect->x *= i810dev->pixeldepth;
- rect->w *= i810dev->pixeldepth;
+ rect->x *= i810drv->pixeldepth;
+ rect->w *= i810drv->pixeldepth;
/* horizontal line 1 */
- dest = i810dev->destaddr + rect->x + (rect->y * i810dev->destpitch);
+ dest = i810drv->destaddr + rect->x + (rect->y * i810drv->destpitch);
i810drv->dma_buffer[0] = BLIT | COLOR_BLT | 3;
- i810drv->dma_buffer[1] = COLOR_COPY_ROP << 16 | i810dev->destpitch |
SOLIDPATTERN;
+ i810drv->dma_buffer[1] = COLOR_COPY_ROP << 16 | i810drv->destpitch |
+SOLIDPATTERN;
i810drv->dma_buffer[2] = 1 << 16 | rect->w;
i810drv->dma_buffer[3] = dest;
- i810drv->dma_buffer[4] = i810dev->color_value;
+ i810drv->dma_buffer[4] = i810drv->color_value;
/* vertical line 2 */
dest += rect->w;
i810drv->dma_buffer[5] = BLIT | COLOR_BLT | 3;
- i810drv->dma_buffer[6] = COLOR_COPY_ROP << 16 | i810dev->destpitch |
SOLIDPATTERN;
- i810drv->dma_buffer[7] = rect->h << 16 | i810dev->pixeldepth;
+ i810drv->dma_buffer[6] = COLOR_COPY_ROP << 16 | i810drv->destpitch |
+SOLIDPATTERN;
+ i810drv->dma_buffer[7] = rect->h << 16 | i810drv->pixeldepth;
i810drv->dma_buffer[8] = dest;
- i810drv->dma_buffer[9] = i810dev->color_value;
+ i810drv->dma_buffer[9] = i810drv->color_value;
/* vertical line 1 */
dest -= rect->w;
i810drv->dma_buffer[10] = BLIT | COLOR_BLT | 3;
- i810drv->dma_buffer[11] = COLOR_COPY_ROP << 16 | i810dev->destpitch |
SOLIDPATTERN;
- i810drv->dma_buffer[12] = rect->h << 16 | i810dev->pixeldepth;
+ i810drv->dma_buffer[11] = COLOR_COPY_ROP << 16 | i810drv->destpitch |
+SOLIDPATTERN;
+ i810drv->dma_buffer[12] = rect->h << 16 | i810drv->pixeldepth;
i810drv->dma_buffer[13] = dest;
- i810drv->dma_buffer[14] = i810dev->color_value;
+ i810drv->dma_buffer[14] = i810drv->color_value;
/* horizontal line 2 */
- dest += rect->h * i810dev->destpitch;
+ dest += rect->h * i810drv->destpitch;
i810drv->dma_buffer[15] = BLIT | COLOR_BLT | 3;
- i810drv->dma_buffer[16] = COLOR_COPY_ROP << 16 | i810dev->destpitch |
SOLIDPATTERN;
+ i810drv->dma_buffer[16] = COLOR_COPY_ROP << 16 | i810drv->destpitch |
+SOLIDPATTERN;
i810drv->dma_buffer[17] = 1 << 16 | rect->w;
i810drv->dma_buffer[18] = dest;
- i810drv->dma_buffer[19] = i810dev->color_value;
+ i810drv->dma_buffer[19] = i810drv->color_value;
i810drv->cmd.dma_cmd_start = 0;
i810drv->cmd.dma_cmd_dsize = 20;
@@ -332,41 +372,40 @@
static void i810Blit( void *drv, void *dev, DFBRectangle *rect, int dx, int dy )
{
I810DriverData *i810drv = (I810DriverData *) drv;
- I810DeviceData *i810dev = (I810DeviceData *) dev;
int xdir = INCREMENT, spitch = 0, dpitch = 0, src, dest;
- rect->x *= i810dev->pixeldepth;
- dx *= i810dev->pixeldepth;
- rect->w *= i810dev->pixeldepth;
-
- src = i810dev->srcaddr + rect->x + (rect->y * i810dev->srcpitch);
- dest = i810dev->destaddr + dx + (dy * i810dev->destpitch);
-
- if (i810dev->srcaddr == i810dev->destaddr) {
- spitch = i810dev->srcpitch;
- dpitch = i810dev->destpitch;
+ rect->x *= i810drv->pixeldepth;
+ dx *= i810drv->pixeldepth;
+ rect->w *= i810drv->pixeldepth;
+
+ src = i810drv->srcaddr + rect->x + (rect->y * i810drv->srcpitch);
+ dest = i810drv->destaddr + dx + (dy * i810drv->destpitch);
+
+ if (i810drv->srcaddr == i810drv->destaddr) {
+ spitch = i810drv->srcpitch;
+ dpitch = i810drv->destpitch;
if (dx > rect->x && dx < rect->x + rect->w) {
xdir = DECREMENT;
rect->x += rect->w - 1;
dx += rect->w - 1;
}
if (dy > rect->y && dy < rect->y + rect->h) {
- i810dev->srcpitch = (-(i810dev->srcpitch)) & 0xFFFF;
- i810dev->destpitch = (-(i810dev->destpitch)) & 0xFFFF;
+ i810drv->srcpitch = (-(i810drv->srcpitch)) & 0xFFFF;
+ i810drv->destpitch = (-(i810drv->destpitch)) & 0xFFFF;
rect->y += rect->h - 1;
dy += rect->h - 1;
}
- src = i810dev->srcaddr + rect->x + (rect->y * spitch);
- dest = i810dev->destaddr + dx + (dy * dpitch);
+ src = i810drv->srcaddr + rect->x + (rect->y * spitch);
+ dest = i810drv->destaddr + dx + (dy * dpitch);
}
- i810drv->dma_buffer[0] = BLIT | FULL_BLIT | 0x6 | i810dev->colorkey_bit;
- i810drv->dma_buffer[1] = xdir | PAT_COPY_ROP << 16 | i810dev->destpitch |
DYN_COLOR_EN | i810dev->blit_color;
+ i810drv->dma_buffer[0] = BLIT | FULL_BLIT | 0x6 | i810drv->colorkey_bit;
+ i810drv->dma_buffer[1] = xdir | PAT_COPY_ROP << 16 | i810drv->destpitch |
+DYN_COLOR_EN | i810drv->blit_color;
i810drv->dma_buffer[2] = (rect->h << 16) | rect->w;
i810drv->dma_buffer[3] = dest;
- i810drv->dma_buffer[4] = i810dev->srcpitch;
+ i810drv->dma_buffer[4] = i810drv->srcpitch;
i810drv->dma_buffer[5] = src;
- i810drv->dma_buffer[6] = i810dev->colorkey;
+ i810drv->dma_buffer[6] = i810drv->colorkey;
i810drv->dma_buffer[7] = i810drv->pattern.offset << 12;
i810drv->cmd.dma_cmd_start = 0;
--
Info: To unsubscribe send a mail to [EMAIL PROTECTED] with
"unsubscribe directfb-dev" as subject.