Modules/PL110 - Added support for the Versatile version
authorJohn Hodge <[email protected]>
Thu, 20 Oct 2011 13:12:06 +0000 (21:12 +0800)
committerJohn Hodge <[email protected]>
Thu, 20 Oct 2011 13:12:06 +0000 (21:12 +0800)
Modules/Display/PL110/main.c

index 4f6ab77..6fa8598 100644 (file)
@@ -79,11 +79,13 @@ tDevFS_Driver       gPL110_DriverStruct = {
 };\r
 // -- Options\r
 tPAddr gPL110_PhysBase = PL110_BASE;\r
+ int   gbPL110_IsVersatile = 1;\r
 // -- KeyVal parse rules\r
 const tKeyVal_ParseRules       gPL110_KeyValueParser = {\r
        NULL,\r
        {\r
                {"Base", "P", &gPL110_PhysBase},\r
+               {"IsVersatile", "i", &gbPL110_IsVersatile},\r
                {NULL, NULL, NULL}\r
        }\r
 };\r
@@ -258,10 +260,18 @@ int PL110_IOCtl(tVFS_Node *Node, int ID, void *Data)
 //\r
 \r
 /**\r
+ * \brief Set the LCD controller resolution\r
+ * \param W    Width (aligned to 16 pixels, cipped to 1024)\r
+ * \param H    Height (clipped to 768)\r
+ * \return Boolean failure\r
  */\r
 int PL110_int_SetResolution(int W, int H)\r
 {\r
-       W = (W + 15)/16;\r
+       W = (W + 15) & ~0xF;\r
+       if(W <= 0 || H <= 0) {\r
+               Log_Warning("PL110", "Attempted to set invalid resolution (%ix%i)", W, H);\r
+               return 1;\r
+       }\r
        if(W > 1024)    W = 1024;\r
        if(H > 768)     H = 768;\r
 \r
@@ -279,8 +289,20 @@ int PL110_int_SetResolution(int W, int H)
        gpPL110_IOMem->LCDUPBase = gPL110_FramebufferPhys;\r
        gpPL110_IOMem->LCDLPBase = 0;\r
 \r
-       gpPL110_IOMem->LCDIMSC = 0;\r
-       gpPL110_IOMem->LCDControl = (1 << 11)|(1 << 5)|(5<<1)|1;\r
+       // Power on, BGR mode, ???, ???, enabled\r
+       Uint32  controlWord = (1 << 11)|(1 << 8)|(1 << 5)|(5 << 1)|1;\r
+       // According to qemu, the Versatile version has these two the wrong\r
+       // way around\r
+       if( gbPL110_IsVersatile )\r
+       {\r
+               gpPL110_IOMem->LCDIMSC = controlWord;   // Actually LCDControl\r
+               gpPL110_IOMem->LCDControl = 0;  // Actually LCDIMSC\r
+       }\r
+       else\r
+       {\r
+               gpPL110_IOMem->LCDIMSC = 0;\r
+               gpPL110_IOMem->LCDControl = controlWord;\r
+       }\r
 \r
        giPL110_Width = W;\r
        giPL110_Height = H;\r

UCC git Repository :: git.ucc.asn.au