Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ae3b1953b | ||
|
|
7695d711e6 | ||
|
|
aa9d53d696 | ||
|
|
c4c6e183fd | ||
|
|
0a592b5941 | ||
|
|
463328ec10 | ||
|
|
42fc24044d | ||
|
|
3802cb3b87 | ||
|
|
7e6f668f70 |
96
cmd/video.c
96
cmd/video.c
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <command.h>
|
#include <command.h>
|
||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
|
#include <linker_lists.h>
|
||||||
#include <video.h>
|
#include <video.h>
|
||||||
#include <video_console.h>
|
#include <video_console.h>
|
||||||
|
|
||||||
@@ -22,8 +23,8 @@ static int do_video_setcursor(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||||||
|
|
||||||
if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev))
|
if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev))
|
||||||
return CMD_RET_FAILURE;
|
return CMD_RET_FAILURE;
|
||||||
col = dectoul(argv[1], NULL);
|
col = hextoul(argv[1], NULL);
|
||||||
row = dectoul(argv[2], NULL);
|
row = hextoul(argv[2], NULL);
|
||||||
vidconsole_position_cursor(dev, col, row);
|
vidconsole_position_cursor(dev, col, row);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -47,10 +48,86 @@ static int do_video_puts(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||||||
return ret ? CMD_RET_FAILURE : 0;
|
return ret ? CMD_RET_FAILURE : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int do_video_write(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
|
char *const argv[])
|
||||||
|
{
|
||||||
|
struct vidconsole_priv *priv;
|
||||||
|
bool use_pixels = false;
|
||||||
|
struct udevice *dev;
|
||||||
|
int ret, i;
|
||||||
|
|
||||||
|
if (argc < 3)
|
||||||
|
return CMD_RET_USAGE;
|
||||||
|
|
||||||
|
if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev))
|
||||||
|
return CMD_RET_FAILURE;
|
||||||
|
priv = dev_get_uclass_priv(dev);
|
||||||
|
|
||||||
|
/* Check for -p flag */
|
||||||
|
if (!strcmp(argv[1], "-p")) {
|
||||||
|
use_pixels = true;
|
||||||
|
argc--;
|
||||||
|
argv++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc < 3 || !(argc % 2))
|
||||||
|
return CMD_RET_USAGE;
|
||||||
|
|
||||||
|
for (i = 1; i < argc; i += 2) {
|
||||||
|
uint col, row;
|
||||||
|
char *pos = argv[i];
|
||||||
|
char *colon = strchr(pos, ':');
|
||||||
|
|
||||||
|
if (!colon)
|
||||||
|
return CMD_RET_USAGE;
|
||||||
|
|
||||||
|
col = hextoul(pos, NULL);
|
||||||
|
row = hextoul(colon + 1, NULL);
|
||||||
|
|
||||||
|
if (use_pixels)
|
||||||
|
vidconsole_set_cursor_pos(dev, col, row);
|
||||||
|
else
|
||||||
|
vidconsole_position_cursor(dev, col, row);
|
||||||
|
|
||||||
|
ret = vidconsole_put_string(dev, argv[i + 1]);
|
||||||
|
if (ret)
|
||||||
|
return CMD_RET_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = video_sync(dev->parent, false);
|
||||||
|
if (ret)
|
||||||
|
return CMD_RET_FAILURE;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int do_video_images(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
|
char *const argv[])
|
||||||
|
{
|
||||||
|
struct video_image *image;
|
||||||
|
int count, i;
|
||||||
|
|
||||||
|
image = ll_entry_start(struct video_image, video_image);
|
||||||
|
count = ll_entry_count(struct video_image, video_image);
|
||||||
|
|
||||||
|
printf("%-20s %10s\n", "Name", "Size");
|
||||||
|
printf("%-20s %10s\n", "--------------------", "----------");
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++, image++) {
|
||||||
|
ulong size = (ulong)image->end - (ulong)image->begin;
|
||||||
|
|
||||||
|
printf("%-20s %10lu\n", image->name, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\nTotal images: %d\n", count);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
U_BOOT_CMD(
|
U_BOOT_CMD(
|
||||||
setcurs, 3, 1, do_video_setcursor,
|
setcurs, 3, 1, do_video_setcursor,
|
||||||
"set cursor position within screen",
|
"set cursor position within screen",
|
||||||
" <col> <row> in character"
|
" <col> <row> in hex characters"
|
||||||
);
|
);
|
||||||
|
|
||||||
U_BOOT_CMD(
|
U_BOOT_CMD(
|
||||||
@@ -58,3 +135,16 @@ U_BOOT_CMD(
|
|||||||
"print string on video framebuffer",
|
"print string on video framebuffer",
|
||||||
" <string>"
|
" <string>"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
U_BOOT_LONGHELP(video,
|
||||||
|
"setcursor <col> <row> - Set cursor position\n"
|
||||||
|
"video puts <string> - Write string at current position\n"
|
||||||
|
"video write [-p] [<col>:<row> <string>]... - Write strings at specified positions\n"
|
||||||
|
" -p: Use pixel coordinates instead of character positions\n"
|
||||||
|
"video images - List images compiled into U-Boot");
|
||||||
|
|
||||||
|
U_BOOT_CMD_WITH_SUBCMDS(video, "Video commands", video_help_text,
|
||||||
|
U_BOOT_SUBCMD_MKENT(setcursor, 3, 1, do_video_setcursor),
|
||||||
|
U_BOOT_SUBCMD_MKENT(puts, 2, 1, do_video_puts),
|
||||||
|
U_BOOT_SUBCMD_MKENT(write, CONFIG_SYS_MAXARGS, 1, do_video_write),
|
||||||
|
U_BOOT_SUBCMD_MKENT(images, 1, 1, do_video_images));
|
||||||
|
|||||||
58
doc/usage/cmd/lcdputs.rst
Normal file
58
doc/usage/cmd/lcdputs.rst
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
.. SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
.. index::
|
||||||
|
single: lcdputs (command)
|
||||||
|
|
||||||
|
lcdputs command
|
||||||
|
===============
|
||||||
|
|
||||||
|
Synopsis
|
||||||
|
--------
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
lcdputs <string>
|
||||||
|
|
||||||
|
Description
|
||||||
|
-----------
|
||||||
|
|
||||||
|
The lcdputs command prints a string to the video framebuffer at the current
|
||||||
|
cursor position.
|
||||||
|
|
||||||
|
string
|
||||||
|
Text string to display on the video console
|
||||||
|
|
||||||
|
Examples
|
||||||
|
--------
|
||||||
|
|
||||||
|
Print a simple string::
|
||||||
|
|
||||||
|
=> lcdputs "Hello World"
|
||||||
|
|
||||||
|
Combine with setcurs to position text::
|
||||||
|
|
||||||
|
=> setcurs 10 5
|
||||||
|
=> lcdputs "Positioned text"
|
||||||
|
|
||||||
|
Print multiple lines::
|
||||||
|
|
||||||
|
=> setcurs 0 0
|
||||||
|
=> lcdputs "Line 1"
|
||||||
|
=> setcurs 0 1
|
||||||
|
=> lcdputs "Line 2"
|
||||||
|
|
||||||
|
Configuration
|
||||||
|
-------------
|
||||||
|
|
||||||
|
The lcdputs command is available if CONFIG_CMD_VIDEO=y.
|
||||||
|
|
||||||
|
See also
|
||||||
|
--------
|
||||||
|
|
||||||
|
* :doc:`video` - video command with subcommands
|
||||||
|
* :doc:`setcurs` - set cursor position
|
||||||
|
|
||||||
|
Return value
|
||||||
|
------------
|
||||||
|
|
||||||
|
The return value $? is 0 (true) on success, 1 (false) on failure.
|
||||||
57
doc/usage/cmd/setcurs.rst
Normal file
57
doc/usage/cmd/setcurs.rst
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
.. SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
.. index::
|
||||||
|
single: setcurs (command)
|
||||||
|
|
||||||
|
setcurs command
|
||||||
|
===============
|
||||||
|
|
||||||
|
Synopsis
|
||||||
|
--------
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
setcurs <col> <row>
|
||||||
|
|
||||||
|
Description
|
||||||
|
-----------
|
||||||
|
|
||||||
|
The setcurs command sets the cursor position on the video console.
|
||||||
|
|
||||||
|
col
|
||||||
|
Column position in hex, with 0 being the left side. Note that this is the
|
||||||
|
text-column position, so the number of pixels per position depends on the
|
||||||
|
font size.
|
||||||
|
|
||||||
|
row
|
||||||
|
Row position in hex, with 0 being the top edge. Note that this is the
|
||||||
|
text-row position, so the number of pixels per position depends on the
|
||||||
|
font size.
|
||||||
|
|
||||||
|
|
||||||
|
Examples
|
||||||
|
--------
|
||||||
|
|
||||||
|
Set cursor to column 0x10, row 5::
|
||||||
|
|
||||||
|
=> setcurs 10 5
|
||||||
|
|
||||||
|
Move cursor to top left::
|
||||||
|
|
||||||
|
=> setcurs 0 0
|
||||||
|
|
||||||
|
Configuration
|
||||||
|
-------------
|
||||||
|
|
||||||
|
The setcurs command is available if CONFIG_CMD_VIDEO=y.
|
||||||
|
|
||||||
|
See also
|
||||||
|
--------
|
||||||
|
|
||||||
|
* :doc:`video` - video command with subcommands
|
||||||
|
* :doc:`lcdputs` - print string on video framebuffer
|
||||||
|
|
||||||
|
Return value
|
||||||
|
------------
|
||||||
|
|
||||||
|
The return value $? is 0 (true) on success, 1 (false) on failure.
|
||||||
120
doc/usage/cmd/video.rst
Normal file
120
doc/usage/cmd/video.rst
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
.. SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
.. index::
|
||||||
|
single: video (command)
|
||||||
|
|
||||||
|
video command
|
||||||
|
=============
|
||||||
|
|
||||||
|
Synopsis
|
||||||
|
--------
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
video setcursor <col> <row>
|
||||||
|
video puts <string>
|
||||||
|
video write [-p] [<col>:<row> <string>]...
|
||||||
|
video images
|
||||||
|
|
||||||
|
Description
|
||||||
|
-----------
|
||||||
|
|
||||||
|
The video command provides access to the video-console subsystem. Common
|
||||||
|
arguments are as follows:
|
||||||
|
|
||||||
|
col
|
||||||
|
Column position in hex, with 0 being the left side. Note that this is the
|
||||||
|
text-column position, so the number of pixels per position depends on the
|
||||||
|
font size.
|
||||||
|
|
||||||
|
row
|
||||||
|
Row position in hex, with 0 being the top edge. Note that this is the
|
||||||
|
text-row position, so the number of pixels per position depends on the
|
||||||
|
font size.
|
||||||
|
|
||||||
|
video setcursor
|
||||||
|
~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
video setcursor <col> <row>
|
||||||
|
|
||||||
|
Set the cursor position on the video console.
|
||||||
|
|
||||||
|
video puts
|
||||||
|
~~~~~~~~~~
|
||||||
|
|
||||||
|
video puts <string>
|
||||||
|
|
||||||
|
Write a string to the video console at the current cursor position.
|
||||||
|
|
||||||
|
string
|
||||||
|
Text string to display
|
||||||
|
|
||||||
|
video write
|
||||||
|
~~~~~~~~~~~
|
||||||
|
|
||||||
|
video write [-p] [<col>:<row> <string>]...
|
||||||
|
|
||||||
|
Write one or more strings to the video console at specified positions. Each
|
||||||
|
position/string pair sets the cursor to the specified location and writes the
|
||||||
|
string. Multiple position/string pairs can be provided to write to multiple
|
||||||
|
locations in a single command.
|
||||||
|
|
||||||
|
-p
|
||||||
|
Use pixel coordinates instead of character positions. When specified, the
|
||||||
|
col and row values are interpreted as pixel offsets and converted to
|
||||||
|
character positions based on the current font size.
|
||||||
|
|
||||||
|
string
|
||||||
|
Text string to display at the specified position
|
||||||
|
|
||||||
|
video images
|
||||||
|
~~~~~~~~~~~~
|
||||||
|
|
||||||
|
video images
|
||||||
|
|
||||||
|
List all images that are compiled into U-Boot. This shows the name and size
|
||||||
|
of each image that was built from .bmp files in the drivers/video/images
|
||||||
|
directory.
|
||||||
|
|
||||||
|
Examples
|
||||||
|
--------
|
||||||
|
|
||||||
|
Set cursor and print text::
|
||||||
|
|
||||||
|
=> video setcursor 10 5
|
||||||
|
=> video puts "Hello World"
|
||||||
|
|
||||||
|
Print at different positions::
|
||||||
|
|
||||||
|
=> video setcursor 0 0
|
||||||
|
=> video puts "Top left"
|
||||||
|
=> video setcursor 0 10
|
||||||
|
=> video puts "Line 16"
|
||||||
|
|
||||||
|
Write text at multiple positions::
|
||||||
|
|
||||||
|
=> video write 0:0 "Top left" 0:a "Line 10"
|
||||||
|
=> video write 0:a "First column in line10" 2a:0 "Text column 42"
|
||||||
|
|
||||||
|
Write text using pixel coordinates::
|
||||||
|
|
||||||
|
=> video write -p 0:0 "Top left corner" a0:80 "Pixel position"
|
||||||
|
|
||||||
|
List compiled-in images::
|
||||||
|
|
||||||
|
=> video images
|
||||||
|
Name Size
|
||||||
|
-------------------- ----------
|
||||||
|
u_boot 6932
|
||||||
|
|
||||||
|
Total images: 1
|
||||||
|
|
||||||
|
Configuration
|
||||||
|
-------------
|
||||||
|
|
||||||
|
The video command is available if CONFIG_CMD_VIDEO=y.
|
||||||
|
|
||||||
|
Return value
|
||||||
|
------------
|
||||||
|
|
||||||
|
The return value $? is 0 (true) on success, 1 (false) on failure.
|
||||||
@@ -85,6 +85,7 @@ Shell commands
|
|||||||
cmd/if
|
cmd/if
|
||||||
cmd/itest
|
cmd/itest
|
||||||
cmd/imxtract
|
cmd/imxtract
|
||||||
|
cmd/lcdputs
|
||||||
cmd/load
|
cmd/load
|
||||||
cmd/loadb
|
cmd/loadb
|
||||||
cmd/loadm
|
cmd/loadm
|
||||||
@@ -117,6 +118,7 @@ Shell commands
|
|||||||
cmd/scmi
|
cmd/scmi
|
||||||
cmd/scp03
|
cmd/scp03
|
||||||
cmd/seama
|
cmd/seama
|
||||||
|
cmd/setcurs
|
||||||
cmd/setexpr
|
cmd/setexpr
|
||||||
cmd/sf
|
cmd/sf
|
||||||
cmd/shim
|
cmd/shim
|
||||||
@@ -135,6 +137,7 @@ Shell commands
|
|||||||
cmd/ums
|
cmd/ums
|
||||||
cmd/unbind
|
cmd/unbind
|
||||||
cmd/ut
|
cmd/ut
|
||||||
|
cmd/video
|
||||||
cmd/virtio
|
cmd/virtio
|
||||||
cmd/wdt
|
cmd/wdt
|
||||||
cmd/wget
|
cmd/wget
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ obj-$(CONFIG_$(PHASE_)PANEL) += panel-uclass.o
|
|||||||
obj-$(CONFIG_PANEL_HX8238D) += hx8238d.o
|
obj-$(CONFIG_PANEL_HX8238D) += hx8238d.o
|
||||||
obj-$(CONFIG_$(PHASE_)SIMPLE_PANEL) += simple_panel.o
|
obj-$(CONFIG_$(PHASE_)SIMPLE_PANEL) += simple_panel.o
|
||||||
|
|
||||||
obj-$(CONFIG_VIDEO_LOGO) += u_boot_logo.o
|
|
||||||
obj-$(CONFIG_$(PHASE_)BMP) += bmp.o
|
obj-$(CONFIG_$(PHASE_)BMP) += bmp.o
|
||||||
|
|
||||||
obj-y += vesa_helper.o
|
obj-y += vesa_helper.o
|
||||||
@@ -86,3 +85,5 @@ obj-$(CONFIG_VIDEO_ZYNQMP_DPSUB) += zynqmp/
|
|||||||
obj-y += bridge/
|
obj-y += bridge/
|
||||||
obj-y += sunxi/
|
obj-y += sunxi/
|
||||||
obj-y += tegra20/
|
obj-y += tegra20/
|
||||||
|
|
||||||
|
obj-y += images/
|
||||||
|
|||||||
9
drivers/video/images/Makefile
Normal file
9
drivers/video/images/Makefile
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-2.0+
|
||||||
|
#
|
||||||
|
# Copyright 2025 Simon Glass <sjg@chromium.org>
|
||||||
|
|
||||||
|
obj-$(CONFIG_VIDEO_LOGO) += u_boot.o
|
||||||
|
|
||||||
|
ifdef CONFIG_$(PHASE_)GENERATE_ACPI_TABLE
|
||||||
|
obj-y += bgrt.o
|
||||||
|
endif
|
||||||
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.8 KiB |
@@ -581,28 +581,24 @@ int video_get_ysize(struct udevice *dev)
|
|||||||
return priv->ysize;
|
return priv->ysize;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SPLASH_DECL(_name) \
|
|
||||||
extern u8 __splash_ ## _name ## _begin[]; \
|
|
||||||
extern u8 __splash_ ## _name ## _end[]
|
|
||||||
|
|
||||||
#define SPLASH_START(_name) __splash_ ## _name ## _begin
|
|
||||||
#define SPLASH_END(_name) __splash_ ## _name ## _end
|
|
||||||
|
|
||||||
SPLASH_DECL(u_boot_logo);
|
|
||||||
|
|
||||||
void *video_get_u_boot_logo(int *sizep)
|
void *video_get_u_boot_logo(int *sizep)
|
||||||
{
|
{
|
||||||
if (sizep)
|
void *ptr;
|
||||||
*sizep = SPLASH_END(u_boot_logo) - SPLASH_START(u_boot_logo);
|
int size;
|
||||||
|
|
||||||
return SPLASH_START(u_boot_logo);
|
ptr = video_image_get(u_boot, &size);
|
||||||
|
if (sizep)
|
||||||
|
*sizep = size;
|
||||||
|
|
||||||
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int show_splash(struct udevice *dev)
|
static int show_splash(struct udevice *dev)
|
||||||
{
|
{
|
||||||
u8 *data = SPLASH_START(u_boot_logo);
|
u8 *data;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
data = video_image_getptr(u_boot);
|
||||||
ret = video_bmp_display(dev, map_to_sysmem(data), -4, 4, true);
|
ret = video_bmp_display(dev, map_to_sysmem(data), -4, 4, true);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -7,7 +7,9 @@
|
|||||||
#ifndef _VIDEO_H_
|
#ifndef _VIDEO_H_
|
||||||
#define _VIDEO_H_
|
#define _VIDEO_H_
|
||||||
|
|
||||||
|
#include <linker_lists.h>
|
||||||
#include <stdio_dev.h>
|
#include <stdio_dev.h>
|
||||||
|
#include <video_image.h>
|
||||||
#ifdef CONFIG_SANDBOX
|
#ifdef CONFIG_SANDBOX
|
||||||
#include <asm/state.h>
|
#include <asm/state.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -201,6 +203,50 @@ enum colour_idx {
|
|||||||
VID_COLOUR_COUNT
|
VID_COLOUR_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct video_image - Information about an embedded image
|
||||||
|
*
|
||||||
|
* This structure holds the pointers to the start and end of an image
|
||||||
|
* that is embedded in the U-Boot binary, along with its name.
|
||||||
|
* On 64-bit: 2*8 + VIDEO_IMAGE_NAMELEN = 32 bytes
|
||||||
|
* On 32-bit: 2*4 + VIDEO_IMAGE_NAMELEN = 24 bytes
|
||||||
|
*
|
||||||
|
* @begin: Pointer to the start of the image data
|
||||||
|
* @end: Pointer to the end of the image data
|
||||||
|
* @name: Name of the image (e.g., "u_boot", "canonical"), null-terminated
|
||||||
|
*/
|
||||||
|
struct video_image {
|
||||||
|
const void *begin;
|
||||||
|
const void *end;
|
||||||
|
char name[VIDEO_IMAGE_NAMELEN];
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* video_image_get() - Get the start address and size of an image
|
||||||
|
*
|
||||||
|
* @_name: Name of the image taken from filename (e.g. u_boot)
|
||||||
|
* @_sizep: Returns the size of the image in bytes
|
||||||
|
* Return: Pointer to the start of the image data
|
||||||
|
*/
|
||||||
|
#define video_image_get(_name, _sizep) ({ \
|
||||||
|
struct video_image *__img = ll_entry_get(struct video_image, _name, \
|
||||||
|
video_image); \
|
||||||
|
*(_sizep) = (ulong)__img->end - (ulong)__img->begin; \
|
||||||
|
(void *)__img->begin; \
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* video_image_getptr() - Get the start address of an image
|
||||||
|
*
|
||||||
|
* @_name: Name of the image taken from filename (e.g. u_boot)
|
||||||
|
* Return: Pointer to the start of the image data
|
||||||
|
*/
|
||||||
|
#define video_image_getptr(_name) ({ \
|
||||||
|
struct video_image *__img = ll_entry_get(struct video_image, _name, \
|
||||||
|
video_image); \
|
||||||
|
(void *)__img->begin; \
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* video_index_to_colour() - convert a color code to a pixel's internal
|
* video_index_to_colour() - convert a color code to a pixel's internal
|
||||||
* representation
|
* representation
|
||||||
|
|||||||
13
include/video_image.h
Normal file
13
include/video_image.h
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||||
|
/*
|
||||||
|
* Copyright 2025 Canonical Ltd
|
||||||
|
* Written by Simon Glass <simon.glass@canonical.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __VIDEO_IMAGE_H
|
||||||
|
#define __VIDEO_IMAGE_H
|
||||||
|
|
||||||
|
/* Maximum length of an embedded image name */
|
||||||
|
#define VIDEO_IMAGE_NAMELEN 16
|
||||||
|
|
||||||
|
#endif /* __VIDEO_IMAGE_H */
|
||||||
@@ -12,8 +12,6 @@ obj-$(CONFIG_$(PHASE_)ACPIGEN) += acpi_table.o
|
|||||||
obj-y += acpi_extra.o
|
obj-y += acpi_extra.o
|
||||||
obj-y += acpi_writer.o
|
obj-y += acpi_writer.o
|
||||||
|
|
||||||
obj-y += bgrt_image.o
|
|
||||||
|
|
||||||
# With QEMU the ACPI tables come from there, not from U-Boot
|
# With QEMU the ACPI tables come from there, not from U-Boot
|
||||||
ifndef CONFIG_QFW_ACPI
|
ifndef CONFIG_QFW_ACPI
|
||||||
obj-y += base.o
|
obj-y += base.o
|
||||||
|
|||||||
@@ -13,23 +13,6 @@
|
|||||||
#include <video.h>
|
#include <video.h>
|
||||||
#include <acpi/acpi_table.h>
|
#include <acpi/acpi_table.h>
|
||||||
|
|
||||||
#define BGRT_DECL(_name) \
|
|
||||||
extern u8 __bgrt_ ## _name ## _begin[]; \
|
|
||||||
extern u8 __bgrt_ ## _name ## _end[]
|
|
||||||
|
|
||||||
#define BGRT_START(_name) __bgrt_ ## _name ## _begin
|
|
||||||
#define BGRT_END(_name) __bgrt_ ## _name ## _end
|
|
||||||
|
|
||||||
BGRT_DECL(image);
|
|
||||||
|
|
||||||
static void *bgrt_get_image(int *sizep)
|
|
||||||
{
|
|
||||||
if (sizep)
|
|
||||||
*sizep = BGRT_END(image) - BGRT_START(image);
|
|
||||||
|
|
||||||
return BGRT_START(image);
|
|
||||||
}
|
|
||||||
|
|
||||||
int acpi_write_bgrt(struct acpi_ctx *ctx)
|
int acpi_write_bgrt(struct acpi_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct udevice *dev;
|
struct udevice *dev;
|
||||||
@@ -42,7 +25,10 @@ int acpi_write_bgrt(struct acpi_ctx *ctx)
|
|||||||
/* If video is available, use the screen size to centre the logo */
|
/* If video is available, use the screen size to centre the logo */
|
||||||
have_video = !uclass_first_device_err(UCLASS_VIDEO, &dev);
|
have_video = !uclass_first_device_err(UCLASS_VIDEO, &dev);
|
||||||
|
|
||||||
logo = bgrt_get_image(&size);
|
if (!IS_ENABLED(CONFIG_VIDEO))
|
||||||
|
return -ENOENT;
|
||||||
|
|
||||||
|
logo = video_image_get(bgrt, &size);
|
||||||
|
|
||||||
/* If there's no logo data, there's nothing to report */
|
/* If there's no logo data, there's nothing to report */
|
||||||
if (!logo)
|
if (!logo)
|
||||||
|
|||||||
@@ -523,23 +523,43 @@ cmd_S_splash= \
|
|||||||
$(obj)/%_logo.S: $(src)/%_logo.bmp
|
$(obj)/%_logo.S: $(src)/%_logo.bmp
|
||||||
$(call cmd,S_splash)
|
$(call cmd,S_splash)
|
||||||
|
|
||||||
# Generate an assembly file to wrap the EFI 'Boot Graphics Resource Table' image
|
# Handle image files in drivers/video/images without _logo suffix
|
||||||
quiet_cmd_S_bgrt= BGRT $@
|
# Generate an assembly file to wrap the image data and create a linker-list entry
|
||||||
# Modified for U-Boot
|
quiet_cmd_S_image= IMAGE $@
|
||||||
cmd_S_bgrt= \
|
cmd_S_image= \
|
||||||
( \
|
( \
|
||||||
echo '.section .rodata.bgrt.init,"a"'; \
|
echo '\#include <video_image.h>'; \
|
||||||
|
echo '.section .rodata.image.init,"a"'; \
|
||||||
echo '.balign 16'; \
|
echo '.balign 16'; \
|
||||||
echo '.global __$(*F)_image_begin'; \
|
echo '.global __image_$(*F)_begin'; \
|
||||||
echo '__$(*F)_image_begin:'; \
|
echo '__image_$(*F)_begin:'; \
|
||||||
echo '.incbin "$<" '; \
|
echo '.incbin "$<" '; \
|
||||||
echo '__$(*F)_image_end:'; \
|
echo '__image_$(*F)_end:'; \
|
||||||
echo '.global __$(*F)_image_end'; \
|
echo '.global __image_$(*F)_end'; \
|
||||||
echo '.balign 16'; \
|
echo '.balign 16'; \
|
||||||
|
echo ''; \
|
||||||
|
echo '/* Linker list entry for this image */'; \
|
||||||
|
echo '.section __u_boot_list_2_video_image_2_$(*F), "aw"'; \
|
||||||
|
echo '.balign 8'; \
|
||||||
|
echo '.global _u_boot_list_2_video_image_2_$(*F)'; \
|
||||||
|
echo '_u_boot_list_2_video_image_2_$(*F):'; \
|
||||||
|
echo '\#ifdef __LP64__'; \
|
||||||
|
echo '.quad __image_$(*F)_begin'; \
|
||||||
|
echo '.quad __image_$(*F)_end'; \
|
||||||
|
echo '.asciz "'$(*F)'"'; \
|
||||||
|
echo '.org _u_boot_list_2_video_image_2_$(*F) + 16 + VIDEO_IMAGE_NAMELEN'; \
|
||||||
|
echo '\#else'; \
|
||||||
|
echo '.long __image_$(*F)_begin'; \
|
||||||
|
echo '.long __image_$(*F)_end'; \
|
||||||
|
echo '.asciz "'$(*F)'"'; \
|
||||||
|
echo '.org _u_boot_list_2_video_image_2_$(*F) + 8 + VIDEO_IMAGE_NAMELEN'; \
|
||||||
|
echo '\#endif'; \
|
||||||
) > $@
|
) > $@
|
||||||
|
|
||||||
$(obj)/%_image.S: $(src)/%_image.bmp
|
ifneq ($(filter drivers/video/images,$(obj)),)
|
||||||
$(call cmd,S_bgrt)
|
$(obj)/%.S: $(src)/%.bmp
|
||||||
|
$(call cmd,S_image)
|
||||||
|
endif
|
||||||
|
|
||||||
# EFI applications
|
# EFI applications
|
||||||
# A Makefile target *.efi is built as EFI application.
|
# A Makefile target *.efi is built as EFI application.
|
||||||
|
|||||||
@@ -1080,3 +1080,53 @@ static int dm_test_video_backspace_truetype(struct unit_test_state *uts)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
DM_TEST(dm_test_video_backspace_truetype, UTF_SCAN_PDATA | UTF_SCAN_FDT);
|
DM_TEST(dm_test_video_backspace_truetype, UTF_SCAN_PDATA | UTF_SCAN_FDT);
|
||||||
|
|
||||||
|
/* video commands */
|
||||||
|
static int dm_test_video_cmd(struct unit_test_state *uts)
|
||||||
|
{
|
||||||
|
struct udevice *dev, *con;
|
||||||
|
|
||||||
|
ut_assertok(select_vidconsole(uts, "vidconsole0"));
|
||||||
|
ut_assertok(video_get_nologo(uts, &dev));
|
||||||
|
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
|
||||||
|
ut_assertok(vidconsole_select_font(con, "8x16", 0));
|
||||||
|
|
||||||
|
ut_assertok(run_command("setcurs 10 5", 0));
|
||||||
|
|
||||||
|
ut_assertok(run_command("lcdputs \"Test string\"", 0));
|
||||||
|
ut_asserteq(187, video_compress_fb(uts, dev, false));
|
||||||
|
ut_assertok(video_check_copy_fb(uts, dev));
|
||||||
|
|
||||||
|
ut_assertok(run_command("video setcursor 0 0", 0));
|
||||||
|
ut_assertok(run_command("video puts \"Top left\"", 0));
|
||||||
|
ut_asserteq(272, video_compress_fb(uts, dev, false));
|
||||||
|
ut_assertok(video_check_copy_fb(uts, dev));
|
||||||
|
|
||||||
|
ut_assertok(run_command(
|
||||||
|
"video write 14:6 \"Multi\" 19:7 \"Write\"", 0));
|
||||||
|
ut_asserteq(381, video_compress_fb(uts, dev, false));
|
||||||
|
ut_assertok(video_check_copy_fb(uts, dev));
|
||||||
|
|
||||||
|
ut_assertok(run_command("video write -p a3:34 \"Pixels\"", 0));
|
||||||
|
ut_asserteq(440, video_compress_fb(uts, dev, false));
|
||||||
|
ut_assertok(video_check_copy_fb(uts, dev));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
DM_TEST(dm_test_video_cmd, UTF_SCAN_PDATA | UTF_SCAN_FDT);
|
||||||
|
|
||||||
|
/* video images command */
|
||||||
|
static int dm_test_video_images(struct unit_test_state *uts)
|
||||||
|
{
|
||||||
|
ut_assertok(run_command("video images", 0));
|
||||||
|
ut_assert_nextline("Name Size");
|
||||||
|
ut_assert_nextline("-------------------- ----------");
|
||||||
|
ut_assert_nextline("bgrt 43926");
|
||||||
|
ut_assert_nextline("u_boot 6932");
|
||||||
|
ut_assert_skip_to_line("");
|
||||||
|
ut_assert_nextline("Total images: 2");
|
||||||
|
ut_assert_console_end();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
DM_TEST(dm_test_video_images, UTF_SCAN_PDATA | UTF_SCAN_FDT | UTF_CONSOLE);
|
||||||
|
|||||||
Reference in New Issue
Block a user