Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/terasic/mtl/terasic_mtl_vt.c
- This file was added.
/*- | |||||
* Copyright (c) 2014 Ed Maste | |||||
* All rights reserved. | |||||
* | |||||
* This software was developed by SRI International and the University of | |||||
* Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) | |||||
* ("CTSRD"), as part of the DARPA CRASH research programme. | |||||
* | |||||
* 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 AUTHOR 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 AUTHOR 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. | |||||
*/ | |||||
#include <sys/cdefs.h> | |||||
__FBSDID("$FreeBSD$"); | |||||
#include <sys/param.h> | |||||
#include <sys/bus.h> | |||||
#include <sys/fbio.h> | |||||
#include <sys/kernel.h> | |||||
#include <sys/module.h> | |||||
#include <sys/rman.h> | |||||
#include <dev/fdt/fdt_common.h> | |||||
#include <dev/ofw/ofw_bus.h> | |||||
#include <dev/ofw/ofw_bus_subr.h> | |||||
#include <dev/terasic/mtl/terasic_mtl.h> | |||||
#include <dev/vt/colors/vt_termcolors.h> | |||||
/* | |||||
* Terasic Multitouch LCD (MTL) vt(4) framebuffer driver. | |||||
*/ | |||||
#include <vm/vm.h> | |||||
#include <vm/pmap.h> | |||||
static int | |||||
terasic_mtl_fbd_panel_info(struct terasic_mtl_softc *sc, struct fb_info *info) | |||||
{ | |||||
phandle_t node; | |||||
pcell_t dts_value[2]; | |||||
int len; | |||||
if ((node = ofw_bus_get_node(sc->mtl_dev)) == -1) | |||||
return (ENXIO); | |||||
/* panel size */ | |||||
if ((len = OF_getproplen(node, "panel-size")) <= 0) | |||||
return (ENXIO); | |||||
OF_getprop(node, "panel-size", &dts_value, len); | |||||
info->fb_width = fdt32_to_cpu(dts_value[0]); | |||||
ray: Please look for possibility to use OF_getpropenc here, to not manually swap value. | |||||
info->fb_height = fdt32_to_cpu(dts_value[1]); | |||||
info->fb_bpp = info->fb_depth = 32; | |||||
info->fb_stride = info->fb_width * (info->fb_depth / 8); | |||||
return (0); | |||||
} | |||||
int | |||||
terasic_mtl_fbd_attach(struct terasic_mtl_softc *sc) | |||||
{ | |||||
struct fb_info *info; | |||||
device_t fbd; | |||||
info = &sc->mtl_fb_info; | |||||
info->fb_name = device_get_nameunit(sc->mtl_dev); | |||||
info->fb_pbase = rman_get_start(sc->mtl_pixel_res); | |||||
info->fb_size = rman_get_size(sc->mtl_pixel_res); | |||||
info->fb_vbase = (intptr_t)pmap_mapdev(info->fb_pbase, info->fb_size); | |||||
if (terasic_mtl_fbd_panel_info(sc, info) != 0) { | |||||
device_printf(sc->mtl_dev, "using default panel params\n"); | |||||
info->fb_bpp = info->fb_depth = 32; | |||||
info->fb_width = 800; | |||||
info->fb_height = 480; | |||||
info->fb_stride = info->fb_width * (info->fb_depth / 8); | |||||
} | |||||
fbd = device_add_child(sc->mtl_dev, "fbd", | |||||
device_get_unit(sc->mtl_dev)); | |||||
if (fbd == NULL) { | |||||
device_printf(sc->mtl_dev, "Failed to attach fbd child\n"); | |||||
return (ENXIO); | |||||
} | |||||
if (device_probe_and_attach(fbd) != 0) { | |||||
device_printf(sc->mtl_dev, | |||||
"Failed to attach fbd device\n"); | |||||
return (ENXIO); | |||||
} | |||||
(void)vt_generate_vga_palette(info->fb_cmap, COLOR_FORMAT_RGB, | |||||
emasteAuthorUnsubmitted Not Done Inline ActionsThe display is RGBx instead of xRGB. Somehow I'll have to pass this information to xf86-video-scfb -- should we hoist the masks and offsets info struct fb_info? emaste: The display is RGBx instead of xRGB.
Somehow I'll have to pass this information to xf86-video… | |||||
rayUnsubmitted Not Done Inline ActionsYeah, looks like we have to add optional ioctl which will return set of masks and offsets. ray: Yeah, looks like we have to add optional ioctl which will return set of masks and offsets. | |||||
emasteAuthorUnsubmitted Not Done Inline ActionsActually it's an endianness issue, which I did not notice until r269783 went in It's actually an ARGB little-endian framebuffer, or BGRA when viewed as big-endian data. canonical source: inline u_int32_t fb_colour(int r, int g, int b) { return ((r&0xff)<<8) | ((g&0xff)<<16) | ((b&0xff)<<24); } emaste: Actually it's an endianness issue, which I did not notice until r269783 went in
http://svnweb. | |||||
0xff, 8, 0xff, 16, 0xff, 24); | |||||
return (0); | |||||
} | |||||
void | |||||
terasic_mtl_fbd_detach(struct terasic_mtl_softc *sc) | |||||
{ | |||||
panic("%s: detach not implemented", __func__); | |||||
} | |||||
extern device_t fbd_driver; | |||||
extern devclass_t fbd_devclass; | |||||
DRIVER_MODULE(fbd, terasic_mtl, fbd_driver, fbd_devclass, 0, 0); |
Please look for possibility to use OF_getpropenc here, to not manually swap value.