From a985ae9b4a05933af71c028be1a9c117aa3bbd25 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Sat, 7 Mar 2015 20:45:15 +0000 Subject: [PATCH] Add support for USB display link adapters to the FB and VT drivers. The vtophys() function is used to get the physical page address for the virtually allocated frame buffers when a physically continuous memory area is not available. This change also allows removing the masking of the FB_FLAG_NOMMAP flag in the PS3 syscons driver. The FB and VT drivers were tested using X.org/xf86-video-scfb and syscons. --- sys/dev/fb/fbd.c | 13 ++++++++++--- sys/dev/vt/hw/fb/vt_fb.c | 17 ++++++++++++----- sys/powerpc/ps3/ps3_syscons.c | 1 - 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/sys/dev/fb/fbd.c b/sys/dev/fb/fbd.c index 6b7b7316bf57..b7e45040f65e 100644 --- a/sys/dev/fb/fbd.c +++ b/sys/dev/fb/fbd.c @@ -51,6 +51,9 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include + #include "fb_if.h" LIST_HEAD(fb_list_head_t, fb_list_entry) fb_list_head = @@ -167,11 +170,14 @@ fb_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, int nprot, info = dev->si_drv1; - if ((info->fb_flags & FB_FLAG_NOMMAP) || info->fb_pbase == 0) + if (info->fb_flags & FB_FLAG_NOMMAP) return (ENODEV); - if (offset < info->fb_size) { - *paddr = info->fb_pbase + offset; + if (offset >= 0 && offset < info->fb_size) { + if (info->fb_pbase == 0) + *paddr = vtophys((uint8_t *)info->fb_vbase + offset); + else + *paddr = info->fb_pbase + offset; return (0); } return (EINVAL); @@ -356,5 +362,6 @@ devclass_t fbd_devclass; DRIVER_MODULE(fbd, fb, fbd_driver, fbd_devclass, 0, 0); DRIVER_MODULE(fbd, drmn, fbd_driver, fbd_devclass, 0, 0); +DRIVER_MODULE(fbd, udl, fbd_driver, fbd_devclass, 0, 0); MODULE_VERSION(fbd, 1); diff --git a/sys/dev/vt/hw/fb/vt_fb.c b/sys/dev/vt/hw/fb/vt_fb.c index 5d38cc7dea0d..40f56fc097e8 100644 --- a/sys/dev/vt/hw/fb/vt_fb.c +++ b/sys/dev/vt/hw/fb/vt_fb.c @@ -41,6 +41,9 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include + static struct vt_driver vt_fb_driver = { .vd_name = "fb", .vd_init = vt_fb_init, @@ -136,10 +139,14 @@ vt_fb_mmap(struct vt_device *vd, vm_ooffset_t offset, vm_paddr_t *paddr, return (ENODEV); if (offset >= 0 && offset < info->fb_size) { - *paddr = info->fb_pbase + offset; - #ifdef VM_MEMATTR_WRITE_COMBINING - *memattr = VM_MEMATTR_WRITE_COMBINING; - #endif + if (info->fb_pbase == 0) { + *paddr = vtophys((uint8_t *)info->fb_vbase + offset); + } else { + *paddr = info->fb_pbase + offset; +#ifdef VM_MEMATTR_WRITE_COMBINING + *memattr = VM_MEMATTR_WRITE_COMBINING; +#endif + } return (0); } @@ -425,7 +432,7 @@ vt_fb_init(struct vt_device *vd) if (info->fb_size == 0) return (CN_DEAD); - if (info->fb_pbase == 0) + if (info->fb_pbase == 0 && info->fb_vbase == 0) info->fb_flags |= FB_FLAG_NOMMAP; if (info->fb_cmsize <= 0) { diff --git a/sys/powerpc/ps3/ps3_syscons.c b/sys/powerpc/ps3/ps3_syscons.c index 521690c39446..4edf56eb513f 100644 --- a/sys/powerpc/ps3/ps3_syscons.c +++ b/sys/powerpc/ps3/ps3_syscons.c @@ -191,7 +191,6 @@ ps3fb_init(struct vt_device *vd) L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, 1, 0, 0, 0); vt_fb_init(vd); - sc->fb_info.fb_flags &= ~FB_FLAG_NOMMAP; /* Set wrongly by vt_fb_init */ return (CN_INTERNAL); }