\r
#include "HdLcd.h"\r
\r
-STATIC\r
-UINTN\r
-GetBytesPerPixel (\r
- IN LCD_BPP Bpp\r
- )\r
-{\r
- switch (Bpp) {\r
- case LCD_BITS_PER_PIXEL_24:\r
- return 4;\r
-\r
- case LCD_BITS_PER_PIXEL_16_565:\r
- case LCD_BITS_PER_PIXEL_16_555:\r
- case LCD_BITS_PER_PIXEL_12_444:\r
- return 2;\r
-\r
- case LCD_BITS_PER_PIXEL_8:\r
- case LCD_BITS_PER_PIXEL_4:\r
- case LCD_BITS_PER_PIXEL_2:\r
- case LCD_BITS_PER_PIXEL_1:\r
- return 1;\r
-\r
- default:\r
- return 0;\r
- }\r
-}\r
+#define BYTES_PER_PIXEL 4\r
\r
/** Initialize display.\r
\r
HDLCD_LITTLE_ENDIAN | HDLCD_4BYTES_PER_PIXEL\r
);\r
\r
- MmioWrite32 (HDLCD_REG_RED_SELECT, (0 << 16 | 8 << 8 | 0));\r
- MmioWrite32 (HDLCD_REG_GREEN_SELECT, (0 << 16 | 8 << 8 | 8));\r
- MmioWrite32 (HDLCD_REG_BLUE_SELECT, (0 << 16 | 8 << 8 | 16));\r
-\r
return EFI_SUCCESS;\r
}\r
\r
EFI_STATUS Status;\r
SCAN_TIMINGS *Horizontal;\r
SCAN_TIMINGS *Vertical;\r
- UINT32 BytesPerPixel;\r
- LCD_BPP LcdBpp;\r
+\r
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION ModeInfo;\r
\r
// Set the video mode timings and other relevant information\r
Status = LcdPlatformGetTimings (\r
ASSERT (Horizontal != NULL);\r
ASSERT (Vertical != NULL);\r
\r
- Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);\r
+ // Get the pixel format information.\r
+ Status = LcdPlatformQueryMode (ModeNumber, &ModeInfo);\r
if (EFI_ERROR (Status)) {\r
ASSERT_EFI_ERROR (Status);\r
return Status;\r
}\r
\r
- BytesPerPixel = GetBytesPerPixel (LcdBpp);\r
+ if (ModeInfo.PixelFormat == PixelBlueGreenRedReserved8BitPerColor) {\r
+ MmioWrite32 (HDLCD_REG_RED_SELECT, (8 << 8) | 16);\r
+ MmioWrite32 (HDLCD_REG_BLUE_SELECT, (8 << 8) | 0);\r
+ } else {\r
+ MmioWrite32 (HDLCD_REG_BLUE_SELECT, (8 << 8) | 16);\r
+ MmioWrite32 (HDLCD_REG_RED_SELECT, (8 << 8) | 0);\r
+ }\r
+\r
+ MmioWrite32 (HDLCD_REG_GREEN_SELECT, (8 << 8) | 8);\r
\r
// Disable the controller\r
MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE);\r
// Update the frame buffer information with the new settings\r
MmioWrite32 (\r
HDLCD_REG_FB_LINE_LENGTH,\r
- Horizontal->Resolution * BytesPerPixel\r
+ Horizontal->Resolution * BYTES_PER_PIXEL\r
);\r
\r
- MmioWrite32 (HDLCD_REG_FB_LINE_PITCH, Horizontal->Resolution * BytesPerPixel);\r
+ MmioWrite32 (\r
+ HDLCD_REG_FB_LINE_PITCH,\r
+ Horizontal->Resolution * BYTES_PER_PIXEL\r
+ );\r
\r
MmioWrite32 (HDLCD_REG_FB_LINE_COUNT, Vertical->Resolution - 1);\r
\r