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

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

?? tchpdd.cpp

?? WINCE4.2下S3C2440觸摸屏驅動源碼
?? CPP
?? 第 1 頁 / 共 3 頁
字號:
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Copyright (c) 2002. Samsung Electronics, co. ltd  All rights reserved.

Module Name:

  tchpdd.cpp

Abstract:

  This module contains the DDSI implementation and PDD support routines
  for the touch panel for the P2 implementation.

Functions:

  TouchDriverCalibrationPointGet
  DdsiTouchPanelGetDeviceCaps
  DdsiTouchPanelSetMode
  DdsiTouchPanelEnable
  DdsiTouchPanelDisable
  DdsiTouchPanelAttach
  DdsiTouchPanelDetach
  DdsiTouchPanelGetPoint
  DdsiTouchPanelPowerHandler

Notes:


Revision History:


--*/

#define DBGPOINTS1 1
#define TRACE_TIP_STATE

#include    <windows.h>
#include	<types.h>
#include    <memory.h>
#include    <nkintr.h>
#include    <oalintr.h>
#include    <tchddsi.h>
#include    <tchpdd.h>
#include    <drv_glob.h>
//#include    <p2debug.h>

#include    <S2440.H>
#include 	"reg.h"

#define SYS_TIMER_PRESCALER	24
//#define SYS_TIMER_DIVIDER 4 // 2
//#define OEM_CLOCK_FREQ (S2440PCLK / (SYS_TIMER_PRESCALER+1) / SYS_TIMER_DIVIDER)

#define JYLEE_TEST 0
#define JYLEE_TEST1 0

//#define TFT240_320	1
//#define TFT640_480	4
//#define LCD_TYPE	TFT240_320
//#define LCD_TYPE	TFT640_480

//#if ( LCD_TYPE == TFT640_480 )
//	#define ADC_DELAY_TIME	65530
//#else
	#define ADC_DELAY_TIME	40000	// yhkim
//#endif

DWORD gIntrTouch = SYSINTR_TOUCH;
DWORD gIntrTouchChanged = SYSINTR_TOUCH_CHANGED;

#ifdef TRACE_TIP_STATE
BOOL PenIsUp = TRUE;
#endif

#if defined(MIPS) || defined(PPC821) || defined(PPC823) || defined(ARM) || defined(SH4)
#define PAGE_MASK 0x0fff
#define PAGE_SIZE 0x1000
volatile static PVOID pTmpRegs;
#endif

static void TouchPanelPowerOff();
static void TouchPanelPowerOn();
static BOOL Touch_Timer0_Setup(void) ;

static BOOL Touch_Pen_filtering(INT *px, INT *py);

// The MDD requires a minimum of MIN_CAL_COUNT consecutive samples before
// it will return a calibration coordinate to GWE.  This value is defined
// in the PDD so that each OEM can control the behaviour of the touch
// panel and still use the Microsoft supplied MDD.  Note that the extern "C"
// is required so that the variable name doesn't get decorated, and
// since we have an initializer the 'extern' is actually ignored and
// space is allocated.
extern "C" const int MIN_CAL_COUNT = 40;

INT		CurrentSampleRateSetting = 0;	//	Low sample rate setting

// @globalvar PTCHAUD_ASIC_REGISTERS | v_pTchAudAsicRegisters | Pointer to Asic regs

PTCHAUD_ASIC_REGISTERS              v_pTchAudAsicRegisters = NULL;

// @globalvar PTOUCHPANEL_POINT_SAMPLE | v_pPenSamples | Pointer to pen samples area
PDRIVER_GLOBALS      v_pDriverGlobals = NULL;

volatile static PVOID v_pCpuRegs = NULL;

TOUCH_PANEL_SAMPLE_FLAGS SampleFlags;

#ifdef CHECK_RATE
    UINT32	tmp_leds = 0x55;
#endif

// Mutex to prevent contention with audio while accessing shared registers
static HANDLE v_hTchAudMutex;

// Global flag to indicate whether we are in power handler routine, so
// we know to avoid system calls.
static BOOL bInPowerHandler = FALSE;


// Macros for aquiring semaphore for shared access to ASIC registers. If
// we are in the power handler routines, we don't need/want to aquire semaphore,
// since we are serialized at that point, and can't make any system calls.
#define TCHAUD_SEM_LOCK()  \
    if (!bInPowerHandler) { \
        DEBUGMSG(ZONE_TIPSTATE,(TEXT("TchPDD Getting semaphore...\r\n"))); \
        TchAudLock(v_hTchAudMutex, &(v_pDriverGlobals->tch.semaphore)); \
    }
#define TCHAUD_SEM_UNLOCK() \
    if (!bInPowerHandler) { \
        DEBUGMSG(ZONE_TIPSTATE,(TEXT("TchPDD Releasing semaphore...\r\n"))); \
        TchAudUnlock(v_hTchAudMutex, &(v_pDriverGlobals->tch.semaphore)); \
    }

// Macros for accessing registers on the touch audio ASIC.  The code for
// these functions is in drvlib so it can be shared between touch and audio.
#define ASIC_READ_REG(reg, pval) \
    TchAudReadReg(reg, pval, v_pTchAudAsicRegisters, bInPowerHandler)
#define ASIC_WRITE_REG(reg, val) \
    TchAudWriteReg(reg, val, v_pTchAudAsicRegisters, bInPowerHandler)
#define ASIC_AND_REG(reg, val) \
    TchAudAndReg(reg, val, v_pTchAudAsicRegisters, bInPowerHandler)
#define ASIC_OR_REG(reg, val) \
    TchAudOrReg(reg, val, v_pTchAudAsicRegisters, bInPowerHandler)


volatile IOPreg *v_pIOPregs;
volatile ADCreg *v_pADCregs;
volatile PWMreg *v_pPWMregs;
volatile INTreg *v_pINTregs;    

volatile unsigned short xbuf[10], ybuf[10];
static unsigned int touch_down = 1;

//#define ADCPRS  49	// 200Mhz
#define ADCPRS  49	// 200Mhz
//#define ADCPRS  65		// 532Mhz

/*++

Routine Description:

    Deallocates the virtual memory reserved for the Touch/Audio Asic registers,
    and the pen samples dma area.

Arguments:

    None.


Return Value:

    None.

Autodoc Information:

    @doc IN_TOUCH_DDSI INTERNAL DRIVERS PDD TOUCH_PANEL

    @func VOID | PddpTouchPanelDeallocateVm |
    Deallocates the virtual memory reserved for the Touch/Audio Asic registers,
    and the pen samples dma area.

--*/
static
void
PddpTouchPanelDeallocateVm(
    VOID
    )
{
    if(v_pIOPregs)
    {
        VirtualFree((void*)v_pIOPregs, sizeof(IOPreg), MEM_RELEASE);
        v_pIOPregs=NULL;
    }
    if(v_pADCregs)
    {   
        VirtualFree((void*)v_pADCregs, sizeof(ADCreg), MEM_RELEASE);
        v_pADCregs = NULL;
    }        
    if ( v_pDriverGlobals )
    {
        VirtualFree( v_pDriverGlobals,
                     DRIVER_GLOBALS_PHYSICAL_MEMORY_SIZE ,
                     MEM_RELEASE
                    );
        v_pDriverGlobals = NULL;
    }    
}

//
// PDD Internal Support Routines
//

/*++
    @doc IN_TOUCH_DDSI INTERNAL DRIVERS PDD TOUCH_PANEL

    @func VOID | PddpTouchPanelGetSamples |
    Copies from the pen dma area the most recent point sample into the location
    pointed to by pPointSamples.  During the copy the sample information is
    adjusted to be consistent with the 12 bit pen data format.
    Has the side effect of reinitializing ioPenPointer if we are near the
    end of the pen sample area.
--*/
static
void
PddpTouchPanelGetSamples(
    PTOUCHPANEL_POINT_SAMPLE pPointSamples //@PARM Pointer to where the samples will be stored.
    )
{
    // ULONG   devDrvPointer;
    ULONG   irg;

    //
    // Copy the samples to our buffer munging the data for the 12 bit
    //  pen data format.
    //

    for ( irg = 0; irg < NUMBER_SAMPLES_PER_POINT; irg++ )
    {
        pPointSamples[ irg ].XSample = xbuf[irg];
        pPointSamples[ irg ].YSample = ybuf[irg];
    }
}

/*++

Routine Description:

    Gathers the most recent sample and evaluates the sample returing
    the determined tip state and the `best guess' for the X and Y coordinates.

    Note: Determined empirically that the variance of the X coordinate of the
          first sample from all other samples is large enough that in order
          to keep the nominal variance small, we discard the first sample.

          Cases of a light touch that locks the ADC into
          seeing X and Y coordinate samples of 0x277 regardless of how the pen
          moves or presses have been seen. XXXXX


Arguments:

    pTipState   Pointer to where the tip state information will be returned.

    pUnCalX     Pointer to where the x coordinate will be returned.

    pUnCalY     Pointer to where the y coordinate will be returned.

Return Value:

    None.

Autodoc Information:

    @doc IN_TOUCH_DDI INTERNAL DRIVERS PDD TOUCH_PANEL

    @func VOID | PddpTouchPanelEvaluateSamples |
    Gathers the most recent sample and evaluates the sample returing
    the determined tip state and the `best guess' for the X and Y coordinates.

--*/
static
void
PddpTouchPanelEvaluateSamples(
    TOUCH_PANEL_SAMPLE_FLAGS	*pSampleFlags, //@PARM Pointer to where the tip state information will be returned.
    INT							*pUncalX,      //@PARM Pointer to where the x coordinate will be returned.
	INT							*pUncalY       //@PARM Pointer to where the y coordinate will be returned.

    )
{
    LONG    dlXDiff0;
    LONG    dlXDiff1;
    LONG    dlXDiff2;
    LONG    dlYDiff0;
    LONG    dlYDiff1;
    LONG    dlYDiff2;

    TOUCHPANEL_POINT_SAMPLES rgPointSamples;

    //
    // Get the sample.
    //

    PddpTouchPanelGetSamples( rgPointSamples );


    //
    // Calcuate the differences for the X samples and insure that
    // the resulting number is positive.
    //

    dlXDiff0 = rgPointSamples[ 0 ].XSample - rgPointSamples[ 1 ].XSample;
    dlXDiff1 = rgPointSamples[ 1 ].XSample - rgPointSamples[ 2 ].XSample;
    dlXDiff2 = rgPointSamples[ 2 ].XSample - rgPointSamples[ 0 ].XSample;
    dlXDiff0 = dlXDiff0 > 0  ? dlXDiff0 : -dlXDiff0;
    dlXDiff1 = dlXDiff1 > 0  ? dlXDiff1 : -dlXDiff1;
    dlXDiff2 = dlXDiff2 > 0  ? dlXDiff2 : -dlXDiff2;

    //
    // Calcuate the differences for the Y samples and insure that
    // the resulting number is positive.
    //

    dlYDiff0 = rgPointSamples[ 0 ].YSample - rgPointSamples[ 1 ].YSample;
    dlYDiff1 = rgPointSamples[ 1 ].YSample - rgPointSamples[ 2 ].YSample;
    dlYDiff2 = rgPointSamples[ 2 ].YSample - rgPointSamples[ 0 ].YSample;
    dlYDiff0 = dlYDiff0 > 0  ? dlYDiff0 : -dlYDiff0;
    dlYDiff1 = dlYDiff1 > 0  ? dlYDiff1 : -dlYDiff1;
    dlYDiff2 = dlYDiff2 > 0  ? dlYDiff2 : -dlYDiff2;

    //
    // The final X coordinate is the average of coordinates of
    // the two MIN of the differences.
    //

    if ( dlXDiff0 < dlXDiff1 )
    {
        if ( dlXDiff2 < dlXDiff0 )
        {

            *pUncalX = (ULONG)( ( ( rgPointSamples[ 0 ].XSample + rgPointSamples[ 2 ].XSample ) >> 1 ) );
        }
        else
        {

            *pUncalX = (ULONG)( ( ( rgPointSamples[ 0 ].XSample + rgPointSamples[ 1 ].XSample ) >> 1 ) );
        }
    }
    else if ( dlXDiff2 < dlXDiff1 )
    {

            *pUncalX = (ULONG)( ( ( rgPointSamples[ 0 ].XSample + rgPointSamples[ 2 ].XSample ) >> 1 ) );
    }
    else
    {

            *pUncalX = (ULONG)( ( ( rgPointSamples[ 1 ].XSample + rgPointSamples[ 2 ].XSample ) >> 1 ) );
    }

    //
    //
    // The final Y coordinate is the average of coordinates of
    // the two MIN of the differences.
    //

    if ( dlYDiff0 < dlYDiff1 )
    {
        if ( dlYDiff2 < dlYDiff0 )
        {

            *pUncalY = (ULONG)( ( ( rgPointSamples[ 0 ].YSample + rgPointSamples[ 2 ].YSample ) >> 1 ) );
        }
        else
        {

            *pUncalY = (ULONG)( ( ( rgPointSamples[ 0 ].YSample + rgPointSamples[ 1 ].YSample ) >> 1 ) );
        }
    }
    else if ( dlYDiff2 < dlYDiff1 )
    {

            *pUncalY = (ULONG)( ( ( rgPointSamples[ 0 ].YSample + rgPointSamples[ 2 ].YSample ) >> 1 ) );
    }
    else
    {

            *pUncalY = (ULONG)( ( ( rgPointSamples[ 1 ].YSample + rgPointSamples[ 2 ].YSample ) >> 1 ) );
    }

    //
    // Validate the coordinates and set the tip state accordingly.
    //

    if ( dlXDiff0 > DELTA_X_COORD_VARIANCE ||
         dlXDiff1 > DELTA_X_COORD_VARIANCE ||
         dlXDiff2 > DELTA_X_COORD_VARIANCE ||
         dlYDiff0 > DELTA_Y_COORD_VARIANCE ||
         dlYDiff1 > DELTA_Y_COORD_VARIANCE ||
         dlYDiff2 > DELTA_Y_COORD_VARIANCE )
    {

//#ifdef DBGPOINTS1
        DEBUGMSG( ZONE_SAMPLES, (TEXT("Sample 0: X 0x%x Y 0x%x\r\n"),
               rgPointSamples[ 0 ].XSample, rgPointSamples[ 0 ].YSample) );
        DEBUGMSG( ZONE_SAMPLES, (TEXT("Sample 1: X 0x%x Y 0x%x\r\n"),
               rgPointSamples[ 1 ].XSample, rgPointSamples[ 1 ].YSample) );
        DEBUGMSG( ZONE_SAMPLES, (TEXT("Sample 2: X 0x%x Y 0x%x\r\n"),
               rgPointSamples[ 2 ].XSample, rgPointSamples[ 2 ].YSample) );


        if ( dlXDiff0 > DELTA_X_COORD_VARIANCE )
            DEBUGMSG( ZONE_SAMPLES, (TEXT("XDiff0 too large 0x%x\r\n"), dlXDiff0) );
        if ( dlXDiff1 > DELTA_X_COORD_VARIANCE )
            DEBUGMSG( ZONE_SAMPLES, (TEXT("XDiff1 too large 0x%x\r\n"), dlXDiff1) );
        if ( dlXDiff2 > DELTA_X_COORD_VARIANCE )
            DEBUGMSG( ZONE_SAMPLES, (TEXT("XDiff2 too large 0x%x\r\n"), dlXDiff2) );

        if ( dlYDiff0 > DELTA_Y_COORD_VARIANCE )
            DEBUGMSG( ZONE_SAMPLES, (TEXT("YDiff0 too large 0x%x\r\n"), dlYDiff0) );
        if ( dlYDiff1 > DELTA_Y_COORD_VARIANCE )
            DEBUGMSG( ZONE_SAMPLES, (TEXT("YDiff1 too large 0x%x\r\n"), dlYDiff1) );
        if ( dlYDiff2 > DELTA_Y_COORD_VARIANCE )
            DEBUGMSG( ZONE_SAMPLES, (TEXT("YDiff2 too large 0x%x\r\n"), dlYDiff2) );

//#endif // DBGPOINTS1

    }
    else
    {
        //
        // Sample is valid. Set tip state accordingly.
        //
		*pSampleFlags = TouchSampleValidFlag | TouchSampleDownFlag;
    }

    DEBUGMSG( ZONE_SAMPLES, (TEXT("Filtered - SampleFlags: 0x%x X: 0x%x Y: 0x%x\r\n"),
           *pSampleFlags, *pUncalX, *pUncalY) );

}

//

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
寂寞少妇一区二区三区| 亚洲一区影音先锋| 精品久久久久久久久久久久久久久 | 91最新地址在线播放| 国产精品一区二区在线观看不卡| 麻豆91在线播放| 久久99精品网久久| 成人免费看片app下载| 成人在线综合网站| 99久久综合精品| 色欧美乱欧美15图片| 在线播放亚洲一区| 精品国产精品一区二区夜夜嗨| 久久综合久久99| 中文字幕一区二区三区乱码在线| 亚洲美女少妇撒尿| 五月综合激情日本mⅴ| 激情综合网最新| 99视频在线精品| 欧美日韩激情在线| 久久精品人人做人人综合 | 日韩丝袜情趣美女图片| 久久精品在这里| 一区二区三区日韩精品视频| 偷拍与自拍一区| 国产精品一区免费在线观看| 99久久精品免费| 欧美一卡二卡在线| 中文无字幕一区二区三区| 亚洲另类一区二区| 精品在线一区二区三区| 91在线国产福利| 精品日韩一区二区| 亚洲精品福利视频网站| 精品一区二区在线视频| 色综合久久久久| 2020国产成人综合网| 亚洲国产一区二区三区青草影视| 麻豆成人综合网| 91国偷自产一区二区三区成为亚洲经典| 911国产精品| 一区二区三区蜜桃| 国产成人无遮挡在线视频| 欧美日韩一级二级| 亚洲国产成人午夜在线一区| 午夜激情综合网| 一本色道久久综合亚洲精品按摩| 欧美第一区第二区| 偷拍与自拍一区| 色婷婷综合久久久中文字幕| 亚洲精品一区二区三区四区高清| 亚洲一二三专区| 99久久精品国产观看| 久久综合九色综合久久久精品综合| 一区二区三区久久| 成人福利视频网站| 26uuu精品一区二区| 亚洲欧洲性图库| 国产91精品在线观看| 欧美mv日韩mv| 全部av―极品视觉盛宴亚洲| 欧美专区日韩专区| 一区二区三区在线免费播放| 成人国产精品免费观看动漫 | 97se亚洲国产综合在线| 国产女人18水真多18精品一级做| 青青国产91久久久久久 | 精品不卡在线视频| 免费欧美在线视频| 欧美mv日韩mv国产网站app| 日本三级韩国三级欧美三级| 欧美日韩国产综合一区二区| 亚洲综合在线观看视频| 99久久精品国产导航| 国产精品麻豆视频| 91丝袜呻吟高潮美腿白嫩在线观看| 国产日韩av一区| 99国产精品国产精品久久| 国产精品久久久久永久免费观看 | 成人深夜在线观看| 国产精品青草综合久久久久99| 国产精品一品视频| 国产精品久久久久影院亚瑟| youjizz久久| 成人免费一区二区三区视频 | 精品国产91九色蝌蚪| 精品一区二区三区免费视频| wwwwxxxxx欧美| 成人精品一区二区三区四区 | 91精品国产色综合久久不卡电影| 日本午夜精品视频在线观看| 欧美xxxx在线观看| 国产九色精品成人porny| 中文字幕不卡的av| 欧美性猛交xxxx乱大交退制版| 三级欧美在线一区| 欧美一区二区三区免费大片| 久久国产精品第一页| 国产人妖乱国产精品人妖| 99久久综合99久久综合网站| 亚洲午夜一区二区| 日韩三级在线观看| 波多野结衣视频一区| 亚洲国产精品天堂| 久久精品一二三| 欧美三级乱人伦电影| 极品少妇xxxx精品少妇偷拍| 国产精品麻豆久久久| 欧美高清hd18日本| 懂色av中文一区二区三区| 偷拍亚洲欧洲综合| 中文字幕亚洲成人| 日韩欧美国产小视频| 粉嫩av一区二区三区在线播放| 亚洲va国产天堂va久久en| 国产欧美精品在线观看| 91精品国产高清一区二区三区| 懂色av一区二区三区蜜臀| 青青草原综合久久大伊人精品优势| 中文乱码免费一区二区| 日韩免费成人网| 欧美日韩精品二区第二页| 成人黄色国产精品网站大全在线免费观看 | 欧美亚洲国产一区二区三区va| 国产一区二区三区| 婷婷综合久久一区二区三区| 国产精品国产三级国产a| 91精品国产色综合久久不卡电影 | 一区二区成人在线视频| 久久久三级国产网站| 91精品国产色综合久久久蜜香臀| 91色视频在线| av激情综合网| 国产一区二区剧情av在线| 美女视频黄免费的久久 | 成人丝袜视频网| 激情六月婷婷久久| 日韩高清欧美激情| 日韩va亚洲va欧美va久久| 亚洲成人免费看| 亚洲卡通欧美制服中文| 国产欧美一区二区三区在线老狼| 欧美大胆一级视频| 日韩欧美美女一区二区三区| 欧美福利一区二区| 日韩一区二区在线免费观看| 欧美片在线播放| 欧美一区二区三区不卡| 欧美高清你懂得| 日韩精品中文字幕一区二区三区| 欧美男生操女生| 制服丝袜亚洲网站| 日韩欧美一二三四区| 日韩欧美国产不卡| 精品欧美一区二区久久 | 成人开心网精品视频| 高清在线不卡av| 成人黄动漫网站免费app| 99久久精品国产一区二区三区| 99久久精品免费看| 欧美在线免费观看亚洲| 欧美日韩高清在线播放| 欧美日本在线视频| 欧美不卡视频一区| 亚洲国产精品二十页| 中文字幕一区二区不卡| 一区二区三区四区精品在线视频| 一区二区理论电影在线观看| 亚洲超碰精品一区二区| 老司机午夜精品99久久| 狠狠网亚洲精品| www.色综合.com| 欧美性一区二区| 欧美本精品男人aⅴ天堂| 中文字幕av一区 二区| 亚洲小说欧美激情另类| 亚洲一区二区在线视频| 美女在线观看视频一区二区| 国产精品一线二线三线| 91麻豆国产自产在线观看| 欧美日韩二区三区| 久久奇米777| 亚洲一区在线观看网站| 国内不卡的二区三区中文字幕| 成人成人成人在线视频| 欧美午夜片在线观看| 久久这里只有精品首页| 亚洲男人的天堂在线aⅴ视频| 日韩av电影免费观看高清完整版 | 亚洲成人免费在线观看| 精品一区二区在线视频| 91啪亚洲精品| 国产性天天综合网| 午夜欧美电影在线观看| 成人av在线播放网站| 日韩视频永久免费| 亚洲综合激情另类小说区| 国产精品 欧美精品| 91精品久久久久久久久99蜜臂| 亚洲丝袜制服诱惑|