- Merge from trunk up to r45543
[reactos.git] / boot / armllb / hw / versatile / hwclcd.c
1 /*
2 * PROJECT: ReactOS Boot Loader
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: boot/armllb/hw/versatile/hwclcd.c
5 * PURPOSE: LLB CLCD Routines for Versatile
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9 #include "precomp.h"
10
11 #define LCDTIMING0_PPL(x) ((((x) / 16 - 1) & 0x3f) << 2)
12 #define LCDTIMING1_LPP(x) (((x) & 0x3ff) - 1)
13 #define LCDCONTROL_LCDPWR (1 << 11)
14 #define LCDCONTROL_LCDEN (1)
15 #define LCDCONTROL_LCDBPP(x) (((x) & 7) << 1)
16 #define LCDCONTROL_LCDTFT (1 << 5)
17
18 #define PL110_LCDTIMING0 (PVOID)0x10120000
19 #define PL110_LCDTIMING1 (PVOID)0x10120004
20 #define PL110_LCDTIMING2 (PVOID)0x10120008
21 #define PL110_LCDUPBASE (PVOID)0x10120010
22 #define PL110_LCDLPBASE (PVOID)0x10120014
23 #define PL110_LCDCONTROL (PVOID)0x10120018
24
25 PUSHORT LlbHwVideoBuffer;
26
27 VOID
28 NTAPI
29 LlbHwVersaClcdInitialize(VOID)
30 {
31 /* Set framebuffer address */
32 WRITE_REGISTER_ULONG(PL110_LCDUPBASE, (ULONG)LlbHwGetFrameBuffer());
33 WRITE_REGISTER_ULONG(PL110_LCDLPBASE, (ULONG)LlbHwGetFrameBuffer());
34
35 /* Initialize timings to 720x400 */
36 WRITE_REGISTER_ULONG(PL110_LCDTIMING0, LCDTIMING0_PPL(LlbHwGetScreenWidth()));
37 WRITE_REGISTER_ULONG(PL110_LCDTIMING1, LCDTIMING1_LPP(LlbHwGetScreenHeight()));
38
39 /* Enable the TFT/LCD Display */
40 WRITE_REGISTER_ULONG(PL110_LCDCONTROL,
41 LCDCONTROL_LCDEN |
42 LCDCONTROL_LCDTFT |
43 LCDCONTROL_LCDPWR |
44 LCDCONTROL_LCDBPP(4));
45 }
46
47 ULONG
48 NTAPI
49 LlbHwGetScreenWidth(VOID)
50 {
51 return 720;
52 }
53
54 ULONG
55 NTAPI
56 LlbHwGetScreenHeight(VOID)
57 {
58 return 400;
59 }
60
61 PVOID
62 NTAPI
63 LlbHwGetFrameBuffer(VOID)
64 {
65 return (PVOID)0x000A0000;
66 }
67
68 ULONG
69 NTAPI
70 LlbHwVideoCreateColor(IN ULONG Red,
71 IN ULONG Green,
72 IN ULONG Blue)
73 {
74 return (((Blue >> 3) << 11)| ((Green >> 2) << 5)| ((Red >> 3) << 0));
75 }
76
77 /* EOF */