BigW Consortium Gitlab

Commit 29dc0284 by Shikai Chen

initial commit from the internal repos

parent 582da0ba
...@@ -11,3 +11,10 @@ ...@@ -11,3 +11,10 @@
*.lai *.lai
*.la *.la
*.a *.a
# kernel intermedate files
*.o.cmd
*.ko
modules.order
Module.symvers
.tmp_versions
rpusbdisp RoboPeak Mini USB Display
========= ====================================
Drivers and Tools for RoboPeak Mini USB Display Project Drivers and Tools for RoboPeak Mini USB Display Project
Visit RoboPeak Website for details.
Demo Video
====================================
http://www.youtube.com/watch?v=KCNrq1hb99U
[国内用户:] http://www.tudou.com/programs/view/rJd1TwZzRZk/
How to Build the Linux Kernel Driver
====================================
Here we only provide you the basic building process. Please refer to the related documents for details.
I. Prerequisite
-----------------
As a linux kernel driver, it requires you to provide the target system's kernel header or the full source code to build.
Before building the driver, you may need to config the linux kernel to enable the features required by the driver. Otherwise, the building process will fail.
If you want to use the driver with your current kernel (without recompiling the kernel and replacing it with the current one), please make sure the kernel header, the config and the related build scripts you used is belonged to this version of kernel.
Please make sure the following kernel features have been enabled. (via make menuconfig under your kernel source)
0) framebuffer support (CONFIG_FB=y)
1) deferred io support in framebuffer (CONFIG_FB_DEFERRED_IO=y)
2) fb file operation support
CONFIG_FB_CFB_FILLRECT=y
CONFIG_FB_CFB_COPYAREA=y
CONFIG_FB_CFB_IMAGEBLIT=y
CONFIG_FB_SYS_FILLRECT=m
CONFIG_FB_SYS_COPYAREA=m
CONFIG_FB_SYS_IMAGEBLIT=m
CONFIG_FB_SYS_FOPS=m
CONFIG_FB_MODE_HELPERS=y
3) Input event support (Generic input layer support)
You may modify the .config directly to enable these features.
Alternatively, here is a tricky method:
Select the Displaylink display driver ( Device Drivers-> Graphics support -> Support for frame buffer devices-> Displaylink USB Framebuffer support) as an external module. By doing so, the above features will be selected by the menuconfiger.
You may need to recompile the kernel if the above configuration changes have been made.
II. Native Build - build the kernel driver for the current machine
-----------------------------------------------------------------
You should have followed the steps described in the prerequisite section already. Here let's assume the location of the Linux kernel header(or source) is ~/workspace/linux-kernel.
Enter the Robopeak USB Displayer linux kernel driver folder (i.e. rpusbdisp/drivers/linux-driver), using the following command:
$ make KERNEL_SOURCE_DIR=~/workspace/linux-kernel
You should find the build result under the current folder: rp_usbdisplay.ko
III. Cross Compile - build the kernel driver for other platforms
------------------------------------------------------------------
You should have followed the steps described in the prerequisite section already. Here let's assume the location of the Linux kernel header(or source) is ~/workspace/target-linux-kernel.
Let's also assume the target platform is ARMv7. We need to use the cross-compiler : arm-linux-gnueabihf-gcc.
Enter the following command to build the kernel driver for the target:
make CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm KERNEL_SOURCE_DIR=~/workspace/target-linux-kernel
You should find the build result under the current folder: rp_usbdisplay.ko
How to Use the Kernel Driver
============================
I.deploy the dependencies modules
---------------------------------
If you had re-configed and recompiled the Linux kernel as required by the building process, you need to deploy the new kernel and all the kernel modules to the target system.
To be specific, you need to deploy AT LEAST the following kernel module to the target system's /lib/module/<target_kernel_version> folder along with the new kenrel image:
* sysfillrect.ko
* syscopyarea.ko
* sysimgblt.ko
* fb_sys_fops.ko
II. deploy the compiled kernel driver
-------------------------------------
Reboot the target system to using the new kernel. Copy the compiled usb display driver (rp_usbdisplay.ko) to the following location:
/lib/modules/`uname -r`/kernel
Enter the above folder and execute the following command:
depmod -a
III. load the kernel driver
---------------------------
Once you had deployed the kernel driver and all of its dependencies, you can ask the kernel to load the driver using :
modprobe rp_usbdisplay
If you want to let the kernel load the driver automatically each time when the system starts, you can added the following line into the file /etc/modules:
rp_usbdisplay
(i.e. cat rp_usbdisplay >> /etc/modules)
IV. verify the driver
---------------------
Using the lsmod command to check whether the driver has been loaded correctlly. You should get the output similar to the following text:
# lsmod
Module Size Used by
rp_usbdisplay 12171 0 [permanent]
fb_sys_fops 1412 1 rp_usbdisplay
sysimgblt 2199 1 rp_usbdisplay
sysfillrect 3295 1 rp_usbdisplay
syscopyarea 3112 1 rp_usbdisplay
Also, you should find the following message in the dmesg log:
[ 7.535799] input: RoboPeakUSBDisplayTS as /devices/virtual/input/input0
[ 7.548115] usbcore: registered new interface driver rp-usbdisp
To verify the driver work with the RoboPeak USB Display, connect the display to the target system via the USB cable. The display should display RoboPea Logo and turn to black (or something else) for about 3 second.
If the display keeps showing the white noise animation and the message : Waiting for signal, you should check the dmesg to see what happens. Normally, the driver will prompt the following message when the display has been pluged in :
[ 1814.173232] rp-usbdisp 4-1:1.0: RP USB Display found (#1), Firmware Version: X.XX, S/N: XXXXXXXXXXXX
Once the driver recognizes the display, a framebuffer device will be created. (e.g. /dev/fb0)
Use the following command to see whether framebuffer device is belonged to the USB display:
# cat /proc/fb
0
1
2 rpusbdisp-fb <
In the above example, /dev/fb2 is the related framebuffer device. To test whether the framebuffer device works, you may using the following command:
# cat /dev/urandom > /dev/fb2
You should see the display screen is filled with random color dots.
V. make X11 output to the USB display
-------------------------------------
There is a sample X11 config file under the source folder: rpusbdisp/drivers/linux-driver/xserver_conf/10-disp.conf. You can use this sample file as the template to make X11 on your target system to output to the USB display.
STEP1: determine the framebuffer device name of the display.
use the command cat /proc/fb
STEP2: modify the 10-disp.conf, change the framebuffer device name to the one determined in STEP1.
STEP3: copy the file 10-disp.conf to the X11's config folder (/usr/share/X11/xorg.conf.d for most systems).
STEP4: restart the X11 server
The X11 desktop should appear on the USB display.
Contact Us
====================================
Website: www.RoboPeak.com
Email: support@robopeak.com
/*
* RoboPeak Project
* Copyright 2009 - 2013
*
* RP USB Display
* Protocol Def
*
* Initial Version by Shikai Chen
*/
#pragma once
#define RPUSBDISP_DISP_CHANNEL_MAX_SIZE 64 //64bytes
#define RPUSBDISP_STATUS_CHANNEL_MAX_SIZE 32 //32bytes
// -- Display Packets
#define RPUSBDISP_DISPCMD_NOPE 0
#define RPUSBDISP_DISPCMD_FILL 1
#define RPUSBDISP_DISPCMD_BITBLT 2
#define RPUSBDISP_DISPCMD_RECT 3
#define RPUSBDISP_DISPCMD_COPY_AREA 4
#define RPUSBDISP_OPERATION_COPY 0
#define RPUSBDISP_OPERATION_XOR 1
#define RPUSBDISP_OPERATION_OR 2
#define RPUSBDISP_OPERATION_AND 3
#if defined(_WIN32) || defined(__ICCARM__)
#pragma pack(1)
#endif
#define RPUSBDISP_CMD_MASK (0x3F)
#define RPUSBDISP_CMD_FLAG_CLEARDITY (0x1<<6)
#define RPUSBDISP_CMD_FLAG_START (0x1<<7)
typedef struct _rpusbdisp_disp_packet_header_t {
#if 0
_u8 cmd:6;
_u8 cleardirty:1;
_u8 start:1;
#else
_u8 cmd_flag;
#endif
} __attribute__((packed)) rpusbdisp_disp_packet_header_t;
typedef struct _rpusbdisp_disp_fill_packet_t {
rpusbdisp_disp_packet_header_t header;
_u16 color_565;
} __attribute__((packed)) rpusbdisp_disp_fill_packet_t;
typedef struct _rpusbdisp_disp_bitblt_packet_t {
rpusbdisp_disp_packet_header_t header;
_u16 x;
_u16 y;
_u16 width;
_u16 height;
_u8 operation;
} __attribute__((packed)) rpusbdisp_disp_bitblt_packet_t;
typedef struct _rpusbdisp_disp_fillrect_packet_t {
rpusbdisp_disp_packet_header_t header;
_u16 left;
_u16 top;
_u16 right;
_u16 bottom;
_u16 color_565;
_u8 operation;
} __attribute__((packed)) rpusbdisp_disp_fillrect_packet_t;
typedef struct _rpusbdisp_disp_copyarea_packet_t {
rpusbdisp_disp_packet_header_t header;
_u16 sx;
_u16 sy;
_u16 dx;
_u16 dy;
_u16 width;
_u16 height;
} __attribute__((packed)) rpusbdisp_disp_copyarea_packet_t;
#if defined(_WIN32) || defined(__ICCARM__)
#pragma pack()
#endif
// -- Status Packets
#define RPUSBDISP_STATUS_TYPE_NORMAL 0
#define RPUSBDISP_DISPLAY_STATUS_DIRTY_FLAG 0x80 //a full screen transfer is required
#define RPUSBDISP_TOUCH_STATUS_NO_TOUCH 0
#define RPUSBDISP_TOUCH_STATUS_PRESSED 1
#if defined(_WIN32) || defined(__ICCARM__)
#pragma pack(1)
#endif
typedef struct _rpusbdisp_status_packet_header_t {
_u8 packet_type;
} __attribute__((packed)) rpusbdisp_status_packet_header_t;
typedef struct _rpusbdisp_status_normal_packet_t {
rpusbdisp_status_packet_header_t header;
_u8 display_status;
_u8 touch_status;
int touch_x;
int touch_y;
} __attribute__((packed)) rpusbdisp_status_normal_packet_t;
#if defined(_WIN32) || defined(__ICCARM__)
#pragma pack()
#endif
######################################
#
# RoboPeak USB LCD Display Linux Driver
#
# Copyright (C) 2009 - 2013 RoboPeak Team
# This file is licensed under the GPL. See LICENSE in the package.
#
# http://www.robopeak.net
#
# Author Shikai Chen
#
######################################
DRIVER_NAME := rp_usbdisplay
KERNEL_SOURCE_DIR ?= /lib/modules/`uname -r`/build
EXTRA_CFLAGS += -I$(PWD)/src -I$(PWD)/../common
obj-m := $(DRIVER_NAME).o
DRIVER_FILES := src/main.o \
src/usbhandlers.o \
src/fbhandlers.o \
src/touchhandlers.o
$(DRIVER_NAME)-objs:= $(DRIVER_FILES)
modules:
$(MAKE) -C $(KERNEL_SOURCE_DIR) KCPPFLAGS="$(EXTRA_CFLAGS)" M=$(PWD) modules
modules_install:
$(MAKE) -C $(KERNEL_SOURCE_DIR) M=$(PWD) modules_install
install: modules_install
clean:
$(MAKE) -C $(KERNEL_SOURCE_DIR) M=$(PWD) clean
#!/bin/sh
./stop.sh
cp rp_usbdisplay.ko /lib/modules/`uname -r`/
modprobe rp_usbdisplay
echo 1 > /sys/class/vtconsole/vtcon1/bind
/*
* RoboPeak USB LCD Display Linux Driver
*
* Copyright (C) 2009 - 2013 RoboPeak Team
* This file is licensed under the GPL. See LICENSE in the package.
*
* http://www.robopeak.net
*
* Author Shikai Chen
*
* ----------------------------------------------------------------------
* Common Includes
*
*/
#ifndef _COMMON_INCLUDE_H
#define _COMMON_INCLUDE_H
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/mutex.h>
#include <asm/uaccess.h>
#include <linux/usb.h>
#include <linux/list.h>
#include <linux/kthread.h>
#include <linux/platform_device.h>
#include <linux/string.h>
#include <linux/delay.h>
#include <linux/fb.h>
#include <linux/mm.h>
#include <linux/vmalloc.h>
#include <linux/input.h>
#include "inc/types.h"
#include "inc/drvconf.h"
#include "inc/devconf.h"
#include "inc/protocol.h"
// object predefine
struct rpusbdisp_dev;
#ifndef err
#define err(format,arg...) printk(KERN_ERR format, ## arg)
#endif
#ifndef info
#define info(format,arg...) printk(KERN_ERR format, ## arg)
#endif
#endif
/*
* RoboPeak USB LCD Display Linux Driver
*
* Copyright (C) 2009 - 2013 RoboPeak Team
* This file is licensed under the GPL. See LICENSE in the package.
*
* http://www.robopeak.net
*
* Author Shikai Chen
*
* ---------------------------------------------------
* Device Configurations
*/
#ifndef _DEVICE_CONF_H
#define _DEVICE_CONF_H
#define RP_DISP_DRIVER_NAME "rp-usbdisp"
#define RP_DISP_USB_VENDOR_ID 0xFCCF // RP Pseudo vendor id
#define RP_DISP_USB_PRODUCT_ID 0xA001
#define RP_DISP_DEFAULT_HEIGHT 240
#define RP_DISP_DEFAULT_WIDTH 320
#define RP_DISP_DEFAULT_PIXEL_BITS 16
typedef _u16 pixel_type_t;
#endif
/*
* RoboPeak USB LCD Display Linux Driver
*
* Copyright (C) 2009 - 2013 RoboPeak Team
* This file is licensed under the GPL. See LICENSE in the package.
*
* http://www.robopeak.net
*
* Author Shikai Chen
*
* ---------------------------------------------------
* Driver Configurations
*/
#ifndef _DRIVER_CONF_H
#define _DRIVER_CONF_H
#define DRIVER_LICENSE_INFO "GPL"
#define DRIVER_VERSION "RoboPeak USB Display Driver Version 0.01"
#define RPUSBDISP_MINOR 300
#define RPUSBDISP_STATUS_QUERY_RETRY_COUNT 4
#define RPUSBDISP_MAX_TRANSFER_SIZE (PAGE_SIZE*16 - 512)
#define RPUSBDISP_MAX_TRANSFER_TICKETS_COUNT 10
#endif
/*
* RoboPeak USB LCD Display Linux Driver
*
* Copyright (C) 2009 - 2013 RoboPeak Team
* This file is licensed under the GPL. See LICENSE in the package.
*
* http://www.robopeak.net
*
* Author Shikai Chen
*
* ---------------------------------------------------
* Definition of Frame Buffer Handlers
*/
#ifndef _RPUSBDISP_FBHANDLERS_H
#define _RPUSBDISP_FBHANDLERS_H
int register_fb_handlers(void);
void unregister_fb_handlers(void);
int fbhandler_on_new_device(struct rpusbdisp_dev * dev);
void fbhandler_on_remove_device(struct rpusbdisp_dev * dev);
void fbhandler_on_all_transfer_done(struct rpusbdisp_dev * dev);
void fbhandler_set_unsync_flag(struct rpusbdisp_dev * dev);
#endif
/*
* RoboPeak USB LCD Display Linux Driver
*
* Copyright (C) 2009 - 2013 RoboPeak Team
* This file is licensed under the GPL. See LICENSE in the package.
*
* http://www.robopeak.net
*
* Author Shikai Chen
*
* ---------------------------------------------------
* Definition of Touch Event Handlers
*/
#ifndef _RPUSBDISP_TOUCH_HANDLERS_H
#define _RPUSBDISP_TOUCH_HANDLERS_H
int register_touch_handler(void);
void unregister_touch_handler(void);
int touchhandler_on_new_device(struct rpusbdisp_dev * dev);
void touchhandler_on_remove_device(struct rpusbdisp_dev * dev);
void touchhandler_send_ts_event(struct rpusbdisp_dev * dev, int x, int y, int touch);
#endif
/*
* RoboPeak USB LCD Display Linux Driver
*
* Copyright (C) 2009 - 2013 RoboPeak Team
* This file is licensed under the GPL. See LICENSE in the package.
*
* http://www.robopeak.net
*
* Author Shikai Chen
*
* ----------------------------------------------------------------------
* Unified Type Def
*
*/
#ifndef RPDRIVER_TYPE_H
#define RPDRIVER_TYPE_H
typedef __u8 _u8;
typedef __u16 _u16;
typedef __u32 _u32;
typedef __u64 _u64;
typedef __s8 _s8;
typedef __s16 _s16;
typedef __s32 _s32;
typedef __s64 _s64;
#endif
\ No newline at end of file
/*
* RoboPeak USB LCD Display Linux Driver
*
* Copyright (C) 2009 - 2013 RoboPeak Team
* This file is licensed under the GPL. See LICENSE in the package.
*
* http://www.robopeak.net
*
* Author Shikai Chen
*
* ---------------------------------------------------
* Definition of USB Driver Handlers
*/
#ifndef _DRIVER_HANDLER_H
#define _DRIVER_HANDLER_H
int register_usb_handlers(void);
void unregister_usb_handlers(void);
int rpusbdisp_usb_get_device_count(void);
struct device * rpusbdisp_usb_get_devicehandle(struct rpusbdisp_dev *);
void rpusbdisp_usb_set_fbhandle(struct rpusbdisp_dev *, void *);
void * rpusbdisp_usb_get_fbhandle(struct rpusbdisp_dev * dev);
void rpusbdisp_usb_set_touchhandle(struct rpusbdisp_dev * dev, void *);
void * rpusbdisp_usb_get_touchhandle(struct rpusbdisp_dev * dev);
int rpusbdisp_usb_try_send_image(struct rpusbdisp_dev * dev, const pixel_type_t * framebuffer, int x, int y, int right, int bottom, int line_width, int clear_dirty);
int rpusbdisp_usb_try_draw_rect(struct rpusbdisp_dev * dev, int x, int y, int right, int bottom, pixel_type_t color, int operation);
int rpusbdisp_usb_try_copy_area(struct rpusbdisp_dev * dev, int sx, int sy, int dx, int dy, int width, int height);
#endif
\ No newline at end of file
/*
* RoboPeak USB LCD Display Linux Driver
*
* Copyright (C) 2009 - 2013 RoboPeak Team
* This file is licensed under the GPL. See LICENSE in the package.
*
* http://www.robopeak.net
*
* Author Shikai Chen
*
*/
#include "inc/common.h"
#include "inc/usbhandlers.h"
#include "inc/fbhandlers.h"
#include "inc/touchhandlers.h"
#if 0
static const struct file_operations lcd_fops = {
.owner = THIS_MODULE,
.read = lcd_read,
.write = lcd_write,
.open = lcd_open,
.unlocked_ioctl = lcd_ioctl,
.release = lcd_release,
.llseek = noop_llseek,
};
/*
* usb class driver info in order to get a minor number from the usb core,
* and to have the device registered with the driver core
*/
static struct usb_class_driver lcd_class = {
.name = "usbdisp%d",
.fops = &lcd_fops,
.minor_base = USBLCD_MINOR,
};
#endif
static int __init usb_disp_init(void)
{
int result;
do {
result = register_touch_handler();
if (result) {
err("touch_handler failed. Error number %d", result);
break;
}
result = register_fb_handlers();
if (result) {
err("fb handler register failed. Error number %d", result);
break;
}
result = register_usb_handlers();
if (result) {
err("usb_register failed. Error number %d", result);
break;
}
}while(0);
return result;
}
static void __exit usb_disp_exit(void)
{
unregister_usb_handlers();
unregister_fb_handlers();
unregister_touch_handler();
}
module_init(usb_disp_init);
module_exit(usb_disp_exit);
MODULE_AUTHOR("Shikai Chen <csk@live.com>");
MODULE_DESCRIPTION(DRIVER_VERSION);
MODULE_LICENSE(DRIVER_LICENSE_INFO);
/*
* RoboPeak USB LCD Display Linux Driver
*
* Copyright (C) 2009 - 2013 RoboPeak Team
* This file is licensed under the GPL. See LICENSE in the package.
*
* http://www.robopeak.net
*
* Author Shikai Chen
*
* ---------------------------------------------------
* Touch Event Handlers
*/
#include "inc/common.h"
#include "inc/touchhandlers.h"
#include "inc/usbhandlers.h"
static struct input_dev * _default_input_dev;
static volatile int _live_flag;
static int _on_create_input_dev(struct input_dev ** inputdev)
{
*inputdev = input_allocate_device();
if (!inputdev) {
return -ENOMEM;
}
(*inputdev)->evbit[0] = BIT(EV_SYN) | BIT(EV_KEY) | BIT(EV_ABS);
(*inputdev)->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
input_set_abs_params((*inputdev), ABS_X, 0, RP_DISP_DEFAULT_WIDTH, 0, 0);
input_set_abs_params((*inputdev), ABS_Y, 0, RP_DISP_DEFAULT_HEIGHT, 0, 0);
input_set_abs_params((*inputdev), ABS_PRESSURE, 0, 1, 0, 0);
(*inputdev)->name = "RoboPeakUSBDisplayTS";
(*inputdev)->id.bustype = BUS_USB;
return input_register_device((*inputdev));
}
static void _on_release_input_dev(struct input_dev * inputdev)
{
input_unregister_device(inputdev);
}
int __init register_touch_handler(void)
{
int ret = _on_create_input_dev(&_default_input_dev);
if (!ret) _live_flag = 1;
return ret;
}
void unregister_touch_handler(void)
{
_live_flag = 0;
_on_release_input_dev(_default_input_dev);
_default_input_dev = NULL;
}
int touchhandler_on_new_device(struct rpusbdisp_dev * dev)
{
// singleton design
return 0;
}
void touchhandler_on_remove_device(struct rpusbdisp_dev * dev)
{
// singleton design
}
void touchhandler_send_ts_event(struct rpusbdisp_dev * dev, int x, int y, int touch)
{
if (!_default_input_dev || !_live_flag) return;
if (touch) {
input_report_abs(_default_input_dev,ABS_X, x);
input_report_abs(_default_input_dev,ABS_Y, y);
input_report_abs(_default_input_dev, ABS_PRESSURE, 1);
input_report_key(_default_input_dev,BTN_TOUCH, 1);
input_sync(_default_input_dev);
} else {
input_report_abs(_default_input_dev, ABS_PRESSURE, 0);
input_report_key(_default_input_dev,BTN_TOUCH, 0);
input_sync(_default_input_dev);
}
}
\ No newline at end of file
#!/bin/sh
echo 0 > /sys/class/vtconsole/vtcon1/bind
rmmod rp_usbdisplay
Section "Device"
Identifier "RPUSBDispFB"
Driver "fbdev"
Option "fbdev" "/dev/fb0"
EndSection
Section "Screen"
Identifier "RPUSBDisp"
Device "RPUSBDispFB"
DefaultFbBpp 16
SubSection "Display"
Visual "TrueColor"
EndSubSection
EndSection
Section "InputClass"
Identifier "RPUSBTouch"
MatchDevicePath "/dev/input/event*"
Driver "evdev"
EndSection
copy the file to /usr/share/X11/xorg.conf.d on Ubuntu system
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment