Linux input subsystem for Android low-level development do not infer the system sleep state escalation key value

Source: Internet
Author: User
<span id="Label3"></p><p style="text-align:center"><p style="text-align:center"><strong><span style="font-size:24px">Android <span style="font-family:宋体">Bottom</span> -up Linux <span style="font-family:宋体">input</span> subsystem should not infer the system sleep state escalation key value</span></strong></p></p><p><p></p></p><p><p>Off-topic: A problem study to the end, the first half of the document over there is basically useless, even wrong.</p></p><p><p>The point is at the end, but some hypothetical guesses are in Front.</p></p><p style="text-align:center"><p style="text-align:center">http://blog.csdn.net/kangear/article/details/40072707</p></p><p style="text-align:center"><p style="text-align:center"><br></p></p><p><p>When debugging the IR remote control <span style="font-family:Times New Roman">input</span> <span style="font-family:宋体">driver, The direct use of a semi-finished driver on the top of the implementation of their own device matching, but at the same time encountered some doubts about</span> <span style="font-family:Times New Roman"></span> <span style="font-family:宋体">input Subsystem. </span></p></p><p><p>Buttons generally have "press and lift" two states are generally used <span style="font-family:Times New Roman">0</span> <span style="font-family:宋体">and</span> <span style="font-family:Times New Roman">1</span> <span style="font-family:宋体">to indicate respectively. In general, for example, the following way to escalate key key values can be completed "press and lift" two state Collection. </span></p></p><p><p></p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Input_event (ddata->input, ev_key, key_power, 1);</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Input_sync (ddata->input);</p></p><p><p>however, A strange problem recently encountered is that the <span style="font-family:Times New Roman">key_wakeup</span> <span style="font-family:宋体">wake-up key in the kernel uses the above method to Chime. User space can only detect the status</span> <span style="font-family:Times New Roman">0</span><span style="font-family:宋体">, the second time the button will have a status of</span> <span style="font-family:Times New Roman">1</span><span style="font-family:宋体">. This causes</span> the <span style="font-family:Times New Roman">Android</span> <span style="font-family:宋体">system to not wake up normally and requires two abilities to wake the System. </span></p></p><p><p></p></p><p><p>The workaround now is to change the floor of the previously escalated <span style="font-family:Times New Roman">Key_wakeup</span> <span style="font-family:宋体">to the</span> <span style="font-family:Times New Roman">key_power</span> <span style="font-family:宋体">key Value. But curiosity leads me to find out what's going on with Them. </span></p></p><p><p></p></p><p><p>Experience out of this in the same report as the following continuous escalation <span style="font-family:Times New Roman">1/0</span> <span style="font-family:宋体">State talent enough in the user space normal detection to</span> the <span style="font-family:Times New Roman">1/0</span> <span style="font-family:宋体">State. </span></p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Input_event (ddata->input, ev_key, key_wakeup, 1);</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Input_sync (ddata->input);</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)"></p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Input_event (ddata->input, ev_key, key_wakeup, 0);</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Input_sync (ddata->input);</p></p><p><p></p></p><p><p>Intuition tells me that I can do this because I am not aware of this two <span style="font-family:Times New Roman">API</span> <span style="font-family:宋体">. A comparison is a cause for everything. </span></p></p><p><p>In addition to <span style="font-family:Times New Roman">key_wakeup</span> <span style="font-family:宋体">Change Another key value to Try. The result</span> is as <span style="font-family:Times New Roman">key_wakeupg</span> as it can be, and the <span style="font-family:宋体">ability to determine non</span> - <span style="font-family:Times New Roman">POWER</span> <span style="font-family:宋体">Buttons is Impossible. This can be related to where the code is located:</span></p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">}else if ((get_suspend_state ()) && (ddata->keycode==key_power)) {</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Input_event (ddata->input, ev_key, key_power, 1);</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Input_sync (ddata->input);</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">}</p></p><p><p></p></p><p><p>Further testing in the non- <span style="font-family:Times New Roman">pm_suspend_on</span> <span style="font-family:宋体">Power mode, All the keys are what. The test result is that all non-</span> <span style="font-family:Times New Roman">POWER</span> <span style="font-family:宋体">keys have a problem with the keys not syncing. But you can't make a point. </span> <span style="font-family:Times New Roman"></span> the <span style="font-family:宋体">physical keys connected using GPIO do not have this Problem. Then</span> the <span style="font-family:Times New Roman">input</span> subsystem was ruled out <span style="font-family:宋体">of hands and Feet. </span></p></p><p><p>The problem is the processing of the pair in the <span style="font-family:Times New Roman">Remote control</span> <span style="font-family:宋体">driver. </span></p></p><p><p>Find out where the problem lies. is actually out of the <span style="font-family:Times New Roman">Remote control</span> <span style="font-family:宋体">driver, The Escalation key value of</span> the <span style="font-family:Times New Roman">PM</span> <span style="font-family:宋体">State is inferred, assuming that</span></p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">static void Remotectl_timer (unsigned long _data)</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">If (ddata->press! = ddata->pre_press) {</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">ddata->pre_press = Ddata->press = 0;</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)"></p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)"><span style="color:rgb(255,0,0)">if (get_suspend_state () ==0) {</span></p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Input_event (ddata->input, ev_key, ddata->keycode, 1);</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Input_sync (ddata->input);</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Input_event (ddata->input, ev_key, ddata->keycode, 0);</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Input_sync (ddata->input);</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">}else if <span style="color:#ff0000">((get_suspend_state ()) && (ddata->keycode==key_power)</span>) {</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Input_event (ddata->input, ev_key, key_wakeup, 1);</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Input_sync (ddata->input);</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Input_event (ddata->input, ev_key, key_wakeup, 0);</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Input_sync (ddata->input);</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">}</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">}</p></p><p><p>          removal of filter conditions, and <span style="font-family:times New Roman">gpio </span> <span style=" Font-family: Song body "> the same effect as the physical keys connected, that is, regardless of the state of the system processing." The key value is uploaded for hibernation or wake-up status. At the same time this also brought me a doubt, the </span> <strong> key driver should not be <span style="font-family:times New Roman">suspend </span> <span style=" Font-family: The state inference of the song Body. Based on the experience of </span> <span style= " font-family:times new roman">android </span> <span style="font-family: arial"> All the states are Uploaded. Response not responding is a decision to look at the upper System. But suppose that for a normal embedded </span> <span style="font-family:times New Roman">linux </span> <span style="font-family: arial"> system is not necessarily, Suppose </span> <span style="font-family:times New Roman">input </span> <span style="font-family: arial"> The subsystem uploads the key value when the system sleeps. Then the corresponding application layer will be able to directly respond to the key Value. Which method to use, this is a </span> <span style="color:rgb (255,0,0)"> paradox </span> </strong>! The macros that combine <span style="font-family:times New Roman">android </span> <span style="font-family: arial" are implemented as follows: < span> </span></p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Diff--git a/drivers/input/remotectl/rkxx_remotectl.c B/DRIVERS/INPUT/REMOTECTL/RKXX_REMOTECTL.C</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Index Db91516: 201C5DD 100644</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">---a/drivers/input/remotectl/rkxx_remotectl.c</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">+ + B/DRIVERS/INPUT/REMOTECTL/RKXX_REMOTECTL.C</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)"><span style="color:rgb(0,153,204)">@@ -306,6 +306,10 @@ -306,6 <span style="color:rgb(0,204,255)"> </span>static void remotectl_do_something (unsigned long Data)</span></p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">if ((ddata->scandata&0x0ff) = = ((~ddata->scandata >> 8) &0x0ff) {</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">If (remotectl_keycode_lookup (ddata)) {</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Ddata->press = 1;</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)"><span style="color:rgb(0,128,0)">+ #ifdef Config_android//ANDROID OS needs input event whatever suspend state</span></p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)"><span style="color:rgb(0,128,0)">+ input_event (ddata->input, ev_key, ddata->keycode, 1);</span></p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)"><span style="color:rgb(0,128,0)">+ Input_sync (ddata->input);</span></p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)"><span style="color:rgb(0,128,0)">+ #else</span></p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">If (ddata->keycode==key_power | | get_suspend_state () ==pm_suspend_on) {</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Input_event (ddata->input, ev_key, ddata->keycode, 1);</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Input_sync (ddata->input);</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)"><span style="color:rgb(0,153,204)">@@ -314,6 +318,7 @@ -314,6 </span>void remotectl_do_something (unsigned long Data)</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">}</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Input_event (ddata->input, ev_key, ddata->keycode, ddata->press);</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Input_sync (ddata->input);</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)"><span style="color:rgb(51,153,102)">+ #endif//config_android</span></p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Ddata->state = rmc_sequence;</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">}else{</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Ddata->state = rmc_preload;</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)"><span style="color:rgb(0,153,204)">@@ -437,6 +442,10 @@ -437,6</span> void Remotectl_timer (unsigned long _data)</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">If (ddata->press! = ddata->pre_press) {</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">ddata->pre_press = Ddata->press = 0;</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)"></p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)"><span style="color:rgb(0,128,0)">+ #ifdef Config_android//ANDROID OS needs input event whatever suspend state</span></p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)"><span style="color:rgb(0,128,0)">+ input_event (ddata->input, ev_key, ddata->keycode, 0);</span></p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)"><span style="color:rgb(0,128,0)">+ Input_sync (ddata->input);</span></p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)"><span style="color:rgb(0,128,0)">+ #else</span></p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">If (get_suspend_state () ==0) {</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Input_event (ddata->input, ev_key, ddata->keycode, 1);</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Input_sync (ddata->input);</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)"><span style="color:rgb(0,153,204)">@@ -448,6 +457,7 @@ -448,6</span> void Remotectl_timer (unsigned long _data)</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Input_event (ddata->input, ev_key, key_wakeup, 0);</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Input_sync (ddata->input);</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">}</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)"><span style="color:rgb(0,128,0)">+ #endif//config_android</span></p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">}</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">#ifdef CONFIG_PM</p></p><p style="background:rgb(179,179,179)"><p style="background:rgb(179,179,179)">Remotectl_wakeup (_data);</p></p><p><p>Suppose it is an android System. <strong>then the key value is escalated in real time regardless of what sleep state the kernel Handles. </strong></p></p><p><p><strong>This ensures that the audio size is controlled when the music is played in Hibernation. This is how Android phones are now implemented</strong> .</p></p><p><p></p></p><p style="text-align:center"><p style="text-align:center">http://blog.csdn.net/kangear/article/details/40072707</p></p><p style="text-align:center"><p style="text-align:center"><span style="text-align:left"></span></p></p><p style="text-align:left"><p style="text-align:left"></p></p><p><p>Another point: the button in the shape <span style="font-family:‘Times New Roman‘">0</span><span style="font-family:宋体">, not</span> <span style="font-family:Times New Roman">input_sync (ddata->input);</span> <span style="font-family:宋体">emitted, It only emits the current Value. It's just a "sync," meaning that the data is ready to be sent. </span></p></p><p><p>There is still no clear understanding of the drive plus some of their own blind imagination misled themselves. The kernel <span style="font-family:Times New Roman">input</span> <span style="font-family:宋体">driver is not distinguished</span> by the <span style="font-family:Times New Roman">POWER</span> <span style="font-family:宋体">key,</span><span style="font-family:Times New Roman">WAKEUP</span> <span style="font-family:宋体">key; There is a difference, the problem must be in their own driver Code. </span></p></p><br> <p><p>Linux input subsystem for Android low-level development do not infer the system sleep state escalation key value</p></p></span>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.