]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
ArmPlatformPkg: create hw-agnostic LcdGraphicsOutputDxe driver
[mirror_edk2.git] / ArmPlatformPkg / Drivers / LcdGraphicsOutputDxe / HdLcd.c
CommitLineData
f8c9f1c1 1/** @file Lcd.c\r
2\r
3 Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>\r
4\r
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include <Library/DebugLib.h>\r
16#include <Library/IoLib.h>\r
17#include <Library/LcdPlatformLib.h>\r
18#include <Library/MemoryAllocationLib.h>\r
19#include <Library/PcdLib.h>\r
20\r
eb618ba4 21#include "HdLcd.h"\r
f8c9f1c1 22#include "LcdGraphicsOutputDxe.h"\r
23\r
24/**********************************************************************\r
25 *\r
26 * This file contains all the bits of the Lcd that are\r
27 * platform independent.\r
28 *\r
29 **********************************************************************/\r
30\r
31EFI_STATUS\r
32LcdInitialize (\r
33 IN EFI_PHYSICAL_ADDRESS VramBaseAddress\r
34 )\r
35{\r
36 // Disable the controller\r
37 MmioWrite32(HDLCD_REG_COMMAND, HDLCD_DISABLE);\r
38\r
39 // Disable all interrupts\r
40 MmioWrite32(HDLCD_REG_INT_MASK, 0);\r
41\r
42 // Define start of the VRAM. This never changes for any graphics mode\r
43 MmioWrite32(HDLCD_REG_FB_BASE, (UINT32) VramBaseAddress);\r
44\r
45 // Setup various registers that never change\r
46 MmioWrite32(HDLCD_REG_BUS_OPTIONS, (4 << 8) | HDLCD_BURST_8);\r
47 MmioWrite32(HDLCD_REG_POLARITIES, HDLCD_PXCLK_LOW | HDLCD_DATA_HIGH | HDLCD_DATEN_HIGH | HDLCD_HSYNC_LOW | HDLCD_VSYNC_HIGH);\r
48 MmioWrite32(HDLCD_REG_PIXEL_FORMAT, HDLCD_LITTLE_ENDIAN | HDLCD_4BYTES_PER_PIXEL);\r
49 MmioWrite32(HDLCD_REG_RED_SELECT, (0 << 16 | 8 << 8 | 0));\r
50 MmioWrite32(HDLCD_REG_GREEN_SELECT, (0 << 16 | 8 << 8 | 8));\r
51 MmioWrite32(HDLCD_REG_BLUE_SELECT, (0 << 16 | 8 << 8 | 16));\r
52\r
53 return EFI_SUCCESS;\r
54}\r
55\r
56EFI_STATUS\r
57LcdSetMode (\r
58 IN UINT32 ModeNumber\r
59 )\r
60{\r
61 EFI_STATUS Status;\r
62 UINT32 HRes;\r
63 UINT32 HSync;\r
64 UINT32 HBackPorch;\r
65 UINT32 HFrontPorch;\r
66 UINT32 VRes;\r
67 UINT32 VSync;\r
68 UINT32 VBackPorch;\r
69 UINT32 VFrontPorch;\r
70 UINT32 BytesPerPixel;\r
71 LCD_BPP LcdBpp;\r
72\r
73\r
74 // Set the video mode timings and other relevant information\r
75 Status = LcdPlatformGetTimings (ModeNumber,\r
76 &HRes,&HSync,&HBackPorch,&HFrontPorch,\r
77 &VRes,&VSync,&VBackPorch,&VFrontPorch);\r
78 ASSERT_EFI_ERROR (Status);\r
79 if (EFI_ERROR( Status )) {\r
80 return EFI_DEVICE_ERROR;\r
81 }\r
82\r
83 Status = LcdPlatformGetBpp (ModeNumber,&LcdBpp);\r
84 ASSERT_EFI_ERROR (Status);\r
85 if (EFI_ERROR( Status )) {\r
86 return EFI_DEVICE_ERROR;\r
87 }\r
88\r
89 BytesPerPixel = GetBytesPerPixel(LcdBpp);\r
90\r
91 // Disable the controller\r
92 MmioWrite32(HDLCD_REG_COMMAND, HDLCD_DISABLE);\r
93\r
94 // Update the frame buffer information with the new settings\r
95 MmioWrite32(HDLCD_REG_FB_LINE_LENGTH, HRes * BytesPerPixel);\r
96 MmioWrite32(HDLCD_REG_FB_LINE_PITCH, HRes * BytesPerPixel);\r
97 MmioWrite32(HDLCD_REG_FB_LINE_COUNT, VRes - 1);\r
98\r
99 // Set the vertical timing information\r
100 MmioWrite32(HDLCD_REG_V_SYNC, VSync);\r
101 MmioWrite32(HDLCD_REG_V_BACK_PORCH, VBackPorch);\r
102 MmioWrite32(HDLCD_REG_V_DATA, VRes - 1);\r
103 MmioWrite32(HDLCD_REG_V_FRONT_PORCH, VFrontPorch);\r
104\r
105 // Set the horizontal timing information\r
106 MmioWrite32(HDLCD_REG_H_SYNC, HSync);\r
107 MmioWrite32(HDLCD_REG_H_BACK_PORCH, HBackPorch);\r
108 MmioWrite32(HDLCD_REG_H_DATA, HRes - 1);\r
109 MmioWrite32(HDLCD_REG_H_FRONT_PORCH, HFrontPorch);\r
110\r
111 // Enable the controller\r
112 MmioWrite32(HDLCD_REG_COMMAND, HDLCD_ENABLE);\r
113\r
114 return EFI_SUCCESS;\r
115}\r
116\r
117VOID\r
118LcdShutdown (\r
119 VOID\r
120 )\r
121{\r
d8c4bb9a
OM
122 // Disable the controller\r
123 MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE);\r
f8c9f1c1 124}\r
5fe98716
AB
125\r
126EFI_STATUS\r
127LcdIdentify (\r
128 VOID\r
129 )\r
130{\r
131 return EFI_SUCCESS;\r
132}\r