主机:VM - RedHat 9.0
开发板:FL2440,linux-2.6.12
arm-linux-gcc:3.4.1
代码中的第90行,若不支持拖拽,则可以获取到笔触坐标,但是LCD上的图标没有响应,不知什么原因。
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
// YM_SEN输出驱动器使能,XP_SEN,YP_SEN输出驱动器禁止
// S3C2410_ADCTSC_XY_PST(3) -- 手动测量X、Y方向,等待中断模式
// x=0, 将ADCTSC[8]设置为0,即检测笔尖落下中断信号
#define WAIT4INT(x) (((x)<<8) |
S3C2410_ADCTSC_YM_SEN | S3C2410_ADCTSC_YP_SEN | S3C2410_ADCTSC_XP_SEN |
S3C2410_ADCTSC_XY_PST(3))
/* ADCTSC Register Bits */
#define S3C2410_ADCTSC_YM_SEN (1<<7)
#define S3C2410_ADCTSC_YP_SEN (1<<6)
#define S3C2410_ADCTSC_XM_SEN (1<<5)
#define S3C2410_ADCTSC_XP_SEN (1<<4)
#define S3C2410_ADCTSC_PULL_UP_DISABLE (1<<3)
#define S3C2410_ADCTSC_AUTO_PST (1<<2)
#define S3C2410_ADCTSC_XY_PST(x) (((x)&0x3)<<0)
/* ADCCON Register Bits */
#define S3C2410_ADCCON_ECFLG (1<<15)
#define S3C2410_ADCCON_PRSCEN (1<<14)
#define S3C2410_ADCCON_PRSCVL(x) (((x)&0xFF)<<6)
#define S3C2410_ADCCON_PRSCVLMASK (0xFF<<6)
#define S3C2410_ADCCON_SELMUX(x) (((x)&0x7)<<3)
#define S3C2410_ADCCON_MUXMASK (0x7<<3)
#define S3C2410_ADCCON_STDBM (1<<2)
#define S3C2410_ADCCON_READ_START (1<<1)
#define S3C2410_ADCCON_ENABLE_START (1<<0)
#define S3C2410_ADCCON_STARTMASK (0x3<<0)
#ifdef S3C2410_ADCCON
#undef S3C2410_ADCCON
#endif
#ifdef S3C2410_ADCTSC
#undef S3C2410_ADCTSC
#endif
#ifdef S3C2410_ADCDLY
#undef S3C2410_ADCDLY
#endif
#ifdef S3C2410_ADCDAT0
#undef S3C2410_ADCDAT0
#endif
#ifdef S3C2410_ADCDAT1
#undef S3C2410_ADCDAT1
#endif
#ifdef S3C2410_PA_ADC
#undef S3C2410_PA_ADC
#endif
#define S3C2410_PA_ADC (0x58000000)
static void __iomem *base_addr;
#define S3C2410_ADCCON (base_addr+(0x00))
#define S3C2410_ADCTSC (base_addr+(0x04))
#define S3C2410_ADCDLY (base_addr+(0x08))
#define S3C2410_ADCDAT0 (base_addr+(0x0c))
#define S3C2410_ADCDAT1 (base_addr+(0x10))
#ifdef CONFIG_PM
#include
#endif
// 支持拖拽
// 若不支持拖拽,则可以获取到笔触坐标,但是LCD上的图标没有响应。
// 可以看到read接口被调用到,不知为何图标没有响应。
#define HOOK_FOR_DRAG
//#define DEBUG
#ifdef DEBUG
#define DPRINTK printk
#else
#define DPRINTK
#endif
typedef struct {
unsigned short pressure;
unsigned short x;
unsigned short y;
unsigned short pad;
} TS_RET;
typedef struct {
int xscale;
int xtrans;
int yscale;
int ytrans;
int xyswap;
} TS_CAL;
#define PEN_UP 0
#define PEN_DOWN 1
#define PEN_FLEETING 2
#define MAX_TS_BUF 16 /* how many do we want to buffer */
#undef USE_ASYNC
#define DEVICE_NAME "s3c2410-ts"
#define TSRAW_MINOR 1
typedef struct {
unsigned int penStatus; /* PEN_UP, PEN_DOWN, PEN_SAMPLE */
TS_RET buf[MAX_TS_BUF]; /* protect against overrun */
unsigned int head, tail; /* head and tail for queued events */
wait_queue_head_t wq;
spinlock_t lock;
#ifdef USE_ASYNC
struct fasync_struct *aq;
#endif
#ifdef CONFIG_PM
struct pm_dev *pm_dev;
#endif
} TS_DEV;
static TS_DEV tsdev;
#define BUF_HEAD (tsdev.buf[tsdev.head])
#define BUF_TAIL (tsdev.buf[tsdev.tail])
#define INCBUF(x,mod) ((++(x)) & ((mod) - 1))
static int tsMajor = 0;
static void (*tsEvent)(void);
#ifdef HOOK_FOR_DRAG
#define TS_TIMER_DELAY (HZ/100) /* 10 ms */
static struct timer_list ts_timer;
#endif
// pick-up regs val from 2.4.18&2440
// YM_SEN输出驱动器使能,XP上拉使能,正常ADC转换,检测笔尖落下中断信号,等待中断模式
#define wait_down_int() __raw_writel(0x000000d3,S3C2410_ADCTSC)
// YM_SEN输出驱动器使能,XP上拉使能,正常ADC转换,检测笔尖抬起中断信号,等待中断模式
#define wait_up_int() __raw_writel(0x000001d3, S3C2410_ADCTSC)
// XM_SEN、XP_SEN输出驱动器使能,XP上拉禁止,正常ADC转换,X方向测量模式
#define mode_x_axis() __raw_writel(0x00000069, S3C2410_ADCTSC)
// 相当于__raw_writel(0x00000068, S3C2410_ADCTSC),即
// XM_SEN、YP_SEN使能,XP上拉禁止,正常ADC转换,无操作模式
#define mode_x_axis_n() __raw_writel(XP_EXTVLT | XM_GND | YP_AIN | YM_HIZ |
XP_PULL_UP_DIS | XP_PST(NOP_MODE), S3C2410_ADCTSC)
// YM_SEN、YP_SEN使能,XP上拉禁止,正常ADC转换,Y方向测量模式
#define mode_y_axis() __raw_writel(0x0000009a, S3C2410_ADCTSC)
// __raw_writel(0x00007ffa, S3C2410_ADCCON); -- A/D转换器预分频器使能,预分频值0xff,模拟输入通道SEL_MUX为XP,正常工作模式,使能读启动操作
// __raw_readl(S3C2410_ADCDAT0); -- 读取ADCDAT)的值
-
#define start_adc_x() do {__raw_writel(0x00007ffa, S3C2410_ADCCON);