46 #include <sys/types.h> 48 #include <sys/ioctl.h> 60 struct fb_var_screeninfo var;
61 struct fb_fix_screeninfo fix;
64 int width, height, stride;
69 PVR2DMEMINFO *memInfo;
70 unsigned long pageAddresses[2];
79 sprintf(name,
"/dev/fb%d", screen);
85 if (ioctl(fd, FBIOGET_VSCREENINFO, &var) < 0) {
86 perror(
"FBIOGET_VSCREENINFO");
90 if (ioctl(fd, FBIOGET_FSCREENINFO, &fix) < 0) {
91 perror(
"FBIOGET_FSCREENINFO");
97 bytesPerPixel = var.bits_per_pixel / 8;
98 stride = fix.line_length;
100 if (var.bits_per_pixel == 16) {
101 if (var.red.length == 5 && var.green.length == 6 &&
102 var.blue.length == 5 && var.red.offset == 11 &&
103 var.green.offset == 5 && var.blue.offset == 0) {
104 format = PVR2D_RGB565;
106 if (var.red.length == 4 && var.green.length == 4 &&
107 var.blue.length == 4 && var.transp.length == 4 &&
108 var.red.offset == 8 && var.green.offset == 4 &&
109 var.blue.offset == 0 && var.transp.offset == 12) {
110 format = PVR2D_ARGB4444;
112 }
else if (var.bits_per_pixel == 32) {
113 if (var.red.length == 8 && var.green.length == 8 &&
114 var.blue.length == 8 && var.transp.length == 8 &&
115 var.red.offset == 16 && var.green.offset == 8 &&
116 var.blue.offset == 0 && var.transp.offset == 24) {
117 format = PVR2D_ARGB8888;
120 if (format == PVR2D_1BPP) {
121 fprintf(stderr,
"%s: could not find a suitable PVR2D pixel format\n", name);
125 start = fix.smem_start;
126 length = var.xres_virtual * var.yres_virtual *
bytesPerPixel;
135 mapped = mmap(0, length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
136 if (!mapped || mapped == (
void *)(-1)) {
145 pageAddresses[0] = start & 0xFFFFF000;
146 pageAddresses[1] = 0;
148 (pvrQwsDisplay.
context, mapped, PVR2D_WRAPFLAG_CONTIGUOUS,
149 length, pageAddresses, &memInfo) != PVR2D_OK) {
150 munmap(mapped, length);
187 PVR2DDEVICEINFO *devs;
189 unsigned long pageAddresses[2];
190 PVR2DMEMINFO *memInfo;
191 PVR2DDISPLAYINFO displayInfo;
200 numDevs = PVR2DEnumerateDevices(0);
203 devs = (PVR2DDEVICEINFO *)malloc(
sizeof(PVR2DDEVICEINFO) * numDevs);
206 if (PVR2DEnumerateDevices(devs) != PVR2D_OK) {
210 devId = devs[0].ulDevID;
212 if (PVR2DCreateDeviceContext(devId, &pvrQwsDisplay.
context, 0) != PVR2D_OK)
216 if (PVR2DGetDeviceInfo(pvrQwsDisplay.
context, &displayInfo) == PVR2D_OK) {
217 if (displayInfo.ulMaxFlipChains > 0 && displayInfo.ulMaxBuffersInChain > 0)
228 pageAddresses[1] = 0;
232 PVR2D_WRAPFLAG_CONTIGUOUS,
234 pageAddresses, &memInfo) != PVR2D_OK) {
235 PVR2DDestroyDeviceContext(pvrQwsDisplay.
context);
240 }
else if (screen == 0) {
241 if (PVR2DGetFrameBuffer
243 PVR2D_FB_PRIMARY_SURFACE, &memInfo) != PVR2D_OK) {
244 fprintf(stderr,
"QWSWSEGL: could not get the primary framebuffer surface\n");
245 PVR2DDestroyDeviceContext(pvrQwsDisplay.
context);
258 unsigned long flipId = 0;
259 unsigned long numBuffers;
260 if (PVR2DCreateFlipChain(pvrQwsDisplay.
context, 0,
267 &stride, &flipId, &(pvrQwsDisplay.
flipChain))
270 PVR2DGetFlipChainBuffers(pvrQwsDisplay.
context,
306 PVR2DDestroyDeviceContext(pvrQwsDisplay.
context);
364 PVR2DDestroyDeviceContext(pvrQwsDisplay.
context);
366 memset(&pvrQwsDisplay, 0,
sizeof(pvrQwsDisplay));
371 return (pvrQwsDisplay.
refCount > 0);
400 drawable->
screen = screen;
429 drawable->
winId = winId;
431 drawable->
screen = screen;
433 drawable->
rect = *rect;
449 while (drawable != 0 && drawable->
winId != winId)
460 return (--(drawable->
refCount) <= 0);
477 drawable->
screen = screen;
479 drawable->
rect.
x = 0;
480 drawable->
rect.
y = 0;
497 while (current != 0 && current != drawable) {
524 return drawable->
type;
549 for (index = 0, rect = drawable->
visibleRects; index < numRects; ++index, ++rect) {
555 }
else if (rect->
x >= screenRect->
width) {
556 rect->
x = screenRect->
width;
567 }
else if (rect->
y >= screenRect->
height) {
575 if (index != indexOut)
596 if (drawable->
rect.
x != rect->
x || drawable->
rect.
y != rect->
y) {
597 drawable->
rect.
x = rect->
x;
598 drawable->
rect.
y = rect->
y;
617 *rect = drawable->
rect;
661 for (index = 0; index < numBuffers; ++
index)
674 for (index = 0; index < numBuffers; ++
index)
677 for (index = 0; index < numBuffers; ++
index) {
678 if (PVR2DMemAlloc(pvrQwsDisplay.
context,
705 for (index = 0; index < numBuffers; ++
index) {
734 PVR2DMEMINFO *buffer;
762 PVR2DPresentFlip(pvrQwsDisplay.
context, pvrQwsDisplay.
flipChain, buffer, 0);
766 pvrRects[
index].left = rect->
x;
767 pvrRects[
index].top = rect->
y;
775 PVR2DSetPresentBltProperties
777 PVR2D_PRESENT_PROPERTY_SRCSTRIDE |
778 PVR2D_PRESENT_PROPERTY_DSTSIZE |
779 PVR2D_PRESENT_PROPERTY_DSTPOS |
780 PVR2D_PRESENT_PROPERTY_CLIPRECTS,
784 numClip, pvrRects + index, 0);
785 PVR2DPresentBlt(pvrQwsDisplay.
context, buffer, 0);
787 PVR2DQueryBlitsComplete(pvrQwsDisplay.
context, buffer, 1);
792 memset(&blit, 0,
sizeof(blit));
794 blit.CopyCode = PVR2DROPcopy;
795 blit.BlitFlags = PVR2D_BLIT_DISABLE_ALL;
797 blit.pSrcMemInfo = buffer;
799 blit.SrcX = rect->
x - drawable->
rect.
x;
800 blit.SrcY = rect->
y - drawable->
rect.
y;
801 blit.SizeX = rect->
width;
802 blit.SizeY = rect->
height;
809 blit.DSizeX = rect->
width;
810 blit.DSizeY = rect->
height;
813 PVR2DBlt(pvrQwsDisplay.
context, &blit);
void pvrQwsSetGeometry(PvrQwsDrawable *drawable, const PvrQwsRect *rect)
PVR2DMEMINFO * backBuffers[PVRQWS_MAX_BACK_BUFFERS]
static int pvrQwsInitFbScreen(int screen)
int pvrQwsAllocBuffers(PvrQwsDrawable *drawable)
PvrQwsDrawable * pvrQwsCreatePixmap(int width, int height, int screen)
PVR2DMEMINFO * frameBuffer
void pvrQwsClearVisibleRegion(PvrQwsDrawable *drawable)
static mach_timebase_info_data_t info
void(* PvrQwsSwapFunction)(PvrQwsDrawable *drawable, void *userData, int repaintOnly)
PvrQwsDrawable * pvrQwsFetchWindow(long winId)
PVR2DFLIPCHAINHANDLE flipChain
PVR2DCONTEXTHANDLE context
#define PVRQWS_MAX_BACK_BUFFERS
void pvrQwsFreeBuffers(PvrQwsDrawable *drawable)
static int bytesPerPixel(QImage::Format format)
PvrQwsDisplay pvrQwsDisplay
int pvrQwsGetBuffers(PvrQwsDrawable *drawable, PVR2DMEMINFO **source, PVR2DMEMINFO **render)
int pvrQwsDisplayOpen(void)
void pvrQwsGetGeometry(PvrQwsDrawable *drawable, PvrQwsRect *rect)
#define PVRQWS_MAX_SCREENS
int pvrQwsGetStride(PvrQwsDrawable *drawable)
PvrQwsRect visibleRects[PVRQWS_MAX_VISIBLE_RECTS]
QFuture< T > mapped(const Sequence &sequence, MapFunction function)
PvrQwsDrawable * nextWinId
PvrQwsDrawable * pvrQwsCreateWindow(int screen, long winId, const PvrQwsRect *rect)
int pvrQwsReleaseWindow(PvrQwsDrawable *drawable)
void pvrQwsInvalidateBuffers(PvrQwsDrawable *drawable)
PVR2DMEMINFO * flipBuffers[PVRQWS_MAX_FLIP_BUFFERS]
static void pvrQwsDestroyDrawableForced(PvrQwsDrawable *drawable)
unsigned long screenStart
static void pvrQwsDestroyContext(void)
qreal angle(const QPointF &p1, const QPointF &p2)
void pvrQwsSetRotation(PvrQwsDrawable *drawable, int angle)
unsigned long numFlipBuffers
PvrQwsDrawableType pvrQwsGetDrawableType(PvrQwsDrawable *drawable)
PvrQwsSwapFunction swapFunction
void pvrQwsSetSwapFunction(PvrQwsDrawable *drawable, PvrQwsSwapFunction func, void *userData)
int pvrQwsSwapBuffers(PvrQwsDrawable *drawable, int repaintOnly)
#define PVRQWS_MAX_VISIBLE_RECTS
void pvrQwsSetVisibleRegion(PvrQwsDrawable *drawable, const PvrQwsRect *rects, int numRects)
PvrQwsDrawable * pvrQwsScreenWindow(int screen)
#define PVRQWS_MAX_FLIP_BUFFERS
PvrQwsScreenInfo screens[PVRQWS_MAX_SCREENS]
static int pvrQwsAddDrawable(void)
void pvrQwsDestroyDrawable(PvrQwsDrawable *drawable)
PvrQwsDrawable * screenDrawable
PvrQwsPixelFormat pvrQwsGetPixelFormat(PvrQwsDrawable *drawable)
static int pvrQwsEnsureScreen(int screen)
PvrQwsDrawable * firstWinId
int pvrQwsDisplayIsOpen(void)
int open(const char *, int,...)
void pvrQwsDisplayClose(void)
void * pvrQwsGetRenderBuffer(PvrQwsDrawable *drawable)