Home | History | Annotate | Line # | Download | only in dev
grf_subr.c revision 1.21
      1  1.21       chs /*	$NetBSD: grf_subr.c,v 1.21 2012/10/27 17:17:59 chs Exp $	*/
      2   1.1    scottr 
      3   1.1    scottr /*-
      4   1.1    scottr  * Copyright (c) 1996 The NetBSD Foundation, Inc.
      5   1.1    scottr  * All rights reserved.
      6   1.1    scottr  *
      7   1.1    scottr  * This code is derived from software contributed to The NetBSD Foundation
      8   1.1    scottr  * by Jason R. Thorpe.
      9   1.1    scottr  *
     10   1.1    scottr  * Redistribution and use in source and binary forms, with or without
     11   1.1    scottr  * modification, are permitted provided that the following conditions
     12   1.1    scottr  * are met:
     13   1.1    scottr  * 1. Redistributions of source code must retain the above copyright
     14   1.1    scottr  *    notice, this list of conditions and the following disclaimer.
     15   1.1    scottr  * 2. Redistributions in binary form must reproduce the above copyright
     16   1.1    scottr  *    notice, this list of conditions and the following disclaimer in the
     17   1.1    scottr  *    documentation and/or other materials provided with the distribution.
     18   1.1    scottr  *
     19   1.1    scottr  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20   1.1    scottr  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21   1.1    scottr  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  1.10       jtc  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  1.10       jtc  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24   1.1    scottr  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25   1.1    scottr  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26   1.1    scottr  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27   1.1    scottr  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28   1.1    scottr  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29   1.1    scottr  * POSSIBILITY OF SUCH DAMAGE.
     30   1.1    scottr  */
     31  1.17     lukem 
     32  1.17     lukem #include <sys/cdefs.h>
     33  1.21       chs __KERNEL_RCSID(0, "$NetBSD: grf_subr.c,v 1.21 2012/10/27 17:17:59 chs Exp $");
     34   1.1    scottr 
     35   1.1    scottr #include <sys/param.h>
     36   1.1    scottr #include <sys/device.h>
     37   1.1    scottr #include <sys/systm.h>
     38   1.1    scottr 
     39   1.6    scottr #include <machine/bus.h>
     40   1.1    scottr #include <machine/grfioctl.h>
     41   1.1    scottr 
     42  1.11    scottr #include <mac68k/nubus/nubus.h>
     43   1.1    scottr #include <mac68k/dev/grfvar.h>
     44   1.1    scottr 
     45   1.1    scottr void
     46  1.18       chs grf_establish(struct grfbus_softc *sc, nubus_slot *sp,
     47  1.18       chs     int (*g_mode)(struct grf_softc *, int, void *))
     48   1.1    scottr {
     49   1.1    scottr 	struct grfmode *gm = &sc->curr_mode;
     50   1.1    scottr 	struct grfbus_attach_args ga;
     51   1.1    scottr 
     52   1.1    scottr 	/* Print hardware characteristics. */
     53  1.21       chs 	printf("%s: %d x %d, ", device_xname(sc->sc_dev), gm->width, gm->height);
     54   1.1    scottr 	if (gm->psize == 1)
     55   1.5  christos 		printf("monochrome\n");
     56   1.1    scottr 	else
     57   1.5  christos 		printf("%d color\n", 1 << gm->psize);
     58   1.1    scottr 
     59   1.1    scottr 	/* Attach grf semantics to the hardware. */
     60   1.1    scottr 	ga.ga_name = "grf";
     61   1.1    scottr 	ga.ga_grfmode = gm;
     62   1.2    scottr 	ga.ga_slot = sp;
     63   1.7    scottr 	ga.ga_tag = sc->sc_tag;
     64   1.9    scottr 	ga.ga_handle = sc->sc_handle;
     65  1.14    scottr 	ga.ga_phys = sc->sc_basepa;
     66   1.1    scottr 	ga.ga_mode = g_mode;
     67  1.21       chs 	(void)config_found(sc->sc_dev, &ga, grfbusprint);
     68   1.1    scottr }
     69   1.1    scottr 
     70   1.1    scottr int
     71  1.18       chs grfbusprint(void *aux, const char *name)
     72   1.1    scottr {
     73   1.1    scottr 	struct grfbus_attach_args *ga = aux;
     74   1.1    scottr 
     75   1.1    scottr 	if (name)
     76  1.16   thorpej 		aprint_normal("%s at %s", ga->ga_name, name);
     77   1.1    scottr 
     78   1.1    scottr 	return (UNCONF);
     79   1.1    scottr }
     80