Olimex Support Forum

OLinuXino Android / Linux boards and System On Modules => A20 => Topic started by: tompeandris on February 02, 2022, 06:12:45 PM

Title: a20 lcd turn off
Post by: tompeandris on February 02, 2022, 06:12:45 PM
We are migrating to mainline and leaving the old 3.x kernel behind.
How can we turn off the lcd backlight (using the LVDS interface)?

This is what we used on old kernel:

```
#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <string.h>
#include <asm/types.h>

#include "sunxi_disp_ioctl.h"

int
main(int argc, char *argv[])
{
  int fd = open("/dev/disp", O_RDWR);
  int ret, tmp, width, height;

  if (fd == -1) {
    fprintf(stderr, "Error: Failed to open /dev/disp: %s\n",
      strerror(errno));
    return errno;
  }

  tmp = 0;
  ret = ioctl(fd, DISP_CMD_LCD_OFF, &tmp);
  if (ret != 0) {
    printf("Warning: LCD OFF failed\n");
  } else {
    printf("Warning: LCD OFF succeeded\n");
        }

  return 0;
}
```
Title: Re: a20 lcd turn off
Post by: LubOlimex on February 03, 2022, 09:01:40 AM
Maybe use directly devmem2 and registers? Check this post:

https://www.olimex.com/forum/index.php?topic=8572.msg32849#msg32849
Title: Re: a20 lcd turn off
Post by: tompeandris on February 11, 2022, 10:08:10 AM
Thanks for the answer, however i do not know where these numbers come from.

Can you please link some documentation where i can get answers?

I am guessing a kernel driver should exists which exports these functions to userspace?
like echo 1 > /dev/lvds_backlight
I would rather limit my executable, not to be able to write to physical memory directly.
Title: Re: a20 lcd turn off
Post by: JohnS on February 11, 2022, 04:03:30 PM
As you can check, things like 0x01C20824 are from the datasheet.

John
Title: Re: a20 lcd turn off
Post by: dlombardo on March 21, 2022, 11:41:58 PM
Maybe off topic as I have no experience with LVDS monitors.

For Olimex LCD I am using

Old 3.x kernel images

Backlight pwm control works with values 20 to 100 in file
/sys/class/pwm-sunxi/pwm0/duty_percent
Values below 20 do not work.

To completely turn off the backlight set GPIO to 0 in
/sys/class/gpio/gpio58_ph8/value
To turn on set GPIO to 1.

New 5.x Mainline images

Backlight can be set from 1 to 10 (100%) in file
/sys/class/backlight/backlight/brightness
Value 0 resets to 10.

To turn monitor off with GPIO set to 0 in
/sys/class/gpio/gpio232/value
To turn monitor on with GPIO set to 1.