Greetings

I finally made my driver work. Now all the blittings,blendings,flippings are done explicitly by my gfxdriver code. To further help other people to create their own driver i will document the changes made in the directfb code that made the system work

This is a patch for the src/core/gfxcard.c (it is also attached)

--- gfxcard.c    2009-01-20 14:50:58.000000000 +0200
+++ vanilla_gfxcard.c    2009-09-02 13:12:30.000000000 +0300
@@ -720,7 +720,8 @@ dfb_gfxcard_state_check( CardState *stat
state->checked, state->accel, state->modified, state->mod_hw );

     /* Return whether the function bit is set. */
-     return !!(state->accel & accel);
+ + return !!(state->accel & accel);
}

/*
@@ -734,7 +735,7 @@ dfb_gfxcard_state_acquire( CardState *st
     CoreSurface            *dst;
     CoreSurface            *src;
     DFBGraphicsCoreShared  *shared;
-     CoreSurfaceAccessFlags  access = CSAF_GPU_WRITE;
+     CoreSurfaceAccessFlags  access = CSAF_CPU_WRITE;

     D_ASSERT( card != NULL );
     D_ASSERT( card->shared != NULL );
@@ -752,10 +753,10 @@ dfb_gfxcard_state_acquire( CardState *st
          if (state->blittingflags & (DSBLIT_BLEND_ALPHACHANNEL |
                                      DSBLIT_BLEND_COLORALPHA   |
                                      DSBLIT_DST_COLORKEY))
-               access |= CSAF_GPU_READ;
+               access |= CSAF_CPU_READ;
     }
     else if (state->drawingflags & (DSDRAW_BLEND | DSDRAW_DST_COLORKEY))
-          access |= CSAF_GPU_READ;
+          access |= CSAF_CPU_READ;

     if (DFB_BLITTING_FUNCTION(accel)) {
D_DEBUG_AT( Core_GfxState, "%s( %p, 0x%08x ) blitting %p -> %p\n", __FUNCTION__,
@@ -776,7 +777,7 @@ dfb_gfxcard_state_acquire( CardState *st
     /* if blitting... */
     if (DFB_BLITTING_FUNCTION( accel )) {
          /* ...lock source for reading */
- ret = dfb_surface_lock_buffer( src, state->from, CSAF_GPU_READ, &state->src ); + ret = dfb_surface_lock_buffer( src, state->from, CSAF_CPU_READ, &state->src );
          if (ret) {
D_DEBUG_AT( Core_Graphics, "Could not lock source for GPU access!\n" );
               dfb_surface_unlock_buffer( dst, &state->dst );
@@ -788,7 +789,7 @@ dfb_gfxcard_state_acquire( CardState *st
          /* if using a mask... */
if (state->blittingflags & (DSBLIT_SRC_MASK_ALPHA | DSBLIT_SRC_MASK_COLOR)) {
               /* ...lock source mask for reading */
- ret = dfb_surface_lock_buffer( state->source_mask, state->from, CSAF_GPU_READ, &state->src_mask ); + ret = dfb_surface_lock_buffer( state->source_mask, state->from, CSAF_CPU_READ, &state->src_mask );
               if (ret) {
D_DEBUG_AT( Core_Graphics, "Could not lock source mask for GPU access!\n" );
                    dfb_surface_unlock_buffer( src, &state->src );
@@ -1674,8 +1675,7 @@ void dfb_gfxcard_blit( DFBRectangle *rec
          return;
     }

-     if (dfb_gfxcard_state_check( state, DFXL_BLIT ) &&
-         dfb_gfxcard_state_acquire( state, DFXL_BLIT ))
+ if (dfb_gfxcard_state_check( state, DFXL_BLIT ) && dfb_gfxcard_state_acquire( state, DFXL_BLIT ))
     {
          if (!D_FLAGS_IS_SET( card->caps.flags, CCF_CLIPPING ) &&
              !D_FLAGS_IS_SET( card->caps.clip, DFXL_BLIT ))


This patch changes the way the surface data are locked during operations. More specifically it changes the access mode from CSAF_GPU_READ/WRITE to CSAF_CPU_READ/WRITE. This seems to be a must do in embedded systems that do not have a GPU but they may have some on-chip coprocessor (typical architecture for the ARM family of processors and also in AVRs and other) dedicated in video data processing. On my AVR32 port without these changes the gfxcard code was unable to aquire the card state because it failed in dfb_surface_pools_allocate.

Also such systems may not have any video dedicated RAM and use the common system memory. But in that case one should not create surfaces with the DSCAPS_SYSTEMONLY attribute set because this will result in gfxcard_state_check falling back to the generic gfxdriver software callback

Can anyone comment about the safety of this solution? Is the change sane or there maybe a chance to observe any IPC problems (deadlocks, race conditions e.t.c)


Best regards
Tasos Parisinos at sciensis dot com

--- gfxcard.c   2009-01-20 14:50:58.000000000 +0200
+++ vanilla_gfxcard.c   2009-09-02 13:12:30.000000000 +0300
@@ -720,7 +720,8 @@ dfb_gfxcard_state_check( CardState *stat
                  state->checked, state->accel, state->modified, state->mod_hw 
);
 
      /* Return whether the function bit is set. */
-     return !!(state->accel & accel);
+       
+    return !!(state->accel & accel);
 }
 
 /*
@@ -734,7 +735,7 @@ dfb_gfxcard_state_acquire( CardState *st
      CoreSurface            *dst;
      CoreSurface            *src;
      DFBGraphicsCoreShared  *shared;
-     CoreSurfaceAccessFlags  access = CSAF_GPU_WRITE;
+     CoreSurfaceAccessFlags  access = CSAF_CPU_WRITE;
 
      D_ASSERT( card != NULL );
      D_ASSERT( card->shared != NULL );
@@ -752,10 +753,10 @@ dfb_gfxcard_state_acquire( CardState *st
           if (state->blittingflags & (DSBLIT_BLEND_ALPHACHANNEL |
                                       DSBLIT_BLEND_COLORALPHA   |
                                       DSBLIT_DST_COLORKEY))
-               access |= CSAF_GPU_READ;
+               access |= CSAF_CPU_READ;
      }
      else if (state->drawingflags & (DSDRAW_BLEND | DSDRAW_DST_COLORKEY))
-          access |= CSAF_GPU_READ;
+          access |= CSAF_CPU_READ;
 
      if (DFB_BLITTING_FUNCTION(accel)) {
           D_DEBUG_AT( Core_GfxState, "%s( %p, 0x%08x )  blitting %p -> %p\n", 
__FUNCTION__,
@@ -776,7 +777,7 @@ dfb_gfxcard_state_acquire( CardState *st
      /* if blitting... */
      if (DFB_BLITTING_FUNCTION( accel )) {
           /* ...lock source for reading */
-          ret = dfb_surface_lock_buffer( src, state->from, CSAF_GPU_READ, 
&state->src );
+          ret = dfb_surface_lock_buffer( src, state->from, CSAF_CPU_READ, 
&state->src );
           if (ret) {
                D_DEBUG_AT( Core_Graphics, "Could not lock source for GPU 
access!\n" );
                dfb_surface_unlock_buffer( dst, &state->dst );
@@ -788,7 +789,7 @@ dfb_gfxcard_state_acquire( CardState *st
           /* if using a mask... */
           if (state->blittingflags & (DSBLIT_SRC_MASK_ALPHA | 
DSBLIT_SRC_MASK_COLOR)) {
                /* ...lock source mask for reading */
-               ret = dfb_surface_lock_buffer( state->source_mask, state->from, 
CSAF_GPU_READ, &state->src_mask );
+               ret = dfb_surface_lock_buffer( state->source_mask, state->from, 
CSAF_CPU_READ, &state->src_mask );
                if (ret) {
                     D_DEBUG_AT( Core_Graphics, "Could not lock source mask for 
GPU access!\n" );
                     dfb_surface_unlock_buffer( src, &state->src );
@@ -1674,8 +1675,7 @@ void dfb_gfxcard_blit( DFBRectangle *rec
           return;
      }
 
-     if (dfb_gfxcard_state_check( state, DFXL_BLIT ) &&
-         dfb_gfxcard_state_acquire( state, DFXL_BLIT ))
+                if (dfb_gfxcard_state_check( state, DFXL_BLIT ) && 
dfb_gfxcard_state_acquire( state, DFXL_BLIT ))
      {
           if (!D_FLAGS_IS_SET( card->caps.flags, CCF_CLIPPING ) &&
               !D_FLAGS_IS_SET( card->caps.clip, DFXL_BLIT ))
_______________________________________________
directfb-dev mailing list
directfb-dev@directfb.org
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev

Reply via email to