1 /* $NetBSD: grfabs.c,v 1.6 2002/01/26 13:40:55 aymeric Exp $ */
4 * Copyright (c) 1994 Christian E. Hopps
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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 #include <sys/cdefs.h>
34 __KERNEL_RCSID(0, "$NetBSD$");
37 * amiga abstract graphics driver.
39 #include <sys/param.h>
40 #include <sys/queue.h>
42 #include <amiga/amiga/color.h>
43 #include <amiga/amiga/cc.h>
44 #include <amiga/dev/grfabs_reg.h>
50 /* add your monitor here. */
51 monitor_t
*cc_init_monitor (void);
54 monitor_t
*(*init_monitor
[])(void) = {
59 struct monitor_list instance_monitors
, *monitors
;
61 struct vbl_node grf_vbl_node
;
63 #define ABS(type, val) \
64 (type) (((int)(val) < 0) ? -(val) : (val))
66 void grf_vbl_function(void *data
);
67 dmode_t
*get_best_display_mode(u_long
, u_long
, u_char
);
71 grf_vbl_function(void *data
)
78 for (m
= monitors
->lh_first
; m
!= NULL
; m
= m
->link
.le_next
) {
85 * XXX: called from ite console init routine.
86 * Does just what configure will do later but without printing anything.
94 grf_vbl_node
.function
= grf_vbl_function
;
96 if (NULL
== monitors
) {
97 LIST_INIT(&instance_monitors
);
98 monitors
= &instance_monitors
;
100 while (init_monitor
[i
]) {
105 add_vbl_function(&grf_vbl_node
, 1, 0);
114 get_best_display_mode(u_long width
, u_long height
, u_char depth
)
119 long dx
, dy
, ct
, dt
= 0;
122 for (m
= monitors
->lh_first
; m
!= NULL
; m
= m
->link
.le_next
) {
125 d
= m
->get_best_mode(&dim
, depth
);
127 dx
= ABS(long, (d
->nominal_size
.width
- width
));
128 dy
= ABS(long, (d
->nominal_size
.height
- height
));
131 if (ct
< dt
|| save
== NULL
) {
146 grf_get_next_mode(monitor_t
*m
, dmode_t
*d
)
148 return(m
->get_next_mode(d
));
152 grf_get_current_mode(monitor_t
*m
)
154 return(m
->get_current_mode());
158 grf_get_best_mode(monitor_t
*m
, dimen_t
*size
, u_char depth
)
160 return(m
->get_best_mode(size
, depth
));
164 grf_alloc_bitmap(monitor_t
*m
, u_short w
, u_short h
, u_short d
, u_short f
)
166 return(m
->alloc_bitmap(w
, h
, d
, f
));
170 grf_free_bitmap(monitor_t
*m
, bmap_t
*bm
)
180 grf_get_current_view(dmode_t
*d
)
182 return(d
->get_current_view(d
));
186 grf_get_monitor(dmode_t
*d
)
188 return(d
->get_monitor(d
));
196 grf_display_view(view_t
*v
)
202 grf_alloc_view(dmode_t
*d
, dimen_t
*dim
, u_char depth
)
205 d
= get_best_display_mode(dim
->width
, dim
->height
, depth
);
207 return(d
->alloc_view(d
, dim
, depth
));
212 grf_remove_view(view_t
*v
)
218 grf_free_view(view_t
*v
)
224 grf_get_display_mode(view_t
*v
)
226 return(v
->get_display_mode(v
));
230 grf_get_colormap(view_t
*v
, colormap_t
*cm
)
232 return(v
->get_colormap(v
, cm
));
236 grf_use_colormap(view_t
*v
, colormap_t
*cm
)
238 return(v
->use_colormap(v
, cm
));