Skip to main content
Associate III
July 12, 2024
Solved

Distribution-Package default-brightness-level modification with patching. stm32mp157f-dk2

  • July 12, 2024
  • 1 reply
  • 1878 views

@Erwan SZYMANSKI

Hello, I am having trouble with another topic . I was learning how to modify my distribution packet . I started with learning how to change backlight of my daughter board (ım using stm32mp157f-dk2). As I was trying to learn I make a patch to change default-brightness-level = <10>;

 

;

	panel_backlight: panel-backlight {
		compatible = "gpio-backlight";
		gpios = <&gpiod 13 GPIO_ACTIVE_LOW>;
		default-on;
		default-brightness-level = <1>;
		status = "okay";
	};

 

in the arch/arm/boot/dts/stm32mp157f-ev1.dts file  (https://github.com/STMicroelectronics/linux/blob/v6.1-stm32mp/arch/arm/boot/dts/stm32mp157f-ev1.dts ). With that I learned how to do patch and recipes.bb and .bbappend files but ı didn't do them applicable for my target design cause I couldn't find the target node about light. How can ı found it?  I looked at all the dts files with my file name but couldn't see it.

Best answer by Erwan SZYMANSKI

Hello @nesnes ,
The panel on the stm32mp157f-dk2 board has its own driver in the Linux kernel. You can find it in Linux kernel sources at drivers/gpu/drm/panel/panel-orisetech-otm8009a.c (https://github.com/STMicroelectronics/linux/blob/v6.1-stm32mp/drivers/gpu/drm/panel/panel-orisetech-otm8009a.c)

// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (C) STMicroelectronics SA 2017
 *
 * Authors: Philippe Cornu <philippe.cornu@st.com>
 * Yannick Fertre <yannick.fertre@st.com>
 */

#include <linux/backlight.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h>
#include <linux/pm_runtime.h>
#include <linux/regulator/consumer.h>

#include <video/mipi_display.h>

#include <drm/drm_mipi_dsi.h>
#include <drm/drm_modes.h>
#include <drm/drm_panel.h>

#define OTM8009A_BACKLIGHT_DEFAULT	240
#define OTM8009A_BACKLIGHT_MAX		255

At the beginning of the file, you can see the defined variable for the default backlight. If this is what you want to change, you can patch this driver with the value you want, then apply this modification to your Distribution Package to be taken into consideration by Yocto.

Kind regards,
Erwan.

 

1 reply

nesnesAuthor
Associate III
July 12, 2024

Can ı change my boards  stm32mp157f-dk2.dts  file (https://github.com/STMicroelectronics/linux/blob/v6.1-stm32mp/arch/arm/boot/dts/stm32mp157f-dk2.dts ) . by adding

 

panel_backlight: panel-backlight {
		compatible = "gpio-backlight";
		gpios = <&gpiod 13 GPIO_ACTIVE_LOW>;
		default-on;
		default-brightness-level = <1>;
		status = "okay"; 

 

from  stm32mp157f-ev1.dts file (https://github.com/STMicroelectronics/linux/blob/v6.1-stm32mp/arch/arm/boot/dts/stm32mp157f-ev1.dts ). Would this cause trouble?  Where should I add this node in stm32mp157f-dk2.dts file if it is not? 

 Like

// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-3-Clause)
/*
 * Copyright (C) STMicroelectronics 2022 - All Rights Reserved
 * Author: Alexandre Torgue <alexandre.torgue@foss.st.com> for STMicroelectronics.
 */

/dts-v1/;

#include "stm32mp157.dtsi"
#include "stm32mp15xf.dtsi"
#include "stm32mp15-pinctrl.dtsi"
#include "stm32mp15xxac-pinctrl.dtsi"
#include "stm32mp15xx-dkx.dtsi"
#include "stm32mp157c-dk2-scmi.dtsi"
#include <dt-bindings/rtc/rtc-stm32.h>

/ {
	model = "STMicroelectronics STM32MP157F-DK2 Discovery Board";
	compatible = "st,stm32mp157f-dk2", "st,stm32mp157";

	aliases {
		serial3 = &usart2;
	};

	chosen {
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;
		stdout-path = "serial0:115200n8";

		framebuffer {
			compatible = "simple-framebuffer";
			clocks = <&rcc LTDC_PX>, <&rcc DSI>, <&rcc DSI_PX>;
			status = "disabled";
		};
	};

	wifi_pwrseq: wifi-pwrseq {
		compatible = "mmc-pwrseq-simple";
		reset-gpios = <&gpioh 4 GPIO_ACTIVE_LOW>;
	};
 
 panel_backlight: panel-backlight {
		compatible = "gpio-backlight";
		gpios = <&gpiod 13 GPIO_ACTIVE_LOW>;
		default-on;
		default-brightness-level = <1>;
		status = "okay";
	};
};

&cryp1 {
	status = "okay";
};

&dsi {
	#address-cells = <1>;
	#size-cells = <0>;
	status = "okay";

	ports {
		#address-cells = <1>;
		#size-cells = <0>;

		port@0 {
			reg = <0>;
			dsi_in: endpoint {
				remote-endpoint = <&ltdc_ep1_out>;
			};
		};

		port@1 {
			reg = <1>;
			dsi_out: endpoint {
				remote-endpoint = <&panel_in>;
			};
		};
	};

	panel_otm8009a: panel-otm8009a@0 {
		compatible = "orisetech,otm8009a";
		reg = <0>;
		reset-gpios = <&gpioe 4 GPIO_ACTIVE_LOW>;
		power-supply = <&v3v3>;
		status = "okay";

		port {
			panel_in: endpoint {
				remote-endpoint = <&dsi_out>;
			};
		};
	};
};

&hdp {
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&hdp2_gpo &hdp2_pins_a>;
	pinctrl-1 = <&hdp2_sleep_pins_a>;
	status = "disabled";
};

&i2c1 {
	touchscreen@38 {
		compatible = "focaltech,ft6236";
		reg = <0x38>;
		interrupts = <2 2>;
		interrupt-parent = <&gpiof>;
		interrupt-controller;
		touchscreen-size-x = <480>;
		touchscreen-size-y = <800>;
		vcc-supply = <&v3v3>;
		iovcc-supply = <&v3v3>;
		panel = <&panel_otm8009a>;
		status = "okay";
	};
};

&ltdc {
	default-on;
	status = "okay";

	port {
		#address-cells = <1>;
		#size-cells = <0>;

		ltdc_ep1_out: endpoint@1 {
			reg = <1>;
			remote-endpoint = <&dsi_in>;
		};
	};
};

&rtc {
	st,lsco = <RTC_OUT2_RMP>;
	pinctrl-0 = <&rtc_out2_rmp_pins_a>;
	pinctrl-names = "default";
};

/* Wifi */
&sdmmc2 {
	pinctrl-names = "default", "opendrain", "sleep";
	pinctrl-0 = <&sdmmc2_b4_pins_a>;
	pinctrl-1 = <&sdmmc2_b4_od_pins_a>;
	pinctrl-2 = <&sdmmc2_b4_sleep_pins_a>;
	non-removable;
	cap-sdio-irq;
	st,neg-edge;
	bus-width = <4>;
	vmmc-supply = <&v3v3>;
	mmc-pwrseq = <&wifi_pwrseq>;
	#address-cells = <1>;
	#size-cells = <0>;
	status = "okay";

	brcmf: bcrmf@1 {
		reg = <1>;
		compatible = "brcm,bcm4329-fmac";
	};
};

/* Bluetooth */
&usart2 {
	pinctrl-names = "default", "sleep", "idle";
	pinctrl-0 = <&usart2_pins_c>;
	pinctrl-1 = <&usart2_sleep_pins_c>;
	pinctrl-2 = <&usart2_idle_pins_c>;
	uart-has-rtscts;
	status = "okay";

	bluetooth {
		shutdown-gpios = <&gpioz 6 GPIO_ACTIVE_HIGH>;
		compatible = "brcm,bcm43438-bt";
		max-speed = <3000000>;
		vbat-supply = <&v3v3>;
		vddio-supply = <&v3v3>;
	};
};

 

Erwan SZYMANSKI
Erwan SZYMANSKIBest answer
Technical Moderator
July 15, 2024

Hello @nesnes ,
The panel on the stm32mp157f-dk2 board has its own driver in the Linux kernel. You can find it in Linux kernel sources at drivers/gpu/drm/panel/panel-orisetech-otm8009a.c (https://github.com/STMicroelectronics/linux/blob/v6.1-stm32mp/drivers/gpu/drm/panel/panel-orisetech-otm8009a.c)

// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (C) STMicroelectronics SA 2017
 *
 * Authors: Philippe Cornu <philippe.cornu@st.com>
 * Yannick Fertre <yannick.fertre@st.com>
 */

#include <linux/backlight.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h>
#include <linux/pm_runtime.h>
#include <linux/regulator/consumer.h>

#include <video/mipi_display.h>

#include <drm/drm_mipi_dsi.h>
#include <drm/drm_modes.h>
#include <drm/drm_panel.h>

#define OTM8009A_BACKLIGHT_DEFAULT	240
#define OTM8009A_BACKLIGHT_MAX		255

At the beginning of the file, you can see the defined variable for the default backlight. If this is what you want to change, you can patch this driver with the value you want, then apply this modification to your Distribution Package to be taken into consideration by Yocto.

Kind regards,
Erwan.

 

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
nesnesAuthor
Associate III
July 16, 2024

Thank you @Erwan SZYMANSKI . I followed the same patching steps for panel-orisetech-otm8009a.c file

here my  .bbapend and patch  files in the directory of my own layer ~/STM32MPU-Ecosystem-v5.1.0/Distribution-Package/layers/meta-my-layer/recipes-kernel/linux/linux-stm32mp 

 

 

nesnes@nesnes-ABRA-A5-V19-2:~/STM32MPU-Ecosystem-v5.1.0/Distribution-Package/layers/meta-my-layer$ tree
.
├── conf
│ └── layer.conf
├── COPYING.MIT
├── README
├── recipes-example
│ └── example
│ └── example_0.1.bb
└── recipes-kernel
 └── linux
 ├── linux-stm32mp
 │ └── 0001-change-backlight-drivers-c.patch
 └── linux-stm32mp_%.bbappend
FILESEXTRAPATHS:prepend := "${THISDIR}/linux-stm32mp:" 
SRC_URI += "file://0001-change-backlight-drivers-c.patch" 
diff --git a/panel-orisetech-otm8009a.c.orig b/panel-orisetech-otm8009a.c
index e4140b4..11079ec 100644
--- a/drivers/gpu/drm/panel/panel-orisetech-otm8009a.c
+++ b/drivers/gpu/drm/panel/panel-orisetech-otm8009a.c
@@ -19,7 +19,7 @@
 #include <drm/drm_modes.h>
 #include <drm/drm_panel.h>
 
-#define OTM8009A_BACKLIGHT_DEFAULT	240
+#define OTM8009A_BACKLIGHT_DEFAULT	100
 #define OTM8009A_BACKLIGHT_MAX		255
 
 /* Manufacturer Command Set */

 

 After creating these files I enabled build environment and write "bitbake st-image-weston". I got some warnings but they are not relevant to my changes .

 

nesnes@nesnes-ABRA-A5-V19-2:~/STM32MPU-Ecosystem-v5.1.0/Distribution-Package/build-openstlinuxweston-stm32mp15-disco$ bitbake st-image-weston
NOTE: Started PRServer with DBfile: /home/nesnes/STM32MPU-Ecosystem-v5.1.0/Distribution-Package/build-openstlinuxweston-stm32mp15-disco/cache/prserv.sqlite3, Address: 127.0.0.1:42843, PID: 19306
Loading cache: 100% |########################################################################################################################################################################| Time: 0:00:00
Loaded 4598 entries from dependency cache.
NOTE: Resolving any missing task queue dependencies

Build Configuration:
BB_VERSION = "2.4.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "universal"
TARGET_SYS = "arm-ostl-linux-gnueabi"
MACHINE = "stm32mp15-disco"
DISTRO = "openstlinux-weston"
DISTRO_VERSION = "4.2.4-snapshot-20240716"
TUNE_FEATURES = "arm vfp cortexa7 neon vfpv4 thumb callconvention-hard"
TARGET_FPU = "hard"
DISTRO_CODENAME = "mickledore"
ACCEPT_EULA_stm32mp15-disco = "1"
GCCVERSION = "12.%"
PREFERRED_PROVIDER_virtual/kernel = "linux-stm32mp"
meta-python 
meta-oe 
meta-gnome 
meta-multimedia 
meta-networking 
meta-webserver = "HEAD:aa5e8edabbc414d8ec1b2ad63c8743c7baf99626"
meta-st-stm32mp = "HEAD:1f152e07019dc06fd331b4926ec7e76ceae3d259"
meta-st-openstlinux = "HEAD:2636960b2bead3d1cb294e378e2b06ef8997189e"
meta = "HEAD:23b5141400b2c676c806df3308f023f7c04e34e0"
meta-my-custo-layer 
meta-my-layer 
workspace = "<unknown>:<unknown>"

Initialising tasks: 100% |###################################################################################################################################################################| Time: 0:00:02
Sstate summary: Wanted 434 Local 365 Mirrors 0 Missed 69 Current 2799 (84% match, 97% complete)
Removing 7 stale sstate objects for arch cortexa7t2hf-neon-vfpv4: 100% |#####################################################################################################################| Time: 0:00:00
Removing 42 stale sstate objects for arch stm32mp15_disco: 100% |############################################################################################################################| Time: 0:00:00
NOTE: Executing Tasks
WARNING: perf-1.0-r9 do_package_qa: QA Issue: File /usr/bin/.debug/perf in package perf-dbg contains reference to TMPDIR
File /usr/lib/python3.11/site-packages/perf-0.1-py3.11-linux-x86_64.egg/.debug/perf.cpython-311-arm-linux-gnueabihf.so in package perf-dbg contains reference to TMPDIR [buildpaths]
WARNING: perf-1.0-r9 do_package_qa: QA Issue: File /usr/lib/python3.11/site-packages/perf-0.1-py3.11-linux-x86_64.egg/perf.cpython-311-arm-linux-gnueabihf.so in package perf-python contains reference to TMPDIR
File /usr/lib/python3.11/site-packages/perf-0.1-py3.11-linux-x86_64.egg/__pycache__/perf.cpython-311.pyc in package perf-python contains reference to TMPDIR
File /usr/lib/python3.11/site-packages/perf-0.1-py3.11-linux-x86_64.egg/EGG-INFO/SOURCES.txt in package perf-python contains reference to TMPDIR [buildpaths]
WARNING: perf-1.0-r9 do_package_qa: QA Issue: File /usr/bin/trace in package perf contains reference to TMPDIR
File /usr/bin/perf in package perf contains reference to TMPDIR [buildpaths]
WARNING: linux-stm32mp-6.1.82-stm32mp-r2-r0 do_package_qa: QA Issue: File /usr/src/debug/linux-stm32mp/6.1.82-stm32mp-r2-r0/drivers/tty/vt/consolemap_deftbl.c in package linux-stm32mp-src contains reference to TMPDIR
File /usr/src/debug/linux-stm32mp/6.1.82-stm32mp-r2-r0/lib/oid_registry_data.c in package linux-stm32mp-src contains reference to TMPDIR
File /usr/src/debug/linux-stm32mp/6.1.82-stm32mp-r2-r0/arch/arm/include/generated/asm/mach-types.h in package linux-stm32mp-src contains reference to TMPDIR [buildpaths]
NOTE: Tasks Summary: Attempted 7925 tasks of which 7739 didn't need to be rerun and all succeeded.
NOTE: Writing buildhistory
NOTE: Writing buildhistory took: 2 seconds

Summary: There were 4 WARNING messages.

 

Now I am gonna try flash the changes to the board , thanks a lot for your help