summaryrefslogtreecommitdiff
path: root/firmware/target/mips/ingenic_x1000/lcd-x1000.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/mips/ingenic_x1000/lcd-x1000.h')
-rw-r--r--firmware/target/mips/ingenic_x1000/lcd-x1000.h110
1 files changed, 110 insertions, 0 deletions
diff --git a/firmware/target/mips/ingenic_x1000/lcd-x1000.h b/firmware/target/mips/ingenic_x1000/lcd-x1000.h
new file mode 100644
index 0000000000..96085ac207
--- /dev/null
+++ b/firmware/target/mips/ingenic_x1000/lcd-x1000.h
@@ -0,0 +1,110 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2021 Aidan MacDonald
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
22#ifndef __LCD_X1000_H__
23#define __LCD_X1000_H__
24
25/* NOTICE: if adding LCD support for a new X1000 target, please take a look
26 * at the implementation in case there's any difficulties; there may be some
27 * parts that need adjusting. The X1000 LCD interface is poorly documented
28 * and it might be necessary to change some settings by trial and error to
29 * match the panel. */
30
31#include "clk-x1000.h"
32#include <stdbool.h>
33
34#define LCD_INSTR_CMD 0
35#define LCD_INSTR_DAT 1
36#define LCD_INSTR_UDELAY 2
37#define LCD_INSTR_END 3
38
39struct lcd_tgt_config {
40 /* Data bus width, in bits */
41 int bus_width: 8;
42
43 /* Command bus width, in bits */
44 int cmd_width: 8;
45
46 /* 1 = use 6800 timings, 0 = use 8080 timings */
47 int use_6800_mode: 1;
48
49 /* 1 = serial interface, 0 = parallel interface */
50 int use_serial: 1;
51
52 /* Clock active edge: 0 = falling edge, 1 = rising edge */
53 int clk_polarity: 1;
54
55 /* DC pin levels: 1 = data high, command low; 0 = data low, command high */
56 int dc_polarity: 1;
57
58 /* WR pin level during idle: 1 = keep high; 0 = keep low */
59 int wr_polarity: 1;
60
61 /* 1 to enable vsync, so DMA transfer is synchronized with TE signal */
62 int te_enable: 1;
63
64 /* Active level of TE signal: 1 = high, 0 = low */
65 int te_polarity: 1;
66
67 /* 1 = support narrow TE signal (<=3 pixel clocks); 0 = don't support */
68 int te_narrow: 1;
69
70 /* Commands used to initiate a framebuffer write. Buffer must be
71 * aligned to 64-byte boundary and size must be a multiple of 4,
72 * regardless of the command bus width. */
73 const void* dma_wr_cmd_buf;
74 size_t dma_wr_cmd_size;
75};
76
77/* Static configuration for the target's LCD, must be defined by target. */
78extern const struct lcd_tgt_config lcd_tgt_config;
79
80/* Set the pixel clock. Valid clock sources are SCLK_A and MPLL. */
81extern void lcd_set_clock(x1000_clk_t clksrc, uint32_t freq);
82
83/* Execute a sequence of LCD commands. Should only be called from
84 * lcd_tgt_ctl_enable() and lcd_tgt_ctl_sleep().
85 *
86 * The array should be a list of pairs (instr, arg), with LCD_INSTR_END
87 * as the last entry.
88 *
89 * - LCD_INSTR_CMD, cmd: issue command write of 'cmd'
90 * - LCD_INSTR_DAT, dat: issue data write of 'dat'
91 * - LCD_INSTR_UDELAY, us: call udelay(us)
92 */
93extern void lcd_exec_commands(const uint32_t* cmdseq);
94
95/* Enable/disable the LCD controller.
96 *
97 * - On enabling: power on the LCD, set the pixel clock with lcd_set_clock(),
98 * and use lcd_exec_commands() to send any needed initialization commands.
99 *
100 * - On disabling: use lcd_exec_commands() to send shutdown commands to the
101 * controller and disable the LCD power supply.
102 */
103extern void lcd_tgt_enable(bool on);
104
105/* Enter or exit sleep mode to save power, normally by sending the necessary
106 * commands with lcd_exec_commands().
107 */
108extern void lcd_tgt_sleep(bool sleep);
109
110#endif /* __LCD_X1000_H__ */