2 Copyright © 2004, The AROS Development Team. All rights reserved.
8 #include "radeon_reg.h"
9 #include "radeon_bios.h"
10 #include "radeon_accel.h"
11 #include "radeon_macros.h"
14 #include <hidd/graphics.h>
15 #include <hidd/hidd.h>
17 #include <proto/oop.h>
18 #include <proto/utility.h>
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 #define POINT_OUTSIDE_CLIP(gc, x, y) \
38 ( (x) < GC_CLIPX1(gc) \
39 || (x) > GC_CLIPX2(gc) \
40 || (y) < GC_CLIPY1(gc) \
41 || (y) > GC_CLIPY2(gc) )
43 struct pRoot_Dispose
{
47 OOP_Object
*METHOD(ATIOffBM
, Root
, New
)
48 __attribute__((alias(METHOD_NAME_S(ATIOnBM
, Root
, New
))));
50 OOP_Object
*METHOD(ATIOnBM
, Root
, New
)
52 if (cl
== sd
->OnBMClass
)
53 EnterFunc(bug("[ATIBitMap] OnBitmap::New()\n"));
55 EnterFunc(bug("[ATIBitMap] OffBitmap::New()\n"));
57 o
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
60 atiBitMap
*bm
= OOP_INST_DATA(cl
, o
);
62 ULONG width
, height
, depth
;
68 InitSemaphore(&bm
->bmLock
);
70 D(bug("[ATIBitMap] Super called. o=%p\n", o
));
72 bm
->onbm
= (cl
== sd
->OnBMClass
);
74 OOP_GetAttr(o
, aHidd_BitMap_Width
, &width
);
75 OOP_GetAttr(o
, aHidd_BitMap_Height
, &height
);
76 OOP_GetAttr(o
, aHidd_BitMap_PixFmt
, (APTR
)&pf
);
77 OOP_GetAttr(pf
, aHidd_PixFmt_Depth
, &depth
);
78 fb
= GetTagData(aHidd_BitMap_FrameBuffer
, FALSE
, msg
->attrList
);
80 D(bug("[ATIBitmap] width=%d height=%d depth=%d\n", width
, height
, depth
));
82 if (width
== 0 || height
== 0 || depth
== 0)
84 bug("[ATIBitMap] size mismatch!\n");
107 bm
->pitch
= (width
* bytesPerPixel
+ 63) & ~63;
109 bm
->bpp
= bytesPerPixel
;
110 bm
->framebuffer
= AllocBitmapArea(sd
, bm
->width
, bm
->height
, bm
->bpp
, TRUE
);
115 bm
->addresses
= AllocVecPooled(sd
->memPool
, height
* sizeof(void*));
117 if (bm
->framebuffer
!= -1)
120 for (__tmp
=0; __tmp
< height
; __tmp
++)
121 bm
->addresses
[__tmp
] = (void*)(bm
->framebuffer
+ sd
->Card
.FrameBuffer
+ __tmp
*bm
->pitch
);
123 ULONG pitch64
= ((bm
->pitch
)) >> 6;
140 bm
->dp_gui_master_cntl
=
141 ((bm
->datatype
<< RADEON_GMC_DST_DATATYPE_SHIFT
)
142 |RADEON_GMC_CLR_CMP_CNTL_DIS
143 |RADEON_GMC_DST_PITCH_OFFSET_CNTL
);
145 bm
->pitch_offset
= ((bm
->framebuffer
>> 10) | (bm
->pitch
<< 16));
147 D(bug("[ATIBitMap] PITCH_OFFSET=%08x\n", bm
->pitch_offset
));
150 if (cl
== sd
->OnBMClass
)
152 if (fb
&& bm
->framebuffer
!= -1)
154 bm
->state
= (struct CardState
*)AllocPooled(sd
->memPool
,
155 sizeof(struct CardState
));
157 bzero((APTR
)(sd
->Card
.FrameBuffer
+ bm
->framebuffer
), 640*480*2);
163 InitMode(sd
, bm
->state
, 640, 480, 16, 25200, bm
->framebuffer
,
168 LoadState(sd
, bm
->state
);
169 //LoadState(sd, sd->poweron_state);
172 RADEONEngineReset(sd
);
173 RADEONEngineRestore(sd
);
180 else if (bm
->framebuffer
!= -1)
185 /* We should be able to get modeID from the bitmap */
186 OOP_GetAttr(o
, aHidd_BitMap_ModeID
, &modeid
);
188 D(bug("[ATIBitMap] BM_ModeID=%x\n", modeid
));
190 if (modeid
!= vHidd_ModeID_Invalid
)
193 ULONG hdisp
, vdisp
, hstart
, hend
, htotal
, vstart
, vend
, vtotal
;
195 /* Get Sync and PixelFormat properties */
196 struct pHidd_Gfx_GetMode __getmodemsg
= {
200 }, *getmodemsg
= &__getmodemsg
;
202 getmodemsg
->mID
= OOP_GetMethodID((STRPTR
)CLID_Hidd_Gfx
, moHidd_Gfx_GetMode
);
203 OOP_DoMethod(sd
->AtiObject
, (OOP_Msg
)getmodemsg
);
205 OOP_GetAttr(sync
, aHidd_Sync_PixelClock
, &pixel
);
206 OOP_GetAttr(sync
, aHidd_Sync_HDisp
, &hdisp
);
207 OOP_GetAttr(sync
, aHidd_Sync_VDisp
, &vdisp
);
208 OOP_GetAttr(sync
, aHidd_Sync_HSyncStart
, &hstart
);
209 OOP_GetAttr(sync
, aHidd_Sync_VSyncStart
, &vstart
);
210 OOP_GetAttr(sync
, aHidd_Sync_HSyncEnd
, &hend
);
211 OOP_GetAttr(sync
, aHidd_Sync_VSyncEnd
, &vend
);
212 OOP_GetAttr(sync
, aHidd_Sync_HTotal
, &htotal
);
213 OOP_GetAttr(sync
, aHidd_Sync_VTotal
, &vtotal
);
215 bm
->state
= (struct CardState
*)AllocPooled(sd
->memPool
,
216 sizeof(struct CardState
));
224 InitMode(sd
, bm
->state
, width
, height
, depth
, pixel
, bm
->framebuffer
,
226 hstart
, hend
, htotal
,
227 vstart
, vend
, vtotal
);
229 LoadState(sd
, bm
->state
);
232 RADEONEngineReset(sd
);
233 RADEONEngineRestore(sd
);
244 if (bm
->framebuffer
== -1)
247 bm
->framebuffer
= (IPTR
)AllocMem(bm
->pitch
* bm
->height
,
248 MEMF_PUBLIC
| MEMF_CLEAR
);
251 for (__tmp
=0; __tmp
< height
; __tmp
++)
252 bm
->addresses
[__tmp
] = (void*)(bm
->framebuffer
+ __tmp
*bm
->pitch
);
257 if ((bm
->framebuffer
!= 0xffffffff) && (bm
->framebuffer
!= 0))
263 OOP_MethodID disp_mid
= OOP_GetMethodID((STRPTR
)IID_Root
, moRoot_Dispose
);
264 OOP_CoerceMethod(cl
, o
, (OOP_Msg
) &disp_mid
);
271 VOID
METHOD(ATIOffBM
, Root
, Dispose
)
272 __attribute__((alias(METHOD_NAME_S(ATIOnBM
, Root
, Dispose
))));
274 VOID
METHOD(ATIOnBM
, Root
, Dispose
)
276 atiBitMap
*bm
= OOP_INST_DATA(cl
, o
);
280 // NVDmaKickoff(&sd->Card);
281 RADEONWaitForIdleMMIO(sd
);
285 FreeBitmapArea(sd
, bm
->framebuffer
, bm
->width
, bm
->height
, bm
->bpp
);
287 bm
->framebuffer
= -1;
291 FreeMem((APTR
)bm
->framebuffer
, bm
->pitch
* bm
->height
);
293 FreeVecPooled(sd
->memPool
, bm
->addresses
);
296 FreePooled(sd
->memPool
, bm
->state
, sizeof(struct CardState
));
303 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
307 VOID
METHOD(ATIOffBM
, Root
, Get
)
308 __attribute__((alias(METHOD_NAME_S(ATIOnBM
, Root
, Get
))));
310 VOID
METHOD(ATIOnBM
, Root
, Get
)
312 atiBitMap
*bm
= OOP_INST_DATA(cl
, o
);
315 if (IS_ATIBM_ATTR(msg
->attrID
, idx
))
319 case aoHidd_ATIBitMap_Drawable
:
321 *msg
->storage
= bm
->framebuffer
+ (IPTR
)sd
->Card
.FrameBuffer
;
323 *msg
->storage
= bm
->framebuffer
;
327 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
332 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
337 VOID
METHOD(ATIOffBM
, Hidd_BitMap
, Clear
)
338 __attribute__((alias(METHOD_NAME_S(ATIOnBM
, Hidd_BitMap
, Clear
))));
340 VOID
METHOD(ATIOnBM
, Hidd_BitMap
, Clear
)
342 atiBitMap
*bm
= OOP_INST_DATA(cl
, o
);
344 D(bug("[ATI] Clear(%p)\n",
352 sd
->Card
.Busy
= TRUE
;
355 RADEONWaitForFifo(sd
, 1);
356 OUTREG(RADEON_DST_PITCH_OFFSET
, bm
->pitch_offset
);
358 bm
->dp_gui_master_cntl_clip
= (bm
->dp_gui_master_cntl
359 | RADEON_GMC_BRUSH_SOLID_COLOR
360 | RADEON_GMC_SRC_DATATYPE_COLOR
361 | RADEON_ROP
[vHidd_GC_DrawMode_Copy
].pattern
);
363 RADEONWaitForFifo(sd
, 4);
365 OUTREG(RADEON_DP_GUI_MASTER_CNTL
, bm
->dp_gui_master_cntl_clip
);
366 OUTREG(RADEON_DP_BRUSH_FRGD_CLR
, GC_BG(msg
->gc
));
367 OUTREG(RADEON_DP_WRITE_MASK
, ~0);
368 OUTREG(RADEON_DP_CNTL
, (RADEON_DST_X_LEFT_TO_RIGHT
369 | RADEON_DST_Y_TOP_TO_BOTTOM
));
371 RADEONWaitForFifo(sd
, 2);
373 OUTREG(RADEON_DST_Y_X
, 0);
374 OUTREG(RADEON_DST_WIDTH_HEIGHT
, (bm
->width
<< 16) | bm
->height
);
380 ULONG
*ptr
= (ULONG
*)bm
->framebuffer
;
382 int i
= (bm
->pitch
* bm
->height
) >> 2;
387 val
= GC_BG(msg
->gc
) << 16 | (GC_BG(msg
->gc
) & 0xffff);
391 val
= GC_BG(msg
->gc
) << 16 | (GC_BG(msg
->gc
) & 0xffff);
395 do { *ptr
++ = val
; } while(--i
);
401 struct pHidd_BitMap_FillRect
{
402 struct pHidd_BitMap_DrawRect dr
;
405 VOID
METHOD(ATIOffBM
, Hidd_BitMap
, FillRect
)
406 __attribute__((alias(METHOD_NAME_S(ATIOnBM
, Hidd_BitMap
, FillRect
))));
408 VOID
METHOD(ATIOnBM
, Hidd_BitMap
, FillRect
)
410 OOP_Object
*gc
= msg
->dr
.gc
;
411 atiBitMap
*bm
= OOP_INST_DATA(cl
, o
);
413 D(bug("[ATI] FillRect(%p, %d:%d - %d:%d)\n",
414 bm
->framebuffer
, msg
->dr
.minX
, msg
->dr
.minY
, msg
->dr
.maxX
, msg
->dr
.maxY
));
421 sd
->Card
.Busy
= TRUE
;
424 RADEONWaitForFifo(sd
, 1);
425 OUTREG(RADEON_DST_PITCH_OFFSET
, bm
->pitch_offset
);
427 bm
->dp_gui_master_cntl_clip
= (bm
->dp_gui_master_cntl
428 | RADEON_GMC_BRUSH_SOLID_COLOR
429 | RADEON_GMC_SRC_DATATYPE_COLOR
430 | RADEON_ROP
[GC_DRMD(gc
)].pattern
);
432 RADEONWaitForFifo(sd
, 4);
434 OUTREG(RADEON_DP_GUI_MASTER_CNTL
, bm
->dp_gui_master_cntl_clip
);
435 OUTREG(RADEON_DP_BRUSH_FRGD_CLR
, GC_FG(gc
));
436 OUTREG(RADEON_DP_WRITE_MASK
, ~0);
437 OUTREG(RADEON_DP_CNTL
, (RADEON_DST_X_LEFT_TO_RIGHT
438 | RADEON_DST_Y_TOP_TO_BOTTOM
));
440 RADEONWaitForFifo(sd
, 2);
442 OUTREG(RADEON_DST_Y_X
, (msg
->dr
.minY
<< 16) | msg
->dr
.minX
);
443 OUTREG(RADEON_DST_WIDTH_HEIGHT
, ((msg
->dr
.maxX
- msg
->dr
.minX
+ 1) << 16) | (msg
->dr
.maxY
- msg
->dr
.minY
+ 1));
449 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
457 VOID
METHOD(ATIOffBM
, Hidd_BitMap
, DrawLine
)
458 __attribute__((alias(METHOD_NAME_S(ATIOnBM
, Hidd_BitMap
, DrawLine
))));
460 VOID
METHOD(ATIOnBM
, Hidd_BitMap
, DrawLine
)
462 OOP_Object
*gc
= msg
->gc
;
463 atiBitMap
*bm
= OOP_INST_DATA(cl
, o
);
465 D(bug("[ATI] DrawLine(%p, %d:%d - %d:%d) %08x\n",
466 bm
->framebuffer
, msg
->x1
, msg
->y1
, msg
->x2
, msg
->y2
,GC_FG(gc
)));
470 if ((GC_LINEPAT(gc
) =! (UWORD
)~0) || !bm
->fbgfx
)
472 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
477 sd
->Card
.Busy
= TRUE
;
480 RADEONWaitForFifo(sd
, 1);
481 OUTREG(RADEON_DST_PITCH_OFFSET
, bm
->pitch_offset
);
483 bm
->dp_gui_master_cntl_clip
= (bm
->dp_gui_master_cntl
484 | RADEON_GMC_BRUSH_SOLID_COLOR
485 | RADEON_GMC_SRC_DATATYPE_COLOR
486 | RADEON_ROP
[GC_DRMD(gc
)].pattern
);
488 if (sd
->Card
.Type
>= RV200
) {
489 RADEONWaitForFifo(sd
, 1);
490 OUTREG(RADEON_DST_LINE_PATCOUNT
,
491 0x55 << RADEON_BRES_CNTL_SHIFT
);
496 bm
->dp_gui_master_cntl_clip
|= RADEON_GMC_DST_CLIPPING
;
500 x2
= GC_CLIPX2(gc
) + 1;
501 y2
= GC_CLIPY2(gc
) + 1;
503 RADEONWaitForFifo(sd
, 2);
504 OUTREG(RADEON_SC_TOP_LEFT
, (y1
<< 16) | x1
);
505 OUTREG(RADEON_SC_BOTTOM_RIGHT
, (y2
<< 16) | x2
);
508 RADEONWaitForFifo(sd
, 3);
510 OUTREG(RADEON_DP_GUI_MASTER_CNTL
, bm
->dp_gui_master_cntl_clip
);
511 OUTREG(RADEON_DP_BRUSH_FRGD_CLR
, GC_FG(gc
));
512 OUTREG(RADEON_DP_WRITE_MASK
, ~0);
514 RADEONWaitForFifo(sd
, 4);
516 OUTREG(RADEON_DST_LINE_START
, (msg
->y1
<< 16) | msg
->x1
);
517 OUTREG(RADEON_DST_LINE_END
, (msg
->y2
<< 16) | msg
->x2
);
518 OUTREG(RADEON_DST_LINE_START
, (msg
->y2
<< 16) | msg
->x2
);
519 OUTREG(RADEON_DST_LINE_END
, ((msg
->y2
+1) << 16) | (msg
->x2
+1));
528 VOID
METHOD(ATIOffBM
, Hidd_BitMap
, DrawRect
)
529 __attribute__((alias(METHOD_NAME_S(ATIOnBM
, Hidd_BitMap
, DrawRect
))));
531 VOID
METHOD(ATIOnBM
, Hidd_BitMap
, DrawRect
)
533 OOP_Object
*gc
= msg
->gc
;
534 atiBitMap
*bm
= OOP_INST_DATA(cl
, o
);
537 D(bug("[ATI] DrawRect(%p, %d:%d - %d:%d)\n",
538 bm
->framebuffer
, msg
->minX
, msg
->minY
, msg
->maxX
, msg
->maxY
));
540 if (msg
->minX
== msg
->maxX
) addX
= 1; else addX
= 0;
541 if (msg
->minY
== msg
->maxY
) addY
= 1; else addY
= 0;
545 if ((GC_LINEPAT(gc
) =! (UWORD
)~0) || !bm
->fbgfx
)
547 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
552 sd
->Card
.Busy
= TRUE
;
555 RADEONWaitForFifo(sd
, 1);
556 OUTREG(RADEON_DST_PITCH_OFFSET
, bm
->pitch_offset
);
558 bm
->dp_gui_master_cntl_clip
= (bm
->dp_gui_master_cntl
559 | RADEON_GMC_BRUSH_SOLID_COLOR
560 | RADEON_GMC_SRC_DATATYPE_COLOR
561 | RADEON_ROP
[GC_DRMD(gc
)].pattern
);
563 if (sd
->Card
.Type
>= RV200
) {
564 RADEONWaitForFifo(sd
, 1);
565 OUTREG(RADEON_DST_LINE_PATCOUNT
,
566 0x55 << RADEON_BRES_CNTL_SHIFT
);
571 bm
->dp_gui_master_cntl_clip
|= RADEON_GMC_DST_CLIPPING
;
575 x2
= GC_CLIPX2(gc
) + 1;
576 y2
= GC_CLIPY2(gc
) + 1;
578 RADEONWaitForFifo(sd
, 2);
579 OUTREG(RADEON_SC_TOP_LEFT
, (y1
<< 16) | x1
);
580 OUTREG(RADEON_SC_BOTTOM_RIGHT
, (y2
<< 16) | x2
);
583 RADEONWaitForFifo(sd
, 3);
585 OUTREG(RADEON_DP_GUI_MASTER_CNTL
, bm
->dp_gui_master_cntl_clip
);
586 OUTREG(RADEON_DP_BRUSH_FRGD_CLR
, GC_FG(gc
));
587 OUTREG(RADEON_DP_WRITE_MASK
, ~0);
589 RADEONWaitForFifo(sd
, 8);
591 OUTREG(RADEON_DST_LINE_START
, (msg
->minY
<< 16) | (msg
->minX
& 0xffff));
592 OUTREG(RADEON_DST_LINE_END
, (msg
->minY
<< 16) | (msg
->maxX
& 0xffff));
594 OUTREG(RADEON_DST_LINE_START
, ((msg
->minY
+ addY
) << 16) | (msg
->maxX
& 0xffff));
595 OUTREG(RADEON_DST_LINE_END
, ((msg
->maxY
<< 16)) | (msg
->maxX
& 0xffff));
597 OUTREG(RADEON_DST_LINE_START
, ((msg
->maxY
<< 16)) | ((msg
->maxX
- addX
) & 0xffff));
598 OUTREG(RADEON_DST_LINE_END
, ((msg
->maxY
<< 16)) | ((msg
->minX
) & 0xffff));
600 OUTREG(RADEON_DST_LINE_START
, ((msg
->maxY
- addY
) << 16) | (msg
->minX
& 0xffff));
601 OUTREG(RADEON_DST_LINE_END
, ((msg
->minY
+ addY
) << 16) | (msg
->minX
& 0xffff));
610 VOID
METHOD(ATIOffBM
, Hidd_BitMap
, DrawPolygon
)
611 __attribute__((alias(METHOD_NAME_S(ATIOnBM
, Hidd_BitMap
, DrawPolygon
))));
613 VOID
METHOD(ATIOnBM
, Hidd_BitMap
, DrawPolygon
)
615 OOP_Object
*gc
= msg
->gc
;
616 atiBitMap
*bm
= OOP_INST_DATA(cl
, o
);
619 D(bug("[ATI] DrawPolygon(%p)\n",
624 if ((GC_LINEPAT(gc
) =! (UWORD
)~0) || !bm
->fbgfx
)
626 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
631 sd
->Card
.Busy
= TRUE
;
634 RADEONWaitForFifo(sd
, 1);
635 OUTREG(RADEON_DST_PITCH_OFFSET
, bm
->pitch_offset
);
637 bm
->dp_gui_master_cntl_clip
= (bm
->dp_gui_master_cntl
638 | RADEON_GMC_BRUSH_SOLID_COLOR
639 | RADEON_GMC_SRC_DATATYPE_COLOR
640 | RADEON_ROP
[GC_DRMD(gc
)].pattern
);
642 if (sd
->Card
.Type
>= RV200
) {
643 RADEONWaitForFifo(sd
, 1);
644 OUTREG(RADEON_DST_LINE_PATCOUNT
,
645 0x55 << RADEON_BRES_CNTL_SHIFT
);
650 bm
->dp_gui_master_cntl_clip
|= RADEON_GMC_DST_CLIPPING
;
654 x2
= GC_CLIPX2(gc
) + 1;
655 y2
= GC_CLIPY2(gc
) + 1;
657 RADEONWaitForFifo(sd
, 2);
658 OUTREG(RADEON_SC_TOP_LEFT
, (y1
<< 16) | x1
);
659 OUTREG(RADEON_SC_BOTTOM_RIGHT
, (y2
<< 16) | x2
);
662 RADEONWaitForFifo(sd
, 3);
664 OUTREG(RADEON_DP_GUI_MASTER_CNTL
, bm
->dp_gui_master_cntl_clip
);
665 OUTREG(RADEON_DP_BRUSH_FRGD_CLR
, GC_FG(gc
));
666 OUTREG(RADEON_DP_WRITE_MASK
, ~0);
668 for (i
= 2; i
< (2 * msg
->n
); i
+=2)
670 RADEONWaitForFifo(sd
, 2);
671 OUTREG(RADEON_DST_LINE_START
, (msg
->coords
[i
-1] << 16) | msg
->coords
[i
-2]);
672 OUTREG(RADEON_DST_LINE_END
, (msg
->coords
[i
+1] << 16) | msg
->coords
[i
]);
681 VOID
METHOD(ATIOffBM
, Hidd_BitMap
, PutPixel
)
682 __attribute__((alias(METHOD_NAME_S(ATIOnBM
, Hidd_BitMap
, PutPixel
))));
684 VOID
METHOD(ATIOnBM
, Hidd_BitMap
, PutPixel
)
686 atiBitMap
*bm
= OOP_INST_DATA(cl
, o
);
687 void *ptr
= bm
->addresses
[msg
->y
];
696 #warning TODO: NVSync(sd)
697 RADEONWaitForIdleMMIO(sd
);
705 ((UBYTE
*)ptr
)[msg
->x
] = msg
->pixel
;
708 ((UWORD
*)ptr
)[msg
->x
] = msg
->pixel
;
711 ((ULONG
*)ptr
)[msg
->x
] = msg
->pixel
;
718 VOID
METHOD(ATIOffBM
, Hidd_BitMap
, DrawPixel
)
719 __attribute__((alias(METHOD_NAME_S(ATIOnBM
, Hidd_BitMap
, DrawPixel
))));
721 VOID
METHOD(ATIOnBM
, Hidd_BitMap
, DrawPixel
)
723 atiBitMap
*bm
= OOP_INST_DATA(cl
, o
);
724 void *ptr
= bm
->addresses
[msg
->y
];
725 OOP_Object
*gc
= msg
->gc
;
727 HIDDT_Pixel src
, dest
, val
;
729 HIDDT_Pixel writeMask
;
741 #warning TODO: NVSync(sd)
742 RADEONWaitForIdleMMIO(sd
);
747 if (vHidd_GC_DrawMode_Copy
== mode
&& GC_COLMASK(gc
) == ~0)
756 dest
= ((UBYTE
*)ptr
)[msg
->x
];
759 dest
= ((UWORD
*)ptr
)[msg
->x
];
762 dest
= ((ULONG
*)ptr
)[msg
->x
];
766 writeMask
= ~GC_COLMASK(gc
) & dest
;
770 if(mode
& 1) val
= ( src
& dest
);
771 if(mode
& 2) val
= ( src
& ~dest
) | val
;
772 if(mode
& 4) val
= (~src
& dest
) | val
;
773 if(mode
& 8) val
= (~src
& ~dest
) | val
;
775 val
= (val
& (writeMask
| GC_COLMASK(gc
) )) | writeMask
;
781 ((UBYTE
*)ptr
)[msg
->x
] = val
;
784 ((UWORD
*)ptr
)[msg
->x
] = val
;
787 ((ULONG
*)ptr
)[msg
->x
] = val
;
794 VOID
METHOD(ATIOffBM
, Hidd_BitMap
, DrawEllipse
)
795 __attribute__((alias(METHOD_NAME_S(ATIOnBM
, Hidd_BitMap
, DrawEllipse
))));
797 VOID
METHOD(ATIOnBM
, Hidd_BitMap
, DrawEllipse
)
799 atiBitMap
*bm
= OOP_INST_DATA(cl
, o
);
800 OOP_Object
*gc
= msg
->gc
;
801 WORD x
= msg
->rx
, y
= 0; /* ellipse points */
804 HIDDT_Pixel writeMask
;
806 /* intermediate terms to speed up loop */
807 LONG t1
= msg
->rx
* msg
->rx
, t2
= t1
<< 1, t3
= t2
<< 1;
808 LONG t4
= msg
->ry
* msg
->ry
, t5
= t4
<< 1, t6
= t5
<< 1;
809 LONG t7
= msg
->rx
* t5
, t8
= t7
<< 1, t9
= 0L;
810 LONG d1
= t2
- t7
+ (t4
>> 1); /* error terms */
811 LONG d2
= (t1
>> 1) - t8
+ t5
;
813 BOOL doclip
= GC_DOCLIP(gc
);
818 void _drawpixel(int x
, int y
)
820 void *ptr
= bm
->addresses
[y
];
821 HIDDT_Pixel val
, dest
;
823 if (vHidd_GC_DrawMode_Copy
== mode
&& GC_COLMASK(gc
) == ~0)
832 dest
= ((UBYTE
*)ptr
)[x
];
835 dest
= ((UWORD
*)ptr
)[x
];
838 dest
= ((ULONG
*)ptr
)[x
];
842 writeMask
= ~GC_COLMASK(gc
) & dest
;
846 if(mode
& 1) val
= ( src
& dest
);
847 if(mode
& 2) val
= ( src
& ~dest
) | val
;
848 if(mode
& 4) val
= (~src
& dest
) | val
;
849 if(mode
& 8) val
= (~src
& ~dest
) | val
;
851 val
= (val
& (writeMask
| GC_COLMASK(gc
) )) | writeMask
;
857 ((UBYTE
*)ptr
)[x
] = val
;
860 ((UWORD
*)ptr
)[x
] = val
;
863 ((ULONG
*)ptr
)[x
] = val
;
870 UBYTE
*ptr
= (UBYTE
*)((IPTR
)bm
->framebuffer
);
873 ptr
+= (IPTR
)sd
->Card
.FrameBuffer
;
877 #warning TODO: NVSync(sd)
878 RADEONWaitForIdleMMIO(sd
);
883 while (d2
< 0) /* til slope = -1 */
885 /* draw 4 points using symmetry */
889 if (!POINT_OUTSIDE_CLIP(gc
, msg
->x
+ x
, msg
->y
+ y
))
890 _drawpixel(msg
->x
+ x
, msg
->y
+ y
);
892 if (!POINT_OUTSIDE_CLIP(gc
, msg
->x
+ x
, msg
->y
- y
))
893 _drawpixel(msg
->x
+ x
, msg
->y
- y
);
895 if (!POINT_OUTSIDE_CLIP(gc
, msg
->x
- x
, msg
->y
+ y
))
896 _drawpixel(msg
->x
- x
, msg
->y
+ y
);
898 if (!POINT_OUTSIDE_CLIP(gc
, msg
->x
- x
, msg
->y
- y
))
899 _drawpixel(msg
->x
- x
, msg
->y
- y
);
903 _drawpixel(msg
->x
+ x
, msg
->y
+ y
);
904 _drawpixel(msg
->x
+ x
, msg
->y
- y
);
905 _drawpixel(msg
->x
- x
, msg
->y
+ y
);
906 _drawpixel(msg
->x
- x
, msg
->y
- y
);
909 y
++; /* always move up here */
911 if (d1
< 0) /* move straight up */
916 else /* move up and left */
920 d1
= d1
+ t9
+ t2
- t8
;
921 d2
= d2
+ t9
+ t5
- t8
;
925 do /* rest of top right quadrant */
927 /* draw 4 points using symmetry */
930 if (!POINT_OUTSIDE_CLIP(gc
, msg
->x
+ x
, msg
->y
+ y
))
931 _drawpixel(msg
->x
+ x
, msg
->y
+ y
);
933 if (!POINT_OUTSIDE_CLIP(gc
, msg
->x
+ x
, msg
->y
- y
))
934 _drawpixel(msg
->x
+ x
, msg
->y
- y
);
936 if (!POINT_OUTSIDE_CLIP(gc
, msg
->x
- x
, msg
->y
+ y
))
937 _drawpixel(msg
->x
- x
, msg
->y
+ y
);
939 if (!POINT_OUTSIDE_CLIP(gc
, msg
->x
- x
, msg
->y
- y
))
940 _drawpixel(msg
->x
- x
, msg
->y
- y
);
944 _drawpixel(msg
->x
+ x
, msg
->y
+ y
);
945 _drawpixel(msg
->x
+ x
, msg
->y
- y
);
946 _drawpixel(msg
->x
- x
, msg
->y
+ y
);
947 _drawpixel(msg
->x
- x
, msg
->y
- y
);
950 x
--; /* always move left here */
952 if (d2
< 0) /* move up and left */
956 d2
= d2
+ t9
+ t5
- t8
;
958 else /* move straight left */
969 HIDDT_Pixel
METHOD(ATIOffBM
, Hidd_BitMap
, GetPixel
)
970 __attribute__((alias(METHOD_NAME_S(ATIOnBM
, Hidd_BitMap
, GetPixel
))));
972 HIDDT_Pixel
METHOD(ATIOnBM
, Hidd_BitMap
, GetPixel
)
975 atiBitMap
*bm
= OOP_INST_DATA(cl
, o
);
979 void *ptr
= bm
->addresses
[msg
->y
];
986 #warning TODO: NVSync(sd)
987 RADEONWaitForIdleMMIO(sd
);
995 pixel
= ((UBYTE
*)ptr
)[msg
->x
];
998 pixel
= ((UWORD
*)ptr
)[msg
->x
];
1001 pixel
= ((ULONG
*)ptr
)[msg
->x
];
1007 /* Get pen number from colortab */
1012 void METHOD(ATIOffBM
, Hidd_BitMap
, BlitColorExpansion
)
1013 __attribute__((alias(METHOD_NAME_S(ATIOnBM
, Hidd_BitMap
, BlitColorExpansion
))));
1015 void METHOD(ATIOnBM
, Hidd_BitMap
, BlitColorExpansion
)
1017 atiBitMap
*bm
= OOP_INST_DATA(cl
, o
);
1021 if ((OOP_OCLASS(msg
->srcBitMap
) == sd
->PlanarBMClass
) && bm
->fbgfx
)
1023 struct planarbm_data
*planar
= OOP_INST_DATA(OOP_OCLASS(msg
->srcBitMap
), msg
->srcBitMap
);
1026 ULONG skipleft
= msg
->srcX
- (msg
->srcX
& ~31);
1027 ULONG mask
= ~0 << bm
->depth
;
1029 cemd
= GC_COLEXP(msg
->gc
);
1030 bg
= GC_BG(msg
->gc
) | mask
;
1031 fg
= GC_FG(msg
->gc
) | mask
;
1033 ULONG bw
= (msg
->width
+ 31 + skipleft
) & ~31;
1034 LONG x
= msg
->destX
, y
= msg
->destY
, w
= msg
->width
, h
= msg
->height
;
1039 sd
->Card
.Busy
= TRUE
;
1041 RADEONWaitForFifo(sd
, 1);
1042 OUTREG(RADEON_DST_PITCH_OFFSET
, bm
->pitch_offset
);
1044 bm
->dp_gui_master_cntl_clip
= (bm
->dp_gui_master_cntl
1045 | RADEON_GMC_WR_MSK_DIS
1046 | RADEON_GMC_BRUSH_NONE
1047 | RADEON_DP_SRC_SOURCE_HOST_DATA
1048 | RADEON_GMC_DST_CLIPPING
1049 | RADEON_GMC_BYTE_MSB_TO_LSB
1050 | RADEON_ROP
[vHidd_GC_DrawMode_Copy
].rop
);
1052 if (cemd
& vHidd_GC_ColExp_Transparent
)
1054 bm
->dp_gui_master_cntl_clip
|= RADEON_GMC_SRC_DATATYPE_MONO_FG_LA
;
1056 RADEONWaitForFifo(sd
, 6);
1057 OUTREG(RADEON_DP_GUI_MASTER_CNTL
, bm
->dp_gui_master_cntl_clip
);
1058 OUTREG(RADEON_DP_SRC_FRGD_CLR
, fg
);
1062 bm
->dp_gui_master_cntl_clip
|= RADEON_GMC_SRC_DATATYPE_MONO_FG_BG
;
1064 RADEONWaitForFifo(sd
, 7);
1065 OUTREG(RADEON_DP_GUI_MASTER_CNTL
, bm
->dp_gui_master_cntl_clip
);
1066 OUTREG(RADEON_DP_SRC_FRGD_CLR
, fg
);
1067 OUTREG(RADEON_DP_SRC_BKGD_CLR
, bg
);
1070 OUTREG(RADEON_SC_TOP_LEFT
, (y
<< 16) | x
);
1071 OUTREG(RADEON_SC_BOTTOM_RIGHT
, ((y
+h
) << 16) | (x
+w
));
1073 OUTREG(RADEON_DST_X_Y
, ((x
- skipleft
) << 16) | y
);
1074 OUTREG(RADEON_DST_WIDTH_HEIGHT
, (bw
<< 16) | h
);
1076 ULONG
*ptr
= (ULONG
*)planar
->planes
[0];
1077 ptr
+= ((msg
->srcY
* planar
->bytesperrow
) >> 2) + (msg
->srcX
>> 5);
1080 RADEONWaitForFifo(sd
, 1);
1081 OUTREG(RADEON_RBBM_GUICNTL
, RADEON_HOST_DATA_SWAP_32BIT
);
1088 for (i
=0; i
< bw
>> 5; i
++)
1090 RADEONWaitForFifo(sd
, 1);
1091 OUTREG(RADEON_HOST_DATA0
, ptr
[i
]);
1094 ptr
+= planar
->bytesperrow
>> 2;
1098 RADEONWaitForFifo(sd
, 1);
1099 OUTREG(RADEON_RBBM_GUICNTL
, RADEON_HOST_DATA_SWAP_NONE
);
1106 OOP_DoSuperMethod(cl
, o
, msg
);
1112 ULONG
METHOD(ATIOffBM
, Hidd_BitMap
, BytesPerLine
)
1113 __attribute__((alias(METHOD_NAME_S(ATIOnBM
, Hidd_BitMap
, BytesPerLine
))));
1115 ULONG
METHOD(ATIOnBM
, Hidd_BitMap
, BytesPerLine
)
1117 atiBitMap
*bm
= OOP_INST_DATA(cl
, o
);
1119 return (bm
->bpp
* msg
->width
+ 255) & ~255;
1123 BOOL
METHOD(ATIOffBM
, Hidd_BitMap
, ObtainDirectAccess
)
1124 __attribute__((alias(METHOD_NAME_S(ATIOnBM
, Hidd_BitMap
, ObtainDirectAccess
))));
1126 BOOL
METHOD(ATIOnBM
, Hidd_BitMap
, ObtainDirectAccess
)
1128 atiBitMap
*bm
= OOP_INST_DATA(cl
, o
);
1131 IPTR VideoData
= bm
->framebuffer
;
1135 VideoData
+= (IPTR
)sd
->Card
.FrameBuffer
;
1139 #warning TODO: NVSync(sd)
1140 RADEONWaitForIdleMMIO(sd
);
1145 *msg
->addressReturn
= (UBYTE
*)VideoData
;
1146 *msg
->widthReturn
= bm
->pitch
/ bm
->bpp
;
1147 *msg
->heightReturn
= bm
->height
;
1148 *msg
->bankSizeReturn
= *msg
->memSizeReturn
= bm
->pitch
* bm
->height
;
1153 VOID
METHOD(ATIOffBM
, Hidd_BitMap
, ReleaseDirectAccess
)
1154 __attribute__((alias(METHOD_NAME_S(ATIOnBM
, Hidd_BitMap
, ReleaseDirectAccess
))));
1156 VOID
METHOD(ATIOnBM
, Hidd_BitMap
, ReleaseDirectAccess
)
1158 atiBitMap
*bm
= OOP_INST_DATA(cl
, o
);
1165 * Unaccelerated methods
1168 VOID
METHOD(ATIOffBM
, Hidd_BitMap
, PutImageLUT
)
1169 __attribute__((alias(METHOD_NAME_S(ATIOnBM
, Hidd_BitMap
, PutImageLUT
))));
1171 VOID
METHOD(ATIOnBM
, Hidd_BitMap
, PutImageLUT
)
1173 atiBitMap
*bm
= OOP_INST_DATA(cl
, o
);
1175 // bug("[ATI] PutImageLUT(%d, %d, %d, %d, %d, %p)\n", msg->x, msg->y, msg->width, msg->height, msg->modulo, msg->pixels);
1181 // IPTR VideoData = bm->framebuffer;
1186 UBYTE
*src
= msg
->pixels
;
1187 ULONG x_add
= msg
->modulo
;
1188 UWORD height
= msg
->height
;
1189 UWORD bw
= msg
->width
;
1190 HIDDT_Pixel
*colmap
= msg
->pixlut
->pixels
;
1198 sd
->Card
.Busy
= TRUE
;
1200 RADEONWaitForFifo(sd
, 1);
1201 OUTREG(RADEON_DST_PITCH_OFFSET
, bm
->pitch_offset
);
1203 bm
->dp_gui_master_cntl_clip
= (bm
->dp_gui_master_cntl
1204 | RADEON_GMC_WR_MSK_DIS
1205 | RADEON_GMC_BRUSH_NONE
1206 | RADEON_DP_SRC_SOURCE_HOST_DATA
1207 | RADEON_GMC_DST_CLIPPING
1208 | RADEON_GMC_SRC_DATATYPE_COLOR
1209 | RADEON_ROP
[vHidd_GC_DrawMode_Copy
].rop
);
1211 RADEONWaitForFifo(sd
, 5);
1212 OUTREG(RADEON_DP_GUI_MASTER_CNTL
, bm
->dp_gui_master_cntl_clip
);
1214 OUTREG(RADEON_SC_TOP_LEFT
, (msg
->y
<< 16) | msg
->x
);
1215 OUTREG(RADEON_SC_BOTTOM_RIGHT
, ((msg
->y
+msg
->height
) << 16) | (msg
->x
+msg
->width
));
1217 OUTREG(RADEON_DST_X_Y
, ((msg
->x
) << 16) | msg
->y
);
1218 OUTREG(RADEON_DST_WIDTH_HEIGHT
, (bw
<< 16) | msg
->height
);
1223 RADEONWaitForFifo(sd
, 1);
1224 OUTREG(RADEON_RBBM_GUICNTL
, RADEON_HOST_DATA_SWAP_32BIT
);
1228 UBYTE
*line
= (UBYTE
*)src
;
1229 ULONG width
= msg
->width
;
1235 RADEONWaitForFifo(sd
, width
);
1238 case 8: OUTREGN(RADEON_HOST_DATA0
, colmap
[*line
++]);
1239 case 7: OUTREGN(RADEON_HOST_DATA1
, colmap
[*line
++]);
1240 case 6: OUTREGN(RADEON_HOST_DATA2
, colmap
[*line
++]);
1241 case 5: OUTREGN(RADEON_HOST_DATA3
, colmap
[*line
++]);
1242 case 4: OUTREGN(RADEON_HOST_DATA4
, colmap
[*line
++]);
1243 case 3: OUTREGN(RADEON_HOST_DATA5
, colmap
[*line
++]);
1244 case 2: OUTREGN(RADEON_HOST_DATA6
, colmap
[*line
++]);
1245 case 1: OUTREGN(RADEON_HOST_DATA7
, colmap
[*line
++]);
1251 RADEONWaitForFifo(sd
, 8);
1253 OUTREGN(RADEON_HOST_DATA0
, colmap
[*line
++]);
1254 OUTREGN(RADEON_HOST_DATA1
, colmap
[*line
++]);
1255 OUTREGN(RADEON_HOST_DATA2
, colmap
[*line
++]);
1256 OUTREGN(RADEON_HOST_DATA3
, colmap
[*line
++]);
1257 OUTREGN(RADEON_HOST_DATA4
, colmap
[*line
++]);
1258 OUTREGN(RADEON_HOST_DATA5
, colmap
[*line
++]);
1259 OUTREGN(RADEON_HOST_DATA6
, colmap
[*line
++]);
1260 OUTREGN(RADEON_HOST_DATA7
, colmap
[*line
++]);
1269 else if (bm
->bpp
== 2)
1272 RADEONWaitForFifo(sd
, 1);
1273 OUTREG(RADEON_RBBM_GUICNTL
, RADEON_HOST_DATA_SWAP_HDW
);
1277 UBYTE
*line
= (UBYTE
*)src
;
1278 ULONG width
= bw
>> 1;
1282 ULONG tmp
= (colmap
[line
[0]] << 16) | (colmap
[line
[1]] & 0x0000ffff);
1283 RADEONWaitForFifo(sd
, 1);
1284 OUTREG(RADEON_HOST_DATA0
, tmp
);
1294 RADEONWaitForFifo(sd
, 1);
1295 OUTREG(RADEON_RBBM_GUICNTL
, RADEON_HOST_DATA_SWAP_NONE
);
1300 // VideoData += (IPTR)sd->Card.FrameBuffer;
1302 // if (sd->Card.Busy)
1305 //#warning TODO: NVSync(sd)
1306 // RADEONWaitForIdleMMIO(sd);
1315 // struct pHidd_BitMap_CopyLUTMemBox16 __m = {
1316 // sd->mid_CopyLUTMemBox16,
1330 // OOP_DoMethod(o, (OOP_Msg)m);
1336 // struct pHidd_BitMap_CopyLUTMemBox32 __m = {
1337 // sd->mid_CopyLUTMemBox32,
1351 // OOP_DoMethod(o, (OOP_Msg)m);
1356 // OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
1361 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
1367 VOID
METHOD(ATIOffBM
, Hidd_BitMap
, PutImage
)
1368 __attribute__((alias(METHOD_NAME_S(ATIOnBM
, Hidd_BitMap
, PutImage
))));
1370 VOID
METHOD(ATIOnBM
, Hidd_BitMap
, PutImage
)
1372 atiBitMap
*bm
= OOP_INST_DATA(cl
, o
);
1377 IPTR VideoData
= bm
->framebuffer
;
1379 /* Try to PutImage with 2D engine first */
1382 UBYTE
*src
= msg
->pixels
;
1383 ULONG x_add
= msg
->modulo
;
1384 UWORD height
= msg
->height
;
1385 UWORD bw
= msg
->width
;
1397 sd
->Card
.Busy
= TRUE
;
1399 RADEONWaitForFifo(sd
, 1);
1400 OUTREG(RADEON_DST_PITCH_OFFSET
, bm
->pitch_offset
);
1402 bm
->dp_gui_master_cntl_clip
= (bm
->dp_gui_master_cntl
1403 | RADEON_GMC_WR_MSK_DIS
1404 | RADEON_GMC_BRUSH_NONE
1405 | RADEON_DP_SRC_SOURCE_HOST_DATA
1406 | RADEON_GMC_DST_CLIPPING
1407 | RADEON_GMC_SRC_DATATYPE_COLOR
1408 | RADEON_ROP
[vHidd_GC_DrawMode_Copy
].rop
);
1410 RADEONWaitForFifo(sd
, 5);
1411 OUTREG(RADEON_DP_GUI_MASTER_CNTL
, bm
->dp_gui_master_cntl_clip
);
1413 OUTREG(RADEON_SC_TOP_LEFT
, (msg
->y
<< 16) | msg
->x
);
1414 OUTREG(RADEON_SC_BOTTOM_RIGHT
, ((msg
->y
+msg
->height
) << 16) | (msg
->x
+msg
->width
));
1416 OUTREG(RADEON_DST_X_Y
, ((msg
->x
) << 16) | msg
->y
);
1417 OUTREG(RADEON_DST_WIDTH_HEIGHT
, (bw
<< 16) | msg
->height
);
1419 switch (msg
->pixFmt
)
1421 case vHidd_StdPixFmt_Native32
:
1422 case vHidd_StdPixFmt_Native
:
1426 RADEONWaitForFifo(sd
, 1);
1427 OUTREG(RADEON_RBBM_GUICNTL
, RADEON_HOST_DATA_SWAP_32BIT
);
1431 ULONG
*line
= (ULONG
*)src
;
1432 ULONG width
= msg
->width
;
1438 RADEONWaitForFifo(sd
, width
);
1441 case 8: OUTREGN(RADEON_HOST_DATA0
, *line
++);
1442 case 7: OUTREGN(RADEON_HOST_DATA1
, *line
++);
1443 case 6: OUTREGN(RADEON_HOST_DATA2
, *line
++);
1444 case 5: OUTREGN(RADEON_HOST_DATA3
, *line
++);
1445 case 4: OUTREGN(RADEON_HOST_DATA4
, *line
++);
1446 case 3: OUTREGN(RADEON_HOST_DATA5
, *line
++);
1447 case 2: OUTREGN(RADEON_HOST_DATA6
, *line
++);
1448 case 1: OUTREGN(RADEON_HOST_DATA7
, *line
++);
1454 RADEONWaitForFifo(sd
, 8);
1456 OUTREGN(RADEON_HOST_DATA0
, *line
++);
1457 OUTREGN(RADEON_HOST_DATA1
, *line
++);
1458 OUTREGN(RADEON_HOST_DATA2
, *line
++);
1459 OUTREGN(RADEON_HOST_DATA3
, *line
++);
1460 OUTREGN(RADEON_HOST_DATA4
, *line
++);
1461 OUTREGN(RADEON_HOST_DATA5
, *line
++);
1462 OUTREGN(RADEON_HOST_DATA6
, *line
++);
1463 OUTREGN(RADEON_HOST_DATA7
, *line
++);
1472 RADEONWaitForFifo(sd
, 1);
1473 OUTREG(RADEON_RBBM_GUICNTL
, RADEON_HOST_DATA_SWAP_NONE
);
1477 else if (bm
->bpp
== 2)
1480 RADEONWaitForFifo(sd
, 1);
1481 OUTREG(RADEON_RBBM_GUICNTL
, RADEON_HOST_DATA_SWAP_HDW
);
1483 if (msg
->pixFmt
== vHidd_StdPixFmt_Native
)
1487 ULONG
*line
= (ULONG
*)src
;
1488 ULONG width
= bw
>> 1;
1492 RADEONWaitForFifo(sd
, 1);
1493 OUTREG(RADEON_HOST_DATA0
, *line
++);
1503 ULONG
*line
= (ULONG
*)src
;
1504 ULONG width
= bw
>> 1;
1508 ULONG tmp
= (line
[0] << 16) | (line
[1] & 0x0000ffff);
1509 RADEONWaitForFifo(sd
, 1);
1510 OUTREG(RADEON_HOST_DATA0
, tmp
);
1520 RADEONWaitForFifo(sd
, 1);
1521 OUTREG(RADEON_RBBM_GUICNTL
, RADEON_HOST_DATA_SWAP_NONE
);
1531 srcpf
= HIDD_Gfx_GetPixFmt(sd
->AtiObject
, msg
->pixFmt
);
1532 OOP_GetAttr(o
, aHidd_BitMap_PixFmt
, (APTR
)&dstpf
);
1537 RADEONWaitForFifo(sd
, 1);
1538 OUTREG(RADEON_RBBM_GUICNTL
, RADEON_HOST_DATA_SWAP_32BIT
);
1542 ULONG
*line
= (ULONG
*)sd
->cpuscratch
;
1546 HIDD_BM_ConvertPixels(o
, &_src
, srcpf
, msg
->modulo
, &line
, dstpf
, msg
->modulo
, msg
->width
, 1, NULL
);
1548 line
= (ULONG
*)sd
->cpuscratch
;
1554 RADEONWaitForFifo(sd
, width
);
1557 case 8: OUTREGN(RADEON_HOST_DATA0
, *line
++);
1558 case 7: OUTREGN(RADEON_HOST_DATA1
, *line
++);
1559 case 6: OUTREGN(RADEON_HOST_DATA2
, *line
++);
1560 case 5: OUTREGN(RADEON_HOST_DATA3
, *line
++);
1561 case 4: OUTREGN(RADEON_HOST_DATA4
, *line
++);
1562 case 3: OUTREGN(RADEON_HOST_DATA5
, *line
++);
1563 case 2: OUTREGN(RADEON_HOST_DATA6
, *line
++);
1564 case 1: OUTREGN(RADEON_HOST_DATA7
, *line
++);
1570 RADEONWaitForFifo(sd
, 8);
1572 OUTREGN(RADEON_HOST_DATA0
, *line
++);
1573 OUTREGN(RADEON_HOST_DATA1
, *line
++);
1574 OUTREGN(RADEON_HOST_DATA2
, *line
++);
1575 OUTREGN(RADEON_HOST_DATA3
, *line
++);
1576 OUTREGN(RADEON_HOST_DATA4
, *line
++);
1577 OUTREGN(RADEON_HOST_DATA5
, *line
++);
1578 OUTREGN(RADEON_HOST_DATA6
, *line
++);
1579 OUTREGN(RADEON_HOST_DATA7
, *line
++);
1588 RADEONWaitForFifo(sd
, 1);
1589 OUTREG(RADEON_RBBM_GUICNTL
, RADEON_HOST_DATA_SWAP_NONE
);
1593 else if (bm
->bpp
== 2)
1596 RADEONWaitForFifo(sd
, 1);
1597 OUTREG(RADEON_RBBM_GUICNTL
, RADEON_HOST_DATA_SWAP_HDW
);
1602 ULONG
*line
= (ULONG
*)sd
->cpuscratch
;
1606 HIDD_BM_ConvertPixels(o
, &_src
, srcpf
, msg
->modulo
, &line
, dstpf
, msg
->modulo
, msg
->width
, 1, NULL
);
1608 line
= (ULONG
*)sd
->cpuscratch
;
1614 RADEONWaitForFifo(sd
, width
>> 1);
1617 case 16: OUTREG(RADEON_HOST_DATA0
, *line
++);
1618 case 14: OUTREG(RADEON_HOST_DATA1
, *line
++);
1619 case 12: OUTREG(RADEON_HOST_DATA2
, *line
++);
1620 case 10: OUTREG(RADEON_HOST_DATA3
, *line
++);
1621 case 8: OUTREG(RADEON_HOST_DATA4
, *line
++);
1622 case 6: OUTREG(RADEON_HOST_DATA5
, *line
++);
1623 case 4: OUTREG(RADEON_HOST_DATA6
, *line
++);
1624 case 2: OUTREG(RADEON_HOST_DATA7
, *line
++);
1630 RADEONWaitForFifo(sd
, 8);
1632 OUTREG(RADEON_HOST_DATA0
, *line
++);
1633 OUTREG(RADEON_HOST_DATA1
, *line
++);
1634 OUTREG(RADEON_HOST_DATA2
, *line
++);
1635 OUTREG(RADEON_HOST_DATA3
, *line
++);
1636 OUTREG(RADEON_HOST_DATA4
, *line
++);
1637 OUTREG(RADEON_HOST_DATA5
, *line
++);
1638 OUTREG(RADEON_HOST_DATA6
, *line
++);
1639 OUTREG(RADEON_HOST_DATA7
, *line
++);
1649 RADEONWaitForFifo(sd
, 1);
1650 OUTREG(RADEON_RBBM_GUICNTL
, RADEON_HOST_DATA_SWAP_NONE
);
1662 // 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);
1667 VideoData
+= (IPTR
)sd
->Card
.FrameBuffer
;
1672 #warning TODO: NVSync(sd)
1673 RADEONWaitForIdleMMIO(sd
);
1680 case vHidd_StdPixFmt_Native
:
1685 struct pHidd_BitMap_CopyMemBox8 __m
= {
1686 sd
->mid_CopyMemBox8
,
1699 OOP_DoMethod(o
, (OOP_Msg
)m
);
1705 struct pHidd_BitMap_CopyMemBox16 __m
= {
1706 sd
->mid_CopyMemBox16
,
1719 OOP_DoMethod(o
, (OOP_Msg
)m
);
1725 struct pHidd_BitMap_CopyMemBox32 __m
= {
1726 sd
->mid_CopyMemBox32
,
1739 OOP_DoMethod(o
, (OOP_Msg
)m
);
1743 } /* switch(data->bytesperpix) */
1746 case vHidd_StdPixFmt_Native32
:
1751 struct pHidd_BitMap_PutMem32Image8 __m
= {
1752 sd
->mid_PutMem32Image8
,
1762 OOP_DoMethod(o
, (OOP_Msg
)m
);
1768 struct pHidd_BitMap_PutMem32Image16 __m
= {
1769 sd
->mid_PutMem32Image16
,
1779 OOP_DoMethod(o
, (OOP_Msg
)m
);
1785 struct pHidd_BitMap_CopyMemBox32 __m
= {
1786 sd
->mid_CopyMemBox32
,
1799 OOP_DoMethod(o
, (OOP_Msg
)m
);
1803 } /* switch(data->bytesperpix) */
1807 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
1809 } /* switch(msg->pixFmt) */
1815 VOID
METHOD(ATIOffBM
, Hidd_BitMap
, GetImage
)
1816 __attribute__((alias(METHOD_NAME_S(ATIOnBM
, Hidd_BitMap
, GetImage
))));
1818 VOID
METHOD(ATIOnBM
, Hidd_BitMap
, GetImage
)
1820 atiBitMap
*bm
= OOP_INST_DATA(cl
, o
);
1824 IPTR VideoData
= bm
->framebuffer
;
1828 VideoData
+= (IPTR
)sd
->Card
.FrameBuffer
;
1832 #warning TODO: NVSync(sd)
1833 RADEONWaitForIdleMMIO(sd
);
1840 case vHidd_StdPixFmt_Native
:
1845 struct pHidd_BitMap_CopyMemBox8 __m
= {
1846 sd
->mid_CopyMemBox8
,
1859 OOP_DoMethod(o
, (OOP_Msg
)m
);
1865 struct pHidd_BitMap_CopyMemBox16 __m
= {
1866 sd
->mid_CopyMemBox16
,
1879 OOP_DoMethod(o
, (OOP_Msg
)m
);
1885 struct pHidd_BitMap_CopyMemBox32 __m
= {
1886 sd
->mid_CopyMemBox32
,
1899 OOP_DoMethod(o
, (OOP_Msg
)m
);
1903 } /* switch(data->bytesperpix) */
1906 case vHidd_StdPixFmt_Native32
:
1911 struct pHidd_BitMap_GetMem32Image8 __m
= {
1912 sd
->mid_GetMem32Image8
,
1923 OOP_DoMethod(o
, (OOP_Msg
)m
);
1929 struct pHidd_BitMap_GetMem32Image16 __m
= {
1930 sd
->mid_GetMem32Image16
,
1941 OOP_DoMethod(o
, (OOP_Msg
)m
);
1947 struct pHidd_BitMap_CopyMemBox32 __m
= {
1948 sd
->mid_CopyMemBox32
,
1961 OOP_DoMethod(o
, (OOP_Msg
)m
);
1965 } /* switch(data->bytesperpix) */
1969 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
1972 } /* switch(msg->pixFmt) */
1978 VOID
METHOD(ATIOffBM
, Hidd_BitMap
, PutTemplate
)
1979 __attribute__((alias(METHOD_NAME_S(ATIOnBM
, Hidd_BitMap
, PutTemplate
))));
1981 VOID
METHOD(ATIOnBM
, Hidd_BitMap
, PutTemplate
)
1983 atiBitMap
*bm
= OOP_INST_DATA(cl
, o
);
1987 IPTR VideoData
= bm
->framebuffer
;
1991 VideoData
+= (IPTR
)sd
->Card
.FrameBuffer
;
1995 #warning TODO: NVSync(sd)
1996 RADEONWaitForIdleMMIO(sd
);
2006 struct pHidd_BitMap_PutMemTemplate8 __m
= {
2007 sd
->mid_PutMemTemplate8
,
2021 OOP_DoMethod(o
, (OOP_Msg
)m
);
2027 struct pHidd_BitMap_PutMemTemplate16 __m
= {
2028 sd
->mid_PutMemTemplate16
,
2042 OOP_DoMethod(o
, (OOP_Msg
)m
);
2048 struct pHidd_BitMap_PutMemTemplate32 __m
= {
2049 sd
->mid_PutMemTemplate32
,
2063 OOP_DoMethod(o
, (OOP_Msg
)m
);
2066 } /* switch(bm->bpp) */
2071 VOID
METHOD(ATIOffBM
, Hidd_BitMap
, PutPattern
)
2072 __attribute__((alias(METHOD_NAME_S(ATIOnBM
, Hidd_BitMap
, PutPattern
))));
2074 VOID
METHOD(ATIOnBM
, Hidd_BitMap
, PutPattern
)
2076 atiBitMap
*bm
= OOP_INST_DATA(cl
, o
);
2080 IPTR VideoData
= bm
->framebuffer
;
2084 VideoData
+= (IPTR
)sd
->Card
.FrameBuffer
;
2088 #warning TODO: NVSync(sd)
2089 RADEONWaitForIdleMMIO(sd
);
2099 struct pHidd_BitMap_PutMemPattern8 __m
= {
2100 sd
->mid_PutMemPattern8
,
2120 OOP_DoMethod(o
, (OOP_Msg
)m
);
2126 struct pHidd_BitMap_PutMemPattern16 __m
= {
2127 sd
->mid_PutMemPattern16
,
2147 OOP_DoMethod(o
, (OOP_Msg
)m
);
2153 struct pHidd_BitMap_PutMemPattern32 __m
= {
2154 sd
->mid_PutMemPattern32
,
2174 OOP_DoMethod(o
, (OOP_Msg
)m
);
2177 } /* switch(bm->bpp) */