mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-25 18:55:24 +00:00
Change GBB bmpblock to version 1.1, supporting direct HWID rendering.
With version 1.0, the BIOS displays its screens using composited images, but
we still have to create a new bmp image for every HWID. Version 1.1 lets us
render the ASCII HWID string directly, so the BIOS screens don't need
modification just because the HWID changes.
In the yaml file, we just replace the hwid image with a magic string, like
so:
bmpblock: 1.1
[...]
screens:
en_remove:
- [ 0, 0, remove_bg]
- [256, 534, en_model_text]
- [314, 534, $HWID]
- [192, 479, url]
- [195, 453, en_remove_text]
This change modifies the bmpblk_utility to accept and generate both 1.0 and
1.1 versions. It also updates the supporting scripts (most of which aren't
needed anymore) and adds a new DEFAULT.yaml file which can be used as the
basis for all locales.
BUG=chrome-os-partner:3264
TEST=none (manual)
Change-Id: I012349393848393928282
Reviewed-on: http://gerrit.chromium.org/gerrit/378
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
This commit is contained in:
@@ -52,7 +52,7 @@ __pragma(pack(push, 1)) /* Support packing for MSVC. */
|
||||
#define BMPBLOCK_SIGNATURE_SIZE (4)
|
||||
|
||||
#define BMPBLOCK_MAJOR_VERSION (0x0001)
|
||||
#define BMPBLOCK_MINOR_VERSION (0x0000)
|
||||
#define BMPBLOCK_MINOR_VERSION (0x0001)
|
||||
|
||||
#define MAX_IMAGE_IN_LAYOUT (8)
|
||||
|
||||
@@ -106,6 +106,7 @@ typedef struct ImageInfo {
|
||||
typedef enum ImageTag {
|
||||
TAG_NONE = 0,
|
||||
TAG_HWID,
|
||||
TAG_HWID_RTOL, /* "right-to-left", ie, right-justified HWID */
|
||||
} ImageTag;
|
||||
|
||||
/* Constants for ImageInfo.format */
|
||||
@@ -122,6 +123,13 @@ typedef enum Compression {
|
||||
MAX_COMPRESS,
|
||||
} Compression;
|
||||
|
||||
/* These magic image names can be used in the .yaml file to indicate that
|
||||
the ASCII HWID should be displayed. For RENDER_HWID, the image coordinates
|
||||
specify upper-left corner of the HWID string. For RENDER_HWID_RTOL, they
|
||||
indicate the upper-right corner (handy for right-to-left languages). */
|
||||
#define RENDER_HWID "$HWID"
|
||||
#define RENDER_HWID_RTOL "$HWID.rtol"
|
||||
|
||||
__pragma(pack(pop)) /* Support packing for MSVC. */
|
||||
|
||||
#endif /* VBOOT_REFERENCE_BMPBLK_HEADER_H_ */
|
||||
|
||||
@@ -2,7 +2,13 @@ This directory contains examples of the new-style BIOS bitmaps, and a simple
|
||||
(and ugly) tool to view the configuration file that describes how each
|
||||
screen is displayed.
|
||||
|
||||
Old-style bitmaps:
|
||||
Note:
|
||||
|
||||
Because the bitmap images and display code is part of the Read-Only BIOS,
|
||||
back-porting any new bitmaps to older devices is not possible.
|
||||
|
||||
|
||||
Old-style, unversioned bitmaps (used in Cr-48):
|
||||
|
||||
In the Cr-48 BIOS there are four BIOS screens that may be presented to the
|
||||
user. Each contains a graphic, a URL, and some informative text. The screens
|
||||
@@ -14,21 +20,26 @@ BIOS is compiled. The result is an opaque blob that cannot be viewed or
|
||||
edited with linux-based tools.
|
||||
|
||||
|
||||
New-style bitmaps (version 1.0):
|
||||
Version 1.0, new-style bitmaps (used in Alex):
|
||||
|
||||
Future BIOSes will continue to display the same basic screens, but using a
|
||||
The BIOSes will continue to display the same basic screens, but it uses a
|
||||
different format. Each screen has separate bitmaps for the basic graphic,
|
||||
the URL, and the informative text, and will be displayed by rendering each
|
||||
component in order. This will allow us to modify and replace any bitmap
|
||||
(most frequently the HWID), using standard command-line tools such as
|
||||
imagemagick. Compositing each screen in this way also means that we can
|
||||
easily provide localized BIOS screens or custom messages.
|
||||
the URL, and the informative text, and is displayed by rendering each
|
||||
component in order. This allows us to modify and replace any bitmap (most
|
||||
frequently the HWID), using standard command-line tools such as imagemagick.
|
||||
Compositing each screen in this way also means that we can easily provide
|
||||
localized BIOS screens or custom messages.
|
||||
|
||||
|
||||
Note:
|
||||
Version 1.1 (used in ZGB):
|
||||
|
||||
This is essentially the same as version 1.0, except that the ASCII HWID
|
||||
string can be rendered directly. In the screen description, the magic image
|
||||
name "$HWID" (or "$HWID.rtol") indicates that the ASCII HWID value should be
|
||||
displayed instead of an actual image. This means that we only need to
|
||||
generate one bmpblock for all locales, since the HWID string can be changed
|
||||
at the factory using "gbb_utility".
|
||||
|
||||
Because the bitmap images and display code is part of the Read-Only BIOS,
|
||||
back-porting the new-style bitmaps to older devices is not possible.
|
||||
|
||||
|
||||
Manual instructions:
|
||||
|
||||
@@ -12,11 +12,14 @@ from lib import bmpblock
|
||||
from lib import pixcontrol
|
||||
from lib import pixdisplay
|
||||
|
||||
|
||||
class MyApp(wx.App):
|
||||
|
||||
def OnInit(self):
|
||||
self._bmpblock = bmpblock.BmpBlock(sys.argv[1])
|
||||
progname = os.path.basename(sys.argv[0])
|
||||
progdir = os.path.abspath(os.path.dirname(sys.argv[0]))
|
||||
self._bmpblock = bmpblock.BmpBlock(os.path.join(progdir, 'lib'),
|
||||
sys.argv[1])
|
||||
self._mainframe = pixcontrol.Frame(self._bmpblock, progname)
|
||||
self._mainframe.Show()
|
||||
self.SetTopWindow(self._mainframe)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
1398
scripts/newbitmaps/images/1366x768/DEFAULT.yaml
Normal file
1398
scripts/newbitmaps/images/1366x768/DEFAULT.yaml
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 5.4 KiB |
@@ -6,6 +6,15 @@
|
||||
# Generate a new yaml file for each specified hwid_*.bmp file.
|
||||
#
|
||||
|
||||
if [ "${1:-}" = "--force" ]; then
|
||||
shift;
|
||||
else
|
||||
echo "This script is deprecated."
|
||||
echo "The latest BIOSes can render HWIDs directly from ASCII."
|
||||
echo "Use --force to proceed anyway."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# I'm sorting the locales in more-or-less geographical order. Right should move
|
||||
# east, left should move west. Of course we'll start in the US. :-)
|
||||
locales="en es_419 pt_BR en_GB fr es pt_PT ca it de el nl da no sv fi et lv lt ru pl cs sk hu sl sr hr bg ro uk tr iw ar fa hi th vi id fil zh_CN zh_TW ko ja"
|
||||
|
||||
@@ -14,10 +14,11 @@ class BmpBlock(object):
|
||||
It has a few special attributes to specify which part we're focusing on.
|
||||
"""
|
||||
|
||||
def __init__(self, filename=None):
|
||||
def __init__(self, libdir, filename=None):
|
||||
self.yaml = None
|
||||
self.filename = None
|
||||
self.current_screen = None
|
||||
self.libdir = libdir
|
||||
self.filename = filename # always set, so we can reload
|
||||
if filename:
|
||||
self.LoadFile(filename)
|
||||
@@ -45,9 +46,9 @@ class BmpBlock(object):
|
||||
"""Raise an error if the specified dict is not a valid BmpBlock structure"""
|
||||
|
||||
assert isinstance(thing, dict)
|
||||
assert thing["bmpblock"] == 1.0
|
||||
assert thing["bmpblock"] == 1.0 or thing["bmpblock"] == 1.1
|
||||
|
||||
seen_images = {}
|
||||
seen_images = {"$HWID":1, "$HWID.rtol":2}
|
||||
seen_screens = {}
|
||||
|
||||
images = thing["images"]
|
||||
@@ -56,6 +57,10 @@ class BmpBlock(object):
|
||||
# image values should all be filenames (ie, strings)
|
||||
for val in images.values():
|
||||
assert val and isinstance(val, types.StringTypes)
|
||||
if not "$HWID" in images:
|
||||
images["$HWID"] = os.path.join(self.libdir,'current_hwid.bmp')
|
||||
if not "$HWID.rtol" in images:
|
||||
images["$HWID.rtol"] = os.path.join(self.libdir, 'current_hwid.bmp')
|
||||
|
||||
screens = thing["screens"]
|
||||
assert isinstance(screens, dict)
|
||||
|
||||
BIN
scripts/newbitmaps/lib/current_hwid.bmp
Normal file
BIN
scripts/newbitmaps/lib/current_hwid.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.0 KiB |
@@ -13,10 +13,17 @@ import re
|
||||
import tempfile
|
||||
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print "usage: %s autotest/../hardware_Components/" % sys.argv[0]
|
||||
if '--force' in sys.argv:
|
||||
sys.argv.remove('--force')
|
||||
else:
|
||||
print "This script is deprecated."
|
||||
print "The latest BIOSes can render HWIDs directly from ASCII."
|
||||
print "Use --force to proceed anyway."
|
||||
sys.exit(1)
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print "usage: %s --force autotest/../hardware_Components/" % sys.argv[0]
|
||||
sys.exit(1)
|
||||
|
||||
def MakeBmp(hwid, geom, bmp, directory):
|
||||
""" Create the bitmap for this file. """
|
||||
|
||||
@@ -282,74 +282,89 @@ int dump_bmpblock(const char *infile, int show_as_yaml,
|
||||
fprintf(yfp, "images:\n");
|
||||
for(i=0; i<hdr->number_of_imageinfos; i++) {
|
||||
img = (ImageInfo *)(ptr + offset);
|
||||
sprintf(image_name, "img_%08x.bmp", offset);
|
||||
fprintf(yfp, " img_%08x: %s # %dx%d %d/%d\n", offset, image_name,
|
||||
img->width, img->height,
|
||||
img->compressed_size, img->original_size);
|
||||
if (todir) {
|
||||
sprintf(full_path_name, "%s/%s", todir, image_name);
|
||||
bfd = open(full_path_name,
|
||||
O_WRONLY | O_CREAT | O_TRUNC | (overwrite ? 0 : O_EXCL),
|
||||
0666);
|
||||
if (bfd < 0) {
|
||||
fprintf(stderr, "Unable to open %s: %s\n", full_path_name,
|
||||
strerror(errno));
|
||||
fclose(yfp);
|
||||
discard_file(ptr, length);
|
||||
return 1;
|
||||
if (img->compressed_size) {
|
||||
sprintf(image_name, "img_%08x.bmp", offset);
|
||||
if (img->tag == TAG_HWID) {
|
||||
fprintf(yfp, " %s: %s # %dx%d %d/%d tag=%d\n",
|
||||
RENDER_HWID, image_name,
|
||||
img->width, img->height,
|
||||
img->compressed_size, img->original_size, img->tag);
|
||||
} else if (img->tag == TAG_HWID_RTOL) {
|
||||
fprintf(yfp, " %s: %s # %dx%d %d/%d tag=%d\n",
|
||||
RENDER_HWID_RTOL, image_name,
|
||||
img->width, img->height,
|
||||
img->compressed_size, img->original_size, img->tag);
|
||||
} else {
|
||||
fprintf(yfp, " img_%08x: %s # %dx%d %d/%d tag=%d\n",
|
||||
offset, image_name,
|
||||
img->width, img->height,
|
||||
img->compressed_size, img->original_size, img->tag);
|
||||
}
|
||||
bfp = fdopen(bfd, "wb");
|
||||
if (!bfp) {
|
||||
fprintf(stderr, "Unable to fdopen %s: %s\n", full_path_name,
|
||||
strerror(errno));
|
||||
close(bfd);
|
||||
fclose(yfp);
|
||||
discard_file(ptr, length);
|
||||
return 1;
|
||||
}
|
||||
switch(img->compression) {
|
||||
case COMPRESS_NONE:
|
||||
data_ptr = ptr + offset + sizeof(ImageInfo);
|
||||
free_data = 0;
|
||||
break;
|
||||
case COMPRESS_EFIv1:
|
||||
data_ptr = do_efi_decompress(img);
|
||||
if (!data_ptr) {
|
||||
if (todir) {
|
||||
sprintf(full_path_name, "%s/%s", todir, image_name);
|
||||
bfd = open(full_path_name,
|
||||
O_WRONLY | O_CREAT | O_TRUNC | (overwrite ? 0 : O_EXCL),
|
||||
0666);
|
||||
if (bfd < 0) {
|
||||
fprintf(stderr, "Unable to open %s: %s\n", full_path_name,
|
||||
strerror(errno));
|
||||
fclose(yfp);
|
||||
discard_file(ptr, length);
|
||||
return 1;
|
||||
}
|
||||
bfp = fdopen(bfd, "wb");
|
||||
if (!bfp) {
|
||||
fprintf(stderr, "Unable to fdopen %s: %s\n", full_path_name,
|
||||
strerror(errno));
|
||||
close(bfd);
|
||||
fclose(yfp);
|
||||
discard_file(ptr, length);
|
||||
return 1;
|
||||
}
|
||||
switch(img->compression) {
|
||||
case COMPRESS_NONE:
|
||||
data_ptr = ptr + offset + sizeof(ImageInfo);
|
||||
free_data = 0;
|
||||
break;
|
||||
case COMPRESS_EFIv1:
|
||||
data_ptr = do_efi_decompress(img);
|
||||
if (!data_ptr) {
|
||||
fclose(bfp);
|
||||
fclose(yfp);
|
||||
discard_file(ptr, length);
|
||||
return 1;
|
||||
}
|
||||
free_data = 1;
|
||||
break;
|
||||
case COMPRESS_LZMA1:
|
||||
data_ptr = do_lzma_decompress(img);
|
||||
if (!data_ptr) {
|
||||
fclose(bfp);
|
||||
fclose(yfp);
|
||||
discard_file(ptr, length);
|
||||
return 1;
|
||||
}
|
||||
free_data = 1;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unsupported compression method encountered.\n");
|
||||
fclose(bfp);
|
||||
fclose(yfp);
|
||||
discard_file(ptr, length);
|
||||
return 1;
|
||||
}
|
||||
free_data = 1;
|
||||
break;
|
||||
case COMPRESS_LZMA1:
|
||||
data_ptr = do_lzma_decompress(img);
|
||||
if (!data_ptr) {
|
||||
if (1 != fwrite(data_ptr, img->original_size, 1, bfp)) {
|
||||
fprintf(stderr, "Unable to write %s: %s\n", full_path_name,
|
||||
strerror(errno));
|
||||
fclose(bfp);
|
||||
fclose(yfp);
|
||||
discard_file(ptr, length);
|
||||
return 1;
|
||||
}
|
||||
free_data = 1;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unsupported compression method encountered.\n");
|
||||
fclose(bfp);
|
||||
fclose(yfp);
|
||||
discard_file(ptr, length);
|
||||
return 1;
|
||||
if (free_data)
|
||||
free(data_ptr);
|
||||
}
|
||||
if (1 != fwrite(data_ptr, img->original_size, 1, bfp)) {
|
||||
fprintf(stderr, "Unable to write %s: %s\n", full_path_name,
|
||||
strerror(errno));
|
||||
fclose(bfp);
|
||||
fclose(yfp);
|
||||
discard_file(ptr, length);
|
||||
return 1;
|
||||
}
|
||||
fclose(bfp);
|
||||
if (free_data)
|
||||
free(data_ptr);
|
||||
}
|
||||
offset += sizeof(ImageInfo);
|
||||
offset += img->compressed_size;
|
||||
@@ -370,9 +385,21 @@ int dump_bmpblock(const char *infile, int show_as_yaml,
|
||||
scr = (ScreenLayout *)(ptr + offset);
|
||||
for(i=0; i<MAX_IMAGE_IN_LAYOUT; i++) {
|
||||
if (scr->images[i].image_info_offset) {
|
||||
fprintf(yfp, " - [%d, %d, img_%08x]\n",
|
||||
scr->images[i].x, scr->images[i].y,
|
||||
scr->images[i].image_info_offset);
|
||||
ImageInfo *iptr =
|
||||
(ImageInfo *)(ptr + scr->images[i].image_info_offset);
|
||||
if (iptr->tag == TAG_HWID) {
|
||||
fprintf(yfp, " - [%d, %d, %s]\n",
|
||||
scr->images[i].x, scr->images[i].y,
|
||||
RENDER_HWID);
|
||||
} else if (iptr->tag == TAG_HWID_RTOL) {
|
||||
fprintf(yfp, " - [%d, %d, %s]\n",
|
||||
scr->images[i].x, scr->images[i].y,
|
||||
RENDER_HWID_RTOL);
|
||||
} else {
|
||||
fprintf(yfp, " - [%d, %d, img_%08x]\n",
|
||||
scr->images[i].x, scr->images[i].y,
|
||||
scr->images[i].image_info_offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -50,15 +50,12 @@ typedef struct BmpBlockConfig {
|
||||
|
||||
class BmpBlockUtil {
|
||||
public:
|
||||
BmpBlockUtil();
|
||||
BmpBlockUtil(bool debug);
|
||||
~BmpBlockUtil();
|
||||
|
||||
/* Load all the images and related infomations according to a config file. */
|
||||
void load_from_config(const char *filename);
|
||||
|
||||
/* Compress all the images using a given comression method. */
|
||||
void compress_all_images(const Compression compress);
|
||||
|
||||
/* Contruct the bmpblock. */
|
||||
void pack_bmpblock();
|
||||
|
||||
@@ -69,9 +66,6 @@ class BmpBlockUtil {
|
||||
void force_compression(uint32_t compression);
|
||||
|
||||
private:
|
||||
/* Clear all internal data. */
|
||||
void initialize();
|
||||
|
||||
/* Elemental function called from load_from_config.
|
||||
* Load the config file (yaml format) and parse it. */
|
||||
void load_yaml_config(const char *filename);
|
||||
@@ -80,10 +74,6 @@ class BmpBlockUtil {
|
||||
* Load all image files into the internal variables. */
|
||||
void load_all_image_files();
|
||||
|
||||
/* Elemental function called from load_from_config.
|
||||
* Contruct all ImageInfo structs. */
|
||||
void fill_all_image_infos();
|
||||
|
||||
/* Elemental function called from load_from_config.
|
||||
* Contruct the BmpBlockHeader struct. */
|
||||
void fill_bmpblock_header();
|
||||
@@ -105,6 +95,16 @@ class BmpBlockUtil {
|
||||
uint32_t get_bmp_image_width(const string content);
|
||||
uint32_t get_bmp_image_height(const string content);
|
||||
|
||||
/* Verbosity flags */
|
||||
bool debug_;
|
||||
|
||||
/* Internal variable for string the BmpBlock version. */
|
||||
uint16_t major_version_;
|
||||
uint16_t minor_version_;
|
||||
|
||||
/* Flags for version-specific features */
|
||||
bool render_hwid_;
|
||||
|
||||
/* Internal variable for storing the config of BmpBlock. */
|
||||
BmpBlockConfig config_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user