2011-01-02 23:16:27 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id: lcd-nano2g.c 28868 2010-12-21 06:59:17Z Buschel $
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 by Dave Chapman
|
|
|
|
*
|
|
|
|
* 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 "config.h"
|
|
|
|
|
|
|
|
#include "hwcompat.h"
|
|
|
|
#include "kernel.h"
|
|
|
|
#include "lcd.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "cpu.h"
|
|
|
|
#include "pmu-target.h"
|
|
|
|
#include "power.h"
|
2011-03-01 01:52:12 +00:00
|
|
|
#include "string.h"
|
2014-12-06 17:37:09 +00:00
|
|
|
#include "dma-s5l8702.h"
|
2011-01-02 23:16:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define R_HORIZ_GRAM_ADDR_SET 0x200
|
|
|
|
#define R_VERT_GRAM_ADDR_SET 0x201
|
|
|
|
#define R_WRITE_DATA_TO_GRAM 0x202
|
|
|
|
#define R_HORIZ_ADDR_START_POS 0x210
|
|
|
|
#define R_HORIZ_ADDR_END_POS 0x211
|
|
|
|
#define R_VERT_ADDR_START_POS 0x212
|
|
|
|
#define R_VERT_ADDR_END_POS 0x213
|
|
|
|
|
|
|
|
|
|
|
|
/* LCD type 1 register defines */
|
|
|
|
|
|
|
|
#define R_COLUMN_ADDR_SET 0x2a
|
|
|
|
#define R_ROW_ADDR_SET 0x2b
|
|
|
|
#define R_MEMORY_WRITE 0x2c
|
|
|
|
|
|
|
|
|
|
|
|
/** globals **/
|
|
|
|
|
|
|
|
int lcd_type; /* also needed in debug-s5l8702.c */
|
2011-03-01 01:52:12 +00:00
|
|
|
static struct mutex lcd_mutex;
|
2014-12-06 17:37:09 +00:00
|
|
|
static uint16_t lcd_dblbuf[LCD_HEIGHT][LCD_WIDTH] CACHEALIGN_ATTR;
|
2012-02-25 12:46:43 +00:00
|
|
|
static bool lcd_ispowered;
|
2011-01-02 23:16:27 +00:00
|
|
|
|
2012-02-25 12:46:43 +00:00
|
|
|
#define SLEEP 0
|
|
|
|
#define CMD16 1
|
|
|
|
#define DATA16 2
|
|
|
|
#define REG15 3
|
|
|
|
#define END 0xff
|
2011-01-02 23:16:27 +00:00
|
|
|
|
2012-02-25 12:46:43 +00:00
|
|
|
/* powersave sequences */
|
|
|
|
|
2012-02-25 12:48:50 +00:00
|
|
|
static const unsigned short lcd_sleep_sequence_01[] =
|
2012-02-25 12:46:43 +00:00
|
|
|
{
|
|
|
|
CMD16, 0x028, /* Display Off */
|
|
|
|
SLEEP, 0x005, /* 50 ms */
|
|
|
|
CMD16, 0x010, /* Sleep In Mode */
|
|
|
|
SLEEP, 0x005, /* 50 ms */
|
|
|
|
END
|
|
|
|
};
|
|
|
|
|
2012-02-25 12:48:50 +00:00
|
|
|
static const unsigned short lcd_deep_stby_sequence_23[] =
|
2012-02-25 12:46:43 +00:00
|
|
|
{
|
|
|
|
/* Display Off */
|
|
|
|
REG15, 0x007, 0x0172,
|
|
|
|
REG15, 0x030, 0x03ff,
|
|
|
|
SLEEP, 0x00a,
|
|
|
|
REG15, 0x007, 0x0120,
|
|
|
|
REG15, 0x030, 0x0000,
|
|
|
|
REG15, 0x100, 0x0780,
|
|
|
|
REG15, 0x007, 0x0000,
|
|
|
|
REG15, 0x101, 0x0260,
|
|
|
|
REG15, 0x102, 0x00a9,
|
|
|
|
SLEEP, 0x003,
|
|
|
|
REG15, 0x100, 0x0700,
|
|
|
|
|
|
|
|
/* Deep Standby Mode */
|
|
|
|
REG15, 0x100, 0x0704,
|
|
|
|
SLEEP, 0x005,
|
|
|
|
END
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef HAVE_LCD_SLEEP
|
|
|
|
/* init sequences */
|
|
|
|
|
2012-02-25 12:48:50 +00:00
|
|
|
static const unsigned short lcd_init_sequence_01[] =
|
2012-02-25 12:46:43 +00:00
|
|
|
{
|
|
|
|
CMD16, 0x011, /* Sleep Out Mode */
|
|
|
|
SLEEP, 0x006, /* 60 ms */
|
|
|
|
CMD16, 0x029, /* Display On */
|
|
|
|
END
|
|
|
|
};
|
|
|
|
|
2012-02-25 12:48:50 +00:00
|
|
|
static const unsigned short lcd_init_sequence_23[] =
|
2012-02-25 12:46:43 +00:00
|
|
|
{
|
|
|
|
/* Display settings */
|
|
|
|
REG15, 0x008, 0x0808,
|
|
|
|
REG15, 0x010, 0x0013,
|
|
|
|
REG15, 0x011, 0x0300,
|
|
|
|
REG15, 0x012, 0x0101,
|
|
|
|
REG15, 0x013, 0x0a03,
|
|
|
|
REG15, 0x014, 0x0a0e,
|
|
|
|
REG15, 0x015, 0x0a19,
|
|
|
|
REG15, 0x016, 0x2402,
|
|
|
|
REG15, 0x018, 0x0001,
|
|
|
|
REG15, 0x090, 0x0021,
|
|
|
|
|
|
|
|
/* Gamma settings */
|
|
|
|
REG15, 0x300, 0x0307,
|
|
|
|
REG15, 0x301, 0x0003,
|
|
|
|
REG15, 0x302, 0x0402,
|
|
|
|
REG15, 0x303, 0x0303,
|
|
|
|
REG15, 0x304, 0x0300,
|
|
|
|
REG15, 0x305, 0x0407,
|
|
|
|
REG15, 0x306, 0x1c04,
|
|
|
|
REG15, 0x307, 0x0307,
|
|
|
|
REG15, 0x308, 0x0003,
|
|
|
|
REG15, 0x309, 0x0402,
|
|
|
|
REG15, 0x30a, 0x0303,
|
|
|
|
REG15, 0x30b, 0x0300,
|
|
|
|
REG15, 0x30c, 0x0407,
|
|
|
|
REG15, 0x30d, 0x1c04,
|
|
|
|
|
|
|
|
REG15, 0x310, 0x0707,
|
|
|
|
REG15, 0x311, 0x0407,
|
|
|
|
REG15, 0x312, 0x0306,
|
|
|
|
REG15, 0x313, 0x0303,
|
|
|
|
REG15, 0x314, 0x0300,
|
|
|
|
REG15, 0x315, 0x0407,
|
|
|
|
REG15, 0x316, 0x1c01,
|
|
|
|
REG15, 0x317, 0x0707,
|
|
|
|
REG15, 0x318, 0x0407,
|
|
|
|
REG15, 0x319, 0x0306,
|
|
|
|
REG15, 0x31a, 0x0303,
|
|
|
|
REG15, 0x31b, 0x0300,
|
|
|
|
REG15, 0x31c, 0x0407,
|
|
|
|
REG15, 0x31d, 0x1c01,
|
|
|
|
|
|
|
|
REG15, 0x320, 0x0206,
|
|
|
|
REG15, 0x321, 0x0102,
|
|
|
|
REG15, 0x322, 0x0404,
|
|
|
|
REG15, 0x323, 0x0303,
|
|
|
|
REG15, 0x324, 0x0300,
|
|
|
|
REG15, 0x325, 0x0407,
|
|
|
|
REG15, 0x326, 0x1c1f,
|
|
|
|
REG15, 0x327, 0x0206,
|
|
|
|
REG15, 0x328, 0x0102,
|
|
|
|
REG15, 0x329, 0x0404,
|
|
|
|
REG15, 0x32a, 0x0303,
|
|
|
|
REG15, 0x32b, 0x0300,
|
|
|
|
REG15, 0x32c, 0x0407,
|
|
|
|
REG15, 0x32d, 0x1c1f,
|
|
|
|
|
|
|
|
/* GRAM and Base Imagen settings (ili9326ds) */
|
|
|
|
REG15, 0x400, 0x001d,
|
|
|
|
REG15, 0x401, 0x0001,
|
|
|
|
REG15, 0x205, 0x0060,
|
|
|
|
|
|
|
|
/* Power settings */
|
|
|
|
REG15, 0x007, 0x0001,
|
|
|
|
REG15, 0x031, 0x0071,
|
|
|
|
REG15, 0x110, 0x0001,
|
|
|
|
REG15, 0x100, 0x17b0,
|
|
|
|
REG15, 0x101, 0x0220,
|
|
|
|
REG15, 0x102, 0x00bd,
|
|
|
|
REG15, 0x103, 0x1500,
|
|
|
|
REG15, 0x105, 0x0103,
|
|
|
|
REG15, 0x106, 0x0105,
|
|
|
|
|
|
|
|
/* Display On */
|
|
|
|
REG15, 0x007, 0x0021,
|
|
|
|
REG15, 0x001, 0x0110,
|
|
|
|
REG15, 0x003, 0x0230,
|
|
|
|
REG15, 0x002, 0x0500,
|
|
|
|
REG15, 0x007, 0x0031,
|
|
|
|
REG15, 0x030, 0x0007,
|
|
|
|
SLEEP, 0x003,
|
|
|
|
REG15, 0x030, 0x03ff,
|
|
|
|
SLEEP, 0x006,
|
|
|
|
REG15, 0x007, 0x0072,
|
|
|
|
SLEEP, 0x00f,
|
|
|
|
REG15, 0x007, 0x0173,
|
|
|
|
END
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2014-12-06 17:37:09 +00:00
|
|
|
/* DMA configuration */
|
|
|
|
|
|
|
|
/* one single transfer at once, needed LLIs:
|
|
|
|
* screen_size / (DMAC_LLI_MAX_COUNT << swidth) =
|
|
|
|
* (320*240*2) / (4095*2) = 19
|
|
|
|
*/
|
|
|
|
#define LCD_DMA_TSKBUF_SZ 1 /* N tasks, MUST be pow2 */
|
|
|
|
#define LCD_DMA_LLIBUF_SZ 32 /* N LLIs, MUST be pow2 */
|
|
|
|
|
|
|
|
static struct dmac_tsk lcd_dma_tskbuf[LCD_DMA_TSKBUF_SZ];
|
|
|
|
static struct dmac_lli volatile \
|
|
|
|
lcd_dma_llibuf[LCD_DMA_LLIBUF_SZ] CACHEALIGN_ATTR;
|
|
|
|
|
|
|
|
static struct dmac_ch lcd_dma_ch = {
|
|
|
|
.dmac = &s5l8702_dmac0,
|
|
|
|
.prio = DMAC_CH_PRIO(4),
|
|
|
|
.cb_fn = NULL,
|
|
|
|
|
|
|
|
.tskbuf = lcd_dma_tskbuf,
|
|
|
|
.tskbuf_mask = LCD_DMA_TSKBUF_SZ - 1,
|
|
|
|
.queue_mode = QUEUE_NORMAL,
|
|
|
|
|
|
|
|
.llibuf = lcd_dma_llibuf,
|
|
|
|
.llibuf_mask = LCD_DMA_LLIBUF_SZ - 1,
|
|
|
|
.llibuf_bus = DMAC_MASTER_AHB1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct dmac_ch_cfg lcd_dma_ch_cfg = {
|
|
|
|
.srcperi = S5L8702_DMAC0_PERI_MEM,
|
|
|
|
.dstperi = S5L8702_DMAC0_PERI_LCD_WR,
|
|
|
|
.sbsize = DMACCxCONTROL_BSIZE_1,
|
|
|
|
.dbsize = DMACCxCONTROL_BSIZE_1,
|
|
|
|
.swidth = DMACCxCONTROL_WIDTH_16,
|
|
|
|
.dwidth = DMACCxCONTROL_WIDTH_16,
|
|
|
|
.sbus = DMAC_MASTER_AHB1,
|
|
|
|
.dbus = DMAC_MASTER_AHB1,
|
|
|
|
.sinc = DMACCxCONTROL_INC_ENABLE,
|
|
|
|
.dinc = DMACCxCONTROL_INC_DISABLE,
|
|
|
|
.prot = DMAC_PROT_CACH | DMAC_PROT_BUFF | DMAC_PROT_PRIV,
|
|
|
|
.lli_xfer_max_count = DMAC_LLI_MAX_COUNT,
|
|
|
|
};
|
|
|
|
|
2012-02-25 12:46:43 +00:00
|
|
|
static inline void s5l_lcd_write_reg(int cmd, unsigned int data)
|
2011-01-02 23:16:27 +00:00
|
|
|
{
|
|
|
|
while (LCD_STATUS & 0x10);
|
|
|
|
LCD_WCMD = cmd;
|
|
|
|
|
|
|
|
while (LCD_STATUS & 0x10);
|
2012-02-25 12:46:43 +00:00
|
|
|
/* 16-bit/1-transfer data format (ili9320ds s7.2.2) */
|
|
|
|
LCD_WDATA = (data & 0x78ff) |
|
|
|
|
((data & 0x0300) << 1) | ((data & 0x0400) << 5);
|
2011-01-02 23:16:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void s5l_lcd_write_cmd(unsigned short cmd)
|
|
|
|
{
|
|
|
|
while (LCD_STATUS & 0x10);
|
|
|
|
LCD_WCMD = cmd;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void s5l_lcd_write_data(unsigned short data)
|
|
|
|
{
|
|
|
|
while (LCD_STATUS & 0x10);
|
|
|
|
LCD_WDATA = data;
|
|
|
|
}
|
|
|
|
|
2012-02-25 12:48:50 +00:00
|
|
|
static void lcd_run_sequence(const unsigned short *seq)
|
2012-02-25 12:46:43 +00:00
|
|
|
{
|
|
|
|
unsigned short tmp;
|
|
|
|
|
|
|
|
while (1) switch (*seq++)
|
|
|
|
{
|
|
|
|
case SLEEP:
|
|
|
|
sleep(*seq++);
|
|
|
|
break;
|
|
|
|
case CMD16:
|
|
|
|
s5l_lcd_write_cmd(*seq++);
|
|
|
|
break;
|
|
|
|
case DATA16:
|
|
|
|
s5l_lcd_write_data(*seq++);
|
|
|
|
break;
|
|
|
|
case REG15:
|
|
|
|
tmp = *seq++; /* avoid compiler warning */
|
|
|
|
s5l_lcd_write_reg(tmp, *seq++);
|
|
|
|
break;
|
|
|
|
case END:
|
|
|
|
default:
|
|
|
|
/* bye */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-02 23:16:27 +00:00
|
|
|
/*** hardware configuration ***/
|
|
|
|
|
|
|
|
int lcd_default_contrast(void)
|
|
|
|
{
|
|
|
|
return 0x1f;
|
|
|
|
}
|
|
|
|
|
|
|
|
void lcd_set_contrast(int val)
|
|
|
|
{
|
|
|
|
(void)val;
|
|
|
|
}
|
|
|
|
|
|
|
|
void lcd_set_invert_display(bool yesno)
|
|
|
|
{
|
|
|
|
(void)yesno;
|
|
|
|
}
|
|
|
|
|
|
|
|
void lcd_set_flip(bool yesno)
|
|
|
|
{
|
|
|
|
(void)yesno;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool lcd_active(void)
|
|
|
|
{
|
2012-02-25 12:46:43 +00:00
|
|
|
return lcd_ispowered;
|
2011-01-02 23:16:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void lcd_shutdown(void)
|
|
|
|
{
|
|
|
|
pmu_write(0x2b, 0); /* Kill the backlight, instantly. */
|
|
|
|
pmu_write(0x29, 0);
|
|
|
|
|
2012-02-25 12:46:43 +00:00
|
|
|
lcd_sleep();
|
|
|
|
}
|
|
|
|
|
|
|
|
void lcd_sleep(void)
|
|
|
|
{
|
|
|
|
mutex_lock(&lcd_mutex);
|
|
|
|
|
|
|
|
lcd_run_sequence((lcd_type & 2) ? lcd_deep_stby_sequence_23
|
|
|
|
: lcd_sleep_sequence_01);
|
|
|
|
|
|
|
|
/* mask lcd controller clock gate */
|
|
|
|
PWRCON(0) |= (1 << 1);
|
|
|
|
|
|
|
|
lcd_ispowered = false;
|
|
|
|
|
2011-03-01 01:52:12 +00:00
|
|
|
mutex_unlock(&lcd_mutex);
|
2011-01-02 23:16:27 +00:00
|
|
|
}
|
|
|
|
|
2011-04-22 21:39:17 +00:00
|
|
|
#ifdef HAVE_LCD_SLEEP
|
2012-02-25 12:46:43 +00:00
|
|
|
void lcd_awake(void)
|
2011-01-02 23:16:27 +00:00
|
|
|
{
|
2012-02-25 12:46:43 +00:00
|
|
|
mutex_lock(&lcd_mutex);
|
|
|
|
|
|
|
|
/* unmask lcd controller clock gate */
|
|
|
|
PWRCON(0) &= ~(1 << 1);
|
|
|
|
|
|
|
|
if (lcd_type & 2) {
|
|
|
|
/* release from deep standby mode (ili9320ds s12.3) */
|
|
|
|
for (int i = 0; i < 6; i++) {
|
|
|
|
s5l_lcd_write_cmd(0x000);
|
|
|
|
udelay(1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
lcd_run_sequence(lcd_init_sequence_23);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
lcd_run_sequence(lcd_init_sequence_01);
|
|
|
|
|
|
|
|
lcd_ispowered = true;
|
|
|
|
|
|
|
|
mutex_unlock(&lcd_mutex);
|
|
|
|
|
|
|
|
send_event(LCD_EVENT_ACTIVATION, NULL);
|
2011-01-02 23:16:27 +00:00
|
|
|
}
|
2011-04-22 21:39:17 +00:00
|
|
|
#endif
|
2011-01-02 23:16:27 +00:00
|
|
|
|
|
|
|
/* LCD init */
|
|
|
|
void lcd_init_device(void)
|
|
|
|
{
|
|
|
|
/* Detect lcd type */
|
2011-03-01 01:52:12 +00:00
|
|
|
mutex_init(&lcd_mutex);
|
2011-01-02 23:16:27 +00:00
|
|
|
lcd_type = (PDAT6 & 0x30) >> 4;
|
2011-11-06 11:35:21 +00:00
|
|
|
while (!(LCD_STATUS & 0x2));
|
|
|
|
LCD_CONFIG = 0x80100db0;
|
2012-02-25 12:46:43 +00:00
|
|
|
|
2014-12-06 17:37:09 +00:00
|
|
|
/* Configure DMA channel */
|
|
|
|
dmac_ch_init(&lcd_dma_ch, &lcd_dma_ch_cfg);
|
|
|
|
|
2012-02-25 12:46:43 +00:00
|
|
|
lcd_ispowered = true;
|
2011-01-02 23:16:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** Update functions ***/
|
|
|
|
|
|
|
|
static inline void lcd_write_pixel(fb_data pixel)
|
|
|
|
{
|
2011-03-01 01:52:12 +00:00
|
|
|
mutex_lock(&lcd_mutex);
|
2011-01-02 23:16:27 +00:00
|
|
|
LCD_WDATA = pixel;
|
2011-03-01 01:52:12 +00:00
|
|
|
mutex_unlock(&lcd_mutex);
|
2011-01-02 23:16:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Update the display.
|
|
|
|
This must be called after all other LCD functions that change the display. */
|
|
|
|
void lcd_update(void) ICODE_ATTR;
|
|
|
|
void lcd_update(void)
|
|
|
|
{
|
|
|
|
lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Line write helper function. */
|
|
|
|
extern void lcd_write_line(const fb_data *addr,
|
|
|
|
int pixelcount,
|
|
|
|
const unsigned int lcd_base_addr);
|
|
|
|
|
2011-03-01 01:52:12 +00:00
|
|
|
static void displaylcd_setup(int x, int y, int width, int height) ICODE_ATTR;
|
|
|
|
static void displaylcd_setup(int x, int y, int width, int height)
|
2011-01-02 23:16:27 +00:00
|
|
|
{
|
2014-12-06 17:37:09 +00:00
|
|
|
/* TODO: ISR()->panicf()->lcd_update() blocks forever */
|
2011-03-01 01:52:12 +00:00
|
|
|
mutex_lock(&lcd_mutex);
|
2014-12-06 17:37:09 +00:00
|
|
|
while (dmac_ch_running(&lcd_dma_ch))
|
|
|
|
yield();
|
2011-01-02 23:16:27 +00:00
|
|
|
|
2011-03-01 01:52:12 +00:00
|
|
|
int xe = (x + width) - 1; /* max horiz */
|
|
|
|
int ye = (y + height) - 1; /* max vert */
|
2011-01-02 23:16:27 +00:00
|
|
|
|
|
|
|
if (lcd_type & 2) {
|
2012-02-25 12:46:43 +00:00
|
|
|
s5l_lcd_write_reg(R_HORIZ_ADDR_START_POS, x);
|
|
|
|
s5l_lcd_write_reg(R_HORIZ_ADDR_END_POS, xe);
|
|
|
|
s5l_lcd_write_reg(R_VERT_ADDR_START_POS, y);
|
|
|
|
s5l_lcd_write_reg(R_VERT_ADDR_END_POS, ye);
|
2011-01-02 23:16:27 +00:00
|
|
|
|
2012-02-25 12:46:43 +00:00
|
|
|
s5l_lcd_write_reg(R_HORIZ_GRAM_ADDR_SET, x);
|
|
|
|
s5l_lcd_write_reg(R_VERT_GRAM_ADDR_SET, y);
|
2011-01-02 23:16:27 +00:00
|
|
|
|
|
|
|
s5l_lcd_write_cmd(R_WRITE_DATA_TO_GRAM);
|
|
|
|
} else {
|
|
|
|
s5l_lcd_write_cmd(R_COLUMN_ADDR_SET);
|
2011-03-01 01:52:12 +00:00
|
|
|
s5l_lcd_write_data(x >> 8);
|
|
|
|
s5l_lcd_write_data(x & 0xff);
|
|
|
|
s5l_lcd_write_data(xe >> 8);
|
|
|
|
s5l_lcd_write_data(xe & 0xff);
|
2011-01-02 23:16:27 +00:00
|
|
|
|
|
|
|
s5l_lcd_write_cmd(R_ROW_ADDR_SET);
|
2011-03-01 01:52:12 +00:00
|
|
|
s5l_lcd_write_data(y >> 8);
|
|
|
|
s5l_lcd_write_data(y & 0xff);
|
|
|
|
s5l_lcd_write_data(ye >> 8);
|
|
|
|
s5l_lcd_write_data(ye & 0xff);
|
2011-01-02 23:16:27 +00:00
|
|
|
|
|
|
|
s5l_lcd_write_cmd(R_MEMORY_WRITE);
|
|
|
|
}
|
2011-03-01 01:52:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void displaylcd_dma(int pixels) ICODE_ATTR;
|
|
|
|
static void displaylcd_dma(int pixels)
|
|
|
|
{
|
2011-12-17 07:54:00 +00:00
|
|
|
commit_dcache();
|
2014-12-06 17:37:09 +00:00
|
|
|
dmac_ch_queue(&lcd_dma_ch, lcd_dblbuf,
|
|
|
|
(void*)S5L8702_DADDR_PERI_LCD_WR, pixels*2, NULL);
|
2011-03-01 01:52:12 +00:00
|
|
|
mutex_unlock(&lcd_mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update a fraction of the display. */
|
|
|
|
void lcd_update_rect(int, int, int, int) ICODE_ATTR;
|
|
|
|
void lcd_update_rect(int x, int y, int width, int height)
|
|
|
|
{
|
|
|
|
int pixels = width * height;
|
2012-02-22 10:18:05 +00:00
|
|
|
fb_data* p = FBADDR(x,y);
|
2011-03-01 01:52:12 +00:00
|
|
|
uint16_t* out = lcd_dblbuf[0];
|
|
|
|
|
2012-02-25 12:46:43 +00:00
|
|
|
#ifdef HAVE_LCD_SLEEP
|
|
|
|
if (!lcd_active()) return;
|
|
|
|
#endif
|
|
|
|
|
2011-03-01 01:52:12 +00:00
|
|
|
displaylcd_setup(x, y, width, height);
|
2011-01-02 23:16:27 +00:00
|
|
|
|
|
|
|
/* Copy display bitmap to hardware */
|
|
|
|
if (LCD_WIDTH == width) {
|
|
|
|
/* Write all lines at once */
|
2011-03-01 01:52:12 +00:00
|
|
|
memcpy(out, p, pixels * 2);
|
2011-01-02 23:16:27 +00:00
|
|
|
} else {
|
|
|
|
do {
|
|
|
|
/* Write a single line */
|
2011-03-01 01:52:12 +00:00
|
|
|
memcpy(out, p, width * 2);
|
2011-01-02 23:16:27 +00:00
|
|
|
p += LCD_WIDTH;
|
2011-03-01 01:52:12 +00:00
|
|
|
out += width;
|
|
|
|
} while (--height);
|
2011-01-02 23:16:27 +00:00
|
|
|
}
|
2011-03-01 01:52:12 +00:00
|
|
|
|
|
|
|
displaylcd_dma(pixels);
|
2011-01-02 23:16:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Line write helper function for lcd_yuv_blit. Writes two lines of yuv420. */
|
|
|
|
extern void lcd_write_yuv420_lines(unsigned char const * const src[3],
|
2011-03-01 01:52:12 +00:00
|
|
|
uint16_t* outbuf,
|
2011-01-02 23:16:27 +00:00
|
|
|
int width,
|
|
|
|
int stride);
|
|
|
|
|
|
|
|
/* Blit a YUV bitmap directly to the LCD */
|
2011-03-01 01:52:12 +00:00
|
|
|
void lcd_blit_yuv(unsigned char * const src[3],
|
|
|
|
int src_x, int src_y, int stride,
|
|
|
|
int x, int y, int width, int height) ICODE_ATTR;
|
2011-01-02 23:16:27 +00:00
|
|
|
void lcd_blit_yuv(unsigned char * const src[3],
|
|
|
|
int src_x, int src_y, int stride,
|
|
|
|
int x, int y, int width, int height)
|
|
|
|
{
|
2011-03-01 01:52:12 +00:00
|
|
|
unsigned int z;
|
2011-01-02 23:16:27 +00:00
|
|
|
unsigned char const * yuv_src[3];
|
|
|
|
|
2012-02-25 12:46:43 +00:00
|
|
|
#ifdef HAVE_LCD_SLEEP
|
|
|
|
if (!lcd_active()) return;
|
|
|
|
#endif
|
|
|
|
|
2011-01-02 23:16:27 +00:00
|
|
|
width = (width + 1) & ~1; /* ensure width is even */
|
|
|
|
|
2011-03-01 01:52:12 +00:00
|
|
|
int pixels = width * height;
|
|
|
|
uint16_t* out = lcd_dblbuf[0];
|
2011-01-02 23:16:27 +00:00
|
|
|
|
|
|
|
z = stride * src_y;
|
|
|
|
yuv_src[0] = src[0] + z + src_x;
|
|
|
|
yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1);
|
|
|
|
yuv_src[2] = src[2] + (yuv_src[1] - src[1]);
|
|
|
|
|
2011-03-01 01:52:12 +00:00
|
|
|
displaylcd_setup(x, y, width, height);
|
|
|
|
|
2011-01-02 23:16:27 +00:00
|
|
|
height >>= 1;
|
|
|
|
|
|
|
|
do {
|
2011-03-01 01:52:12 +00:00
|
|
|
lcd_write_yuv420_lines(yuv_src, out, width, stride);
|
2011-01-02 23:16:27 +00:00
|
|
|
yuv_src[0] += stride << 1;
|
|
|
|
yuv_src[1] += stride >> 1; /* Skip down one chroma line */
|
|
|
|
yuv_src[2] += stride >> 1;
|
2011-03-01 01:52:12 +00:00
|
|
|
out += width << 1;
|
|
|
|
} while (--height);
|
|
|
|
|
|
|
|
displaylcd_dma(pixels);
|
2011-01-02 23:16:27 +00:00
|
|
|
}
|