summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/imx233/creative-zen
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2013-11-18 15:08:53 +0000
committerAmaury Pouly <amaury.pouly@gmail.com>2013-11-18 21:44:05 +0000
commita8b816ae9cc00fe216e43d9bd9276b5d8cf12b25 (patch)
tree729e7ad4ecf5b9a608177c37e7199cbac994bd0b /firmware/target/arm/imx233/creative-zen
parentb770f639346fa8a40d07b9dcc66b3e378210b0a9 (diff)
downloadrockbox-a8b816ae9cc00fe216e43d9bd9276b5d8cf12b25.tar.gz
rockbox-a8b816ae9cc00fe216e43d9bd9276b5d8cf12b25.zip
creativezenmozaic: factor out code with the zen/zenxfi
Most of the code is similar, only the lcd driver is significantly different. Change-Id: I9eab1faf08d2356f2d820d6930ef3b0653349aa1
Diffstat (limited to 'firmware/target/arm/imx233/creative-zen')
-rw-r--r--firmware/target/arm/imx233/creative-zen/button-zen.c20
-rw-r--r--firmware/target/arm/imx233/creative-zen/lcd-zenmozaic.c152
-rw-r--r--firmware/target/arm/imx233/creative-zen/power-zen.c20
3 files changed, 190 insertions, 2 deletions
diff --git a/firmware/target/arm/imx233/creative-zen/button-zen.c b/firmware/target/arm/imx233/creative-zen/button-zen.c
index cacc47d448..1997f91357 100644
--- a/firmware/target/arm/imx233/creative-zen/button-zen.c
+++ b/firmware/target/arm/imx233/creative-zen/button-zen.c
@@ -57,6 +57,19 @@ struct imx233_button_lradc_mapping_t imx233_button_lradc_mapping[] =
{2945, BUTTON_PLAYPAUSE},
{3400, 0},
{0, IMX233_BUTTON_LRADC_END},
+#elif defined(CREATIVE_ZENMOZAIC)
+ {0, IMX233_BUTTON_LRADC_HOLD},
+ {200, BUTTON_MENU},
+ {445, BUTTON_SHORTCUT},
+ {645, BUTTON_UP},
+ {860, BUTTON_LEFT},
+ {1060, BUTTON_RIGHT},
+ {1260, BUTTON_DOWN},
+ {1480, BUTTON_SELECT},
+ {2700, BUTTON_BACK},
+ {2945, BUTTON_PLAYPAUSE},
+ {3400, 0},
+ {0, IMX233_BUTTON_LRADC_END},
#else
#error wrong target
#endif
@@ -65,6 +78,11 @@ struct imx233_button_lradc_mapping_t imx233_button_lradc_mapping[] =
void button_init_device(void)
{
imx233_button_lradc_init();
+#if defined(CREATIVE_ZENXFI) || defined(CREATIVE_ZENMOZAIC)
+ imx233_pinctrl_acquire(2, 8, "jack_detect");
+ imx233_pinctrl_set_function(2, 8, PINCTRL_FUNCTION_GPIO);
+ imx233_pinctrl_enable_gpio(2, 8, false);
+#endif
}
bool button_hold(void)
@@ -72,7 +90,7 @@ bool button_hold(void)
return imx233_button_lradc_hold();
}
-#ifdef CREATIVE_ZENXFI
+#if defined(CREATIVE_ZENXFI) || defined(CREATIVE_ZENMOZAIC)
bool headphones_inserted(void)
{
return !imx233_pinctrl_get_gpio(2, 8);
diff --git a/firmware/target/arm/imx233/creative-zen/lcd-zenmozaic.c b/firmware/target/arm/imx233/creative-zen/lcd-zenmozaic.c
new file mode 100644
index 0000000000..eac36676ae
--- /dev/null
+++ b/firmware/target/arm/imx233/creative-zen/lcd-zenmozaic.c
@@ -0,0 +1,152 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (c) 2013 by Amaury Pouly
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include <sys/types.h> /* off_t */
+#include <string.h>
+#include "cpu.h"
+#include "system.h"
+#include "backlight-target.h"
+#include "lcd.h"
+#include "lcdif-imx233.h"
+#include "clkctrl-imx233.h"
+#include "pinctrl-imx233.h"
+#include "dcp-imx233.h"
+#include "logf.h"
+#ifndef BOOTLOADER
+#include "button.h"
+#include "font.h"
+#include "action.h"
+#endif
+
+#ifdef HAVE_LCD_ENABLE
+static bool lcd_on;
+#endif
+
+static void lcd_write_reg(uint16_t reg, uint16_t value)
+{
+ imx233_lcdif_set_data_swizzle(3);
+ imx233_lcdif_pio_send(false, 2, &reg);
+ if(reg != 0x22)
+ imx233_lcdif_pio_send(true, 2, &value);
+}
+
+void lcd_init_device(void)
+{
+ /* clock at 24MHZ */
+ imx233_clkctrl_enable(CLK_PIX, false);
+ imx233_clkctrl_set_div(CLK_PIX, 3);
+ imx233_clkctrl_set_bypass(CLK_PIX, true); /* use XTAL */
+ imx233_clkctrl_enable(CLK_PIX, true);
+ imx233_lcdif_init();
+ imx233_lcdif_setup_system_pins(8);
+ imx233_lcdif_set_timings(2, 2, 2, 2);
+ imx233_lcdif_set_word_length(8);
+
+ lcd_write_reg(0, 1);
+ lcd_write_reg(3, 0);
+
+ lcd_write_reg(3, 0x510);
+ lcd_write_reg(9, 8);
+ lcd_write_reg(0xc, 0);
+ lcd_write_reg(0xd, 0);
+ lcd_write_reg(0xe, 0);
+ lcd_write_reg(0x5b, 4);
+ lcd_write_reg(0xd, 0x10);
+ lcd_write_reg(9, 0);
+ lcd_write_reg(3, 0x10);
+ lcd_write_reg(0xd, 0x14);
+ lcd_write_reg(0xe, 0x2b12);
+ lcd_write_reg(1, 0x21f);
+ lcd_write_reg(2, 0x700);
+ lcd_write_reg(5, 0x30);
+ lcd_write_reg(6, 0);
+ lcd_write_reg(8, 0x202);
+ lcd_write_reg(0xa, 0x3); // OF uses 0xc0003 with 3 transfers/pixels
+ lcd_write_reg(0xb, 0);
+ lcd_write_reg(0xf, 0);
+ lcd_write_reg(0x10, 0);
+ lcd_write_reg(0x11, 0);
+ lcd_write_reg(0x14, 0x9f00);
+ lcd_write_reg(0x15, 0x9f00);
+ lcd_write_reg(0x16, 0x7f00);
+ lcd_write_reg(0x17, 0x9f00);
+ lcd_write_reg(0x20, 0);
+ lcd_write_reg(0x21, 0);
+ lcd_write_reg(0x23, 0);
+ lcd_write_reg(0x24, 0);
+ lcd_write_reg(0x25, 0);
+ lcd_write_reg(0x26, 0);
+ lcd_write_reg(0x30, 0x707);
+ lcd_write_reg(0x31, 0x504);
+ lcd_write_reg(0x32, 7);
+ lcd_write_reg(0x33, 0x307);
+ lcd_write_reg(0x34, 7);
+ lcd_write_reg(0x35, 0x400);
+ lcd_write_reg(0x36, 0x607);
+ lcd_write_reg(0x37, 0x703);
+ lcd_write_reg(0x3a, 0x1a0d);
+ lcd_write_reg(0x3b, 0x1309);
+
+ lcd_write_reg(9, 4);
+ lcd_write_reg(7, 5);
+ lcd_write_reg(7, 0x25);
+ lcd_write_reg(7, 0x27);
+ lcd_write_reg(0x5b, 0);
+ lcd_write_reg(7, 0x37);
+#ifdef HAVE_LCD_ENABLE
+ lcd_on = true;
+#endif
+}
+
+#ifdef HAVE_LCD_ENABLE
+bool lcd_active(void)
+{
+ return lcd_on;
+}
+
+void lcd_enable(bool enable)
+{
+ if(lcd_on == enable)
+ return;
+
+ lcd_on = enable;
+}
+#endif
+
+void lcd_update(void)
+{
+ lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
+}
+
+void lcd_update_rect(int x, int y, int w, int h)
+{
+ #ifdef HAVE_LCD_ENABLE
+ if(!lcd_on)
+ return;
+ #endif
+
+ imx233_lcdif_wait_ready();
+ lcd_write_reg(0x16, x | (x + w - 1) << 8);
+ lcd_write_reg(0x17, y | (y + h - 1) << 8);
+ lcd_write_reg(0x21, y * LCD_WIDTH + x);
+ lcd_write_reg(0x22, 0);
+ for(int yy = y; yy < y + h; yy++)
+ imx233_lcdif_pio_send(true, 2 * w, FBADDR(x, yy));
+}
diff --git a/firmware/target/arm/imx233/creative-zen/power-zen.c b/firmware/target/arm/imx233/creative-zen/power-zen.c
index 81157da511..2c68325432 100644
--- a/firmware/target/arm/imx233/creative-zen/power-zen.c
+++ b/firmware/target/arm/imx233/creative-zen/power-zen.c
@@ -27,11 +27,29 @@
#include "power-imx233.h"
static bool tuner_enable = false;
+static bool initialised = false;
+
+static void init(void)
+{
+#ifdef CREATIVE_ZENMOZAIC
+ /* CE is B2P15 (active high) */
+ imx233_pinctrl_acquire(2, 15, "tuner power");
+ imx233_pinctrl_set_function(2, 15, PINCTRL_FUNCTION_GPIO);
+ imx233_pinctrl_enable_gpio(2, 15, true);
+#endif
+ initialised = true;
+}
bool tuner_power(bool enable)
{
- if(enable != tuner_enable)
+ if(!initialised)
+ init();
+ if(tuner_enable != enable)
{
+#ifdef CREATIVE_ZENMOZAIC
+ imx233_pinctrl_set_gpio(2, 15, enable);
+ sleep(HZ / 5);
+#endif
tuner_enable = enable;
}
return tuner_enable;