Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.
This commit is contained in:
parent
6a4d107f7d
commit
ec798a6e6c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: genfb_pci.c,v 1.12 2009/02/14 20:33:58 jmcneill Exp $ */
|
||||
/* $NetBSD: genfb_pci.c,v 1.13 2009/02/15 18:41:49 jmcneill Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 Michael Lorenz
|
||||
@ -27,7 +27,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: genfb_pci.c,v 1.12 2009/02/14 20:33:58 jmcneill Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: genfb_pci.c,v 1.13 2009/02/15 18:41:49 jmcneill Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -81,9 +81,9 @@ static void pci_genfb_attach(struct device *, struct device *, void *);
|
||||
static int pci_genfb_ioctl(void *, void *, u_long, void *, int,
|
||||
struct lwp *);
|
||||
static paddr_t pci_genfb_mmap(void *, void *, off_t, int);
|
||||
static int pci_genfb_borrow(void *, bus_addr_t, bus_space_handle_t *);
|
||||
static int pci_genfb_drm_print(void *, const char *);
|
||||
|
||||
|
||||
CFATTACH_DECL(genfb_pci, sizeof(struct pci_genfb_softc),
|
||||
pci_genfb_match, pci_genfb_attach, NULL, NULL);
|
||||
|
||||
@ -163,6 +163,7 @@ pci_genfb_attach(struct device *parent, struct device *self, void *aux)
|
||||
|
||||
ops.genfb_ioctl = pci_genfb_ioctl;
|
||||
ops.genfb_mmap = pci_genfb_mmap;
|
||||
ops.genfb_borrow = pci_genfb_borrow;
|
||||
|
||||
if (genfb_attach(&sc->sc_gen, &ops) == 0) {
|
||||
|
||||
@ -290,3 +291,18 @@ pci_genfb_mmap(void *v, void *vs, off_t offset, int prot)
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
pci_genfb_borrow(void *opaque, bus_addr_t addr, bus_space_handle_t *hdlp)
|
||||
{
|
||||
struct pci_genfb_softc *sc = opaque;
|
||||
|
||||
if (sc == NULL)
|
||||
return 0;
|
||||
if (!sc->sc_gen.sc_fboffset)
|
||||
return 0;
|
||||
if (sc->sc_gen.sc_fboffset != addr)
|
||||
return 0;
|
||||
*hdlp = sc->sc_memh;
|
||||
return 1;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: genfb.c,v 1.18 2009/02/14 20:33:59 jmcneill Exp $ */
|
||||
/* $NetBSD: genfb.c,v 1.19 2009/02/15 18:41:49 jmcneill Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 Michael Lorenz
|
||||
@ -27,7 +27,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1.18 2009/02/14 20:33:59 jmcneill Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1.19 2009/02/15 18:41:49 jmcneill Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -83,6 +83,8 @@ struct wsdisplay_accessops genfb_accessops = {
|
||||
NULL /* scroll */
|
||||
};
|
||||
|
||||
static struct genfb_softc *genfb_softc = NULL;
|
||||
|
||||
void
|
||||
genfb_init(struct genfb_softc *sc)
|
||||
{
|
||||
@ -207,6 +209,9 @@ genfb_attach(struct genfb_softc *sc, struct genfb_ops *ops)
|
||||
j += 3;
|
||||
}
|
||||
|
||||
if (genfb_softc == NULL)
|
||||
genfb_softc = sc;
|
||||
|
||||
aa.console = console;
|
||||
aa.scrdata = &sc->sc_screenlist;
|
||||
aa.accessops = &genfb_accessops;
|
||||
@ -420,3 +425,13 @@ genfb_is_console(void)
|
||||
{
|
||||
return genfb_cnattach_called;
|
||||
}
|
||||
|
||||
int
|
||||
genfb_borrow(bus_addr_t addr, bus_space_handle_t *hdlp)
|
||||
{
|
||||
struct genfb_softc *sc = genfb_softc;
|
||||
|
||||
if (sc && sc->sc_ops.genfb_borrow)
|
||||
return sc->sc_ops.genfb_borrow(sc, addr, hdlp);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: genfbvar.h,v 1.7 2009/02/14 20:33:59 jmcneill Exp $ */
|
||||
/* $NetBSD: genfbvar.h,v 1.8 2009/02/15 18:41:49 jmcneill Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 Michael Lorenz
|
||||
@ -27,7 +27,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: genfbvar.h,v 1.7 2009/02/14 20:33:59 jmcneill Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: genfbvar.h,v 1.8 2009/02/15 18:41:49 jmcneill Exp $");
|
||||
|
||||
#ifndef GENFBVAR_H
|
||||
#define GENFBVAR_H
|
||||
@ -48,6 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: genfbvar.h,v 1.7 2009/02/14 20:33:59 jmcneill Exp $"
|
||||
struct genfb_ops {
|
||||
int (*genfb_ioctl)(void *, void *, u_long, void *, int, struct lwp *);
|
||||
paddr_t (*genfb_mmap)(void *, void *, off_t, int);
|
||||
int (*genfb_borrow)(void *, bus_addr_t, bus_space_handle_t *);
|
||||
};
|
||||
|
||||
struct genfb_colormap_callback {
|
||||
@ -79,5 +80,6 @@ void genfb_cnattach(void);
|
||||
int genfb_is_console(void);
|
||||
void genfb_init(struct genfb_softc *);
|
||||
int genfb_attach(struct genfb_softc *, struct genfb_ops *);
|
||||
int genfb_borrow(bus_addr_t, bus_space_handle_t *);
|
||||
|
||||
#endif /* GENFBVAR_H */
|
||||
|
Loading…
Reference in New Issue
Block a user