This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM3354: How to control LCD backlight using command line

Part Number: AM3354

Tool/software: Linux

Hi,

In our AM3354 based custom designed board, I want to control the LCD back-light manually through command line, once the board is up. Currently, in .dts file the LCD back-light pin is assigned to a PWM pin. Please help me to achieve this.

We are using 7" New Heaven capacitive LCD display.

SDK version - Processor-sdk-03.03

Kernel version - 4.4.41

I have enabled PWM0. Below are the pin-mux details,

ecap0_pins_default: backlight_pins {
pinctrl-single,pins = <
0x164 0x0 /* eCAP0_in_PWM0_out.eCAP0_in_PWM0_out MODE0 */
>;
};

epwmss0: epwmss@48300000 {
status = "okay";

ecap0: ecap@48300100 {
status = "okay";
pinctrl-names = "default", "sleep";
pinctrl-0 = <&ecap0_pins_default>;
};
};
lcd_bl: backlight {
                compatible = "pwm-backlight";
                pwms = <&ecap0 0 50000 0>;
                brightness-levels = <0 51 53 56 62 75 101 152 255>;
                default-brightness-level = <8>;
        };


Please find my attached DTS file for full details.

Also I have tested with various SYSFS Attributes, but no change in LCD.

1016.am335x-evm.dts.tar.gz

  • Hi Ravikumar,

    As I see you are using a standard backlight device tree configuration with 9 fixed brightness levels but you can use array of brightness levels with constant step like this: brightness-levels = <0 32 64 96 128 160 192 224 255>;
    You can refer to Linux documentation for additional details at:
    www.kernel.org/.../pwm.txt
    You can control brightness level from your source code using simple PWM based backlight control driver functions from linux/drivers/video/backlight/pwm_bl.c
    I suggest you the linked below PWM user's guide If you would like to control backlight from the console:
    processors.wiki.ti.com/.../Linux_Core_PWM_User's_Guide

    BR
    Tsvetolin Shulev
  • Hi Tsvetolin Shulev,

    Thanks for the reply. I have changed the brightness-levels as per your last message. But when I execute the below command to change the brightness, there is no change on the LCD.

    #echo 0 > /sys/class/backlight/backlight/brightness
    #echo 8 > /sys/class/backlight/backlight/brightness


    And also, I have referred the above mentioned link for controlling backlight from the console, as per the wiki link, I tried export command it is giving me the below error,

    #echo 0 > /sys/class/pwm/pwmchip0/export
    #-sh: echo: write error: Device or resource busy