accel updates: add BCM support, add scale blit, fix mem alloc
authorFelix Domke <tmbinc@elitedvb.net>
Wed, 3 Jun 2009 12:49:24 +0000 (14:49 +0200)
committerFelix Domke <tmbinc@elitedvb.net>
Wed, 3 Jun 2009 12:57:50 +0000 (14:57 +0200)
lib/gdi/accel.cpp
lib/gdi/accel.h

index d9c80e2ea82cf17b12eec2723ed92ec6c623511b..f1ffe193502d6847a1ffb31b7df1db857abc2420 100644 (file)
@@ -9,7 +9,9 @@
 #include <lib/gdi/gpixmap.h>
 
 gAccel *gAccel::instance;
 #include <lib/gdi/gpixmap.h>
 
 gAccel *gAccel::instance;
+// #define BCM_ACCEL
 
 
+#ifdef ATI_ACCEL
 extern int ati_accel_init(void);
 extern void ati_accel_close(void);
 extern void ati_accel_blit(
 extern int ati_accel_init(void);
 extern void ati_accel_close(void);
 extern void ati_accel_blit(
@@ -21,6 +23,20 @@ extern void ati_accel_fill(
                int dst_addr, int dst_width, int dst_height, int dst_stride,
                int x, int y, int width, int height,
                unsigned long color);
                int dst_addr, int dst_width, int dst_height, int dst_stride,
                int x, int y, int width, int height,
                unsigned long color);
+#endif
+#ifdef BCM_ACCEL
+extern int bcm_accel_init(void);
+extern void bcm_accel_close(void);
+extern void bcm_accel_blit(
+               int src_addr, int src_width, int src_height, int src_stride,
+               int dst_addr, int dst_width, int dst_height, int dst_stride,
+               int src_x, int src_y, int width, int height,
+               int dst_x, int dst_y, int dwidth, int dheight);
+extern void bcm_accel_fill(
+               int dst_addr, int dst_width, int dst_height, int dst_stride,
+               int x, int y, int width, int height,
+               unsigned long color);
+#endif
 
 gAccel::gAccel()
 {
 
 gAccel::gAccel()
 {
@@ -33,12 +49,18 @@ gAccel::gAccel()
 #ifdef ATI_ACCEL       
        ati_accel_init();
 #endif
 #ifdef ATI_ACCEL       
        ati_accel_init();
 #endif
+#ifdef BCM_ACCEL       
+       bcm_accel_init();
+#endif
 }
 
 gAccel::~gAccel()
 {
 #ifdef ATI_ACCEL
        ati_accel_close();
 }
 
 gAccel::~gAccel()
 {
 #ifdef ATI_ACCEL
        ati_accel_close();
+#endif
+#ifdef BCM_ACCEL
+       bcm_accel_close();
 #endif
        instance = 0;
 }
 #endif
        instance = 0;
 }
@@ -62,7 +84,7 @@ void gAccel::setAccelMemorySpace(void *addr, int phys_addr, int size)
        m_accel_phys_addr = phys_addr;
 }
 
        m_accel_phys_addr = phys_addr;
 }
 
-int gAccel::blit(gSurface *dst, const gSurface *src, const ePoint &p, const eRect &area, int flags)
+int gAccel::blit(gSurface *dst, const gSurface *src, const eRect &p, const eRect &area, int flags)
 {
 #ifdef ATI_ACCEL
        ati_accel_blit(
 {
 #ifdef ATI_ACCEL
        ati_accel_blit(
@@ -71,6 +93,14 @@ int gAccel::blit(gSurface *dst, const gSurface *src, const ePoint &p, const eRec
                area.left(), area.top(), area.width(), area.height(),
                p.x(), p.y());
        return 0;
                area.left(), area.top(), area.width(), area.height(),
                p.x(), p.y());
        return 0;
+#endif
+#ifdef BCM_ACCEL
+       bcm_accel_blit(
+               src->data_phys, src->x, src->y, src->stride,
+               dst->data_phys, dst->x, dst->y, dst->stride, 
+               area.left(), area.top(), area.width(), area.height(),
+               p.x(), p.y(), p.width(), p.height());
+       return 0;
 #endif
        return -1;
 }
 #endif
        return -1;
 }
@@ -83,12 +113,20 @@ int gAccel::fill(gSurface *dst, const eRect &area, unsigned long col)
                area.left(), area.top(), area.width(), area.height(),
                col);
        return 0;
                area.left(), area.top(), area.width(), area.height(),
                col);
        return 0;
+#endif
+#if 0 // def BCM_ACCEL
+       bcm_accel_fill(
+               dst->data_phys, dst->x, dst->y, dst->stride, 
+               area.left(), area.top(), area.width(), area.height(),
+               col);
+       return 0;
 #endif
        return -1;
 }
 
 int gAccel::accelAlloc(void *&addr, int &phys_addr, int size)
 {
 #endif
        return -1;
 }
 
 int gAccel::accelAlloc(void *&addr, int &phys_addr, int size)
 {
+       eDebug("accel %d bytes", size);
        if ((!size) || (!m_accel_allocation))
        {
                eDebug("size: %d, alloc %p", size, m_accel_allocation);
        if ((!size) || (!m_accel_allocation))
        {
                eDebug("size: %d, alloc %p", size, m_accel_allocation);
@@ -99,6 +137,21 @@ int gAccel::accelAlloc(void *&addr, int &phys_addr, int size)
        
        size += 4095; size >>= 12;
        int i;
        
        size += 4095; size >>= 12;
        int i;
+       
+       int used = 0, free = 0, s = 0;
+       for (i=0; i < m_accel_size; ++i)
+       {
+               if (m_accel_allocation[i] == 0)
+                       free++;
+               else if (m_accel_allocation[i] == -1)
+                       used++;
+               else
+               {
+                       used++;
+                       s += m_accel_allocation[i];
+               }
+       }
+       eDebug("accel memstat: used=%d kB, free %d kB, s %d kB", used * 4, free * 4, s * 4);
 
        for (i=0; i < m_accel_size - size; ++i)
        {
 
        for (i=0; i < m_accel_size - size; ++i)
        {
@@ -108,7 +161,7 @@ int gAccel::accelAlloc(void *&addr, int &phys_addr, int size)
                                break;
                if (a == size)
                {
                                break;
                if (a == size)
                {
-                       m_accel_allocation[i+a] = size;
+                       m_accel_allocation[i] = size;
                        for (a=1; a<size; ++a)
                                m_accel_allocation[i+a] = -1;
                        addr = ((unsigned char*)m_accel_addr) + (i << 12);
                        for (a=1; a<size; ++a)
                                m_accel_allocation[i+a] = -1;
                        addr = ((unsigned char*)m_accel_addr) + (i << 12);
@@ -116,6 +169,7 @@ int gAccel::accelAlloc(void *&addr, int &phys_addr, int size)
                        return 0;
                }
        }
                        return 0;
                }
        }
+       eDebug("accel alloc failed\n");
        return -1;
 }
 
        return -1;
 }
 
index 63d3bf306209aca01529c82b74e94fd1430aac81..b08ba6610defb44c83f1188b350a9cde7fc8deda 100644 (file)
@@ -14,7 +14,7 @@ public:
        
        void setAccelMemorySpace(void *addr, int phys_addr, int size);
        
        
        void setAccelMemorySpace(void *addr, int phys_addr, int size);
        
-       int blit(gSurface *dst, const gSurface *src, const ePoint &p, const eRect &area, int flags);
+       int blit(gSurface *dst, const gSurface *src, const eRect &p, const eRect &area, int flags);
        int fill(gSurface *dst, const eRect &area, unsigned long col);
        
        int accelAlloc(void *&addr, int &phys_addr, int size);
        int fill(gSurface *dst, const eRect &area, unsigned long col);
        
        int accelAlloc(void *&addr, int &phys_addr, int size);