xref: /netbsd/sys/arch/amiga/dev/grfabs_ccreg.h (revision 6550d01e)
1 /*	$NetBSD: grfabs_ccreg.h,v 1.9 2006/03/08 23:46:22 lukem Exp $	*/
2 
3 /*
4  * Copyright (c) 1994 Christian E. Hopps
5  * 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 Christian E. Hopps.
18  * 4. The name of the author may not be used to endorse or promote products
19  *    derived from this software without specific prior written permission
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #if ! defined (_GRFABS_CCREG_H)
34 #define _GRFABS_CCREG_H
35 
36 typedef colormap_t *alloc_colormap_func (int);
37 
38 typedef struct monitor_data {
39     LIST_HEAD(modelist, display_mode) modes; /* a list of supported modes. */
40     dmode_t *current_mode;
41     u_long    flags;		  /* monitor flags. */
42 } mdata_t;
43 
44 typedef struct display_mode_data {
45     monitor_t  * monitor;	/* the monitor that owns this mode. */
46     view_t * current_view;	/* current view to be displayed. */
47     cop_t  **frames;
48     u_short    hedley_current;	/* current hedley quadrent. */
49     u_short    bplcon0;		/* bplcon0 data. */
50     u_short    std_start_x;
51     u_short    std_start_y;
52 #if defined (GRF_ECS) || defined (GRF_AGA)
53     /* ECS registers. */
54     u_short   beamcon0;
55     u_short   hbstart;		/* no modes use the rest of these */
56     u_short   hbstop;		/* ECS registers. */
57     u_short   hsstart;
58     u_short   hsstop;
59     u_short   vbstart;
60     u_short   vbstop;
61     u_short   vsstart;
62     u_short   vsstop;
63 #endif
64     /* some limit stuff. */
65     dimen_t   max_size;		/* largest fit. */
66     dimen_t   min_size;		/* smallest fit. */
67     u_short   min_depth;
68     u_short   max_depth;
69     u_long   flags;		/* mode specific flags. */
70     use_colormap_func *use_colormap;
71     get_colormap_func *get_colormap;
72     alloc_colormap_func *alloc_colormap;
73     display_view_func  *display_view;
74     vbl_handler_func   *vbl_handler;	/* gets called every vertical blank. */
75 					/* when this is the current mode.*/
76 } dmdata_t;
77 
78 enum dmode_flag_bits {
79     DMB_INTERLACE,
80     DMB_HEDLEY_EXP
81 };
82 
83 enum dmode_flags {
84     DMF_INTERLACE = 1 << DMB_INTERLACE,
85     DMF_HEDLEY_EXP = 1 << DMB_HEDLEY_EXP
86 };
87 
88 typedef struct view_data {
89     dmode_t *mode;		/* the mode for this view */
90     colormap_t *colormap;
91     u_long    flags;		/* view specific flags. */
92 } vdata_t;
93 
94 enum view_flag_bits {
95     VB_DISPLAY,
96 };
97 
98 enum view_flags {
99     VF_DISPLAY = 1 << VB_DISPLAY,  /* set if view is being displayed */
100 };
101 
102 /*
103  *  This that are in grfabs_ccglb.c
104  */
105 #if defined (GRF_A2024)
106 #  if defined (GRF_PAL)
107 extern cop_t std_pal_a2024_copper_list[];
108 extern int std_pal_a2024_copper_list_len;
109 extern int std_pal_a2024_copper_list_size;
110 #  endif
111 #  if defined (GRF_NTSC)
112 extern cop_t std_a2024_copper_list[];
113 extern int std_a2024_copper_list_len;
114 extern int std_a2024_copper_list_size;
115 #  endif
116 extern cop_t std_dlace_copper_list[];
117 extern int std_dlace_copper_list_len;
118 extern int std_dlace_copper_list_size;
119 
120 extern u_short a2024_color_value_line0[4];
121 extern u_short a2024_color_value_line1[4];
122 #endif /* GRF_A2024 */
123 
124 #if defined(GRF_AGA)
125 extern cop_t aga_copper_list[];
126 extern int aga_copper_list_len;
127 extern int aga_copper_list_size;
128 #endif
129 
130 extern cop_t std_copper_list[];
131 extern int std_copper_list_len;
132 extern int std_copper_list_size;
133 extern monitor_t *cc_monitor;
134 extern u_short cc_default_colors[32];
135 extern u_short cc_a2024_default_colors[4];
136 
137 /*
138  * Misc macros, defines and enums.
139  */
140 
141 #define MDATA(m) ((mdata_t *)(m->data))
142 #define DMDATA(d) ((dmdata_t *)(d->data))
143 #define VDATA(v) ((vdata_t *)(v->data))
144 #define RWDATA(r) ((rwdata_t *)(r->data))
145 
146 #if defined (GRF_ECS) || defined (GRF_AGA)
147 #define CALC_DIWHIGH(hs, vs, he, ve) \
148         ((u_short)((he&0x100)<<5)|(ve&0x700)|((hs&0x100)>>3)|((vs&0x700)>>8))
149 #define USE_CON3 0x0001
150 #else
151 #define USE_CON3 0x0
152 #endif
153 
154 enum lace_frame_numbers {
155     F_LACE_LONG,
156     F_LACE_SHORT,
157     F_LACE_STORE_LONG,
158     F_LACE_STORE_SHORT,
159     F_LACE_TOTAL
160 };
161 
162 enum frame_numbers {
163     F_LONG,
164     F_STORE_LONG,
165     F_TOTAL
166 };
167 
168 #if defined (GRF_A2024)
169 
170 /*
171  * Defines macros and enums for A2024 hedley expansion
172  */
173 
174 enum quad_frame_numbers {
175     F_QD_QUAD0, F_QD_QUAD1, F_QD_QUAD2, F_QD_QUAD3,
176     F_QD_STORE_QUAD0, F_QD_STORE_QUAD1, F_QD_STORE_QUAD2, F_QD_STORE_QUAD3,
177     F_QD_TOTAL
178 };
179 
180 /* -------
181  * |0 |1 |
182  * |------
183  * |2 |3 |
184  * -------
185  */
186 
187 #define QUAD0_ID 0x0001
188 #define QUAD1_ID 0x00f1
189 #define QUAD2_ID 0x0f01
190 #define QUAD3_ID 0x0ff1
191 
192 #define HALF_2024_LINE (512>>3)
193 #define DIGITAL_RED 0x0800
194 #define DIGITAL_GREEN 0x0080
195 #define DIGITAL_BLUE 0x0008
196 #define DIGITAL_INTENSE 0x0001
197 
198 #define A2024_L0_BLACK  (0)
199 #define A2024_L0_DGREY  (DIGITAL_BLUE)
200 #define A2024_L0_LGREY  (DIGITAL_RED)
201 #define A2024_L0_WHITE  (DIGITAL_RED|DIGITAL_BLUE)
202 
203 #define A2024_L1_BLACK  (0)
204 #define A2024_L1_DGREY  (DIGITAL_INTENSE)
205 #define A2024_L1_LGREY  (DIGITAL_GREEN)
206 #define A2024_L1_WHITE  (DIGITAL_GREEN|DIGITAL_INTENSE)
207 
208 #define A2024_L0_INDEX(color_reg) (((0x4&color_reg)>>1)|(0x1&color_reg))
209 #define A2024_L1_INDEX(color_reg) (((0x8&color_reg)>>2)|((0x2&color_reg)>>1))
210 #define A2024_CM_TO_CR(cm,rn) \
211 	(a2024_color_value_line0[0x3 & (cm)->entry[A2024_L0_INDEX(rn)]] |\
212 	 a2024_color_value_line1[0x3 & (cm)->entry[A2024_L1_INDEX(rn)]])
213 #endif /* GRF_A2024 */
214 
215 /*
216  *  Misc defined values for custom chips.
217  */
218 
219 /* ECS stuff */
220 #define VARVBLANK	0x1000	/* Variable vertical blank enable */
221 #define LOLDIS		0x0800	/* long line disable */
222 #define CSCBLANKEN	0x0400	/* redirect composite sync */
223 #define VARVSYNC	0x0200	/* Variable vertical sync enable */
224 #define VARHSYNC	0x0100	/* Variable horizontal sync enable */
225 #define VARBEAM	0x0080	/* variable beam counter enable */
226 #define DISPLAYDUAL	0x0040	/* use UHRES pointer and standard pointers */
227 #define DISPLAYPAL	0x0020	/* set decodes to generate PAL display */
228 #define VARCSYNC	0x0010	/* Variable composite sync enable */
229 #define CSBLANK	0x0008	/* Composite blank out to CSY* pin */
230 #define CSYNCTRUE	0x0004	/* composite sync true signal */
231 #define VSYNCTRUE	0x0002	/* vertical sync true */
232 #define HSYNCTRUE	0x0001	/* horizontal sync true */
233 
234 /* new defines for bplcon0 */
235 #define USE_BPLCON3	1
236 
237 /* new defines for bplcon2 */
238 #define BPLCON2_ZDCTEN		(1<<10) /* colormapped genlock bit */
239 #define BPLCON2_ZDBPEN		(1<<11) /* use bitplane as genlock bits */
240 #define BPLCON2_ZDBPSEL0	(1<<12) /* three bits to select one */
241 #define BPLCON2_ZDBPSEL1	(1<<13) /* of 8 bitplanes in */
242 #define BPLCON2_ZDBPSEL2	(1<<14) /* ZDBPEN genlock mode */
243 
244 /* defines for bplcon3 register */
245 #define BPLCON3_EXTBLNKEN	(1<<0)	/* external blank enable */
246 #define BPLCON3_EXTBLKZD	(1<<1)	/* external blank ored into trnsprncy */
247 #define BPLCON3_ZDCLKEN	(1<<2)	/* zd pin outputs a 14 MHz clock*/
248 #define BPLCON3_BRDNTRAN	(1<<4)	/* border is opaque */
249 #define BPLCON3_BRDNBLNK	(1<<5)	/* border is opaque */
250 
251 /* mixture of stuff. */
252 #define	STANDARD_NTSC_ROWS	262
253 #define	STANDARD_PAL_ROWS	312
254 #define	STANDARD_COLORCLOCKS	226
255 #define	STANDARD_DENISE_MAX	455
256 #define	STANDARD_DENISE_MIN	93
257 #define	STANDARD_NTSC_BEAMCON	( 0x0000 )
258 #define	STANDARD_PAL_BEAMCON	( DISPLAYPAL )
259 #define	SPECIAL_BEAMCON	( VARVBLANK | LOLDIS | VARVSYNC | VARHSYNC | VARBEAM | CSBLANK | VSYNCTRUE)
260 
261 #define	MIN_NTSC_ROW	21
262 #define	MIN_PAL_ROW	29
263 #define	STANDARD_VIEW_X	0x81
264 #define	STANDARD_VIEW_Y	0x2C
265 #define	STANDARD_HBSTRT	0x06
266 #define	STANDARD_HSSTRT	0x0B
267 #define	STANDARD_HSSTOP	0x1C
268 #define	STANDARD_HBSTOP	0x2C
269 #define	STANDARD_VBSTRT	0x0122
270 #define	STANDARD_VSSTRT	0x02A6
271 #define	STANDARD_VSSTOP	0x03AA
272 #define	STANDARD_VBSTOP	0x1066
273 
274 /*
275  * Prototypes
276  */
277 
278 #if defined (__STDC__)
279 /* monitor functions */
280 monitor_t *cc_init_monitor(void);
281 void monitor_vbl_handler(monitor_t * m);
282 dmode_t *get_current_mode(void);
283 dmode_t *get_next_mode(dmode_t * d);
284 dmode_t *get_best_mode(dimen_t * size, u_char depth);
285 bmap_t *alloc_bitmap(u_short width, u_short height, u_short depth, u_short flags);
286 void free_bitmap(bmap_t * bm);
287 void cc_load_mode(dmode_t * d);
288 int cc_init_modes(void);
289 /* mode functions */
290 monitor_t *cc_get_monitor(dmode_t * d);
291 view_t *cc_get_current_view(dmode_t * d);
292 view_t *cc_alloc_view(dmode_t * mode, dimen_t * dim, u_char depth);
293 colormap_t *cc_alloc_colormap(int depth);
294 int cc_colormap_checkvals(colormap_t * vcm, colormap_t * cm, int use);
295 int cc_get_colormap(view_t * v, colormap_t * cm);
296 int cc_use_colormap(view_t * v, colormap_t * cm);
297 
298 #  if defined (GRF_A2024)
299 colormap_t *cc_a2024_alloc_colormap(int depth);
300 int cc_a2024_get_colormap(view_t * v, colormap_t * cm);
301 int cc_a2024_use_colormap(view_t * v, colormap_t * cm);
302 #  endif /* GRF_2024 */
303 
304 void cc_mode_vbl_handler(dmode_t * d);
305 void cc_lace_mode_vbl_handler(dmode_t * d);
306 /* view functions */
307 void cc_init_view(view_t * v, bmap_t * bm, dmode_t * mode, box_t * dbox);
308 void cc_free_view(view_t * v);
309 void cc_remove_view(view_t * v);
310 dmode_t * cc_get_display_mode(view_t * v);
311 
312 #if defined (GRF_SUPER72)
313 dmode_t *cc_init_super72(void);
314 void display_super72_view(view_t * v);
315 #endif /* SUPER72 */
316 
317 #  if defined (GRF_NTSC)
318 dmode_t *cc_init_ntsc_hires(void);
319 void display_hires_view(view_t * v);
320 dmode_t *cc_init_ntsc_hires_lace(void);
321 void display_hires_lace_view(view_t * v);
322 
323 #    if defined (GRF_A2024)
324 dmode_t *cc_init_ntsc_hires_dlace(void);
325 void display_hires_dlace_view(view_t * v);
326 dmode_t *cc_init_ntsc_a2024(void);
327 void display_a2024_view(view_t * v);
328 void a2024_mode_vbl_handler(dmode_t * d);
329 #    endif /* GRF_A2024 */
330 
331 #    if defined (GRF_AGA)
332 dmode_t *cc_init_ntsc_aga(void);
333 void display_aga_view(view_t * v);
334 #    endif /* GRF_AGA */
335 #  endif /* GRF_NTSC */
336 
337 #  if defined (GRF_PAL)
338 dmode_t *cc_init_pal_hires(void);
339 void display_pal_hires_view(view_t * v);
340 dmode_t *cc_init_pal_hires_lace(void);
341 void display_pal_hires_lace_view(view_t * v);
342 
343 #    if defined (GRF_A2024)
344 dmode_t *cc_init_pal_hires_dlace(void);
345 void display_pal_hires_dlace_view(view_t * v);
346 
347 dmode_t *cc_init_pal_a2024(void);
348 void display_pal_a2024_view(view_t * v);
349 void pal_a2024_mode_vbl_handler(dmode_t * d);
350 #    endif /* GRF_A2024 */
351 
352 #    if defined (GRF_AGA)
353 dmode_t *cc_init_pal_aga(void);
354 void display_pal_aga_view(view_t * v);
355 #    endif /* GRF_AGA */
356 #  endif /* GRF_PAL */
357 #endif /* __STDC__ */
358 
359 
360 #endif /* _GRFABS_CCABS_H */
361