Beaglebone && GUI

旧街凉风 提交于 2019-11-30 22:39:58
    本文基于chipsee平台的扩展板为Beaglebone平台添加GUI支持。

   首先是开发环境的选择,这里我们使用TI SDK(ti-sdk-am335x-evm-05.06.00.00-Linux-x86)中提供的Linux内核与最精简根文件系统(arago-base-tisdk-image-am335x-evm.tar.gz)。

修改Linux内核支持Chipsee扩展板LCD与电容屏
   这个可以对照chipsee提供的修改过的内核来做,无非就是添加两个驱动支持(具体设备名称参见chipsee提供的资料)。
    1) 添加LCD相关支持
            (1) LCD背光支持,不用手动添加,原始代码中已有,这里列出相关代码。

arch/arm/mach-omap2/board-am335xevm.c:

static struct platform_pwm_backlight_data am335x_backlight_data0 = {
 .pwm_id         = "ecap.0",
 .ch             = -1,
 .lth_brightness = 21,
 .max_brightness = AM335X_BACKLIGHT_MAX_BRIGHTNESS,
 .dft_brightness = AM335X_BACKLIGHT_DEFAULT_BRIGHTNESS,
 .pwm_period_ns  = AM335X_PWM_PERIOD_NANO_SECONDS,
};
static struct platform_pwm_backlight_data am335x_backlight_data2 = {
 .pwm_id         = "ecap.2",
 .ch             = -1,
 .lth_brightness = 21,
 .max_brightness = AM335X_BACKLIGHT_MAX_BRIGHTNESS,
 .dft_brightness = AM335X_BACKLIGHT_DEFAULT_BRIGHTNESS,
 .pwm_period_ns  = AM335X_PWM_PERIOD_NANO_SECONDS,
};

... ...

/* Setup pwm-backlight */
static struct platform_device am335x_backlight = {
 .name           = "pwm-backlight",
 .id             = -1,
 .dev		= {
 .platform_data = &am335x_backlight_data0,    // 我也不知道为什么要先设成data0再修改成data2,可能有些其他evm板使用的是ecap.0吧
 },
};

... ...

static int __init backlight_init(void)
{
	int status = 0;

	if (backlight_enable) {
		int ecap_index = 0;                        // 默认使用ecap.0

		switch (am335x_evm_get_id()) {
		case GEN_PURP_EVM:
		case GEN_PURP_DDR3_EVM:
			ecap_index = 0;
			break;
		case EVM_SK:
			/*
			 * Invert polarity of PWM wave from ECAP to handle
			 * backlight intensity to pwm brightness
			 */
			ecap_index = 2;
			pwm_pdata[ecap_index].chan_attrib[0].inverse_pol = true;
			am335x_backlight.dev.platform_data =
				&am335x_backlight_data2;    // Beaglebone使用ecap.2
			break;
		default:
			pr_err("%s: Error on attempting to enable backlight,"
				" not supported\n", __func__);
			return -EINVAL;
		}

		am33xx_register_ecap(ecap_index, &pwm_pdata[ecap_index]);    // 注册设备
		platform_device_register(&am335x_backlight);                 // sys文件系统
	}
	return status;
}
late_initcall(backlight_init);    // board初始化后调用

            (2)  LCD控制器初始化,一个是TFP410(TI芯片,位于扩展板),另一个为INNOLUX_TN92(位于LCD屏幕上,使用TFP410进行控制)。

arch/arm/mach-omap2/board-am335xevm.c:

static const struct display_panel disp_panel = {
 WVGA,
 16,
 16,
 COLOR_ACTIVE,
};

... ...

static struct lcd_ctrl_config lcd_cfg = {
	&disp_panel,
	.ac_bias		= 255,
	.ac_bias_intrpt		= 0,
	.dma_burst_sz		= 16,
	.bpp			= 16,
	.fdd			= 0x80,
	.tft_alt_mode		= 0,
	.stn_565_mode		= 0,
	.mono_8bit_mode		= 0,
	.invert_line_clock	= 0,
	.invert_frm_clock	= 1,
	.sync_edge		= 0,
	.sync_ctrl		= 1,
	.raster_order		= 0,
};

struct da8xx_lcdc_platform_data TFC_S9700RTWV35TR_01B_pdata = {
	.manu_name		= "ThreeFive",
	.controller_data	= &lcd_cfg,
	.type			= "INNOLUX_TN92",
};

static void csun_lcdc_init(int evm_id, int profile) {
        setup_pin_mux(lcdc_pin_mux);        // lcdc_pin_mux 此结构太长且不许要修改在这就不列出了

        if (conf_disp_pll(300000000)) {
            pr_info("Failed configure display PLL, not attempting to"
                    "register LCDC\n");
            return;
        }

        if (am33xx_register_lcdc(&TFC_S9700RTWV35TR_01B_pdata))
            pr_info("Failed to register LCDC device\n");
}

... ...
drivers/video/ da8xx-fb.c:
static struct da8xx_panel known_lcd_panels[] = {
	/* Sharp LCD035Q3DG01 */
	[0] = {
		.name = "Sharp_LCD035Q3DG01",
		.width = 320,
		.height = 240,
		.hfp = 8,
		.hbp = 6,
		.hsw = 0,
		.vfp = 2,
		.vbp = 2,
		.vsw = 0,
		.pxl_clk = 4608000,
		.invert_pxl_clk = 1,
	},

        ... ...

	/* INNOLUX AT070TN92 */            // 添加 "INNOLUX AT070TN92" panel
	[4] = {
		.name = "INNOLUX_TN92",
		.width = 800, 
		.height = 480, 
		.hfp = 1, 
		.hbp = 45,
		.hsw = 48,
		.vfp = 12,
		.vbp = 20,
		.vsw = 2, 
		.pxl_clk = 25000000,
		.invert_pxl_clk = 0, 
	},   
};

    2) 添加触摸屏支持
            (1) 触摸屏初始化,其实就是初始化管脚配置,具体工作留给相应驱动程序完成。

arch/arm/mach-omap2/board-am335xevm.c:

/* Pin mux for captive touch screen */ 
static struct pinmux_config cap_tsc_pin_mux[] = { 
        {"gpmc_wait0.gpio0_30",         OMAP_MUX_MODE7 | AM33XX_PIN_INPUT}, 
        {"NULL",0}, 
};

#define CAP_TSC_INT           GPIO_TO_PIN(0,30)
static void cap_tsc_init(int evm_id,int profile)
{
        setup_pin_mux(cap_tsc_pin_mux);
        return;
}
            (2) 添加对应触摸屏的驱动程序与头文件: drivers/input/touchscreen/ ft5x0x_ts.c; include/linux/i2c/ ft5x06_ts.h;  include/linux/ earlysuspend.h   (都可以从Android中扒过来) ,而后修改drivers/input/touchscreen 目录下的Kconfig文件与Makefile:
... ...
config TOUCHSCREEN_FT5X0X
        tristate "FocalTech ft5x0x touchscreen"
        depends on I2C 
        default n
... ...
wm97xx-ts-y := wm97xx-core.o

obj-$(CONFIG_TOUCHSCREEN_FT5X0X)        += ft5x0x_ts.o
obj-$(CONFIG_TOUCHSCREEN_88PM860X)      += 88pm860x-ts.o
... ...

    3) 向beaglebone 初始化结构中添加相应函数

arch/arm/mach-omap2/board-am335xevm.c:

... ...
/* Beaglebone Rev A3 and after */
static struct evm_dev_cfg beaglebone_dev_cfg[] = {
    {am335x_rtc_init,   DEV_ON_BASEBOARD, PROFILE_NONE},
    {clkout2_enable,    DEV_ON_BASEBOARD, PROFILE_NONE},
    {tps65217_init,	DEV_ON_BASEBOARD, PROFILE_NONE},
    {csun_lcdc_init,    DEV_ON_BASEBOARD, PROFILE_NONE}, // ADD BY Cedric Sun, lcd controller
    {cap_tsc_init,	DEV_ON_BASEBOARD, PROFILE_NONE}, // ADD BY Cedric Sun, capacitive touch screen pin mux
    {mii1_init,	        DEV_ON_BASEBOARD, PROFILE_NONE},
    {usb0_init,	        DEV_ON_BASEBOARD, PROFILE_NONE},
    {usb1_init,	        DEV_ON_BASEBOARD, PROFILE_NONE},
    {mmc0_init,	        DEV_ON_BASEBOARD, PROFILE_NONE},
    {i2c1_init,	        DEV_ON_BASEBOARD, PROFILE_NONE}, // ADD BY Cedric Sun, used by capacitive touch screen
    {i2c2_init,	        DEV_ON_BASEBOARD, PROFILE_NONE},
    {NULL, 0, 0},
};
... ...
    4)  一切准备妥当,重新编译内核,别忘了选择触摸屏模块,编译成模块或是直接进内核都行。

    5) 使用tslib 来进行测试,具体tslib 的编译安装这里不表。

添加QT4.8.4支持

    1) 从  http://download.qt-project.org/official_releases/qt/4.8/4.8.4/qt-everywhere-opensource-src-4.8.4.tar.gz 下载源码。

   2) 添加mkspecs 文件,在qt-src/mkspecs/qws 目录下添加linux-arago-g++ 文件夹,在其下创建两个文件"qmake.conf", "qplatformdefs.h"。

qmake.conf:

#
# qmake configuration for building with arm-linux-g++
#

QMAKE_CFLAGS_RELEASE     = -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp
QMAKE_INCDIR             = /home/cedric/Projects/beaglebone/tools/tslib/install/include
QMAKE_LIBDIR             = /home/cedric/Projects/beaglebone/tools/tslib/install/lib

include(../../common/linux.conf)
include(../../common/gcc-base-unix.conf)
include(../../common/g++-unix.conf)
include(../../common/qws.conf)

# modifications to g++.conf
QMAKE_CC                = arm-arago-linux-gnueabi-gcc
QMAKE_CXX               = arm-arago-linux-gnueabi-g++
QMAKE_LINK              = arm-arago-linux-gnueabi-g++
QMAKE_LINK_SHLIB        = arm-arago-linux-gnueabi-g++

# modifications to linux.conf
QMAKE_AR                = arm-arago-linux-gnueabi-ar cqs 
QMAKE_OBJCOPY           = arm-arago-linux-gnueabi-objcopy
QMAKE_STRIP             = arm-arago-linux-gnueabi-strip

load(qt_config)

qplatformdefs.h:

#include "../../linux-g++/qplatformdefs.h"
    3) 在qt-src 目录下执行./configure 
./configure -opensource -confirm-license -no-pch -platform linux-g++-64 -xplatform qws/linux-arago-g++ -embedded armv7 -prefix /opt/qt -qt-gfx-linuxfb -qt-gfx-vnc -no-largefile -exceptions -no-accessibility -no-qt3support -no-sse2 -qt-zlib -no-gif -no-libtiff -qt-libpng -no-libmng -qt-libjpeg -openssl -no-nis -no-cups -qt-kbd-linuxinput -nomake demos -nomake examples -qt-mouse-linuxinput -qt-mouse-tslib
    4) make -j5; make install(可能出错,依编译环境而定
    5) 拷贝/opt/qt 到开发板上的相同目录中,有些东西是不必要的,例如bin/ 等等。
    6
) 设置QT编译环境,使用如下脚本,soucre 一下就好

export OE_QMAKE_CC=arm-arago-linux-gnueabi-gcc
export OE_QMAKE_CXX=arm-arago-linux-gnueabi-g++
export OE_QMAKE_LINK=arm-arago-linux-gnueabi-g++
export OE_QMAKE_LINK_SHLIB=arm-arago-linux-gnueabi-g++

export OE_QMAKE_AR=arm-arago-linux-gnueabi-ar
export OE_QMAKE_OBJCOPY=arm-arago-linux-gnueabi-objcopy
export OE_QMAKE_STRIP=arm-arago-linux-gnueabi-strip

export OE_QMAKE_CFLAGS="-march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp"

export PATH=$PATH:"/usr/local/ti-sdk-am335x-evm/linux-devkit/bin"
    7) 设置执行环境(在beaglebone 开发板上调用),使用如下脚本,source 一下就好
#!/bin/sh                                                                       
                                                                                
# QWS                                                                           
export QWS_MOUSE_PROTO=Tslib:/dev/input/event0
export POINTERCAL_FILE=$TSLIB_ROOT/etc/pointercal
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/qt/lib
                                                                                
# tslib                                                                         
export TSLIB_ROOT=/opt/tslib
export TSLIB_TSDEVICE=/dev/input/event0
export TSLIB_CONFFILE=$TSLIB_ROOT/etc/ts.conf
export TSLIB_PLUGINDIR=$TSLIB_ROOT/lib/ts
export TSLIB_CALIBFILE=$TSLIB_ROOT/etc/pointercal
export TSLIB_FBDEVICE=/dev/fb0
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TSLIB_ROOT/lib
     8) 编译example进行测试就好。












易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!