changeset 650:7d6878435c85

R2D: Luna LCD driver implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 07 May 2020 07:32:27 +0000
parents 37396b85f3f7
children 27bb8ec7bbd3
files src/cs/drivers/drv_app/r2d/lcds/luna/r2d_luna_lcd.h src/cs/drivers/drv_app/r2d/lcds/luna/r2d_task_i.c src/cs/drivers/drv_app/r2d/lcds/luna/r2d_task_init_i.c
diffstat 3 files changed, 154 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cs/drivers/drv_app/r2d/lcds/luna/r2d_luna_lcd.h	Thu May 07 07:32:27 2020 +0000
@@ -0,0 +1,16 @@
+/*
+ * This header file provides definitions for the Luna LCD hardware interface.
+ */
+
+/* reset control */
+#define	CNTL_RST_REG	(*(volatile unsigned short *)0xFFFFFD04)
+#define	EXT_RESET	0x0004
+
+/* the LCD is connected to Calypso nCS3, with A1 line as register select */
+
+#define	LCD_IR		(*(volatile unsigned short *)0x02000000)
+#define	LCD_DR		(*(volatile unsigned short *)0x02000002)
+
+/* macro for writing first IR, then DR */
+
+#define	LCD_REG_WR(reg, data)	{LCD_IR = (reg); LCD_DR = (data);}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cs/drivers/drv_app/r2d/lcds/luna/r2d_task_i.c	Thu May 07 07:32:27 2020 +0000
@@ -0,0 +1,64 @@
+#include "r2d/lcds/luna/r2d_luna_lcd.h" 
+#include "rvm/rvm_use_id_list.h"
+
+void r2d_lcd_power_on(void)
+{
+}
+
+void r2d_lcd_power_off(void)
+{
+}
+
+void r2d_refresh(void)
+{
+	UINT16 i,j;
+	UINT32 v;
+	UINT32  *p;
+	INT16 x1,x2,y1,y2,de,ds;
+
+	p=r2d_g_framebuffer->p_memory_words;
+    
+	x1=(r2d_update_ul_x>>1)<<1;  //0
+	x2=((r2d_update_br_x>>1)<<1)+1; //174;
+
+	ds=(x1>>1);
+	de=R2D_MWWIDTH-(x2>>1)-1; // WHY -1, is formula right ????
+
+	y1=r2d_update_ul_y; //0
+	y2=r2d_update_br_y; //219
+
+	/* set window area */
+	LCD_REG_WR(0x36, x2);
+	LCD_REG_WR(0x37, x1);
+	LCD_REG_WR(0x38, y2);
+	LCD_REG_WR(0x39, y1);
+	/* set current write address */
+	LCD_REG_WR(0x20, x1);
+	LCD_REG_WR(0x21, y1);
+	/* set up for GRAM write */
+	LCD_IR = 0x22;
+
+	p=p+y1*R2D_MWWIDTH;
+
+	for(i=y1;i<=y2;i++)
+	{
+		p+=ds;
+		for(j=(x1>>1);j<=(x2>>1);j++)
+		{
+			v=*p++;
+			v=~v;
+
+			/*white*/
+			/*v=0xffffffff*/
+			/*black*/
+			/*v=0x00000000*/
+
+			LCD_DR = v&0x0FFFF;
+			LCD_DR = v>>16;
+		}	    
+		p+=de;
+	} 
+
+	r2d_check_and_send_event(r2d_g_framebuffer);
+	r2d_reinit_update_region();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cs/drivers/drv_app/r2d/lcds/luna/r2d_task_init_i.c	Thu May 07 07:32:27 2020 +0000
@@ -0,0 +1,74 @@
+#include "r2d/lcds/luna/r2d_luna_lcd.h"
+
+#define R2D_MB_PRIM_SIZE	(4000)
+
+static void r2d_refresh_task_init(void)
+{
+	UINT32  i;
+
+	/* reset pulse */
+	CNTL_RST_REG |= EXT_RESET;
+	rvf_delay(RVF_MS_TO_TICKS(10));
+	CNTL_RST_REG &= ~EXT_RESET;
+	rvf_delay(RVF_MS_TO_TICKS(50));
+	/* start register init */
+	LCD_REG_WR(0x0001, 0x011c); // set SS and NL bit
+	LCD_REG_WR(0x0002, 0x0100); // set 1 line inversion
+	LCD_REG_WR(0x0003, 0x1030); // set GRAM write direction and BGR=1.
+	LCD_REG_WR(0x0008, 0x0808); // set BP and FP
+	LCD_REG_WR(0x000F, 0x0901); // Set frame rate
+	rvf_delay(RVF_MS_TO_TICKS(10));
+	LCD_REG_WR(0x0010, 0x0000); // Set SAP,DSTB,STB
+	LCD_REG_WR(0x0011, 0x1B41); // Set APON,PON,AON,VCI1EN,VC
+	rvf_delay(RVF_MS_TO_TICKS(50));
+	LCD_REG_WR(0x0012, 0x200E); // Internal reference voltage= Vci;
+	LCD_REG_WR(0x0013, 0x0052); // Set GVDD
+	LCD_REG_WR(0x0014, 0x4B5C); // Set VCOMH/VCOML voltage
+	//------------- Set GRAM area ------------------//
+	LCD_REG_WR(0x0030, 0x0000);
+	LCD_REG_WR(0x0031, 0x00DB);
+	LCD_REG_WR(0x0032, 0x0000);
+	LCD_REG_WR(0x0033, 0x0000);
+	LCD_REG_WR(0x0034, 0x00DB);
+	LCD_REG_WR(0x0035, 0x0000);
+	LCD_REG_WR(0x0036, 0x00AF);
+	LCD_REG_WR(0x0037, 0x0000);
+	LCD_REG_WR(0x0038, 0x00DB);
+	LCD_REG_WR(0x0039, 0x0000);
+	// ----------- Adjust the Gamma Curve ----------//
+	LCD_REG_WR(0x0050, 0x0000);
+	LCD_REG_WR(0x0051, 0x0705);
+	LCD_REG_WR(0x0052, 0x0C0A);
+	LCD_REG_WR(0x0053, 0x0401);
+	LCD_REG_WR(0x0054, 0x040C);
+	LCD_REG_WR(0x0055, 0x0608);
+	LCD_REG_WR(0x0056, 0x0000);
+	LCD_REG_WR(0x0057, 0x0104);
+	LCD_REG_WR(0x0058, 0x0E06);
+	LCD_REG_WR(0x0059, 0x060E);
+	rvf_delay(RVF_MS_TO_TICKS(50));
+	LCD_REG_WR(0x0007, 0x1017);
+
+	/* initial hw framebuffer clearing */
+	LCD_REG_WR(0x20, 0);
+	LCD_REG_WR(0x21, 0);
+	LCD_IR = 0x22;
+	for (i = 0; i < 176*220; i++)
+		LCD_DR = 0xFFFF;	/* white color */
+}
+
+static void r2d_refresh_task_kill(void)
+{
+}
+
+static void r2d_dithering_init(void)
+{
+   R2D_MALLOC(r2d_mb_id,UINT32,sizeof(UINT32)*4,r2d_g_dithering_matrix);
+   if (r2d_g_dithering_matrix!=NULL)
+   {
+     r2d_g_dithering_matrix[0]=0;
+     r2d_g_dithering_matrix[1]=2;
+     r2d_g_dithering_matrix[2]=3;
+     r2d_g_dithering_matrix[3]=1;
+   }
+}