[PATCH v4 09/12] arm64: dts: qcom: sdm845-lg-common: Add camera flash

Paul Sajna posted 12 patches 2 months, 2 weeks ago
There is a newer version of this series
[PATCH v4 09/12] arm64: dts: qcom: sdm845-lg-common: Add camera flash
Posted by Paul Sajna 2 months, 2 weeks ago
Camera doesn't work yet (imx351), but we can use the flash as a flashlight.

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Paul Sajna <sajattack@postmarketos.org>
---
 arch/arm64/boot/dts/qcom/sdm845-lg-common.dtsi | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/sdm845-lg-common.dtsi b/arch/arm64/boot/dts/qcom/sdm845-lg-common.dtsi
index 93b9a0246510..fa664b5120d2 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-lg-common.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-lg-common.dtsi
@@ -494,6 +494,19 @@ &pm8998_resin {
 	status = "okay";
 };
 
+&pmi8998_flash {
+	status = "okay";
+
+	led-0 {
+		function = LED_FUNCTION_FLASH;
+		color = <LED_COLOR_ID_WHITE>;
+		led-sources = <1>;
+		led-max-microamp = <100000>;
+		flash-max-microamp = <500000>;
+		flash-max-timeout-us = <500000>;
+	};
+};
+
 &pmi8998_lpg {
 	status = "okay";
 

-- 
2.52.0
Re: [PATCH v4 09/12] arm64: dts: qcom: sdm845-lg-common: Add camera flash
Posted by Paul Sajna 2 months, 1 week ago
I did more testing on this, and the led only comes on if it's brightness is set to approx 150/255 or lower. In that case, should I set led-max-microamp to 60mA?



November 25, 2025 at 8:12 AM, "Paul Sajna" <sajattack@postmarketos.org mailto:sajattack@postmarketos.org?to=%22Paul%20Sajna%22%20%3Csajattack%40postmarketos.org%3E > wrote:


> 
> Camera doesn't work yet (imx351), but we can use the flash as a flashlight.
> 
> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
> Signed-off-by: Paul Sajna <sajattack@postmarketos.org>
> ---
>  arch/arm64/boot/dts/qcom/sdm845-lg-common.dtsi | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/qcom/sdm845-lg-common.dtsi b/arch/arm64/boot/dts/qcom/sdm845-lg-common.dtsi
> index 93b9a0246510..fa664b5120d2 100644
> --- a/arch/arm64/boot/dts/qcom/sdm845-lg-common.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sdm845-lg-common.dtsi
> @@ -494,6 +494,19 @@ &pm8998_resin {
>  status = "okay";
>  };
>  
> +&pmi8998_flash {
> + status = "okay";
> +
> + led-0 {
> + function = LED_FUNCTION_FLASH;
> + color = <LED_COLOR_ID_WHITE>;
> + led-sources = <1>;
> + led-max-microamp = <100000>;
> + flash-max-microamp = <500000>;
> + flash-max-timeout-us = <500000>;
> + };
> +};
> +
>  &pmi8998_lpg {
>  status = "okay";
>  
> 
> -- 
> 2.52.0
>
Re: [PATCH v4 09/12] arm64: dts: qcom: sdm845-lg-common: Add camera flash
Posted by Konrad Dybcio 2 months, 1 week ago
On 11/28/25 9:20 PM, Paul Sajna wrote:
> I did more testing on this, and the led only comes on if it's brightness is set to approx 150/255 or lower. In that case, should I set led-max-microamp to 60mA?

FWIW your downstream kernel sets up channels 0 and 1, here you only
enabled 1. Taking a look at a picture of the phone, I only see a single
LED on the back, so perhaps you're (over)driving a single power line?

I'm not a milion percent sure, but I would assume the current draw
*limiting* register applies to the sum of the current going through
the three channels because there's only a single instance of it.

Konrad
Re: [PATCH v4 09/12] arm64: dts: qcom: sdm845-lg-common: Add camera flash
Posted by Paul Sajna 2 months, 1 week ago
linux-postmarketos-qcom-sdm845-6.16.7_p20251203010632-r0.apk


December 1, 2025 at 11:42 AM, "Konrad Dybcio" <konrad.dybcio@oss.qualcomm.com mailto:konrad.dybcio@oss.qualcomm.com?to=%22Konrad%20Dybcio%22%20%3Ckonrad.dybcio%40oss.qualcomm.com%3E > wrote:


> 
> On 11/28/25 9:20 PM, Paul Sajna wrote:
> 
> > 
> > I did more testing on this, and the led only comes on if it's brightness is set to approx 150/255 or lower. In that case, should I set led-max-microamp to 60mA?
> > 
> FWIW your downstream kernel sets up channels 0 and 1, here you only
> enabled 1. Taking a look at a picture of the phone, I only see a single
> LED on the back, so perhaps you're (over)driving a single power line?
> 
> I'm not a milion percent sure, but I would assume the current draw
> *limiting* register applies to the sum of the current going through
> the three channels because there's only a single instance of it.
> 
> Konrad
>

I tried setting up both, but only the one that was mapped as `led-sources = <2>` seemed to have any effect. Also it would confuse userspace flashlight apps if there were two I think. So I'll push v5 with just the one that does anything.
Re: [PATCH v4 09/12] arm64: dts: qcom: sdm845-lg-common: Add camera flash
Posted by Konrad Dybcio 2 months, 1 week ago
On 12/3/25 10:27 AM, Paul Sajna wrote:
> linux-postmarketos-qcom-sdm845-6.16.7_p20251203010632-r0.apk
> 
> 
> December 1, 2025 at 11:42 AM, "Konrad Dybcio" <konrad.dybcio@oss.qualcomm.com mailto:konrad.dybcio@oss.qualcomm.com?to=%22Konrad%20Dybcio%22%20%3Ckonrad.dybcio%40oss.qualcomm.com%3E > wrote:
> 
> 
>>
>> On 11/28/25 9:20 PM, Paul Sajna wrote:
>>
>>>
>>> I did more testing on this, and the led only comes on if it's brightness is set to approx 150/255 or lower. In that case, should I set led-max-microamp to 60mA?
>>>
>> FWIW your downstream kernel sets up channels 0 and 1, here you only
>> enabled 1. Taking a look at a picture of the phone, I only see a single
>> LED on the back, so perhaps you're (over)driving a single power line?
>>
>> I'm not a milion percent sure, but I would assume the current draw
>> *limiting* register applies to the sum of the current going through
>> the three channels because there's only a single instance of it.
>>
>> Konrad
>>
> 
> I tried setting up both, but only the one that was mapped as `led-sources = <2>` seemed to have any effect. Also it would confuse userspace flashlight apps if there were two I think. So I'll push v5 with just the one that does anything.

led-sources is parsed into a bitmap and written into REG_MODULE_EN,
this doesn't translate into anything that's userspace-visible

That would instead be the case if you defined a pair of LEDs under
the device node (which is valid if there's two separate ones, such
as for some phones with a back and front LED flash)

Konrad
Re: [PATCH v4 09/12] arm64: dts: qcom: sdm845-lg-common: Add camera flash
Posted by Paul Sajna 2 months, 1 week ago
December 4, 2025 at 9:17 AM, "Konrad Dybcio" <konrad.dybcio@oss.qualcomm.com mailto:konrad.dybcio@oss.qualcomm.com?to=%22Konrad%20Dybcio%22%20%3Ckonrad.dybcio%40oss.qualcomm.com%3E > wrote:

> led-sources is parsed into a bitmap and written into REG_MODULE_EN,
> this doesn't translate into anything that's userspace-visible
> 
> That would instead be the case if you defined a pair of LEDs under
> the device node (which is valid if there's two separate ones, such
> as for some phones with a back and front LED flash)
> 
> Konrad
>

so it should be led-sources = <1 2> or something? Under a single node?
Re: [PATCH v4 09/12] arm64: dts: qcom: sdm845-lg-common: Add camera flash
Posted by Konrad Dybcio 2 months, 1 week ago
On 12/4/25 7:37 PM, Paul Sajna wrote:
> December 4, 2025 at 9:17 AM, "Konrad Dybcio" <konrad.dybcio@oss.qualcomm.com mailto:konrad.dybcio@oss.qualcomm.com?to=%22Konrad%20Dybcio%22%20%3Ckonrad.dybcio%40oss.qualcomm.com%3E > wrote:
> 
>> led-sources is parsed into a bitmap and written into REG_MODULE_EN,
>> this doesn't translate into anything that's userspace-visible
>>
>> That would instead be the case if you defined a pair of LEDs under
>> the device node (which is valid if there's two separate ones, such
>> as for some phones with a back and front LED flash)
>>
>> Konrad
>>
> 
> so it should be led-sources = <1 2> or something? Under a single node?

Eh of course what I said is wrong, it does indeed parse it, but in the
end it's a !!mask (if any enabled, enable the module)

but for your purposes, try "led-sources = <0>, <1>;" under a single node
that you have right now - the count also matters and it may just resolve
the presumably-overcurrent issue

Konrad