From f423e3d4e68dbc81e3b03d03bdc8a911e1107507 Mon Sep 17 00:00:00 2001 From: henry Date: Fri, 27 Nov 2009 09:47:25 +0800 Subject: [PATCH] Add keypad debug info. --- keypad.c | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/keypad.c b/keypad.c index ef21dfc..2eab832 100644 --- a/keypad.c +++ b/keypad.c @@ -85,7 +85,7 @@ #define GET_KEY_DELAY_US (2) // Interval for get key timer -#define GET_KEY_INTERVAL_JIFFIES (HZ/50+1) +#define NEXT_GET_KEY_JIFFIES (jiffies + HZ/50 + 1) //=========================== Device ========================================= @@ -94,7 +94,7 @@ //=========================== Debug ========================================== -#define KEY_DEBUGF(arg...) printk (arg) +#define KEYPAD_DEBUGF(arg...) printk (arg) /******************************************************************************* @@ -147,23 +147,23 @@ static char s_acKeyTable [4][4] = { ******************************************************************************/ static void InitGPIO(void) { - s3c_gpio_cfgpin(KEYSCAN0, KEYSCAN0_OUTP); - s3c_gpio_cfgpin(KEYSCAN1, KEYSCAN0_OUTP); - s3c_gpio_cfgpin(KEYSCAN2, KEYSCAN0_OUTP); - s3c_gpio_cfgpin(KEYSCAN3, KEYSCAN0_OUTP); - s3c_gpio_setpin(KEYSCAN0, 0); - s3c_gpio_setpin(KEYSCAN1, 0); - s3c_gpio_setpin(KEYSCAN2, 0); - s3c_gpio_setpin(KEYSCAN3, 0); - - s3c_gpio_cfgpin(KEYROW0, KEYROW0_INP); - s3c_gpio_cfgpin(KEYROW1, KEYROW0_INP); - s3c_gpio_cfgpin(KEYROW2, KEYROW0_INP); - s3c_gpio_cfgpin(KEYROW3, KEYROW0_INP); + s3c_gpio_cfgpin (KEYSCAN0, KEYSCAN0_OUTP); + s3c_gpio_cfgpin (KEYSCAN1, KEYSCAN0_OUTP); + s3c_gpio_cfgpin (KEYSCAN2, KEYSCAN0_OUTP); + s3c_gpio_cfgpin (KEYSCAN3, KEYSCAN0_OUTP); + s3c_gpio_setpin (KEYSCAN0, 0); + s3c_gpio_setpin (KEYSCAN1, 0); + s3c_gpio_setpin (KEYSCAN2, 0); + s3c_gpio_setpin (KEYSCAN3, 0); + + s3c_gpio_cfgpin (KEYROW0, KEYROW0_INP); + s3c_gpio_cfgpin (KEYROW1, KEYROW0_INP); + s3c_gpio_cfgpin (KEYROW2, KEYROW0_INP); + s3c_gpio_cfgpin (KEYROW3, KEYROW0_INP); } -//扫描时GPIO配置函数 +// 扫描时GPIO配置函数 static void InitGPIOScan(void) { // Configure scan port as output @@ -209,7 +209,7 @@ static char GetKey (void) static void PutKeyEvent (char key) { - KEY_DEBUGF ("PutKeyEvent: %c", key); + KEYPAD_DEBUGF ("PutKeyEvent: %c", key); BUF_HEAD = key; s_zkdKeyDev.m_unBufHead = INCBUF (s_zkdKeyDev.m_unBufHead, MAX_BUTTON_BUF); @@ -246,6 +246,7 @@ static void KeyPad_TimerHandler (unsigned long unArg) s_zkdKeyDev.m_cLastKey = cKey; s_zkdKeyDev.m_unKeyCnt = KEY_DOWNX_CNT; s_zkdKeyDev.m_unKeyStatus = STATUS_DOWNX; + KEYPAD_DEBUGF ("KeyPad_TimerHandler: scan key %c (not stable)\n", cKey); } break; @@ -254,6 +255,7 @@ static void KeyPad_TimerHandler (unsigned long unArg) if (cKey != s_zkdKeyDev.m_cLastKey) { // Key not in stable status s_zkdKeyDev.m_unKeyStatus = STATUS_NOKEY; + KEYPAD_DEBUGF ("KeyPad_TimerHandler: scan key %c unstable (count = %u)\n", cKey, KEY_DOWNX_CNT-s_zkdKeyDev.m_unKeyCnt); } else { // Key keep stable if (--s_zkdKeyDev.m_unKeyCnt == 0) { @@ -262,6 +264,7 @@ static void KeyPad_TimerHandler (unsigned long unArg) s_zkdKeyDev.m_unKeyStatus = STATUS_DOWN; // 记录键值,唤醒等待队列 + KEYPAD_DEBUGF ("KeyPad_TimerHandler: scan key %c stable\n", cKey); PutKeyEvent (cKey); } } @@ -276,6 +279,7 @@ static void KeyPad_TimerHandler (unsigned long unArg) // Key keep press if (--s_zkdKeyDev.m_unKeyCnt == 0) { // Keep keep press for a long time, treated as another key press + KEYPAD_DEBUGF ("KeyPad_TimerHandler: re-put key %c\n", cKey); PutKeyEvent (cKey); s_zkdKeyDev.m_unKeyCnt = KEY_DOWN_CNT; } @@ -285,8 +289,7 @@ static void KeyPad_TimerHandler (unsigned long unArg) } // Modify timer for scanning keys, schedule every 20+ms - mod_timer ( &s_zkdKeyDev.m_tlKeyTimer, - jiffies + GET_KEY_INTERVAL_JIFFIES ); + mod_timer ( &s_zkdKeyDev.m_tlKeyTimer, NEXT_GET_KEY_JIFFIES ); } @@ -356,7 +359,7 @@ static int KeyPad_Open (struct inode *inode,struct file *filp) s_zkdKeyDev.m_unBufHead = s_zkdKeyDev.m_unBufTail = 0; // Add timer for scanning keys, schedule every 20+ms - s_zkdKeyDev.m_tlKeyTimer.expires = jiffies + GET_KEY_INTERVAL_JIFFIES; + s_zkdKeyDev.m_tlKeyTimer.expires = NEXT_GET_KEY_JIFFIES; add_timer ( &s_zkdKeyDev.m_tlKeyTimer ); // Notify that this driver opened @@ -415,6 +418,7 @@ static int __init KeyPad_Init (void) int result; dev_t dev; + KEYPAD_DEBUGF ("KeyPad_Init\n"); // Initialize and lock this driver init_MUTEX_LOCKED (&s_zkdKeyDev.m_smMutex); @@ -473,6 +477,7 @@ static int __init KeyPad_Init (void) static void __exit KeyPad_Exit(void) { + KEYPAD_DEBUGF ("KeyPad_Exit\n"); // Lock this driver down_interruptible ( &s_zkdKeyDev.m_smMutex ); -- 2.11.4.GIT