Disable the output of a display in Linux.

Source: Internet
Author: User

Today, I received a task to enable and disable the display.

Let's take a look at the following ideas:

1. requirement: the terminal screen must be switched off, but the system is still running. You can use the remote control to wake up.

2. Direction:

2.1. Cut off the power of the display and enter the power-saving mode

In fact, this includes two aspects:

1) use hardware to cut off the power of the monitor.

2) software disconnection because remote control is needed to wake up later

2.2. Disable the output function of the video card

Let's talk about the road to implementation:

At first, I thought that my desktop computer could not just switch the power supply on the display by one click. Then, is there any corresponding hardware interface on the terminal, because I am a hardware engineer, I like what I do first. I think there are no interfaces on the hardware. So I asked the boss, does the hardware have interfaces? The result is as expected: No.

Well, if you don't have one, you can use another method. As a result, Google and Baidu searched for keywords such as "Linux switch screen" and found some materials. Although this function has little effect on me, however, it is good to understand the entire Linux environment. The above describes several methods for suspending the system, allowing it to wait, sleep, or sleep.

First, let's talk about the standby method.

# Cd/sys/power/

# Cat state

Displays the supported standby mode: Mem Disk

# Echo "mem">./State

The screen is black. Check the status of the terminal. The system is no longer working. Only the power light is on. This is powering the memory.

To start the system, you only need to press the power key on the motherboard.

However, it is a pity that our terminal is very unstable when using this method. It is impossible to predict when the system will crash and restart.

This kind of tragedy often happens when the boss comes to see the results. Therefore, the boss said that what he wants is not such an effect. The entire system does not need to be stopped. Because of the special nature of this product, power-on is required directly after the instance is started. Power-off is not required for no special reason, so the power-on key is not frequently used in a sense. The most important thing is that we need to be able to wake up with remote control, but the system applications are not running in the STANDBY state, remote control signals must be received by applications. Therefore, this method is of little help to our needs (so demand is the boss ).

That is to say, hardware disconnection and software disconnection are useless (at least at that time)

Well, there is only one way to turn off the output of the video card. When they assigned me a task, they asked me to use the interface in the ATI Video Card SDK, let's see what they said.

In fact, I am very ashamed, because I am not very familiar with the SDK, so I have to patiently read the documentation, and then read the sample, go to the web version and familiarize yourself with every function interface, struct, and constant. In fact, it is a translation plus understanding. Line. It seems that there are two interfaces. One is to enable or disable the specified adapter, that is, int adl_adapter_active_setprefer (INT iadapterindex, int istatus, int inumprefertarget, adldisplaytarget
* Lpprefertarget, int * lpnewlyactivate), and dynamically enable GPU display int adl_displayenable_set (INT iadapterindex, int * lpdisplayindexlist, int idisplaylistsize, int bpersistonly ).

After carefully studying the parameters and platform, we found that the randroid version is less than 1.2 and the version is 1.3, which does not support Linux. In fact, I am not very sure, because after all, it is not implemented ......

Later, I don't know what to do. I think of the interface that I requested last time, which is also used to implement the screen switch. I thought about it. Maybe I can refer to it.

The command is actually very simple, xset

Screen off: $ xset dpms force off

Open Screen: $ xset dpms force on

However, it takes a short time to switch the screen. You can press the keyboard or mouse to open the screen. For a long time, since X can turn off the screen, there must be an interface, but where is this interface? If you use this command, you need to block a series of events on the mouse and keyboard. This is not a very easy task, and it may become messy.

I thought about it. In fact, what we say is that the video card does not output anything. Is it a little too demanding? The screen switch should be made on the power supply and cut off the power supply. The video card is not output. If the video card is still output, but the screen is not received, can it? Disable the screen if you force the screen to not receive anything. (Screen, that is, display devices, such as LVDS, VGA, dfp1, crt1, and DVI)

So I went to Google's "Linux off-screen" and found a good post,

Http://www.aiview.com/linux/:

VGA output can be controlled using the xrandroid command, this package should have been followed by the xorg-x11 installed.

The terminal supports the following video interfaces through the xrandroid command output:

  • Dfp1
  • LVDS
  • Crt1

Note: in many cases, VGA interfaces can be used for external display devices, projectors, and other VGA devices.

LVDS is a built-in LCD interface.

Xrandroid

The xrandroid command without parameters lists the video interface names and device connections supported by the system.

Screen 0: Minimum 320x200, current 1080x1920, maximum 1920x1920
LVDS connected 1080x1920 + 0 + 0 right (normal left inverted right X axis Y axis) 930mm x 523mm
1920x1080 60.0 * +
1680x1050 60.0
1400x1050 60.0
1600x900 60.0
1280x1024 60.0
1440x900 60.0
1280x960 60.0
1280x768 60.0
1280x720 60.0
1024x768 60.0
800x600 60.0
640x480 60.0
Dfp1 disconnected (normal left inverted right X axis Y axis)
Crt1 disconnected (normal left inverted right X axis Y axis)

Run the following command to send the video output to an interface device.

 $ xrandr --output DFP1 --auto

Run the following command to disable the video output of an interface device.

$ Xrandroid -- output LVDS -- off after trying, the system's display screen has three LVDS dfp1 crt1 and finally understands why to obtain the information of the system's display in the program, three screens and two display adapters are returned. LVDS is an LCD screen that has been used by the terminal. dfp1 is an external HDMI screen interface, as for this crt1, it is estimated that the above post only describes hardware integration. It can only be said that Linux is profound and profound, and learning and exploration are not just one day away. Great x

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.