Added 400ns delay in ata_WaitBusyTO before read of device status.
[tangerine.git] / arch / common / hidd.radeon / ati_bitmap.c
blob378c512b2b5b9b242b8599f82b0acca66eb8a99c
1 /*
2 Copyright © 2004, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "ati.h"
7 #include "radeon.h"
8 #include "radeon_reg.h"
9 #include "radeon_bios.h"
10 #include "radeon_accel.h"
11 #include "radeon_macros.h"
13 #include <oop/oop.h>
14 #include <hidd/graphics.h>
15 #include <hidd/hidd.h>
17 #include <proto/oop.h>
18 #include <proto/utility.h>
20 #define DEBUG 0
21 #include <aros/debug.h>
23 #define sd ((struct ati_staticdata*)SD(cl))
25 #undef HiddPCIDeviceAttrBase
26 #undef HiddGfxAttrBase
27 #undef HiddPixFmtAttrBase
28 #undef HiddSyncAttrBase
29 #undef HiddBitMapAttrBase
30 #define HiddPCIDeviceAttrBase (sd->pciAttrBase)
31 #define HiddATIBitMapAttrBase (sd->atiBitMapAttrBase)
32 #define HiddBitMapAttrBase (sd->bitMapAttrBase)
33 #define HiddPixFmtAttrBase (sd->pixFmtAttrBase)
34 #define HiddGfxAttrBase (sd->gfxAttrBase)
35 #define HiddSyncAttrBase (sd->syncAttrBase)
37 struct pRoot_Dispose {
38 OOP_MethodID mID;
41 OOP_Object *METHOD(ATIOffBM, Root, New)
42 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Root, New))));
44 OOP_Object *METHOD(ATIOnBM, Root, New)
46 if (cl == sd->OnBMClass)
47 EnterFunc(bug("[ATIBitMap] OnBitmap::New()\n"));
48 else
49 EnterFunc(bug("[ATIBitMap] OffBitmap::New()\n"));
51 o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
52 if (o)
54 atiBitMap *bm = OOP_INST_DATA(cl, o);
56 ULONG width, height, depth;
57 UBYTE bytesPerPixel;
58 ULONG fb;
60 OOP_Object *pf;
62 InitSemaphore(&bm->bmLock);
64 D(bug("[ATIBitMap] Super called. o=%p\n", o));
66 bm->onbm = (cl == sd->OnBMClass);
68 OOP_GetAttr(o, aHidd_BitMap_Width, &width);
69 OOP_GetAttr(o, aHidd_BitMap_Height, &height);
70 OOP_GetAttr(o, aHidd_BitMap_PixFmt, (APTR)&pf);
71 OOP_GetAttr(pf, aHidd_PixFmt_Depth, &depth);
72 fb = GetTagData(aHidd_BitMap_FrameBuffer, FALSE, msg->attrList);
74 D(bug("[ATIBitmap] width=%d height=%d depth=%d\n", width, height, depth));
76 if (width == 0 || height == 0 || depth == 0)
78 bug("[ATIBitMap] size mismatch!\n");
81 if (depth <= 8)
82 bytesPerPixel = 1;
83 else if (depth <= 16)
84 bytesPerPixel = 2;
85 else
86 bytesPerPixel = 4;
88 if (fb)
90 width = 640;
91 height = 480;
92 bytesPerPixel = 4;
93 depth = 32;
96 bm->width = width;
97 bm->height = height;
98 bm->pitch = (width * bytesPerPixel + 63) & ~63;
99 bm->depth = depth;
100 bm->bpp = bytesPerPixel;
101 bm->framebuffer = AllocBitmapArea(sd, bm->width, bm->height, bm->bpp, TRUE);
102 bm->fbgfx = TRUE;
103 bm->state = NULL;
104 bm->BitMap = o;
105 bm->usecount = 0;
107 if (bm->framebuffer != -1)
109 ULONG pitch64 = ((bm->pitch)) >> 6;
111 switch(depth)
113 case 15:
114 bm->datatype = 3;
115 break;
117 case 16:
118 bm->datatype = 4;
119 break;
121 case 32:
122 bm->datatype = 6;
123 break;
126 bm->dp_gui_master_cntl =
127 ((bm->datatype << RADEON_GMC_DST_DATATYPE_SHIFT)
128 |RADEON_GMC_CLR_CMP_CNTL_DIS
129 |RADEON_GMC_DST_PITCH_OFFSET_CNTL);
131 bm->pitch_offset = ((bm->framebuffer >> 10) | (bm->pitch << 16));
133 D(bug("[ATIBitMap] PITCH_OFFSET=%08x\n", bm->pitch_offset));
136 if (cl == sd->OnBMClass)
138 if (fb && bm->framebuffer != -1)
140 bm->state = (struct CardState *)AllocPooled(sd->memPool,
141 sizeof(struct CardState));
143 bzero((APTR)(sd->Card.FrameBuffer + bm->framebuffer), 640*480*2);
145 if (bm->state)
147 LOCK_HW
149 InitMode(sd, bm->state, 640, 480, 16, 25200, bm->framebuffer,
150 640, 480,
151 656, 752, 800,
152 490, 492, 525);
154 LoadState(sd, bm->state);
155 DPMS(sd, sd->dpms);
157 RADEONEngineReset(sd);
158 RADEONEngineRestore(sd);
160 UNLOCK_HW
162 return o;
165 else if (bm->framebuffer != -1)
167 HIDDT_ModeID modeid;
168 OOP_Object *sync;
170 /* We should be able to get modeID from the bitmap */
171 OOP_GetAttr(o, aHidd_BitMap_ModeID, &modeid);
173 D(bug("[ATIBitMap] BM_ModeID=%x\n", modeid));
175 if (modeid != vHidd_ModeID_Invalid)
177 ULONG pixel;
178 ULONG hdisp, vdisp, hstart, hend, htotal, vstart, vend, vtotal;
180 /* Get Sync and PixelFormat properties */
181 struct pHidd_Gfx_GetMode __getmodemsg = {
182 modeID: modeid,
183 syncPtr: &sync,
184 pixFmtPtr: &pf,
185 }, *getmodemsg = &__getmodemsg;
187 getmodemsg->mID = OOP_GetMethodID((STRPTR)CLID_Hidd_Gfx, moHidd_Gfx_GetMode);
188 OOP_DoMethod(sd->AtiObject, (OOP_Msg)getmodemsg);
190 OOP_GetAttr(sync, aHidd_Sync_PixelClock, &pixel);
191 OOP_GetAttr(sync, aHidd_Sync_HDisp, &hdisp);
192 OOP_GetAttr(sync, aHidd_Sync_VDisp, &vdisp);
193 OOP_GetAttr(sync, aHidd_Sync_HSyncStart, &hstart);
194 OOP_GetAttr(sync, aHidd_Sync_VSyncStart, &vstart);
195 OOP_GetAttr(sync, aHidd_Sync_HSyncEnd, &hend);
196 OOP_GetAttr(sync, aHidd_Sync_VSyncEnd, &vend);
197 OOP_GetAttr(sync, aHidd_Sync_HTotal, &htotal);
198 OOP_GetAttr(sync, aHidd_Sync_VTotal, &vtotal);
200 bm->state = (struct CardState *)AllocPooled(sd->memPool,
201 sizeof(struct CardState));
203 pixel /= 1000;
205 if (bm->state)
207 LOCK_HW
209 InitMode(sd, bm->state, width, height, depth, pixel, bm->framebuffer,
210 hdisp, vdisp,
211 hstart, hend, htotal,
212 vstart, vend, vtotal);
214 LoadState(sd, bm->state);
215 DPMS(sd, sd->dpms);
217 RADEONEngineReset(sd);
218 RADEONEngineRestore(sd);
220 UNLOCK_HW
222 return o;
227 else
229 if (bm->framebuffer == -1)
231 bm->framebuffer = (IPTR)AllocMem(bm->pitch * bm->height,
232 MEMF_PUBLIC | MEMF_CLEAR);
233 bm->fbgfx = FALSE;
235 else
236 bm->fbgfx = TRUE;
238 if ((bm->framebuffer != 0xffffffff) && (bm->framebuffer != 0))
240 return o;
244 OOP_MethodID disp_mid = OOP_GetMethodID((STRPTR)IID_Root, moRoot_Dispose);
245 OOP_CoerceMethod(cl, o, (OOP_Msg) &disp_mid);
248 return NULL;
252 VOID METHOD(ATIOffBM, Root, Dispose)
253 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Root, Dispose))));
255 VOID METHOD(ATIOnBM, Root, Dispose)
257 atiBitMap *bm = OOP_INST_DATA(cl, o);
259 LOCK_BITMAP
260 LOCK_HW
261 // NVDmaKickoff(&sd->Card);
262 RADEONWaitForIdleMMIO(sd);
264 if (bm->fbgfx)
266 FreeBitmapArea(sd, bm->framebuffer, bm->width, bm->height, bm->bpp);
268 bm->framebuffer = -1;
269 bm->fbgfx = 0;
271 else
272 FreeMem((APTR)bm->framebuffer, bm->pitch * bm->height);
274 if (bm->state)
275 FreePooled(sd->memPool, bm->state, sizeof(struct CardState));
277 bm->state = NULL;
279 UNLOCK_HW
280 UNLOCK_BITMAP
282 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
286 VOID METHOD(ATIOffBM, Root, Get)
287 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Root, Get))));
289 VOID METHOD(ATIOnBM, Root, Get)
291 atiBitMap *bm = OOP_INST_DATA(cl, o);
292 ULONG idx;
294 if (IS_ATIBM_ATTR(msg->attrID, idx))
296 switch (idx)
298 case aoHidd_ATIBitMap_Drawable:
299 if (bm->fbgfx)
300 *msg->storage = bm->framebuffer + (IPTR)sd->Card.FrameBuffer;
301 else
302 *msg->storage = bm->framebuffer;
303 break;
305 default:
306 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
309 else
311 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
316 VOID METHOD(ATIOffBM, Hidd_BitMap, Clear)
317 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, Clear))));
319 VOID METHOD(ATIOnBM, Hidd_BitMap, Clear)
321 atiBitMap *bm = OOP_INST_DATA(cl, o);
323 D(bug("[ATI] Clear(%p)\n",
324 bm->framebuffer));
326 LOCK_BITMAP
328 if (bm->fbgfx)
330 LOCK_HW
331 sd->Card.Busy = TRUE;
332 bm->usecount++;
334 RADEONWaitForFifo(sd, 1);
335 OUTREG(RADEON_DST_PITCH_OFFSET, bm->pitch_offset);
337 bm->dp_gui_master_cntl_clip = (bm->dp_gui_master_cntl
338 | RADEON_GMC_BRUSH_SOLID_COLOR
339 | RADEON_GMC_SRC_DATATYPE_COLOR
340 | RADEON_ROP[GC_DRMD(vHidd_GC_DrawMode_Copy)].pattern);
342 RADEONWaitForFifo(sd, 4);
344 OUTREG(RADEON_DP_GUI_MASTER_CNTL, bm->dp_gui_master_cntl_clip);
345 OUTREG(RADEON_DP_BRUSH_FRGD_CLR, GC_BG(msg->gc));
346 OUTREG(RADEON_DP_WRITE_MASK, ~0);
347 OUTREG(RADEON_DP_CNTL, (RADEON_DST_X_LEFT_TO_RIGHT
348 | RADEON_DST_Y_TOP_TO_BOTTOM));
350 RADEONWaitForFifo(sd, 2);
352 OUTREG(RADEON_DST_Y_X, 0);
353 OUTREG(RADEON_DST_WIDTH_HEIGHT, (bm->width << 16) | bm->height);
355 UNLOCK_HW
357 else
359 ULONG *ptr = (ULONG*)bm->framebuffer;
360 ULONG val = 0;
361 int i = (bm->pitch * bm->height) >> 2;
363 switch (bm->bpp)
365 case 2:
366 val = GC_BG(msg->gc) << 16 | (GC_BG(msg->gc) & 0xffff);
367 break;
369 default:
370 val = GC_BG(msg->gc) << 16 | (GC_BG(msg->gc) & 0xffff);
371 break;
374 do { *ptr++ = val; } while(--i);
377 UNLOCK_BITMAP
380 struct pHidd_BitMap_FillRect {
381 struct pHidd_BitMap_DrawRect dr;
384 VOID METHOD(ATIOffBM, Hidd_BitMap, FillRect)
385 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, FillRect))));
387 VOID METHOD(ATIOnBM, Hidd_BitMap, FillRect)
389 OOP_Object *gc = msg->dr.gc;
390 atiBitMap *bm = OOP_INST_DATA(cl, o);
392 D(bug("[ATI] FillRect(%p, %d:%d - %d:%d)\n",
393 bm->framebuffer, msg->dr.minX, msg->dr.minY, msg->dr.maxX, msg->dr.maxY));
395 LOCK_BITMAP
397 if (bm->fbgfx)
399 LOCK_HW
400 sd->Card.Busy = TRUE;
401 bm->usecount++;
403 RADEONWaitForFifo(sd, 1);
404 OUTREG(RADEON_DST_PITCH_OFFSET, bm->pitch_offset);
406 bm->dp_gui_master_cntl_clip = (bm->dp_gui_master_cntl
407 | RADEON_GMC_BRUSH_SOLID_COLOR
408 | RADEON_GMC_SRC_DATATYPE_COLOR
409 | RADEON_ROP[GC_DRMD(gc)].pattern);
411 RADEONWaitForFifo(sd, 4);
413 OUTREG(RADEON_DP_GUI_MASTER_CNTL, bm->dp_gui_master_cntl_clip);
414 OUTREG(RADEON_DP_BRUSH_FRGD_CLR, GC_FG(gc));
415 OUTREG(RADEON_DP_WRITE_MASK, ~0);
416 OUTREG(RADEON_DP_CNTL, (RADEON_DST_X_LEFT_TO_RIGHT
417 | RADEON_DST_Y_TOP_TO_BOTTOM));
419 RADEONWaitForFifo(sd, 2);
421 OUTREG(RADEON_DST_Y_X, (msg->dr.minY << 16) | msg->dr.minX);
422 OUTREG(RADEON_DST_WIDTH_HEIGHT, ((msg->dr.maxX - msg->dr.minX + 1) << 16) | (msg->dr.maxY - msg->dr.minY + 1));
424 UNLOCK_HW
426 else
428 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
431 UNLOCK_BITMAP
436 VOID METHOD(ATIOffBM, Hidd_BitMap, DrawLine)
437 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, DrawLine))));
439 VOID METHOD(ATIOnBM, Hidd_BitMap, DrawLine)
441 OOP_Object *gc = msg->gc;
442 atiBitMap *bm = OOP_INST_DATA(cl, o);
444 D(bug("[ATI] DrawLine(%p, %d:%d - %d:%d) %08x\n",
445 bm->framebuffer, msg->x1, msg->y1, msg->x2, msg->y2,GC_FG(gc)));
447 LOCK_BITMAP
449 if ((GC_LINEPAT(gc) =! (UWORD)~0) || !bm->fbgfx)
451 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
453 else
455 LOCK_HW
456 sd->Card.Busy = TRUE;
457 bm->usecount++;
459 RADEONWaitForFifo(sd, 1);
460 OUTREG(RADEON_DST_PITCH_OFFSET, bm->pitch_offset);
462 bm->dp_gui_master_cntl_clip = (bm->dp_gui_master_cntl
463 | RADEON_GMC_BRUSH_SOLID_COLOR
464 | RADEON_GMC_SRC_DATATYPE_COLOR
465 | RADEON_ROP[GC_DRMD(gc)].pattern);
467 if (sd->Card.Type >= RV200) {
468 RADEONWaitForFifo(sd, 1);
469 OUTREG(RADEON_DST_LINE_PATCOUNT,
470 0x55 << RADEON_BRES_CNTL_SHIFT);
473 if (GC_DOCLIP(gc))
475 bm->dp_gui_master_cntl_clip |= RADEON_GMC_DST_CLIPPING;
476 UWORD x1,y1,x2,y2;
477 x1 = GC_CLIPX1(gc);
478 y1 = GC_CLIPY1(gc);
479 x2 = GC_CLIPX2(gc) + 1;
480 y2 = GC_CLIPY2(gc) + 1;
482 RADEONWaitForFifo(sd, 2);
483 OUTREG(RADEON_SC_TOP_LEFT, (y1 << 16) | x1);
484 OUTREG(RADEON_SC_BOTTOM_RIGHT, (y2 << 16) | x2);
487 RADEONWaitForFifo(sd, 3);
489 OUTREG(RADEON_DP_GUI_MASTER_CNTL, bm->dp_gui_master_cntl_clip);
490 OUTREG(RADEON_DP_BRUSH_FRGD_CLR, GC_FG(gc));
491 OUTREG(RADEON_DP_WRITE_MASK, ~0);
493 RADEONWaitForFifo(sd, 4);
495 OUTREG(RADEON_DST_LINE_START, (msg->y1 << 16) | msg->x1);
496 OUTREG(RADEON_DST_LINE_END, (msg->y2 << 16) | msg->x2);
497 OUTREG(RADEON_DST_LINE_START, (msg->y2 << 16) | msg->x2);
498 OUTREG(RADEON_DST_LINE_END, ((msg->y2+1) << 16) | (msg->x2+1));
500 UNLOCK_HW
503 UNLOCK_BITMAP
507 VOID METHOD(ATIOffBM, Hidd_BitMap, DrawRect)
508 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, DrawRect))));
510 VOID METHOD(ATIOnBM, Hidd_BitMap, DrawRect)
512 OOP_Object *gc = msg->gc;
513 atiBitMap *bm = OOP_INST_DATA(cl, o);
514 UWORD addX, addY;
516 D(bug("[ATI] DrawRect(%p, %d:%d - %d:%d)\n",
517 bm->framebuffer, msg->minX, msg->minY, msg->maxX, msg->maxY));
519 if (msg->minX == msg->maxX) addX = 1; else addX = 0;
520 if (msg->minY == msg->maxY) addY = 1; else addY = 0;
522 LOCK_BITMAP
524 if ((GC_LINEPAT(gc) =! (UWORD)~0) || !bm->fbgfx)
526 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
528 else
530 LOCK_HW
531 sd->Card.Busy = TRUE;
532 bm->usecount++;
534 RADEONWaitForFifo(sd, 1);
535 OUTREG(RADEON_DST_PITCH_OFFSET, bm->pitch_offset);
537 bm->dp_gui_master_cntl_clip = (bm->dp_gui_master_cntl
538 | RADEON_GMC_BRUSH_SOLID_COLOR
539 | RADEON_GMC_SRC_DATATYPE_COLOR
540 | RADEON_ROP[GC_DRMD(gc)].pattern);
542 if (sd->Card.Type >= RV200) {
543 RADEONWaitForFifo(sd, 1);
544 OUTREG(RADEON_DST_LINE_PATCOUNT,
545 0x55 << RADEON_BRES_CNTL_SHIFT);
548 if (GC_DOCLIP(gc))
550 bm->dp_gui_master_cntl_clip |= RADEON_GMC_DST_CLIPPING;
551 UWORD x1,y1,x2,y2;
552 x1 = GC_CLIPX1(gc);
553 y1 = GC_CLIPY1(gc);
554 x2 = GC_CLIPX2(gc) + 1;
555 y2 = GC_CLIPY2(gc) + 1;
557 RADEONWaitForFifo(sd, 2);
558 OUTREG(RADEON_SC_TOP_LEFT, (y1 << 16) | x1);
559 OUTREG(RADEON_SC_BOTTOM_RIGHT, (y2 << 16) | x2);
562 RADEONWaitForFifo(sd, 3);
564 OUTREG(RADEON_DP_GUI_MASTER_CNTL, bm->dp_gui_master_cntl_clip);
565 OUTREG(RADEON_DP_BRUSH_FRGD_CLR, GC_FG(gc));
566 OUTREG(RADEON_DP_WRITE_MASK, ~0);
568 RADEONWaitForFifo(sd, 8);
570 OUTREG(RADEON_DST_LINE_START, (msg->minY << 16) | (msg->minX & 0xffff));
571 OUTREG(RADEON_DST_LINE_END, (msg->minY << 16) | (msg->maxX & 0xffff));
573 OUTREG(RADEON_DST_LINE_START, ((msg->minY + addY) << 16) | (msg->maxX & 0xffff));
574 OUTREG(RADEON_DST_LINE_END, ((msg->maxY << 16)) | (msg->maxX & 0xffff));
576 OUTREG(RADEON_DST_LINE_START, ((msg->maxY << 16)) | ((msg->maxX - addX) & 0xffff));
577 OUTREG(RADEON_DST_LINE_END, ((msg->maxY << 16)) | ((msg->minX) & 0xffff));
579 OUTREG(RADEON_DST_LINE_START, ((msg->maxY - addY) << 16) | (msg->minX & 0xffff));
580 OUTREG(RADEON_DST_LINE_END, ((msg->minY + addY) << 16) | (msg->minX & 0xffff));
582 UNLOCK_HW
585 UNLOCK_BITMAP
589 VOID METHOD(ATIOffBM, Hidd_BitMap, DrawPolygon)
590 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, DrawPolygon))));
592 VOID METHOD(ATIOnBM, Hidd_BitMap, DrawPolygon)
594 OOP_Object *gc = msg->gc;
595 atiBitMap *bm = OOP_INST_DATA(cl, o);
596 ULONG i;
598 D(bug("[ATI] DrawPolygon(%p)\n",
599 bm->framebuffer));
601 LOCK_BITMAP
603 if ((GC_LINEPAT(gc) =! (UWORD)~0) || !bm->fbgfx)
605 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
607 else
609 LOCK_HW
610 sd->Card.Busy = TRUE;
611 bm->usecount++;
613 RADEONWaitForFifo(sd, 1);
614 OUTREG(RADEON_DST_PITCH_OFFSET, bm->pitch_offset);
616 bm->dp_gui_master_cntl_clip = (bm->dp_gui_master_cntl
617 | RADEON_GMC_BRUSH_SOLID_COLOR
618 | RADEON_GMC_SRC_DATATYPE_COLOR
619 | RADEON_ROP[GC_DRMD(gc)].pattern);
621 if (sd->Card.Type >= RV200) {
622 RADEONWaitForFifo(sd, 1);
623 OUTREG(RADEON_DST_LINE_PATCOUNT,
624 0x55 << RADEON_BRES_CNTL_SHIFT);
627 if (GC_DOCLIP(gc))
629 bm->dp_gui_master_cntl_clip |= RADEON_GMC_DST_CLIPPING;
630 UWORD x1,y1,x2,y2;
631 x1 = GC_CLIPX1(gc);
632 y1 = GC_CLIPY1(gc);
633 x2 = GC_CLIPX2(gc) + 1;
634 y2 = GC_CLIPY2(gc) + 1;
636 RADEONWaitForFifo(sd, 2);
637 OUTREG(RADEON_SC_TOP_LEFT, (y1 << 16) | x1);
638 OUTREG(RADEON_SC_BOTTOM_RIGHT, (y2 << 16) | x2);
641 RADEONWaitForFifo(sd, 3);
643 OUTREG(RADEON_DP_GUI_MASTER_CNTL, bm->dp_gui_master_cntl_clip);
644 OUTREG(RADEON_DP_BRUSH_FRGD_CLR, GC_FG(gc));
645 OUTREG(RADEON_DP_WRITE_MASK, ~0);
647 for (i = 2; i < (2 * msg->n); i+=2)
649 RADEONWaitForFifo(sd, 2);
650 OUTREG(RADEON_DST_LINE_START, (msg->coords[i-1] << 16) | msg->coords[i-2]);
651 OUTREG(RADEON_DST_LINE_END, (msg->coords[i+1] << 16) | msg->coords[i]);
654 UNLOCK_HW
657 UNLOCK_BITMAP
662 VOID METHOD(ATIOffBM, Hidd_BitMap, PutPixel)
663 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, PutPixel))));
665 VOID METHOD(ATIOnBM, Hidd_BitMap, PutPixel)
667 atiBitMap *bm = OOP_INST_DATA(cl, o);
669 LOCK_BITMAP
671 UBYTE *ptr = (UBYTE*)((IPTR)bm->framebuffer + bm->bpp * msg->x + bm->pitch * msg->y);
673 if (bm->fbgfx)
675 ptr += (IPTR)sd->Card.FrameBuffer;
676 if (sd->Card.Busy)
678 LOCK_HW
679 #warning TODO: NVSync(sd)
680 RADEONWaitForIdleMMIO(sd);
681 UNLOCK_HW
685 switch (bm->bpp)
687 case 1:
688 *ptr = msg->pixel;
689 break;
690 case 2:
691 *(UWORD*)ptr = msg->pixel;
692 break;
693 case 4:
694 *(ULONG*)ptr = msg->pixel;
695 break;
698 UNLOCK_BITMAP
702 HIDDT_Pixel METHOD(ATIOffBM, Hidd_BitMap, GetPixel)
703 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, GetPixel))));
705 HIDDT_Pixel METHOD(ATIOnBM, Hidd_BitMap, GetPixel)
707 HIDDT_Pixel pixel=0;
708 atiBitMap *bm = OOP_INST_DATA(cl, o);
710 LOCK_BITMAP
712 UBYTE *ptr = (UBYTE*)((IPTR)bm->framebuffer + bm->bpp * msg->x + bm->pitch * msg->y);
714 if (bm->fbgfx)
716 ptr += (IPTR)sd->Card.FrameBuffer;
717 if (sd->Card.Busy)
719 LOCK_HW
720 #warning TODO: NVSync(sd)
721 RADEONWaitForIdleMMIO(sd);
722 UNLOCK_HW
726 switch (bm->bpp)
728 case 1:
729 pixel = *ptr;
730 break;
731 case 2:
732 pixel = *(UWORD*)ptr;
733 break;
734 case 4:
735 pixel = *(ULONG*)ptr;
736 break;
739 UNLOCK_BITMAP
741 /* Get pen number from colortab */
742 return pixel;
746 ULONG METHOD(ATIOffBM, Hidd_BitMap, BytesPerLine)
747 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, BytesPerLine))));
749 ULONG METHOD(ATIOnBM, Hidd_BitMap, BytesPerLine)
751 atiBitMap *bm = OOP_INST_DATA(cl, o);
753 return (bm->bpp * msg->width + 255) & ~255;
757 BOOL METHOD(ATIOffBM, Hidd_BitMap, ObtainDirectAccess)
758 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, ObtainDirectAccess))));
760 BOOL METHOD(ATIOnBM, Hidd_BitMap, ObtainDirectAccess)
762 atiBitMap *bm = OOP_INST_DATA(cl, o);
763 LOCK_BITMAP
765 IPTR VideoData = bm->framebuffer;
767 if (bm->fbgfx)
769 VideoData += (IPTR)sd->Card.FrameBuffer;
770 if (sd->Card.Busy)
772 LOCK_HW
773 #warning TODO: NVSync(sd)
774 RADEONWaitForIdleMMIO(sd);
775 UNLOCK_HW
779 *msg->addressReturn = (UBYTE*)VideoData;
780 *msg->widthReturn = bm->pitch / bm->bpp;
781 *msg->heightReturn = bm->height;
782 *msg->bankSizeReturn = *msg->memSizeReturn = bm->pitch * bm->height;
784 return TRUE;
787 VOID METHOD(ATIOffBM, Hidd_BitMap, ReleaseDirectAccess)
788 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, ReleaseDirectAccess))));
790 VOID METHOD(ATIOnBM, Hidd_BitMap, ReleaseDirectAccess)
792 atiBitMap *bm = OOP_INST_DATA(cl, o);
794 UNLOCK_BITMAP
799 * Unaccelerated methods
802 VOID METHOD(ATIOffBM, Hidd_BitMap, PutImageLUT)
803 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, PutImageLUT))));
805 VOID METHOD(ATIOnBM, Hidd_BitMap, PutImageLUT)
807 atiBitMap *bm = OOP_INST_DATA(cl, o);
809 LOCK_BITMAP
811 IPTR VideoData = bm->framebuffer;
813 if (bm->fbgfx)
815 VideoData += (IPTR)sd->Card.FrameBuffer;
817 if (sd->Card.Busy)
819 LOCK_HW
820 #warning TODO: NVSync(sd)
821 RADEONWaitForIdleMMIO(sd);
822 UNLOCK_HW
826 switch(bm->bpp)
828 case 2:
830 struct pHidd_BitMap_CopyLUTMemBox16 __m = {
831 sd->mid_CopyLUTMemBox16,
832 msg->pixels,
835 (APTR)VideoData,
836 msg->x,
837 msg->y,
838 msg->width,
839 msg->height,
840 msg->modulo,
841 bm->pitch,
842 msg->pixlut
843 }, *m = &__m;
845 OOP_DoMethod(o, (OOP_Msg)m);
847 break;
849 case 4:
851 struct pHidd_BitMap_CopyLUTMemBox32 __m = {
852 sd->mid_CopyLUTMemBox32,
853 msg->pixels,
856 (APTR)VideoData,
857 msg->x,
858 msg->y,
859 msg->width,
860 msg->height,
861 msg->modulo,
862 bm->pitch,
863 msg->pixlut
864 }, *m = &__m;
866 OOP_DoMethod(o, (OOP_Msg)m);
868 break;
870 default:
871 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
872 break;
874 } /* switch(data->bytesperpix) */
876 UNLOCK_BITMAP
880 VOID METHOD(ATIOffBM, Hidd_BitMap, PutImage)
881 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, PutImage))));
883 VOID METHOD(ATIOnBM, Hidd_BitMap, PutImage)
885 atiBitMap *bm = OOP_INST_DATA(cl, o);
887 LOCK_BITMAP
889 IPTR VideoData = bm->framebuffer;
891 if (bm->fbgfx)
893 VideoData += (IPTR)sd->Card.FrameBuffer;
895 if (sd->Card.Busy)
897 LOCK_HW
898 #warning TODO: NVSync(sd)
899 RADEONWaitForIdleMMIO(sd);
900 UNLOCK_HW
904 switch(msg->pixFmt)
906 case vHidd_StdPixFmt_Native:
907 switch(bm->bpp)
909 case 1:
911 struct pHidd_BitMap_CopyMemBox8 __m = {
912 sd->mid_CopyMemBox8,
913 msg->pixels,
916 (APTR)VideoData,
917 msg->x,
918 msg->y,
919 msg->width,
920 msg->height,
921 msg->modulo,
922 bm->pitch
923 }, *m = &__m;
925 OOP_DoMethod(o, (OOP_Msg)m);
927 break;
929 case 2:
931 struct pHidd_BitMap_CopyMemBox16 __m = {
932 sd->mid_CopyMemBox16,
933 msg->pixels,
936 (APTR)VideoData,
937 msg->x,
938 msg->y,
939 msg->width,
940 msg->height,
941 msg->modulo,
942 bm->pitch
943 }, *m = &__m;
945 OOP_DoMethod(o, (OOP_Msg)m);
947 break;
949 case 4:
951 struct pHidd_BitMap_CopyMemBox32 __m = {
952 sd->mid_CopyMemBox32,
953 msg->pixels,
956 (APTR)VideoData,
957 msg->x,
958 msg->y,
959 msg->width,
960 msg->height,
961 msg->modulo,
962 bm->pitch
963 }, *m = &__m;
965 OOP_DoMethod(o, (OOP_Msg)m);
967 break;
969 } /* switch(data->bytesperpix) */
970 break;
972 case vHidd_StdPixFmt_Native32:
973 switch(bm->bpp)
975 case 1:
977 struct pHidd_BitMap_PutMem32Image8 __m = {
978 sd->mid_PutMem32Image8,
979 msg->pixels,
980 (APTR)VideoData,
981 msg->x,
982 msg->y,
983 msg->width,
984 msg->height,
985 msg->modulo,
986 bm->pitch
987 }, *m = &__m;
988 OOP_DoMethod(o, (OOP_Msg)m);
990 break;
992 case 2:
994 struct pHidd_BitMap_PutMem32Image16 __m = {
995 sd->mid_PutMem32Image16,
996 msg->pixels,
997 (APTR)VideoData,
998 msg->x,
999 msg->y,
1000 msg->width,
1001 msg->height,
1002 msg->modulo,
1003 bm->pitch
1004 }, *m = &__m;
1005 OOP_DoMethod(o, (OOP_Msg)m);
1007 break;
1009 case 4:
1011 struct pHidd_BitMap_CopyMemBox32 __m = {
1012 sd->mid_CopyMemBox32,
1013 msg->pixels,
1016 (APTR)VideoData,
1017 msg->x,
1018 msg->y,
1019 msg->width,
1020 msg->height,
1021 msg->modulo,
1022 bm->pitch
1023 }, *m = &__m;
1025 OOP_DoMethod(o, (OOP_Msg)m);
1027 break;
1029 } /* switch(data->bytesperpix) */
1030 break;
1032 default:
1033 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
1034 break;
1035 } /* switch(msg->pixFmt) */
1037 UNLOCK_BITMAP
1040 VOID METHOD(ATIOffBM, Hidd_BitMap, GetImage)
1041 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, GetImage))));
1043 VOID METHOD(ATIOnBM, Hidd_BitMap, GetImage)
1045 atiBitMap *bm = OOP_INST_DATA(cl, o);
1047 LOCK_BITMAP
1049 IPTR VideoData = bm->framebuffer;
1051 if (bm->fbgfx)
1053 VideoData += (IPTR)sd->Card.FrameBuffer;
1054 if (sd->Card.Busy)
1056 LOCK_HW
1057 #warning TODO: NVSync(sd)
1058 RADEONWaitForIdleMMIO(sd);
1059 UNLOCK_HW
1063 switch(msg->pixFmt)
1065 case vHidd_StdPixFmt_Native:
1066 switch(bm->bpp)
1068 case 1:
1070 struct pHidd_BitMap_CopyMemBox8 __m = {
1071 sd->mid_CopyMemBox8,
1072 (APTR)VideoData,
1073 msg->x,
1074 msg->y,
1075 msg->pixels,
1078 msg->width,
1079 msg->height,
1080 bm->pitch,
1081 msg->modulo
1082 }, *m = &__m;
1084 OOP_DoMethod(o, (OOP_Msg)m);
1086 break;
1088 case 2:
1090 struct pHidd_BitMap_CopyMemBox16 __m = {
1091 sd->mid_CopyMemBox16,
1092 (APTR)VideoData,
1093 msg->x,
1094 msg->y,
1095 msg->pixels,
1098 msg->width,
1099 msg->height,
1100 bm->pitch,
1101 msg->modulo
1102 }, *m = &__m;
1104 OOP_DoMethod(o, (OOP_Msg)m);
1106 break;
1108 case 4:
1110 struct pHidd_BitMap_CopyMemBox32 __m = {
1111 sd->mid_CopyMemBox32,
1112 (APTR)VideoData,
1113 msg->x,
1114 msg->y,
1115 msg->pixels,
1118 msg->width,
1119 msg->height,
1120 bm->pitch,
1121 msg->modulo
1122 }, *m = &__m;
1124 OOP_DoMethod(o, (OOP_Msg)m);
1126 break;
1128 } /* switch(data->bytesperpix) */
1129 break;
1131 case vHidd_StdPixFmt_Native32:
1132 switch(bm->bpp)
1134 case 1:
1136 struct pHidd_BitMap_GetMem32Image8 __m = {
1137 sd->mid_GetMem32Image8,
1138 (APTR)VideoData,
1139 msg->x,
1140 msg->y,
1141 msg->pixels,
1142 msg->width,
1143 msg->height,
1144 bm->pitch,
1145 msg->modulo
1146 }, *m = &__m;
1148 OOP_DoMethod(o, (OOP_Msg)m);
1150 break;
1152 case 2:
1154 struct pHidd_BitMap_GetMem32Image16 __m = {
1155 sd->mid_GetMem32Image16,
1156 (APTR)VideoData,
1157 msg->x,
1158 msg->y,
1159 msg->pixels,
1160 msg->width,
1161 msg->height,
1162 bm->pitch,
1163 msg->modulo
1164 }, *m = &__m;
1166 OOP_DoMethod(o, (OOP_Msg)m);
1168 break;
1170 case 4:
1172 struct pHidd_BitMap_CopyMemBox32 __m = {
1173 sd->mid_CopyMemBox32,
1174 (APTR)VideoData,
1175 msg->x,
1176 msg->y,
1177 msg->pixels,
1180 msg->width,
1181 msg->height,
1182 bm->pitch,
1183 msg->modulo
1184 }, *m = &__m;
1186 OOP_DoMethod(o, (OOP_Msg)m);
1188 break;
1190 } /* switch(data->bytesperpix) */
1191 break;
1193 default:
1194 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
1195 break;
1197 } /* switch(msg->pixFmt) */
1199 UNLOCK_BITMAP
1203 VOID METHOD(ATIOffBM, Hidd_BitMap, PutTemplate)
1204 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, PutTemplate))));
1206 VOID METHOD(ATIOnBM, Hidd_BitMap, PutTemplate)
1208 atiBitMap *bm = OOP_INST_DATA(cl, o);
1210 LOCK_BITMAP
1212 IPTR VideoData = bm->framebuffer;
1214 if (bm->fbgfx)
1216 VideoData += (IPTR)sd->Card.FrameBuffer;
1217 if (sd->Card.Busy)
1219 LOCK_HW
1220 #warning TODO: NVSync(sd)
1221 RADEONWaitForIdleMMIO(sd);
1222 UNLOCK_HW
1227 switch(bm->bpp)
1229 case 1:
1231 struct pHidd_BitMap_PutMemTemplate8 __m = {
1232 sd->mid_PutMemTemplate8,
1233 msg->gc,
1234 msg->template,
1235 msg->modulo,
1236 msg->srcx,
1237 (APTR)VideoData,
1238 bm->pitch,
1239 msg->x,
1240 msg->y,
1241 msg->width,
1242 msg->height,
1243 msg->inverttemplate
1244 }, *m = &__m;
1246 OOP_DoMethod(o, (OOP_Msg)m);
1248 break;
1250 case 2:
1252 struct pHidd_BitMap_PutMemTemplate16 __m = {
1253 sd->mid_PutMemTemplate16,
1254 msg->gc,
1255 msg->template,
1256 msg->modulo,
1257 msg->srcx,
1258 (APTR)VideoData,
1259 bm->pitch,
1260 msg->x,
1261 msg->y,
1262 msg->width,
1263 msg->height,
1264 msg->inverttemplate
1265 }, *m = &__m;
1267 OOP_DoMethod(o, (OOP_Msg)m);
1269 break;
1271 case 4:
1273 struct pHidd_BitMap_PutMemTemplate32 __m = {
1274 sd->mid_PutMemTemplate32,
1275 msg->gc,
1276 msg->template,
1277 msg->modulo,
1278 msg->srcx,
1279 (APTR)VideoData,
1280 bm->pitch,
1281 msg->x,
1282 msg->y,
1283 msg->width,
1284 msg->height,
1285 msg->inverttemplate
1286 }, *m = &__m;
1288 OOP_DoMethod(o, (OOP_Msg)m);
1290 break;
1291 } /* switch(bm->bpp) */
1293 UNLOCK_BITMAP
1296 VOID METHOD(ATIOffBM, Hidd_BitMap, PutPattern)
1297 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, PutPattern))));
1299 VOID METHOD(ATIOnBM, Hidd_BitMap, PutPattern)
1301 atiBitMap *bm = OOP_INST_DATA(cl, o);
1303 LOCK_BITMAP
1305 IPTR VideoData = bm->framebuffer;
1307 if (bm->fbgfx)
1309 VideoData += (IPTR)sd->Card.FrameBuffer;
1310 if (sd->Card.Busy)
1312 LOCK_HW
1313 #warning TODO: NVSync(sd)
1314 RADEONWaitForIdleMMIO(sd);
1315 UNLOCK_HW
1320 switch(bm->bpp)
1322 case 1:
1324 struct pHidd_BitMap_PutMemPattern8 __m = {
1325 sd->mid_PutMemPattern8,
1326 msg->gc,
1327 msg->pattern,
1328 msg->patternsrcx,
1329 msg->patternsrcy,
1330 msg->patternheight,
1331 msg->patterndepth,
1332 msg->patternlut,
1333 msg->invertpattern,
1334 msg->mask,
1335 msg->maskmodulo,
1336 msg->masksrcx,
1337 (APTR)VideoData,
1338 bm->pitch,
1339 msg->x,
1340 msg->y,
1341 msg->width,
1342 msg->height
1343 }, *m = &__m;
1345 OOP_DoMethod(o, (OOP_Msg)m);
1347 break;
1349 case 2:
1351 struct pHidd_BitMap_PutMemPattern16 __m = {
1352 sd->mid_PutMemPattern16,
1353 msg->gc,
1354 msg->pattern,
1355 msg->patternsrcx,
1356 msg->patternsrcy,
1357 msg->patternheight,
1358 msg->patterndepth,
1359 msg->patternlut,
1360 msg->invertpattern,
1361 msg->mask,
1362 msg->maskmodulo,
1363 msg->masksrcx,
1364 (APTR)VideoData,
1365 bm->pitch,
1366 msg->x,
1367 msg->y,
1368 msg->width,
1369 msg->height
1370 }, *m = &__m;
1372 OOP_DoMethod(o, (OOP_Msg)m);
1374 break;
1376 case 4:
1378 struct pHidd_BitMap_PutMemPattern32 __m = {
1379 sd->mid_PutMemPattern32,
1380 msg->gc,
1381 msg->pattern,
1382 msg->patternsrcx,
1383 msg->patternsrcy,
1384 msg->patternheight,
1385 msg->patterndepth,
1386 msg->patternlut,
1387 msg->invertpattern,
1388 msg->mask,
1389 msg->maskmodulo,
1390 msg->masksrcx,
1391 (APTR)VideoData,
1392 bm->pitch,
1393 msg->x,
1394 msg->y,
1395 msg->width,
1396 msg->height
1397 }, *m = &__m;
1399 OOP_DoMethod(o, (OOP_Msg)m);
1401 break;
1402 } /* switch(bm->bpp) */
1404 UNLOCK_BITMAP