[U-Boot] [RFC PATCH 1/2] video: add a function to acquire the GraphicDevice of cfb_console

Sometimes the GraphicDevice of cfb_console is useful at other place.
Add a function to acquire it, so that the graphics hardware (especially the framebuffer) can be reused.
Signed-off-by: Icenowy Zheng icenowy@aosc.xyz --- drivers/video/cfb_console.c | 5 +++++ include/video_fb.h | 2 ++ 2 files changed, 7 insertions(+)
diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c index c0b1b8dc17..c80ed1646f 100644 --- a/drivers/video/cfb_console.c +++ b/drivers/video/cfb_console.c @@ -2199,3 +2199,8 @@ int video_get_screen_columns(void) { return CONSOLE_COLS; } + +GraphicDevice *video_get_graphic_device(void) +{ + return pGD; +}; diff --git a/include/video_fb.h b/include/video_fb.h index b008853f30..29f2b24648 100644 --- a/include/video_fb.h +++ b/include/video_fb.h @@ -89,4 +89,6 @@ void video_set_lut ( unsigned char b /* blue */ );
+GraphicDevice *video_get_graphic_device(void); + #endif /*_VIDEO_FB_H_ */

As cfb_console now can expose its GraphicDevice, use it in the implementation of EFI GOP protocol, so that the graphics framebuffer can be passed to EFI applications.
Signed-off-by: Icenowy Zheng icenowy@aosc.xyz ---
Tested on an Allwinner H3 board with out-of-tree display support.
cmd/bootefi.c | 2 +- lib/efi_loader/Makefile | 1 + lib/efi_loader/efi_gop.c | 29 ++++++++++++++++++++++++----- 3 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 97a0fc9c7c..c0636ba5a3 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -210,7 +210,7 @@ static unsigned long do_bootefi_exec(void *efi, void *fdt) #ifdef CONFIG_PARTITIONS efi_disk_register(); #endif -#ifdef CONFIG_LCD +#if defined CONFIG_LCD || defined CONFIG_CFB_CONSOLE efi_gop_register(); #endif #ifdef CONFIG_NET diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index fa8b91a526..e88c99528c 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -17,6 +17,7 @@ obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o obj-y += efi_image_loader.o efi_boottime.o efi_runtime.o efi_console.o obj-y += efi_memory.o obj-$(CONFIG_LCD) += efi_gop.o +obj-$(CONFIG_CFB_CONSOLE) += efi_gop.o obj-$(CONFIG_PARTITIONS) += efi_disk.o obj-$(CONFIG_NET) += efi_net.o obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += efi_smbios.o diff --git a/lib/efi_loader/efi_gop.c b/lib/efi_loader/efi_gop.c index 286ad83097..86f9aa2d70 100644 --- a/lib/efi_loader/efi_gop.c +++ b/lib/efi_loader/efi_gop.c @@ -13,6 +13,7 @@ #include <lcd.h> #include <malloc.h> #include <video.h> +#include <video_fb.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -80,8 +81,10 @@ static efi_status_t EFIAPI gop_blt(struct efi_gop *this, void *buffer, switch (gopobj->bpix) { #ifdef CONFIG_DM_VIDEO case VIDEO_BPP32: -#else +#elif defined CONFIG_LCD case LCD_COLOR32: +#elif defined CONFIG_CFB_CONSOLE + case GDF_32BIT_X888RGB: #endif for (i = 0; i < height; i++) { u32 *dest = fb + ((i + dy) * line_len32) + @@ -117,7 +120,7 @@ static efi_status_t EFIAPI gop_blt(struct efi_gop *this, void *buffer,
#ifdef CONFIG_DM_VIDEO video_sync_all(); -#else +#elif defined CONFIG_LCD lcd_sync(); #endif
@@ -144,7 +147,7 @@ int efi_gop_register(void) row = video_get_ysize(vdev); fb_base = (uintptr_t)priv->fb; fb_size = priv->fb_size; -#else +#elif defined CONFIG_LCD int line_len;
bpix = panel_info.vl_bpix; @@ -152,15 +155,29 @@ int efi_gop_register(void) row = panel_info.vl_row; fb_base = gd->fb_base; fb_size = lcd_get_size(&line_len); +#elif defined CONFIG_CFB_CONSOLE + GraphicDevice *pGD; + + pGD = video_get_graphic_device(); + bpix = pGD->gdfIndex; + col = pGD->winSizeX; + row = pGD->winSizeY; + fb_base = pGD->frameAdrs; + if (pGD->memSize) + fb_size = pGD->memSize; + else + fb_size = pGD->plnSizeX * row; #endif
switch (bpix) { #ifdef CONFIG_DM_VIDEO case VIDEO_BPP16: case VIDEO_BPP32: -#else +#elif defined CONFIG_LCD case LCD_COLOR32: case LCD_COLOR16: +#elif defined CONFIG_CFB_CONSOLE + case GDF_32BIT_X888RGB: #endif break; default: @@ -185,8 +202,10 @@ int efi_gop_register(void)
#ifdef CONFIG_DM_VIDEO if (bpix == VIDEO_BPP32) { -#else +#elif defined CONFIG_LCD if (bpix == LCD_COLOR32) { +#elif defined CONFIG_CFB_CONSOLE + if (bpix == GDF_32BIT_X888RGB) { #endif /* With 32bit color space we can directly expose the fb */ gopobj->mode.fb_base = fb_base;

On Tue, Feb 7, 2017 at 8:58 PM, Icenowy Zheng icenowy@aosc.xyz wrote:
As cfb_console now can expose its GraphicDevice, use it in the implementation of EFI GOP protocol, so that the graphics framebuffer can be passed to EFI applications.
Signed-off-by: Icenowy Zheng icenowy@aosc.xyz
Tested on an Allwinner H3 board with out-of-tree display support.
cmd/bootefi.c | 2 +- lib/efi_loader/Makefile | 1 + lib/efi_loader/efi_gop.c | 29 ++++++++++++++++++++++++----- 3 files changed, 26 insertions(+), 6 deletions(-)
Instead of adding support on legacy CFB console driver, can we use the DM video driver instead?
Regards, Bin

Hi,
On 7 February 2017 at 05:58, Icenowy Zheng icenowy@aosc.xyz wrote:
Sometimes the GraphicDevice of cfb_console is useful at other place.
Add a function to acquire it, so that the graphics hardware (especially the framebuffer) can be reused.
Signed-off-by: Icenowy Zheng icenowy@aosc.xyz
drivers/video/cfb_console.c | 5 +++++ include/video_fb.h | 2 ++ 2 files changed, 7 insertions(+)
Please can you use driver-model video instead.
Regards, Simon
participants (3)
-
Bin Meng
-
Icenowy Zheng
-
Simon Glass