* [U-Boot] [PATCH] efi_loader: Allow width smaller than buffer stride in efi_gop Blt()
@ 2018-03-14 3:31 Ivan Gorinov
2018-03-14 15:45 ` [U-Boot] " Heinrich Schuchardt
2018-03-14 17:21 ` Heinrich Schuchardt
0 siblings, 2 replies; 4+ messages in thread
From: Ivan Gorinov @ 2018-03-14 3:31 UTC (permalink / raw)
To: u-boot
Current implementation of Blt() in EFI_GRAPHICS_OUTPUT_PROTOCOL
assumes the memory buffer stride (number of bytes in a row)
always matches the rectangle Width, ignoring non-zero Delta.
Signed-off-by: Ivan Gorinov <ivan.gorinov@intel.com>
---
lib/efi_loader/efi_gop.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/lib/efi_loader/efi_gop.c b/lib/efi_loader/efi_gop.c
index 3caddd5..362065b 100644
--- a/lib/efi_loader/efi_gop.c
+++ b/lib/efi_loader/efi_gop.c
@@ -64,6 +64,7 @@ efi_status_t EFIAPI gop_blt(struct efi_gop *this, void *buffer,
{
struct efi_gop_obj *gopobj = container_of(this, struct efi_gop_obj, ops);
int i, j, line_len16, line_len32;
+ int buffer_stride;
void *fb;
EFI_ENTRY("%p, %p, %u, %zu, %zu, %zu, %zu, %zu, %zu, %zu", this,
@@ -72,6 +73,11 @@ efi_status_t EFIAPI gop_blt(struct efi_gop *this, void *buffer,
if (operation != EFI_BLT_BUFFER_TO_VIDEO)
return EFI_EXIT(EFI_INVALID_PARAMETER);
+ if (delta == 0)
+ buffer_stride = width * sizeof(u32);
+ else
+ buffer_stride = delta;
+
fb = gopobj->fb;
line_len16 = gopobj->info.width * sizeof(u16);
line_len32 = gopobj->info.width * sizeof(u32);
@@ -87,7 +93,7 @@ efi_status_t EFIAPI gop_blt(struct efi_gop *this, void *buffer,
for (i = 0; i < height; i++) {
u32 *dest = fb + ((i + dy) * line_len32) +
(dx * sizeof(u32));
- u32 *src = buffer + ((i + sy) * line_len32) +
+ u32 *src = buffer + ((i + sy) * buffer_stride) +
(sx * sizeof(u32));
/* Same color format, just memcpy */
@@ -102,7 +108,7 @@ efi_status_t EFIAPI gop_blt(struct efi_gop *this, void *buffer,
for (i = 0; i < height; i++) {
u16 *dest = fb + ((i + dy) * line_len16) +
(dx * sizeof(u16));
- u32 *src = buffer + ((i + sy) * line_len32) +
+ u32 *src = buffer + ((i + sy) * buffer_stride) +
(sx * sizeof(u32));
/* Convert from rgb888 to rgb565 */
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread* [U-Boot] efi_loader: Allow width smaller than buffer stride in efi_gop Blt()
2018-03-14 3:31 [U-Boot] [PATCH] efi_loader: Allow width smaller than buffer stride in efi_gop Blt() Ivan Gorinov
@ 2018-03-14 15:45 ` Heinrich Schuchardt
2018-03-14 17:21 ` Heinrich Schuchardt
1 sibling, 0 replies; 4+ messages in thread
From: Heinrich Schuchardt @ 2018-03-14 15:45 UTC (permalink / raw)
To: u-boot
On 03/14/2018 04:31 AM, Ivan Gorinov wrote:
> Current implementation of Blt() in EFI_GRAPHICS_OUTPUT_PROTOCOL
> assumes the memory buffer stride (number of bytes in a row)
> always matches the rectangle Width, ignoring non-zero Delta.
>
> Signed-off-by: Ivan Gorinov <ivan.gorinov@intel.com>
Hello Ivan,
thanks for reporting the problem. Unfortunately your patch is not based
on the custodian's repository. You can find the upcoming EFI related
patches in
https://github.com/agraf/u-boot.git, branch efi-next.
I tried to address your problem in
efi_loader: implement missing bit blit operations in gop
https://lists.denx.de/pipermail/u-boot/2018-February/319846.html
But I think I got it wrong as according to the UEFI specification
'delta' is measured in bytes and not in pixels.
I will create a patch for lib/efi_loader/efi_gop.c and add you on cc. It
would be great if you could review efi_gop.c once again.
lib/efi_selftest/efi_selftest_bitblt.c should be adjusted to test the
use of 'delta'.
Best regards
Heinrich
> ---
> lib/efi_loader/efi_gop.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/lib/efi_loader/efi_gop.c b/lib/efi_loader/efi_gop.c
> index 3caddd5..362065b 100644
> --- a/lib/efi_loader/efi_gop.c
> +++ b/lib/efi_loader/efi_gop.c
> @@ -64,6 +64,7 @@ efi_status_t EFIAPI gop_blt(struct efi_gop *this, void *buffer,
> {
> struct efi_gop_obj *gopobj = container_of(this, struct efi_gop_obj, ops);
> int i, j, line_len16, line_len32;
> + int buffer_stride;
> void *fb;
>
> EFI_ENTRY("%p, %p, %u, %zu, %zu, %zu, %zu,the %zu, %zu, %zu", this,
> @@ -72,6 +73,11 @@ efi_status_t EFIAPI gop_blt(struct efi_gop *this, void *buffer,
> if (operation != EFI_BLT_BUFFER_TO_VIDEO)
> return EFI_EXIT(EFI_INVALID_PARAMETER);
>
> + if (delta == 0)
> + buffer_stride = width * sizeof(u32);
> + else
> + buffer_stride = delta;
> +
> fb = gopobj->fb;
> line_len16 = gopobj->info.width * sizeof(u16);
> line_len32 = gopobj->info.width * sizeof(u32);
> @@ -87,7 +93,7 @@ efi_status_t EFIAPI gop_blt(struct efi_gop *this, void *buffer,
> for (i = 0; i < height; i++) {
> u32 *dest = fb + ((i + dy) * line_len32) +
> (dx * sizeof(u32));
> - u32 *src = buffer + ((i + sy) * line_len32) +
> + u32 *src = buffer + ((i + sy) * buffer_stride) +
> (sx * sizeof(u32));
>
> /* Same color format, just memcpy */
> @@ -102,7 +108,7 @@ efi_status_t EFIAPI gop_blt(struct efi_gop *this, void *buffer,
> for (i = 0; i < height; i++) {
> u16 *dest = fb + ((i + dy) * line_len16) +
> (dx * sizeof(u16));
> - u32 *src = buffer + ((i + sy) * line_len32) +
> + u32 *src = buffer + ((i + sy) * buffer_stride) +
> (sx * sizeof(u32));
>
> /* Convert from rgb888 to rgb565 */
>
^ permalink raw reply [flat|nested] 4+ messages in thread* [U-Boot] efi_loader: Allow width smaller than buffer stride in efi_gop Blt()
2018-03-14 3:31 [U-Boot] [PATCH] efi_loader: Allow width smaller than buffer stride in efi_gop Blt() Ivan Gorinov
2018-03-14 15:45 ` [U-Boot] " Heinrich Schuchardt
@ 2018-03-14 17:21 ` Heinrich Schuchardt
2018-03-14 18:29 ` Ivan Gorinov
1 sibling, 1 reply; 4+ messages in thread
From: Heinrich Schuchardt @ 2018-03-14 17:21 UTC (permalink / raw)
To: u-boot
On 03/14/2018 04:31 AM, Ivan Gorinov wrote:
> Current implementation of Blt() in EFI_GRAPHICS_OUTPUT_PROTOCOL
> assumes the memory buffer stride (number of bytes in a row)
> always matches the rectangle Width, ignoring non-zero Delta.
>
> Signed-off-by: Ivan Gorinov <ivan.gorinov@intel.com>
> ---
> lib/efi_loader/efi_gop.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/lib/efi_loader/efi_gop.c b/lib/efi_loader/efi_gop.c
> index 3caddd5..362065b 100644
> --- a/lib/efi_loader/efi_gop.c
> +++ b/lib/efi_loader/efi_gop.c
> @@ -64,6 +64,7 @@ efi_status_t EFIAPI gop_blt(struct efi_gop *this, void *buffer,
> {
> struct efi_gop_obj *gopobj = container_of(this, struct efi_gop_obj, ops);
> int i, j, line_len16, line_len32;
> + int buffer_stride;
> void *fb;
>
> EFI_ENTRY("%p, %p, %u, %zu, %zu, %zu, %zu, %zu, %zu, %zu", this,
> @@ -72,6 +73,11 @@ efi_status_t EFIAPI gop_blt(struct efi_gop *this, void *buffer,
> if (operation != EFI_BLT_BUFFER_TO_VIDEO)
> return EFI_EXIT(EFI_INVALID_PARAMETER);
>
> + if (delta == 0)
> + buffer_stride = width * sizeof(u32);
> + else
> + buffer_stride = delta;
> +
> fb = gopobj->fb;
> line_len16 = gopobj->info.width * sizeof(u16);
> line_len32 = gopobj->info.width * sizeof(u32);
> @@ -87,7 +93,7 @@ efi_status_t EFIAPI gop_blt(struct efi_gop *this, void *buffer,
> for (i = 0; i < height; i++) {
> u32 *dest = fb + ((i + dy) * line_len32) +
> (dx * sizeof(u32));
> - u32 *src = buffer + ((i + sy) * line_len32) +
> + u32 *src = buffer + ((i + sy) * buffer_stride) +
> (sx * sizeof(u32));
>
> /* Same color format, just memcpy */
> @@ -102,7 +108,7 @@ efi_status_t EFIAPI gop_blt(struct efi_gop *this, void *buffer,
> for (i = 0; i < height; i++) {
> u16 *dest = fb + ((i + dy) * line_len16) +
> (dx * sizeof(u16));
> - u32 *src = buffer + ((i + sy) * line_len32) +
> + u32 *src = buffer + ((i + sy) * buffer_stride) +
If delta cannot be divided by 4 a misaligned access error will occur on
arm64.
Best regards
Heinrich
> (sx * sizeof(u32));
>
> /* Convert from rgb888 to rgb565 */
>
^ permalink raw reply [flat|nested] 4+ messages in thread* [U-Boot] efi_loader: Allow width smaller than buffer stride in efi_gop Blt()
2018-03-14 17:21 ` Heinrich Schuchardt
@ 2018-03-14 18:29 ` Ivan Gorinov
0 siblings, 0 replies; 4+ messages in thread
From: Ivan Gorinov @ 2018-03-14 18:29 UTC (permalink / raw)
To: u-boot
On Wed, 2018-03-14 at 18:21 +0100, Heinrich Schuchardt wrote:
@@ -87,7 +93,7 @@ efi_status_t EFIAPI gop_blt(struct efi_gop *this, void
> > *buffer,
> > for (i = 0; i < height; i++) {
> > u32 *dest = fb + ((i + dy) * line_len32) +
> > (dx * sizeof(u32));
> > - u32 *src = buffer + ((i + sy) * line_len32) +
> > + u32 *src = buffer + ((i + sy) * buffer_stride) +
> > (sx * sizeof(u32));
> >
> > /* Same color format, just memcpy */
> > @@ -102,7 +108,7 @@ efi_status_t EFIAPI gop_blt(struct efi_gop *this, void
> > *buffer,
> > for (i = 0; i < height; i++) {
> > u16 *dest = fb + ((i + dy) * line_len16) +
> > (dx * sizeof(u16));
> > - u32 *src = buffer + ((i + sy) * line_len32) +
> > + u32 *src = buffer + ((i + sy) * buffer_stride) +
> If delta cannot be divided by 4 a misaligned access error will occur on
> arm64.
This is unlikely because EFI spec allows only 32-bit pixel data in BLT buffer,
regardless of actual video frame buffer pixel format.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-03-14 18:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-14 3:31 [U-Boot] [PATCH] efi_loader: Allow width smaller than buffer stride in efi_gop Blt() Ivan Gorinov
2018-03-14 15:45 ` [U-Boot] " Heinrich Schuchardt
2018-03-14 17:21 ` Heinrich Schuchardt
2018-03-14 18:29 ` Ivan Gorinov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox