changeset 277:0196b6bf633c

R2D: LCD hardware suspend implemented for Luna
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 07 Sep 2021 22:18:20 +0000
parents 4221c724c664
children 75758d7a9be3
files src/cs/drivers/drv_app/r2d/lcds/luna/r2d_onoff_i.c src/cs/drivers/drv_app/r2d/r2d_onoff.c src/cs/drivers/drv_app/r2d/r2d_task.c
diffstat 3 files changed, 35 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/cs/drivers/drv_app/r2d/lcds/luna/r2d_onoff_i.c	Tue Sep 07 21:05:38 2021 +0000
+++ b/src/cs/drivers/drv_app/r2d/lcds/luna/r2d_onoff_i.c	Tue Sep 07 22:18:20 2021 +0000
@@ -2,15 +2,36 @@
 #include "main/sys_types.h"
 #include "armio.h"
 
+static void lcd_suspend(void)
+{
+	if (r2d_lcd_hw_suspend)
+		return;		/* already in suspend */
+	r2d_lcd_hw_suspend = 1;
+	LCD_REG_WR(0x0007, 0);			/* display off */
+	rvf_delay(RVF_MS_TO_TICKS(50));
+	LCD_REG_WR(0x0010, 1);			/* suspend mode */
+}
+
+static void lcd_resume(void)
+{
+	if (!r2d_lcd_hw_suspend)
+		return;		/* already on */
+	LCD_REG_WR(0x0010, 0);			/* out of suspend */
+	rvf_delay(RVF_MS_TO_TICKS(50));
+	LCD_REG_WR(0x0007, 0x1017);		/* display on */
+	r2d_lcd_hw_suspend = 0;
+	r2d_refresh();
+}
+
 static void r2d_onoff_action(enum blrr_display_state set_state)
 {
 	UBYTE on_off;
 
 	/*
 	 * PWL control: on our current Luna setups (Caramel2 or iWOW DSK)
-	 * PWL is only an indicator LED for developers, but the Mother's
-	 * plan for the dream FreeCalypso handset includes having PWL
-	 * regulate the backlight intensity.
+	 * PWL is only an indicator LED for developers.  We use this PWL
+	 * indicator to show the state of "virtual dimming", as there is
+	 * no physical LCD backlight dimming control on Luna.
 	 */
 	switch (set_state) {
 	case BLRR_DISPLAY_OFF:
@@ -36,10 +57,12 @@
 	default:
 		return;		/* error, but we are a void function */
 	}
-	/* physical backlight on/off */
-	if (on_off)
+	/* physical LCD and backlight on/off */
+	if (on_off) {
+		lcd_resume();
 		AI_SetBit(9);
-	else
+	} else {
 		AI_ResetBit(9);
-	/* TFT on/off control remains to be implemented */
+		lcd_suspend();
+	}
 }
--- a/src/cs/drivers/drv_app/r2d/r2d_onoff.c	Tue Sep 07 21:05:38 2021 +0000
+++ b/src/cs/drivers/drv_app/r2d/r2d_onoff.c	Tue Sep 07 22:18:20 2021 +0000
@@ -4,10 +4,13 @@
  */
 
 #include "rv/rv_general.h"
+#include "rvf/rvf_api.h"
 #include "r2d/r2d_config.h"
 #include "r2d/r2d_messages.h"
 #include "r2d/r2d_blrr_api.h"
 
+extern int r2d_lcd_hw_suspend;
+
 #ifdef CONFIG_TARGET_LUNA
   #include "r2d/lcds/luna/r2d_onoff_i.c"
 #elif defined(CONFIG_TARGET_C139)
--- a/src/cs/drivers/drv_app/r2d/r2d_task.c	Tue Sep 07 21:05:38 2021 +0000
+++ b/src/cs/drivers/drv_app/r2d/r2d_task.c	Tue Sep 07 22:18:20 2021 +0000
@@ -39,7 +39,7 @@
 extern void r2d_process_onoff_message(T_R2D_EVT *msg);
 
 /* FreeCalypso addition */
-int r2d_is_running;
+int r2d_is_running, r2d_lcd_hw_suspend;
 
 /*******************************************************************************
 ** Function         r2d_core
@@ -94,7 +94,7 @@
 			//   RV_TRACE_LEVEL_DEBUG_HIGH, TRACE_XXX );
 
 			r2d_g_event_was_sent=FALSE;
-			if (r2d_g_refresh_disabled==0)
+			if (r2d_g_refresh_disabled==0 && !r2d_lcd_hw_suspend)
 			{
 			    r2d_refresh();
 			    rvf_delay(RVF_MS_TO_TICKS(R2D_REFRESH_PERIOD));