From 3ec66893e377b088c1284d2d23adb2aeea6d7965 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Sat, 27 Feb 2021 22:08:58 +0000 Subject: New port: FiiO M3K on bare metal Change-Id: I7517e7d5459e129dcfc9465c6fbd708619888fbe --- firmware/target/mips/ingenic_x1000/lcd-x1000.h | 110 +++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 firmware/target/mips/ingenic_x1000/lcd-x1000.h (limited to 'firmware/target/mips/ingenic_x1000/lcd-x1000.h') 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 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2021 Aidan MacDonald + * + * 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. + * + ****************************************************************************/ + +#ifndef __LCD_X1000_H__ +#define __LCD_X1000_H__ + +/* NOTICE: if adding LCD support for a new X1000 target, please take a look + * at the implementation in case there's any difficulties; there may be some + * parts that need adjusting. The X1000 LCD interface is poorly documented + * and it might be necessary to change some settings by trial and error to + * match the panel. */ + +#include "clk-x1000.h" +#include + +#define LCD_INSTR_CMD 0 +#define LCD_INSTR_DAT 1 +#define LCD_INSTR_UDELAY 2 +#define LCD_INSTR_END 3 + +struct lcd_tgt_config { + /* Data bus width, in bits */ + int bus_width: 8; + + /* Command bus width, in bits */ + int cmd_width: 8; + + /* 1 = use 6800 timings, 0 = use 8080 timings */ + int use_6800_mode: 1; + + /* 1 = serial interface, 0 = parallel interface */ + int use_serial: 1; + + /* Clock active edge: 0 = falling edge, 1 = rising edge */ + int clk_polarity: 1; + + /* DC pin levels: 1 = data high, command low; 0 = data low, command high */ + int dc_polarity: 1; + + /* WR pin level during idle: 1 = keep high; 0 = keep low */ + int wr_polarity: 1; + + /* 1 to enable vsync, so DMA transfer is synchronized with TE signal */ + int te_enable: 1; + + /* Active level of TE signal: 1 = high, 0 = low */ + int te_polarity: 1; + + /* 1 = support narrow TE signal (<=3 pixel clocks); 0 = don't support */ + int te_narrow: 1; + + /* Commands used to initiate a framebuffer write. Buffer must be + * aligned to 64-byte boundary and size must be a multiple of 4, + * regardless of the command bus width. */ + const void* dma_wr_cmd_buf; + size_t dma_wr_cmd_size; +}; + +/* Static configuration for the target's LCD, must be defined by target. */ +extern const struct lcd_tgt_config lcd_tgt_config; + +/* Set the pixel clock. Valid clock sources are SCLK_A and MPLL. */ +extern void lcd_set_clock(x1000_clk_t clksrc, uint32_t freq); + +/* Execute a sequence of LCD commands. Should only be called from + * lcd_tgt_ctl_enable() and lcd_tgt_ctl_sleep(). + * + * The array should be a list of pairs (instr, arg), with LCD_INSTR_END + * as the last entry. + * + * - LCD_INSTR_CMD, cmd: issue command write of 'cmd' + * - LCD_INSTR_DAT, dat: issue data write of 'dat' + * - LCD_INSTR_UDELAY, us: call udelay(us) + */ +extern void lcd_exec_commands(const uint32_t* cmdseq); + +/* Enable/disable the LCD controller. + * + * - On enabling: power on the LCD, set the pixel clock with lcd_set_clock(), + * and use lcd_exec_commands() to send any needed initialization commands. + * + * - On disabling: use lcd_exec_commands() to send shutdown commands to the + * controller and disable the LCD power supply. + */ +extern void lcd_tgt_enable(bool on); + +/* Enter or exit sleep mode to save power, normally by sending the necessary + * commands with lcd_exec_commands(). + */ +extern void lcd_tgt_sleep(bool sleep); + +#endif /* __LCD_X1000_H__ */ -- cgit v1.2.3