[Libdlo] DLFB 0.1 (udlfb)

Greg KH greg at kroah.com
Fri May 22 16:04:56 PDT 2009


On Fri, May 22, 2009 at 09:42:36PM +0200, Roberto De Ioris wrote:
> Hi all, this is the first (prototype) release of a linux
> framebuffer module for the displaylink devices.

Very cool.  Want me to add this to the drivers/staging/ tree in the
kernel at this point in time?  Or do you want to work on it some more
first?

> /*****************************************************************************
>  *                          DLFB Kernel Driver                               *
>  *                            Version 0.1 (udlfb)                            *
>  *             (C) 2009 Roberto De Ioris <roberto at unbit.it>                  *
>  *                                                                           *
>  *     This file is licensed under the GPL. See COPYING in the package.      *
>  * Based on the amazing work of Florian Echtler and libdlo 0.1               *

Which version of the GPL is this licensed under?  You might be a bit
more specific :)

> /*
> 
> static struct usb_device_id id_table [] = {
> 	{ USB_DEVICE(0x17e9, 0x023d) },
>         { }
> };
> 
> */
> 
> static struct usb_device_id id_table [] = {
>         { .idVendor = 0x17e9, .match_flags = USB_DEVICE_ID_MATCH_VENDOR, },
>         { },
> };

You should probably stick with the explicit product id until you have
tested it on other devices.  I think newer ones will need some more
commands before they will work properly like this one.

> static int image_blit(struct dlfb_data *dev, int x, int y, int width, int height, char *data) {
> 	
> 	int i,j,base ;
> 	int rem = width ;
> 	int ret, clen;
> 	u32 col;
> 	u16 dlocol ;
> 	
> 
> 	base = (FB_W*2*y)+(x*2) ;
> 
> 	data += (FB_W*2*y)+(x*2) ;
> 
> 	//printk("IMAGE_BLIT\n");
> 
>         for(i = y;i<y+height;i++) {
> 
>                 rem = width ;
> 
> 		//printk("WRITING LINE %d\n", i);
> 
>                 while(rem) {
> 
>                         dev->buf[0] = 0xAF ;
>                         dev->buf[1] = 0x68 ;
> 
>                         dev->buf[2] = (char)(base >> 16) ;
>                         dev->buf[3] = (char)(base >> 8) ;
>                         dev->buf[4] = (char)(base) ;
> 
>                         if (rem > 255) {
>                                 dev->buf[5] = 255 ;
> 				for(j=0;j<510;j+=2) {
> 					col = read_pixel_565(data+j, 1);
> 					dlocol = ntohs(rgb16(col));
> 					memcpy(dev->buf+6+j, &dlocol, 2); 
> 				}
> 				//memcpy(dev->buf+6, data, 510) ;
> 				//memset(dev->buf+6, 0xff, 510);
>                         	ret = usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, 1), dev->buf, 510+6, &clen,0);
>                                 rem-=255;
>                                 base+=510;
> 				data+= 510;
>                         } 
>                         else {
>                                 dev->buf[5] = rem ;
> 				//memset(dev->buf+6, 0xff, rem*2);
> 				//memcpy(dev->buf+6, data, rem*2) ;
> 				for(j=0;j<rem*2;j+=2) {
>                                         col = read_pixel_565(data+j, 1);
>                                         dlocol = ntohs(rgb16(col));
>                                         memcpy(dev->buf+6+j, &dlocol, 2);
>                                 }
>                         	ret = usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, 1), dev->buf, (rem*2)+6, &clen,0);
>                                 base+= rem*2 ;
> 				data+= rem*2;
>                                 rem = 0 ;
>                         }

That's going to be slow, using usb_bulk_msg().  Think we can just create
urbs and fire them off to be reaped automatically later instead?  That
should let us queue things up much better.

> 			ret = usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, 1), dev->buf, 9, &clen,0);
> 			//printk("scritta linea in framebuffer %d %d\n", ret, clen);

Same here.

> static int dlfb_probe(struct usb_interface *interface, const struct usb_device_id *id)
> {
> 	struct dlfb_data *dev ;
> 	struct fb_info *info;
> 	int i ;
> 
> 	int ret ;
> 	char rbuf[4] ;
> 	int clen;
> 	
> 
> 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
> 	if (dev == NULL) {
> 		printk("cannot allocate dev structure.\n");
> 		return -ENOMEM;
> 	}
> 
> 	dev->udev = usb_get_dev(interface_to_usbdev(interface));
>         dev->interface = interface;
> 	
> 	printk("DisplayLink device attached\n");

dev_info please :)

> 	dev->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
> 	if (dev->tx_urb == NULL) {
> 		printk("error allocatin tx urb\n");
> 		goto out4;
> 	}
> 	printk("allocato tx urb %p\n", dev->tx_urb); 

What are you using this urb for? 

> 	dev->ctrl_urb = usb_alloc_urb(0, GFP_KERNEL);

And this one?

thanks,

greg k-h


More information about the Libdlo mailing list