Fix nokia-beatles closed-flip cover wake via dynamic TLMM gpiochip resolution

- Resolve MSM8909 TLMM (1000000.pinctrl) dynamically across /dev/gpiochip* in bananarchy-cover-idle (BA_GPIO_GET_CHIPINFO / hw_ensure_gpiochip) and bananarchy-cover-diagnose.sh, and default cover-display.conf to gpiochip_device = auto so strict fw_devlink/MPM probe order shifts never leave closed-flip button wakes in backend=none.

- Guard gpiochip_device = auto and BA_GPIO_GET_CHIPINFO in test-cover-kernel.py and check-rebuild.sh, and update a1114 (carbonara) image and release archive SHA-256 pins in check-rebuild.sh and CHANGELOG.md.
This commit is contained in:
Luxferre committed 2026-11-13 19:06:40 +02:00
1 parent 2ae4ef34a2
commit a23a9b4edb
9 files changed
+121 -23

No files matched your search

+91 -13
View File
@@ -67,6 +67,7 @@
* fixed by the kernel ABI; a compile-time size check guards the cross build. */
#define BA_GPIO_IOC_MAGIC 0xb4u
#define BA_IOC_WR 1u
#define BA_IOC_RD 2u
#define BA_IOC_RDWR 3u
#define BA_IOC(dir, type, nr, size) \
(((unsigned int)(dir) << 30) | ((unsigned int)(type) << 8) | \
@@ -76,11 +77,18 @@
#define BA_SPI_IOC_WR_MODE BA_IOC(BA_IOC_WR, 'k', 1u, 1u)
#define BA_SPI_IOC_WR_BITS BA_IOC(BA_IOC_WR, 'k', 3u, 1u)
#define BA_SPI_IOC_WR_SPEED BA_IOC(BA_IOC_WR, 'k', 4u, 4u)
#define BA_GPIO_GET_CHIPINFO BA_IOC(BA_IOC_RD, BA_GPIO_IOC_MAGIC, 1u, 68u)
#define BA_GPIO_GET_LINEHANDLE BA_IOC(BA_IOC_RDWR, BA_GPIO_IOC_MAGIC, 3u, 364u)
#define BA_GPIO_GET_VALUES BA_IOC(BA_IOC_RDWR, BA_GPIO_IOC_MAGIC, 8u, 64u)
#define BA_GPIO_SET_VALUES BA_IOC(BA_IOC_RDWR, BA_GPIO_IOC_MAGIC, 9u, 64u)
#define BA_GPIOHANDLE_REQUEST_OUTPUT (1u << 1)
struct ba_gpiochip_info {
char name[32];
char label[32];
uint32_t lines;
};
struct ba_gpiohandle_request {
uint32_t lineoffsets[64];
uint32_t flags;
@@ -108,6 +116,8 @@ struct ba_spi_ioc_transfer {
uint8_t pad;
};
_Static_assert(sizeof(struct ba_gpiochip_info) == 68,
"gpiochip v1 chipinfo ABI size");
_Static_assert(sizeof(struct ba_gpiohandle_request) == 364,
"gpiochip v1 linehandle ABI size");
_Static_assert(sizeof(struct ba_spi_ioc_transfer) == 32,
@@ -670,6 +680,79 @@ static int hw_gpio_set(struct cover_hw *hw, int fd,
return ioctl(fd, BA_GPIO_SET_VALUES, &data) >= 0;
}
static int hw_ensure_gpiochip(struct cover_hw *hw)
{
unsigned int min_lines;
glob_t gl;
size_t i;
int best_fd = -1;
char best_path[128] = "";
if(hw->sim || hw->fd_chip >= 0)
return 1;
min_lines = (hw->mux_gpio > hw->reset_gpio ?
hw->mux_gpio : hw->reset_gpio) + 1;
if(hw->word_bits != 9 && hw->dc_gpio < 1024 && hw->dc_gpio + 1 > min_lines)
min_lines = hw->dc_gpio + 1;
if(hw->gpio_path[0] && strcasecmp(hw->gpio_path, "auto") != 0) {
int fd = open(hw->gpio_path, O_RDWR | O_CLOEXEC);
if(fd >= 0) {
struct ba_gpiochip_info info;
memset(&info, 0, sizeof(info));
if(ioctl(fd, BA_GPIO_GET_CHIPINFO, &info) == 0) {
info.label[sizeof(info.label) - 1] = '\0';
if(info.lines >= min_lines &&
(strstr(info.label, "pinctrl") != NULL ||
strstr(info.label, "tlmm") != NULL)) {
hw->fd_chip = fd;
return 1;
}
close(fd);
} else if(errno == ENOTTY) {
hw->fd_chip = fd;
return 1;
} else {
close(fd);
}
}
}
if(glob("/dev/gpiochip*", 0, NULL, &gl) == 0) {
for(i = 0; i < gl.gl_pathc; i++) {
struct ba_gpiochip_info info;
int fd = open(gl.gl_pathv[i], O_RDWR | O_CLOEXEC);
if(fd < 0)
continue;
memset(&info, 0, sizeof(info));
if(ioctl(fd, BA_GPIO_GET_CHIPINFO, &info) == 0 &&
info.lines >= min_lines) {
info.label[sizeof(info.label) - 1] = '\0';
if(strstr(info.label, "pinctrl") != NULL ||
strstr(info.label, "tlmm") != NULL) {
if(best_fd >= 0)
close(best_fd);
best_fd = fd;
safe_copy(best_path, sizeof(best_path), gl.gl_pathv[i]);
fd = -1;
break;
}
if(best_fd < 0) {
best_fd = fd;
safe_copy(best_path, sizeof(best_path), gl.gl_pathv[i]);
fd = -1;
}
}
if(fd >= 0)
close(fd);
}
globfree(&gl);
}
if(best_fd >= 0) {
hw->fd_chip = best_fd;
safe_copy(hw->gpio_path, sizeof(hw->gpio_path), best_path);
return 1;
}
return 0;
}
static int hw_gpio_request(struct cover_hw *hw, const unsigned int *offsets,
const unsigned char *defaults, unsigned int count)
{
@@ -679,7 +762,7 @@ static int hw_gpio_request(struct cover_hw *hw, const unsigned int *offsets,
hw_event(hw, "claim");
return 1;
}
if(hw->fd_chip < 0)
if(!hw_ensure_gpiochip(hw))
return -1;
memset(&req, 0, sizeof(req));
for(i = 0; i < count && i < 64; i++) {
@@ -824,11 +907,8 @@ static int hw_activate(struct cover_hw *hw)
int fd;
if(!hw->spi_enabled)
return 0;
if(!hw->sim && hw->fd_chip < 0) {
hw->fd_chip = open(hw->gpio_path, O_RDWR | O_CLOEXEC);
if(hw->fd_chip < 0)
return 0;
}
if(!hw_ensure_gpiochip(hw))
return 0;
if(!hw->mux_claimed) {
mux_offset[0] = hw->mux_gpio;
mux_default[0] = (unsigned char)hw->mux_open_level;
@@ -1906,7 +1986,7 @@ static void cover_hw_init(struct cover_hw *hw)
hw->kernel_lit = -1;
hw->kernel_restored = 0;
safe_copy(hw->spi_path, sizeof(hw->spi_path), "/dev/spidev0.1");
safe_copy(hw->gpio_path, sizeof(hw->gpio_path), "/dev/gpiochip0");
safe_copy(hw->gpio_path, sizeof(hw->gpio_path), "auto");
safe_copy(hw->firmware, sizeof(hw->firmware),
"/lib/firmware/nokia,beatles-gc9305-ext-panel.bin");
safe_copy(hw->kernel_fb, sizeof(hw->kernel_fb), "/dev/fb0");
@@ -2094,11 +2174,8 @@ static void read_config(const char *path, char *socket_path, size_t splen,
if(strcmp(hw->backend, "none") == 0 || strcmp(hw->backend, "fb") == 0 ||
!hw->spi_path[0] || !hw->gpio_path[0] || !hw->firmware[0])
return;
if(!hw->sim) {
hw->fd_chip = open(hw->gpio_path, O_RDWR | O_CLOEXEC);
if(hw->fd_chip < 0)
return;
}
if(!hw_ensure_gpiochip(hw))
return;
hw->spi_enabled = 1;
}
@@ -2270,7 +2347,8 @@ static void handle_command(char *buffer, struct state *state,
safe_copy(hw->backend, sizeof(hw->backend), value);
hw->spi_enabled =
strcmp(hw->backend, "none") != 0 && strcmp(hw->backend, "fb") != 0 &&
hw->spi_path[0] && hw->gpio_path[0] && hw->firmware[0];
hw->spi_path[0] && hw->gpio_path[0] && hw->firmware[0] &&
hw_ensure_gpiochip(hw);
} else if(strcmp(key, "mux_closed_level") == 0)
hw->mux_closed_level = config_level(value, hw->mux_closed_level);
else if(strcmp(key, "mux_open_level") == 0)