Modules/PL110 - Added support for the Versatile version
[tpg/acess2.git] / Modules / Display / PL110 / main.c
index f1604c6..6fa8598 100644 (file)
@@ -44,7 +44,8 @@ struct sPL110
 };\r
 \r
 // === CONSTANTS ===\r
-#define PL110_BASE     0x10020000      \r
+#define PL110_BASE     0x10020000      // Integrator\r
+\r
 const struct {\r
        short W, H;\r
 }      caPL110_Modes[] = {\r
@@ -78,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
@@ -134,7 +137,8 @@ Uint64 PL110_Read(tVFS_Node *node, Uint64 off, Uint64 len, void *buffer)
  */\r
 Uint64 PL110_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)\r
 {\r
-       return DrvUtil_Video_WriteLFB(giPL110_BufferMode, &gPL110_DrvUtil_BufInfo, Offset, Length, Buffer);\r
+       gPL110_DrvUtil_BufInfo.BufferFormat = giPL110_BufferMode;\r
+       return DrvUtil_Video_WriteLFB(&gPL110_DrvUtil_BufInfo, Offset, Length, Buffer);\r
 }\r
 \r
 const char *csaPL110_IOCtls[] = {DRV_IOCTLNAMES, DRV_VIDEO_IOCTLNAMES, NULL};\r
@@ -256,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
@@ -277,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