summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx233/creative-zen
diff options
context:
space:
mode:
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[] =
57 {2945, BUTTON_PLAYPAUSE}, 57 {2945, BUTTON_PLAYPAUSE},
58 {3400, 0}, 58 {3400, 0},
59 {0, IMX233_BUTTON_LRADC_END}, 59 {0, IMX233_BUTTON_LRADC_END},
60#elif defined(CREATIVE_ZENMOZAIC)
61 {0, IMX233_BUTTON_LRADC_HOLD},
62 {200, BUTTON_MENU},
63 {445, BUTTON_SHORTCUT},
64 {645, BUTTON_UP},
65 {860, BUTTON_LEFT},
66 {1060, BUTTON_RIGHT},
67 {1260, BUTTON_DOWN},
68 {1480, BUTTON_SELECT},
69 {2700, BUTTON_BACK},
70 {2945, BUTTON_PLAYPAUSE},
71 {3400, 0},
72 {0, IMX233_BUTTON_LRADC_END},
60#else 73#else
61#error wrong target 74#error wrong target
62#endif 75#endif
@@ -65,6 +78,11 @@ struct imx233_button_lradc_mapping_t imx233_button_lradc_mapping[] =
65void button_init_device(void) 78void button_init_device(void)
66{ 79{
67 imx233_button_lradc_init(); 80 imx233_button_lradc_init();
81#if defined(CREATIVE_ZENXFI) || defined(CREATIVE_ZENMOZAIC)
82 imx233_pinctrl_acquire(2, 8, "jack_detect");
83 imx233_pinctrl_set_function(2, 8, PINCTRL_FUNCTION_GPIO);
84 imx233_pinctrl_enable_gpio(2, 8, false);
85#endif
68} 86}
69 87
70bool button_hold(void) 88bool button_hold(void)
@@ -72,7 +90,7 @@ bool button_hold(void)
72 return imx233_button_lradc_hold(); 90 return imx233_button_lradc_hold();
73} 91}
74 92
75#ifdef CREATIVE_ZENXFI 93#if defined(CREATIVE_ZENXFI) || defined(CREATIVE_ZENMOZAIC)
76bool headphones_inserted(void) 94bool headphones_inserted(void)
77{ 95{
78 return !imx233_pinctrl_get_gpio(2, 8); 96 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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (c) 2013 by Amaury Pouly
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include <sys/types.h> /* off_t */
22#include <string.h>
23#include "cpu.h"
24#include "system.h"
25#include "backlight-target.h"
26#include "lcd.h"
27#include "lcdif-imx233.h"
28#include "clkctrl-imx233.h"
29#include "pinctrl-imx233.h"
30#include "dcp-imx233.h"
31#include "logf.h"
32#ifndef BOOTLOADER
33#include "button.h"
34#include "font.h"
35#include "action.h"
36#endif
37
38#ifdef HAVE_LCD_ENABLE
39static bool lcd_on;
40#endif
41
42static void lcd_write_reg(uint16_t reg, uint16_t value)
43{
44 imx233_lcdif_set_data_swizzle(3);
45 imx233_lcdif_pio_send(false, 2, &reg);
46 if(reg != 0x22)
47 imx233_lcdif_pio_send(true, 2, &value);
48}
49
50void lcd_init_device(void)
51{
52 /* clock at 24MHZ */
53 imx233_clkctrl_enable(CLK_PIX, false);
54 imx233_clkctrl_set_div(CLK_PIX, 3);
55 imx233_clkctrl_set_bypass(CLK_PIX, true); /* use XTAL */
56 imx233_clkctrl_enable(CLK_PIX, true);
57 imx233_lcdif_init();
58 imx233_lcdif_setup_system_pins(8);
59 imx233_lcdif_set_timings(2, 2, 2, 2);
60 imx233_lcdif_set_word_length(8);
61
62 lcd_write_reg(0, 1);
63 lcd_write_reg(3, 0);
64
65 lcd_write_reg(3, 0x510);
66 lcd_write_reg(9, 8);
67 lcd_write_reg(0xc, 0);
68 lcd_write_reg(0xd, 0);
69 lcd_write_reg(0xe, 0);
70 lcd_write_reg(0x5b, 4);
71 lcd_write_reg(0xd, 0x10);
72 lcd_write_reg(9, 0);
73 lcd_write_reg(3, 0x10);
74 lcd_write_reg(0xd, 0x14);
75 lcd_write_reg(0xe, 0x2b12);
76 lcd_write_reg(1, 0x21f);
77 lcd_write_reg(2, 0x700);
78 lcd_write_reg(5, 0x30);
79 lcd_write_reg(6, 0);
80 lcd_write_reg(8, 0x202);
81 lcd_write_reg(0xa, 0x3); // OF uses 0xc0003 with 3 transfers/pixels
82 lcd_write_reg(0xb, 0);
83 lcd_write_reg(0xf, 0);
84 lcd_write_reg(0x10, 0);
85 lcd_write_reg(0x11, 0);
86 lcd_write_reg(0x14, 0x9f00);
87 lcd_write_reg(0x15, 0x9f00);
88 lcd_write_reg(0x16, 0x7f00);
89 lcd_write_reg(0x17, 0x9f00);
90 lcd_write_reg(0x20, 0);
91 lcd_write_reg(0x21, 0);
92 lcd_write_reg(0x23, 0);
93 lcd_write_reg(0x24, 0);
94 lcd_write_reg(0x25, 0);
95 lcd_write_reg(0x26, 0);
96 lcd_write_reg(0x30, 0x707);
97 lcd_write_reg(0x31, 0x504);
98 lcd_write_reg(0x32, 7);
99 lcd_write_reg(0x33, 0x307);
100 lcd_write_reg(0x34, 7);
101 lcd_write_reg(0x35, 0x400);
102 lcd_write_reg(0x36, 0x607);
103 lcd_write_reg(0x37, 0x703);
104 lcd_write_reg(0x3a, 0x1a0d);
105 lcd_write_reg(0x3b, 0x1309);
106
107 lcd_write_reg(9, 4);
108 lcd_write_reg(7, 5);
109 lcd_write_reg(7, 0x25);
110 lcd_write_reg(7, 0x27);
111 lcd_write_reg(0x5b, 0);
112 lcd_write_reg(7, 0x37);
113#ifdef HAVE_LCD_ENABLE
114 lcd_on = true;
115#endif
116}
117
118#ifdef HAVE_LCD_ENABLE
119bool lcd_active(void)
120{
121 return lcd_on;
122}
123
124void lcd_enable(bool enable)
125{
126 if(lcd_on == enable)
127 return;
128
129 lcd_on = enable;
130}
131#endif
132
133void lcd_update(void)
134{
135 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
136}
137
138void lcd_update_rect(int x, int y, int w, int h)
139{
140 #ifdef HAVE_LCD_ENABLE
141 if(!lcd_on)
142 return;
143 #endif
144
145 imx233_lcdif_wait_ready();
146 lcd_write_reg(0x16, x | (x + w - 1) << 8);
147 lcd_write_reg(0x17, y | (y + h - 1) << 8);
148 lcd_write_reg(0x21, y * LCD_WIDTH + x);
149 lcd_write_reg(0x22, 0);
150 for(int yy = y; yy < y + h; yy++)
151 imx233_lcdif_pio_send(true, 2 * w, FBADDR(x, yy));
152}
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 @@
27#include "power-imx233.h" 27#include "power-imx233.h"
28 28
29static bool tuner_enable = false; 29static bool tuner_enable = false;
30static bool initialised = false;
31
32static void init(void)
33{
34#ifdef CREATIVE_ZENMOZAIC
35 /* CE is B2P15 (active high) */
36 imx233_pinctrl_acquire(2, 15, "tuner power");
37 imx233_pinctrl_set_function(2, 15, PINCTRL_FUNCTION_GPIO);
38 imx233_pinctrl_enable_gpio(2, 15, true);
39#endif
40 initialised = true;
41}
30 42
31bool tuner_power(bool enable) 43bool tuner_power(bool enable)
32{ 44{
33 if(enable != tuner_enable) 45 if(!initialised)
46 init();
47 if(tuner_enable != enable)
34 { 48 {
49#ifdef CREATIVE_ZENMOZAIC
50 imx233_pinctrl_set_gpio(2, 15, enable);
51 sleep(HZ / 5);
52#endif
35 tuner_enable = enable; 53 tuner_enable = enable;
36 } 54 }
37 return tuner_enable; 55 return tuner_enable;