changeset 217:6541e43f88e5

R2D display on/off control implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 24 Apr 2021 23:38:18 +0000
parents 777698cf6583
children 77b980f09bd9
files components/r2d_drv_flash src/cs/drivers/drv_app/r2d/lcds/c139/r2d_onoff_i.c src/cs/drivers/drv_app/r2d/lcds/luna/r2d_onoff_i.c src/cs/drivers/drv_app/r2d/r2d_blrr_api.c src/cs/drivers/drv_app/r2d/r2d_blrr_api.h src/cs/drivers/drv_app/r2d/r2d_messages.h src/cs/drivers/drv_app/r2d/r2d_onoff.c src/cs/drivers/drv_app/r2d/r2d_task.c
diffstat 8 files changed, 173 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/components/r2d_drv_flash	Sat Apr 24 19:58:49 2021 +0000
+++ b/components/r2d_drv_flash	Sat Apr 24 23:38:18 2021 +0000
@@ -49,6 +49,8 @@
 cfile_plain $SRCDIR/r2d_i.c
 cfile_plain $SRCDIR/r2d_inits.c
 cfile_plain $SRCDIR/r2d_task.c
+cfile_plain $SRCDIR/r2d_onoff.c
+cfile_plain $SRCDIR/r2d_blrr_api.c
 
 # New sourceset
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cs/drivers/drv_app/r2d/lcds/c139/r2d_onoff_i.c	Sat Apr 24 23:38:18 2021 +0000
@@ -0,0 +1,9 @@
+#include "armio.h"
+
+static void r2d_onoff_action(enum blrr_display_state set_state)
+{
+	if (set_state != BLRR_DISPLAY_OFF)
+		AI_SetBit(1);
+	else
+		AI_ResetBit(1);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cs/drivers/drv_app/r2d/lcds/luna/r2d_onoff_i.c	Sat Apr 24 23:38:18 2021 +0000
@@ -0,0 +1,45 @@
+#include "r2d/lcds/luna/r2d_luna_lcd.h"
+#include "main/sys_types.h"
+#include "armio.h"
+
+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.
+	 */
+	switch (set_state) {
+	case BLRR_DISPLAY_OFF:
+		*(volatile SYS_UWORD8 *)0xFFFE8000 = 0;
+		*(volatile SYS_UWORD8 *)0xFFFE8001 = 0;
+		on_off = 0;
+		break;
+	case BLRR_DISPLAY_ON:
+		*(volatile SYS_UWORD8 *)0xFFFE8000 = 255;
+		*(volatile SYS_UWORD8 *)0xFFFE8001 = 1;
+		on_off = 1;
+		break;
+	case BLRR_DISPLAY_INCALL:
+		*(volatile SYS_UWORD8 *)0xFFFE8000 = 16;
+		*(volatile SYS_UWORD8 *)0xFFFE8001 = 1;
+		on_off = 1;
+		break;
+	case BLRR_DISPLAY_CHG_BOOT:
+		*(volatile SYS_UWORD8 *)0xFFFE8000 = 64;
+		*(volatile SYS_UWORD8 *)0xFFFE8001 = 1;
+		on_off = 1;
+		break;
+	default:
+		return;		/* error, but we are a void function */
+	}
+	/* physical backlight on/off */
+	if (on_off)
+		AI_SetBit(9);
+	else
+		AI_ResetBit(9);
+	/* TFT on/off control remains to be implemented */
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cs/drivers/drv_app/r2d/r2d_blrr_api.c	Sat Apr 24 23:38:18 2021 +0000
@@ -0,0 +1,37 @@
+/*
+ * This module implements the blrr_display_ctrl() function defined
+ * in r2d_blrr_api.h; this implementation consists of posting the
+ * necessary internal message to the R2D task.
+ */
+
+#include "r2d/r2d_blrr_api.h"
+#include "r2d/r2d_i.h"
+#include "r2d/r2d_messages.h"
+#include "rv/rv_general.h"
+#include "rvf/rvf_api.h"
+#include "rvm/rvm_use_id_list.h"
+
+T_RV_RET blrr_display_ctrl(enum blrr_display_state arg)
+{
+	T_R2D_EVT *msg;
+
+	if (rvf_get_buf(r2d_mb_id, sizeof(T_R2D_EVT), (T_RVF_BUFFER **)&msg)
+	    == RVF_RED) {
+		rvf_send_trace(
+			"rvf_get_buf() failed in blrr_display_ctrl()", 43,
+			NULL_PARAM, RV_TRACE_LEVEL_ERROR, R2D_USE_ID);
+		return RV_MEMORY_ERR;
+	}
+	msg->os_hdr.msg_id        = R2D_MESSAGE_ONOFF;
+	msg->os_hdr.src_addr_id   = r2d_addr_id;
+	msg->os_hdr.dest_addr_id  = r2d_addr_id;
+	msg->os_hdr.callback_func = NULL;
+	msg->status = arg;
+	if (rvf_send_msg(r2d_addr_id, msg) != RV_OK) {
+		rvf_send_trace("blrr_display_ctrl(): Send failed!", 33,
+				NULL_PARAM, RV_TRACE_LEVEL_ERROR, R2D_USE_ID);
+		rvf_free_buf(msg);
+		return RV_INTERNAL_ERR;
+	}
+	return RV_OK;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cs/drivers/drv_app/r2d/r2d_blrr_api.h	Sat Apr 24 23:38:18 2021 +0000
@@ -0,0 +1,23 @@
+/*
+ * This header file is a FreeCalypso addition to R2D.  It defines
+ * the API for turning BLRR (backlight required for readability)
+ * displays on and off, and for communicating different display modes
+ * which may translate to different display brightness levels
+ * (different backlight intensity levels) on some hw targets.
+ */
+
+#ifndef	__R2D_BLRR_API_H
+#define	__R2D_BLRR_API_H
+
+#include "rv/rv_general.h"
+
+enum blrr_display_state {
+	BLRR_DISPLAY_OFF = 0,
+	BLRR_DISPLAY_ON,
+	BLRR_DISPLAY_INCALL,
+	BLRR_DISPLAY_CHG_BOOT
+};
+
+extern T_RV_RET blrr_display_ctrl(enum blrr_display_state);
+
+#endif	/* include guard */
--- a/src/cs/drivers/drv_app/r2d/r2d_messages.h	Sat Apr 24 19:58:49 2021 +0000
+++ b/src/cs/drivers/drv_app/r2d/r2d_messages.h	Sat Apr 24 23:38:18 2021 +0000
@@ -1,18 +1,18 @@
 /****************************************************************************/
 /*                                                                          */
-/*	File Name:	xxx_messages.h												*/
+/*  File Name:	r2d_messages.h					            */
 /*                                                                          */
-/*	Purpose:	This file contains data structures and functions prototypes */
-/*				used to send events to the XXX SWE.							*/
+/*  Purpose:	This file contains data structures and functions prototypes */
+/*		used to send events to the R2D SWE.			    */
 /*                                                                          */
-/*  Version		0.1															*/
-/*																			*/
-/* 	Date       	Modification												*/
-/*  ------------------------------------									*/
-/*  20/08/2000	Create														*/
-/*																			*/
-/*	Author		David Lamy-Charrier (dlamy@tif.ti.com)						*/
-/*																			*/
+/*  Version	0.1							    */
+/*									    */
+/*  Date       	Modification						    */
+/*  ------------------------------------				    */
+/*  20/08/2000	Create							    */
+/*									    */
+/*  Author	David Lamy-Charrier (dlamy@tif.ti.com)			    */
+/*									    */
 /* (C) Copyright 2000 by Texas Instruments Incorporated, All Rights Reserved*/
 /****************************************************************************/
 #ifndef __R2D_MESSAGES_H_
@@ -27,30 +27,25 @@
 #endif
 
 
-
-
 /* the message offset must differ for each SWE in order to have unique msg_id in the system */
 #define R2D_MESSAGES_OFFSET		(0x36 << 10)
 
 
 /* define a first msg id */
-#define R2D_MESSAGE_1		(R2D_MESSAGES_OFFSET | 0x0001)
-
+#define R2D_MESSAGE_ONOFF	(R2D_MESSAGES_OFFSET | 0x0001)
 
 
 /*****************************************/
 /* structures of messages send to R2D	*/
 typedef struct
 {	T_RV_HDR	os_hdr;
-	BOOLEAN		status;
+	UINT16		status;
 } T_R2D_EVT;
 
 
-
 #ifdef __cplusplus
 }
 #endif
 
 
 #endif /* __R2D_MESSAGES_H_ */
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cs/drivers/drv_app/r2d/r2d_onoff.c	Sat Apr 24 23:38:18 2021 +0000
@@ -0,0 +1,22 @@
+/*
+ * This FreeCalypso-added R2D module implements on/off control
+ * for BLRR (backlight required for readability) displays.
+ */
+
+#include "rv/rv_general.h"
+#include "r2d/r2d_config.h"
+#include "r2d/r2d_messages.h"
+#include "r2d/r2d_blrr_api.h"
+
+#ifdef CONFIG_TARGET_LUNA
+  #include "r2d/lcds/luna/r2d_onoff_i.c"
+#elif defined(CONFIG_TARGET_C139)
+  #include "r2d/lcds/c139/r2d_onoff_i.c"
+#else
+  #error "R2D on/off module selection: unsupported target"
+#endif
+
+void r2d_process_onoff_message(T_R2D_EVT *msg)
+{
+	r2d_onoff_action(msg->status);
+}
--- a/src/cs/drivers/drv_app/r2d/r2d_task.c	Sat Apr 24 19:58:49 2021 +0000
+++ b/src/cs/drivers/drv_app/r2d/r2d_task.c	Sat Apr 24 23:38:18 2021 +0000
@@ -1,8 +1,8 @@
 /**
 
-	@file:	r2d_task.c
+    @file:	r2d_task.c
 
-	@author Christophe Favergeon
+    @author Christophe Favergeon
 
     @version 0.5
 
@@ -12,18 +12,16 @@
 
 /*
 
- 	Date       	Modification
+    Date       	Modification
   ------------------------------------
     06/02/2001	Create
-	10/18/2001  Version 0.5 for first integration with Riviera database
+    10/18/2001  Version 0.5 for first integration with Riviera database
 
 
  (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved
 */
 
 
-
-
 #include "rv/general.h"
 #include "rvf/rvf_api.h"
 #include "rvm/rvm_api.h"
@@ -38,6 +36,8 @@
 
 extern INT16 r2d_g_refresh_disabled;
 
+extern void r2d_process_onoff_message(T_R2D_EVT *msg);
+
 /* FreeCalypso addition */
 int r2d_is_running;
 
@@ -50,7 +50,7 @@
 T_RVM_RETURN r2d_core(void)
 {
 	BOOLEAN error_occured = FALSE;
-//	T_R2D_EVT * msg_ptr_rx, * msg_ptr_tx;
+	T_R2D_EVT *msg;
 
 	//r2d_start();
 
@@ -70,13 +70,25 @@
 		//rvf_send_trace("WAIT EVENT",strlen("WAIT EVENT"), NULL_PARAM,
 		//	   RV_TRACE_LEVEL_DEBUG_HIGH, TRACE_XXX );
 		/* Wait for the necessary events (infinite wait for a msg in the mailbox 0). */
-		 received_event = rvf_wait ( EVENT_MASK(RVF_APPL_EVT_0), 0);
+		received_event = rvf_wait(EVENT_MASK(RVF_APPL_EVT_0) |
+					  RVF_TASK_MBOX_0_EVT_MASK, 0);
 
 		 //rvf_send_trace("EVENT RECEIVED",strlen("EVENT RECEIVED"), NULL_PARAM,
 		//	   RV_TRACE_LEVEL_DEBUG_HIGH, TRACE_XXX );
 
-		/* If an event related to mailbox 0 is received, then */
-		if (received_event & EVENT_MASK(RVF_APPL_EVT_0) )
+		/* Check for mailbox events */
+		if (received_event & RVF_TASK_MBOX_0_EVT_MASK) 
+		{
+			/* Read the message in the driver mailbox and delegate action..*/
+			msg = (T_R2D_EVT *) rvf_read_mbox(RVF_TASK_MBOX_0);
+			if (msg) {
+				if (msg->os_hdr.msg_id == R2D_MESSAGE_ONOFF)
+					r2d_process_onoff_message(msg);
+				rvf_free_buf ((void *) msg);
+			}
+		}
+		/* Check for refresh trigger events */
+		if (received_event & EVENT_MASK(RVF_APPL_EVT_0))
 		{
 			//rvf_send_trace("GOOD EVENT",strlen("GOOD EVENT"), NULL_PARAM,
 			//   RV_TRACE_LEVEL_DEBUG_HIGH, TRACE_XXX );
@@ -86,7 +98,6 @@
 			  r2d_refresh();
 			rvf_delay(RVF_MS_TO_TICKS(R2D_REFRESH_PERIOD));
 		}
-
 	}
 
 	return RVM_OK;