@@ -31,6 +31,9 @@ typedef struct _FRAMEBUFFER_INFO
3131 ULONG PixelsPerScanLine ; // aka. "Pitch" or "ScreenStride", but Stride is in bytes or bits...
3232 ULONG BitsPerPixel ; // aka. "PixelStride".
3333
34+ /* Physical format of the pixel for BPP > 8, specified by bit-mask */
35+ PIXEL_BITMASK PixelMasks ;
36+
3437/** Calculated values */
3538
3639 ULONG BytesPerPixel ;
@@ -55,6 +58,11 @@ VidFbPrintFramebufferInfo(VOID)
5558 TRACE (" BitsPerPixel : %lu\n" , framebufInfo .BitsPerPixel );
5659 TRACE (" BytesPerPixel : %lu\n" , framebufInfo .BytesPerPixel );
5760 TRACE (" Delta : %lu\n" , framebufInfo .Delta );
61+ TRACE (" ARGB masks: : %08x/%08x/%08x/%08x\n" ,
62+ framebufInfo .PixelMasks .ReservedMask ,
63+ framebufInfo .PixelMasks .RedMask ,
64+ framebufInfo .PixelMasks .GreenMask ,
65+ framebufInfo .PixelMasks .BlueMask );
5866}
5967#endif
6068
@@ -78,6 +86,10 @@ VidFbPrintFramebufferInfo(VOID)
7886 * @param[in] BitsPerPixel
7987 * The number of usable bits (not counting the reserved ones) per pixel.
8088 *
89+ * @param[in] PixelMasks
90+ * Optional pointer to a PIXEL_BITMASK structure describing the pixel
91+ * format used by the framebuffer.
92+ *
8193 * @return
8294 * TRUE if initialization is successful; FALSE if not.
8395 **/
@@ -88,8 +100,11 @@ VidFbInitializeVideo(
88100 _In_ UINT32 ScreenWidth ,
89101 _In_ UINT32 ScreenHeight ,
90102 _In_ UINT32 PixelsPerScanLine ,
91- _In_ UINT32 BitsPerPixel )
103+ _In_ UINT32 BitsPerPixel ,
104+ _In_opt_ PPIXEL_BITMASK PixelMasks )
92105{
106+ PPIXEL_BITMASK BitMasks = & framebufInfo .PixelMasks ;
107+
93108 RtlZeroMemory (& framebufInfo , sizeof (framebufInfo ));
94109
95110 framebufInfo .BaseAddress = BaseAddress ;
@@ -110,8 +125,66 @@ VidFbInitializeVideo(
110125 return FALSE;
111126 }
112127
128+ //ASSERT((BitsPerPixel <= 8 && !PixelMasks) || (BitsPerPixel > 8));
129+ if (BitsPerPixel > 8 )
130+ {
131+ if (!PixelMasks ||
132+ (PixelMasks -> RedMask == 0 &&
133+ PixelMasks -> GreenMask == 0 &&
134+ PixelMasks -> BlueMask == 0 /* &&
135+ PixelMasks->ReservedMask == 0 */ ))
136+ {
137+ /* Determine pixel mask given color depth and color channel */
138+ switch (BitsPerPixel )
139+ {
140+ case 32 :
141+ case 24 : /* 8:8:8 */
142+ BitMasks -> RedMask = 0x00FF0000 ; // 0x00FF0000;
143+ BitMasks -> GreenMask = 0x0000FF00 ; // 0x00FF0000 >> 8;
144+ BitMasks -> BlueMask = 0x000000FF ; // 0x00FF0000 >> 16;
145+ BitMasks -> ReservedMask = ((1 << (BitsPerPixel - 24 )) - 1 ) << 24 ;
146+ break ;
147+ case 16 : /* 5:6:5 */
148+ BitMasks -> RedMask = 0xF800 ; // 0xF800;
149+ BitMasks -> GreenMask = 0x07E0 ; // (0xF800 >> 5) | 0x20;
150+ BitMasks -> BlueMask = 0x001F ; // 0xF800 >> 11;
151+ BitMasks -> ReservedMask = 0 ;
152+ break ;
153+ case 15 : /* 5:5:5 */
154+ BitMasks -> RedMask = 0x7C00 ; // 0x7C00;
155+ BitMasks -> GreenMask = 0x03E0 ; // 0x7C00 >> 5;
156+ BitMasks -> BlueMask = 0x001F ; // 0x7C00 >> 10;
157+ BitMasks -> ReservedMask = 0x8000 ;
158+ break ;
159+ default :
160+ /* Unsupported BPP */
161+ UNIMPLEMENTED ;
162+ RtlZeroMemory (BitMasks , sizeof (* BitMasks ));
163+ }
164+ }
165+ else
166+ {
167+ /* Copy the pixel masks */
168+ RtlCopyMemory (BitMasks , PixelMasks , sizeof (* BitMasks ));
169+ }
170+ }
171+ else
172+ {
173+ /* Palettized modes don't use masks */
174+ RtlZeroMemory (BitMasks , sizeof (* BitMasks ));
175+ }
176+
113177#if DBG
114178 VidFbPrintFramebufferInfo ();
179+ {
180+ ULONG BppFromMasks =
181+ PixelBitmasksToBpp (BitMasks -> RedMask ,
182+ BitMasks -> GreenMask ,
183+ BitMasks -> BlueMask ,
184+ BitMasks -> ReservedMask );
185+ TRACE ("BitsPerPixel = %lu , BppFromMasks = %lu\n" , BitsPerPixel , BppFromMasks );
186+ //ASSERT(BitsPerPixel == BppFromMasks);
187+ }
115188#endif
116189
117190 return TRUE;
0 commit comments