在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

    
    
    <address id="vxupu"><td id="vxupu"></td></address>

      <pre id="vxupu"><small id="vxupu"></small></pre>
      <dfn id="vxupu"></dfn>
      <div id="vxupu"><small id="vxupu"></small></div>
    1. 新聞中心

      EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > AM335x(TQ335x)學(xué)習(xí)筆記——觸摸屏驅(qū)動(dòng)編寫

      AM335x(TQ335x)學(xué)習(xí)筆記——觸摸屏驅(qū)動(dòng)編寫

      作者: 時(shí)間:2016-11-28 來(lái)源:網(wǎng)絡(luò) 收藏
    2. if(status){
    3. returnstatus;
    4. }
    5. count=3;
    6. while(count--){
    7. if(i2c_write_bytes(client,config,sizeof(config))<0){
    8. dev_err(dev,"FailedtoconfiguretheGT811,tryagain...");
    9. status=-EINVAL;
    10. }
    11. else{
    12. dev_info(dev,"Gt811configuesucceed");
    13. status=0;
    14. break;
    15. }
    16. }
    17. returnstatus;
    18. }
    19. staticstructgt811_ts_platdata*gt811_ts_parse_devtree(structi2c_client*client)
    20. {
    21. structdevice*dev=&client->dev;
    22. structdevice_node*node;
    23. structgt811_ts_platdata*pdata;
    24. enumof_gpio_flagsflags;
    25. node=dev->of_node;
    26. if(!node){
    27. dev_err(dev,"Theof_nodeisNULL.");
    28. returnERR_PTR(-ENODEV);
    29. }
    30. pdata=devm_kzalloc(dev,sizeof(structdevice_node),GFP_KERNEL);
    31. if(!pdata){
    32. dev_err(dev,"Noenoughmemoryleft.");
    33. returnERR_PTR(-ENOMEM);
    34. }
    35. pdata->reset_pin=of_get_gpio_flags(node,0,&flags);
    36. if(pdata->reset_pin<0){
    37. dev_err(dev,"GetRSTpinfailed!");
    38. returnERR_PTR(-EINVAL);
    39. }
    40. if(of_property_read_u32(node,"touchscreen-size-x",&pdata->size_x)){
    41. dev_err(dev,"Failedtogetthetouchscreenxsize.");
    42. returnERR_PTR(-EINVAL);
    43. }
    44. if(of_property_read_u32(node,"touchscreen-size-y",&pdata->size_y)){
    45. dev_err(dev,"Failedtogetthetouchscreenysize.");
    46. returnERR_PTR(-EINVAL);
    47. }
    48. if(of_property_read_u32(node,"touchscreen-size-p",&pdata->size_p)){
    49. pdata->size_p=255;
    50. }
    51. if(of_property_read_u32(node,"touchscreen-swap",&pdata->swap)){
    52. pdata->swap=1;
    53. }
    54. if(of_property_read_u32(node,"touchscreen-revert-x",&pdata->revert_x)){
    55. pdata->revert_x=1;
    56. }
    57. if(of_property_read_u32(node,"touchscreen-revert-x",&pdata->revert_y)){
    58. pdata->revert_y=1;
    59. }
    60. returnpdata;
    61. }
    62. staticintgt811_ts_probe(structi2c_client*client,conststructi2c_device_id*id)
    63. {
    64. structdevice*dev=&client->dev;
    65. structgt811_ts_platdata*pdata=dev_get_platdata(dev);
    66. structinput_dev*input;
    67. interror=0;
    68. if(!of_match_device(of_match_ptr(gt811_ts_of_match),dev)){
    69. dev_err(dev,"Failedtomatch.");
    70. return-EINVAL;
    71. }
    72. if(!pdata){
    73. pdata=gt811_ts_parse_devtree(client);
    74. if(IS_ERR(pdata)){
    75. dev_err(dev,"Getdevicedatafromdevicetreefailed!");
    76. error=-EINVAL;
    77. gotofailed_exit;
    78. }
    79. }
    80. pdata->client=client;
    81. i2c_set_clientdata(client,pdata);
    82. input=devm_input_allocate_device(dev);
    83. if(!input){
    84. dev_err(dev,"Failedtoallocateinputdevice");
    85. error=-ENOMEM;
    86. gotopdata_free;
    87. }
    88. pdata->input=input;
    89. input->name=client->name;
    90. input->id.bustype=BUS_I2C;
    91. input->id.product=0xBEEF;
    92. input->id.vendor=0xDEAD;
    93. input->dev.parent=&client->dev;
    94. __set_bit(EV_KEY,input->evbit);
    95. __set_bit(EV_ABS,input->evbit);
    96. __set_bit(BTN_TOUCH,input->keybit);
    97. input_set_abs_params(input,ABS_X,0,pdata->size_x,0,0);
    98. input_set_abs_params(input,ABS_Y,0,pdata->size_y,0,0);
    99. input_set_abs_params(input,ABS_MT_POSITION_X,0,pdata->size_x,0,0);
    100. input_set_abs_params(input,ABS_MT_POSITION_Y,0,pdata->size_y,0,0);
    101. error=input_mt_init_slots(input,5,INPUT_MT_DIRECT|INPUT_MT_DROP_UNUSED);
    102. if(error){
    103. dev_err(dev,"Failedtoinitializethemulti-touchslots.");
    104. gotoinput_free;
    105. }
    106. input_set_drvdata(input,pdata);
    107. error=input_register_device(input);
    108. if(error){
    109. dev_err(dev,"Registerinputdevicefailed!");
    110. gotoinput_free;
    111. }
    112. if(gt811_ts_initilize(client)){
    113. dev_err(dev,"FailedtoinitializeGT811.");
    114. }
    115. INIT_WORK(&pdata->work,gt811_ts_handler);
    116. error=devm_request_any_context_irq(dev,client->irq,gt811_ts_isr,
    117. IRQF_TRIGGER_FALLING,client->name,pdata);
    118. if(error){
    119. dev_err(dev,"Failedtorequestirq(number:%d)",client->irq);
    120. gotoinput_free;
    121. }
    122. return0;
    123. input_free:
    124. devm_kfree(dev,input);
    125. pdata_free:
    126. devm_kfree(dev,pdata);
    127. failed_exit:
    128. returnerror;
    129. }
    130. staticintgt811_ts_remove(structi2c_client*client)
    131. {
    132. structgt811_ts_platdata*pdata=(structgt811_ts_platdata*)i2c_get_clientdata(client);
    133. devm_free_irq(&client->dev,client->irq,i2c_get_clientdata(client));
    134. input_unregister_device(pdata->input);
    135. devm_kfree(&client->dev,pdata);
    136. return0;
    137. }
    138. staticconststructi2c_device_idgt811_ts_id[]={
    139. {"gt811_ts",0},
    140. {}
    141. };
    142. staticstructi2c_drivergt811_ts_driver={
    143. .driver={
    144. .owner=THIS_MODULE,
    145. .name="gt811_ts",
    146. .of_match_table=of_match_ptr(gt811_ts_of_match),
    147. },
    148. .probe=gt811_ts_probe,
    149. .remove=gt811_ts_remove,
    150. .id_table=gt811_ts_id,
    151. };
    152. module_i2c_driver(gt811_ts_driver);
    153. MODULE_AUTHOR("girlkoo");
    154. MODULE_DESCRIPTION("Gt811I2CTouchscreenDriver");
    155. MODULE_LICENSE("GPL");
    156. (4) 使用tslib工具測(cè)試

      本文引用地址:http://www.biyoush.com/article/201611/322822.htm

      tslib的編譯方法請(qǐng)參考本博客的另一片文章,鏈接如下:

      S5PV210(TQ210)學(xué)習(xí)筆記——觸摸屏驅(qū)動(dòng)編寫

      本文就不再重復(fù)tslib的配置方法。

      (5)效果展示

      (6) 完整驅(qū)動(dòng)代碼

      請(qǐng)到本人的資源中下載TQ335x的觸摸屏驅(qū)動(dòng)源碼,鏈接如下:

      http://download.csdn.net/download/girlkoo/8202177


      上一頁(yè) 1 2 下一頁(yè)

      關(guān)鍵詞: AM335xTQ335x觸摸屏驅(qū)動(dòng)編

      評(píng)論


      相關(guān)推薦

      技術(shù)專區(qū)

      關(guān)閉