From f347d1ec36b3c6c8ed58dc9283b6b84a34bc0700 Mon Sep 17 00:00:00 2001 From: Vincent Knecht Date: Sat, 26 Aug 2023 13:16:43 -0700 Subject: [PATCH] lk2nd: device: Allow panel selector to NOP arbitrary compatible's status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the case a device has variants with specific touchscreen coupled with specific panel, it's useful to be able to declare both touchscreens with status "disabled" in Linux DTS, and have lk2nd NOP this status for the one associated with detected panel. Co-authored-by: Niklas Henrik Tonnätt Co-authored-by: Nils Tonnaett --- app/aboot/lk2nd-device.c | 25 +++++++++++++++++++++++-- app/aboot/lk2nd-device.h | 1 + 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/app/aboot/lk2nd-device.c b/app/aboot/lk2nd-device.c index 85037f1a9..793500b1c 100644 --- a/app/aboot/lk2nd-device.c +++ b/app/aboot/lk2nd-device.c @@ -276,8 +276,8 @@ static const char *fdt_getprop_str(const void *fdt, int offset, const char *prop static void lk2nd_parse_panels(const void *fdt, int offset) { struct lk2nd_panel *panel = &lk2nd_dev.panel; - const char *old, *new; - int old_len, new_len; + const char *old, *new, *ts; + int old_len, new_len, ts_len; offset = fdt_subnode_offset(fdt, offset, "panel"); if (offset < 0) @@ -306,6 +306,16 @@ static void lk2nd_parse_panels(const void *fdt, int offset) strlcpy((char*) panel->compatible, new, new_len); strlcpy((char*) panel->old_compatible, old, old_len); + + ts = fdt_getprop_str(fdt, offset, "touchscreen-compatible", &ts_len); + if (!ts || ts_len < 1) + return; + + panel->ts_compatible = malloc(ts_len); + ASSERT(panel->ts_compatible); + strlcpy((char*) panel->ts_compatible, ts, ts_len + 1); + + dprintf(INFO, "Found touchscreen-compatible: %s\n", panel->ts_compatible); } static void lk2nd_parse_device_node(const void *fdt) @@ -433,6 +443,17 @@ static void lk2nd_update_panel_compatible(void *fdt) ret = fdt_setprop(fdt, offset, "compatible", panel->compatible, panel->compatible_size); if (ret) dprintf(CRITICAL, "Failed to update panel compatible: %d\n", ret); + + /* Enable associated touchscreen if any */ + if (panel->ts_compatible) { + offset = fdt_node_offset_by_compatible(fdt, -1, panel->ts_compatible); + if (offset < 0) + return; + + ret = fdt_nop_property(fdt, offset, "status"); + if (ret) + dprintf(CRITICAL, "Failed to NOP touchscreen status: %d\n", ret); + } } void lk2nd_update_device_tree(void *fdt, const char *cmdline) diff --git a/app/aboot/lk2nd-device.h b/app/aboot/lk2nd-device.h index 9fabd7949..152a7fa56 100644 --- a/app/aboot/lk2nd-device.h +++ b/app/aboot/lk2nd-device.h @@ -10,6 +10,7 @@ struct lk2nd_panel { const char *old_compatible; const char *compatible; int compatible_size; + const char *ts_compatible; }; struct lk2nd_device {