Skip to contentSkip to conversation

splash: add more options/support

PATCH Superseded Julien Masson 1 participant 3 messages Sep 19, 2022

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover splash: add more options/support

This patch series add several options/support for splashscreen feature:
- support raw image from MMC
- get devpart from environment variable

With these changes the user has now more options and can change default configurations through environment variables.

Example: image located in splashscreen partition (MMC as raw)

```
splashsource=mmc_raw
splashdevpart=0#splashscreen
```

Julien Masson (2):
splash: support raw image from MMC
splash: get devpart from environment variable

 common/splash.c        |  6 ++++++
 common/splash_source.c | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)
Signature · 1 line
2.37.3
#1 lore raw

PATCH 1/2 splash: support raw image from MMC

The user has now the choice to specify the splash location in the MMC as a raw storage.

---
 common/splash.c        |  6 ++++++
 common/splash_source.c | 29 +++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)
common/splash.c +6 -0
index 0e520cc103..5206e35f74 100644
@@ -39,6 +39,12 @@ static struct splash_location default_splash_locations[] = {
 		.flags = SPLASH_STORAGE_FS,
 		.devpart = "0:1",
 	},
+	{
+		.name = "mmc_raw",
+		.storage = SPLASH_STORAGE_MMC,
+		.flags = SPLASH_STORAGE_RAW,
+		.devpart = "0:1",
+	},
 	{
 		.name = "usb_fs",
 		.storage = SPLASH_STORAGE_USB,
common/splash_source.c +29 -0
index 2c03cbdf92..c512aa0196 100644
@@ -65,6 +65,33 @@ static int splash_nand_read_raw(u32 bmp_load_addr, int offset, size_t read_size)
 }
 #endif
 
+#ifdef CONFIG_CMD_MMC
+static int splash_mmc_read_raw(u32 bmp_load_addr, struct splash_location *location,
+			       size_t read_size)
+{
+	struct disk_partition partition;
+	struct blk_desc *desc;
+	lbaint_t blkcnt;
+	int ret, n;
+
+	ret = part_get_info_by_dev_and_name_or_num("mmc", location->devpart, &desc,
+						   &partition, 1);
+	if (ret < 0)
+		return ret;
+
+	blkcnt = DIV_ROUND_UP(read_size, partition.blksz);
+	n = blk_dread(desc, partition.start, blkcnt, (void *)(uintptr_t)bmp_load_addr);
+
+	return (n == blkcnt) ? 0 : -EINVAL;
+}
+#else
+static int splash_mmc_read_raw(u32 bmp_load_addr, int offset, size_t read_size)
+{
+	debug("%s: mmc support not available\n", __func__);
+	return -ENOSYS;
+}
+#endif
+
 static int splash_storage_read_raw(struct splash_location *location,
 			       u32 bmp_load_addr, size_t read_size)
 {
@@ -75,6 +102,8 @@ static int splash_storage_read_raw(struct splash_location *location,
 
 	offset = location->offset;
 	switch (location->storage) {
+	case SPLASH_STORAGE_MMC:
+		return splash_mmc_read_raw(bmp_load_addr, location, read_size);
 	case SPLASH_STORAGE_NAND:
 		return splash_nand_read_raw(bmp_load_addr, offset, read_size);
 	case SPLASH_STORAGE_SF:
Signature · 1 line
2.37.3
#2 lore raw

PATCH 2/2 splash: get devpart from environment variable

In reply to Julien Masson

By default several types of splash locations are supported and the user can select one of them through environment var (splashsource).

However the devpart is still hardcoded and we cannot change it from the environment.

This patch add the support of "splashdevpart" which allow the user to set the devpart though this environment variable.

Example: image located in splashscreen partition (MMC as raw)

```
splashsource=mmc_raw
splashdevpart=0#splashscreen
```
---
 common/splash_source.c | 5 +++++
 1 file changed, 5 insertions(+)
common/splash_source.c +5 -0
index c512aa0196..a7764ff16f 100644
@@ -451,6 +451,7 @@ int splash_source_load(struct splash_location *locations, uint size)
 {
 	struct splash_location *splash_location;
 	char *env_splashimage_value;
+	char *env_splashdevpart_value;
 	u32 bmp_load_addr;
 
 	env_splashimage_value = env_get("splashimage");
@@ -467,6 +468,10 @@ int splash_source_load(struct splash_location *locations, uint size)
 	if (!splash_location)
 		return -EINVAL;
 
+	env_splashdevpart_value = env_get("splashdevpart");
+	if (env_splashdevpart_value)
+		splash_location->devpart = env_splashdevpart_value;
+
 	if (splash_location->flags == SPLASH_STORAGE_RAW)
 		return splash_load_raw(splash_location, bmp_load_addr);
 	else if (splash_location->flags == SPLASH_STORAGE_FS)
Signature · 1 line
2.37.3