cancel
Showing results for 
Search instead for 
Did you mean: 

how to switch off lcd by using drm ?

Jzhua
Associate III

i‘m not using qt or other 3rd gui framweork, no weston, no x, just direct use drm api,i need switch off lcd after some time is not operated,i google it a while,It looks i need a complete desktop environment to do that,so i want know is any way to do that easily.

now i can simply switch off backlight to look like the lcd is off

4 REPLIES 4
Olivier GALLIEN
ST Employee

Hi @Jzhua​ ,

I understand playing with backlight is a valid method but maybe not achieving best result in term of power consumption. ( https://wiki.st.com/stm32mpu/wiki/How_to_modify_the_panel_backlight )

I escalate your point to some expert. Keep you posted.

Olivier

Olivier GALLIEN
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.

Okay, I will continue to learn about the content

Olivier GALLIEN
ST Employee

Hi @Jzhua​ ,

I found some help from expert :

We have implemented “atomic�? drm/kms drivers so dpms is managed thanks to the CRTC “active�? drm property (prop_active in the uapi, “ACTIVE�? with the libdrm).

In the modetest source code, you can find functions calls setting or resetting the “active�? value (https://github.com/grate-driver/libdrm/blob/master/tests/modetest/modetest.c#L1315

When the CRTC is not anymore in the active state, the panel disable() then unprepare() functions are called (see https://cgit.freedesktop.org/drm/drm-misc/tree/drivers/gpu/drm/panel/panel-orisetech-otm8009a.c#n246).

The “modetest�? command will show the CRTC “ACTIVE�? state current value.

More documentations :

https://elixir.bootlin.com/linux/v5.10.61/source/include/drm/drm_mode_config.h#L659

https://elixir.bootlin.com/linux/v5.10.61/source/drivers/gpu/drm/drm_crtc.c#L212

Hope it help

Olivier

Olivier GALLIEN
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.

i found a easy way to do that

void drm_blank(int blank)
{
	if(lcd_drm && lcd_drm->main_monitor_crtc){
		if(blank){
			// disbale crtc
			drmModeSetCrtc(lcd_drm->fd, lcd_drm->main_monitor_crtc->crtc_id,
					0, // fb_id
					0, 0,  // x,y
					NULL,  // connectors
					0,     // connector_count
					NULL); // mode
		}else{
			struct modeset_buf* buf = &lcd_drm->dev->bufs[lcd_drm->dev->front_buf];
			// enable crtc
			drmModeSetCrtc(lcd_drm->fd, lcd_drm->main_monitor_crtc->crtc_id,
					buf->fb,
					0, 0,  // x,y
					&lcd_drm->dev->conn,
					1,  // connector_count
					&lcd_drm->dev->mode);
		}
	}
}