xref: /netbsd-src/sys/dev/hpc/hpcfbio.h (revision 659f65e0ee29a604a89f76f049906e3fbc49abf7)
1 /*	$NetBSD: hpcfbio.h,v 1.1 2001/02/22 18:37:55 uch Exp $	*/
2 
3 /*-
4  * Copyright (c) 1999
5  *         Shin Takemura and PocketBSD Project. All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *	This product includes software developed by the PocketBSD project
18  *	and its contributors.
19  * 4. Neither the name of the project nor the names of its contributors
20  *    may be used to endorse or promote products derived from this software
21  *    without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  *
35  */
36 
37 #ifndef H_HPCFBIO
38 #define	H_HPCFBIO
39 
40 #include <sys/types.h>
41 #include <sys/ioccom.h>
42 
43 #define HPCFB_MAXNAMELEN	32
44 #define HPCFB_DEFAULT_CONFIG	0
45 #define HPCFB_CURRENT_CONFIG	-1
46 #define HPCFB_DEFAULT_UNIT	0
47 #define HPCFB_CURRENT_UNIT	-1
48 
49 #define HPCFB_CLASS_UNKNOWN	0	/* unknown class		*/
50 #define HPCFB_CLASS_GRAYSCALE	1	/* gray scale (maybe monochrome)*/
51 #define HPCFB_CLASS_INDEXCOLOR	2	/* index color			*/
52 #define HPCFB_CLASS_RGBCOLOR	3	/* RGB color			*/
53 
54 #define	HPCFB_ACCESS_CACHEABLE	(1<<0)	/* cacheable			*/
55 #define	HPCFB_ACCESS_BYTE      	(1<<1) 	/* permit 8 bit access		*/
56 #define	HPCFB_ACCESS_WORD      	(1<<2) 	/* permit 16 bit access		*/
57 #define	HPCFB_ACCESS_3BYTE     	(1<<3) 	/* permit 3 bytes access       	*/
58 #define	HPCFB_ACCESS_DWORD     	(1<<4) 	/* permit 32 bit access		*/
59 #define	HPCFB_ACCESS_5BYTE     	(1<<5) 	/* permit 5 bytes access       	*/
60 #define	HPCFB_ACCESS_6BYTE     	(1<<6) 	/* permit 6 bytes access       	*/
61 #define	HPCFB_ACCESS_7BYTE     	(1<<7) 	/* permit 7 bytes access	*/
62 #define	HPCFB_ACCESS_QWORD     	(1<<8) 	/* permit 64 bit access		*/
63 #define	HPCFB_ACCESS_9BYTE     	(1<<9) 	/* permit 9 bytes access	*/
64 #define	HPCFB_ACCESS_10BYTE    	(1<<10)	/* permit 10 bytes access	*/
65 #define	HPCFB_ACCESS_11BYTE    	(1<<11)	/* permit 11 bytes access	*/
66 #define	HPCFB_ACCESS_12BYTE    	(1<<12)	/* permit 12 bytes access	*/
67 #define	HPCFB_ACCESS_13BYTE    	(1<<13)	/* permit 13 bytes access	*/
68 #define	HPCFB_ACCESS_14BYTE    	(1<<14)	/* permit 14 bytes access	*/
69 #define	HPCFB_ACCESS_15BYTE    	(1<<15)	/* permit 15 bytes access	*/
70 #define	HPCFB_ACCESS_OWORD     	(1<<16)	/* permit 128 bit access	*/
71 
72 #define	HPCFB_ACCESS_LSB_TO_MSB	(1<<17)	/* first pixel is at LSB side	*/
73 #define	HPCFB_ACCESS_R_TO_L	(1<<18)	/* pixel order is right to left	*/
74 #define	HPCFB_ACCESS_B_TO_T	(1<<19)	/* pixel order is bottom to top	*/
75 #define HPCFB_ACCESS_Y_TO_X	(1<<20)	/* pixel ordef is Y to X	*/
76 #define	HPCFB_ACCESS_STATIC	(1<<21)	/* no translation table		*/
77 #define	HPCFB_ACCESS_REVERSE	(1<<22)	/* value 0 means white		*/
78 #define	HPCFB_ACCESS_PACK_BLANK	(1<<23)	/* pack has a blank at MSB     	*/
79 #define	HPCFB_ACCESS_PIXEL_BLANK (1<<24)/* pixel has a blank at MSB	*/
80 #define	HPCFB_ACCESS_ALPHA_REVERSE (1<<25) /* alpha value 0 means thick	*/
81 
82 #define	HPCFB_SWAP_BYTE		(1<<0)
83 #define	HPCFB_SWAP_WORD		(1<<1)
84 #define	HPCFB_SWAP_DWORD	(1<<2)
85 #define	HPCFB_SWAP_QWORD	(1<<3)
86 
87 struct hpcfb_fbconf {
88 	short	hf_conf_index;		/* configuration index		*/
89 	short	hf_nconfs;		/* how many configurations	*/
90 
91 	short	hf_class;		/* HPCFB_CLASS_*		*/
92 
93 	char	hf_name[HPCFB_MAXNAMELEN];
94 				      	/* frame buffer name, null terminated*/
95 	char	hf_conf_name[HPCFB_MAXNAMELEN];
96 					/* config name, null terminated	*/
97 
98 	short	hf_height;		/* how many lines	       	*/
99 	short	hf_width;		/* how many pixels in a line   	*/
100 
101 	u_long	hf_baseaddr;		/* frame buffer start address  	*/
102 	u_long	hf_offset;		/* frame buffer start offset for mmap*/
103 	short	hf_bytes_per_line;	/**/
104 	short	hf_nplanes;		/**/
105 	long	hf_bytes_per_plane;	/**/
106 
107 	short	hf_pack_width;		/* how many bits in a pack     	*/
108 	short	hf_pixels_per_pack;	/* how many pixels in a pack   	*/
109 	short	hf_pixel_width;		/* effective bits width	       	*/
110 
111 	u_long	hf_access_flags;	/* HPCFB_ACCESS_*		*/
112 	u_long	hf_swap_flags;		/* HPCFB_SWAP_*			*/
113 	u_long	hf_reg_offset;   	/* hardware register offset for mmap */
114 	u_long	hf_reserved[3];
115 
116 	/*
117 	 * class dependend data
118 	 */
119 	short	hf_class_data_length;
120 	union {
121 		char	hf_place_holder[128];
122 		struct hf_gray_tag {
123 			u_long	hf_flags;	/* reserved for future use */
124 		} hf_gray;
125 		struct hf_indexed_tag {
126 			u_long	hf_flags;	/* reserved for future use */
127 		} hf_indexed;
128 		struct hf_rgb_tag {
129 			u_long	hf_flags;	/* reserved for future use */
130 
131 			short	hf_red_width;
132 			short	hf_red_shift;
133 			short	hf_green_width;
134 			short	hf_green_shift;
135 			short	hf_blue_width;
136 			short	hf_blue_shift;
137 			short	hf_alpha_width;
138 			short	hf_alpha_shift;
139 		} hf_rgb;
140 	} hf_u;
141 
142 	/*
143 	 * extended data for future use
144 	 */
145 	int	hf_ext_size;			/* this value is 0     	*/
146 	void	*hf_ext_data;       		/* this value is NULL  	*/
147 };
148 
149 #define HPCFB_DSP_CLASS_UNKNOWN		0	/* unknown display type	*/
150 #define HPCFB_DSP_CLASS_COLORCRT	1	/* color CRT		*/
151 #define HPCFB_DSP_CLASS_COLORLCD	2	/* color LCD		*/
152 #define HPCFB_DSP_CLASS_GRAYCRT		3	/* gray or mono CRT	*/
153 #define HPCFB_DSP_CLASS_GRAYLCD		4	/* gray or mono LCD	*/
154 #define HPCFB_DSP_CLASS_EXTERNAL	5	/* external output	*/
155 #define HPCFB_DSP_CLASS_VIDEO		6	/* external video output*/
156 
157 #define HPCFB_DSP_DPI_UNKNOWN		0
158 
159 struct hpcfb_dspconf {
160 	short	hd_unit_index;		/* display unit index		*/
161 	short	hd_nunits;	     	/* how many display units	*/
162 
163 	short	hd_class;		/* HPCFB_DSP_CLASS_*		*/
164 	char	hd_name[HPCFB_MAXNAMELEN];
165 				      	/* display name			*/
166 
167 	unsigned long	hd_op_flags;
168 	unsigned long	hd_reserved[3];
169 
170 	short	hd_conf_index;		/* configuration index		*/
171 	short	hd_nconfs;		/* how many configurations	*/
172 	char	hd_conf_name[HPCFB_MAXNAMELEN];
173 					/* configuration name		*/
174 	short	hd_width;
175 	short	hd_height;
176 	short	hd_xdpi;
177 	short	hd_ydpi;
178 
179 };
180 
181 struct hpcfb_dsp_op {
182 	short	op;
183 	long	args[4];
184 	short	ext_size;
185 	void	*ext_arg;
186 };
187 
188 /*
189  * view port postion
190  * arg0 is x_offset
191  * arg1 is y_offset
192  */
193 #define HPCFB_DSP_OP_VIEW	0
194 
195 /*
196  * display settings
197  * arg0 is bright;
198  * arg1 is contrast;
199  */
200 #define HPCFB_DSP_OP_BRIGHT    	1
201 
202 /*
203  * power state
204  * arg0 is power state
205  */
206 #define HPCFB_DSP_OP_POWER     	2
207 #define HPCFB_DSP_PW_ON		0	/* full power 			*/
208 #define HPCFB_DSP_PW_SAVE	10	/* power save mode, but not blank */
209 #define HPCFB_DSP_PW_CUT	20	/* power save mode, screen is blank */
210 #define HPCFB_DSP_PW_OFF	30	/* power off			*/
211 
212 /*
213  * output signal settings
214  * ext_arg is struct hpcfb_dsp_signal
215  */
216 #define HPCFB_DSP_OP_SIGNAL    	3
217 #define HPCFB_DSP_SIG_H_SYNC_HIGH	(1<<0)
218 #define HPCFB_DSP_SIG_V_SYNC_HIGH	(1<<1)
219 #define HPCFB_DSP_SIG_C_SYNC_HIGH	(1<<2)
220 #define HPCFB_DSP_SIG_SYNC_EXT		(1<<3)
221 #define HPCFB_DSP_SIG_SYNC_GREEN	(1<<4)
222 struct hpcfb_dsp_signal {
223 	unsigned long	flags;
224 	long	pixclock;	/* pixel clock in pico seconds	*/
225 	long	left_margin;	/* time from H sync to picture	*/
226 	long	right_margin;	/* time from picture to H sync	*/
227 	long	upper_margin;	/* time from V sync to picture	*/
228 	long	lower_margin;	/* time from picture to V sync	*/
229 	long	hsync_len;	/* length of H sync		*/
230 	long	vsync_len;	/* length of V sync		*/
231 };
232 
233 #define	HPCFBIO_GCONF		_IOWR('H', 0, struct hpcfb_fbconf)
234 #define	HPCFBIO_SCONF		_IOW('H', 1, struct hpcfb_fbconf)
235 #define	HPCFBIO_GDSPCONF	_IOWR('H', 2, struct hpcfb_dspconf)
236 #define	HPCFBIO_SDSPCONF	_IOW('H', 3, struct hpcfb_dspconf)
237 #define	HPCFBIO_GOP		_IOR('H', 4, struct hpcfb_dsp_op)
238 #define	HPCFBIO_SOP		_IOWR('H', 5, struct hpcfb_dsp_op)
239 
240 #endif /* H_HPCFBIO */
241