Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / arch / amiga / dev / grfabs_reg.h
blob6e7c9869dfd711de564eb4163162861c736c81c4
1 /* $NetBSD: grfabs_reg.h,v 1.7.16.1 2005/11/10 13:51:36 skrll Exp $ */
3 /*
4 * Copyright (c) 1994 Christian E. Hopps
5 * All rights reserved.
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
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.
33 #if ! defined (_GRFABS_REG_H)
34 #define _GRFABS_REG_H
36 struct point {
37 long x;
38 long y;
40 typedef struct point point_t;
42 struct dimension {
43 u_long width;
44 u_long height;
46 typedef struct dimension dimen_t;
48 struct box {
49 long x;
50 long y;
51 u_long width;
52 u_long height;
54 typedef struct box box_t;
56 struct rectangle {
57 long left;
58 long top;
59 long right;
60 long bottom;
63 typedef struct rectangle rect_t;
65 typedef struct bitmap bmap_t;
66 typedef struct colormap colormap_t;
67 typedef struct view view_t;
68 typedef struct display_mode dmode_t;
69 typedef struct monitor monitor_t;
71 LIST_HEAD(monitor_list, monitor);
72 extern struct monitor_list *monitors;
75 * Bitmap stuff.
79 * Note structure is 5 long words big. This may come in handy for
80 * contiguous allocations
82 * Please do fill in everything correctly this is the main input for
83 * all other programs. In other words all problems with RTG start here.
84 * If you do not mimic everyone else exactly problems will appear.
85 * If you need a template look at alloc_bitmap() in grf_cc.c.
87 * WARNING: the plane array is only for convience, all data for bitplanes
88 * MUST be contiguous. This is for mapping purposes. The reason
89 * for the plane pointers and row_mod is to support interleaving
90 * on monitors that wish to support this.
92 * 2nd Warning: Also don't get funky with these pointers you are expected
93 * to place the start of mappable plane data in ``hardware_address'',
94 * ``hardware_address'' is the only thing that /dev/view checks and it
95 * expects the planes to follow with no padding in between. If you have
96 * special alignment requirements make use of the given fields
97 * so that the entire contiguous plane data is exactly:
98 * bytes_per_row*height*depth long starting at the physical address
99 * contained within hardware_address.
101 * Final Warning: Plane data must begin on a PAGE address and the allocation
102 * must be ``n'' PAGES big do to mapping requirements (otherwise the
103 * user could write over non-allocated memory.
106 struct bitmap {
107 u_short bytes_per_row; /* number of bytes per display row. */
108 u_short row_mod; /* number of bytes to reach next row. */
109 u_short rows; /* number of display rows. */
110 u_short depth; /* depth of bitmap. */
111 u_short flags; /* flags. */
112 u_short pad;
113 u_char *blit_temp; /* private monitor buffer. */
114 u_char **plane; /* plane data for bitmap. */
115 u_char *hardware_address; /* mappable bitplane pointer. */
118 enum bitmap_flag_bits {
119 BMB_CLEAR, /* init only. */
120 BMB_INTERLEAVED, /* init/read. */
121 BMB_ALIGN64, /* init/read. */
124 enum bitmap_flags {
125 BMF_CLEAR = 1 << BMB_CLEAR, /* init only. */
126 BMF_INTERLEAVED = 1 << BMB_INTERLEAVED, /* init/read. */
127 BMF_ALIGN64 = 1 << BMB_ALIGN64 /* init/read. */
130 /* Use these macros to find misc. sizes of actual bitmap */
131 #define BM_WIDTH(b) ((b)->bytes_per_row << 3)
132 #define BM_HEIGHT(b) ((b)->rows)
133 #define BM_ROW(b,p,l) \
134 ((b)->plane[p] + (((b)->bytes_per_row + (b)->row_mod) * l))
137 * Colormap stuff.
141 * valid masks are a bitfield of zeros followed by ones that indicate
142 * which mask are valid for each component. The ones and zeros will
143 * be contiguous so adding one to this value yields the number of
144 * levels for that component.
145 * -ch
148 struct colormap {
149 u_char type; /* what type of entries these are. */
150 union {
151 /* CM_GREYSCALE */
152 u_char grey;
153 #define grey_mask valid_mask.grey
154 /* CM_COLOR */
155 struct {
156 u_char red;
157 #define red_mask valid_mask.rgb_mask.red
158 u_char green;
159 #define green_mask valid_mask.rgb_mask.green
160 u_char blue;
161 #define blue_mask valid_mask.rgb_mask.blue
162 } rgb_mask;
163 } valid_mask;
164 u_short first; /* what color register does entry[0] refer to. */
165 u_short size; /* number of entries */
166 u_long *entry; /* the table of actual color values. */
169 enum colormap_type {
170 CM_MONO, /* only on or off allowed */
171 CM_GREYSCALE, /* grey vals. */
172 CM_COLOR /* RGB vals. */
175 #define CM_FIXVAL(x) (0xff & (x))
177 /* these macros are for creating entries */
178 #define MAKE_COLOR_ENTRY(r,g,b) \
179 (CM_FIXVAL(r) << 16 | CM_FIXVAL(g) << 8 | CM_FIXVAL(b))
180 #define MAKE_MONO_ENTRY(x) ((x) ? 1 : 0)
181 #define MAKE_GREY_ENTRY(l) CM_FIXVAL(l)
183 #define CM_LTOW(v) \
184 (((0x000F0000 & (v)) >> 8) | ((0x00000F00 & (v)) >> 4) | (0xF & (v)))
185 #define CM_WTOL(v) \
186 (((0xF00 & (v)) << 8) | ((0x0F0 & (v)) << 4) | (0xF & (v)))
188 #define CM_GET_RED(entry) (((entry) & 0xFF0000) >> 16)
189 #define CM_GET_GREEN(entry) (((entry) & 0x00FF00) >> 8)
190 #define CM_GET_BLUE(entry) (((entry) & 0x0000FF))
191 #define CM_GET_GREY(entry) (((entry) & 0x0000FF))
192 #define CM_GET_MONO(entry) (((entry) & 0x000001))
195 * View stuff.
197 typedef void remove_view_func (view_t *v);
198 typedef void free_view_func (view_t *v);
199 typedef void display_view_func (view_t *v);
200 typedef dmode_t *get_mode_func (view_t *v);
201 typedef int get_colormap_func (view_t *v, colormap_t *);
202 typedef int use_colormap_func (view_t *v, colormap_t *);
204 struct view {
205 bmap_t *bitmap; /* bitmap. */
206 box_t display; /* viewable area. */
207 void *data; /* view specific data. */
209 /* functions */
210 display_view_func *display_view; /* make this view active */
211 remove_view_func *remove_view; /* remove this view if active */
212 free_view_func *free_view; /* free this view */
213 get_mode_func *get_display_mode;/* get the mode this view belongs to */
214 get_colormap_func *get_colormap; /* get a color map for registers */
215 use_colormap_func *use_colormap; /* use color map to load registers */
218 #define VDISPLAY_LINE(v, p, l) ((v)->bitmap->plane[(p)] +\
219 (((v)->bitmap->bytes_per_row + (v)->bitmap->row_mod) * l))
222 * Mode stuff
225 typedef view_t *alloc_view_func (dmode_t *mode, dimen_t *dim, u_char depth);
226 typedef view_t *get_current_view_func (dmode_t *);
227 typedef monitor_t *get_monitor_func (dmode_t *);
229 struct display_mode {
230 LIST_ENTRY(display_mode) link;
231 const u_char *name; /* logical name for mode. */
232 dimen_t nominal_size; /* best fit. */
233 void *data; /* mode specific flags. */
234 alloc_view_func *alloc_view; /* allocate a view for this mode. */
235 get_current_view_func *get_current_view; /* get active view. */
236 get_monitor_func *get_monitor; /* get monitor that mode belongs to */
240 * Monitor stuff.
242 typedef void vbl_handler_func (void *);
243 typedef dmode_t *get_next_mode_func (dmode_t *);
244 typedef dmode_t *get_current_mode_func (void);
245 typedef dmode_t *get_best_mode_func (dimen_t *size, u_char depth);
246 typedef bmap_t *alloc_bitmap_func (u_short w, u_short h, u_short d, u_short f);
247 typedef void free_bitmap_func (bmap_t *bm);
249 struct monitor {
250 LIST_ENTRY(monitor) link; /* a link into the database. */
251 const u_char *name; /* a logical name for this monitor. */
252 void *data; /* monitor specific data. */
253 get_current_mode_func *get_current_mode;
254 vbl_handler_func *vbl_handler; /* called on every vbl if not NULL */
255 get_next_mode_func *get_next_mode; /* return next mode in list */
256 get_best_mode_func *get_best_mode; /* return mode that best fits */
258 alloc_bitmap_func *alloc_bitmap;
259 free_bitmap_func *free_bitmap;
263 * Misc draw related macros.
266 #define BOX_2_RECT(b,r) do { \
267 (r)->left = (b)->x; (r)->top = (b)->y; \
268 (r)->right = (b)->x + (b)->width -1; \
269 (r)->bottom = (b)->y + (b)->height -1; \
270 } while (0)
272 #define RECT_2_BOX(r,b) do { \
273 (b)->x = (r)->left; \
274 (b)->y = (r)->top; \
275 (b)->width = (r)->right - (r)->left +1; \
276 (b)->height = (r)->bottom - (r)->top +1; \
277 } while(0)
279 #define INIT_BOX(b,xx,yy,ww,hh) do{(b)->x = xx; (b)->y = yy; (b)->width = ww; (b)->height = hh;}while (0)
280 #define INIT_RECT(rc,l,t,r,b) do{(rc)->left = l; (rc)->right = r; (rc)->top = t; (rc)->bottom = b;}while (0)
281 #define INIT_POINT(p,xx,yy) do {(p)->x = xx; (p)->y = yy;} while (0)
282 #define INIT_DIM(d,w,h) do {(d)->width = w; (d)->height = h;} while (0)
286 * Prototypes
289 /* views */
290 view_t * grf_alloc_view(dmode_t *d, dimen_t *dim, u_char depth);
291 void grf_display_view(view_t *v);
292 void grf_remove_view(view_t *v);
293 void grf_free_view(view_t *v);
294 dmode_t *grf_get_display_mode(view_t *v);
295 int grf_get_colormap(view_t *v, colormap_t *cm);
296 int grf_use_colormap(view_t *v, colormap_t *cm);
298 /* modes */
299 view_t *grf_get_current_view(dmode_t *d);
300 monitor_t *grf_get_monitor(dmode_t *d);
302 /* monitors */
303 dmode_t * grf_get_next_mode(monitor_t *m, dmode_t *d);
304 dmode_t * grf_get_current_mode(monitor_t *);
305 dmode_t * grf_get_best_mode(monitor_t *m, dimen_t *size, u_char depth);
306 bmap_t * grf_alloc_bitmap(monitor_t *m, u_short w, u_short h,
307 u_short d, u_short f);
308 void grf_free_bitmap(monitor_t *m, bmap_t *bm);
310 int grfcc_probe(void);
312 #endif /* _GRFABS_REG_H */