]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
cmd: add new command to read edid
authorJulien Stephan <jstephan@baylibre.com>
Mon, 30 Jun 2025 10:08:16 +0000 (12:08 +0200)
committerTom Rini <trini@konsulko.com>
Tue, 30 Dec 2025 17:22:57 +0000 (11:22 -0600)
Add a new command to read EDID info from connected display.

When applicable EDID can also be retrieved by commands such as:

  i2c dev x
  i2c edid 0x50

but the new read_edid function relies on the implementation of the
read_edid callback from DISPLAY driver.

Signed-off-by: Julien Stephan <jstephan@baylibre.com>
cmd/Kconfig
cmd/Makefile
cmd/read_edid.c [new file with mode: 0644]
drivers/video/display-uclass.c
include/display.h

index f21d27cb27f28267963e0d264e4cb9e7e791b0e8..3018e33ca7d5730c1353e1b30a689261c2b01907 100644 (file)
@@ -1608,6 +1608,12 @@ config CMD_READ
        help
          Provides low-level access to the data in a partition.
 
+config CMD_READ_EDID
+       bool "read_edid - Read display EDID"
+       depends on DISPLAY
+       help
+         Read and parse edid from connected display device.
+
 config CMD_REMOTEPROC
        bool "remoteproc"
        depends on REMOTEPROC
index 80cf70b7fe8c1747db37d7cb1428863a671560b5..7cb379c05a01237133eab24c085a47c3f5386626 100644 (file)
@@ -154,6 +154,7 @@ obj-$(CONFIG_CMD_WOL) += wol.o
 obj-$(CONFIG_CMD_QFW) += qfw.o
 obj-$(CONFIG_CMD_READ) += read.o
 obj-$(CONFIG_CMD_WRITE) += read.o
+obj-$(CONFIG_CMD_READ_EDID) += read_edid.o
 obj-$(CONFIG_CMD_REGINFO) += reginfo.o
 obj-$(CONFIG_CMD_REMOTEPROC) += remoteproc.o
 obj-$(CONFIG_CMD_RNG) += rng.o
diff --git a/cmd/read_edid.c b/cmd/read_edid.c
new file mode 100644 (file)
index 0000000..428dddc
--- /dev/null
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2025 BayLibre, SAS
+ */
+
+#include <command.h>
+#include <dm.h>
+#include <display.h>
+#include <edid.h>
+
+static int do_read_edid(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[])
+{
+       struct udevice *dev;
+       int ret;
+       u8 edid[EDID_EXT_SIZE];
+
+       /* Get the first display device (UCLASS_DISPLAY) */
+       ret = uclass_first_device_err(UCLASS_DISPLAY, &dev);
+       if (ret) {
+               printf("Cannot get display device: %d\n", ret);
+               return CMD_RET_FAILURE;
+       }
+
+       ret = display_read_edid(dev, edid, EDID_EXT_SIZE);
+       if (ret) {
+               printf("Cannot read edid: %d\n", ret);
+               return CMD_RET_FAILURE;
+       }
+
+       edid_print_info((struct edid1_info *)edid);
+
+       return CMD_RET_SUCCESS;
+}
+
+U_BOOT_CMD(read_edid, 1, 0, do_read_edid,
+       "Read and print EDID from display",
+       ""
+);
index 57e730538dfd70513c4746653719440d973aed6a..85dac12a197e8e527ffa8217768c1e2a967585cd 100644 (file)
@@ -10,7 +10,7 @@
 #include <edid.h>
 #include <errno.h>
 
-static int display_read_edid(struct udevice *dev, u8 *buf, int buf_size)
+int display_read_edid(struct udevice *dev, u8 *buf, int buf_size)
 {
        struct dm_display_ops *ops = display_get_ops(dev);
 
index e8d8aaa15fbcbf0b2bcaeec0d612ad66346d28c3..26b965daba9384e8e351a4a5fc6f4703b8d8511d 100644 (file)
@@ -25,6 +25,16 @@ struct display_plat {
        bool in_use;
 };
 
+/**
+ * display_read_edid() - Read edid from display
+ *
+ * @dev:       Device to read from
+ * @buf:       Buffer to read into (should be EDID_SIZE bytes)
+ * @buf_size:  Buffer size (should be EDID_SIZE)
+ * Return number of bytes read, <= 0 for error
+ */
+int display_read_edid(struct udevice *dev, u8 *buf, int buf_size);
+
 /**
  * display_read_timing() - Read timing information
  *