<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Jun 20, 2015 at 1:07 PM, Joseph Fry <span dir="ltr"><<a href="mailto:joe@thefrys.com" target="_blank">joe@thefrys.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Sat, Jun 20, 2015 at 12:55 PM, Gary Buhrmaster <span dir="ltr"><<a href="mailto:gary.buhrmaster@gmail.com" target="_blank">gary.buhrmaster@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">On Sat, Jun 20, 2015 at 4:23 PM, Joseph Fry <<a href="mailto:joe@thefrys.com" target="_blank">joe@thefrys.com</a>> wrote:<br>
.....<br>
<span>> In the function description you see that it says it returns a negative error<br>
> number, or the number of bytes written.  If you look at the actual return<br>
> statement, it's returning the count (or the error from i2c_transfer).<br>
><br>
> I think I need to patch lirc_zilog:<br>
><br>
> for (i = 0; i < 10; i++) {<br>
> ret = i2c_master_send(tx->c, buf, 1);<br>
> - if (ret == 1)<br>
> + if (ret > 0)<br>
> break;<br>
> udelay(100);<br>
> }<br>
><br>
> Can anyone confirm my conclusion?  My programming skills are limited to<br>
> scripts... so this is new territory for me.<br>
<br>
</span>Since the return is the count, and you only send 1 character,<br>
a "successful" send would be the count passed in, or 1.<br>
<br>
So, while you may be on the right track, this does not seem<br>
to be the bug you are looking for (and btw, if you write <n><br>
bytes, if the return is not <n>, you need to handle the short<br>
write case in some form, as the code immediately above<br>
does for a return not equal to the 2 case.).</blockquote><div><br></div></span><div>I just tested this... and indeed your right.  I added in some debug output and see that the pause is occuring after the "sent code..." message.  And I was able to confirm that i2c_master_send is returning 1 every time.</div><div><br></div><div>so... time to keep digging. </div></div></div></div>
</blockquote></div><br></div><div class="gmail_extra">Ok... here is where I am now.</div><div class="gmail_extra"><br></div><div class="gmail_extra">When sending a button, lirc_zlog reports this to syslog (with debugging enabled):</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">Jun 20 14:03:13 mythserver kernel: [10341.776138] lirc_zilog: 01 60 7e a2 d9</div><div class="gmail_extra">Jun 20 14:03:13 mythserver kernel: [10341.795537] lirc_zilog: 05 49 0e 48 91lirc_zilog: 09 77 d6 3d 09</div><div class="gmail_extra">Jun 20 14:03:13 mythserver kernel: [10341.835569] lirc_zilog: 0d 44 18 60 f1lirc_zilog: 11 32 c6 e9 bb</div><div class="gmail_extra">Jun 20 14:03:14 mythserver kernel: [10341.875489] lirc_zilog: 15 2f c5 4a e3lirc_zilog: 19 b9 a0 48 a2</div><div class="gmail_extra">Jun 20 14:03:14 mythserver kernel: [10341.915157] lirc_zilog: 1d 7d 81 59 90lirc_zilog: 21 28 0d 48 69</div><div class="gmail_extra">Jun 20 14:03:14 mythserver kernel: [10341.955083] lirc_zilog: 25 10 c4 78 78lirc_zilog: 29 27 51 1e 71</div><div class="gmail_extra">Jun 20 14:03:14 mythserver kernel: [10341.995125] lirc_zilog: 2d 09 de 13 c5lirc_zilog: 31 18 d2 56 36</div><div class="gmail_extra">Jun 20 14:03:14 mythserver kernel: [10342.034793] lirc_zilog: 35 8e 59 93 6blirc_zilog: 39 9c f1 d5 e5</div><div class="gmail_extra">Jun 20 14:03:14 mythserver kernel: [10342.074715] lirc_zilog: 3d cf c4 ba 05lirc_zilog: 41 cb 81 e5 26</div><div class="gmail_extra">Jun 20 14:03:14 mythserver kernel: [10342.115762] lirc_zilog: 45 f3 f1 b7 6elirc_zilog: 49 88 29 c2 f6</div><div class="gmail_extra">Jun 20 14:03:14 mythserver kernel: [10342.155681] lirc_zilog: 4d bb e7 9f 1alirc_zilog: 51 ed 39 93 45</div><div class="gmail_extra">Jun 20 14:03:14 mythserver kernel: [10342.195353] lirc_zilog: 55 cd 3b d9 1clirc_zilog: 59 89 fe b7 5d</div><div class="gmail_extra">Jun 20 14:03:14 mythserver kernel: [10342.235402] lirc_zilog: 5d 82 7e 44 a1lirc_zilog: 61 00 00 00 a1</div><div class="gmail_extra">Jun 20 14:03:14 mythserver kernel: [10342.327126] lirc_zilog: sent code 130, key 2</div><div class="gmail_extra"><br></div><div class="gmail_extra">Only after that does the led flash.  And while all the above happens quickly, it does take some time.</div><div class="gmail_extra"><br></div><div class="gmail_extra">I am sure there is a good reason for it, but zilog is breaking the data up in to 32bit chunks and sending them one chunk at a time, prefixing them with 1 byte that indicates where in the stream they are... first block starts at 01, next is 05, and so on.  </div><div class="gmail_extra"><br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_extra"><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace">static int send_data_block(struct IR_tx *tx, unsigned char *data_block)</font></div></div></div><div class="gmail_extra"><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace">{</font></div></div></div><div class="gmail_extra"><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace"><span class="" style="white-space:pre">      </span>int i, j, ret;</font></div></div></div><div class="gmail_extra"><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace"><span class="" style="white-space:pre">      </span>unsigned char buf[5];</font></div></div></div><div class="gmail_extra"><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace"><br></font></div></div></div><div class="gmail_extra"><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace"><span class="" style="white-space:pre">       </span>for (i = 0; i < TX_BLOCK_SIZE;) {</font></div></div></div><div class="gmail_extra"><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace"><span class="" style="white-space:pre">                </span>int tosend = TX_BLOCK_SIZE - i;</font></div></div></div><div class="gmail_extra"><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace"><span class="" style="white-space:pre">             </span>if (tosend > 4)</font></div></div></div><div class="gmail_extra"><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace"><span class="" style="white-space:pre">                  </span>tosend = 4;</font></div></div></div><div class="gmail_extra"><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace"><span class="" style="white-space:pre">         </span>buf[0] = (unsigned char)(i + 1);</font></div></div></div><div class="gmail_extra"><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace"><span class="" style="white-space:pre">            </span>for (j = 0; j < tosend; ++j)</font></div></div></div><div class="gmail_extra"><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace"><span class="" style="white-space:pre">                     </span>buf[1 + j] = data_block[i + j];</font></div></div></div><div class="gmail_extra"><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace"><span class="" style="white-space:pre">             </span>dprintk("%*ph", 5, buf);</font></div></div></div><div class="gmail_extra"><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace"><span class="" style="white-space:pre">          </span>ret = i2c_master_send(tx->c, buf, tosend + 1);</font></div></div></div><div class="gmail_extra"><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace"><span class="" style="white-space:pre">           </span>if (ret != tosend + 1) {</font></div></div></div><div class="gmail_extra"><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace"><span class="" style="white-space:pre">                    </span>zilog_error("i2c_master_send failed with %d\n", ret);</font></div></div></div><div class="gmail_extra"><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace"><span class="" style="white-space:pre">                     </span>return ret < 0 ? ret : -EFAULT;</font></div></div></div><div class="gmail_extra"><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace"><span class="" style="white-space:pre">          </span>}</font></div></div></div><div class="gmail_extra"><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace"><span class="" style="white-space:pre">           </span>i += tosend;</font></div></div></div><div class="gmail_extra"><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace"><span class="" style="white-space:pre">        </span>}</font></div></div></div><div class="gmail_extra"><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace"><span class="" style="white-space:pre">   </span>return 0;</font></div></div></div><div class="gmail_extra"><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace">}</font></div></div></div></blockquote><div class="gmail_extra"><div><br></div></div><div class="gmail_extra">I know that i2c_master_send can handle up to 64k... so I think I may try and force it to send everything in one go rather than breaking it up.  I doubt it will work, but it would be interesting if it did.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Beyond that, I can't see anything else to do to make this faster.</div></div>