本文均属自己阅读源码的点滴总结,转账请注明出处谢谢。
欢迎和大家交流。qq:1037701636 email: [email protected],[email protected]
过去的一周,大概不到5天由于项目的部分需求暂时需要使用到触摸屏,所以暂时停下来做了一下bb-xm的触摸屏移植和Qt的支持。
学是必须的,写代码是必须的,看代码是必须的,整理文档也是必须的。
下面就简单和大家分享过去一周的成果。
1.先是简单介绍Qt4.6.2的移植部分,其实移植早做好了,只是现在想增加触摸屏对qt的支持,所以给出如下qt的编译配置:
./configure -prefix /home/Qt/lib_arm -opensource -confirm-license -release -shared -embedded arm -xplatform qws/linux-arm-g++ -depths 8,16,24,32 -fast -optimized-qmake -pch -qt-sql-sqlite -qt-libjpeg -qt-zlib -qt-libpng -qt-freetype -little-endian -host-little-endian -no-qt3support -no-libtiff -no-libmng -no-opengl -no-mmx -no-sse -no-sse2 -no-3dnow -no-openssl -no-webkit -no-phonon -no-nis -no-opengl -no-cups -no-glib -no-xcursor -no-xfixes -no-xrandr -no-xrender -no-separate-debug-info -nomake examples -nomake tools -nomake docs -qt-mouse-tslib -I /home/Qt/tslib/include -L /home/Qt/tslib/lib -verbose
-qt-mouse-tslib -I /home/Qt/tslib/include -L /home/Qt/tslib/lib这部分是Qt支持触摸屏的关键,-I和-L分别制定了tslib所在的库和头文件,说道这里tslib的编译简单如下:
//by gzz #ifdef CONFIG_TOUCHSCREEN_ADS7846 #define OMAP3_BEAGLE_TS_GPIO 162 /* gpio_133 for v1.0 */ #include <plat/mcspi.h> #include <linux/spi/spi.h> #include <linux/spi/ads7846.h> //for ads7864 touchscreen static struct omap2_mcspi_device_config ads7846_mcspi_config = { .turbo_mode = 0, .single_channel = 1, /* 0: slave, 1: master */ }; static int ads7846_get_pendown_state(void) { return !gpio_get_value(OMAP3_BEAGLE_TS_GPIO); } struct ads7846_platform_data ads7846_config = { .x_max = 0x0fff, .y_max = 0x0fff, .x_plate_ohms = 180, .pressure_max = 255, .debounce_max = 10, .debounce_tol = 3, .debounce_rep = 1, .get_pendown_state = ads7846_get_pendown_state, .keep_vref_on = 1, .settle_delay_usecs = 150, .wakeup = true, }; struct spi_board_info omap3beagle_spi_board_info[] = { [0] = { .modalias = "ads7846", .bus_num = 3, .chip_select = 0, .max_speed_hz = 1500000, .controller_data = &ads7846_mcspi_config, .irq = OMAP_GPIO_IRQ(OMAP3_BEAGLE_TS_GPIO), .platform_data = &ads7846_config, }, }; static void ads7846_dev_init(void) { printk("Initialize ads7846 touch screen controller\n"); if (gpio_request(OMAP3_BEAGLE_TS_GPIO, "ADS7846 pendown") < 0) printk(KERN_ERR "can't get ads7846 pen down GPIO\n"); gpio_direction_input(OMAP3_BEAGLE_TS_GPIO); omap_set_gpio_debounce(OMAP3_BEAGLE_TS_GPIO, 1); omap_set_gpio_debounce_time(OMAP3_BEAGLE_TS_GPIO, 0xa); } #else static inline void __init ads7846_dev_init(void) { return; } #endif加入该部分代码后再在该模块初始化函数omap3_beagle_init中