Fixes to FbpGetPixelInformation() and FbpGetColorMask() routines

This commit is contained in:
Rafal Kupiec 2024-05-12 22:20:22 +02:00
parent 3d08be4fac
commit 615a1457bf
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
3 changed files with 42 additions and 39 deletions

View File

@ -269,14 +269,14 @@ typedef struct _XTBL_FRAMEBUFFER_MODE_INFORMATION
EFI_GRAPHICS_PIXEL_FORMAT PixelFormat; EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
struct struct
{ {
USHORT BlueMask;
USHORT BlueShift; USHORT BlueShift;
USHORT GreenMask; USHORT BlueSize;
USHORT GreenShift; USHORT GreenShift;
USHORT RedMask; USHORT GreenSize;
USHORT RedShift; USHORT RedShift;
USHORT ReservedMask; USHORT RedSize;
USHORT ReservedShift; USHORT ReservedShift;
USHORT ReservedSize;
} PixelInformation; } PixelInformation;
} XTBL_FRAMEBUFFER_MODE_INFORMATION, *PXTBL_FRAMEBUFFER_MODE_INFORMATION; } XTBL_FRAMEBUFFER_MODE_INFORMATION, *PXTBL_FRAMEBUFFER_MODE_INFORMATION;

View File

@ -524,8 +524,8 @@ FbpFindFramebufferAddress(OUT PEFI_PHYSICAL_ADDRESS Address)
* @param PixelBitMask * @param PixelBitMask
* Provides a pixel bit mask. * Provides a pixel bit mask.
* *
* @param ColorMask * @param ColorSize
* Supplies a pointer to the memory area where the color mask will be stored. * Supplies a pointer to the memory area where the color size will be stored.
* *
* @param ColorShift * @param ColorShift
* Supplies a pointer to the memory area where the color shift (position) will be stored. * Supplies a pointer to the memory area where the color shift (position) will be stored.
@ -537,34 +537,37 @@ FbpFindFramebufferAddress(OUT PEFI_PHYSICAL_ADDRESS Address)
XTCDECL XTCDECL
VOID VOID
FbpGetColorMask(IN UINT PixelBitMask, FbpGetColorMask(IN UINT PixelBitMask,
OUT PUSHORT ColorMask, OUT PUSHORT ColorSize,
OUT PUSHORT ColorShift) OUT PUSHORT ColorShift)
{ {
UINT Index, Mask; UINT Shift, Size;
/* Initialize variables */ /* Initialize variables */
Index = 0; Shift = 0;
Mask = 1; Size = 0;
/* Make sure EfiMask is not zero */ /* Make sure EfiMask is not zero */
if(PixelBitMask) if(PixelBitMask)
{ {
while((Index < 32) && ((PixelBitMask & Mask) == 0)) /* Get color shift */
while((PixelBitMask & 1) == 0)
{ {
Index++; Shift++;
Mask <<= 1; PixelBitMask >>= 1;
}
/* Get color size */
while((PixelBitMask & 1) == 1)
{
Size++;
PixelBitMask >>= 1;
} }
/* Set color mask and shift */
*ColorShift = Index;
*ColorMask = (Mask >> Index);
}
else
{
/* Set default color mask and shift */
*ColorMask = 0;
*ColorShift = 0;
} }
/* Set color mask and shift */
*ColorShift = Shift;
*ColorSize = Size;
} }
/** /**
@ -672,26 +675,26 @@ FbpGetPixelInformation(IN PEFI_PIXEL_BITMASK PixelsBitMask)
case PixelBlueGreenRedReserved8BitPerColor: case PixelBlueGreenRedReserved8BitPerColor:
/* BGRR, 32 bits per pixel */ /* BGRR, 32 bits per pixel */
FbpDisplayInfo.ModeInfo.BitsPerPixel = 32; FbpDisplayInfo.ModeInfo.BitsPerPixel = 32;
FbpDisplayInfo.ModeInfo.PixelInformation.BlueMask = 0xFF;
FbpDisplayInfo.ModeInfo.PixelInformation.BlueShift = 0; FbpDisplayInfo.ModeInfo.PixelInformation.BlueShift = 0;
FbpDisplayInfo.ModeInfo.PixelInformation.GreenMask = 0xFF; FbpDisplayInfo.ModeInfo.PixelInformation.BlueSize = 8;
FbpDisplayInfo.ModeInfo.PixelInformation.GreenShift = 8; FbpDisplayInfo.ModeInfo.PixelInformation.GreenShift = 8;
FbpDisplayInfo.ModeInfo.PixelInformation.RedMask = 0xFF; FbpDisplayInfo.ModeInfo.PixelInformation.GreenSize = 8;
FbpDisplayInfo.ModeInfo.PixelInformation.RedShift = 16; FbpDisplayInfo.ModeInfo.PixelInformation.RedShift = 16;
FbpDisplayInfo.ModeInfo.PixelInformation.ReservedMask = 0xFF; FbpDisplayInfo.ModeInfo.PixelInformation.RedSize = 8;
FbpDisplayInfo.ModeInfo.PixelInformation.ReservedShift = 24; FbpDisplayInfo.ModeInfo.PixelInformation.ReservedShift = 24;
FbpDisplayInfo.ModeInfo.PixelInformation.ReservedSize = 8;
break; break;
case PixelRedGreenBlueReserved8BitPerColor: case PixelRedGreenBlueReserved8BitPerColor:
/* RGBR, 32 bits per pixel */ /* RGBR, 32 bits per pixel */
FbpDisplayInfo.ModeInfo.BitsPerPixel = 32; FbpDisplayInfo.ModeInfo.BitsPerPixel = 32;
FbpDisplayInfo.ModeInfo.PixelInformation.BlueMask = 0xFF;
FbpDisplayInfo.ModeInfo.PixelInformation.BlueShift = 16; FbpDisplayInfo.ModeInfo.PixelInformation.BlueShift = 16;
FbpDisplayInfo.ModeInfo.PixelInformation.GreenMask = 0xFF; FbpDisplayInfo.ModeInfo.PixelInformation.BlueSize = 8;
FbpDisplayInfo.ModeInfo.PixelInformation.GreenShift = 8; FbpDisplayInfo.ModeInfo.PixelInformation.GreenShift = 8;
FbpDisplayInfo.ModeInfo.PixelInformation.RedMask = 0xFF; FbpDisplayInfo.ModeInfo.PixelInformation.GreenSize = 8;
FbpDisplayInfo.ModeInfo.PixelInformation.RedShift = 0; FbpDisplayInfo.ModeInfo.PixelInformation.RedShift = 0;
FbpDisplayInfo.ModeInfo.PixelInformation.ReservedMask = 0xFF; FbpDisplayInfo.ModeInfo.PixelInformation.RedSize = 8;
FbpDisplayInfo.ModeInfo.PixelInformation.ReservedShift = 24; FbpDisplayInfo.ModeInfo.PixelInformation.ReservedShift = 24;
FbpDisplayInfo.ModeInfo.PixelInformation.ReservedSize = 8;
break; break;
case PixelBitMask: case PixelBitMask:
/* Assume 32 bits per pixel */ /* Assume 32 bits per pixel */
@ -711,26 +714,26 @@ FbpGetPixelInformation(IN PEFI_PIXEL_BITMASK PixelsBitMask)
} }
/* Set pixel information */ /* Set pixel information */
FbpGetColorMask(PixelsBitMask->RedMask, &FbpDisplayInfo.ModeInfo.PixelInformation.RedMask, FbpGetColorMask(PixelsBitMask->RedMask, &FbpDisplayInfo.ModeInfo.PixelInformation.RedSize,
&FbpDisplayInfo.ModeInfo.PixelInformation.RedShift); &FbpDisplayInfo.ModeInfo.PixelInformation.RedShift);
FbpGetColorMask(PixelsBitMask->GreenMask, &FbpDisplayInfo.ModeInfo.PixelInformation.GreenMask, FbpGetColorMask(PixelsBitMask->GreenMask, &FbpDisplayInfo.ModeInfo.PixelInformation.GreenSize,
&FbpDisplayInfo.ModeInfo.PixelInformation.GreenShift); &FbpDisplayInfo.ModeInfo.PixelInformation.GreenShift);
FbpGetColorMask(PixelsBitMask->BlueMask, &FbpDisplayInfo.ModeInfo.PixelInformation.BlueMask, FbpGetColorMask(PixelsBitMask->BlueMask, &FbpDisplayInfo.ModeInfo.PixelInformation.BlueSize,
&FbpDisplayInfo.ModeInfo.PixelInformation.BlueShift); &FbpDisplayInfo.ModeInfo.PixelInformation.BlueShift);
FbpGetColorMask(PixelsBitMask->ReservedMask, &FbpDisplayInfo.ModeInfo.PixelInformation.ReservedMask, FbpGetColorMask(PixelsBitMask->ReservedMask, &FbpDisplayInfo.ModeInfo.PixelInformation.ReservedSize,
&FbpDisplayInfo.ModeInfo.PixelInformation.ReservedShift); &FbpDisplayInfo.ModeInfo.PixelInformation.ReservedShift);
break; break;
default: default:
/* Unknown pixel format */ /* Unknown pixel format */
FbpDisplayInfo.ModeInfo.BitsPerPixel = 0; FbpDisplayInfo.ModeInfo.BitsPerPixel = 0;
FbpDisplayInfo.ModeInfo.PixelInformation.BlueMask = 0x0;
FbpDisplayInfo.ModeInfo.PixelInformation.BlueShift = 0; FbpDisplayInfo.ModeInfo.PixelInformation.BlueShift = 0;
FbpDisplayInfo.ModeInfo.PixelInformation.GreenMask = 0x0; FbpDisplayInfo.ModeInfo.PixelInformation.BlueSize = 0;
FbpDisplayInfo.ModeInfo.PixelInformation.GreenShift = 0; FbpDisplayInfo.ModeInfo.PixelInformation.GreenShift = 0;
FbpDisplayInfo.ModeInfo.PixelInformation.RedMask = 0x0; FbpDisplayInfo.ModeInfo.PixelInformation.GreenSize = 0;
FbpDisplayInfo.ModeInfo.PixelInformation.RedShift = 0; FbpDisplayInfo.ModeInfo.PixelInformation.RedShift = 0;
FbpDisplayInfo.ModeInfo.PixelInformation.ReservedMask = 0x0; FbpDisplayInfo.ModeInfo.PixelInformation.RedSize = 0;
FbpDisplayInfo.ModeInfo.PixelInformation.ReservedShift = 0; FbpDisplayInfo.ModeInfo.PixelInformation.ReservedShift = 0;
FbpDisplayInfo.ModeInfo.PixelInformation.ReservedSize = 0;
break; break;
} }

View File

@ -45,7 +45,7 @@ FbpFindFramebufferAddress(OUT PEFI_PHYSICAL_ADDRESS Address);
XTCDECL XTCDECL
VOID VOID
FbpGetColorMask(IN UINT EfiMask, FbpGetColorMask(IN UINT EfiMask,
OUT PUSHORT ColorMask, OUT PUSHORT ColorSize,
OUT PUSHORT ColorShift); OUT PUSHORT ColorShift);
XTCDECL XTCDECL