Skip to content

Commit

Permalink
lk2nd: device: Allow panel selector to NOP arbitrary compatible's status
Browse files Browse the repository at this point in the history
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 <[email protected]>
Co-authored-by: Nils Tonnaett <[email protected]>
  • Loading branch information
3 people authored and M0Rf30 committed Dec 11, 2023
1 parent 2e745a2 commit f347d1e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
25 changes: 23 additions & 2 deletions app/aboot/lk2nd-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions app/aboot/lk2nd-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ struct lk2nd_panel {
const char *old_compatible;
const char *compatible;
int compatible_size;
const char *ts_compatible;
};

struct lk2nd_device {
Expand Down

0 comments on commit f347d1e

Please sign in to comment.