Method and device for acquiring maximum brightness supported by screen
By caching the maximum screen brightness value in the user space, avoiding repeated access to the kernel space, the problem of obtaining the maximum screen brightness for too long under high load of the device is solved, and display efficiency and system stability are improved.
Patent Information
- Application Number
- CN202311862104.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-29
- Publication Date
- 2025-07-08
- Estimated Expiration
- 2043-12-29
AI Technical Summary
Under high load of the device, the execution time is too long when calling the screen maximum brightness interface to obtain, causing the thread to be unable to handle subsequent synthesis display tasks, which may lead to frame loss or jamming.
By detecting the screen status change command, we can determine whether the user space variable caches the maximum screen brightness value. If it has been cached, it will be obtained directly. Otherwise, it will be obtained from the kernel space and cached to the user space to avoid repeated access to the kernel space.
Reduces the time to obtain the maximum screen brightness and improves the system's robustness and display efficiency under high load conditions.
Smart Images

Figure CN120279820A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of display technology, and particularly to a method and device for obtaining the maximum brightness supported by a screen. Background Art
[0002] When the device is in a high-load situation, there will be a problem of long execution time when calling the maximum brightness acquisition interface of the screen to obtain the maximum brightness supported by the current screen. In this case, the thread cannot process subsequent composite display tasks, resulting in frame drops or even freezes. Summary of the Invention
[0003] In view of this, this application provides a method and device for obtaining the maximum brightness supported by a screen, which is used to reduce the duration of calling the interface to obtain the maximum brightness supported by the current screen.
[0004] In the first aspect of this application, a method for obtaining the maximum brightness supported by a screen is provided, which is applied to an electronic terminal device based on a Qualcomm chip platform. The method includes:
[0005] When a screen status change instruction is detected, determine whether the first variable in the user space is the initial value;
[0006] If not, obtain the value of the first variable to obtain the maximum screen brightness value;
[0007] If so, obtain the maximum screen brightness value from the kernel space and assign the maximum screen brightness value to the first variable.
[0008] In the embodiments of this application, when a screen status change instruction is detected, first determine whether the maximum screen brightness value is cached in the user space. If the maximum screen brightness value has been cached, it can be directly obtained without accessing the kernel space. If the maximum screen brightness value has not been cached, it means that this is the first time the electronic device requests the maximum screen brightness value, and it is necessary to access the kernel space to obtain the maximum screen brightness value. After obtaining the maximum screen brightness value, assign this value to the first variable in the user space to implement caching the maximum screen brightness value in the user space. In this way, when the maximum screen brightness value is requested again later, the value of the first variable can be directly used to avoid accessing the kernel space. The solution of this application only needs to access the kernel space once, reducing the duration of obtaining the maximum brightness supported by the current screen.
[0009] In a possible embodiment, the electronic terminal device includes a SurfaceFlinger module and a Composer module. When a screen status change instruction is detected, determining whether the first variable in the user space is the initial value includes:
[0010] After the Composer module receives the screen status change instruction sent by the SurfaceFlinger module through Binder, the Composer module calls the screen maximum brightness acquisition interface;
[0011] The Composer module determines whether the first variable in the user space is the initial value through the screen maximum brightness acquisition interface;
[0012] The obtaining the value of the first variable to obtain the screen maximum brightness value includes:
[0013] The Composer module obtains the value of the first variable to obtain the screen maximum brightness value.
[0014] In the embodiment of the present application, when a screen status change instruction is detected, the Composer module will call the screen maximum brightness acquisition interface, and determine whether the first variable in the user space is the initial value through the screen maximum brightness acquisition interface. When the first variable is not the initial value, the value of the first variable is obtained to obtain the screen maximum brightness value, avoiding accessing the kernel space and effectively reducing the duration of obtaining the screen maximum brightness value.
[0015] In a possible embodiment, the obtaining the screen maximum brightness value from the kernel space includes:
[0016] After the Composer module calls the screen maximum brightness acquisition interface, it obtains a pre-created file descriptor;
[0017] The Composer module accesses the kernel space through the file descriptor to obtain the screen maximum brightness value.
[0018] In the embodiment of the present application, when the first variable in the user space is the initial value, the Composer module will access the kernel space through the file descriptor to obtain the screen maximum brightness value, so that the screen maximum brightness acquisition interface gets a correct response.
[0019] In a possible embodiment, the kernel space includes a virtual file system, and the virtual file system includes the screen maximum brightness value. The accessing the kernel space through the file descriptor to obtain the screen maximum brightness value includes:
[0020] The Composer module accesses the virtual file system under the kernel space through the file descriptor to obtain the screen maximum brightness value.
[0021] In the embodiment of the present application, when the first variable in the user space is the initial value, the Composer module accesses the virtual file system through the file descriptor to obtain the screen maximum brightness value, so that the screen maximum brightness acquisition interface gets a correct response.
[0022] In a possible embodiment, the method further includes:
[0023] After obtaining the maximum screen brightness value, the Composer module releases a signal to recycle the file descriptor.
[0024] In the embodiment of the present application, recycling the file descriptor in a timely manner after obtaining the maximum screen brightness value can save system resources.
[0025] In a possible embodiment, the initial value of the first variable is a non-positive number.
[0026] In a possible embodiment, the method further includes:
[0027] The Composer module receives the preprocessed layer unit sent by the SurfaceFlinger module;
[0028] The Composer module changes the screen display state according to the layer unit and the maximum screen brightness value.
[0029] In the embodiment of the present application, through the collaborative action of the Composer module and the SurfaceFlinger module, the Composer module receives the layer unit sent by the SurfaceFlinger module, and changes the screen display state according to the layer unit and the maximum screen brightness value.
[0030] In a second aspect, the present application provides a device for obtaining the maximum supported screen brightness, which is applied to an electronic terminal device based on a Qualcomm chip platform. The device includes:
[0031] A judgment module, configured to judge whether the first variable in the user space is the initial value when detecting a screen state change instruction;
[0032] A first variable access module, configured to, if not, obtain the value of the first variable to obtain the maximum screen brightness value;
[0033] A kernel space access module, configured to, if so, obtain the maximum screen brightness value from the kernel space and assign the maximum screen brightness value to the first variable.
[0034] In a possible embodiment, the electronic terminal device includes a SurfaceFlinger module and a Composer module, and the judgment module includes:
[0035] A calling module, configured to, after the Composer module receives a screen status change instruction sent by the SurfaceFlinger module via Binder, the Composer module calls an interface for obtaining the maximum screen brightness;
[0036] A sub - judgment module, configured to determine whether a first variable in user space is an initial value by the Composer module through the interface for obtaining the maximum screen brightness;
[0037] The first variable access module is specifically configured to, the Composer module obtains the value of the first variable to obtain the maximum screen brightness value.
[0038] In a possible embodiment, the kernel space access module includes:
[0039] A file descriptor acquisition module, configured to, after the Composer module calls the interface for obtaining the maximum screen brightness, obtain a pre - created file descriptor;
[0040] A file descriptor access module, configured to, the Composer module accesses the kernel space through the file descriptor to obtain the maximum screen brightness value.
[0041] In a possible embodiment, the kernel space includes a virtual file system, the virtual file system includes the maximum screen brightness value, and the file descriptor access module is specifically configured to, the Composer module accesses the virtual file system under the kernel space through the file descriptor to obtain the maximum screen brightness value.
[0042] In a possible embodiment, the device further includes:
[0043] A file descriptor release module, configured to, after the Composer module obtains the maximum screen brightness value, release and recycle the signal of the file descriptor.
[0044] In a possible embodiment, the initial value of the first variable is a non - positive number.
[0045] In a possible embodiment, the device further includes:
[0046] A layer unit receiving module, configured to, the Composer module receives a pre - processed layer unit sent by the SurfaceFlinger module;
[0047] A display module, configured to, the Composer module changes the screen display state according to the layer unit and the maximum screen brightness value.
[0048] In a third aspect of the present application, an electronic device is provided, including:
[0049] One or more processors and a memory;
[0050] The memory is coupled to the one or more processors, and the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to cause the electronic device to execute the method steps described in the first aspect above.
[0051] In the fourth aspect of the present application, a computer-readable storage medium is provided, including a computer program, which when running on an electronic device, causes the electronic device to execute the method steps described in the first aspect above.
[0052] Adopting the technical solution provided by the embodiment of the present application, when a screen state change instruction is detected, it is judged whether the first variable in the user space is the initial value; if not, the value of the first variable is obtained to obtain the maximum screen brightness value; if so, the maximum screen brightness value is obtained from the kernel space, and the maximum screen brightness value is assigned to the first variable. It can be seen that after obtaining the maximum screen brightness value, the present application caches the maximum screen brightness value in the user space. When there is a request for obtaining the maximum screen brightness value later, it can be directly obtained from the user space. The solution of the present application only needs to access the kernel space once, reducing the time for obtaining the maximum brightness supported by the current screen. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required to be used in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained according to these drawings.
[0054] Figure 1 A schematic structural diagram of an electronic device;
[0055] Figure 2 A schematic diagram of a system architecture of an electronic device;
[0056] Figure 3 A schematic flowchart of a method for obtaining the maximum brightness supported by a screen provided by an embodiment of the present application;
[0057] Figure 4 Another schematic flowchart of a method for obtaining the maximum brightness supported by a screen provided by an embodiment of the present application;
[0058] Figure 5 A schematic flowchart of a process for obtaining the maximum screen brightness value;
[0059] Figure 6Another schematic diagram of the process for obtaining the maximum screen brightness value;
[0060] Figure 7 This is a schematic structural diagram of a device for obtaining the maximum brightness supported by the screen provided by an embodiment of the present application. Detailed implementation manners
[0061] For a better understanding of the technical solution of the present application, the embodiments of the present application will be described in detail below with reference to the accompanying drawings.
[0062] It should be clear that the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application without creative efforts belong to the scope of protection of the present application.
[0063] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the present application. The singular forms of "a", "the", and "said" used in the embodiments of the present application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise.
[0064] It should be understood that the term " / and / " used herein is only a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " herein generally represents an "or" relationship between the associated objects before and after.
[0065] See Figure 1 , Figure 1 The following is a schematic hardware structure diagram of an electronic device provided by an embodiment of the present application. The electronic device can be a mobile phone, a tablet computer, or other user terminals.
[0066] The electronic device includes a processor 110, a transceiver 120, and a display unit 170. Among them, the display unit 170 may include a display screen.
[0067] Optionally, the electronic device may further include a memory 130. The processor 110, the transceiver 120, and the memory 130 can communicate with each other through an internal connection path to transmit control and / or data signals. The memory 130 is used to store computer programs, and the processor 110 is used to call and run the computer programs from the memory 130.
[0068] Optionally, the electronic device may further include an antenna 140 for transmitting the wireless signals output by the transceiver 120.
[0069] The above-mentioned processor 110 and the memory 130 may be integrated into a processing device. More commonly, they are independent components of each other. The processor 110 is used to execute the program code stored in the memory 130 to implement the above functions. Specifically, in implementation, the memory 130 may also be integrated in the processor 110, or be independent of the processor 110.
[0070] In addition, in order to make the functions of the electronic device more complete, the electronic device may further include one or more of an input unit 160, an audio circuit 180, a camera 190, a sensor 101, etc. The audio circuit may further include a speaker 182, a microphone 184, etc.
[0071] Optionally, the above-mentioned electronic device may further include a power supply 150 for supplying power to various devices or circuits in the electronic device.
[0072] It can be understood that Figure 1 The operations and / or functions of the respective modules in the illustrated electronic device are respectively for implementing the corresponding processes in the following method embodiments. Specifically, reference may be made to the descriptions in the following method embodiments. To avoid repetition, detailed descriptions are appropriately omitted here.
[0073] It can be understood that Figure 1 The processor 110 in the illustrated electronic device may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units may be independent devices or integrated in one or more processors. A memory may also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory may save the instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to use the instruction or data again, it can directly call it from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0074] In some embodiments, the processor 110 may include one or more interfaces. The interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0075] It can be understood that the interface connection relationships between the modules illustrated in the embodiments of the present application are only illustrative descriptions and do not constitute a structural limitation on the electronic device. In other embodiments of the present application, the electronic device may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0076] It can be understood that Figure 1 The power supply 150 shown is used to supply power to the processor 110, the memory 130, the display unit 170, the camera 190, the input unit 160, the transceiver 120, etc. The antenna 140 is used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device can be used to cover a single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization rate of the antennas. For example, the antenna 140 can be multiplexed as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0077] The transceiver 120 can provide solutions for wireless communications applied to electronic devices, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite systems (GNSSs), frequency modulation (FM), near field communication (NFC), infrared (IR), etc. The transceiver 120 can be one or more devices integrating at least one communication processing module. The transceiver 120 receives electromagnetic waves via the antenna 140, performs frequency modulation and filtering processing on the electromagnetic wave signals, and sends the processed signals to the processor 110. The transceiver 120 can also receive the signals to be sent from the processor 110, perform frequency modulation and amplification on them, and convert them into electromagnetic waves through the antenna 140 for radiation.
[0078] In some embodiments, the antenna 140 of the electronic device is coupled to the transceiver 120 such that the electronic device can communicate with a network and other devices via wireless communication technologies. The wireless communication technologies may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technologies, etc. The GNSS may include global positioning system (GPS), global navigation satellite system (GLONASS), beidou navigation satellite system (BDS), quasi-zenith satellite system (QZSS), and / or satellite based augmentation systems (SBAS).
[0079] The electronic device implements the display function through the GPU, the display unit 170, and the application processor, etc. The GPU is a microprocessor for image processing, and is connected to the display unit 170 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs, which execute program instructions to generate or change display information.
[0080] The display unit 170 is used to display images, videos, etc. The display unit 170 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a MiniLED, a MicroLED, a Micro-OLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device may include one or N display units 170, where N is a positive integer greater than 1.
[0081] The electronic device can implement the shooting function through the ISP, the camera 190, the video codec, the GPU, the display unit 170, and the application processor, etc.
[0082] The ISP is used to process the data fed back by the camera 190. For example, when recording a video, the camera is turned on, and light passes through the lens and is transmitted to the camera's photosensitive element. The light signal is converted into an electrical signal, and the camera's photosensitive element transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye. The ISP can also optimize the noise, brightness, and skin color of the image through algorithms.
[0083] The ISP can also optimize parameters such as the exposure and color temperature of the shooting scene. In some embodiments, the ISP can be set in the camera 190. The camera 190 is used to capture static images or videos. An object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal and then transmits the electrical signal to the ISP to convert it into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in standard RGB, YUV, etc. formats. In some embodiments, the electronic device may include one or N cameras 190, where N is a positive integer greater than 1. The digital signal processor is used to process digital signals. In addition to processing digital image signals, it can also process other digital signals. For example, when the electronic device selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy, etc.
[0084] Video codecs are used to compress or decompress digital videos. An electronic device may support one or more video codecs. In this way, the electronic device can play or record videos in multiple encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
[0085] The NPU is a neural-network (NN) computing processor. By learning from the structure of biological neural networks, such as the transmission pattern between human brain neurons, it can quickly process input information and can also continuously self-learn. Through the NPU, applications such as intelligent cognition of electronic devices can be realized, such as image recognition, face recognition, speech recognition, text understanding, etc.
[0086] The memory 130 can be used to store computer-executable program code, and the executable program code includes instructions. The memory 130 may include a program storage area and a data storage area. Among them, the program storage area can store an operating system, application programs required for at least one function (such as a sound playback function, an image playback function, etc.). The data storage area can store data created during the use of the electronic device (such as audio data, phone book, etc.). In addition, the memory 130 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc. The processor 110 executes various functional applications and data processing of the electronic device by running the instructions stored in the memory 130 and / or the instructions stored in the memory provided in the processor.
[0087] The electronic device can implement audio functions through an audio circuit 180, a speaker 182, a microphone 184, and an application processor, etc. Such as music playback, recording, etc.
[0088] The audio circuit 180 is used to convert digital audio information into an analog audio signal for output, and is also used to convert an analog audio input into a digital audio signal. The audio circuit 180 can also be used to encode and decode audio signals. In some embodiments, the audio circuit 180 may be provided in the processor 110, or some functional modules of the audio circuit 180 may be provided in the processor 110.
[0089] The speaker 182, also known as a "loudspeaker", is used to convert an audio electrical signal into a sound signal. The electronic device can listen to music or hands-free calls through the speaker 182.
[0090] The microphone 184, also known as the "microphone" or "transmitter", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak close to the microphone 184 to input the sound signal into the microphone 184. The electronic device can be provided with at least one microphone 184. In some other embodiments, the electronic device can be provided with two microphones 184, which can not only collect sound signals but also implement a noise reduction function. In some other embodiments, the electronic device can also be provided with three, four or more microphones 184 to collect sound signals, reduce noise, identify the sound source, and implement functions such as directional recording.
[0091] The method for obtaining the maximum brightness supported by the screen in the embodiments of the present application can be implemented through Figure 2 the system architecture shown in, see Figure 2 , the system architecture of the electronic device includes a kernel part, a framework layer part, and an application layer part; the kernel part includes a driver layer and a real-time operating system, and the driver layer includes a GPU (graphics processing unit), a display driver (specifically an LCD driver in the figure), a TP driver (touch screen driver), buttons, etc.; the real-time operating system includes interrupt management, task scheduling, and MEM (memory management); the framework layer includes basic system capabilities, underlying software services, hardware service capabilities, etc.; the application layer includes system applications (such as calendars, cameras, contacts, browsers, etc.) and third-party applications (such as social applications and video applications provided by third parties). The method for obtaining the maximum brightness supported by the screen in the embodiments of the present application is performed in the kernel layer and the framework layer. When performing operations such as swiping and switching screens on the screen of the electronic device, it means that a new display screen needs to be synthesized, and at this time, the method of the present application will be triggered to execute. It can be understood that the display screen of the electronic device has a refresh rate parameter, and the screen display content needs to be refreshed every second. If the screen display content is set to be refreshed at a preset period, the method of the present application can also be triggered to execute. During the process of the screen turning from off to on, since a new picture needs to be displayed, the method in the present application will also be triggered to execute.
[0092] When the device is in a high-load situation, there will be a problem of a long execution time when calling the interface to obtain the maximum brightness supported by the current screen. In this case, the thread will not be able to process subsequent composite display tasks, resulting in frame drops or even freezes.
[0093] Currently, when the business layer and the framework layer of an electronic device obtain the maximum screen brightness value through the maximum screen brightness acquisition interface, they both need to access the virtual file system. This process not only involves data transfer from the kernel space to the user space, but also involves the allocation, mapping, and destruction of file descriptors. If the system load pressure is high at this time and the memory read and write are severely blocked, the thread will be in the Uninteruptable Sleep state all the time when the maximum screen brightness acquisition interface performs internal memory access related operations, seriously blocking the execution of the composite display task.
[0094] Based on this, the present application provides a method for obtaining the maximum supported screen brightness, which is applied to any electronic device equipped with a display screen, including but not limited to mobile phones, tablets, etc. The maximum screen brightness is related to the model of the device, but the maximum screen brightness of a certain device is determined and will not change. See Figure 3 , the method for obtaining the maximum supported screen brightness includes:
[0095] S201. When a screen status change instruction is detected, determine whether the first variable in the user space is the initial value.
[0096] In the embodiments of the present application, the electronic device mentioned can be an electronic terminal device based on a Qualcomm chip platform. The screen status change instruction can include changes to the screen display content and changes to the screen display brightness. It can be understood that when operations such as swiping are performed on the electronic device screen, a new display screen needs to be synthesized for display. In addition, the display screen of the electronic device has a specific refresh rate, that is, the number of times the screen is updated per second. The electronic device needs to update the screen display content at the predetermined refresh rate. When switching the screen frame rate, a new display screen needs to be synthesized for display. The user's swiping operation on the screen can trigger a screen status change instruction, and the operation of switching the screen frame rate can also trigger a screen status change instruction. Of course, it can also be set to trigger the screen status change instruction according to a preset period. In one example, it can be to trigger the screen status change instruction in real time for screen refresh. In addition, since the screen status change instruction can include changes to the screen display content and changes to the screen display brightness, a screen status change instruction will also be triggered during the process of the screen turning on and off. When the electronic terminal device detects a screen status change instruction, it needs to determine whether the first variable in the user space is the initial value. The initial value is any non-positive number. In one example, the initial value of the first variable can be set to -1. The first variable is a member variable of the corresponding object in the user space.
[0097] S202. If not, obtain the value of the first variable to obtain the maximum screen brightness value.
[0098] If the value of the first variable in the user space is not the initial value, obtain the value of the first variable to obtain the maximum screen brightness value.
[0099] S203. If so, obtain the maximum screen brightness value from the kernel space and assign the maximum screen brightness value to the first variable.
[0100] If the value of the first variable in the user space is the initial value, it is necessary to access the kernel space to obtain the maximum screen brightness value from the virtual file system in the kernel space. Specifically, the electronic device will obtain the maximum screen brightness value from the virtual file node / sys / class / backlight / panelx-backlight / max_brightness under the sysfs system. After obtaining the maximum screen brightness value, assign this value to the first variable.
[0101] In the embodiment of the present application, when a screen status change instruction is detected, first determine whether the maximum screen brightness value is cached in the user space. If the maximum screen brightness value is cached, it can be directly obtained without accessing the kernel space. If the maximum screen brightness value is not cached, it means that this is the first time the electronic terminal device requests the maximum screen brightness value, then it is necessary to access the kernel space to obtain the maximum screen brightness value, and after obtaining the maximum screen brightness value, assign this value to the first variable in the user space, so as to cache the maximum screen brightness value in the user space. In this way, when the maximum screen brightness value is requested again later, the value of the first variable can be directly used, avoiding accessing the kernel space. The solution of the present application only needs to access the kernel space once, reducing the time required to obtain the maximum brightness supported by the current screen.
[0102] In one example, the electronic terminal device includes a SurfaceFlinger module and a Composer module. When a screen status change instruction is detected, determine whether the first variable in the user space is the initial value. Refer to Figure 4 , including:
[0103] S301. After the Composer module receives the screen status change instruction sent by the SurfaceFlinger module through Binder, the Composer module calls the maximum screen brightness acquisition interface.
[0104] The SurfaceFlinger module can perform operations such as switching the screen frame rate to change the screen state. After the operation is performed, it notifies the Composer module through Binder, triggering the Composer module to execute and call the screen maximum brightness acquisition interface. Among them, Binder is an inter-process communication mechanism, and the Composer module is an important component in the Android operating system, responsible for managing the composite graphical interface. It displays various application images on the screen by synthesizing, scaling, and blending them, ensuring a smooth user interface experience. Layers corresponding to the status bar, wallpaper, navigation bar, and notification bar can all be objects of operation by the Composer module. When a screen state change instruction is detected, the Composer module calls the screen maximum brightness acquisition interface, and the screen maximum brightness acquisition interface can be getHWPanelMaxBrightness(). getHWPanelMaxBrightness() is a function that can obtain the screen maximum brightness value.
[0105] S302. The Composer module determines whether the first variable in the user space is the initial value through the screen maximum brightness acquisition interface.
[0106] After the Composer module calls the screen maximum brightness acquisition interface, it determines whether the first variable in the user space is the initial value through the screen maximum brightness acquisition interface.
[0107] The above-mentioned obtaining the value of the first variable to obtain the screen maximum brightness value includes:
[0108] S303. The Composer module obtains the value of the first variable to obtain the screen maximum brightness value.
[0109] When the screen maximum brightness acquisition interface determines that the first variable in the user space is not the initial value, the Composer module obtains the value of the first variable to obtain the screen maximum brightness value.
[0110] In the embodiment of the present application, when a screen state change instruction is detected, the Composer module will call the screen maximum brightness acquisition interface, and determine whether the first variable in the user space is the initial value through the screen maximum brightness acquisition interface. In the case where the first variable is not the initial value, the value of the first variable is obtained to obtain the screen maximum brightness value, avoiding accessing the kernel space and greatly reducing the time for obtaining the screen maximum brightness value.
[0111] In one example, the above-mentioned obtaining the screen maximum brightness value from the kernel space includes:
[0112] Step 1. After the Composer module calls the screen maximum brightness acquisition interface, it obtains a pre-created file descriptor;
[0113] Step 2: The Composer module accesses the kernel space through the file descriptor to obtain the maximum screen brightness value.
[0114] After the Composer module calls the maximum screen brightness acquisition interface, the system allocates a fd (file descriptor) for this system call to access the virtual file system in the kernel space.
[0115] In the embodiment of the present application, when the first variable in the user space is the initial value, the Composer module accesses the kernel space through the file descriptor to obtain the maximum screen brightness value, so that the maximum screen brightness acquisition interface gets a correct response.
[0116] In one example, the kernel space includes a virtual file system, the virtual file system includes the maximum screen brightness value, and the accessing the kernel space through the file descriptor to obtain the maximum screen brightness value includes:
[0117] The Composer module accesses the virtual file system under the kernel space through the file descriptor to obtain the maximum screen brightness value.
[0118] The virtual file system can be the sysfs system. The maximum screen brightness value is stored in the directory / sys / class / backlight / panelx-backlight / max_brightness of this system. The Composer module can access the / sys / class / backlight / panelx-backlight / max_brightness node through the file descriptor to obtain the maximum screen brightness value.
[0119] In the embodiment of the present application, when the first variable in the user space is the initial value, the Composer module accesses the virtual file system through the file descriptor to obtain the maximum screen brightness value, so that the maximum screen brightness acquisition interface gets a correct response.
[0120] In one example, after the Composer module obtains the maximum screen brightness value, it releases the signal for recycling the file descriptor.
[0121] After the Composer module obtains the maximum screen brightness value, it no longer needs the file descriptor. Therefore, it can release the signal for recycling the file descriptor. After the system receives this signal, it can recycle and destroy the file descriptor.
[0122] In the embodiment of the present application, recycling the file descriptor in time after obtaining the maximum screen brightness value can save system resources.
[0123] In one example, the above method further includes:
[0124] The Composer module receives the preprocessed layer units sent by the SurfaceFlinger module;
[0125] The Composer module changes the screen display state according to the layer units and the maximum screen brightness value.
[0126] The electronic terminal device includes a SurfaceFlinger module and a Composer module. The SurfaceFlinger module can perform operations such as changing the screen state like switching the frame rate, and inform the Composer module through Binder, triggering the Composer module to execute the call to the maximum screen brightness acquisition interface. Here, Binder is an inter-process communication mechanism. The SurfaceFlinger is a module responsible for preprocessing the display layer information and sending it to the Composer module for composition. The SurfaceFlinger module sends the filtered layer units (such as the status bar, navigation bar, wallpaper, launcher icon layer) to the Composer module. The Composer module can adjust the screen display content or screen display brightness according to the layer units and the maximum screen brightness value to achieve a change in the screen display state.
[0127] In the embodiment of the present application, through the cooperation of the Composer module and the SurfaceFlinger module, the Composer module performs image composition according to the layer units and the maximum screen brightness value sent by the SurfaceFlinger module, changing the screen display state.
[0128] In one example, the method for obtaining the maximum screen brightness value in the related art is as Figure 5As shown, after calling the screen maximum brightness acquisition interface getHWPanelMaxBrightness, the virtual file node / sys / class / backlight / panelx-backlight / max_brightness is opened, the screen maximum brightness value is read and used, and finally the virtual file node / sys / class / backlight / panelx-backlight / max_brightness is closed. If the screen maximum brightness acquisition interface is called again, the above steps are repeated. It can be seen that in the related art, when obtaining the screen maximum brightness value, it is necessary to access the virtual file system. If the system load pressure is relatively high at this time, it will cause serious memory read and write blockage, and the thread is always in the Uninteruptable Sleep state when accessing the virtual file system, seriously blocking the execution of the composite display task.
[0129] In one example, the method for obtaining the screen maximum brightness value in the embodiment of the present application is as Figure 6 As shown, after calling the screen maximum brightness acquisition interface getHWPanelMaxBrightness, first determine whether the variable used for caching is the initial value. If it is not the initial value, directly use the cached maximum brightness value; if it is the initial value, then access the virtual file system, open the virtual file node / sys / class / backlight / panelx-backlight / max_brightness, read and use the screen maximum brightness value, assign the screen maximum brightness value to the cache variable, and finally close the virtual file node / sys / class / backlight / panelx-backlight / max_brightness. If the screen maximum brightness acquisition interface is called again, since the judgment result of whether the cache variable is the initial value is negative, the cached maximum brightness value can be directly used without accessing the virtual file system. The embodiment of the present application caches the screen maximum brightness value obtained from the virtual file node, avoiding the performance instability problem caused by excessive access to the virtual file system. The embodiment of the present application only needs to access the virtual file system once, caches the screen maximum brightness value into the user space after accessing the virtual file system. When there is a subsequent need to obtain the screen maximum brightness value, it can be directly obtained from the cache, greatly reducing the time for obtaining the screen maximum brightness value, significantly improving the running efficiency of the screen maximum brightness acquisition interface, and effectively improving the robustness of the display subsystem under high system load.
[0130] In a second aspect, the present application provides a device for obtaining the maximum brightness supported by the screen, which is applied to an electronic terminal device based on a Qualcomm chip platform. Refer to Figure 7 , the device includes:
[0131] A judgment module 401, configured to determine whether a first variable in the user space is an initial value when a screen status change instruction is detected;
[0132] A first variable access module 402, configured to, if not, obtain the value of the first variable to obtain the maximum screen brightness value;
[0133] A kernel space access module 403, configured to, if so, obtain the maximum screen brightness value from the kernel space and assign the maximum screen brightness value to the first variable.
[0134] In a possible embodiment, the electronic terminal device includes a SurfaceFlinger module and a Composer module, and the judgment module includes:
[0135] An invocation module, configured to, after the Composer module receives a screen status change instruction sent by the SurfaceFlinger module through Binder, the Composer module invokes a maximum screen brightness acquisition interface;
[0136] A sub-judgment module, configured to determine whether a first variable in the user space is an initial value by the Composer module through the maximum screen brightness acquisition interface;
[0137] The first variable access module is specifically configured to obtain the value of the first variable by the Composer module to obtain the maximum screen brightness value.
[0138] In a possible embodiment, the kernel space access module includes:
[0139] A file descriptor acquisition module, configured to obtain a pre-created file descriptor after the Composer module invokes the maximum screen brightness acquisition interface;
[0140] A file descriptor access module, configured to access the kernel space by the Composer module through the file descriptor to obtain the maximum screen brightness value.
[0141] In a possible embodiment, the kernel space includes a virtual file system, the virtual file system includes a maximum screen brightness value, and the file descriptor access module is specifically configured to access the virtual file system under the kernel space by the Composer module through the file descriptor to obtain the maximum screen brightness value.
[0142] In a possible embodiment, the device further includes:
[0143] A file descriptor release module, configured to release and recycle the signal of the file descriptor after the Composer module obtains the maximum screen brightness value.
[0144] In a possible embodiment, the initial value of the first variable is a non-positive number.
[0145] In a possible embodiment, the device further includes:
[0146] A layer unit receiving module, configured to receive, by the Composer module, the preprocessed layer units sent by the SurfaceFlinger module;
[0147] A display module, configured to change the screen display state by the Composer module according to the layer units and the maximum screen brightness value.
[0148] In a third aspect of the present application, an electronic device is provided, including:
[0149] One or more processors and a memory;
[0150] The memory is coupled to the one or more processors. The memory is used to store computer program code, and the computer program code includes computer instructions. The one or more processors call the computer instructions to cause the electronic device to execute the steps of any of the above methods for obtaining the maximum screen brightness supported. The structure of the electronic device can be referred to Figure 1 , which will not be elaborated here.
[0151] In a fourth aspect of the present application, a computer-readable storage medium is provided, including a computer program, which, when running on an electronic device, causes the electronic device to execute the steps of any of the above methods for obtaining the maximum screen brightness supported.
[0152] The present application also provides a computer program product, which, when running on a computer, causes the computer to execute the steps of the method for obtaining the maximum screen brightness supported in any of the above embodiments.
[0153] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more integrated available media. The available medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a solid state disk (SSD), etc.
[0154] Each embodiment in this specification is described in a related manner. For the same or similar parts among the embodiments, reference can be made to each other. The key point of each embodiment is to illustrate the differences from other embodiments. In particular, for the device and electronic device embodiments, since they are basically similar to the method embodiments, the description is relatively simple. For the relevant parts, reference can be made to the partial description of the method embodiments.
[0155] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.
Claims
1. A method for obtaining the maximum brightness supported by a screen, characterized in that, Applied to an electronic terminal device based on a Qualcomm chip platform, the method includes: When a screen state change instruction is detected, determine whether the first variable in the user space is the initial value; If not, obtain the value of the first variable to obtain the maximum screen brightness value; If so, obtain the maximum screen brightness value from the kernel space and assign the maximum screen brightness value to the first variable.
2. The method according to claim 1, characterized in that The electronic terminal device includes a SurfaceFlinger module and a Composer module. When a screen state change instruction is detected, determining whether the first variable in the user space is the initial value includes: After the Composer module receives the screen state change instruction sent by the SurfaceFlinger module through Binder, the Composer module calls the maximum screen brightness acquisition interface; The Composer module determines whether the first variable in the user space is the initial value through the maximum screen brightness acquisition interface; Obtaining the value of the first variable to obtain the maximum screen brightness value includes: The Composer module obtains the value of the first variable to obtain the maximum screen brightness value.
3. The method according to claim 2, wherein Obtaining the maximum screen brightness value from the kernel space includes: After the Composer module calls the maximum screen brightness acquisition interface, obtain a pre-created file descriptor; The Composer module accesses the kernel space through the file descriptor to obtain the maximum screen brightness value.
4. The method according to claim 3, characterized in that, The kernel space includes a virtual file system, and the virtual file system includes the maximum screen brightness value. Accessing the kernel space through the file descriptor to obtain the maximum screen brightness value includes: The Composer module accesses the virtual file system under the kernel space through the file descriptor to obtain the maximum screen brightness value.
5. The method according to claim 4, wherein The method further includes: After the Composer module obtains the maximum screen brightness value, release the signal for recycling the file descriptor.
6. The method according to claim 1, characterized in that, The initial value of the first variable is a non-positive number.
7. The method according to claim 4, wherein The method further includes: The Composer module receives the preprocessed layer unit sent by the SurfaceFlinger module; The Composer module changes the screen display state according to the layer unit and the maximum screen brightness value.
8. A device for obtaining the maximum brightness supported by a screen, characterized in that, Applied to an electronic terminal device based on a Qualcomm chip platform, the device includes: A judgment module, configured to determine whether the first variable in the user space is the initial value when a screen state change instruction is detected; A first variable access module, configured to, if not, obtain the value of the first variable to obtain the maximum screen brightness value; A kernel space access module, configured to, if so, obtain the maximum screen brightness value from the kernel space and assign the maximum screen brightness value to the first variable.
9. An electronic device, characterized in that, Includes: One or more processors and memories; The memory is coupled to the one or more processors, and the memory is used to store computer program code, which includes computer instructions. The one or more processors call the computer instructions to cause the electronic device to execute the method for obtaining the maximum brightness supported by the screen according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, It includes a computer program which, when running on an electronic device, causes the electronic device to execute the method for obtaining the maximum brightness supported by the screen according to any one of claims 1 to 7.
Citation Information
Patent Citations
Hardware resource access method and hardware resource access device
CN104424034A
Method and apparatus for processing brightness in multi-system mobile terminal
CN105657112A
Screen brightness adjusting method for electronic terminal and device
CN106297734A
Loading method and device of FPGA program data
CN108132811A
Screen brightness adjusting method and electronic equipment
CN114999421A