/*-
* Copyright (c) 2007 Michael Lorenz
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* an SBus frontend for the generic fb console driver */
/*
* Match a graphics device.
*/
static int
genfb_match_sbus(device_t parent, cfdata_t cf, void *aux)
{
struct sbus_attach_args *sa = aux;
/* if there's no address property we can't use the device */
if (prom_getpropint(sa->sa_node, "address", -1) == -1)
return 0;
if (strcmp("display", prom_getpropstring(sa->sa_node, "device_type"))
== 0)
return 1;
return 0;
}
/*
* Attach a display. We need to notice if it is the console, too.
*/
static void
genfb_attach_sbus(device_t parent, device_t self, void *args)
{
struct genfb_sbus_softc *sc = device_private(self);
struct sbus_attach_args *sa = args;
static const struct genfb_ops zero_ops;
struct genfb_ops ops = zero_ops;
prop_dictionary_t dict;
bus_space_handle_t bh;
paddr_t fbpa;
vaddr_t fbva;
int node = sa->sa_node;
int isconsole;
aprint_normal("\n");
sc->sc_gen.sc_dev = self;
/* Remember cookies for genfb_mmap_sbus() */
sc->sc_tag = sa->sa_bustag;
sc->sc_paddr = sbus_bus_addr(sa->sa_bustag, sa->sa_slot, sa->sa_offset);
/* read geometry information from the device tree */
sc->sc_gen.sc_width = prom_getpropint(sa->sa_node, "width", 1152);
sc->sc_gen.sc_height = prom_getpropint(sa->sa_node, "height", 900);
sc->sc_gen.sc_depth = prom_getpropint(sa->sa_node, "depth", 8);
sc->sc_gen.sc_stride = prom_getpropint(sa->sa_node, "linebytes",
(sc->sc_gen.sc_width * sc->sc_gen.sc_depth + 7) >> 3 );
sc->sc_gen.sc_fbsize = sc->sc_gen.sc_height * sc->sc_gen.sc_stride;
fbva = (uint32_t)prom_getpropint(sa->sa_node, "address", 0);
if (fbva == 0)
panic("this fb has no address property\n");
aprint_normal_dev(self, "%d x %d at %d bit\n",
sc->sc_gen.sc_width, sc->sc_gen.sc_height, sc->sc_gen.sc_depth);