rk29_phone: touch screen driver add four virtual keys
This commit is contained in:
parent
7eb1bd4ba5
commit
16efb0f379
3 changed files with 125 additions and 56 deletions
|
|
@ -1433,7 +1433,7 @@ struct rk29_i2c_platform_data default_i2c2_data = {
|
|||
.bus_num = 2,
|
||||
.flags = 0,
|
||||
.slave_addr = 0xff,
|
||||
.scl_rate = 200*1000,
|
||||
.scl_rate = 400*1000,
|
||||
.mode = I2C_MODE_IRQ,
|
||||
.io_init = rk29_i2c2_io_init,
|
||||
};
|
||||
|
|
@ -2730,10 +2730,10 @@ struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
|
|||
* xpt2046 touch panel
|
||||
* author: hhb@rock-chips.com
|
||||
*****************************************************************************************/
|
||||
#if defined(CONFIG_TOUCHSCREEN_XPT2046_NORMAL_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_TSLIB_SPI)
|
||||
#define XPT2046_GPIO_INT RK29_PIN4_PD5 //中断脚
|
||||
#define DEBOUNCE_REPTIME 3
|
||||
|
||||
#if defined(CONFIG_TOUCHSCREEN_XPT2046_NORMAL_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_TSLIB_SPI)
|
||||
static struct xpt2046_platform_data xpt2046_info = {
|
||||
.model = 2046,
|
||||
.keep_vref_on = 1,
|
||||
|
|
@ -2846,6 +2846,70 @@ static struct spi_board_info board_spi_devices[] = {
|
|||
};
|
||||
|
||||
|
||||
/**********************************************************************************************
|
||||
*
|
||||
* The virtual keys for android "back", "home", "menu", "search", these four keys are touch key
|
||||
* on the touch screen panel. (added by hhb@rock-chips.com 2011.03.31)
|
||||
*
|
||||
***********************************************************************************************/
|
||||
static ssize_t rk29xx_virtual_keys_show(struct kobject *kobj,
|
||||
struct kobj_attribute *attr, char *buf)
|
||||
{
|
||||
#if (defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) && defined(CONFIG_TOUCHSCREEN_480X800)) \
|
||||
|| defined(CONFIG_TOUCHSCREEN_HX8520_IIC) || defined(CONFIG_TOUCHSCREEN_GT801_IIC)
|
||||
/* center: x: home: 50, menu: 184, back: 315, search 435, y: 830*/
|
||||
/* centerx;centery;width;height; */
|
||||
return sprintf(buf,
|
||||
__stringify(EV_KEY) ":" __stringify(KEY_BACK) ":315:815:120:50" //":50:830:98:50" //":210:796:98:50"
|
||||
":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":85:815:88:50" // ":184:830:120:50" // ":435:796:120:50"
|
||||
":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":184:815:100:50" //":315:830:100:50" //":320:796:100:50"
|
||||
":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":435:815:88:50" //":50:815:98:50" // //":85:796:88:50"
|
||||
"\n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct kobj_attribute rk29xx_virtual_keys_attr = {
|
||||
.attr = {
|
||||
#if defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
|
||||
.name = "virtualkeys.xpt2046-touchscreen",
|
||||
#elif defined(CONFIG_TOUCHSCREEN_HX8520_IIC)
|
||||
.name = "virtualkeys.hx8520-touchscreen",
|
||||
#elif defined(CONFIG_TOUCHSCREEN_GT801_IIC)
|
||||
.name = "virtualkeys.gt801-touchscreen",
|
||||
#endif
|
||||
|
||||
|
||||
.mode = S_IRUGO,
|
||||
},
|
||||
.show = &rk29xx_virtual_keys_show,
|
||||
};
|
||||
|
||||
static struct attribute *rk29xx_properties_attrs[] = {
|
||||
&rk29xx_virtual_keys_attr.attr,
|
||||
NULL
|
||||
};
|
||||
|
||||
static struct attribute_group rk29xx_properties_attr_group = {
|
||||
.attrs = rk29xx_properties_attrs,
|
||||
};
|
||||
static int rk29xx_virtual_keys_init(void)
|
||||
{
|
||||
int ret;
|
||||
struct kobject *properties_kobj;
|
||||
printk("rk29xx_virtual_keys_init \n");
|
||||
properties_kobj = kobject_create_and_add("board_properties", NULL);
|
||||
if (properties_kobj)
|
||||
ret = sysfs_create_group(properties_kobj,
|
||||
&rk29xx_properties_attr_group);
|
||||
if (!properties_kobj || ret)
|
||||
{
|
||||
pr_err("failed to create board_properties\n");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static void __init rk29_gic_init_irq(void)
|
||||
{
|
||||
gic_dist_init(0, (void __iomem *)RK29_GICPERI_BASE, 32);
|
||||
|
|
@ -2905,6 +2969,7 @@ static void __init machine_rk29_board_init(void)
|
|||
spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
|
||||
|
||||
rk29sdk_init_wifi_mem();
|
||||
rk29xx_virtual_keys_init();
|
||||
}
|
||||
|
||||
static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
|
||||
|
|
|
|||
|
|
@ -46,7 +46,10 @@
|
|||
#define TOUCH_REG_NUM 5 //ÿ<><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ļĴ<C4BC><C4B4><EFBFBD><EFBFBD><EFBFBD>Ŀ
|
||||
|
||||
const unsigned char GT801_RegData[GT801_REGS_NUM]={
|
||||
0x19,0x05,0x06,0x28,0x02,0x14,0x14,0x10,0x40,0xB0,0x01,0xE0,0x03,0x4C,0x78,0x9A,0xBC,0xDE,0x65,0x43,0x20,0x11,0x00,0x00,0x00,0x00,0x05,0xCF,0x20,0x0B,0x0D,0x8D,0x32,0x3C,0x1E,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01
|
||||
0x19,0x05,0x06,0x28,0x02,0x14,0x14,0x10,0x40,0xB0,0x01,0xE0,0x03,0x4C,0x78,
|
||||
0x9A,0xBC,0xDE,0x65,0x43,0x20,0x11,0x00,0x00,0x00,0x00,0x05,0xCF,0x20,0x0B,
|
||||
0x0D,0x8D,0x32,0x3C,0x1E,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01
|
||||
};
|
||||
|
||||
struct gt801_ts_data {
|
||||
|
|
@ -109,7 +112,6 @@ static int gt801_read_regs(struct i2c_client *client, u8 reg, u8 buf[], unsigned
|
|||
static int gt801_write_regs(struct i2c_client *client, u8 reg, u8 const buf[], unsigned short len)
|
||||
{
|
||||
int ret;
|
||||
int i = len;
|
||||
ret = i2c_master_reg8_send(client,reg, buf, len, 200*1000);
|
||||
if (ret < 0) {
|
||||
printk("gt801_ts_work_func:i2c_transfer fail =%d\n",ret);
|
||||
|
|
@ -207,13 +209,17 @@ static void gt801_ts_work_func(struct work_struct *work)
|
|||
else{
|
||||
x = ((( ((unsigned short)buf[i+ptxh] )<< 8) ) | buf[i+ptxl]);
|
||||
y = (((((unsigned short)buf[i+ptyh] )<< 8) )| buf[i+ptyl]);
|
||||
/* adjust the x and y to proper value added by hhb@rock-chips.com*/
|
||||
x = 480-x;
|
||||
y = 800-y;
|
||||
if (ts->swap_xy)
|
||||
if(y < 800){
|
||||
y = 800-y;
|
||||
}
|
||||
|
||||
if (ts->swap_xy){
|
||||
swap(x, y);
|
||||
}
|
||||
|
||||
if (verify_coord(ts,&x,&y))
|
||||
;//goto out;
|
||||
if (verify_coord(ts,&x,&y));//goto out;
|
||||
|
||||
gt801printk("input_report_abs--%d-%d-(%d/%d)\n", i,touch_state_index, x, y);
|
||||
input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 1); //Finger Size
|
||||
|
|
@ -230,12 +236,14 @@ static void gt801_ts_work_func(struct work_struct *work)
|
|||
|
||||
#endif
|
||||
|
||||
if(syn_flag)
|
||||
if(syn_flag){
|
||||
input_sync(ts->input_dev);
|
||||
}
|
||||
|
||||
out:
|
||||
if (ts->use_irq)
|
||||
enable_irq(ts->client->irq);
|
||||
|
||||
if (ts->use_irq) {
|
||||
enable_irq(ts->client->irq);
|
||||
}
|
||||
return;
|
||||
}
|
||||
static enum hrtimer_restart gt801_ts_timer_func(struct hrtimer *timer)
|
||||
|
|
@ -299,6 +307,7 @@ static int __devinit setup_resetPin(struct i2c_client *client, struct gt801_ts_d
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __devinit setup_pendown(struct i2c_client *client, struct gt801_ts_data *ts)
|
||||
{
|
||||
int err;
|
||||
|
|
@ -342,6 +351,7 @@ static int __devinit setup_pendown(struct i2c_client *client, struct gt801_ts_da
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gt801_chip_Init(struct i2c_client *client)
|
||||
{
|
||||
u8 i,j;
|
||||
|
|
@ -384,6 +394,7 @@ static int gt801_chip_Init(struct i2c_client *client)
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int gt801_ts_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||
{
|
||||
struct gt801_ts_data *ts;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@
|
|||
* author: hhb@rock-chips.com
|
||||
* creat date: 2011-03-22
|
||||
* route:drivers/video/display/screen/lcd_ls035y8dx02a.c - driver for rk29 phone sdk
|
||||
* station:haven't been tested in any hardware platform
|
||||
* declaration: This program driver have been tested in rk29_phonesdk hardware platform at 2011.03.31.
|
||||
* about migration: you need just 3 interface functions,such as lcd_init(void),lcd_standby(u8 enable),
|
||||
* set_lcd_info(struct rk29fb_screen *screen, struct rk29lcd_info *lcd_info )
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
|
|
@ -28,20 +30,20 @@
|
|||
#define OUT_TYPE SCREEN_RGB
|
||||
#define OUT_FACE OUT_P888
|
||||
#define OUT_CLK (26*1000000) //***27 uint Hz
|
||||
#define LCDC_ACLK 150000000 //29 lcdc axi DMA Ƶ<><C6B5> //rk29
|
||||
#define LCDC_ACLK 150000000 //29 lcdc axi DMA Ƶ<><C6B5>
|
||||
|
||||
/* Timing */
|
||||
#define H_PW 8 //16
|
||||
#define H_BP 6//24
|
||||
#define H_VD 480//320 //***800
|
||||
#define H_FP 60//16
|
||||
#define H_PW 16//8 //16
|
||||
#define H_BP 24//6//24
|
||||
#define H_VD 480//320
|
||||
#define H_FP 16//60//16
|
||||
|
||||
#define V_PW 12//2
|
||||
#define V_BP 4// 2
|
||||
#define V_VD 800//480 //***480
|
||||
#define V_FP 40//4
|
||||
#define V_VD 800//480
|
||||
#define V_FP 50//4
|
||||
|
||||
#define LCD_WIDTH 800 //need modify //rk29
|
||||
#define LCD_WIDTH 800 //need modify
|
||||
#define LCD_HEIGHT 480
|
||||
|
||||
/* Other */
|
||||
|
|
@ -51,16 +53,12 @@
|
|||
static struct rk29lcd_info *gLcd_info = NULL;
|
||||
int lcd_init(void);
|
||||
int lcd_standby(u8 enable);
|
||||
/*
|
||||
#define RXD_PORT RK2818_PIN_PB7
|
||||
#define TXD_PORT RK2818_PIN_PB6 //gLcd_info->txd_pin
|
||||
#define CLK_PORT RK2818_PIN_PB5 //gLcd_info->clk_pin
|
||||
#define CS_PORT RK2818_PIN_PB4 // gLcd_info->cs_pin
|
||||
*/
|
||||
|
||||
#define RXD_PORT RK29_PIN2_PC7
|
||||
#define TXD_PORT gLcd_info->txd_pin
|
||||
#define CLK_PORT gLcd_info->clk_pin
|
||||
#define CS_PORT gLcd_info->cs_pin
|
||||
#define RESET_PORT RK29_PIN6_PC6
|
||||
|
||||
#define CS_OUT() gpio_direction_output(CS_PORT, 1)
|
||||
#define CS_SET() gpio_set_value(CS_PORT, GPIO_HIGH)
|
||||
|
|
@ -167,8 +165,6 @@ void spi_screenreg_set(u32 Addr, u32 Data0, u32 Data1)
|
|||
TXD_SET();
|
||||
else
|
||||
TXD_CLR();
|
||||
|
||||
// \u6a21\u62dfCLK
|
||||
CLK_SET();
|
||||
DRVDelayUs(2);
|
||||
CLK_CLR();
|
||||
|
|
@ -180,8 +176,9 @@ void spi_screenreg_set(u32 Addr, u32 Data0, u32 Data1)
|
|||
CLK_CLR();
|
||||
DRVDelayUs(10);
|
||||
|
||||
if(0xffff == Data0)
|
||||
return;
|
||||
if(0xffff == Data0){
|
||||
return;
|
||||
}
|
||||
|
||||
CS_CLR();
|
||||
|
||||
|
|
@ -194,8 +191,6 @@ void spi_screenreg_set(u32 Addr, u32 Data0, u32 Data1)
|
|||
TXD_SET();
|
||||
else
|
||||
TXD_CLR();
|
||||
|
||||
// \u6a21\u62dfCLK
|
||||
CLK_SET();
|
||||
DRVDelayUs(2);
|
||||
CLK_CLR();
|
||||
|
|
@ -221,8 +216,6 @@ void spi_screenreg_set(u32 Addr, u32 Data0, u32 Data1)
|
|||
TXD_SET();
|
||||
else
|
||||
TXD_CLR();
|
||||
|
||||
// \u6a21\u62dfCLK
|
||||
CLK_SET();
|
||||
DRVDelayUs(2);
|
||||
CLK_CLR();
|
||||
|
|
@ -244,11 +237,11 @@ void set_lcd_info(struct rk29fb_screen *screen, struct rk29lcd_info *lcd_info )
|
|||
/* Screen size */
|
||||
screen->x_res = H_VD;
|
||||
screen->y_res = V_VD;
|
||||
screen->width = LCD_WIDTH; //rk29
|
||||
screen->height = LCD_HEIGHT; //rk29
|
||||
screen->width = LCD_WIDTH;
|
||||
screen->height = LCD_HEIGHT;
|
||||
|
||||
/* Timing */
|
||||
screen->lcdc_aclk = LCDC_ACLK; //rk29
|
||||
screen->lcdc_aclk = LCDC_ACLK;
|
||||
screen->pixclock = OUT_CLK;
|
||||
screen->left_margin = H_BP; /*>2*/
|
||||
screen->right_margin = H_FP; /*>2*/
|
||||
|
|
@ -281,27 +274,26 @@ int lcd_init(void)
|
|||
{
|
||||
volatile u32 data;
|
||||
if(gLcd_info){
|
||||
printk("lcd init11111111111111111111111111...\n");
|
||||
gLcd_info->io_init();
|
||||
}
|
||||
|
||||
/* reset lcd to start init lcd */
|
||||
gpio_request(RK29_PIN6_PC6, NULL);
|
||||
gpio_direction_output(RK29_PIN6_PC6, 0);
|
||||
/* reset lcd to start init lcd by software if there is no hardware reset circuit for the lcd */
|
||||
#ifdef RESET_PORT
|
||||
gpio_request(RESET_PORT, NULL);
|
||||
gpio_direction_output(RESET_PORT, 0);
|
||||
mdelay(2);
|
||||
gpio_set_value(RK29_PIN6_PC6, 1);
|
||||
gpio_set_value(RESET_PORT, 1);
|
||||
mdelay(10);
|
||||
gpio_free(RK29_PIN6_PC6);
|
||||
gpio_free(RESET_PORT);
|
||||
#endif
|
||||
|
||||
|
||||
printk("lcd init22222222222222222222222222...\n");
|
||||
printk("lcd init...\n");
|
||||
spi_screenreg_set(0x29, 0xffff, 0xffff);
|
||||
spi_screenreg_set(0x11, 0xffff, 0xffff);
|
||||
|
||||
spi_screenreg_set(0x29, 0xffff, 0xffff); //display on
|
||||
spi_screenreg_set(0x11, 0xffff, 0xffff); //sleep out
|
||||
mdelay(150);
|
||||
spi_screenreg_set(0x36, 0x0000, 0xffff);
|
||||
//while(1)
|
||||
spi_screenreg_set(0x36, 0x0000, 0xffff); //set address mode
|
||||
|
||||
while(0) //this code is not used here
|
||||
{
|
||||
data = spi_screenreg_get(0x0a);
|
||||
printk("------------liuylcd init reg 0x0a=0x%x \n", spi_screenreg_get(0x0a));
|
||||
|
|
@ -314,11 +306,12 @@ int lcd_init(void)
|
|||
data = spi_screenreg_get(0x0f);
|
||||
printk("------------liuylcd init reg 0x0f=0x%x \n", spi_screenreg_get(0x0f));
|
||||
}
|
||||
spi_screenreg_set(0x3a, 0x0070, 0xffff);
|
||||
spi_screenreg_set(0xb0, 0x0000, 0xffff);
|
||||
spi_screenreg_set(0xb8, 0x0001, 0xffff);
|
||||
spi_screenreg_set(0xb9, 0x0001, 0x00ff);
|
||||
spi_screenreg_set(0xb0, 0x0003, 0xffff);
|
||||
|
||||
spi_screenreg_set(0x3a, 0x0070, 0xffff); //set pixel format
|
||||
spi_screenreg_set(0xb0, 0x0000, 0xffff); //enable command acess
|
||||
spi_screenreg_set(0xb8, 0x0001, 0xffff); //BLC setting
|
||||
spi_screenreg_set(0xb9, 0x0001, 0x00ff); //LED PWM
|
||||
spi_screenreg_set(0xb0, 0x0003, 0xffff); //disable command acess
|
||||
|
||||
if(gLcd_info)
|
||||
gLcd_info->io_deinit();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue