hopefully correct implementation of PutImageLUT
[cake.git] / arch / common / hidd.radeon / ati_bitmap.c
blobf2f920efcab470a25a44da69148f4427712d5aa6
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 == 24)
82 depth = 32;
84 if (depth <= 8)
85 bytesPerPixel = 1;
86 else if (depth <= 16)
87 bytesPerPixel = 2;
88 else
89 bytesPerPixel = 4;
91 if (fb)
93 width = 640;
94 height = 480;
95 bytesPerPixel = 4;
96 depth = 32;
99 bm->width = width;
100 bm->height = height;
101 bm->pitch = (width * bytesPerPixel + 63) & ~63;
102 bm->depth = depth;
103 bm->bpp = bytesPerPixel;
104 bm->framebuffer = AllocBitmapArea(sd, bm->width, bm->height, bm->bpp, TRUE);
105 bm->fbgfx = TRUE;
106 bm->state = NULL;
107 bm->BitMap = o;
108 bm->usecount = 0;
110 if (bm->framebuffer != -1)
112 ULONG pitch64 = ((bm->pitch)) >> 6;
114 switch(depth)
116 case 15:
117 bm->datatype = 3;
118 break;
120 case 16:
121 bm->datatype = 4;
122 break;
124 case 32:
125 bm->datatype = 6;
126 break;
129 bm->dp_gui_master_cntl =
130 ((bm->datatype << RADEON_GMC_DST_DATATYPE_SHIFT)
131 |RADEON_GMC_CLR_CMP_CNTL_DIS
132 |RADEON_GMC_DST_PITCH_OFFSET_CNTL);
134 bm->pitch_offset = ((bm->framebuffer >> 10) | (bm->pitch << 16));
136 D(bug("[ATIBitMap] PITCH_OFFSET=%08x\n", bm->pitch_offset));
139 if (cl == sd->OnBMClass)
141 if (fb && bm->framebuffer != -1)
143 bm->state = (struct CardState *)AllocPooled(sd->memPool,
144 sizeof(struct CardState));
146 bzero((APTR)(sd->Card.FrameBuffer + bm->framebuffer), 640*480*2);
148 if (bm->state)
150 LOCK_HW
152 InitMode(sd, bm->state, 640, 480, 16, 25200, bm->framebuffer,
153 640, 480,
154 656, 752, 800,
155 490, 492, 525);
157 LoadState(sd, bm->state);
158 //LoadState(sd, sd->poweron_state);
159 DPMS(sd, sd->dpms);
161 RADEONEngineReset(sd);
162 RADEONEngineRestore(sd);
164 UNLOCK_HW
166 return o;
169 else if (bm->framebuffer != -1)
171 HIDDT_ModeID modeid;
172 OOP_Object *sync;
174 /* We should be able to get modeID from the bitmap */
175 OOP_GetAttr(o, aHidd_BitMap_ModeID, &modeid);
177 D(bug("[ATIBitMap] BM_ModeID=%x\n", modeid));
179 if (modeid != vHidd_ModeID_Invalid)
181 ULONG pixel;
182 ULONG hdisp, vdisp, hstart, hend, htotal, vstart, vend, vtotal;
184 /* Get Sync and PixelFormat properties */
185 struct pHidd_Gfx_GetMode __getmodemsg = {
186 modeID: modeid,
187 syncPtr: &sync,
188 pixFmtPtr: &pf,
189 }, *getmodemsg = &__getmodemsg;
191 getmodemsg->mID = OOP_GetMethodID((STRPTR)CLID_Hidd_Gfx, moHidd_Gfx_GetMode);
192 OOP_DoMethod(sd->AtiObject, (OOP_Msg)getmodemsg);
194 OOP_GetAttr(sync, aHidd_Sync_PixelClock, &pixel);
195 OOP_GetAttr(sync, aHidd_Sync_HDisp, &hdisp);
196 OOP_GetAttr(sync, aHidd_Sync_VDisp, &vdisp);
197 OOP_GetAttr(sync, aHidd_Sync_HSyncStart, &hstart);
198 OOP_GetAttr(sync, aHidd_Sync_VSyncStart, &vstart);
199 OOP_GetAttr(sync, aHidd_Sync_HSyncEnd, &hend);
200 OOP_GetAttr(sync, aHidd_Sync_VSyncEnd, &vend);
201 OOP_GetAttr(sync, aHidd_Sync_HTotal, &htotal);
202 OOP_GetAttr(sync, aHidd_Sync_VTotal, &vtotal);
204 bm->state = (struct CardState *)AllocPooled(sd->memPool,
205 sizeof(struct CardState));
207 pixel /= 1000;
209 if (bm->state)
211 LOCK_HW
213 InitMode(sd, bm->state, width, height, depth, pixel, bm->framebuffer,
214 hdisp, vdisp,
215 hstart, hend, htotal,
216 vstart, vend, vtotal);
218 LoadState(sd, bm->state);
219 DPMS(sd, sd->dpms);
221 RADEONEngineReset(sd);
222 RADEONEngineRestore(sd);
224 UNLOCK_HW
226 return o;
231 else
233 if (bm->framebuffer == -1)
235 bm->framebuffer = (IPTR)AllocMem(bm->pitch * bm->height,
236 MEMF_PUBLIC | MEMF_CLEAR);
237 bm->fbgfx = FALSE;
239 else
240 bm->fbgfx = TRUE;
242 if ((bm->framebuffer != 0xffffffff) && (bm->framebuffer != 0))
244 return o;
248 OOP_MethodID disp_mid = OOP_GetMethodID((STRPTR)IID_Root, moRoot_Dispose);
249 OOP_CoerceMethod(cl, o, (OOP_Msg) &disp_mid);
252 return NULL;
256 VOID METHOD(ATIOffBM, Root, Dispose)
257 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Root, Dispose))));
259 VOID METHOD(ATIOnBM, Root, Dispose)
261 atiBitMap *bm = OOP_INST_DATA(cl, o);
263 LOCK_BITMAP
264 LOCK_HW
265 // NVDmaKickoff(&sd->Card);
266 RADEONWaitForIdleMMIO(sd);
268 if (bm->fbgfx)
270 FreeBitmapArea(sd, bm->framebuffer, bm->width, bm->height, bm->bpp);
272 bm->framebuffer = -1;
273 bm->fbgfx = 0;
275 else
276 FreeMem((APTR)bm->framebuffer, bm->pitch * bm->height);
278 if (bm->state)
279 FreePooled(sd->memPool, bm->state, sizeof(struct CardState));
281 bm->state = NULL;
283 UNLOCK_HW
284 UNLOCK_BITMAP
286 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
290 VOID METHOD(ATIOffBM, Root, Get)
291 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Root, Get))));
293 VOID METHOD(ATIOnBM, Root, Get)
295 atiBitMap *bm = OOP_INST_DATA(cl, o);
296 ULONG idx;
298 if (IS_ATIBM_ATTR(msg->attrID, idx))
300 switch (idx)
302 case aoHidd_ATIBitMap_Drawable:
303 if (bm->fbgfx)
304 *msg->storage = bm->framebuffer + (IPTR)sd->Card.FrameBuffer;
305 else
306 *msg->storage = bm->framebuffer;
307 break;
309 default:
310 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
313 else
315 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
320 VOID METHOD(ATIOffBM, Hidd_BitMap, Clear)
321 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, Clear))));
323 VOID METHOD(ATIOnBM, Hidd_BitMap, Clear)
325 atiBitMap *bm = OOP_INST_DATA(cl, o);
327 D(bug("[ATI] Clear(%p)\n",
328 bm->framebuffer));
330 LOCK_BITMAP
332 if (bm->fbgfx)
334 LOCK_HW
335 sd->Card.Busy = TRUE;
336 bm->usecount++;
338 RADEONWaitForFifo(sd, 1);
339 OUTREG(RADEON_DST_PITCH_OFFSET, bm->pitch_offset);
341 bm->dp_gui_master_cntl_clip = (bm->dp_gui_master_cntl
342 | RADEON_GMC_BRUSH_SOLID_COLOR
343 | RADEON_GMC_SRC_DATATYPE_COLOR
344 | RADEON_ROP[vHidd_GC_DrawMode_Copy].pattern);
346 RADEONWaitForFifo(sd, 4);
348 OUTREG(RADEON_DP_GUI_MASTER_CNTL, bm->dp_gui_master_cntl_clip);
349 OUTREG(RADEON_DP_BRUSH_FRGD_CLR, GC_BG(msg->gc));
350 OUTREG(RADEON_DP_WRITE_MASK, ~0);
351 OUTREG(RADEON_DP_CNTL, (RADEON_DST_X_LEFT_TO_RIGHT
352 | RADEON_DST_Y_TOP_TO_BOTTOM));
354 RADEONWaitForFifo(sd, 2);
356 OUTREG(RADEON_DST_Y_X, 0);
357 OUTREG(RADEON_DST_WIDTH_HEIGHT, (bm->width << 16) | bm->height);
359 UNLOCK_HW
361 else
363 ULONG *ptr = (ULONG*)bm->framebuffer;
364 ULONG val = 0;
365 int i = (bm->pitch * bm->height) >> 2;
367 switch (bm->bpp)
369 case 2:
370 val = GC_BG(msg->gc) << 16 | (GC_BG(msg->gc) & 0xffff);
371 break;
373 default:
374 val = GC_BG(msg->gc) << 16 | (GC_BG(msg->gc) & 0xffff);
375 break;
378 do { *ptr++ = val; } while(--i);
381 UNLOCK_BITMAP
384 struct pHidd_BitMap_FillRect {
385 struct pHidd_BitMap_DrawRect dr;
388 VOID METHOD(ATIOffBM, Hidd_BitMap, FillRect)
389 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, FillRect))));
391 VOID METHOD(ATIOnBM, Hidd_BitMap, FillRect)
393 OOP_Object *gc = msg->dr.gc;
394 atiBitMap *bm = OOP_INST_DATA(cl, o);
396 D(bug("[ATI] FillRect(%p, %d:%d - %d:%d)\n",
397 bm->framebuffer, msg->dr.minX, msg->dr.minY, msg->dr.maxX, msg->dr.maxY));
399 LOCK_BITMAP
401 if (bm->fbgfx)
403 LOCK_HW
404 sd->Card.Busy = TRUE;
405 bm->usecount++;
407 RADEONWaitForFifo(sd, 1);
408 OUTREG(RADEON_DST_PITCH_OFFSET, bm->pitch_offset);
410 bm->dp_gui_master_cntl_clip = (bm->dp_gui_master_cntl
411 | RADEON_GMC_BRUSH_SOLID_COLOR
412 | RADEON_GMC_SRC_DATATYPE_COLOR
413 | RADEON_ROP[GC_DRMD(gc)].pattern);
415 RADEONWaitForFifo(sd, 4);
417 OUTREG(RADEON_DP_GUI_MASTER_CNTL, bm->dp_gui_master_cntl_clip);
418 OUTREG(RADEON_DP_BRUSH_FRGD_CLR, GC_FG(gc));
419 OUTREG(RADEON_DP_WRITE_MASK, ~0);
420 OUTREG(RADEON_DP_CNTL, (RADEON_DST_X_LEFT_TO_RIGHT
421 | RADEON_DST_Y_TOP_TO_BOTTOM));
423 RADEONWaitForFifo(sd, 2);
425 OUTREG(RADEON_DST_Y_X, (msg->dr.minY << 16) | msg->dr.minX);
426 OUTREG(RADEON_DST_WIDTH_HEIGHT, ((msg->dr.maxX - msg->dr.minX + 1) << 16) | (msg->dr.maxY - msg->dr.minY + 1));
428 UNLOCK_HW
430 else
432 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
435 UNLOCK_BITMAP
440 VOID METHOD(ATIOffBM, Hidd_BitMap, DrawLine)
441 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, DrawLine))));
443 VOID METHOD(ATIOnBM, Hidd_BitMap, DrawLine)
445 OOP_Object *gc = msg->gc;
446 atiBitMap *bm = OOP_INST_DATA(cl, o);
448 D(bug("[ATI] DrawLine(%p, %d:%d - %d:%d) %08x\n",
449 bm->framebuffer, msg->x1, msg->y1, msg->x2, msg->y2,GC_FG(gc)));
451 LOCK_BITMAP
453 if ((GC_LINEPAT(gc) =! (UWORD)~0) || !bm->fbgfx)
455 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
457 else
459 LOCK_HW
460 sd->Card.Busy = TRUE;
461 bm->usecount++;
463 RADEONWaitForFifo(sd, 1);
464 OUTREG(RADEON_DST_PITCH_OFFSET, bm->pitch_offset);
466 bm->dp_gui_master_cntl_clip = (bm->dp_gui_master_cntl
467 | RADEON_GMC_BRUSH_SOLID_COLOR
468 | RADEON_GMC_SRC_DATATYPE_COLOR
469 | RADEON_ROP[GC_DRMD(gc)].pattern);
471 if (sd->Card.Type >= RV200) {
472 RADEONWaitForFifo(sd, 1);
473 OUTREG(RADEON_DST_LINE_PATCOUNT,
474 0x55 << RADEON_BRES_CNTL_SHIFT);
477 if (GC_DOCLIP(gc))
479 bm->dp_gui_master_cntl_clip |= RADEON_GMC_DST_CLIPPING;
480 UWORD x1,y1,x2,y2;
481 x1 = GC_CLIPX1(gc);
482 y1 = GC_CLIPY1(gc);
483 x2 = GC_CLIPX2(gc) + 1;
484 y2 = GC_CLIPY2(gc) + 1;
486 RADEONWaitForFifo(sd, 2);
487 OUTREG(RADEON_SC_TOP_LEFT, (y1 << 16) | x1);
488 OUTREG(RADEON_SC_BOTTOM_RIGHT, (y2 << 16) | x2);
491 RADEONWaitForFifo(sd, 3);
493 OUTREG(RADEON_DP_GUI_MASTER_CNTL, bm->dp_gui_master_cntl_clip);
494 OUTREG(RADEON_DP_BRUSH_FRGD_CLR, GC_FG(gc));
495 OUTREG(RADEON_DP_WRITE_MASK, ~0);
497 RADEONWaitForFifo(sd, 4);
499 OUTREG(RADEON_DST_LINE_START, (msg->y1 << 16) | msg->x1);
500 OUTREG(RADEON_DST_LINE_END, (msg->y2 << 16) | msg->x2);
501 OUTREG(RADEON_DST_LINE_START, (msg->y2 << 16) | msg->x2);
502 OUTREG(RADEON_DST_LINE_END, ((msg->y2+1) << 16) | (msg->x2+1));
504 UNLOCK_HW
507 UNLOCK_BITMAP
511 VOID METHOD(ATIOffBM, Hidd_BitMap, DrawRect)
512 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, DrawRect))));
514 VOID METHOD(ATIOnBM, Hidd_BitMap, DrawRect)
516 OOP_Object *gc = msg->gc;
517 atiBitMap *bm = OOP_INST_DATA(cl, o);
518 UWORD addX, addY;
520 D(bug("[ATI] DrawRect(%p, %d:%d - %d:%d)\n",
521 bm->framebuffer, msg->minX, msg->minY, msg->maxX, msg->maxY));
523 if (msg->minX == msg->maxX) addX = 1; else addX = 0;
524 if (msg->minY == msg->maxY) addY = 1; else addY = 0;
526 LOCK_BITMAP
528 if ((GC_LINEPAT(gc) =! (UWORD)~0) || !bm->fbgfx)
530 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
532 else
534 LOCK_HW
535 sd->Card.Busy = TRUE;
536 bm->usecount++;
538 RADEONWaitForFifo(sd, 1);
539 OUTREG(RADEON_DST_PITCH_OFFSET, bm->pitch_offset);
541 bm->dp_gui_master_cntl_clip = (bm->dp_gui_master_cntl
542 | RADEON_GMC_BRUSH_SOLID_COLOR
543 | RADEON_GMC_SRC_DATATYPE_COLOR
544 | RADEON_ROP[GC_DRMD(gc)].pattern);
546 if (sd->Card.Type >= RV200) {
547 RADEONWaitForFifo(sd, 1);
548 OUTREG(RADEON_DST_LINE_PATCOUNT,
549 0x55 << RADEON_BRES_CNTL_SHIFT);
552 if (GC_DOCLIP(gc))
554 bm->dp_gui_master_cntl_clip |= RADEON_GMC_DST_CLIPPING;
555 UWORD x1,y1,x2,y2;
556 x1 = GC_CLIPX1(gc);
557 y1 = GC_CLIPY1(gc);
558 x2 = GC_CLIPX2(gc) + 1;
559 y2 = GC_CLIPY2(gc) + 1;
561 RADEONWaitForFifo(sd, 2);
562 OUTREG(RADEON_SC_TOP_LEFT, (y1 << 16) | x1);
563 OUTREG(RADEON_SC_BOTTOM_RIGHT, (y2 << 16) | x2);
566 RADEONWaitForFifo(sd, 3);
568 OUTREG(RADEON_DP_GUI_MASTER_CNTL, bm->dp_gui_master_cntl_clip);
569 OUTREG(RADEON_DP_BRUSH_FRGD_CLR, GC_FG(gc));
570 OUTREG(RADEON_DP_WRITE_MASK, ~0);
572 RADEONWaitForFifo(sd, 8);
574 OUTREG(RADEON_DST_LINE_START, (msg->minY << 16) | (msg->minX & 0xffff));
575 OUTREG(RADEON_DST_LINE_END, (msg->minY << 16) | (msg->maxX & 0xffff));
577 OUTREG(RADEON_DST_LINE_START, ((msg->minY + addY) << 16) | (msg->maxX & 0xffff));
578 OUTREG(RADEON_DST_LINE_END, ((msg->maxY << 16)) | (msg->maxX & 0xffff));
580 OUTREG(RADEON_DST_LINE_START, ((msg->maxY << 16)) | ((msg->maxX - addX) & 0xffff));
581 OUTREG(RADEON_DST_LINE_END, ((msg->maxY << 16)) | ((msg->minX) & 0xffff));
583 OUTREG(RADEON_DST_LINE_START, ((msg->maxY - addY) << 16) | (msg->minX & 0xffff));
584 OUTREG(RADEON_DST_LINE_END, ((msg->minY + addY) << 16) | (msg->minX & 0xffff));
586 UNLOCK_HW
589 UNLOCK_BITMAP
593 VOID METHOD(ATIOffBM, Hidd_BitMap, DrawPolygon)
594 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, DrawPolygon))));
596 VOID METHOD(ATIOnBM, Hidd_BitMap, DrawPolygon)
598 OOP_Object *gc = msg->gc;
599 atiBitMap *bm = OOP_INST_DATA(cl, o);
600 ULONG i;
602 D(bug("[ATI] DrawPolygon(%p)\n",
603 bm->framebuffer));
605 LOCK_BITMAP
607 if ((GC_LINEPAT(gc) =! (UWORD)~0) || !bm->fbgfx)
609 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
611 else
613 LOCK_HW
614 sd->Card.Busy = TRUE;
615 bm->usecount++;
617 RADEONWaitForFifo(sd, 1);
618 OUTREG(RADEON_DST_PITCH_OFFSET, bm->pitch_offset);
620 bm->dp_gui_master_cntl_clip = (bm->dp_gui_master_cntl
621 | RADEON_GMC_BRUSH_SOLID_COLOR
622 | RADEON_GMC_SRC_DATATYPE_COLOR
623 | RADEON_ROP[GC_DRMD(gc)].pattern);
625 if (sd->Card.Type >= RV200) {
626 RADEONWaitForFifo(sd, 1);
627 OUTREG(RADEON_DST_LINE_PATCOUNT,
628 0x55 << RADEON_BRES_CNTL_SHIFT);
631 if (GC_DOCLIP(gc))
633 bm->dp_gui_master_cntl_clip |= RADEON_GMC_DST_CLIPPING;
634 UWORD x1,y1,x2,y2;
635 x1 = GC_CLIPX1(gc);
636 y1 = GC_CLIPY1(gc);
637 x2 = GC_CLIPX2(gc) + 1;
638 y2 = GC_CLIPY2(gc) + 1;
640 RADEONWaitForFifo(sd, 2);
641 OUTREG(RADEON_SC_TOP_LEFT, (y1 << 16) | x1);
642 OUTREG(RADEON_SC_BOTTOM_RIGHT, (y2 << 16) | x2);
645 RADEONWaitForFifo(sd, 3);
647 OUTREG(RADEON_DP_GUI_MASTER_CNTL, bm->dp_gui_master_cntl_clip);
648 OUTREG(RADEON_DP_BRUSH_FRGD_CLR, GC_FG(gc));
649 OUTREG(RADEON_DP_WRITE_MASK, ~0);
651 for (i = 2; i < (2 * msg->n); i+=2)
653 RADEONWaitForFifo(sd, 2);
654 OUTREG(RADEON_DST_LINE_START, (msg->coords[i-1] << 16) | msg->coords[i-2]);
655 OUTREG(RADEON_DST_LINE_END, (msg->coords[i+1] << 16) | msg->coords[i]);
658 UNLOCK_HW
661 UNLOCK_BITMAP
666 VOID METHOD(ATIOffBM, Hidd_BitMap, PutPixel)
667 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, PutPixel))));
669 VOID METHOD(ATIOnBM, Hidd_BitMap, PutPixel)
671 atiBitMap *bm = OOP_INST_DATA(cl, o);
673 LOCK_BITMAP
675 UBYTE *ptr = (UBYTE*)((IPTR)bm->framebuffer + bm->bpp * msg->x + bm->pitch * msg->y);
677 if (bm->fbgfx)
679 ptr += (IPTR)sd->Card.FrameBuffer;
680 if (sd->Card.Busy)
682 LOCK_HW
683 #warning TODO: NVSync(sd)
684 RADEONWaitForIdleMMIO(sd);
685 UNLOCK_HW
689 switch (bm->bpp)
691 case 1:
692 *ptr = msg->pixel;
693 break;
694 case 2:
695 *(UWORD*)ptr = msg->pixel;
696 break;
697 case 4:
698 *(ULONG*)ptr = msg->pixel;
699 break;
702 UNLOCK_BITMAP
706 HIDDT_Pixel METHOD(ATIOffBM, Hidd_BitMap, GetPixel)
707 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, GetPixel))));
709 HIDDT_Pixel METHOD(ATIOnBM, Hidd_BitMap, GetPixel)
711 HIDDT_Pixel pixel=0;
712 atiBitMap *bm = OOP_INST_DATA(cl, o);
714 LOCK_BITMAP
716 UBYTE *ptr = (UBYTE*)((IPTR)bm->framebuffer + bm->bpp * msg->x + bm->pitch * msg->y);
718 if (bm->fbgfx)
720 ptr += (IPTR)sd->Card.FrameBuffer;
721 if (sd->Card.Busy)
723 LOCK_HW
724 #warning TODO: NVSync(sd)
725 RADEONWaitForIdleMMIO(sd);
726 UNLOCK_HW
730 switch (bm->bpp)
732 case 1:
733 pixel = *ptr;
734 break;
735 case 2:
736 pixel = *(UWORD*)ptr;
737 break;
738 case 4:
739 pixel = *(ULONG*)ptr;
740 break;
743 UNLOCK_BITMAP
745 /* Get pen number from colortab */
746 return pixel;
750 void METHOD(ATIOffBM, Hidd_BitMap, BlitColorExpansion)
751 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, BlitColorExpansion))));
753 void METHOD(ATIOnBM, Hidd_BitMap, BlitColorExpansion)
755 atiBitMap *bm = OOP_INST_DATA(cl, o);
757 LOCK_BITMAP
759 if ((OOP_OCLASS(msg->srcBitMap) == sd->PlanarBMClass) && bm->fbgfx)
761 struct planarbm_data *planar = OOP_INST_DATA(OOP_OCLASS(msg->srcBitMap), msg->srcBitMap);
762 HIDDT_Pixel bg, fg;
763 ULONG cemd;
764 ULONG skipleft = msg->srcX - (msg->srcX & ~31);
765 ULONG mask = ~0 << bm->depth;
767 cemd = GC_COLEXP(msg->gc);
768 bg = GC_BG(msg->gc) | mask;
769 fg = GC_FG(msg->gc) | mask;
771 ULONG bw = (msg->width + 31 + skipleft) & ~31;
772 LONG x = msg->destX, y = msg->destY, w = msg->width, h = msg->height;
774 LOCK_HW
776 bm->usecount++;
777 sd->Card.Busy = TRUE;
779 RADEONWaitForFifo(sd, 1);
780 OUTREG(RADEON_DST_PITCH_OFFSET, bm->pitch_offset);
782 bm->dp_gui_master_cntl_clip = (bm->dp_gui_master_cntl
783 | RADEON_GMC_WR_MSK_DIS
784 | RADEON_GMC_BRUSH_NONE
785 | RADEON_DP_SRC_SOURCE_HOST_DATA
786 | RADEON_GMC_DST_CLIPPING
787 | RADEON_GMC_BYTE_MSB_TO_LSB
788 | RADEON_ROP[vHidd_GC_DrawMode_Copy].rop);
790 if (cemd & vHidd_GC_ColExp_Transparent)
792 bm->dp_gui_master_cntl_clip |= RADEON_GMC_SRC_DATATYPE_MONO_FG_LA;
794 RADEONWaitForFifo(sd, 6);
795 OUTREG(RADEON_DP_GUI_MASTER_CNTL, bm->dp_gui_master_cntl_clip);
796 OUTREG(RADEON_DP_SRC_FRGD_CLR, fg);
798 else
800 bm->dp_gui_master_cntl_clip |= RADEON_GMC_SRC_DATATYPE_MONO_FG_BG;
802 RADEONWaitForFifo(sd, 7);
803 OUTREG(RADEON_DP_GUI_MASTER_CNTL, bm->dp_gui_master_cntl_clip);
804 OUTREG(RADEON_DP_SRC_FRGD_CLR, fg);
805 OUTREG(RADEON_DP_SRC_BKGD_CLR, bg);
808 OUTREG(RADEON_SC_TOP_LEFT, (y << 16) | x);
809 OUTREG(RADEON_SC_BOTTOM_RIGHT, ((y+h) << 16) | (x+w));
811 OUTREG(RADEON_DST_X_Y, ((x - skipleft) << 16) | y);
812 OUTREG(RADEON_DST_WIDTH_HEIGHT, (bw << 16) | h);
814 ULONG *ptr = (ULONG*)planar->planes[0];
815 ptr += ((msg->srcY * planar->bytesperrow) >> 2) + (msg->srcX >> 5);
817 #if AROS_BIG_ENDIAN
818 RADEONWaitForFifo(sd, 1);
819 OUTREG(RADEON_RBBM_GUICNTL, RADEON_HOST_DATA_SWAP_32BIT);
820 #endif
822 while(h--)
824 int i;
826 for (i=0; i < bw >> 5; i++)
828 RADEONWaitForFifo(sd, 1);
829 OUTREG(RADEON_HOST_DATA0, ptr[i]);
832 ptr += planar->bytesperrow >> 2;
835 #if AROS_BIG_ENDIAN
836 RADEONWaitForFifo(sd, 1);
837 OUTREG(RADEON_RBBM_GUICNTL, RADEON_HOST_DATA_SWAP_NONE);
838 #endif
840 UNLOCK_HW
843 else
844 OOP_DoSuperMethod(cl, o, msg);
846 UNLOCK_BITMAP
850 ULONG METHOD(ATIOffBM, Hidd_BitMap, BytesPerLine)
851 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, BytesPerLine))));
853 ULONG METHOD(ATIOnBM, Hidd_BitMap, BytesPerLine)
855 atiBitMap *bm = OOP_INST_DATA(cl, o);
857 return (bm->bpp * msg->width + 255) & ~255;
861 BOOL METHOD(ATIOffBM, Hidd_BitMap, ObtainDirectAccess)
862 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, ObtainDirectAccess))));
864 BOOL METHOD(ATIOnBM, Hidd_BitMap, ObtainDirectAccess)
866 atiBitMap *bm = OOP_INST_DATA(cl, o);
867 LOCK_BITMAP
869 IPTR VideoData = bm->framebuffer;
871 if (bm->fbgfx)
873 VideoData += (IPTR)sd->Card.FrameBuffer;
874 if (sd->Card.Busy)
876 LOCK_HW
877 #warning TODO: NVSync(sd)
878 RADEONWaitForIdleMMIO(sd);
879 UNLOCK_HW
883 *msg->addressReturn = (UBYTE*)VideoData;
884 *msg->widthReturn = bm->pitch / bm->bpp;
885 *msg->heightReturn = bm->height;
886 *msg->bankSizeReturn = *msg->memSizeReturn = bm->pitch * bm->height;
888 return TRUE;
891 VOID METHOD(ATIOffBM, Hidd_BitMap, ReleaseDirectAccess)
892 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, ReleaseDirectAccess))));
894 VOID METHOD(ATIOnBM, Hidd_BitMap, ReleaseDirectAccess)
896 atiBitMap *bm = OOP_INST_DATA(cl, o);
898 UNLOCK_BITMAP
903 * Unaccelerated methods
906 VOID METHOD(ATIOffBM, Hidd_BitMap, PutImageLUT)
907 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, PutImageLUT))));
909 VOID METHOD(ATIOnBM, Hidd_BitMap, PutImageLUT)
911 atiBitMap *bm = OOP_INST_DATA(cl, o);
913 // bug("[ATI] PutImageLUT(%d, %d, %d, %d, %d, %p)\n", msg->x, msg->y, msg->width, msg->height, msg->modulo, msg->pixels);
915 LOCK_BITMAP
919 // IPTR VideoData = bm->framebuffer;
921 if (bm->fbgfx)
924 UBYTE *src = msg->pixels;
925 ULONG x_add = msg->modulo;
926 UWORD height = msg->height;
927 UWORD bw = msg->width;
928 HIDDT_Pixel *colmap = msg->pixlut->pixels;
930 if (bm->bpp == 2)
931 bw = (bw + 1) & ~1;
933 LOCK_HW
935 bm->usecount++;
936 sd->Card.Busy = TRUE;
938 RADEONWaitForFifo(sd, 1);
939 OUTREG(RADEON_DST_PITCH_OFFSET, bm->pitch_offset);
941 bm->dp_gui_master_cntl_clip = (bm->dp_gui_master_cntl
942 | RADEON_GMC_WR_MSK_DIS
943 | RADEON_GMC_BRUSH_NONE
944 | RADEON_DP_SRC_SOURCE_HOST_DATA
945 | RADEON_GMC_DST_CLIPPING
946 | RADEON_GMC_SRC_DATATYPE_COLOR
947 | RADEON_ROP[vHidd_GC_DrawMode_Copy].rop);
949 RADEONWaitForFifo(sd, 5);
950 OUTREG(RADEON_DP_GUI_MASTER_CNTL, bm->dp_gui_master_cntl_clip);
952 OUTREG(RADEON_SC_TOP_LEFT, (msg->y << 16) | msg->x);
953 OUTREG(RADEON_SC_BOTTOM_RIGHT, ((msg->y+msg->height) << 16) | (msg->x+msg->width));
955 OUTREG(RADEON_DST_X_Y, ((msg->x) << 16) | msg->y);
956 OUTREG(RADEON_DST_WIDTH_HEIGHT, (bw << 16) | msg->height);
958 if (bm->bpp == 4)
960 #if AROS_BIG_ENDIAN
961 RADEONWaitForFifo(sd, 1);
962 OUTREG(RADEON_RBBM_GUICNTL, RADEON_HOST_DATA_SWAP_32BIT);
963 #endif
964 while (height--)
966 UBYTE *line = (UBYTE*)src;
967 ULONG width = msg->width;
969 while(width)
971 if (width <= 8)
973 RADEONWaitForFifo(sd, width);
974 switch (width)
976 case 8: OUTREGN(RADEON_HOST_DATA0, colmap[*line++]);
977 case 7: OUTREGN(RADEON_HOST_DATA1, colmap[*line++]);
978 case 6: OUTREGN(RADEON_HOST_DATA2, colmap[*line++]);
979 case 5: OUTREGN(RADEON_HOST_DATA3, colmap[*line++]);
980 case 4: OUTREGN(RADEON_HOST_DATA4, colmap[*line++]);
981 case 3: OUTREGN(RADEON_HOST_DATA5, colmap[*line++]);
982 case 2: OUTREGN(RADEON_HOST_DATA6, colmap[*line++]);
983 case 1: OUTREGN(RADEON_HOST_DATA7, colmap[*line++]);
985 width = 0;
987 else
989 RADEONWaitForFifo(sd, 8);
991 OUTREGN(RADEON_HOST_DATA0, colmap[*line++]);
992 OUTREGN(RADEON_HOST_DATA1, colmap[*line++]);
993 OUTREGN(RADEON_HOST_DATA2, colmap[*line++]);
994 OUTREGN(RADEON_HOST_DATA3, colmap[*line++]);
995 OUTREGN(RADEON_HOST_DATA4, colmap[*line++]);
996 OUTREGN(RADEON_HOST_DATA5, colmap[*line++]);
997 OUTREGN(RADEON_HOST_DATA6, colmap[*line++]);
998 OUTREGN(RADEON_HOST_DATA7, colmap[*line++]);
1000 width -= 8;
1004 src += x_add;
1007 else if (bm->bpp == 2)
1009 #if AROS_BIG_ENDIAN
1010 RADEONWaitForFifo(sd, 1);
1011 OUTREG(RADEON_RBBM_GUICNTL, RADEON_HOST_DATA_SWAP_HDW);
1012 #endif
1013 while (height--)
1015 UBYTE *line = (UBYTE*)src;
1016 ULONG width = bw >> 1;
1018 while(width--)
1020 ULONG tmp = (colmap[line[0]] << 16) | (colmap[line[1]] & 0x0000ffff);
1021 RADEONWaitForFifo(sd, 1);
1022 OUTREG(RADEON_HOST_DATA0, tmp);
1023 line+=2;
1026 src += x_add;
1031 #if AROS_BIG_ENDIAN
1032 RADEONWaitForFifo(sd, 1);
1033 OUTREG(RADEON_RBBM_GUICNTL, RADEON_HOST_DATA_SWAP_NONE);
1034 #endif
1036 UNLOCK_HW
1038 // VideoData += (IPTR)sd->Card.FrameBuffer;
1040 // if (sd->Card.Busy)
1041 // {
1042 // LOCK_HW
1043 //#warning TODO: NVSync(sd)
1044 // RADEONWaitForIdleMMIO(sd);
1045 // UNLOCK_HW
1046 // }
1047 // }
1049 // switch(bm->bpp)
1050 // {
1051 // case 2:
1052 // {
1053 // struct pHidd_BitMap_CopyLUTMemBox16 __m = {
1054 // sd->mid_CopyLUTMemBox16,
1055 // msg->pixels,
1056 // 0,
1057 // 0,
1058 // (APTR)VideoData,
1059 // msg->x,
1060 // msg->y,
1061 // msg->width,
1062 // msg->height,
1063 // msg->modulo,
1064 // bm->pitch,
1065 // msg->pixlut
1066 // }, *m = &__m;
1068 // OOP_DoMethod(o, (OOP_Msg)m);
1069 // }
1070 // break;
1072 // case 4:
1073 // {
1074 // struct pHidd_BitMap_CopyLUTMemBox32 __m = {
1075 // sd->mid_CopyLUTMemBox32,
1076 // msg->pixels,
1077 // 0,
1078 // 0,
1079 // (APTR)VideoData,
1080 // msg->x,
1081 // msg->y,
1082 // msg->width,
1083 // msg->height,
1084 // msg->modulo,
1085 // bm->pitch,
1086 // msg->pixlut
1087 // }, *m = &__m;
1089 // OOP_DoMethod(o, (OOP_Msg)m);
1090 // }
1091 // break;
1093 // default:
1094 // OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
1095 // break;
1098 else
1099 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
1101 UNLOCK_BITMAP
1105 VOID METHOD(ATIOffBM, Hidd_BitMap, PutImage)
1106 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, PutImage))));
1108 VOID METHOD(ATIOnBM, Hidd_BitMap, PutImage)
1110 atiBitMap *bm = OOP_INST_DATA(cl, o);
1111 BOOL done = FALSE;
1113 LOCK_BITMAP
1115 IPTR VideoData = bm->framebuffer;
1117 /* Try to PutImage with 2D engine first */
1118 if (bm->fbgfx)
1120 UBYTE *src = msg->pixels;
1121 ULONG x_add = msg->modulo;
1122 UWORD height = msg->height;
1123 UWORD bw = msg->width;
1125 if (bm->bpp == 2)
1126 bw = (bw + 1) & ~1;
1128 done = TRUE;
1130 if (done)
1132 LOCK_HW
1134 bm->usecount++;
1135 sd->Card.Busy = TRUE;
1137 RADEONWaitForFifo(sd, 1);
1138 OUTREG(RADEON_DST_PITCH_OFFSET, bm->pitch_offset);
1140 bm->dp_gui_master_cntl_clip = (bm->dp_gui_master_cntl
1141 | RADEON_GMC_WR_MSK_DIS
1142 | RADEON_GMC_BRUSH_NONE
1143 | RADEON_DP_SRC_SOURCE_HOST_DATA
1144 | RADEON_GMC_DST_CLIPPING
1145 | RADEON_GMC_SRC_DATATYPE_COLOR
1146 | RADEON_ROP[vHidd_GC_DrawMode_Copy].rop);
1148 RADEONWaitForFifo(sd, 5);
1149 OUTREG(RADEON_DP_GUI_MASTER_CNTL, bm->dp_gui_master_cntl_clip);
1151 OUTREG(RADEON_SC_TOP_LEFT, (msg->y << 16) | msg->x);
1152 OUTREG(RADEON_SC_BOTTOM_RIGHT, ((msg->y+msg->height) << 16) | (msg->x+msg->width));
1154 OUTREG(RADEON_DST_X_Y, ((msg->x) << 16) | msg->y);
1155 OUTREG(RADEON_DST_WIDTH_HEIGHT, (bw << 16) | msg->height);
1157 switch (msg->pixFmt)
1159 case vHidd_StdPixFmt_Native32:
1160 case vHidd_StdPixFmt_Native:
1161 if (bm->bpp == 4)
1163 #if AROS_BIG_ENDIAN
1164 RADEONWaitForFifo(sd, 1);
1165 OUTREG(RADEON_RBBM_GUICNTL, RADEON_HOST_DATA_SWAP_32BIT);
1166 #endif
1167 while (height--)
1169 ULONG *line = (ULONG*)src;
1170 ULONG width = msg->width;
1172 while(width)
1174 if (width <= 8)
1176 RADEONWaitForFifo(sd, width);
1177 switch (width)
1179 case 8: OUTREGN(RADEON_HOST_DATA0, *line++);
1180 case 7: OUTREGN(RADEON_HOST_DATA1, *line++);
1181 case 6: OUTREGN(RADEON_HOST_DATA2, *line++);
1182 case 5: OUTREGN(RADEON_HOST_DATA3, *line++);
1183 case 4: OUTREGN(RADEON_HOST_DATA4, *line++);
1184 case 3: OUTREGN(RADEON_HOST_DATA5, *line++);
1185 case 2: OUTREGN(RADEON_HOST_DATA6, *line++);
1186 case 1: OUTREGN(RADEON_HOST_DATA7, *line++);
1188 width = 0;
1190 else
1192 RADEONWaitForFifo(sd, 8);
1194 OUTREGN(RADEON_HOST_DATA0, *line++);
1195 OUTREGN(RADEON_HOST_DATA1, *line++);
1196 OUTREGN(RADEON_HOST_DATA2, *line++);
1197 OUTREGN(RADEON_HOST_DATA3, *line++);
1198 OUTREGN(RADEON_HOST_DATA4, *line++);
1199 OUTREGN(RADEON_HOST_DATA5, *line++);
1200 OUTREGN(RADEON_HOST_DATA6, *line++);
1201 OUTREGN(RADEON_HOST_DATA7, *line++);
1203 width -= 8;
1207 src += x_add;
1209 #if AROS_BIG_ENDIAN
1210 RADEONWaitForFifo(sd, 1);
1211 OUTREG(RADEON_RBBM_GUICNTL, RADEON_HOST_DATA_SWAP_NONE);
1212 #endif
1215 else if (bm->bpp == 2)
1217 #if AROS_BIG_ENDIAN
1218 RADEONWaitForFifo(sd, 1);
1219 OUTREG(RADEON_RBBM_GUICNTL, RADEON_HOST_DATA_SWAP_HDW);
1220 #endif
1221 if (msg->pixFmt == vHidd_StdPixFmt_Native)
1223 while (height--)
1225 ULONG *line = (ULONG*)src;
1226 ULONG width = bw >> 1;
1228 while(width--)
1230 RADEONWaitForFifo(sd, 1);
1231 OUTREG(RADEON_HOST_DATA0, *line++);
1234 src += x_add;
1237 else
1239 while (height--)
1241 ULONG *line = (ULONG*)src;
1242 ULONG width = bw >> 1;
1244 while(width--)
1246 ULONG tmp = (line[0] << 16) | (line[1] & 0x0000ffff);
1247 RADEONWaitForFifo(sd, 1);
1248 OUTREG(RADEON_HOST_DATA0, tmp);
1249 line+=2;
1252 src += x_add;
1257 #if AROS_BIG_ENDIAN
1258 RADEONWaitForFifo(sd, 1);
1259 OUTREG(RADEON_RBBM_GUICNTL, RADEON_HOST_DATA_SWAP_NONE);
1260 #endif
1262 break;
1264 default:
1266 OOP_Object *dstpf;
1267 OOP_Object *srcpf;
1269 srcpf = HIDD_Gfx_GetPixFmt(sd->AtiObject, msg->pixFmt);
1270 OOP_GetAttr(o, aHidd_BitMap_PixFmt, (APTR)&dstpf);
1272 if (bm->bpp == 4)
1274 #if AROS_BIG_ENDIAN
1275 RADEONWaitForFifo(sd, 1);
1276 OUTREG(RADEON_RBBM_GUICNTL, RADEON_HOST_DATA_SWAP_32BIT);
1277 #endif
1278 while(height--)
1280 ULONG *line = (ULONG*)sd->cpuscratch;
1281 ULONG width = bw;
1282 APTR _src = src;
1284 HIDD_BM_ConvertPixels(o, &_src, srcpf, msg->modulo, &line, dstpf, msg->modulo, msg->width, 1, NULL);
1286 line = (ULONG*)sd->cpuscratch;
1288 while(width)
1290 if (width <= 8)
1292 RADEONWaitForFifo(sd, width);
1293 switch (width)
1295 case 8: OUTREGN(RADEON_HOST_DATA0, *line++);
1296 case 7: OUTREGN(RADEON_HOST_DATA1, *line++);
1297 case 6: OUTREGN(RADEON_HOST_DATA2, *line++);
1298 case 5: OUTREGN(RADEON_HOST_DATA3, *line++);
1299 case 4: OUTREGN(RADEON_HOST_DATA4, *line++);
1300 case 3: OUTREGN(RADEON_HOST_DATA5, *line++);
1301 case 2: OUTREGN(RADEON_HOST_DATA6, *line++);
1302 case 1: OUTREGN(RADEON_HOST_DATA7, *line++);
1304 width = 0;
1306 else
1308 RADEONWaitForFifo(sd, 8);
1310 OUTREGN(RADEON_HOST_DATA0, *line++);
1311 OUTREGN(RADEON_HOST_DATA1, *line++);
1312 OUTREGN(RADEON_HOST_DATA2, *line++);
1313 OUTREGN(RADEON_HOST_DATA3, *line++);
1314 OUTREGN(RADEON_HOST_DATA4, *line++);
1315 OUTREGN(RADEON_HOST_DATA5, *line++);
1316 OUTREGN(RADEON_HOST_DATA6, *line++);
1317 OUTREGN(RADEON_HOST_DATA7, *line++);
1319 width -= 8;
1323 src += x_add;
1325 #if AROS_BIG_ENDIAN
1326 RADEONWaitForFifo(sd, 1);
1327 OUTREG(RADEON_RBBM_GUICNTL, RADEON_HOST_DATA_SWAP_NONE);
1328 #endif
1331 else if (bm->bpp == 2)
1333 #if AROS_BIG_ENDIAN
1334 RADEONWaitForFifo(sd, 1);
1335 OUTREG(RADEON_RBBM_GUICNTL, RADEON_HOST_DATA_SWAP_HDW);
1336 #endif
1338 while(height--)
1340 ULONG *line = (ULONG*)sd->cpuscratch;
1341 ULONG width = bw;
1342 APTR _src = src;
1344 HIDD_BM_ConvertPixels(o, &_src, srcpf, msg->modulo, &line, dstpf, msg->modulo, msg->width, 1, NULL);
1346 line = (ULONG*)sd->cpuscratch;
1348 while(width)
1350 if (width <= 16)
1352 RADEONWaitForFifo(sd, width >> 1);
1353 switch (width)
1355 case 16: OUTREG(RADEON_HOST_DATA0, *line++);
1356 case 14: OUTREG(RADEON_HOST_DATA1, *line++);
1357 case 12: OUTREG(RADEON_HOST_DATA2, *line++);
1358 case 10: OUTREG(RADEON_HOST_DATA3, *line++);
1359 case 8: OUTREG(RADEON_HOST_DATA4, *line++);
1360 case 6: OUTREG(RADEON_HOST_DATA5, *line++);
1361 case 4: OUTREG(RADEON_HOST_DATA6, *line++);
1362 case 2: OUTREG(RADEON_HOST_DATA7, *line++);
1364 width = 0;
1366 else
1368 RADEONWaitForFifo(sd, 8);
1370 OUTREG(RADEON_HOST_DATA0, *line++);
1371 OUTREG(RADEON_HOST_DATA1, *line++);
1372 OUTREG(RADEON_HOST_DATA2, *line++);
1373 OUTREG(RADEON_HOST_DATA3, *line++);
1374 OUTREG(RADEON_HOST_DATA4, *line++);
1375 OUTREG(RADEON_HOST_DATA5, *line++);
1376 OUTREG(RADEON_HOST_DATA6, *line++);
1377 OUTREG(RADEON_HOST_DATA7, *line++);
1379 width -= 16;
1383 src += x_add;
1386 #if AROS_BIG_ENDIAN
1387 RADEONWaitForFifo(sd, 1);
1388 OUTREG(RADEON_RBBM_GUICNTL, RADEON_HOST_DATA_SWAP_NONE);
1389 #endif
1394 UNLOCK_HW
1398 if (!done)
1400 // bug("[ATI] PutImage x=%d y=%d w=%d h=%d bpp=%d fmt=%d\n", msg->x, msg->y, msg->width, msg->height, bm->bpp, msg->pixFmt);
1403 if (bm->fbgfx)
1405 VideoData += (IPTR)sd->Card.FrameBuffer;
1407 if (sd->Card.Busy)
1409 LOCK_HW
1410 #warning TODO: NVSync(sd)
1411 RADEONWaitForIdleMMIO(sd);
1412 UNLOCK_HW
1416 switch(msg->pixFmt)
1418 case vHidd_StdPixFmt_Native:
1419 switch(bm->bpp)
1421 case 1:
1423 struct pHidd_BitMap_CopyMemBox8 __m = {
1424 sd->mid_CopyMemBox8,
1425 msg->pixels,
1428 (APTR)VideoData,
1429 msg->x,
1430 msg->y,
1431 msg->width,
1432 msg->height,
1433 msg->modulo,
1434 bm->pitch
1435 }, *m = &__m;
1437 OOP_DoMethod(o, (OOP_Msg)m);
1439 break;
1441 case 2:
1443 struct pHidd_BitMap_CopyMemBox16 __m = {
1444 sd->mid_CopyMemBox16,
1445 msg->pixels,
1448 (APTR)VideoData,
1449 msg->x,
1450 msg->y,
1451 msg->width,
1452 msg->height,
1453 msg->modulo,
1454 bm->pitch
1455 }, *m = &__m;
1457 OOP_DoMethod(o, (OOP_Msg)m);
1459 break;
1461 case 4:
1463 struct pHidd_BitMap_CopyMemBox32 __m = {
1464 sd->mid_CopyMemBox32,
1465 msg->pixels,
1468 (APTR)VideoData,
1469 msg->x,
1470 msg->y,
1471 msg->width,
1472 msg->height,
1473 msg->modulo,
1474 bm->pitch
1475 }, *m = &__m;
1477 OOP_DoMethod(o, (OOP_Msg)m);
1479 break;
1481 } /* switch(data->bytesperpix) */
1482 break;
1484 case vHidd_StdPixFmt_Native32:
1485 switch(bm->bpp)
1487 case 1:
1489 struct pHidd_BitMap_PutMem32Image8 __m = {
1490 sd->mid_PutMem32Image8,
1491 msg->pixels,
1492 (APTR)VideoData,
1493 msg->x,
1494 msg->y,
1495 msg->width,
1496 msg->height,
1497 msg->modulo,
1498 bm->pitch
1499 }, *m = &__m;
1500 OOP_DoMethod(o, (OOP_Msg)m);
1502 break;
1504 case 2:
1506 struct pHidd_BitMap_PutMem32Image16 __m = {
1507 sd->mid_PutMem32Image16,
1508 msg->pixels,
1509 (APTR)VideoData,
1510 msg->x,
1511 msg->y,
1512 msg->width,
1513 msg->height,
1514 msg->modulo,
1515 bm->pitch
1516 }, *m = &__m;
1517 OOP_DoMethod(o, (OOP_Msg)m);
1519 break;
1521 case 4:
1523 struct pHidd_BitMap_CopyMemBox32 __m = {
1524 sd->mid_CopyMemBox32,
1525 msg->pixels,
1528 (APTR)VideoData,
1529 msg->x,
1530 msg->y,
1531 msg->width,
1532 msg->height,
1533 msg->modulo,
1534 bm->pitch
1535 }, *m = &__m;
1537 OOP_DoMethod(o, (OOP_Msg)m);
1539 break;
1541 } /* switch(data->bytesperpix) */
1542 break;
1544 default:
1545 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
1546 break;
1547 } /* switch(msg->pixFmt) */
1550 UNLOCK_BITMAP
1553 VOID METHOD(ATIOffBM, Hidd_BitMap, GetImage)
1554 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, GetImage))));
1556 VOID METHOD(ATIOnBM, Hidd_BitMap, GetImage)
1558 atiBitMap *bm = OOP_INST_DATA(cl, o);
1560 LOCK_BITMAP
1562 IPTR VideoData = bm->framebuffer;
1564 if (bm->fbgfx)
1566 VideoData += (IPTR)sd->Card.FrameBuffer;
1567 if (sd->Card.Busy)
1569 LOCK_HW
1570 #warning TODO: NVSync(sd)
1571 RADEONWaitForIdleMMIO(sd);
1572 UNLOCK_HW
1576 switch(msg->pixFmt)
1578 case vHidd_StdPixFmt_Native:
1579 switch(bm->bpp)
1581 case 1:
1583 struct pHidd_BitMap_CopyMemBox8 __m = {
1584 sd->mid_CopyMemBox8,
1585 (APTR)VideoData,
1586 msg->x,
1587 msg->y,
1588 msg->pixels,
1591 msg->width,
1592 msg->height,
1593 bm->pitch,
1594 msg->modulo
1595 }, *m = &__m;
1597 OOP_DoMethod(o, (OOP_Msg)m);
1599 break;
1601 case 2:
1603 struct pHidd_BitMap_CopyMemBox16 __m = {
1604 sd->mid_CopyMemBox16,
1605 (APTR)VideoData,
1606 msg->x,
1607 msg->y,
1608 msg->pixels,
1611 msg->width,
1612 msg->height,
1613 bm->pitch,
1614 msg->modulo
1615 }, *m = &__m;
1617 OOP_DoMethod(o, (OOP_Msg)m);
1619 break;
1621 case 4:
1623 struct pHidd_BitMap_CopyMemBox32 __m = {
1624 sd->mid_CopyMemBox32,
1625 (APTR)VideoData,
1626 msg->x,
1627 msg->y,
1628 msg->pixels,
1631 msg->width,
1632 msg->height,
1633 bm->pitch,
1634 msg->modulo
1635 }, *m = &__m;
1637 OOP_DoMethod(o, (OOP_Msg)m);
1639 break;
1641 } /* switch(data->bytesperpix) */
1642 break;
1644 case vHidd_StdPixFmt_Native32:
1645 switch(bm->bpp)
1647 case 1:
1649 struct pHidd_BitMap_GetMem32Image8 __m = {
1650 sd->mid_GetMem32Image8,
1651 (APTR)VideoData,
1652 msg->x,
1653 msg->y,
1654 msg->pixels,
1655 msg->width,
1656 msg->height,
1657 bm->pitch,
1658 msg->modulo
1659 }, *m = &__m;
1661 OOP_DoMethod(o, (OOP_Msg)m);
1663 break;
1665 case 2:
1667 struct pHidd_BitMap_GetMem32Image16 __m = {
1668 sd->mid_GetMem32Image16,
1669 (APTR)VideoData,
1670 msg->x,
1671 msg->y,
1672 msg->pixels,
1673 msg->width,
1674 msg->height,
1675 bm->pitch,
1676 msg->modulo
1677 }, *m = &__m;
1679 OOP_DoMethod(o, (OOP_Msg)m);
1681 break;
1683 case 4:
1685 struct pHidd_BitMap_CopyMemBox32 __m = {
1686 sd->mid_CopyMemBox32,
1687 (APTR)VideoData,
1688 msg->x,
1689 msg->y,
1690 msg->pixels,
1693 msg->width,
1694 msg->height,
1695 bm->pitch,
1696 msg->modulo
1697 }, *m = &__m;
1699 OOP_DoMethod(o, (OOP_Msg)m);
1701 break;
1703 } /* switch(data->bytesperpix) */
1704 break;
1706 default:
1707 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
1708 break;
1710 } /* switch(msg->pixFmt) */
1712 UNLOCK_BITMAP
1716 VOID METHOD(ATIOffBM, Hidd_BitMap, PutTemplate)
1717 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, PutTemplate))));
1719 VOID METHOD(ATIOnBM, Hidd_BitMap, PutTemplate)
1721 atiBitMap *bm = OOP_INST_DATA(cl, o);
1723 LOCK_BITMAP
1725 IPTR VideoData = bm->framebuffer;
1727 if (bm->fbgfx)
1729 VideoData += (IPTR)sd->Card.FrameBuffer;
1730 if (sd->Card.Busy)
1732 LOCK_HW
1733 #warning TODO: NVSync(sd)
1734 RADEONWaitForIdleMMIO(sd);
1735 UNLOCK_HW
1740 switch(bm->bpp)
1742 case 1:
1744 struct pHidd_BitMap_PutMemTemplate8 __m = {
1745 sd->mid_PutMemTemplate8,
1746 msg->gc,
1747 msg->template,
1748 msg->modulo,
1749 msg->srcx,
1750 (APTR)VideoData,
1751 bm->pitch,
1752 msg->x,
1753 msg->y,
1754 msg->width,
1755 msg->height,
1756 msg->inverttemplate
1757 }, *m = &__m;
1759 OOP_DoMethod(o, (OOP_Msg)m);
1761 break;
1763 case 2:
1765 struct pHidd_BitMap_PutMemTemplate16 __m = {
1766 sd->mid_PutMemTemplate16,
1767 msg->gc,
1768 msg->template,
1769 msg->modulo,
1770 msg->srcx,
1771 (APTR)VideoData,
1772 bm->pitch,
1773 msg->x,
1774 msg->y,
1775 msg->width,
1776 msg->height,
1777 msg->inverttemplate
1778 }, *m = &__m;
1780 OOP_DoMethod(o, (OOP_Msg)m);
1782 break;
1784 case 4:
1786 struct pHidd_BitMap_PutMemTemplate32 __m = {
1787 sd->mid_PutMemTemplate32,
1788 msg->gc,
1789 msg->template,
1790 msg->modulo,
1791 msg->srcx,
1792 (APTR)VideoData,
1793 bm->pitch,
1794 msg->x,
1795 msg->y,
1796 msg->width,
1797 msg->height,
1798 msg->inverttemplate
1799 }, *m = &__m;
1801 OOP_DoMethod(o, (OOP_Msg)m);
1803 break;
1804 } /* switch(bm->bpp) */
1806 UNLOCK_BITMAP
1809 VOID METHOD(ATIOffBM, Hidd_BitMap, PutPattern)
1810 __attribute__((alias(METHOD_NAME_S(ATIOnBM, Hidd_BitMap, PutPattern))));
1812 VOID METHOD(ATIOnBM, Hidd_BitMap, PutPattern)
1814 atiBitMap *bm = OOP_INST_DATA(cl, o);
1816 LOCK_BITMAP
1818 IPTR VideoData = bm->framebuffer;
1820 if (bm->fbgfx)
1822 VideoData += (IPTR)sd->Card.FrameBuffer;
1823 if (sd->Card.Busy)
1825 LOCK_HW
1826 #warning TODO: NVSync(sd)
1827 RADEONWaitForIdleMMIO(sd);
1828 UNLOCK_HW
1833 switch(bm->bpp)
1835 case 1:
1837 struct pHidd_BitMap_PutMemPattern8 __m = {
1838 sd->mid_PutMemPattern8,
1839 msg->gc,
1840 msg->pattern,
1841 msg->patternsrcx,
1842 msg->patternsrcy,
1843 msg->patternheight,
1844 msg->patterndepth,
1845 msg->patternlut,
1846 msg->invertpattern,
1847 msg->mask,
1848 msg->maskmodulo,
1849 msg->masksrcx,
1850 (APTR)VideoData,
1851 bm->pitch,
1852 msg->x,
1853 msg->y,
1854 msg->width,
1855 msg->height
1856 }, *m = &__m;
1858 OOP_DoMethod(o, (OOP_Msg)m);
1860 break;
1862 case 2:
1864 struct pHidd_BitMap_PutMemPattern16 __m = {
1865 sd->mid_PutMemPattern16,
1866 msg->gc,
1867 msg->pattern,
1868 msg->patternsrcx,
1869 msg->patternsrcy,
1870 msg->patternheight,
1871 msg->patterndepth,
1872 msg->patternlut,
1873 msg->invertpattern,
1874 msg->mask,
1875 msg->maskmodulo,
1876 msg->masksrcx,
1877 (APTR)VideoData,
1878 bm->pitch,
1879 msg->x,
1880 msg->y,
1881 msg->width,
1882 msg->height
1883 }, *m = &__m;
1885 OOP_DoMethod(o, (OOP_Msg)m);
1887 break;
1889 case 4:
1891 struct pHidd_BitMap_PutMemPattern32 __m = {
1892 sd->mid_PutMemPattern32,
1893 msg->gc,
1894 msg->pattern,
1895 msg->patternsrcx,
1896 msg->patternsrcy,
1897 msg->patternheight,
1898 msg->patterndepth,
1899 msg->patternlut,
1900 msg->invertpattern,
1901 msg->mask,
1902 msg->maskmodulo,
1903 msg->masksrcx,
1904 (APTR)VideoData,
1905 bm->pitch,
1906 msg->x,
1907 msg->y,
1908 msg->width,
1909 msg->height
1910 }, *m = &__m;
1912 OOP_DoMethod(o, (OOP_Msg)m);
1914 break;
1915 } /* switch(bm->bpp) */
1917 UNLOCK_BITMAP