Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Feb 2015 09:29:20 +0100
From:      Hans Petter Selasky <hps@selasky.org>
To:        Shawn Webb <lattera@gmail.com>, freebsd-current@freebsd.org
Subject:   Re: Pluggable frame buffer devices
Message-ID:  <54E6F060.2010301@selasky.org>
In-Reply-To: <1963872.pLReSBKNjx@shawnwebb-laptop>
References:  <54E11A57.3030105@selasky.org> <5013637.Hs60HQbBR0@shawnwebb-laptop> <1963872.pLReSBKNjx@shawnwebb-laptop>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------020208060106010008060204
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 7bit

On 02/20/15 02:15, Shawn Webb wrote:
> On Thursday, February 19, 2015 07:04:50 PM Shawn Webb wrote:
>> On Sunday, February 15, 2015 11:14:47 PM Hans Petter Selasky wrote:
>>> Hi,
>>>
>>> I've added support for USB display link adapters to FreeBSD-11-current,
>>> but the kernel panics once "vt_fb_attach(info)" is called from
>>> "fbd_register(struct fb_info* info)" when the USB device is plugged or
>>> udl.ko is loaded. Is this a known issue?
>>>
>>> REF: https://svnweb.freebsd.org/base/head/sys/dev/usb/video/udl.c
>>>
>>> --HPS
>>
>> I just bought a DisplayLink adapter that's compatible. Compiling a new
>> kernel with device udl brings this error:
>>

Hi,

You need to also build the "sys/modules/videomode" and install and kldload.

Does your device need a power supply?

Can you plug the device through an external USB HUB after boot?

Also you need some VT patches, before it will attach to VT which I can 
send you. See attachment.

Beware the unplugging the device is not supported. It will crash / panic 
which needs to be resolved.

--HPS

--------------020208060106010008060204
Content-Type: text/x-diff;
 name="video.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="video.diff"

diff --git a/sys/dev/fb/fbd.c b/sys/dev/fb/fbd.c
index f9b4d8e..11cb30e 100644
--- a/sys/dev/fb/fbd.c
+++ b/sys/dev/fb/fbd.c
@@ -51,6 +51,9 @@ __FBSDID("$FreeBSD$");
 #include <dev/vt/vt.h>
 #include <dev/vt/hw/fb/vt_fb.h>
 
+#include <vm/vm.h>
+#include <vm/pmap.h>
+
 #include "fb_if.h"
 
 LIST_HEAD(fb_list_head_t, fb_list_entry) fb_list_head =
@@ -167,14 +170,21 @@ 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) {
+	if (offset >= info->fb_size)
+		return (EINVAL);
+	if (info->fb_pbase == 0) {
+		/*
+		 * If there is no physical address
+		 * assume there is a virtual address
+		 * which is mappable:
+		 */
+		*paddr = vtophys((uint8_t *)info->fb_vbase + offset);
+	} else {
 		*paddr = info->fb_pbase + offset;
-		return (0);
 	}
-	return (EINVAL);
+	return (0);
 }
 
 static int
@@ -354,5 +364,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 5a0fe4f..bd1b881 100644
--- a/sys/dev/vt/hw/fb/vt_fb.c
+++ b/sys/dev/vt/hw/fb/vt_fb.c
@@ -37,10 +37,14 @@ __FBSDID("$FreeBSD$");
 #include <sys/malloc.h>
 #include <sys/queue.h>
 #include <sys/fbio.h>
+
 #include <dev/vt/vt.h>
 #include <dev/vt/hw/fb/vt_fb.h>
 #include <dev/vt/colors/vt_termcolors.h>
 
+#include <vm/vm.h>
+#include <vm/pmap.h>
+
 static struct vt_driver vt_fb_driver = {
 	.vd_name = "fb",
 	.vd_init = vt_fb_init,
@@ -135,7 +139,7 @@ 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;
+		*paddr = vtophys(info->fb_vbase + offset);
 	#ifdef VM_MEMATTR_WRITE_COMBINING
 		*memattr = VM_MEMATTR_WRITE_COMBINING;
 	#endif
@@ -423,7 +427,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) {

--------------020208060106010008060204--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?54E6F060.2010301>