Skip to content

Commit

Permalink
rockchip: resource: support parse "logo" partition picture
Browse files Browse the repository at this point in the history
We provide a "logo" partition for user to store logo.bmp
and update from kernel user space dynamically.

This patch follows the rkdevelop usage:
- Only support store one picture named "logo.bmp";
- Use "dd" command to generate partition image with logo.img
  eg: "dd if=logo.bmp of=logo.img count=1 bs=19456"

Change-Id: Iffde4d123e303c010d99cd446c241a535bce1dcf
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
  • Loading branch information
JosephChen2017 committed Jul 12, 2019
1 parent 47e67a8 commit 1d30bcc
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
62 changes: 62 additions & 0 deletions arch/arm/mach-rockchip/resource_img.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
*/
#include <common.h>
#include <adc.h>
#include <bmp_layout.h>
#include <asm/io.h>
#include <fs.h>
#include <malloc.h>
#include <sysmem.h>
#include <asm/unaligned.h>
#include <linux/list.h>
#include <asm/arch/resource_img.h>
#include <boot_rkimg.h>
Expand Down Expand Up @@ -165,6 +167,7 @@ static int init_resource_list(struct resource_img_hdr *hdr)
int offset = 0;
int resource_found = 0;
struct blk_desc *dev_desc;
struct bmp_header *header;
disk_partition_t part_info;
char *boot_partname = PART_BOOT;

Expand Down Expand Up @@ -317,6 +320,65 @@ static int init_resource_list(struct resource_img_hdr *hdr)

ret = 0;
printf("Load FDT from %s part\n", boot_partname);

/*
* Add logo.bmp from "logo" parititon
*
* We provide a "logo" partition for user to store logo.bmp
* and update from kernel user space dynamically.
*/
if (part_get_info_by_name(dev_desc, PART_LOGO, &part_info) >= 0) {
struct resource_file *file;
struct list_head *node;

header = memalign(ARCH_DMA_MINALIGN, RK_BLK_SIZE);
if (!header) {
ret = -ENOMEM;
goto err;
}

ret = blk_dread(dev_desc, part_info.start, 1, header);
if (ret != 1) {
ret = -EIO;
goto err2;
}

if (header->signature[0] != 'B' ||
header->signature[1] != 'M') {
ret = 0;
goto err2;
}

entry = malloc(sizeof(*entry));
if (!entry) {
ret = -ENOMEM;
goto err2;
}

memcpy(entry->tag, ENTRY_TAG, sizeof(ENTRY_TAG));
memcpy(entry->name, "logo.bmp", sizeof("logo.bmp"));
entry->f_size = get_unaligned_le32(&header->file_size);
entry->f_offset = 0;

/* Delete exist "logo.bmp", then add new */
list_for_each(node, &entrys_head) {
file = list_entry(node,
struct resource_file, link);
if (!strcmp(file->name, entry->name)) {
list_del(&file->link);
free(file);
break;
}
}

add_file_to_list(entry, part_info.start);
free(entry);
printf("Load \"logo.bmp\" from logo part\n");
ret = 0;
err2:
free(header);
}

err:
free(content);
out:
Expand Down
1 change: 1 addition & 0 deletions include/boot_rkimg.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ enum _boot_mode {
#define PART_BOOT "boot"
#define PART_RECOVERY "recovery"
#define PART_DTBO "dtbo"
#define PART_LOGO "logo"

#define RK_BLK_SIZE 512

Expand Down

0 comments on commit 1d30bcc

Please sign in to comment.