From 51936e950e82bcb443ea2a54139cf6fd60e9f5c6 Mon Sep 17 00:00:00 2001
From: Jeffrey Lee <jlee@gitlab.riscosopen.org>
Date: Tue, 17 Dec 2013 23:49:47 +0000
Subject: [PATCH] Re-enable Pandora TV-out support

Detail:
  s/board - Re-enable Pandora TV-out support now that we have the ability to turn TV-out power on/off
  hdr/board, s/Video - Add the new TV-out power control function to the video board config struct. All OMAP boards should be able to use the same implementation, which enables/disables the VDAC power supply in the TPS
Admin:
  Tested on BB-xM and Pandora
  TV detection (and TV-out in general) now works properly on the Pandora


Version 0.94. Tagged as 'OMAP3-0_94'
---
 VersionNum | 14 +++++++-------
 hdr/board  |  1 +
 s/Video    | 26 ++++++++++++++++++++++++++
 s/board    |  2 +-
 4 files changed, 35 insertions(+), 8 deletions(-)

diff --git a/VersionNum b/VersionNum
index b466cbd..3fc9e53 100644
--- a/VersionNum
+++ b/VersionNum
@@ -1,15 +1,15 @@
-/* (0.93)
+/* (0.94)
  *
  * This file is automatically maintained by srccommit, do not edit manually.
  * Last processed by srccommit version: 1.1.
  *
  */
-#define Module_MajorVersion_CMHG        0.93
+#define Module_MajorVersion_CMHG        0.94
 #define Module_MinorVersion_CMHG        
 #define Module_Date_CMHG                17 Dec 2013
 
-#define Module_MajorVersion             "0.93"
-#define Module_Version                  93
+#define Module_MajorVersion             "0.94"
+#define Module_Version                  94
 #define Module_MinorVersion             ""
 #define Module_Date                     "17 Dec 2013"
 
@@ -18,6 +18,6 @@
 #define Module_ComponentName            "OMAP3"
 #define Module_ComponentPath            "castle/RiscOS/Sources/HAL/OMAP3"
 
-#define Module_FullVersion              "0.93"
-#define Module_HelpVersion              "0.93 (17 Dec 2013)"
-#define Module_LibraryVersionInfo       "0:93"
+#define Module_FullVersion              "0.94"
+#define Module_HelpVersion              "0.94 (17 Dec 2013)"
+#define Module_LibraryVersionInfo       "0:94"
diff --git a/hdr/board b/hdr/board
index 29fcfbb..2d511d8 100644
--- a/hdr/board
+++ b/hdr/board
@@ -126,6 +126,7 @@ VideoBoardConfig_Num_LCDs        # 1 ; Number of LCD outputs available
 VideoBoardConfig_MySize          # 2 ; sizeof(VideoBoardConfig), or 0 for old HAL
 VideoBoardConfig_LCD_Configs     # 4 ; Pointer to list of LCD configs
 VideoBoardConfig_TVDet_Func      # 4 ; Function to poll TV detection signal
+VideoBoardConfig_TVPower_Func    # 4 ; Function to control TV out power. R0=hal device, R1=on/off flag
 VideoBoardConfig_Size            # 0
 
 VideoBoardConfig_Flags_SVideo    * 1
diff --git a/s/Video b/s/Video
index f7c2807..a1f4d37 100644
--- a/s/Video
+++ b/s/Video
@@ -45,6 +45,7 @@
         IMPORT  GPIOx_SetAsOutput
         IMPORT  GPIOx_SetOutput
         IMPORT  HAL_CounterDelay
+        IMPORT  TPSWrite
 
 Video_Init
         ; Configure GPIO pins so we can turn the DVI framer on/off
@@ -90,6 +91,8 @@ VideoDevice_Init
         STR     a2, [a3, #VideoBoardConfig_LCD_Configs]
         ADR     a2, Video_TVDet_Func
         STR     a2, [a3, #VideoBoardConfig_TVDet_Func]
+        ADR     a2, Video_TVPower_Func
+        STR     a2, [a3, #VideoBoardConfig_TVPower_Func]
         MOV     a1, #0
         MOV     a2, v1
         CallOS  OS_AddDevice
@@ -226,6 +229,29 @@ Video_TVDet_Func
         GPIO_GetInput a1, a1, a2
         EXIT
 
+Video_TVPower_Func
+        Entry   "v1-v2,sb", 4
+        LDR     sb, VideoWorkspace
+        LDR     v1, OSentries+4*OS_IICOpV
+        MOVS    ip, a2
+        MOV     a3, #1
+        MOV     a2, sp
+        BEQ     %FT50
+        ; Configure VDAC for 1.8V output
+        MOV     a1, #&4b*2
+        MOV     ip, #3
+        MOV     a4, #&99 ; VDAC_DEDICATED
+        STR     ip, [a2]
+        BL      TPSWrite
+        ; Enable it
+        MOV     ip, #&20
+50      ; Arrive here with ip=0 when disabling
+        MOV     a1, #&4b*2
+        MOV     a4, #&96 ; VDAC_DEV_GRP
+        STR     ip, [a2]
+        BL      TPSWrite
+        EXIT
+
 Video_SetPandoraGamma ROUT
         Entry   "v1-v4"
         ADR     a1, PandoraGamma
diff --git a/s/board b/s/board
index ea3a919..a165059 100644
--- a/s/board
+++ b/s/board
@@ -136,7 +136,7 @@ BoardConfigTable
         BOARDCFG "BeagleBoard", BeagleBoard, L4_UART3, "123", 3,          "123", 3,     2,       &16,     170,            147,    M_HSO+M_AI,      VBC_SV,   1,         VBC_DVI
         BOARDCFG "DevKit8000",  DevKit8000,  L4_UART3, "123", 3,          "132", 3,     2,       &16,     GPIO_PIN_MAX+7, 147,    M_HSO+M_AI,      VBC_SV,   1,         VBC_DVI       ; TODO - If USB host is completely broken, we should hide it from RO
         BOARDCFG "IGEPv2",      IGEPv2,      L4_UART3, "123", 3,          "123", 3,     2,       &16,     170,            24,     M_HSO+M_AI,      0,        1,         VBC_DVI
-        BOARDCFG "Pandora",     Pandora,     L4_UART3, "123", 3,          "123", 3,     255,     &16,     255,            16,     M_HSO+M_AI+M_PD, 0,        1,         VBC_Pandora
+        BOARDCFG "Pandora",     Pandora,     L4_UART3, "123", 3,          "123", 3,     255,     &16,     255,            16,     M_HSO+M_AI+M_PD, VBC_Both, 1,         VBC_Pandora
         BOARDCFG "Touch Book",  TouchBook,   L4_UART3, "123", 3,          "123", 3,     255,     &16,     176,            147,    M_HSO+M_AI+M_HF, 0,        1,         VBC_TouchBook
         BOARDCFG "OMAP3 EVM",   OMAP35xEVM,  L4_UART1, "123", 1,          "123", 3,     255,     &16,     GPIO_PIN_MAX+7, 21,     M_HSO+M_AI,      VBC_Both, 1,         VBC_DVI
 BoardConfigTable_End
-- 
GitLab