亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? skyeye_ts_drv.c

?? 一個模擬可種嵌入開發環境的模擬軟件.能模擬ARM系列等.
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* 
 *
 * linux/drivers/char/skyeye_ts.c - Touch screen driver for touch screen simulated on skyeye.
*/

#include <linux/kernel.h>     /* We're doing kernel work */
#include <linux/module.h>     /* Specifically, a module */
#include <linux/interrupt.h>  /* We want interrupts */

#include <linux/miscdevice.h> /* for misc_register() and misc_deregister() */

#include <linux/fs.h>         /* for struct 'file_operations' */

#include <linux/timer.h>     /* for timeout interrupts */
#include <linux/param.h>     /* for HZ. HZ = 100 and the timer step is 1/100 */
#include <linux/sched.h>     /* for jiffies definition. jiffies is incremented
                              * once for each clock tick; thus it's incremented
			      * HZ times per secondes.*/
#include <linux/mm.h>        /* for verify_area */
#include <linux/slab.h>    /* for kmalloc */
#include <linux/init.h>

#include <asm/irq.h>         /* For IRQ_MACHSPEC */

#include <linux/version.h>

/*----------------------------------------------------------------------------*/



//#include "mc68328digi.h" //struct ts_pen_info was defined in this head file
#include "skyeye_ts_drv.h"
#include "ep7312_sys.h"
//#include "clps7110.h"

#define IRQ_FLG_STD   (0x8000)        /* internally used              */

/*----------------------------------------------------------------------------*/

/* Available info from pen position and status */

//struct ts_pen_info {
  //int x,y;    /* pen position                                      */
  //int dx,dy;  /* delta move from last position                     */
  //int event;  /* event from pen (DOWN,UP,CLICK,MOVE)               */
  //int state;  /* state of pen (DOWN,UP,ERROR)                      */
  //int ev_no;  /* no of the event                                   */
  //unsigned long ev_time;  /* time of the event (ms) since ts_open  */
//};


static const char* __file__ = __FILE__;

/*----------------------------------------------------------------------------*//*
 * Kernel compatibility.
 * Kernel > 2.2.3, include/linux/version.h contain a macro for KERNEL_VERSION
 */
#include <linux/version.h>
#ifndef KERNEL_VERSION
#define KERNEL_VERSION(a,b,c)  (((a) << 16) + ((b) << 8) + (c))
#endif

/*
 * Conditional compilation. LINUX_VERSION_CODE is the code of this version
 * (as per KERNEL_VERSION)
 */
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0))
#include <asm/uaccess.h>    /* for put_user     */
#include <linux/poll.h>     /* for polling fnct */
#endif

/* 
 * Length of the data structure
 */
#define DATA_LENGTH       sizeof(struct ts_pen_info)

/*
 * Size of the buffer for the event queue
 */
#define TS_BUF_SIZE        32*DATA_LENGTH

/*
 * Minor number for the touch screen device. Major is 10 because of the misc 
 * type of the driver.
 */
//#define MC68328DIGI_MINOR    9
#define SKYEYE_TS_MINOR    9
#define SKYEYE_TS_MAJOR    10



/*
 * ADS7843 fields (BURR-BROWN Touch Screen Controller).
 */
#define ADS7843_START_BIT (1<<7)
#define ADS7843_A2        (1<<6)
#define ADS7843_A1        (1<<5)
#define ADS7843_A0        (1<<4)
#define ADS7843_MODE      (1<<3)  /* HIGH = 8, LOW = 12 bits conversion */
#define ADS7843_SER_DFR   (1<<2)  /* LOW = differential mode            */
#define ADS7843_PD1       (1<<1)  /* PD1,PD0 = 11  PENIRQ disable       */
#define ADS7843_PD0       (1<<0)  /* PD1,PD0 = 00  PENIRQ enable        */

/*
 * Conversion status.
 */
#define CONV_ERROR      -1   /* error during conversion flow        */
#define CONV_END         0   /* conversion ended (= pen is up)      */
#define CONV_LOOP        1   /* conversion continue (= pen is down) */

/*
 * Useful masks.
 */
#define PEN_IRQ_NUM	6
//#define PEN_IRQ_NUM	IRQ6_IRQ_NUM

//#define PENIRQ_DATA 	PDDATA
//#define PENIRQ_PUEN	PDPUEN
//#define PENIRQ_DIR	PDDIR
//#define PENIRQ_SEL	PDSEL
//#define ICR_PENPOL	ICR_POL6
//#define IMR_MPEN	IMR_MIRQ6

/*
 * Touch screen driver states.
 */
#define TS_DRV_ERROR       -1
#define TS_DRV_IDLE         0
#define TS_DRV_WAIT         1
#define TS_DRV_ASKX         2
#define TS_DRV_ASKY         3
#define TS_DRV_READX        4
#define TS_DRV_READY        5

/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
//#define ENABLE_PEN_IRQ    { INTSR &= ~EINT2; }
//#define DISABLE_PEN_IRQ   { INTSR |= EINT2; }

#define ENABLE_PEN_IRQ    { INTSR |= EINT2; }
#define DISABLE_PEN_IRQ   { INTSR &= ~EINT2; }

/*----------------------------------------------------------------------------*/


/* predefinitions ------------------------------------------------------------*/

static void handle_pen_irq(int irq, void *dev_id, struct pt_regs *regs);

/*----------------------------------------------------------------------------*/
/* structure -----------------------------------------------------------------*/

struct ts_pen_position { int x,y; };

struct ts_queue {
  unsigned long head;
  unsigned long tail;
  wait_queue_head_t proc_list;
  struct fasync_struct *fasync;
  unsigned char buf[TS_BUF_SIZE];
};

/*----------------------------------------------------------------------------*/
/* Variables -----------------------------------------------------------------*/

/*
 * driver state variable.
 */
static int ts_drv_state;

/*
 * first tick initiated at ts_open.
 */
static struct timeval   first_tick;

/*
 * pen state.
 */
static int new_pen_state;

/*
 * event counter.
 */
static int ev_counter;

/*
 * counter to differentiate a click from a move.
 */
static int state_counter;

static struct timer_list         ts_wake_time;

/*
 * drv parameters.
 */
static struct ts_drv_params      current_params;
static int                       sample_ticks;
/*
 * pen info variables.
 */
static struct ts_pen_info        ts_pen;
static struct ts_pen_info        ts_pen_prev;
//static struct ts_pen_position    current_pos;
static struct ts_pen_info    current_pos;
static struct ts_pen_info 	*buff;

/*
 * driver management.
 */
static struct ts_queue *queue;
static int    device_open = 0;   /* number of open device to prevent concurrent
                                  * access to the same device
				  */


/*----------------------------------------------------------------------------*/
/* Init & release functions --------------------------------------------------*/

static void init_ts_state(void) {
  //DISABLE_SPIM_IRQ;      /* Disable SPIM interrupt */

  ts_drv_state = TS_DRV_IDLE;
  state_counter = 0;

  ENABLE_PEN_IRQ;        /* Enable interrupt IRQ5  */
}

static void init_ts_pen_values(void) {
  
}


/*
 * Set default values for the params of the driver.
 */
static void init_ts_settings(void) {
  
}

static void init_ts_hardware(void) {
}

static void init_ts_drv(void) {
  
}

static void release_ts_drv(void) {
 
}

/*----------------------------------------------------------------------------*/
/* xcopilot compatibility hacks ----------------------------------------------*/
#ifdef CONFIG_XCOPILOT_BUGS

/* xcopilot has the following bugs:
 *
 * - Disabling the penirq has no effect; we keep on getting irqs even when
 *   penirq is disabled; this is not too annoying: we just trash pen irq events
 *   that come when disabled.
 *
 * - SPIM interrupt is not simulated; this is not too annoying: we just read
 *   SPI data immediately and bypass a couple of states related to SPI irq.
 *
 * - We do not get mouse drag events; this is a known xcopilot bug.
 *   This is annoying: we miss all moves ! You should patch and recompile
 *   your xcopilot.
 *
 *   This has been reported as Debian bug #64367, and there is a patch there:
 *     http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=64367&repeatmerged=yes
 *   which is:
 *   +-----------------------------------------------------------------------+
 *   | --- display.c   Tue Aug 25 14:56:02 1998
 *   | +++ display2.c  Fri May 19 16:07:52 2000
 *   | @@ -439,7 +439,7 @@
 *   | static void HandleDigitizer(Widget w, XtPointer client_data, XEvent\
 *   | *event, Boolean *continue_to_dispatch)
 *   | {
 *   | -  Time start;
 *   | +  static Time start;
 *   | 
 *   | *continue_to_dispatch = True;
 *   +-----------------------------------------------------------------------+
 *   In short, add 'static' to the declaration of 'start' in HandleDigitizer()
 *   in display.c
 *
 *   With this patch, all works perfectly !
 *
 * - The pen state can be read only in IPR, not in port D; again, we're doing
 *   the workaround.
 *
 * With all these workarounds in this file, and with the patch on xcopilot,
 * things go perfectly smoothly.
 *
 */

/*
 * Ugly stuff to read the mouse position on xcopilot
 *
 * We get the position of the last mouse up/down only, we get no moves !!! :-(
 */
 
static void xcopilot_read_now(void) {
    PFDATA &= ~0xf; PFDATA |= 6;
    SPIMCONT |= SPIMCONT_XCH | SPIMCONT_IRQEN;
    current_pos.x = SPIMDATA;
    rescale_xpos(&current_pos.x);

    PFDATA &= ~0xf; PFDATA |= 9;
    SPIMCONT |= SPIMCONT_XCH | SPIMCONT_IRQEN;
    current_pos.y = SPIMDATA;
    rescale_ypos(&current_pos.y);

    swap_xy(&current_pos.x, &current_pos.y);
}
#endif


//****** by ywc 2004-04-09 ***************
static void skyeye_read_now(void){
	long * TS_Buf_start_addr;
 	
	TS_Buf_start_addr=0xff00b000;
	current_pos.x=TS_Buf_start_addr[0];
	current_pos.y=TS_Buf_start_addr[1];
	current_pos.dx=0;
	current_pos.dy=0;
	current_pos.event=TS_Buf_start_addr[4];
	current_pos.state=0;
	current_pos.ev_no=TS_Buf_start_addr[6];//1--new data come,0--no new data--set by ts_read
	current_pos.ev_time=0;
//	printk("&TS_Buf_start_addr[2]==%p\n",&TS_Buf_start_addr[2]);
//        printk("&TS_Buf_start_addr[3]==%p\n",&TS_Buf_start_addr[3]);
//	printk("ts driver: skyeye_read_now:"); 
//	printk("current_pos.x=%d,current_pos.y=%d\n\n",current_pos.x,current_pos.y);
}
//****** by ywc 2004-04-09 ***************


/*
 * Get one char from the queue buffer.
 * AND the head with 'TS_BUF_SIZE -1' to have the loopback
 */
static unsigned char get_char_from_queue(void) {
  unsigned int result;

  result = queue->buf[queue->tail];
  queue->tail = (queue->tail + 1) & (TS_BUF_SIZE - 1);
  return result;
}

/*
 * Write one event in the queue buffer.
 * Test if there is place for an event = the head cannot be just one event
 * length after the queue.
 */
static void put_in_queue(char *in, int len) {
  unsigned long head    = queue->head;
  unsigned long maxhead = (queue->tail - len) & (TS_BUF_SIZE - 1);
  int i;
  
  if(head != maxhead)              /* There is place for the event */
    for(i=0;i<len;i++) {
      queue->buf[head] = in[i];
      head++;
      head &= (TS_BUF_SIZE - 1);
    }
  //else printk("%0: Queue is full !!!!\n", __file__);
  queue->head = head;
}

/*
 * Test if queue is empty.
 */
static inline int queue_empty(void) {
  return queue->head == queue->tail;
}

/*
 * Test if the delta move of the pen is enough big to say that this is a really
 * move and not due to noise.
 */
static int is_moving(void) {
  int threshold;
  int dx, dy;
  
  threshold=((ts_pen_prev.event & EV_PEN_MOVE) > 0 ?
             current_params.follow_thrs : current_params.mv_thrs);
  dx = current_pos.x-ts_pen_prev.x;
  dy = current_pos.y-ts_pen_prev.y;
  if(dx < 0) dx = -dx; /* abs() */
  if(dy < 0) dy = -dy;
  return (dx > threshold ? 1 :
	  (dy > threshold ? 1 : 0));
}

static void copy_info(void) {
  ts_pen_prev.x = ts_pen.x;
  ts_pen_prev.y = ts_pen.y;
  ts_pen_prev.dx = ts_pen.dx;
  ts_pen_prev.dy = ts_pen.dy;
  ts_pen_prev.event = ts_pen.event;
  ts_pen_prev.state = ts_pen.state;
  ts_pen_prev.ev_no = ts_pen.ev_no;
  ts_pen_prev.ev_time = ts_pen.ev_time;
}

static void cause_event(int conv) {

  switch(conv) {

  case CONV_ERROR: /* error occure during conversion */
    ts_pen.state &= 0;            /* clear */
    ts_pen.state |= ST_PEN_UP;    /* recover a stable state for the drv.      */
    ts_pen.state |= ST_PEN_ERROR; /* tell that the state is due to an error   */
    ts_pen.event = EV_PEN_UP;     /* event = pen go to up */
    ts_pen.x = ts_pen_prev.x;     /* get previous coord as current to by-pass */
    ts_pen.y = ts_pen_prev.y;     /* possible errors                          */
    ts_pen.dx = 0;
    ts_pen.dy = 0;
    ts_pen.ev_no = ev_counter++;    /* get no of event   */
    //ts_pen.ev_time = set_ev_time(); /* get time of event */
    copy_info();                    /* remember info */
    if(current_params.event_queue_on)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区成人| 亚洲三级电影网站| 欧美日韩国产成人在线免费| caoporm超碰国产精品| 国产最新精品精品你懂的| 久久黄色级2电影| 韩日av一区二区| 国产乱色国产精品免费视频| 国产一区二区免费看| 国产福利91精品一区| 丁香五精品蜜臀久久久久99网站| 成人激情开心网| 91麻豆精品在线观看| 欧美性三三影院| 91麻豆精品91久久久久久清纯 | 亚洲同性同志一二三专区| 中文字幕一区二区视频| 一区二区三区在线观看网站| 天天爽夜夜爽夜夜爽精品视频| 麻豆精品一区二区综合av| 国产一区二区三区视频在线播放| 丁香激情综合国产| 在线看国产日韩| 欧美tickle裸体挠脚心vk| 中文字幕精品综合| 午夜精彩视频在线观看不卡| 国产激情视频一区二区在线观看 | av在线不卡观看免费观看| 欧美无人高清视频在线观看| 日韩一区二区在线观看视频播放| 久久亚洲免费视频| 亚洲伊人伊色伊影伊综合网| 久久国产精品一区二区| 一本一道波多野结衣一区二区 | 国产麻豆精品在线| 91成人在线观看喷潮| 欧美精品一区二区三区四区| 亚洲色图制服诱惑| 国产在线精品一区二区| 91激情在线视频| 久久久99精品久久| 婷婷久久综合九色国产成人| 北条麻妃国产九九精品视频| 日韩欧美色综合| 一区二区三区丝袜| 丁香另类激情小说| 久久综合成人精品亚洲另类欧美| 亚洲精品视频在线观看免费| 国产久卡久卡久卡久卡视频精品| 欧美日韩aaa| 亚洲理论在线观看| 粉嫩av一区二区三区在线播放| 6080日韩午夜伦伦午夜伦| 亚洲婷婷综合色高清在线| 另类小说一区二区三区| 欧美男生操女生| 亚洲综合一区二区三区| 91在线精品一区二区三区| 久久精品欧美日韩精品| 久久99久久99精品免视看婷婷| 欧美三级视频在线| 亚洲一级在线观看| 色噜噜狠狠成人网p站| 中文字幕一区二区在线播放| 成人午夜私人影院| 国产日本一区二区| 国产成人免费在线视频| 国产日韩精品视频一区| 韩国精品在线观看| 久久婷婷久久一区二区三区| 久草在线在线精品观看| 日韩视频国产视频| 理论电影国产精品| 日韩亚洲国产中文字幕欧美| 免费欧美高清视频| 日韩欧美的一区二区| 久久97超碰国产精品超碰| 91精品国产乱| 久久成人久久鬼色| 久久久高清一区二区三区| 国产精品小仙女| 国产精品色呦呦| 92精品国产成人观看免费 | 精品国产伦一区二区三区免费| 日韩国产精品久久| 精品久久久久久综合日本欧美| 久久国产剧场电影| 国产午夜精品久久久久久免费视| 成人免费观看视频| 亚洲综合一二区| 日韩丝袜情趣美女图片| 毛片av一区二区| 中文字幕第一区第二区| 色综合久久久久综合99| 日本不卡一区二区| 久久久久久9999| 91老司机福利 在线| 石原莉奈在线亚洲三区| 欧美成人video| 91香蕉视频在线| 日韩电影免费在线| 中文字幕中文字幕一区| 欧美日韩在线精品一区二区三区激情 | 久久aⅴ国产欧美74aaa| 久久理论电影网| 日本高清不卡视频| 激情深爱一区二区| 一区二区三区在线免费观看| 日韩精品一区二区三区swag| 99热这里都是精品| 秋霞午夜鲁丝一区二区老狼| 日本一区二区不卡视频| 欧美乱妇20p| 成人免费观看av| 久久超碰97中文字幕| 亚洲精品成a人| 国产欧美日韩激情| 日韩一区国产二区欧美三区| 91麻豆精东视频| 韩国成人在线视频| 午夜精品久久久久久久99水蜜桃| 国产日韩欧美制服另类| 欧美剧在线免费观看网站| 不卡一二三区首页| 国产精品资源在线| 三级在线观看一区二区| 亚洲精品成人在线| 国产精品免费人成网站| www成人在线观看| 在线成人免费观看| 欧美色网一区二区| 99久久99久久综合| 国产a视频精品免费观看| 另类成人小视频在线| 亚洲va国产va欧美va观看| 亚洲日本在线看| 国产精品成人免费精品自在线观看| 欧美大胆人体bbbb| 日韩欧美视频一区| 日韩欧美国产1| 91麻豆精品国产自产在线观看一区 | 国产精品人人做人人爽人人添| 精品福利视频一区二区三区| 欧美天堂一区二区三区| 欧美在线一区二区三区| 日本韩国视频一区二区| 一本一道综合狠狠老| 日本高清视频一区二区| 日本精品一区二区三区高清| 91色porny| 日本乱人伦aⅴ精品| 在线视频你懂得一区二区三区| 色成年激情久久综合| 欧美伊人久久久久久久久影院| 欧美伊人久久大香线蕉综合69| 欧日韩精品视频| 欧美精品色一区二区三区| 91麻豆精品国产自产在线| 日韩一二三区视频| 久久精品夜色噜噜亚洲a∨| 久久精品人人做人人综合 | 亚洲国产精品ⅴa在线观看| 国产亲近乱来精品视频| 国产精品亲子伦对白| 国产精品国模大尺度视频| 亚洲女同一区二区| 天天影视涩香欲综合网| 麻豆91在线播放| 国产成人av自拍| 92精品国产成人观看免费| 欧美三级视频在线播放| 精品国产一区二区三区不卡| 国产校园另类小说区| 一区二区三区在线免费观看 | 精品成人在线观看| 国产精品欧美一区喷水| 亚洲1区2区3区视频| 激情小说亚洲一区| 色综合久久综合中文综合网| 欧美肥大bbwbbw高潮| 国产婷婷色一区二区三区在线| 国产欧美精品在线观看| 一区二区久久久久久| 无码av中文一区二区三区桃花岛| 国产在线乱码一区二区三区| a美女胸又www黄视频久久| 538prom精品视频线放| 国产人成一区二区三区影院| 亚洲精品免费在线观看| 精品一区二区三区不卡| 91欧美一区二区| 精品久久久久久最新网址| 亚洲乱码中文字幕| 国产成人精品网址| 这里只有精品免费| 一区二区三区产品免费精品久久75| 国产一区二区三区最好精华液| 色噜噜偷拍精品综合在线| 久久亚洲私人国产精品va媚药| 亚洲bdsm女犯bdsm网站|