union bt_cmap {
u_int8_t cm_map[256][3];
u_int32_t cm_chip[256 * 3 / 4];
};
#define BT_ADDR 0x00
#define BT_CMAP 0x04
#define BT_CTRL 0x08
#define BT_OMAP 0x0c
#define BT_D4M3(x) ((((x) >> 2) << 1) + ((x) >> 2))
#define BT_D4M4(x) ((x) & ~3)
#define CGSIX_ROM_OFFSET 0x000000
#define CGSIX_BT_OFFSET 0x200000
#define CGSIX_BT_SIZE (sizeof(u_int32_t) * 4)
#define CGSIX_DHC_OFFSET 0x240000
#define CGSIX_ALT_OFFSET 0x280000
#define CGSIX_FHC_OFFSET 0x300000
#define CGSIX_FHC_SIZE (sizeof(u_int32_t) * 1)
#define CGSIX_THC_OFFSET 0x301000
#define CGSIX_THC_SIZE (sizeof(u_int32_t) * 640)
#define CGSIX_FBC_OFFSET 0x700000
#define CGSIX_FBC_SIZE 0x1000
#define CGSIX_TEC_OFFSET 0x701000
#define CGSIX_TEC_SIZE (sizeof(u_int32_t) * 3)
#define CGSIX_VID_OFFSET 0x800000
#define CGSIX_VID_SIZE (1024 * 1024)
#define CG6_FHC 0x0
#define FHC_FBID_MASK 0xff000000
#define FHC_FBID_SHIFT 24
#define FHC_REV_MASK 0x00f00000
#define FHC_REV_SHIFT 20
#define FHC_FROP_DISABLE 0x00080000
#define FHC_ROW_DISABLE 0x00040000
#define FHC_SRC_DISABLE 0x00020000
#define FHC_DST_DISABLE 0x00010000
#define FHC_RESET 0x00008000
#define FHC_LEBO 0x00002000
#define FHC_RES_MASK 0x00001800
#define FHC_RES_1024 0x00000000
#define FHC_RES_1152 0x00000800
#define FHC_RES_1280 0x00001000
#define FHC_RES_1600 0x00001800
#define FHC_CPU_MASK 0x00000600
#define FHC_CPU_SPARC 0x00000000
#define FHC_CPU_68020 0x00000200
#define FHC_CPU_386 0x00000400
#define FHC_TEST 0x00000100
#define FHC_TESTX_MASK 0x000000f0
#define FHC_TESTX_SHIFT 4
#define FHC_TESTY_MASK 0x0000000f
#define FHC_TESTY_SHIFT 0
#define CG6_FBC_MODE 0x004
#define CG6_FBC_CLIP 0x008
#define CG6_FBC_S 0x010
#define CG6_FBC_DRAW 0x014
#define CG6_FBC_BLIT 0x018
#define CG6_FBC_FONT 0x01c
#define CG6_FBC_X0 0x080
#define CG6_FBC_Y0 0x084
#define CG6_FBC_Z0 0x088
#define CB6_FBC_C0 0x08c
#define CG6_FBC_X1 0x090
#define CG6_FBC_Y1 0x094
#define CG6_FBC_Z1 0x098
#define CB6_FBC_C1 0x09c
#define CG6_FBC_X2 0x0a0
#define CG6_FBC_Y2 0x0a4
#define CG6_FBC_Z2 0x0a8
#define CB6_FBC_C2 0x0ac
#define CG6_FBC_X3 0x0b0
#define CG6_FBC_Y3 0x0b4
#define CG6_FBC_Z3 0x0b8
#define CB6_FBC_C3 0x0bc
#define CG6_FBC_OFFX 0x0c0
#define CG6_FBC_OFFY 0x0c4
#define CG6_FBC_INCX 0x0d0
#define CG6_FBC_INCY 0x0d4
#define CG6_FBC_CLIPMINX 0x0e0
#define CG6_FBC_CLIPMINY 0x0e4
#define CG6_FBC_CLIPMAXX 0x0f0
#define CG6_FBC_CLIPMAXY 0x0f4
#define CG6_FBC_FG 0x100
#define CG6_FBC_BG 0x104
#define CG6_FBC_ALU 0x108
#define CG6_FBC_PM 0x10c
#define CG6_FBC_PIXELM 0x110
#define CG6_FBC_PATALIGN 0x11c
#define CG6_FBC_PATTERN 0x120
#define CG6_FBC_APOINTX 0x800
#define CG6_FBC_APOINTY 0x804
#define CG6_FBC_APOINTZ 0x808
#define CG6_FBC_RPOINTX 0x810
#define CG6_FBC_RPOINTY 0x814
#define CG6_FBC_RPOINTZ 0x818
#define CG6_FBC_POINTR 0x830
#define CG6_FBC_POINTG 0x834
#define CG6_FBC_POINTB 0x838
#define CG6_FBC_POINTA 0x83c
#define CG6_FBC_ALINEX 0x840
#define CG6_FBC_ALINEY 0x844
#define CG6_FBC_ALINEZ 0x848
#define CG6_FBC_RLINEX 0x850
#define CG6_FBC_RLINEY 0x854
#define CG6_FBC_RLINEZ 0x858
#define CG6_FBC_LINER 0x870
#define CG6_FBC_LINEG 0x874
#define CG6_FBC_LINEB 0x878
#define CG6_FBC_LINEA 0x87c
#define CG6_FBC_ATRIX 0x880
#define CG6_FBC_ATRIY 0x884
#define CG6_FBC_ATRIZ 0x888
#define CG6_FBC_RTRIX 0x890
#define CG6_FBC_RTRIY 0x894
#define CG6_FBC_RTRIZ 0x898
#define CG6_FBC_TRIR 0x8b0
#define CG6_FBC_TRIG 0x8b4
#define CG6_FBC_TRIB 0x8b8
#define CG6_FBC_TRIA 0x8bc
#define CG6_FBC_AQUADX 0x8c0
#define CG6_FBC_AQUADY 0x8c4
#define CG6_FBC_AQUADZ 0x8c8
#define CG6_FBC_RQUADX 0x8d0
#define CG6_FBC_RQUADY 0x8d4
#define CG6_FBC_RQUADZ 0x8d8
#define CG6_FBC_QUADR 0x8f0
#define CG6_FBC_QUADG 0x8f4
#define CG6_FBC_QUADB 0x8f8
#define CG6_FBC_QUADA 0x8fc
#define CG6_FBC_ARECTX 0x900
#define CG6_FBC_ARECTY 0x904
#define CG6_FBC_ARECTZ 0x908
#define CG6_FBC_RRECTX 0x910
#define CG6_FBC_RRECTY 0x914
#define CG6_FBC_RRECTZ 0x918
#define CG6_FBC_RRECTR 0x930
#define CG6_FBC_RRECTG 0x934
#define CG6_FBC_RRECTB 0x938
#define CG6_FBC_RRECTA 0x938
#define FBC_MODE_VAL ( \
0x00200000 \
| 0x00020000 \
| 0x00008000 \
| 0x00002000 \
| 0x00001000 \
| 0x00000200 \
| 0x00000080 \
)
#define FBC_MODE_MASK ( \
0x00300000 \
| 0x00060000 \
| 0x00018000 \
| 0x00006000 \
| 0x00001800 \
| 0x00000600 \
| 0x00000180 \
)
#define FBC_S_GXINPROGRESS 0x10000000
#define FBC_BLIT_UNKNOWN 0x80000000
#define FBC_BLIT_GXFULL 0x20000000
#define FBC_DRAW_UNKNOWN 0x80000000
#define FBC_DRAW_GXFULL 0x20000000
#define FBC_ALU_COPY ( \
0x80000000 \
| 0x20000000 \
| 0x00800000 \
| 0x00000000 \
| 0x00000000 \
| 0x08000000 \
| 0x01000000 \
| 0x0000cccc \
)
#define FBC_ALU_FILL ( \
0x80000000 \
| 0x20000000 \
| 0x00800000 \
| 0x00000000 \
| 0x00000000 \
| 0x08000000 \
| 0x01000000 \
| 0x0000ff00 \
)
#define FBC_ALU_FLIP ( \
0x80000000 \
| 0x20000000 \
| 0x00800000 \
| 0x00000000 \
| 0x00000000 \
| 0x08000000 \
| 0x01000000 \
| 0x00005555 \
)
#define CG6_TEC_MV 0x0
#define CG6_TEC_CLIP 0x4
#define CG6_TEC_VDC 0x8
#define CG6_THC_HSYNC1 0x800
#define CG6_THC_HSYNC2 0x804
#define CG6_THC_HSYNC3 0x808
#define CG6_THC_VSYNC1 0x80c
#define CG6_THC_VSYNC2 0x810
#define CG6_THC_REFRESH 0x814
#define CG6_THC_MISC 0x818
#define CG6_THC_CURSXY 0x8fc
#define CG6_THC_CURSMASK 0x900
#define CG6_THC_CURSBITS 0x980
#define THC_CURSOFF ((65536-32) | ((65536-32) << 16))
#define THC_MISC_REV_M 0x000f0000
#define THC_MISC_REV_S 16
#define THC_MISC_RESET 0x00001000
#define THC_MISC_VIDEN 0x00000400
#define THC_MISC_SYNC 0x00000200
#define THC_MISC_VSYNC 0x00000100
#define THC_MISC_SYNCEN 0x00000080
#define THC_MISC_CURSRES 0x00000040
#define THC_MISC_INTEN 0x00000020
#define THC_MISC_INTR 0x00000010
#define THC_MISC_CYCLS 0x0000000f
struct cgsix_softc {
struct sunfb sc_sunfb;
bus_space_tag_t sc_bustag;
bus_addr_t sc_paddr;
bus_space_handle_t sc_bt_regs;
bus_space_handle_t sc_fhc_regs;
bus_space_handle_t sc_thc_regs;
bus_space_handle_t sc_tec_regs;
bus_space_handle_t sc_vid_regs;
bus_space_handle_t sc_fbc_regs;
int sc_nscreens;
union bt_cmap sc_cmap;
void *sc_ih;
u_int sc_mode;
u_int sc_curs_enabled, sc_curs_fg, sc_curs_bg;
struct wsdisplay_curpos sc_curs_pos, sc_curs_hot, sc_curs_size;
u_char sc_curs_image[128], sc_curs_mask[128];
};
#define CG6_USER_FBC 0x70000000
#define CG6_USER_TEC 0x70001000
#define CG6_USER_BTREGS 0x70002000
#define CG6_USER_FHC 0x70004000
#define CG6_USER_THC 0x70005000
#define CG6_USER_ROM 0x70006000
#define CG6_USER_RAM 0x70016000
#define CG6_USER_DHC 0x80000000
#define THC_READ(sc,r) \
bus_space_read_4((sc)->sc_bustag, (sc)->sc_thc_regs, (r))
#define THC_WRITE(sc,r,v) \
bus_space_write_4((sc)->sc_bustag, (sc)->sc_thc_regs, (r), (v))
#define TEC_READ(sc,r) \
bus_space_read_4((sc)->sc_bustag, (sc)->sc_tec_regs, (r))
#define TEC_WRITE(sc,r,v) \
bus_space_write_4((sc)->sc_bustag, (sc)->sc_tec_regs, (r), (v))
#define FHC_READ(sc) \
bus_space_read_4((sc)->sc_bustag, (sc)->sc_fhc_regs, CG6_FHC)
#define FHC_WRITE(sc,v) \
bus_space_write_4((sc)->sc_bustag, (sc)->sc_fhc_regs, CG6_FHC, (v))
#define FBC_READ(sc,r) \
bus_space_read_4((sc)->sc_bustag, (sc)->sc_fbc_regs, (r))
#define FBC_WRITE(sc,r,v) \
bus_space_write_4((sc)->sc_bustag, (sc)->sc_fbc_regs, (r), (v))
#define BT_WRITE(sc, reg, val) \
bus_space_write_4((sc)->sc_bustag, (sc)->sc_bt_regs, (reg), (val))
#define BT_READ(sc, reg) \
bus_space_read_4((sc)->sc_bustag, (sc)->sc_bt_regs, (reg))
#define BT_BARRIER(sc,reg,flags) \
bus_space_barrier((sc)->sc_bustag, (sc)->sc_bt_regs, (reg), \
sizeof(u_int32_t), (flags))
#define CG6_BLIT_WAIT(sc) \
while ((FBC_READ(sc, CG6_FBC_BLIT) & \
(FBC_BLIT_UNKNOWN|FBC_BLIT_GXFULL)) == \
(FBC_BLIT_UNKNOWN|FBC_BLIT_GXFULL))
#define CG6_DRAW_WAIT(sc) \
while ((FBC_READ(sc, CG6_FBC_DRAW) & \
(FBC_DRAW_UNKNOWN|FBC_DRAW_GXFULL)) == \
(FBC_DRAW_UNKNOWN|FBC_DRAW_GXFULL))
#define CG6_DRAIN(sc) \
while (FBC_READ(sc, CG6_FBC_S) & FBC_S_GXINPROGRESS)
#define CG6_MAX_CURSOR 32
#define CG6_CFFLAG_NOACCEL 0x1