Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Port the Tegra (2D) display drivers to the DRM fram...
details: https://anonhg.NetBSD.org/src/rev/f8aaf0ab1d4c
branches: trunk
changeset: 341520:f8aaf0ab1d4c
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Mon Nov 09 23:05:58 2015 +0000
description:
Port the Tegra (2D) display drivers to the DRM framework.
tegradrm0 at tegraio0
tegrafb0 at tegradrm0
tegrafb0: framebuffer at 0x9b000000, size 1280x720, depth 32, stride 5120
wsdisplay0 at tegrafb0 kbdmux 1
wsmux1: connecting to wsdisplay0
wsdisplay0: screen 0-3 added (default, vt100 emulation)
tegradrm0: info: registered panic notifier
tegradrm0: initialized tegra 0.1.0 20151108 on minor 0
Same features as before (fb console, X wsfb driver works) with the addition
of being able to use xf86-video-modesetting and xrandr to switch video
modes at runtime.
diffstat:
sys/arch/arm/nvidia/files.tegra | 30 +-
sys/arch/arm/nvidia/tegra_dc.c | 396 --------------
sys/arch/arm/nvidia/tegra_drm.c | 300 ++++++++++
sys/arch/arm/nvidia/tegra_drm.h | 133 ++++
sys/arch/arm/nvidia/tegra_drm_fb.c | 109 +++
sys/arch/arm/nvidia/tegra_drm_mode.c | 958 ++++++++++++++++++++++++++++++++++
sys/arch/arm/nvidia/tegra_fb.c | 150 +++++
sys/arch/arm/nvidia/tegra_hdmi.c | 556 -------------------
sys/arch/arm/nvidia/tegra_io.c | 11 +-
sys/arch/evbarm/conf/JETSONTK1 | 20 +-
sys/arch/evbarm/conf/NYAN-BIG | 143 +----
sys/arch/evbarm/tegra/tegra_machdep.c | 21 +-
12 files changed, 1693 insertions(+), 1134 deletions(-)
diffs (truncated from 2986 to 300 lines):
diff -r 461c20e0d692 -r f8aaf0ab1d4c sys/arch/arm/nvidia/files.tegra
--- a/sys/arch/arm/nvidia/files.tegra Mon Nov 09 22:04:53 2015 +0000
+++ b/sys/arch/arm/nvidia/files.tegra Mon Nov 09 23:05:58 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.tegra,v 1.19 2015/10/21 20:02:12 jmcneill Exp $
+# $NetBSD: files.tegra,v 1.20 2015/11/09 23:05:58 jmcneill Exp $
#
# Configuration info for NVIDIA Tegra ARM Peripherals
#
@@ -102,26 +102,24 @@
attach tegrahost1x at tegraio with tegra_host1x
file arch/arm/nvidia/tegra_host1x.c tegra_host1x
-# Display controller
-device tegradc { }
-attach tegradc at tegraio with tegra_dc
-file arch/arm/nvidia/tegra_dc.c tegra_dc
-
-# Framebuffer console
-attach genfb at tegradc with tegra_genfb
-file arch/arm/nvidia/tegra_genfb.c tegra_genfb
-
-# HDMI
-device tegrahdmi: edid, ddc_read_edid, videomode
-attach tegrahdmi at tegraio with tegra_hdmi
-file arch/arm/nvidia/tegra_hdmi.c tegra_hdmi
-defflag opt_tegra.h TEGRA_HDMI_DEBUG
-
# HDMI CEC
device tegracec: hdmicecbus
attach tegracec at tegraio with tegra_cec
file arch/arm/nvidia/tegra_cec.c tegra_cec
+# Display
+define tegrafbbus { }
+device tegradrm: drmkms, tegrafbbus
+attach tegradrm at tegraio with tegra_drm
+file arch/arm/nvidia/tegra_drm.c tegra_drm
+file arch/arm/nvidia/tegra_drm_mode.c tegra_drm
+file arch/arm/nvidia/tegra_drm_fb.c tegra_drm
+
+# Framebuffer console
+device tegrafb: tegrafbbus, drmfb, wsemuldisplaydev
+attach tegrafb at tegrafbbus with tegra_fb
+file arch/arm/nvidia/tegra_fb.c tegra_fb
+
# GPU
attach nouveau at tegraio with tegra_nouveau
file arch/arm/nvidia/tegra_nouveau.c tegra_nouveau
diff -r 461c20e0d692 -r f8aaf0ab1d4c sys/arch/arm/nvidia/tegra_dc.c
--- a/sys/arch/arm/nvidia/tegra_dc.c Mon Nov 09 22:04:53 2015 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,396 +0,0 @@
-/* $NetBSD: tegra_dc.c,v 1.3 2015/07/23 14:31:05 jmcneill Exp $ */
-
-/*-
- * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
- * 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 AUTHOR ``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 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 "locators.h"
-
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra_dc.c,v 1.3 2015/07/23 14:31:05 jmcneill Exp $");
-
-#include <sys/param.h>
-#include <sys/bus.h>
-#include <sys/device.h>
-#include <sys/intr.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-
-#include <dev/videomode/videomode.h>
-
-#include <arm/nvidia/tegra_reg.h>
-#include <arm/nvidia/tegra_dcreg.h>
-#include <arm/nvidia/tegra_var.h>
-
-#define TEGRA_DC_NPORTS 2
-#define TEGRA_DC_DEPTH 32
-#define TEGRA_DC_FBALIGN PAGE_SIZE
-
-static int tegra_dc_match(device_t, cfdata_t, void *);
-static void tegra_dc_attach(device_t, device_t, void *);
-
-struct tegra_dc_softc {
- device_t sc_dev;
- bus_space_tag_t sc_bst;
- bus_space_handle_t sc_bsh;
- bus_dma_tag_t sc_dmat;
- int sc_port;
-
- bus_dma_segment_t sc_dmasegs[1];
- bus_size_t sc_dmasize;
- bus_dmamap_t sc_dmamap;
- void *sc_dmap;
-
- device_t sc_fbdev;
-};
-
-static int tegra_dc_print(void *, const char *);
-static int tegra_dc_allocmem(struct tegra_dc_softc *, bus_size_t);
-static int tegra_dc_init(struct tegra_dc_softc *,
- const struct videomode *);
-static void tegra_dc_init_win(struct tegra_dc_softc *,
- const struct videomode *);
-static void tegra_dc_init_disp(struct tegra_dc_softc *,
- const struct videomode *);
-static void tegra_dc_update(struct tegra_dc_softc *);
-
-CFATTACH_DECL_NEW(tegra_dc, sizeof(struct tegra_dc_softc),
- tegra_dc_match, tegra_dc_attach, NULL, NULL);
-
-#define DC_READ(sc, reg) \
- bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (reg))
-#define DC_WRITE(sc, reg, val) \
- bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, (reg), (val))
-#define DC_SET_CLEAR(sc, reg, set, clr) \
- tegra_reg_set_clear((sc)->sc_bst, (sc)->sc_bsh, (reg), (set), (clr))
-
-static int
-tegra_dc_match(device_t parent, cfdata_t cf, void *aux)
-{
- struct tegraio_attach_args * const tio = aux;
- const struct tegra_locators * const loc = &tio->tio_loc;
-
- if (loc->loc_port == TEGRAIOCF_PORT_DEFAULT ||
- loc->loc_port >= TEGRA_DC_NPORTS)
- return 0;
-
- return 1;
-}
-
-static void
-tegra_dc_attach(device_t parent, device_t self, void *aux)
-{
- struct tegra_dc_softc * const sc = device_private(self);
- struct tegraio_attach_args * const tio = aux;
- const struct tegra_locators * const loc = &tio->tio_loc;
-
- sc->sc_dev = self;
- sc->sc_port = loc->loc_port;
- sc->sc_bst = tio->tio_bst;
- sc->sc_dmat = tio->tio_dmat;
- if (bus_space_map(sc->sc_bst, TEGRA_GHOST_BASE + loc->loc_offset,
- loc->loc_size, 0, &sc->sc_bsh) != 0) {
- aprint_error(": couldn't map DC\n");
- return;
- }
-
- aprint_naive("\n");
- aprint_normal(": DISPLAY%c\n", loc->loc_port + 'A');
-}
-
-
-static int
-tegra_dc_allocmem(struct tegra_dc_softc *sc, bus_size_t size)
-{
- int error, nsegs;
-
- error = bus_dmamem_alloc(sc->sc_dmat, size, TEGRA_DC_FBALIGN, 0,
- sc->sc_dmasegs, 1, &nsegs, BUS_DMA_WAITOK);
- if (error)
- return error;
- error = bus_dmamem_map(sc->sc_dmat, sc->sc_dmasegs, nsegs, size,
- &sc->sc_dmap, BUS_DMA_WAITOK | BUS_DMA_COHERENT);
- if (error)
- goto free;
- error = bus_dmamap_create(sc->sc_dmat, size, 1, size, 0,
- BUS_DMA_WAITOK, &sc->sc_dmamap);
- if (error)
- goto unmap;
- error = bus_dmamap_load(sc->sc_dmat, sc->sc_dmamap, sc->sc_dmap,
- size, NULL, BUS_DMA_WAITOK);
- if (error)
- goto destroy;
-
- sc->sc_dmasize = size;
-
- memset(sc->sc_dmap, 0, size);
-
- return 0;
-
-destroy:
- bus_dmamap_destroy(sc->sc_dmat, sc->sc_dmamap);
-unmap:
- bus_dmamem_unmap(sc->sc_dmat, sc->sc_dmap, size);
-free:
- bus_dmamem_free(sc->sc_dmat, sc->sc_dmasegs, nsegs);
-
- sc->sc_dmasize = 0;
- sc->sc_dmap = NULL;
-
- return error;
-}
-
-static int
-tegra_dc_print(void *aux, const char *pnp)
-{
- const struct tegrafb_attach_args * const tfb = aux;
-
- aprint_normal(" output %s", device_xname(tfb->tfb_outputdev));
-
- return UNCONF;
-}
-
-static int
-tegra_dc_init(struct tegra_dc_softc *sc, const struct videomode *mode)
-{
- tegra_car_dc_enable(sc->sc_port);
-
- tegra_dc_init_win(sc, mode);
- tegra_dc_init_disp(sc, mode);
- tegra_dc_update(sc);
- return 0;
-}
-
-
-static void
-tegra_dc_init_win(struct tegra_dc_softc *sc, const struct videomode *mode)
-{
- /* Write access control */
- DC_WRITE(sc, DC_CMD_STATE_ACCESS_REG,
- DC_CMD_STATE_ACCESS_WRITE_MUX | DC_CMD_STATE_ACCESS_READ_MUX);
-
- /* Enable window A programming */
- DC_WRITE(sc, DC_CMD_DISPLAY_WINDOW_HEADER_REG,
- DC_CMD_DISPLAY_WINDOW_HEADER_WINDOW_A_SELECT);
-
- /* Set colour depth to ARGB8888 */
- DC_WRITE(sc, DC_WINC_A_COLOR_DEPTH_REG,
- __SHIFTIN(DC_WINC_A_COLOR_DEPTH_DEPTH_T_A8R8G8B8,
- DC_WINC_A_COLOR_DEPTH_DEPTH));
-
- /* Disable byte swapping */
- DC_WRITE(sc, DC_WINC_A_BYTE_SWAP_REG,
- __SHIFTIN(DC_WINC_A_BYTE_SWAP_SWAP_NOSWAP,
- DC_WINC_A_BYTE_SWAP_SWAP));
-
- /* Initial DDA */
- DC_WRITE(sc, DC_WINC_A_H_INITIAL_DDA_REG, 0);
- DC_WRITE(sc, DC_WINC_A_V_INITIAL_DDA_REG, 0);
- DC_WRITE(sc, DC_WINC_A_DDA_INCREMENT_REG, 0x10001000);
-
- /* Window position, size, stride */
- DC_WRITE(sc, DC_WINC_A_POSITION_REG,
- __SHIFTIN(0, DC_WINC_A_POSITION_V) |
- __SHIFTIN(0, DC_WINC_A_POSITION_H));
- DC_WRITE(sc, DC_WINC_A_SIZE_REG,
- __SHIFTIN(mode->vdisplay, DC_WINC_A_SIZE_V) |
- __SHIFTIN(mode->hdisplay, DC_WINC_A_SIZE_H));
- DC_WRITE(sc, DC_WINC_A_PRESCALED_SIZE_REG,
- __SHIFTIN(mode->vdisplay, DC_WINC_A_PRESCALED_SIZE_V) |
- __SHIFTIN(mode->hdisplay * (TEGRA_DC_DEPTH / 8),
- DC_WINC_A_PRESCALED_SIZE_H));
- DC_WRITE(sc, DC_WINC_A_LINE_STRIDE_REG,
- __SHIFTIN(mode->hdisplay * (TEGRA_DC_DEPTH / 8),
- DC_WINC_A_LINE_STRIDE_LINE_STRIDE));
-
- /* Framebuffer start address */
- DC_WRITE(sc, DC_WINBUF_A_START_ADDR_REG,
- (uint32_t)sc->sc_dmamap->dm_segs[0].ds_addr);
-
- /* Offsets */
- DC_WRITE(sc, DC_WINBUF_A_ADDR_H_OFFSET_REG, 0);
- DC_WRITE(sc, DC_WINBUF_A_ADDR_V_OFFSET_REG, 0);
-
- /* Surface kind */
- DC_WRITE(sc, DC_WINBUF_A_SURFACE_KIND_REG,
- __SHIFTIN(DC_WINBUF_A_SURFACE_KIND_SURFACE_KIND_PITCH,
- DC_WINBUF_A_SURFACE_KIND_SURFACE_KIND));
-
- /* Enable window A */
- DC_WRITE(sc, DC_WINC_A_WIN_OPTIONS_REG,
- DC_WINC_A_WIN_OPTIONS_WIN_ENABLE);
-}
-
-static void
-tegra_dc_init_disp(struct tegra_dc_softc *sc, const struct videomode *mode)
Home |
Main Index |
Thread Index |
Old Index