NanoPayload

Annotated stage2/lcd.c

63:d81fbf93be63
2015-06-14 Paul Boddie Fixed minor licensing details and reformatted boilerplate. stage2-non-pic
paul@15 1
/*
paul@15 2
 * Ben NanoNote LCD initialisation, based on uboot-xburst and xburst-tools.
paul@15 3
 *
paul@33 4
 * Copyright (C) 2001-2002 Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
paul@15 5
 * Copyright (C) 2015 Paul Boddie <paul@boddie.org.uk>
paul@15 6
 *
paul@63 7
 * This program is free software: you can redistribute it and/or modify
paul@63 8
 * it under the terms of the GNU General Public License as published by
paul@63 9
 * the Free Software Foundation, either version 3 of the License, or
paul@63 10
 * (at your option) any later version.
paul@15 11
 *
paul@63 12
 * This program is distributed in the hope that it will be useful,
paul@63 13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
paul@63 14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
paul@63 15
 * GNU General Public License for more details.
paul@15 16
 *
paul@63 17
 * You should have received a copy of the GNU General Public License
paul@63 18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
paul@15 19
 */
paul@15 20
paul@34 21
#ifdef CONFIG_CPU_JZ4730_MINIPC
paul@34 22
#include "minipc_claa070vc01.h"
paul@40 23
#include "minipc.h"
paul@34 24
#else
paul@34 25
#include "nanonote_gpm940b0.h"
paul@40 26
#include "nanonote.h"
paul@34 27
#endif
paul@34 28
paul@15 29
#include "xburst_types.h"
paul@33 30
#include "jzlcd.h"
paul@33 31
#include "sdram.h"
paul@33 32
#include "board.h"
paul@15 33
paul@40 34
extern vidinfo_t panel_info;
paul@40 35
paul@15 36
static void test_pattern(void *lcd_base)
paul@15 37
{
paul@15 38
	unsigned short v_max  = panel_info.vl_row;
paul@15 39
	unsigned short h_max  = panel_info.vl_col;
paul@15 40
	unsigned short v, h;
paul@22 41
	u32 *pix = (u32 *)lcd_base;
paul@15 42
paul@22 43
	/* WARNING: Code silently assumes 32 bit/pixel */
paul@22 44
	for (v = 0; v < v_max; v += 1) {
paul@22 45
		for (h = 0; h < h_max; h += 1) {
paul@28 46
			*pix++ = (
paul@28 47
				(((255 * (h_max - h)) / (h_max - 1)) << 16) +
paul@28 48
				((((255 * h) / (h_max - 1) + (255 * (v_max - v)) / (v_max - 1)) / 2) << 8) +
paul@28 49
				((255 * v) / (v_max - 1))
paul@28 50
				);
paul@15 51
		}
paul@15 52
	}
paul@15 53
}
paul@15 54
paul@15 55
void lcd_clear(void *lcd_base)
paul@15 56
{
paul@15 57
	test_pattern(lcd_base);
paul@15 58
}
paul@15 59
paul@15 60
/* LCD initialisation. */
paul@15 61
paul@15 62
static void *lcd_base;
paul@15 63
paul@15 64
void lcd_init(void)
paul@15 65
{
paul@20 66
	__lcd_display_pin_init();
paul@20 67
	__lcd_display_on();
paul@20 68
paul@48 69
	lcd_ctrl_init(&lcd_base);
paul@15 70
	lcd_clear(lcd_base);
paul@15 71
	lcd_enable();
paul@15 72
}