diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2006-07-26 13:38:31 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2006-07-26 13:38:31 +0000 |
commit | 40a3fd6938962a13b4f73c77b2058942c2a9c701 (patch) | |
tree | d51d4f8b159591aecbd6030b21bc0968fb40e64c /firmware | |
parent | b98b895bab8c63c889f47a70b341d1ddfc585da9 (diff) |
Remote LCD communication driver for X5, very loosely based on patch FS#5634 by Rani Hod
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10331 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/SOURCES | 1 | ||||
-rwxr-xr-x | firmware/target/coldfire/iaudio/x5/backlight-target.h | 2 | ||||
-rwxr-xr-x | firmware/target/coldfire/iaudio/x5/backlight-x5.c | 10 | ||||
-rwxr-xr-x | firmware/target/coldfire/iaudio/x5/lcd-remote-target.h | 30 | ||||
-rwxr-xr-x | firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c | 177 |
5 files changed, 220 insertions, 0 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES index 7394c6abdf..bef54c0319 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES @@ -225,5 +225,6 @@ target/coldfire/iaudio/x5/system-x5.c target/coldfire/iaudio/x5/usb-x5.c target/coldfire/iaudio/x5/backlight-x5.c target/coldfire/iaudio/x5/m5636-x5.c +target/coldfire/iaudio/x5/lcd-remote-x5.c #endif #endif diff --git a/firmware/target/coldfire/iaudio/x5/backlight-target.h b/firmware/target/coldfire/iaudio/x5/backlight-target.h index 5b6f7e1f8f..262650ae24 100755 --- a/firmware/target/coldfire/iaudio/x5/backlight-target.h +++ b/firmware/target/coldfire/iaudio/x5/backlight-target.h @@ -21,5 +21,7 @@ void __backlight_on(void); void __backlight_off(void); +void __remote_backlight_on(void); +void __remote_backlight_off(void); #endif diff --git a/firmware/target/coldfire/iaudio/x5/backlight-x5.c b/firmware/target/coldfire/iaudio/x5/backlight-x5.c index 2b09d14b55..91c7224267 100755 --- a/firmware/target/coldfire/iaudio/x5/backlight-x5.c +++ b/firmware/target/coldfire/iaudio/x5/backlight-x5.c @@ -35,3 +35,13 @@ void __backlight_off(void) pcf50606_write(0x38, 0x80); /* Backlight OFF, GPO1INV=1, GPO1ACT=000 */ set_irq_level(level); } + +void __remote_backlight_on(void) +{ + and_l(~0x00200000, &GPIO_OUT); +} + +void __remote_backlight_off(void) +{ + or_l(0x00200000, &GPIO_OUT); +} diff --git a/firmware/target/coldfire/iaudio/x5/lcd-remote-target.h b/firmware/target/coldfire/iaudio/x5/lcd-remote-target.h new file mode 100755 index 0000000000..72d4ed9fb2 --- /dev/null +++ b/firmware/target/coldfire/iaudio/x5/lcd-remote-target.h @@ -0,0 +1,30 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 by Linus Nielsen Feltzing + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef LCD_REMOTE_TARGET_H +#define LCD_REMOTE_TARGET_H + +void lcd_remote_write_command(int cmd); +void lcd_remote_write_command_ex(int cmd, int data); +void lcd_remote_write_data(const unsigned char* p_bytes, int count); +bool remote_detect(void); +void lcd_remote_powersave(bool on); +void lcd_remote_set_contrast(int val); +void remote_set_row_and_col(int row, int col); + +#endif diff --git a/firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c b/firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c new file mode 100755 index 0000000000..c1ec00f0e7 --- /dev/null +++ b/firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c @@ -0,0 +1,177 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 by Linus Nielsen Feltzing + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "config.h" +#include "system.h" +#include "kernel.h" + +/* The LCD in the iAudio M3/M5/X5 remote control is a Tomato LSI 0350 */ + +#define LCD_SET_DUTY_RATIO 0x48 +#define LCD_SELECT_ADC 0xa0 +#define LCD_SELECT_SHL 0xc0 +#define LCD_SET_COM0 0x44 +#define LCD_OSC_ON 0xab +#define LCD_SELECT_DCDC 0x64 +#define LCD_SELECT_RES 0x20 +#define LCD_SET_VOLUME 0x81 +#define LCD_SET_BIAS 0x50 +#define LCD_CONTROL_POWER 0x28 +#define LCD_DISPLAY_ON 0xae +#define LCD_SET_INITLINE 0x40 +#define LCD_SET_COLUMN 0x10 +#define LCD_SET_PAGE 0xb0 +#define LCD_SET_GRAY 0x88 +#define LCD_SET_PWM_FRC 0x90 +#define LCD_SET_POWER_SAVE 0xa8 + +#define CS_LO and_l(~0x00000020, &GPIO1_OUT) +#define CS_HI or_l(0x00000020, &GPIO1_OUT) +#define CLK_LO and_l(~0x00004000, &GPIO_OUT) +#define CLK_HI or_l(0x00004000, &GPIO_OUT) +#define DATA_LO and_l(~0x00002000, &GPIO_OUT) +#define DATA_HI or_l(0x00002000, &GPIO_OUT) +#define RS_LO and_l(~0x00008000, &GPIO_OUT) +#define RS_HI or_l(0x00008000, &GPIO_OUT) + +#define LCD_REMOTE_DEFAULT_CONTRAST 0x18; + +static int cached_contrast = LCD_REMOTE_DEFAULT_CONTRAST; +static bool remote_initialized = false; + +static void remote_write(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; +} + +void lcd_remote_write_command(int cmd) +{ + remote_write(cmd, true); +} + +void lcd_remote_write_command_ex(int cmd, int data) +{ + remote_write(cmd, true); + remote_write(data, true); +} + +void lcd_remote_write_data(const unsigned char* p_bytes, int count) +{ + while(count--) + remote_write(*p_bytes++, false); +} + +void remote_set_row_and_col(int row, int col) +{ + lcd_remote_write_command(LCD_SET_PAGE | (row & 0xf)); + lcd_remote_write_command_ex(LCD_SET_COLUMN | ((col >> 4) & 0xf), + col & 0xf); +} + +int lcd_remote_default_contrast(void) +{ + return LCD_REMOTE_DEFAULT_CONTRAST; +} + +void lcd_remote_powersave(bool on) +{ + if (on) + lcd_remote_write_command(LCD_SET_POWER_SAVE | 1); + else + lcd_remote_write_command(LCD_SET_POWER_SAVE | 1); +} + +void lcd_remote_set_contrast(int val) +{ + cached_contrast = val; + lcd_remote_write_command_ex(LCD_SET_VOLUME, val); +} + +bool remote_detect(void) +{ + return (GPIO_READ & 0x01000000); +} + +void remote_init(void) +{ + or_l(0x0000e000, &GPIO_OUT); + or_l(0x0000e000, &GPIO_ENABLE); + or_l(0x0000e000, &GPIO_FUNCTION); + + or_l(0x00000020, &GPIO1_OUT); + or_l(0x00000020, &GPIO1_ENABLE); + or_l(0x00000020, &GPIO1_FUNCTION); + + sleep(10); + + lcd_remote_write_command(LCD_SET_DUTY_RATIO); + lcd_remote_write_command(0x70); /* 1/128 */ + + lcd_remote_write_command(LCD_SELECT_ADC | 1); /* Reverse direction */ + lcd_remote_write_command(LCD_SELECT_SHL | 8); /* Reverse direction */ + + lcd_remote_write_command(LCD_SET_COM0); + lcd_remote_write_command(0x00); + + lcd_remote_write_command(LCD_OSC_ON); + + lcd_remote_write_command(LCD_SELECT_DCDC | 2); /* DC/DC 5xboost */ + + lcd_remote_write_command(LCD_SELECT_RES | 7); /* Regulator resistor: 7.2 */ + + lcd_remote_write_command(LCD_SET_BIAS | 6); /* 1/11 */ + + lcd_remote_write_command(LCD_CONTROL_POWER | 7); /* All circuits ON */ + + sleep(30); + + lcd_remote_write_command_ex(LCD_SET_GRAY | 0, 0x00); + lcd_remote_write_command_ex(LCD_SET_GRAY | 1, 0x00); + lcd_remote_write_command_ex(LCD_SET_GRAY | 2, 0x0c); + lcd_remote_write_command_ex(LCD_SET_GRAY | 3, 0x00); + lcd_remote_write_command_ex(LCD_SET_GRAY | 4, 0xcc); + lcd_remote_write_command_ex(LCD_SET_GRAY | 5, 0x00); + lcd_remote_write_command_ex(LCD_SET_GRAY | 6, 0xcc); + lcd_remote_write_command_ex(LCD_SET_GRAY | 7, 0x0c); + + lcd_remote_write_command(LCD_SET_PWM_FRC | 6); /* 4FRC + 12PWM */ + + lcd_remote_write_command(LCD_DISPLAY_ON | 1); /* display on */ + + remote_initialized = true; + + lcd_remote_set_contrast(cached_contrast); +} |