From 41fcb8fbdba1e21a9923ef462dc3349e4066ceb7 Mon Sep 17 00:00:00 2001 From: Ricard Rosson Date: Tue, 11 Aug 2026 09:07:30 +0100 Subject: [PATCH 1/2] drivers/lcd: rename apa102.c/max7219.c to unique object names drivers/ is built by a single flat Makefile: every per-directory Make.defs appends its sources to one CSRCS list and its directory to one VPATH, and the objects all land in drivers/ named after the source basename. Two sources with the same basename in different subdirectories therefore map to the same object, and make resolves the prerequisite through VPATH, which is searched in the order drivers/Makefile includes the Make.defs files. lcd is included before leds, so drivers/lcd always wins. Both apa102 and max7219 exist twice, once as an LCD front-end and once as an LED driver: drivers/lcd/apa102.c CONFIG_LCD_APA102 drivers/leds/apa102.c CONFIG_LEDS_APA102 drivers/lcd/max7219.c CONFIG_LCD_MAX7219 drivers/leds/max7219.c CONFIG_LEDS_MAX7219 drivers/lcd/Make.defs puts lcd on the VPATH for the whole directory whenever CONFIG_LCD=y, so selecting only the LED driver still builds apa102.o from drivers/lcd/apa102.c and the selected LED driver is never compiled at all. Because the LCD front-ends take their constants from include/nuttx/lcd/apa102.h and include/nuttx/lcd/max7219.h, which are behind CONFIG_LCD_APA102 / CONFIG_LCD_MAX7219, the substituted source does not even compile. With CONFIG_LCD=y + CONFIG_LEDS_APA102=y and CONFIG_LCD_APA102 unset: lcd/apa102.c:701:20: error: 'APA102_BLACK' undeclared (first use in this function); did you mean 'APA102_BPP'? and correspondingly for CONFIG_LEDS_MAX7219 without CONFIG_LCD_MAX7219: lcd/max7219.c:773:20: error: 'MAX7219_BLACK' undeclared (first use in this function); did you mean 'MAX7219_BPP'? So neither LED driver can be built together with CONFIG_LCD, and there is no diagnostic pointing at the real cause. Give the LCD front-ends distinct basenames. The LCD side is the adapted use of these parts (an LED matrix driven as a display), and drivers/lcd already names such variants for their role, e.g. ht16k33_14seg.c, so the suffix goes there and the LED drivers keep the plain part names. The CMake build derives object paths from the source directory and was never affected; its source lists are updated to match. Signed-off-by: Ricard Rosson Assisted-by: Claude Opus 5 (Claude Code) --- .github/CODEOWNERS | 4 ++-- drivers/lcd/CMakeLists.txt | 4 ++-- drivers/lcd/Make.defs | 4 ++-- drivers/lcd/{apa102.c => apa102_lcd.c} | 2 +- drivers/lcd/{max7219.c => max7219_lcd.c} | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) rename drivers/lcd/{apa102.c => apa102_lcd.c} (99%) rename drivers/lcd/{max7219.c => max7219_lcd.c} (99%) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 6389d90e48035..8f932f87c9b67 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -13025,7 +13025,7 @@ drivers/ipcc/ipcc_register.c michal.lyszczek@bofc.pl xiaoxiang@xiaomi.com anjiah drivers/ipcc/ipcc_unlink.c michal.lyszczek@bofc.pl devel@sumpfralle.de anjiahao@xiaomi.com alin.jerpelea@sony.com anchao@xiaomi.com drivers/ipcc/ipcc_write.c michal.lyszczek@bofc.pl anjiahao@xiaomi.com anchao@xiaomi.com dongjiuzhu1@xiaomi.com xiaoxiang@xiaomi.com drivers/lcd/Kconfig 101105604+simbit18@users.noreply.github.com acassis@gmail.com paul-a.patience@polymtl.ca -drivers/lcd/apa102.c acassis@gmail.com tiago.medicci@espressif.com petro.karashchenko@gmail.com gustavo.nihei@espressif.com raiden00@railab.me +drivers/lcd/apa102_lcd.c acassis@gmail.com tiago.medicci@espressif.com petro.karashchenko@gmail.com gustavo.nihei@espressif.com raiden00@railab.me drivers/lcd/ft80x.c xiaoxiang@xiaomi.com anjiahao@xiaomi.com anchao@xiaomi.com yamamoto@midokura.com drivers/lcd/ft80x.h alin.jerpelea@sony.com xiaoxiang@xiaomi.com anjiahao@xiaomi.com petro.karashchenko@gmail.com drivers/lcd/ft80x_spi.c alin.jerpelea@sony.com xiaoxiang@xiaomi.com yamamoto@midokura.com @@ -13041,7 +13041,7 @@ drivers/lcd/lcd_dev.c matias@protobits.dev jianglianfang@xiaomi.com rongyichang@ drivers/lcd/lcd_framebuffer.c xiaoxiang@xiaomi.com huangqi3@xiaomi.com jianglianfang@xiaomi.com akaliszan@altimetrik.com drivers/lcd/lcddrv_spiif.c dave@marples.net alin.jerpelea@sony.com petro.karashchenko@gmail.com raiden00@railab.me drivers/lcd/lpm013m091a.c alin.jerpelea@sony.com michael.jung@secore.ly xiaoxiang@xiaomi.com petro.karashchenko@gmail.com -drivers/lcd/max7219.c acassis@gmail.com alin.jerpelea@sony.com liaoao@xiaomi.com matias@protobits.dev michael.jung@secore.ly +drivers/lcd/max7219_lcd.c acassis@gmail.com alin.jerpelea@sony.com liaoao@xiaomi.com matias@protobits.dev michael.jung@secore.ly drivers/lcd/memlcd.c jernej.turnsek@gmail.com juha.niskanen@haltian.com alin.jerpelea@sony.com liaoao@xiaomi.com drivers/lcd/mio283qt2.c alin.jerpelea@sony.com yamamoto@midokura.com michael.jung@secore.ly drivers/lcd/mio283qt9a.c alin.jerpelea@sony.com yamamoto@midokura.com michael.jung@secore.ly raiden00@railab.me diff --git a/drivers/lcd/CMakeLists.txt b/drivers/lcd/CMakeLists.txt index 68e4e0ef4c6d0..192b6ac611570 100644 --- a/drivers/lcd/CMakeLists.txt +++ b/drivers/lcd/CMakeLists.txt @@ -50,7 +50,7 @@ if(CONFIG_LCD) endif() if(CONFIG_LCD_APA102) - list(APPEND SRCS apa102.c) + list(APPEND SRCS apa102_lcd.c) endif() if(CONFIG_LCD_P14201) @@ -94,7 +94,7 @@ if(CONFIG_LCD) endif() if(CONFIG_LCD_MAX7219) - list(APPEND SRCS max7219.c) + list(APPEND SRCS max7219_lcd.c) endif() if(CONFIG_LCD_MIO283QT9A) diff --git a/drivers/lcd/Make.defs b/drivers/lcd/Make.defs index 081b5020195df..baae957c57168 100644 --- a/drivers/lcd/Make.defs +++ b/drivers/lcd/Make.defs @@ -48,7 +48,7 @@ ifeq ($(CONFIG_LCD_LPM013M091A),y) endif ifeq ($(CONFIG_LCD_APA102),y) - CSRCS += apa102.c + CSRCS += apa102_lcd.c endif ifeq ($(CONFIG_LCD_P14201),y) @@ -92,7 +92,7 @@ ifeq ($(CONFIG_LCD_MIO283QT2),y) endif ifeq ($(CONFIG_LCD_MAX7219),y) - CSRCS += max7219.c + CSRCS += max7219_lcd.c endif ifeq ($(CONFIG_LCD_MIO283QT9A),y) diff --git a/drivers/lcd/apa102.c b/drivers/lcd/apa102_lcd.c similarity index 99% rename from drivers/lcd/apa102.c rename to drivers/lcd/apa102_lcd.c index 619fa577e376a..908fc44f50f78 100644 --- a/drivers/lcd/apa102.c +++ b/drivers/lcd/apa102_lcd.c @@ -1,5 +1,5 @@ /**************************************************************************** - * drivers/lcd/apa102.c + * drivers/lcd/apa102_lcd.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/drivers/lcd/max7219.c b/drivers/lcd/max7219_lcd.c similarity index 99% rename from drivers/lcd/max7219.c rename to drivers/lcd/max7219_lcd.c index 3438fe15c5d9c..fe7d121ea66d0 100644 --- a/drivers/lcd/max7219.c +++ b/drivers/lcd/max7219_lcd.c @@ -1,5 +1,5 @@ /**************************************************************************** - * drivers/lcd/max7219.c + * drivers/lcd/max7219_lcd.c * * SPDX-License-Identifier: Apache-2.0 * From aa63960f7b45d516a6f0b8cdb8b16ab64753e003 Mon Sep 17 00:00:00 2001 From: Ricard Rosson Date: Tue, 11 Aug 2026 09:13:42 +0100 Subject: [PATCH 2/2] drivers/lcd: honour the LCD_APA102_* settings in the apa102 LCD driver drivers/lcd/Kconfig offers CONFIG_LCD_APA102_XRES, CONFIG_LCD_APA102_YRES and CONFIG_LCD_APA102_FREQUENCY under "if LCD_APA102", but apa102_lcd.c tests for CONFIG_APA102_XRES, CONFIG_APA102_YRES and CONFIG_APA102_FREQUENCY, which no Kconfig file defines. The #ifndef fallbacks therefore always win and the matrix geometry is hard-wired to 16x16 no matter what is configured. The frequency setting is doubly dead: even the fallback is unused, because apa102_configspi() calls SPI_SETFREQUENCY() with APA102_SPI_MAXFREQUENCY from include/nuttx/leds/apa102.h, which is 100 kHz (its "Default 4MHz" comment notwithstanding), so the chain is always clocked at 100 kHz. Use the names the Kconfig actually defines and drive the bus at the configured frequency. The fallback definitions are kept for an out-of-Kconfig build and given the Kconfig defaults; 16x16 keeps the previous geometry for anyone who never set the options. Verified on stm32f4discovery:nsh with CONFIG_LCD_APA102_XRES=8, CONFIG_LCD_APA102_YRES=4 and CONFIG_LCD_APA102_FREQUENCY=4000000: the shadow framebuffer in g_apa102dev shrinks to 8x4 LEDs and the SPI frequency argument is 0x003d0900, where before the settings had no effect at all. Signed-off-by: Ricard Rosson Assisted-by: Claude Opus 5 (Claude Code) --- drivers/lcd/apa102_lcd.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/lcd/apa102_lcd.c b/drivers/lcd/apa102_lcd.c index 908fc44f50f78..636a8cfdbf018 100644 --- a/drivers/lcd/apa102_lcd.c +++ b/drivers/lcd/apa102_lcd.c @@ -51,12 +51,14 @@ /* APA102 Configuration Settings: * - * CONFIG_APA102_XRES - Specifies the number of physical + * CONFIG_LCD_APA102_XRES - Specifies the number of physical * APA102 devices that are connected together horizontally. * - * CONFIG_APA102_YRES - Specifies the number of physical + * CONFIG_LCD_APA102_YRES - Specifies the number of physical * APA102 devices that are connected together vertically. * + * CONFIG_LCD_APA102_FREQUENCY - SPI frequency used to drive the chain. + * * CONFIG_LCD_INTENSITY - Defines the default bright of LEDs. * * Required LCD driver settings: @@ -68,24 +70,24 @@ /* SPI frequency */ -#ifndef CONFIG_APA102_FREQUENCY -# define CONFIG_APA102_FREQUENCY 10000000 +#ifndef CONFIG_LCD_APA102_FREQUENCY +# define CONFIG_LCD_APA102_FREQUENCY 1000000 #endif /* APA102_COLUMNS determines the number of physical LEDs * matrices that are used connected horizontally. */ -#ifndef CONFIG_APA102_XRES -# define CONFIG_APA102_XRES 16 +#ifndef CONFIG_LCD_APA102_XRES +# define CONFIG_LCD_APA102_XRES 16 #endif /* APA102_LINES determines the number of physical LEDs * matrices that are used connected vertically. */ -#ifndef CONFIG_APA102_YRES -# define CONFIG_APA102_YRES 16 +#ifndef CONFIG_LCD_APA102_YRES +# define CONFIG_LCD_APA102_YRES 16 #endif /* Check contrast selection */ @@ -98,8 +100,8 @@ /* Display Resolution */ -#define APA102_XRES CONFIG_APA102_XRES -#define APA102_YRES CONFIG_APA102_YRES +#define APA102_XRES CONFIG_LCD_APA102_XRES +#define APA102_YRES CONFIG_LCD_APA102_YRES /* Color depth and format */ @@ -318,7 +320,7 @@ static inline void apa102_configspi(FAR struct spi_dev_s *spi) SPI_SETMODE(spi, SPIDEV_MODE0); SPI_SETBITS(spi, 8); SPI_HWFEATURES(spi, 0); - SPI_SETFREQUENCY(spi, APA102_SPI_MAXFREQUENCY); + SPI_SETFREQUENCY(spi, CONFIG_LCD_APA102_FREQUENCY); } /****************************************************************************