cg14.h revision e311bbee
1/*
2 * CG14 framebuffer - defines.
3 *
4 * Copyright (C) 2000 Jakub Jelinek (jakub@redhat.com)
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19 * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23
24#ifndef CG14_H
25#define CG14_H
26
27#include "xf86.h"
28#include "xf86_OSproc.h"
29#include "xf86RamDac.h"
30#include <X11/Xmd.h>
31#include "gcstruct.h"
32#include "xf86sbusBus.h"
33#include "exa.h"
34
35/* Various offsets in virtual (ie. mmap()) spaces Linux and Solaris support. */
36#define CG14_REGS_VOFF		0x00000000	/* registers */
37#define CG14_XLUT_VOFF		0x00003000	/* X Look Up Table */
38#define CG14_CLUT1_VOFF		0x00004000	/* Color Look Up Table */
39#define CG14_CLUT2_VOFF		0x00005000	/* Color Look Up Table */
40#define CG14_CLUT3_VOFF		0x00006000	/* Color Look Up Table */
41#define CG14_DIRECT_VOFF	0x10000000
42#define CG14_CTLREG_VOFF	0x20000000
43#define CG14_CURSOR_VOFF	0x30000000
44#define CG14_SHDW_VRT_VOFF	0x40000000
45#define CG14_XBGR_VOFF		0x50000000
46#define CG14_BGR_VOFF		0x60000000
47#define CG14_X16_VOFF		0x70000000
48#define CG14_C16_VOFF		0x80000000
49#define CG14_X32_VOFF		0x90000000
50#define CG14_B32_VOFF		0xa0000000
51#define CG14_G32_VOFF		0xb0000000
52#define CG14_R32_VOFF		0xc0000000
53
54/* these two are NetBSD specific */
55#define CG14_SXREG_VOFF		0x00010000	/* SX userspace registers */
56#define CG14_SXIO_VOFF		0xd0000000
57
58
59/* Hardware cursor map */
60#define CG14_CURS_SIZE		32
61struct cg14curs {
62	volatile uint32_t	curs_plane0[CG14_CURS_SIZE];	/* plane 0 */
63	volatile uint32_t	curs_plane1[CG14_CURS_SIZE];
64	volatile uint8_t	curs_ctl;	/* control register */
65#define CG14_CURS_ENABLE	0x4
66#define CG14_CURS_DOUBLEBUFFER	0x2 		/* use X-channel for curs */
67	volatile uint8_t	pad0[3];
68	volatile uint16_t	curs_x;		/* x position */
69	volatile uint16_t	curs_y;		/* y position */
70	volatile uint32_t	curs_color1;	/* color register 1 */
71	volatile uint32_t	curs_color2;	/* color register 2 */
72	volatile uint32_t	pad[444];	/* pad to 2KB boundary */
73	volatile uint32_t	curs_plane0incr[CG14_CURS_SIZE]; /* autoincr */
74	volatile uint32_t	curs_plane1incr[CG14_CURS_SIZE]; /* autoincr */
75};
76
77typedef struct {
78	unsigned char	*fb;
79	unsigned char	*x32;
80	unsigned char	*xlut;
81	struct cg14curs	*curs;
82	int		width;
83	int		height;
84	int		use_shadow;
85	int		memsize;
86	int		HWCursor;
87	void *		shadow;
88	sbusDevicePtr	psdp;
89	CloseScreenProcPtr CloseScreen;
90	CreateScreenResourcesProcPtr CreateScreenResources;
91	OptionInfoPtr	Options;
92	xf86CursorInfoPtr	CursorInfoRec;
93	/* SX accel stuff */
94	void		*sxreg, *sxio;
95	int		use_accel, use_xrender;
96	uint32_t	last_mask;
97	uint32_t	last_rop;
98	uint32_t	srcoff, srcpitch, mskoff, mskpitch;
99	uint32_t	srcformat, dstformat, mskformat;
100	uint32_t	fillcolour;
101	int		op;
102	Bool		source_is_solid, no_source_pixmap;
103	int		xdir, ydir;
104	ExaDriverPtr 	pExa;
105} Cg14Rec, *Cg14Ptr;
106
107/* SX stuff */
108/* write an SX register */
109static inline void
110write_sx_reg(Cg14Ptr p, int reg, uint32_t val)
111{
112	*(volatile uint32_t *)(p->sxreg + reg) = val;
113}
114
115/* read an SX register */
116static inline uint32_t
117read_sx_reg(Cg14Ptr p, int reg)
118{
119	return *(volatile uint32_t *)(p->sxreg + reg);
120}
121
122/* write a memory referencing instruction */
123static inline void
124write_sx_io(Cg14Ptr p, int reg, uint32_t val)
125{
126	*(volatile uint32_t *)(p->sxio + (reg & ~7)) = val;
127}
128
129Bool CG14SetupCursor(ScreenPtr);
130Bool CG14InitAccel(ScreenPtr);
131
132/* xrender ops */
133void CG14Comp_Over8Solid(Cg14Ptr, uint32_t, uint32_t, uint32_t, uint32_t,
134                   int, int);
135void CG14Comp_Over32Solid(Cg14Ptr, uint32_t, uint32_t, uint32_t, uint32_t,
136                   int, int);
137void CG14Comp_Over32(Cg14Ptr, uint32_t, uint32_t, uint32_t, uint32_t,
138                   int, int, int);
139void CG14Comp_Over32Mask(Cg14Ptr, uint32_t, uint32_t, uint32_t, uint32_t,
140                   uint32_t, uint32_t, int, int, int);
141void CG14Comp_Over32Mask_noalpha(Cg14Ptr, uint32_t, uint32_t, uint32_t,
142		   uint32_t, uint32_t, uint32_t, int, int, int);
143void CG14Comp_Over32Mask32_noalpha(Cg14Ptr, uint32_t, uint32_t, uint32_t,
144		   uint32_t, uint32_t, uint32_t, int, int, int);
145void CG14Comp_Add8(Cg14Ptr, uint32_t, uint32_t, uint32_t, uint32_t,
146                   int, int);
147void CG14Comp_Add8_32(Cg14Ptr, uint32_t, uint32_t, uint32_t, uint32_t,
148                   int, int);
149void CG14Comp_Add32(Cg14Ptr, uint32_t, uint32_t, uint32_t, uint32_t,
150                   int, int);
151
152#define GET_CG14_FROM_SCRN(p)    ((Cg14Ptr)((p)->driverPrivate))
153
154/*
155 * This should match corresponding definition in Solaris's
156 * '/usr/include/sys/cg14io.h'.
157 */
158#ifdef __NetBSD__
159#include <dev/sun/fbio.h>
160#include <sys/ioccom.h>
161#define CG14_SET_PIXELMODE	_IOW('M', 3, int)
162#else
163#define CG14_SET_PIXELMODE	(('M' << 8) | 3)
164#endif
165
166#endif /* CG14_H */
167