Rockbox.org home
Downloads
Release release
Dev builds dev builds
Extras extras
themes themes
Documentation
Manual manual
Wiki wiki
Device Status device status
Support
Forums forums
Mailing lists mailing lists
IRC IRC
Development
Bugs bugs
Patches patches
Dev Guide dev guide
Search



Donate

Rockbox Technical Forums


Login with username, password and session length
Home Help Search Staff List Login Register
News:

Rockbox Ports are now being developed for various digital audio players!

+  Rockbox Technical Forums
|-+  Support and General Use
| |-+  Hardware
| | |-+  Remote LCD Display Code Suggestion
« previous next »
  • Print
Pages: [1]

Author Topic: Remote LCD Display Code Suggestion  (Read 2478 times)

Offline Eriol

  • Member
  • *
  • Posts: 12
Remote LCD Display Code Suggestion
« on: July 26, 2006, 02:50:39 PM »
In the recent (today's) update, there was some preliminary writer code committed.  Awesome.  Hope to test some of it myself one of these days.  But there was one thing that struck me as a bit... inefficient: every time you write one byte, there's a function call.  Now for the commands, I can live with it, as those are generally short sequences anyways.  But it's the array one that I believe could be improved so that you don't have to jump in/out of functions for every single byte.  Though at the same time, I think that inlining EVERY call to updating the display could get rather large in the code.  The command and single-writes do NOT need to be inlined.  And I don't want two copies of the functional part of the remote_write() function, one inline, one not in the code.

So I propose a non-inline "wrapper" to an inline functional part.  What I mean is below:
Code: [Select]
// Taken from: * $Id: lcd-remote-x5.c,v 1.1 2006/07/26 13:38:31 linus Exp $
// ... Code above omitted

static void remote_write(unsigned char byte, bool is_command)
{
    remote_write_inlined(byte, is_command);
}

inline static void remote_write_inlined(unsigned char byte, bool is_command)
{
    int i;
 
    CS_LO;
    if (is_command)
  RS_LO;
    else
        RS_HI;
 
    for (i = 0x80; i; i >>= 1)
    {
        CLK_LO;
        if (i & byte)
            DATA_HI;
        else
            DATA_LO;
        CLK_HI;
    }

    CS_HI;
}

// Other functions here omitted

void lcd_remote_write_data(const unsigned char* p_bytes, int count)
{
    while(count--)
        remote_write_inlined(*p_bytes++, false);
}
// ... Rest of code after this.
Basically, this is all that would change.  A non-inline "wrapper" that would compile out to EXACTLY what we have now, and inlining the function where it is called continually.  We keep only one block of text in the source that does actual writing, but preserve the efficiency of an inline function, while also not polluting ALL the calls with inlines.  And the rest of the code "should" work exactly the same.

I don't have an environment set up (I really do have to get around to that... keep bugging me.  ;) ), but if somebody else could check this out, and/or give an opinion on it, please speak up.  I just see making a function call on every write in a continual write operation as grossly inefficient, and offending my coding sensibilities, whereas a macro clearly could create other problems.  I think this is a better solution.

Edit: bah.  Missed a bracket on original post, and 2nd edit is for another typo.
« Last Edit: July 26, 2006, 04:49:16 PM by Eriol »
Logged

Offline LinusN

  • Member
  • *
  • Posts: 1914
Re: Remote LCD Display Code Suggestion
« Reply #1 on: July 26, 2006, 04:34:47 PM »
Thanks for the heads up.

The X5 remote LCD code is just a proof-of-concept to get the ball rolling. We will soon change it to the asm optimized version seen in firmware/drivers/lcd-h100-remote.c, which is far better.
Logged
Archos Jukebox 6000, Recorder, FM Recorder/iAudio X5/iriver H1x0, H3x0/Toshiba Gigabeat F20/iPod G5, G5.5

Offline Eriol

  • Member
  • *
  • Posts: 12
Re: Remote LCD Display Code Suggestion
« Reply #2 on: July 26, 2006, 04:48:50 PM »
Quote from: LinusN on July 26, 2006, 04:34:47 PM
The X5 remote LCD code is just a proof-of-concept to get the ball rolling. We will soon change it to the asm optimized version seen in firmware/drivers/lcd-h100-remote.c, which is far better.
Ah, I see that.  They're both 68k processors, so shouldn't be radically different (hopefully).  Been a while since I did 68k asm myself, so I'll leave that for others until I re-aquaint myself.

Thanks for looking at it.
Logged

Offline jhMikeS

  • Developer
  • Member
  • *
  • Posts: 242
Re: Remote LCD Display Code Suggestion
« Reply #3 on: August 02, 2006, 03:44:12 PM »
This was something I kind of looked forward to working on but I don't want to duplicate efforts (got other stuff to wrap up too). There's no button interface yet either (right)?

We're going to use all four gray shades I hope. I didn't actually look yet if it does.  ::)
Logged

Offline LinusN

  • Member
  • *
  • Posts: 1914
Re: Remote LCD Display Code Suggestion
« Reply #4 on: August 02, 2006, 03:51:01 PM »
Quote from: MikeS on August 02, 2006, 03:44:12 PM
This was something I kind of looked forward to working on but I don't want to duplicate efforts (got other stuff to wrap up too). There's no button interface yet either (right)?
The button driver is there and it works. The only thing that is missing is mapping the buttons to actions. That will be done as soon as we commit the new action-based button handling.

Quote
We're going to use all four gray shades I hope. I didn't actually look yet if it does.  ::)
Yes it does.
Logged
Archos Jukebox 6000, Recorder, FM Recorder/iAudio X5/iriver H1x0, H3x0/Toshiba Gigabeat F20/iPod G5, G5.5

  • Print
Pages: [1]
« previous next »
+  Rockbox Technical Forums
|-+  Support and General Use
| |-+  Hardware
| | |-+  Remote LCD Display Code Suggestion
 

  • SMF 2.0.17 | SMF © 2019, Simple Machines
  • Rockbox Privacy Policy
  • XHTML
  • RSS
  • WAP2

Page created in 0.076 seconds with 15 queries.