Jump to content

Blanking the HDMI output


bsccara

Recommended Posts

I'm running OpenElec on a NanoPI-M1 and one thing missing is having the screen blanked when the screensaver kicks in, allowing the monitor to power down. In Kodi there's no option to do it, unlike when running in other OS.

Probably someone is going to direct me at CEC but that does not work for me as I have a PC monitor connected to the board through a HDMI->VGA adaptor.

I've read in the sunxi docs that the '/sys/class/graphics/fb0/blank' sysfs entry should control blanking for the framebuffer, therefore blanking the HDMI output, but it either does not work that way or at all, as nothing happens.

On the RP world there is a command line utility that can enable/disable the video output, is there any way of doing it on an H3-based board ?

Link to comment
Share on other sites

Cracked it. Anyone interested can use the code below to do it:

#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <string.h>

#define DISP_BLANK 0x0C

int main(int argc, char *argv[])
{
        int fd_disp, ret;
        unsigned long buffer[4] = {0};

        if (strcasecmp(argv[1], "off") == 0) buffer[1] = 1;
        else if (strcasecmp(argv[1], "on") == 0) buffer[1] = 0;
        else return 0;

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

        if (ioctl(fd_disp, DISP_BLANK, buffer)) ret = errno;
        else ret = 0;

        close(fd_disp);

        return ret;
}

Compile this for ARM and use as '<program name> off' to blank and '<program name> on' to un-blank.

Still, it is strange why just writing to the sysfs entry doesn't work...

 

Link to comment
Share on other sites

I've read in the sunxi docs that the '/sys/class/graphics/fb0/blank' sysfs entry should control blanking for the framebuffer

This was done for A10/A20 but I guess it never arrived to H3.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines