1 /* $NetBSD: grf_subr.c,v 1.16 2008/03/29 06:47:07 tsutsui Exp $ */
4 * Copyright (c) 1996 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 * Subroutines common to all framebuffer devices.
36 #include <sys/cdefs.h>
37 __KERNEL_RCSID(0, "$NetBSD: grf_subr.c,v 1.16 2008/03/29 06:47:07 tsutsui Exp $");
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/malloc.h>
42 #include <sys/device.h>
44 #include <machine/autoconf.h>
45 #include <machine/cpu.h>
47 #include <hp300/dev/grfioctl.h>
48 #include <hp300/dev/grfvar.h>
50 static int grfdevprint(void *, const char *);
53 grfdev_attach(struct grfdev_softc
*sc
,
54 int (*init
)(struct grf_data
*, int, uint8_t *),
55 void *regs
, struct grfsw
*sw
)
57 struct grfdev_attach_args ga
;
61 sc
->sc_data
= gp
= &grf_cn
;
63 sc
->sc_data
= malloc(sizeof(struct grf_data
),
64 M_DEVBUF
, M_NOWAIT
| M_ZERO
);
65 if (sc
->sc_data
== NULL
) {
66 aprint_error(": can't allocate grf data\n");
70 /* Initialize the framebuffer hardware. */
71 if ((*init
)(sc
->sc_data
, sc
->sc_scode
, regs
) == 0) {
72 aprint_error(": init failed\n");
73 free(sc
->sc_data
, M_DEVBUF
);
78 gp
->g_flags
= GF_ALIVE
;
80 gp
->g_display
.gd_id
= gp
->g_sw
->gd_swid
;
83 /* Announce ourselves. */
84 printf(": %d x %d ", gp
->g_display
.gd_dwidth
,
85 gp
->g_display
.gd_dheight
);
86 if (gp
->g_display
.gd_colors
== 2)
89 printf("%d color", gp
->g_display
.gd_colors
);
90 printf(" %s display\n", gp
->g_sw
->gd_desc
);
93 ga
.ga_scode
= sc
->sc_scode
; /* XXX */
94 ga
.ga_isconsole
= sc
->sc_isconsole
;
95 ga
.ga_data
= (void *)sc
->sc_data
;
96 (void)config_found(sc
->sc_dev
, &ga
, grfdevprint
);
100 grfdevprint(void *aux
, const char *pnp
)
102 /* struct grfdev_attach_args *ga = aux; */
104 /* Only grf's can attach to grfdev's... easy. */
106 aprint_normal("grf at %s", pnp
);