⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ir_control.h

📁 完整的基于Conxant平台的USB电视棒的WIN驱动程序。
💻 H
字号:
/*+++ *******************************************************************\ 
* 
*  Copyright and Disclaimer: 
*  
*     --------------------------------------------------------------- 
*     This software is provided "AS IS" without warranty of any kind, 
*     either expressed or implied, including but not limited to the 
*     implied warranties of noninfringement, merchantability and/or 
*     fitness for a particular purpose.
*     --------------------------------------------------------------- 
*   
*     Copyright (c) 2008 Conexant Systems, Inc. 
*     All rights reserved. 
*
\******************************************************************* ---*/ 

#ifndef _IR_CONTROL_H_
#define _IR_CONTROL_H_

extern "C"
{
    #include <wdm.h>
}

#include <windef.h>
#include <ks.h>
#include <ksmedia.h>

#include "ir_decode.h"
#include "keyq.h"
#include "Debug.h"
#include "CUSBINTF.H"
#include "UsbI2cInterface.h"
#include "pcbconfig.h"
#include "Ir_reg.h"

#define BULK_EP6 1<<4
#define BULK_EP5 1<<5
#define BULK_EP4 1<<6
#define BULK_EP3 1<<7
#define BULK_EP2 1<<8
#define BULK_EP1 1<<9

#define ISO_EP6 1<<10
#define ISO_EP4 1<<11
#define ISO_EP3 1<<12
#define ISO_EP2 1<<13
#define ISO_EP1 1<<14

#define IR_RX_REQ 1<<19

#define MAKO_I2C 0x88

#define DATA_BLOCK_SIZE 8
#define DATA_BLOCK_NUM 80
#define IR_BUFFER_SIZE DATA_BLOCK_SIZE*DATA_BLOCK_NUM
#define IR_BUFFER_NUM 3
#define IR_LENGTH 3
#define EVENT_LENGTH 6



 

typedef struct _BUFFER_ENTRY_MINI
{
    LIST_ENTRY      list_entry;
    PBYTE           p_buffer;
    PIRP            p_irp;
    PURB            p_urb;
    DWORD           bytes_completed;
    READ_CONTEXT    read_context;
    DWORD*          p_data_transfer;
    DWORD           buffer_id;
    BOOLEAN         buffer_in_list;
    BOOLEAN         buffer_dirty;
}BUFFER_ENTRY_MINI, *PBUFFER_ENTRY_MINI;

typedef struct _QUEUE_HEAD
{
    LIST_ENTRY      queue_head;
    LONG            count;
    KEVENT          list_event;
    KSPIN_LOCK      spin_lock;
}QUEUE_HEAD,*PQUEUE_HEAD;

class PolarisUsbInterface;

class IR_Control
{
public:
    IR_Control(
		CUsbInterface* p_usb,
		PolarisUsbInterface* p_firmware,
		UsbI2cInterface* p_i2c_interface,
		PDEVICE_OBJECT pdo,
		PcbConfig* p_current_config);

    ~IR_Control();

    VOID powerDown();
    VOID powerUp();

    NTSTATUS start();
    VOID stop();
    VOID flushQueue();
    PBUFFER_ENTRY_MINI allocateBuffer();
    PBUFFER_ENTRY_MINI getBuffer(PQUEUE_HEAD p_queue);
    VOID addBuffer(PBUFFER_ENTRY_MINI p_buffer, PQUEUE_HEAD p_queue);
	
    VOID freeBuffer(PBUFFER_ENTRY_MINI p_buffer);
    VOID sendBuffer(PBUFFER_ENTRY_MINI p_buffer);
    VOID sendFreeBuffer(PBUFFER_ENTRY_MINI p_buffer);
    VOID waitForTimes(DWORD wait_time);
	
    VOID changConfigindex(BYTE index);
	
    VOID getKeystroke(DWORD* p_command, DWORD* p_address);
    VOID sliced_data(PBYTE p_buffer, PBYTE p_ir, PBYTE p_event);
    VOID ProcessEvent(PBYTE p_event, PBYTE p_pre_event);
    VOID DoEvent(PBYTE p_pre_event);
    VOID ProcessIr(PBYTE p_ir);
    VOID doProcessIr(WORD value);
    VOID initializeIR();

protected:
    static VOID static_ThreadFunction(IR_Control* p_this);
    static VOID static_ThreadQueue(IR_Control* p_this);
    static VOID static_BufferComplete(
        PBUFFER_ENTRY_MINI       p_context,
        NTSTATUS                 status, 
        ULONG                    transfer_size,
        PVOID                    p_read_context);

	 
    VOID threadFunction();
    VOID threadQueue();

    NTSTATUS startThread();
    NTSTATUS startQueueThread();
	
    VOID stopThread();
	
    KIRQL lock(PQUEUE_HEAD p_queue);
    VOID  unlock(KIRQL irql,PQUEUE_HEAD p_queue);


private:
    PDEVICE_OBJECT  _pdo;
    CUsbInterface*  _p_usb;
    PolarisUsbInterface*    _p_usb_firmware;
    UsbI2cInterface* _p_i2c_interface;
    PVOID           _p_thread_object;  
    PVOID           _p_queue_thread;
    DWORD           _pipe;
    BYTE            _interface;

    KEVENT          _thread_event;
    KEVENT          _queue_event;

    IR_Decode       _decoder;
    KeystrokeQueue  _key_queue;

    DWORD           _last_command;
    DWORD           _last_address;

    BOOLEAN         _was_started;
    BOOLEAN         _queue_started;

    QUEUE_HEAD      _data_queue;
    QUEUE_HEAD      _free_queue;
    LONG            _buffer_count;
	
    KEVENT          _wait;
    DWORD           _urb_size;
    PcbConfig*      _p_current_config;
    PPCB_CONFIG     _p_current_pcb;
    BYTE            _config_index;
};



inline KIRQL IR_Control::lock(PQUEUE_HEAD p_queue)
{
    KIRQL irql;

    KeAcquireSpinLock (&p_queue->spin_lock, &irql);

    return irql;
}

/////////////////////////////////////////////////////////////////////////////////////////
//BufferQueue::unLock
//
// UnLock the list's spin lock after touching the list
inline VOID  IR_Control::unlock(KIRQL irql,PQUEUE_HEAD p_queue)
{
    KeReleaseSpinLock (&p_queue->spin_lock, irql);
}


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -