From: Stefan E. <se...@us...> - 2001-10-09 17:53:40
|
Update of /cvsroot/blob/blob/src/diag In directory usw-pr-cvs1:/tmp/cvs-serv13752 Modified Files: lcd.c Log Message: - generic LCD support and test functions - these functions can be overwritten by other modules to add platform specific behavior Index: lcd.c =================================================================== RCS file: /cvsroot/blob/blob/src/diag/lcd.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- lcd.c 2001/10/09 16:48:12 1.1 +++ lcd.c 2001/10/09 17:53:37 1.2 @@ -0,0 +1,227 @@ +/********************************************************************** + * lcd.c + * + * AUTOR: SELETZ + * + * Generic lcd framework + * + * Copyright (C) 2001 Stefan Eletzhofer <ste...@ww...> + * + * 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 program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/********************************************************************** + * includes + */ +#ifdef HAVE_CONFIG_H +# include <blob/config.h> +#endif + +#include <blob/types.h> +#include <blob/errno.h> +#include <blob/util.h> +#include <blob/command.h> +#include <blob/serial.h> +#include <blob/sa1100.h> +#include <blob/sa1111.h> + +#include <blob/lcd.h> + +/********************************************************************** + * defines + */ +#define WEAK_SYM __attribute__ (( weak )) + +#define MEM(adr) (*((u32 *)adr)) +#define SET(reg,bit) ((reg) |= (1<<(bit))) +#define CLR(reg,bit) ((reg) &= ~(1<<(bit))) + +/********************************************************************** + * program globals + */ + +/********************************************************************** + * module globals + */ + +u16 *lcd_palette = (u16*)(LCD_PALETTE_DMA_ADR); + +/********************************************************************** + * Prototypes + */ +void lcd_palette_set( int no, int val ); + +/**********************************************************************/ +/**********************************************************************/ +/**********************************************************************/ + +/********************************************************************** + * Do whatever necessary to power up lcd display + */ +int WEAK_SYM lcd_power_up( void ) +{ + return 0; +} + +int WEAK_SYM lcd_power_down( void ) +{ + return 0; +} + +int WEAK_SYM lcd_gpio_setup( void ) +{ + GPDR |= 0x3FC; + GAFR |= 0x3FC; + + return 0; +} + +int WEAK_SYM lcd_controller_enable( void ) +{ + lcd_palette[0] &= 0xcfff; + lcd_palette[0] |= 2<<16; // 8 bpp + + /* Sequence from 11.7.10 */ + LCCR3 = LCD_LCCR3; + LCCR2 = LCD_LCCR2; + LCCR1 = LCD_LCCR1; + LCCR0 = LCD_LCCR0 & ~LCCR0_LEN; + DBAR1 = (u32 *)LCD_PALETTE_DMA_ADR; + DBAR2 = (u32 *)LCD_VIDEORAM_DMA_ADR; + LCCR0 |= LCCR0_LEN; + return 0; +} + +int WEAK_SYM lcd_controller_disable( void ) +{ + LCCR0 &= ~LCCR0_LEN; + return 0; +} + +int WEAK_SYM lcd_backlight_on( void ) +{ + return 0; +} + +int WEAK_SYM lcd_backlight_off( void ) +{ + return 0; +} + +int WEAK_SYM lcd_palette_setup( void ) +{ + int n; + + for ( n = 0 ; n < 128 ; n++ ) { + lcd_palette_set(n, 0x1FFF ); + } + for ( n = 128 ; n < 256 ; n++ ) { + lcd_palette_set(n, 0x1000 ); + } + + return 0; +} + +int WEAK_SYM lcd_contrast( int value ) +{ + return 0; +} + +int WEAK_SYM lcd_brightness( int value ) +{ + return 0; +} + +static char testlcdhelp[] = "lcdtest\nTests lcd display\n"; +__commandlist(lcd_test, "lcdtest", testlcdhelp); + +int WEAK_SYM lcd_test( void ) +{ + int ret = 0; + int x,y; + char c; + + SerialOutputString( "LCD: power up ..." ); + ret = lcd_power_up(); + if ( ret != 0 ) return ret; + SerialOutputString( "done\n" ); + + SerialOutputString( "LCD: gpio setup ..." ); + ret = lcd_gpio_setup(); + if ( ret != 0 ) return ret; + SerialOutputString( "done\n" ); + + + SerialOutputString( "LCD: palette setup ..." ); + ret = lcd_palette_setup(); + if ( ret != 0 ) return ret; + SerialOutputString( "done\n" ); + + + SerialOutputString( "LCD: controller enable ..." ); + ret = lcd_controller_enable(); + if ( ret != 0 ) return ret; + SerialOutputString( "done\n" ); + + SerialOutputString( "LCD: backlight on ..." ); + ret = lcd_backlight_on(); + if ( ret != 0 ) return ret; + SerialOutputString( "done\n" ); + + + /* vertical lines */ + SerialOutputString( "LCD: vertical lines test pattern ..." ); + for ( y=0; y<LCD_ROWS; y++ ) { + for ( x=0; x<(LCD_COLS>>2); x++ ) { + MEM( LCD_VIDEORAM_START + (y*LCD_ROWS) + (x<<2) ) = 0xF0F0F0F0; + } + } + SerialOutputString( "done\n" ); + + SerialOutputString( "LCD: press any key to proceed\n" ); + while ( !SerialInputByte( &c ) ) + ; + + SerialOutputString( "LCD: backlight off ..." ); + ret = lcd_backlight_off(); + if ( ret != 0 ) return ret; + SerialOutputString( "done\n" ); + + SerialOutputString( "LCD: controller disable ..." ); + ret = lcd_controller_disable(); + if ( ret != 0 ) return ret; + SerialOutputString( "done\n" ); + + SerialOutputString( "LCD: power down ..." ); + ret = lcd_power_down(); + if ( ret != 0 ) return ret; + SerialOutputString( "done\n" ); + + return 0; +} + +/********************************************************************** + * Statische Funktionen + */ + +void lcd_palette_set( int no, int val ) +{ + if ( no < 0 || no > 255 ) + return; + + lcd_palette[ no ] = val; + + return; +} |