summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Fredriksson <john.xj.fredriksson@stericsson.com>2011-05-13 08:27:29 +0000
committerJohn Fredriksson <john.xj.fredriksson@stericsson.com>2011-05-18 15:39:58 +0000
commite4d853338323231e1959c66281ac17a9c3884cdf (patch)
treed5ae05b4b731ecaa2d8fd337858f0410c97960c2
parent8dced85322657d9c1ae47f81ae9e4b7ca6c46832 (diff)
Remove dependency to ump and use hwmem instead.
Hwmem is used instead of ump for graphics buffers.
-rw-r--r--src/mali_dri.c16
-rw-r--r--src/mali_exa.c117
-rw-r--r--src/mali_exa.h14
-rw-r--r--src/mali_fbdev.c13
-rw-r--r--src/mali_fbdev.h4
5 files changed, 106 insertions, 58 deletions
diff --git a/src/mali_dri.c b/src/mali_dri.c
index 937fee5..0f9e104 100644
--- a/src/mali_dri.c
+++ b/src/mali_dri.c
@@ -33,9 +33,6 @@
#define IGNORE( a ) ( a = a )
-#define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
-
-
extern XF86ModuleData dri2ModuleData;
typedef struct
@@ -78,7 +75,7 @@ static DRI2Buffer2Ptr MaliDRI2CreateBuffer( DrawablePtr pDraw, unsigned int atta
if ( DRI2CanFlip( pDraw ) && fPtr->use_pageflipping && DRAWABLE_PIXMAP != pDraw->type)
{
- ump_secure_id ump_id = UMP_INVALID_SECURE_ID;
+ unsigned int secure_id = -1;
if ( (fPtr->fb_lcd_var.yres*2) > fPtr->fb_lcd_var.yres_virtual )
{
@@ -87,18 +84,18 @@ static DRI2Buffer2Ptr MaliDRI2CreateBuffer( DrawablePtr pDraw, unsigned int atta
return NULL;
}
- (void)ioctl(fPtr->fb_lcd_fd, GET_UMP_SECURE_ID, &ump_id );
+ secure_id = ioctl(fPtr->fb_lcd_fd, MCDE_GET_BUFFER_NAME_IOC, NULL);
- if ( UMP_INVALID_SECURE_ID == ump_id )
+ if ( -1 == secure_id )
{
- xf86DrvMsg( pScrn->scrnIndex, X_ERROR, "[%s:%d] failed to retrieve UMP memory handle for flipping\n", __FUNCTION__, __LINE__ );
+ xf86DrvMsg( pScrn->scrnIndex, X_ERROR, "[%s:%d] failed to retrieve HWMEM memory handle for flipping\n", __FUNCTION__, __LINE__ );
free( buffer );
free( privates );
return NULL;
}
- buffer->name = ump_id;
+ buffer->name = secure_id;
if ( DRI2BufferBackLeft == attachment )
{
@@ -179,7 +176,7 @@ static DRI2Buffer2Ptr MaliDRI2CreateBuffer( DrawablePtr pDraw, unsigned int atta
privPixmap = (PrivPixmap *)exaGetPixmapDriverPrivate( pPixmap );
buffer->pitch = pPixmap->devKind;
buffer->cpp = pPixmap->drawable.bitsPerPixel / 8;
- buffer->name = ump_secure_id_get( privPixmap->mem_info->handle );
+ buffer->name = privPixmap->mem_info->hwmem_global_name;
}
return buffer;
@@ -191,6 +188,7 @@ static void MaliDRI2DestroyBuffer( DrawablePtr pDraw, DRI2Buffer2Ptr buffer )
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
MaliPtr fPtr = MALIPTR(pScrn);
+ xf86DrvMsg( pScrn->scrnIndex, X_ERROR, "[%s:%d] DestroyBuffer\n", __FUNCTION__, __LINE__ );
if ( NULL != buffer )
{
MaliDRI2BufferPrivatePtr private = buffer->driverPrivate;
diff --git a/src/mali_exa.c b/src/mali_exa.c
index 5138e62..5d4b0df 100644
--- a/src/mali_exa.c
+++ b/src/mali_exa.c
@@ -139,7 +139,14 @@ static void maliDestroyPixmap(ScreenPtr pScreen, void *driverPriv )
IGNORE( pScreen );
if ( NULL != privPixmap->mem_info )
{
- ump_reference_release(privPixmap->mem_info->handle);
+ //xf86DrvMsg(mi.pScrn->scrnIndex, X_INFO, "Release hwmem handle: 0x%x\n", privPixmap->mem_info->hwmem_handle );
+ if (privPixmap->addr != NULL)
+ {
+ munmap(privPixmap->addr, privPixmap->mem_info->usize);
+ }
+ ioctl( (MALIPTR(xf86Screens[pScreen->myNum]))->hwmem_fd,
+ HWMEM_RELEASE_IOC,
+ privPixmap->mem_info->hwmem_alloc);
free( privPixmap->mem_info );
privPixmap->mem_info = NULL;
free( privPixmap );
@@ -165,7 +172,8 @@ static Bool maliModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int
if (pPixData == mi.fb_virt)
{
- ump_secure_id ump_id = UMP_INVALID_SECURE_ID;
+ // initialize it to -1 since this denotes an error
+ unsigned int secure_id = -1;
privPixmap->isFrameBuffer = TRUE;
@@ -186,9 +194,10 @@ static Bool maliModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int
}
/* get the secure ID for the framebuffer */
- (void)ioctl( fd_fbdev, GET_UMP_SECURE_ID, &ump_id );
+ secure_id = ioctl( fd_fbdev, MCDE_GET_BUFFER_NAME_IOC, NULL );
- if ( UMP_INVALID_SECURE_ID == ump_id)
+ // a return of -1 for secure_id denotes an error.
+ if ( -1 == secure_id)
{
free( mem_info );
privPixmap->mem_info = NULL;
@@ -197,8 +206,13 @@ static Bool maliModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int
return FALSE;
}
- mem_info->handle = ump_handle_create_from_secure_id( ump_id );
- if ( UMP_INVALID_MEMORY_HANDLE == mem_info->handle )
+ mem_info->hwmem_alloc = ioctl( MALIPTR(xf86Screens[pPixmap->drawable.pScreen->myNum])->hwmem_fd,
+ HWMEM_IMPORT_IOC,
+ secure_id);
+
+ mem_info->hwmem_global_name = secure_id;
+
+ if ( -1 == mem_info->hwmem_alloc )
{
xf86DrvMsg( mi.pScrn->scrnIndex, X_ERROR, "[%s:%d] UMP failed to create handle from secure id\n", __FUNCTION__, __LINE__);
free( mem_info );
@@ -233,8 +247,8 @@ static Bool maliModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int
return FALSE;
}
- pPixmap->devKind = ( (pPixmap->drawable.width*pPixmap->drawable.bitsPerPixel) + 7 ) / 8;
- pPixmap->devKind = MALI_ALIGN( pPixmap->devKind, 8 );
+ //pPixmap->devKind = ( (pPixmap->drawable.width*pPixmap->drawable.bitsPerPixel) + 7 ) / 8;
+ //pPixmap->devKind = MALI_ALIGN( pPixmap->devKind, 8 );
size = exaGetPixmapPitch(pPixmap) * pPixmap->drawable.height;
@@ -249,8 +263,12 @@ static Bool maliModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int
if ( mem_info && mem_info->usize != 0 )
{
- ump_reference_release(mem_info->handle);
- mem_info->handle = NULL;
+ ioctl( MALIPTR(xf86Screens[pPixmap->drawable.pScreen->myNum])->hwmem_fd,
+ HWMEM_RELEASE_IOC,
+ mem_info->hwmem_alloc);
+
+ mem_info->hwmem_alloc = 0;
+ mem_info->hwmem_global_name = 0;
memset(privPixmap, 0, sizeof(*privPixmap));
TRACE_EXIT();
@@ -274,17 +292,40 @@ static Bool maliModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int
}
}
- mem_info->handle = ump_ref_drv_allocate( size, UMP_REF_DRV_CONSTRAINT_PHYSICALLY_LINEAR );
- if ( UMP_INVALID_MEMORY_HANDLE == mem_info->handle )
+ { // Create and fill in values in struct for passing with ioctl
+ struct hwmem_alloc_request args;
+ args.size = size;
+ args.flags = HWMEM_ALLOC_CACHED;
+ args.default_access = HWMEM_ACCESS_READ | HWMEM_ACCESS_WRITE | HWMEM_ACCESS_IMPORT;
+ args.mem_type = HWMEM_MEM_CONTIGUOUS_SYS;
+ mem_info->hwmem_alloc = ioctl( MALIPTR(xf86Screens[pPixmap->drawable.pScreen->myNum])->hwmem_fd,
+ HWMEM_ALLOC_IOC,
+ &args);
+
+ if ( 0 == mem_info->hwmem_alloc )
+ {
+ xf86DrvMsg(mi.pScrn->scrnIndex, X_ERROR, "[%s:%d] failed to allocate hwmem memory (%i bytes)\n", __FUNCTION__, __LINE__, size);
+ TRACE_EXIT();
+ return FALSE;
+ }
+
+ }
+
+ mem_info->hwmem_global_name = ioctl( MALIPTR(xf86Screens[pPixmap->drawable.pScreen->myNum])->hwmem_fd,
+ HWMEM_EXPORT_IOC,
+ mem_info->hwmem_alloc);
+
+ if ( 0 == mem_info->hwmem_global_name )
{
- xf86DrvMsg(mi.pScrn->scrnIndex, X_ERROR, "[%s:%d] failed to allocate UMP memory (%i bytes)\n", __FUNCTION__, __LINE__, size);
- TRACE_EXIT();
+ xf86DrvMsg(mi.pScrn->scrnIndex, X_ERROR, "[%s:%d] failed to export global hwmem name\n", __FUNCTION__, __LINE__);
+ TRACE_EXIT();
return FALSE;
}
mem_info->usize = size;
privPixmap->mem_info = mem_info;
privPixmap->mem_info->usize = size;
+ privPixmap->addr = NULL;
privPixmap->bits_per_pixel = 16;
TRACE_EXIT();
@@ -333,11 +374,28 @@ static Bool maliPrepareAccess(PixmapPtr pPix, int index)
mem_info = privPixmap->mem_info;
- if ( NULL != mem_info )
+ if ( NULL != mem_info )
{
- if ( privPixmap->refs == 0 )
+ struct hwmem_set_domain_request args;
+ args.id = mem_info->hwmem_alloc;
+ args.domain = HWMEM_DOMAIN_CPU;
+ args.access = HWMEM_ACCESS_READ | HWMEM_ACCESS_WRITE | HWMEM_ACCESS_IMPORT;
+
+ /* using memset avoids API compatibility problems with the skip/offset field. */
+ /* skip/offset = 0; start = 0; */
+ memset(&args.region, 0, sizeof(args.region));
+ args.region.count = 1;
+ args.region.end = mem_info->usize;
+ args.region.size = mem_info->usize;
+ ioctl( MALIPTR(xf86Screens[pPix->drawable.pScreen->myNum])->hwmem_fd,
+ HWMEM_SET_DOMAIN_IOC,
+ &args);
+
+ if (!privPixmap->addr)
{
- privPixmap->addr = (unsigned long)ump_mapped_pointer_get( mem_info->handle );
+ privPixmap->addr = mmap(NULL, mem_info->usize, PROT_READ | PROT_WRITE,
+ MAP_SHARED, MALIPTR(xf86Screens[pPix->drawable.pScreen->myNum])->hwmem_fd,
+ (off_t)mem_info->hwmem_alloc);
}
}
else
@@ -347,7 +405,7 @@ static Bool maliPrepareAccess(PixmapPtr pPix, int index)
return FALSE;
}
- pPix->devPrivate.ptr = (void *)(privPixmap->addr);
+ pPix->devPrivate.ptr = privPixmap->addr;
if ( NULL == pPix->devPrivate.ptr )
{
xf86DrvMsg(mi.pScrn->scrnIndex, X_ERROR, "[%s:%d] cpu address not set\n", __FUNCTION__, __LINE__);
@@ -355,7 +413,6 @@ static Bool maliPrepareAccess(PixmapPtr pPix, int index)
return FALSE;
}
- privPixmap->refs++;
TRACE_EXIT();
return TRUE;
@@ -364,7 +421,6 @@ static Bool maliPrepareAccess(PixmapPtr pPix, int index)
static void maliFinishAccess(PixmapPtr pPix, int index)
{
PrivPixmap *privPixmap = (PrivPixmap *)exaGetPixmapDriverPrivate(pPix);
- mali_mem_info *mem_info;
TRACE_ENTER();
IGNORE( index );
@@ -381,18 +437,7 @@ static void maliFinishAccess(PixmapPtr pPix, int index)
return;
}
- mem_info = privPixmap->mem_info;
-
- if ( !privPixmap->isFrameBuffer )
- {
- if ( privPixmap->refs == 1 )
- {
- if ( NULL != mem_info ) ump_mapped_pointer_release( mem_info->handle );
- }
- }
-
pPix->devPrivate.ptr = NULL;
- privPixmap->refs--;
TRACE_EXIT();
}
@@ -478,7 +523,7 @@ Bool maliSetupExa( ScreenPtr pScreen, ExaDriverPtr exa, int xres, int yres, unsi
exa->flags = EXA_OFFSCREEN_PIXMAPS | EXA_HANDLES_PIXMAPS | EXA_SUPPORTS_PREPARE_AUX;
exa->offScreenBase = (fPtr->fb_lcd_fix.line_length*fPtr->fb_lcd_var.yres);
exa->memorySize = fPtr->fb_lcd_fix.smem_len;
- exa->pixmapOffsetAlign = 4096;
+ //exa->pixmapOffsetAlign = 4096;
exa->pixmapPitchAlign = 8;
fd_fbdev = fPtr->fb_lcd_fd;
@@ -508,14 +553,6 @@ Bool maliSetupExa( ScreenPtr pScreen, ExaDriverPtr exa, int xres, int yres, unsi
MALI_EXA_FUNC(PrepareAccess);
MALI_EXA_FUNC(FinishAccess);
- if ( UMP_OK != ump_open() )
- {
- xf86DrvMsg(mi.pScrn->scrnIndex, X_ERROR, "[%s:%d] failed to open UMP subsystem\n", __FUNCTION__, __LINE__);
- TRACE_EXIT();
- return FALSE;
- }
-
-
xf86DrvMsg(mi.pScrn->scrnIndex, X_INFO, "Mali EXA driver is loaded successfully\n");
TRACE_EXIT();
diff --git a/src/mali_exa.h b/src/mali_exa.h
index 43017fb..887851b 100644
--- a/src/mali_exa.h
+++ b/src/mali_exa.h
@@ -23,14 +23,9 @@
#ifndef _MALI_EXA_H_
#define _MALI_EXA_H_
-#include <ump/ump.h>
-#include <ump/ump_ref_drv.h>
#include "xf86.h"
#include "exa.h"
-/* Change this ioctl according to your specific UMP integration with LCD kernel driver */
-#define GET_UMP_SECURE_ID _IOWR('m', 310, unsigned int)
-
struct mali_info
{
ScrnInfoPtr pScrn;
@@ -43,17 +38,18 @@ struct mali_info
typedef struct
{
- ump_handle handle;
+ int hwmem_alloc;
+ int hwmem_global_name;
+ int bits_per_pixel;
unsigned long usize;
} mali_mem_info;
typedef struct
{
Bool isFrameBuffer;
- int refs;
- int bits_per_pixel;
- unsigned long addr;
+ void *addr;
mali_mem_info *mem_info;
+ int bits_per_pixel;
} PrivPixmap;
#endif /* _MALI_EXA_H_ */
diff --git a/src/mali_fbdev.c b/src/mali_fbdev.c
index fecbd7e..be717e7 100644
--- a/src/mali_fbdev.c
+++ b/src/mali_fbdev.c
@@ -893,6 +893,7 @@ static Bool MaliPreInit(ScrnInfoPtr pScrn, int flags)
fPtr->dri_render = DRI_NONE;
fPtr->use_pageflipping = FALSE;
fPtr->use_pageflipping_vsync = FALSE;
+ fPtr->hwmem_fd = 0;
/* open device */
if ( !MaliHWInit( pScrn, xf86FindOptionValue( fPtr->pEnt->device->options,"fbdev" ) ) ) return FALSE;
@@ -1037,6 +1038,12 @@ static Bool MaliScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **ar
else xf86DrvMsg(scrnIndex,X_ERROR,"DRI2 initialization failed\n");
}
+ if (0 == (fPtr->hwmem_fd = open("/dev/hwmem", O_RDWR)))
+ {
+ xf86DrvMsg(scrnIndex,X_ERROR,"opening of hwmem device file failed\n");
+ return FALSE;
+ }
+
if (NULL == (fPtr->fbmem = MaliHWMapVidmem(pScrn)))
{
xf86DrvMsg(scrnIndex,X_ERROR,"mapping of video memory failed\n");
@@ -1191,6 +1198,12 @@ static Bool MaliCloseScreen(int scrnIndex, ScreenPtr pScreen)
mali_drm_close_master( pScrn );
}
+ if ( fPtr->hwmem_fd )
+ {
+ close(fPtr->hwmem_fd);
+ fPtr->hwmem_fd = 0;
+ }
+
return TRUE;
}
diff --git a/src/mali_fbdev.h b/src/mali_fbdev.h
index 4ab0eda..0aaff9a 100644
--- a/src/mali_fbdev.h
+++ b/src/mali_fbdev.h
@@ -25,7 +25,10 @@
#include <linux/videodev2.h>
#include <linux/fb.h>
+#include <linux/hwmem.h>
+#include <sys/mman.h>
#include "exa.h"
+#include <video/mcde_fb.h>
#define DPMSModeOn 0
#define DPMSModeStandby 1
@@ -59,6 +62,7 @@ typedef struct {
char deviceName[64];
Bool use_pageflipping;
Bool use_pageflipping_vsync;
+ int hwmem_fd;
} MaliRec, *MaliPtr;
typedef struct {