xref: /netbsd-src/sys/arch/mac68k/dev/grfvar.h (revision 355a2878fad22b80314bcbfd857f2fb9f9076bd0)
1*355a2878Srin /*	$NetBSD: grfvar.h,v 1.32 2019/07/26 10:48:44 rin Exp $	*/
24fdae7a0Scgd 
38ae7f8bcSbriggs /*
49b6bd2d9Srmind  * Copyright (c) 1988 University of Utah.
58ae7f8bcSbriggs  * Copyright (c) 1990 The Regents of the University of California.
68ae7f8bcSbriggs  * All rights reserved.
78ae7f8bcSbriggs  *
88ae7f8bcSbriggs  * This code is derived from software contributed to Berkeley by
98ae7f8bcSbriggs  * the Systems Programming Group of the University of Utah Computer
108ae7f8bcSbriggs  * Science Department.
118ae7f8bcSbriggs  *
128ae7f8bcSbriggs  * Redistribution and use in source and binary forms, with or without
138ae7f8bcSbriggs  * modification, are permitted provided that the following conditions
148ae7f8bcSbriggs  * are met:
158ae7f8bcSbriggs  * 1. Redistributions of source code must retain the above copyright
168ae7f8bcSbriggs  *    notice, this list of conditions and the following disclaimer.
178ae7f8bcSbriggs  * 2. Redistributions in binary form must reproduce the above copyright
188ae7f8bcSbriggs  *    notice, this list of conditions and the following disclaimer in the
198ae7f8bcSbriggs  *    documentation and/or other materials provided with the distribution.
20aad01611Sagc  * 3. Neither the name of the University nor the names of its contributors
21aad01611Sagc  *    may be used to endorse or promote products derived from this software
22aad01611Sagc  *    without specific prior written permission.
23aad01611Sagc  *
24aad01611Sagc  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25aad01611Sagc  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26aad01611Sagc  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27aad01611Sagc  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28aad01611Sagc  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29aad01611Sagc  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30aad01611Sagc  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31aad01611Sagc  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32aad01611Sagc  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33aad01611Sagc  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34aad01611Sagc  * SUCH DAMAGE.
35aad01611Sagc  *
36aad01611Sagc  * from: Utah $Hdr: grfvar.h 1.9 91/01/21$
37aad01611Sagc  *
38aad01611Sagc  *	@(#)grfvar.h	7.3 (Berkeley) 5/7/91
39aad01611Sagc  */
408ae7f8bcSbriggs 
4159b4da2bSbriggs #define CARD_NAME_LEN	64
42d048582cSscottr 
43d048582cSscottr /*
44*355a2878Srin  * Color map, required for DAFB to support genfb(4).
45*355a2878Srin  */
46*355a2878Srin struct grfbus_cmap {
47*355a2878Srin 	uint8_t		*red;
48*355a2878Srin 	uint8_t		*green;
49*355a2878Srin 	uint8_t		*blue;
50*355a2878Srin };
51*355a2878Srin 
52*355a2878Srin /*
53d048582cSscottr  * State info, per hardware instance.
54d048582cSscottr  */
55d048582cSscottr struct grfbus_softc {
56cbab9cadSchs 	device_t	sc_dev;
5759b4da2bSbriggs 	nubus_slot	sc_slot;
586bc53a23Sbriggs 
5963526c1fSscottr 	bus_addr_t		sc_basepa;	/* base of video space */
6063526c1fSscottr 	bus_addr_t		sc_fbofs;	/* offset to framebuffer */
61da2f2cb7Sscottr 
62a3d5b326Sbriggs 	bus_space_tag_t		sc_tag;
63ee80f120Sscottr 	bus_space_handle_t	sc_handle;
64a3d5b326Sbriggs 	bus_space_handle_t	sc_regh;
65a3d5b326Sbriggs 
6659b4da2bSbriggs 	struct	grfmode curr_mode;	/* hardware desc(for ioctl)	*/
67a3d5b326Sbriggs 	u_int32_t	card_id;	/* DrHW value for nubus cards	*/
68ef8ecc05Sscottr 	bus_size_t	cli_offset;	/* Offset to clear interrupt	*/
69a3d5b326Sbriggs 					/* for cards where that's suff.	*/
70ef8ecc05Sscottr 	u_int32_t	cli_value;	/* Value to write at cli_offset */
7159b4da2bSbriggs 	nubus_dir	board_dir;	/* Nubus dir for curr board	*/
72*355a2878Srin 
73*355a2878Srin 	bus_space_handle_t	sc_cmh;
74*355a2878Srin 	void			(*sc_set_mapreg)(void *, int, int, int, int);
75*355a2878Srin 	struct grfbus_cmap	sc_cmap;
76d048582cSscottr };
77d048582cSscottr 
78d048582cSscottr /*
79d048582cSscottr  * State info, per grf instance.
80d048582cSscottr  */
81d048582cSscottr struct grf_softc {
828a007407Sscottr 	char sc_xname[15];		/* name of the device */
838a007407Sscottr 	struct macfb_softc *mfb_sc;
84d048582cSscottr };
85d048582cSscottr 
86d048582cSscottr /*
87d048582cSscottr  * Attach grf and ite semantics to Mac video hardware.
88d048582cSscottr  */
89d048582cSscottr struct grfbus_attach_args {
904e4eb31eSrjs 	const char	*ga_name;	/* name of semantics to attach */
91ee80f120Sscottr 	bus_space_tag_t	ga_tag;		/* forwarded ... */
92ee80f120Sscottr 	bus_space_handle_t ga_handle;
93ee80f120Sscottr 	struct grfmode	*ga_grfmode;
94d048582cSscottr 	nubus_slot	*ga_slot;
9563526c1fSscottr 	bus_addr_t	ga_phys;
968a007407Sscottr 	bus_addr_t	ga_fboff;
977acd68b1Schs 	int		(*ga_mode)(struct grf_softc *, int, void *);
98*355a2878Srin 	void		(*ga_set_mapreg)(void *, int, int, int, int);
99*355a2878Srin 	struct grfbus_softc *ga_parent;
1008ae7f8bcSbriggs };
1018ae7f8bcSbriggs 
10253524e44Schristos typedef	void *(*grf_phys_t)(struct grf_softc *, vaddr_t);
10337163421Sbriggs 
1048ae7f8bcSbriggs /* flags */
1058ae7f8bcSbriggs #define	GF_ALIVE	0x01
1068ae7f8bcSbriggs #define GF_OPEN		0x02
1078ae7f8bcSbriggs #define GF_EXCLUDE	0x04
1088ae7f8bcSbriggs #define GF_WANTED	0x08
1098ae7f8bcSbriggs #define GF_BSDOPEN	0x10
1108ae7f8bcSbriggs #define GF_HPUXOPEN	0x20
1118ae7f8bcSbriggs 
1128ae7f8bcSbriggs /* requests to mode routine */
1138ae7f8bcSbriggs #define GM_GRFON	1
1148ae7f8bcSbriggs #define GM_GRFOFF	2
11559b4da2bSbriggs #define GM_CURRMODE	3
11659b4da2bSbriggs #define GM_LISTMODES	4
11759b4da2bSbriggs #define GM_NEWMODE	5
1188ae7f8bcSbriggs 
1198ae7f8bcSbriggs /* minor device interpretation */
1208a007407Sscottr #define GRFUNIT(d)	(minor(d))
1218ae7f8bcSbriggs 
12259b4da2bSbriggs /*
12359b4da2bSbriggs  * Nubus image data structure.  This is the equivalent of a PixMap in
12459b4da2bSbriggs  * MacOS programming parlance.  One of these structures exists for each
12559b4da2bSbriggs  * video mode that a quickdraw compatible card can fit in.
12659b4da2bSbriggs  */
12759b4da2bSbriggs struct image_data {
12859b4da2bSbriggs 	u_int32_t	size;
12959b4da2bSbriggs 	u_int32_t	offset;
13059b4da2bSbriggs 	u_int16_t	rowbytes;
13159b4da2bSbriggs 	u_int16_t	top;
13259b4da2bSbriggs 	u_int16_t	left;
13359b4da2bSbriggs 	u_int16_t	bottom;
13459b4da2bSbriggs 	u_int16_t	right;
13559b4da2bSbriggs 	u_int16_t	version;
13659b4da2bSbriggs 	u_int16_t	packType;
13759b4da2bSbriggs 	u_int32_t	packSize;
13859b4da2bSbriggs 	u_int32_t	hRes;
13959b4da2bSbriggs 	u_int32_t	vRes;
14059b4da2bSbriggs 	u_int16_t	pixelType;
14159b4da2bSbriggs 	u_int16_t	pixelSize;
14259b4da2bSbriggs 	u_int16_t	cmpCount;
14359b4da2bSbriggs 	u_int16_t	cmpSize;
14459b4da2bSbriggs 	u_int32_t	planeBytes;
14559b4da2bSbriggs };
14659b4da2bSbriggs 
14759b4da2bSbriggs #define VID_PARAMS		1
14859b4da2bSbriggs #define VID_TABLE_OFFSET	2
14959b4da2bSbriggs #define VID_PAGE_CNT		3
15059b4da2bSbriggs #define VID_DEV_TYPE		4
15137163421Sbriggs 
1527acd68b1Schs void	grf_attach(struct macfb_softc *, int);
153d048582cSscottr 
1547acd68b1Schs void	grf_establish(struct grfbus_softc *, nubus_slot *,
1557acd68b1Schs 	    int (*)(struct grf_softc *, int, void *));
1567acd68b1Schs int	grfbusprint(void *, const char *);
157