zForce紅外觸屏處理晶元驅動分析

2021-06-28 21:24:02 字數 2814 閱讀 5002

zforce紅外觸屏處理晶元驅動原始碼有兩套,分別為linux&android、wince系統實現。

我用的是linux系統,應用不是qt實現的,介面都是opengl實現,所以,要自行處理觸屏輸入控制。

linux的觸屏驅動使用了input子系統,前一天已經做了乙個基本學習,現在分析一下驅動實現。

硬體介面:

ir觸屏使用i2c訪問,有資料時,dataready會置低,3.3v供電,pin10接地。

i2c訪問不是一般器件的暫存器式的讀寫操作,而是基於zforce的通訊協議訪問。

測試時可以參考zforce的通訊協議說明,實際驅動已經實現所有協議內容,不做具體分析。

觸屏模組硬體和軟體適配修改有:

1. 需要提供乙個irq,連線dataready

我的板子上用的是gpio的irq,需要初始化gpio pin mux,輸入和中斷使能,下降沿觸發(以後再具體分析gpio的驅動架構)

2. 對接i2c3

使用ti的晶元,其linux核心中i2c的驅動使用的是new style驅動模型。

在i2c模組,修改全域性變數:

static struct i2c_board_info __initdata ti814x_i2c_boardinfo1 = ,

};

i2c初始化函式中增加:

omap_register_i2c_bus(3, 100, ti814x_i2c_boardinfo1,array_size(ti814x_i2c_boardinfo1));
這個函式是由cpu提供商實現,作用是用new style方式註冊i2c匯流排及裝置,具體實現以後分析。

zforce模組初始化函式呼叫

static struct i2c_driver zforce_ts_driver =

,    .probe = zforce_ts_probe,

.remove = zforce_ts_remove,

.suspend = zforce_ts_suspend,

.resume = zforce_ts_resume,

.id_table = zforce_ts_id,

};

i2c_add_driver ( &zforce_ts_driver );
driver和device匹配,os會呼叫driver的probe函式:zforce_ts_probe

配置input引數:

dev_set_drvdata ( &client->dev, priv );

input = input_allocate_device();

if ( !input )

input->evbit[0] = bit_mask ( ev_key ) | bit_mask ( ev_abs );

input->keybit[bit_word ( btn_touch )] = bit_mask ( btn_touch );

// setup the coordinate system (span from 0 to max in both axis)

input_set_abs_params( input, abs_mt_touch_major, 0, 0xff, 0, 0);

input_set_abs_params( input, abs_mt_touch_minor, 0, 0xff, 0, 0);

input_set_abs_params( input, abs_mt_orientation, 0, 1, 0, 0);

input_set_abs_params( input, abs_mt_tracking_id, 0, 0xfff, 0, 0);

input_set_abs_params ( input, abs_mt_position_x, 0, max_x, 0, 0 );

input_set_abs_params ( input, abs_mt_position_y, 0, max_y, 0, 0 );

input_mt_create_slots( input, max_coords);

input->name = client->name;

input->id.bustype = bus_i2c;

input->dev.parent = &client->dev;

input_set_drvdata ( input, priv );

error = input_register_device ( input );

配置中斷和中斷處理函式:

init_delayed_work ( &priv->work, zforce_ts_isr_bh );

init_completion ( &priv->complete );

error = request_irq ( priv->irq, zforce_ts_isr_th, irqf_trigger_low, client->name, priv );

這裡使用:

1.工作佇列實現中斷的上下半部分處理,

2.完成量實現核心執行緒同步。

最終,驅動獲取觸屏資訊後:

for ( ; i < numberoftouches; ++i )

else

}input_event( priv->input, ev_key, btn_touch, 1);

其中,abs_mt_tracking_id對應多點觸控的不同點id。

手機觸屏分類

通過moto xt800的開發,第一次接觸到另一種觸屏方式,所以網上找了下資料,發現與以往mobile手機開發中的不同之處 1 電阻式觸控螢幕 利用壓力感應進行控制。電阻觸控螢幕的主要部分是一塊與顯示器表面非常配合的電阻薄膜屏,這是一種多層的復合薄膜,它以一層玻璃或硬塑料平板作為基層,表面塗有一層透...

04 觸屏事件

touchstart 手指觸控螢幕時觸發 touchmove 手指在螢幕上移動時觸發 touchend 手指離開螢幕時觸發 touches 位於螢幕上的所有手指的列表 targettouches 位於該元素上的所有手指的列表 changedtouches touchstart時包含剛與觸控螢幕接觸的...

android game 觸屏事件處理

如圖 按螢幕飛機會發出子彈 img 用手指觸控一下螢幕,這短暫的0.1秒內大概會產生10個左右的motionevent 並且系統會盡可能快的把這些event發給監聽執行緒,這樣的話在這一段時間內cpu就會忙於處理ontouchevent從而畫面一卡一卡的。我用的辦法是在ontouchevent中sl...