Data processing method, electronic device and readable storage medium
By using direct memory access DMA channels in electronic devices to copy image frame data in parallel, the problem of too long data copy time is solved, the display frame rate and system efficiency are improved, and a smoother image refresh effect is achieved.
Patent Information
- Application Number
- CN202310864198.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-12
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2043-07-12
AI Technical Summary
Existing electronic equipment has the problem of too long data copying time during the refresh process of image frame data, resulting in a low display frame rate and unable to meet users' high requirements for picture smoothness.
The direct memory access DMA channel is used for data copying, and the image frame data is copied in parallel through two DMA channels, thereby shortening the data copying time. During the copying process, the DMA channel interface is called multiple times and the DMA channel resources are released to improve efficiency.
It significantly reduces data copy time, increases the display frame rate of image frame data, avoids excessive CPU load, and improves system efficiency and reliability.
Smart Images

Figure CN117094876B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of terminal technology, and in particular to a data processing method, an electronic device, and a readable storage medium. Background Art
[0002] With the rapid development of electronic devices, users have higher and higher performance requirements for various functions of electronic devices. For example, in the process of refreshing image frame data, the picture usually needs to be smooth, that is, there is no lag. At present, some electronic devices provide dual frame buffer technology, in which one frame buffer is used for rendering image frame data, and the other frame buffer is used for sending image frame data, that is, providing image frame data to be displayed to the display screen.
[0003] In the process of using dual frame buffers to render and display image frame data, after rendering each frame of image frame data in one frame buffer, it is necessary to copy this frame of image frame data to another frame buffer to be sent to display. Since copying takes a certain amount of time, how to improve the display frame rate of image frame data becomes an urgent problem to be solved. Summary of the invention
[0004] The present application provides a data processing method, an electronic device and a readable storage medium, which can solve the problem of how to improve the display frame rate of image frame data in the related art. The technical solution is as follows:
[0005] In a first aspect, a data processing method is provided, which is applied to an electronic device, and the method includes:
[0006] In the case of receiving a first trigger message, the first thread copies the first image frame data in the first frame buffer to the second frame buffer through a direct memory access DMA channel, wherein the first trigger message is triggered after the display screen of the electronic device completes display of a previous frame of the second image frame data;
[0007] The first thread sends a rendering instruction to the second thread to trigger the second thread to render a next frame of third image frame data to the first frame buffer;
[0008] In case of receiving the second trigger message, the first thread sends the first image frame data in the second frame buffer to the display screen so as to display the first image frame data through the display screen, and the second trigger message is triggered periodically.
[0009] As an example of the present application, data copying through a DMA channel can increase the data copying speed, reduce the data copying time, and increase the display frame rate of the image frame data.
[0010] As an example of the present application, in the case of receiving the first trigger message, the first thread copies the first image frame data in the first frame buffer to the second frame buffer through the direct memory access DMA channel, including:
[0011] When receiving the first trigger message, the first thread copies the first image frame data from the first frame buffer to the second frame buffer through the first DMA channel and the second DMA channel.
[0012] As an example of the present application, copying data through two DMA channels can shorten the data copying time to 1.7 milliseconds, thus reducing the data copying time, thereby improving the display frame rate of the image frame data. In addition, since the DMA device is managed by the CPU, the CPU time will still be consumed during the operation of the DMA device. If more DMA channels are used for data copying, more CPU time will be consumed. Therefore, in the embodiment of the present application, copying data through two DMA channels can ensure that the data copying time is shortened while avoiding as much time overhead as possible for the CPU.
[0013] As an example of the present application, in the case of receiving the first trigger message, the first thread copies the first image frame data from the first frame buffer to the second frame buffer through the first DMA channel and the second DMA channel, including:
[0014] In case of receiving the first trigger message, the first thread calls a DMA channel allocation interface to request allocation of the first DMA channel and the second DMA channel;
[0015] The first thread calls an initialization interface to initialize the first DMA channel and the second DMA channel respectively;
[0016] The first thread calls a data copy interface to copy the first image frame data from the first frame buffer to the second frame buffer through the first DMA channel and the second DMA channel.
[0017] In this way, the first DMA channel and the second DMA channel are configured and initialized by calling different interface requests, and then the first DMA channel and the second DMA channel can be used to copy data.
[0018] As an example of the present application, the amount of data in the first frame buffer is greater than the sum of the maximum amount of data that can be copied by the first DMA channel and the second DMA channel at one time;
[0019] The first thread calls a data copy interface to copy the first image frame data from the first frame buffer to the second frame buffer through the first DMA channel and the second DMA channel, including:
[0020] The first thread calls the data copy interface multiple times to copy the first image frame data through the first DMA channel and the second DMA channel multiple times;
[0021] Each time the first thread calls the data copy interface, it determines whether to copy all the first image frame data in the first frame buffer to the second frame buffer;
[0022] When all the first image frame data in the first frame buffer are not copied to the second frame buffer, the first thread continues to call the data copy interface to continue copying the first image frame data through the first DMA channel and the second DMA channel until all the first image frame data in the first frame buffer are copied to the second frame buffer.
[0023] In this way, during the data copying process, the first DMA channel and the second DMA channel are called multiple times to perform cyclic copying through the first DMA channel and the second DMA channel, thereby completing the copying of the first image frame data.
[0024] As an example of the present application, the first thread calls the data copy interface multiple times to copy the first image frame data through the first DMA channel and the second DMA channel multiple times, including:
[0025] The first thread determines, during each copying of the first image frame data through the first DMA channel and the second DMA channel, a first data copy parameter and a second data copy parameter related to the data to be copied this time, wherein the first data copy parameter is used for the first DMA channel to copy data, and the second data copy parameter is used for the second DMA channel to copy data;
[0026] The first thread sends the first data copy parameter and the second data copy parameter to the data copy interface, so that the first DMA channel copies the first image frame data based on the first data copy parameter, and the second DMA channel copies the first image frame data based on the second data copy parameter.
[0027] In this way, the first thread configures the relevant parameters of the data that needs to be copied each time (that is, the first data copy parameter and the second data copy parameter) to the first DMA channel and the second DMA channel through the data copy interface, that is, the control logic is executed by the first thread, so that the first DMA channel and the second DMA channel only need to copy data based on the relevant parameters, thereby reducing the operation logic of the first DMA channel and the second DMA channel.
[0028] As an example of the present application, in the case of receiving the first trigger message, after the first thread copies the first image frame data from the first frame buffer to the second frame buffer through the first DMA channel and the second DMA channel, it also includes:
[0029] The first thread releases the first DMA channel and the second DMA channel.
[0030] In this way, after the first image frame data is copied from the first frame buffer through the first DMA channel and the second DMA channel, the first DMA channel and the second DMA channel are released to avoid continuing to occupy resources when the first DMA channel and the second DMA channel are not in use, thereby avoiding resource waste.
[0031] As an example of the present application, in the case of receiving the first trigger message, before the first thread copies the first image frame data in the first frame buffer to the second frame buffer through the direct memory access DMA channel, it also includes:
[0032] After the display screen completes displaying the second image frame data, the display screen calls the first interrupt interface and reports a first interrupt signal to the first interrupt interface;
[0033] After receiving the first interrupt signal, the first interrupt interface sends the first trigger message to the first thread.
[0034] After the display screen completes displaying the second image frame data, the display screen triggers the first thread to copy data through the first interrupt signal, thereby improving the system efficiency of the electronic device and maintaining reliable and normal operation of the system.
[0035] As an example of the present application, the second image frame data is the first image frame data displayed after the screen of the electronic device is turned on;
[0036] In the case of receiving the first trigger message, before the first thread copies the first image frame data in the first frame buffer to the second frame buffer through the direct memory access DMA channel, the method further includes:
[0037] In response to the screen-on operation, the display screen enters a screen-on state;
[0038] The display screen periodically reports a second interrupt signal to the second interrupt interface;
[0039] The second interrupt interface sends a third trigger message to the second thread when it is determined that the second interrupt signal is received for the first time, and sends the second trigger message to the first thread when it is determined that the second interrupt signal is not received for the first time;
[0040] After receiving the third trigger message, the second thread renders the second image frame data to the first frame buffer;
[0041] After receiving the second trigger message, the first thread copies the second image frame data from the first frame buffer to the second frame buffer through the DMA channel;
[0042] The first thread sends the rendering instruction to the second thread to trigger the second thread to render the first image frame data to the first frame buffer;
[0043] After receiving the second trigger message again, the first thread sends the second image frame data in the second frame buffer to the display screen for display.
[0044] In this way, after the screen is initially turned on, the display screen triggers the second thread to render the image frame data through an interrupt, and after a certain period of time, triggers the first thread to copy the rendered image frame data from the first frame buffer to the second frame buffer. After that, the display screen triggers the first thread to send the image for display, thereby realizing the initial display of the image frame data after the screen is turned on.
[0045] In a second aspect, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the data processing method described in any one of the first aspects when executing the computer program.
[0046] In a third aspect, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is run on a computer, the computer executes the data processing method described in the first aspect.
[0047] In a fourth aspect, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute the data processing method described in the first aspect.
[0048] The technical effects obtained by the above-mentioned second aspect, third aspect and fourth aspect are similar to the technical effects obtained by the corresponding technical means in the above-mentioned first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 is a schematic diagram showing a rendering and display process of image frame data according to an exemplary embodiment;
[0050] Figure 2 is a schematic structural diagram of an electronic device according to an exemplary embodiment;
[0051] Figure 3 is a schematic diagram of the architecture of a software system of an electronic device according to an exemplary embodiment;
[0052] Figure 4 is a schematic diagram showing an application scenario according to an exemplary embodiment;
[0053] Figure 5 is a flowchart of a data processing method according to an exemplary embodiment;
[0054] Figure 6 is a schematic diagram of a process of copying data through two DMA channels according to another exemplary embodiment;
[0055] Figure 7 is a schematic diagram of a process of initializing a DMA channel according to an exemplary embodiment;
[0056] Figure 8 It is a flowchart of a data processing method according to another exemplary embodiment. DETAILED DESCRIPTION
[0057] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.
[0058] It should be understood that the "multiple" mentioned in this application refers to two or more. In the description of this application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in order to facilitate the clear description of the technical solution of this application, the words "first" and "second" are used to distinguish between the same items or similar items with basically the same functions and effects. Those skilled in the art can understand that the words "first" and "second" do not limit the quantity and execution order, and the words "first" and "second" do not limit them to be different.
[0059] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0060] When an application draws image frame data, it is generally implemented through the cooperation of multiple threads such as the interface refresh thread (also known as the UI thread) and the display thread (also known as the display thread). Among them, the interface refresh thread is mainly responsible for processing events related to the user interface (UI), such as being responsible for updating and redrawing the UI interface, and the interface refresh thread stores the drawn image frame data in the frame buffer. The display thread is used to obtain the image frame data drawn by the interface refresh thread from the frame buffer and send it to the display screen, thereby realizing the display of the image frame data.
[0061] In order to improve the refresh smoothness of the UI interface, a dual frame buffer technology is currently provided, that is, two frame buffers are provided. During the image frame data rendering and display process, one frame buffer is used to render the image frame data, and the other frame buffer is used to send the image. One frame buffer corresponds to one image frame, or one frame of image frame data. Usually, one frame of image frame data is about 650KB in size. See Figure 1 , the electronic device provides a frame buffer buffer1 and a frame buffer buffer2, wherein the frame buffer buffer1 is used to render image frame data, and the frame buffer buffer2 is used to send images. That is, after the interface refresh thread renders the UI interface, the obtained image frame data is stored in the frame buffer buffer1, and then the electronic device copies the data in the frame buffer buffer1 to the frame buffer buffer2, and then the display thread sends the image frame data in the frame buffer buffer2 to the display screen for display, so that the frame buffer buffer1 can continue to be used for the next image frame data rendering.
[0062] In some embodiments, the central processing unit (CPU) of the electronic device provides a data copy function (such as a memcpy method), and the electronic device copies the image frame data in the frame buffer buffer1 to the frame buffer buffer2 through the data copy function. However, since the time consumed by the data copy is related to the CPU frequency of the electronic device, and for some electronic devices with low CPU performance, such as some wearable devices, whose CPU frequency is low, it will be limited by the CPU frequency, so that the CPU will copy the image frame data in the frame buffer buffer1 to the frame buffer buffer2. It takes a long time, for example, it takes about 3.3 milliseconds or even longer to copy 650KB of image frame data, which results in a large time overhead, thereby affecting the improvement of the display frame rate of the image frame data. To this end, an embodiment of the present application provides a data processing method, which can improve the data copy process, thereby reducing the time overhead of data copying, and further improving the display frame rate of the image frame data.
[0063] Before introducing the data processing method provided in the embodiment of the present application in detail, the execution subject provided in the embodiment of the present application is first introduced. The data processing method provided in the embodiment of the present application can be executed by an electronic device, illustratively, the electronic device can be but not limited to a wearable device, a mobile phone, a sports camera (GoPro), a digital camera, a tablet computer, a desktop, a laptop, a handheld computer, a notebook computer, a vehicle-mounted device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook, a cellular phone, a personal digital assistant (personal digital assistant, PDA), an augmented reality (augmented reality, AR)\virtual reality (virtual reality, VR) device, and the wearable device can be a smart watch, a smart bracelet, etc.
[0064] Please refer to Figure 2 , Figure 2 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 2The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, a subscriber identification module (SIM) card interface 195 and a direct memory access (DMA) device 196, etc. Among them, the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0065] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0066] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0067] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0068] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0069] In some embodiments, the processor 110 may include one or more interfaces, such as 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.
[0070] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0071] The charging management module 140 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from a wired charger through the USB interface 130. In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100. While the charging management module 140 is charging the battery 142, it may also power the electronic device 100 through the power management module 141.
[0072] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and provides power to the processor 110, the internal memory 121, the external memory, the display screen 194, the camera 193 and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle number, battery health status (leakage, impedance), etc. In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.
[0073] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
[0074] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which is connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. In one example, the interface refresh thread calls the GPU to render image frame data. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
[0075] The display screen 194 is used to display images, videos, etc. The display screen 194 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 or an active-matrix organic light emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is an integer greater than 1.
[0076] The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.
[0077] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.
[0078] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created by the electronic device 100 during use (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.
[0079] The electronic device 100 can implement audio functions, such as music playback, recording, etc., through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone interface 170D and the application processor.
[0080] The touch sensor 180K is also called a "touch panel". The touch sensor 180K can be set on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also called a "touch screen". The touch sensor 180K is used to detect touch operations acting on or near it. The touch sensor 180K can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180K can also be set on the surface of the electronic device 100, which is different from the position of the display screen 194.
[0081] The key 190 includes a power key, a volume key, etc. The key 190 may be a mechanical key or a touch key. The electronic device 100 may receive key inputs and generate key signal inputs related to user settings and function control of the electronic device 100.
[0082] DMA device 196 is a hardware mechanism for copying data. In some scenarios, DMA device 196 can obtain control of the CPU, and then independently copy data from one address space to another address space, such as copying data from one memory unit to another memory unit, or copying data from an external memory to the internal memory. It is worth mentioning that compared with the CPU, data copying through DMA device 196 can increase the data transmission speed. In addition, data copying through DMA device 196 allows the CPU to only be responsible for management without participating in the data copy operation, thereby avoiding data copying from occupying CPU resources and reducing CPU overhead.
[0083] Next, the software system of the electronic device 100 will be described.
[0084] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software system of the electronic device 100.
[0085] Figure 3 1 is a block diagram of a software system of an electronic device 100 provided in an embodiment of the present application. Figure 3 , the layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom, namely, the application layer, the application framework layer, the Android runtime (Android runtime) and the system layer, the hardware abstraction layer (HAL) and the kernel layer.
[0086] also, Figure 3 The relationship between some hardware and software systems of the electronic device is also shown. Figure 3 As shown, the hardware includes a display screen 194 and a DMA device 196. As an example of the present application, the DMA device 196 is used to copy image frame data from the first frame buffer to the second frame buffer. The number of DMA devices 196 can be one or more, and a single DMA device 196 generally includes one or more DMA channels. The DMA device 196 can control each DMA channel through a DMA controller.
[0087] The application layer can include a series of application packages. Figure 3 As shown, the application package may include camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and other applications.
[0088] The application framework layer provides application programming interface (API) and programming framework for the applications in the application layer. The application framework layer includes some predefined functions. Figure 3 As shown, the application framework layer may include a power management service module, a business module, a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, etc. The power management service module is used to control the display screen to turn on or off. In one example, the power management service module is a PowerManageService module. The business module is called by the application of the application layer to implement the corresponding business functions, such as implementing audio playback, video playback and other services. The window manager is used to manage window programs. The window manager can obtain the size of the display screen, determine whether there is a status bar, lock the display screen, capture the display screen, etc. The content provider is used to store and obtain data and make these data accessible to the application. These data may include video, images, audio, dialed and received calls, browsing history and bookmarks, phone books, etc. The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, etc. The view system can be used to build the display interface of the application. The display interface can be composed of one or more views, for example, including a view for displaying a text message notification icon, a view for displaying text, and a view for displaying pictures. The phone manager is used to provide communication functions for the electronic device 100, such as management of call status (including connection, hang up, etc.). The resource manager provides various resources for applications, such as localized strings, icons, pictures, layout files, video files, etc. The notification manager enables applications to display notification information in the status bar, which can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify the completion of downloads, message reminders, etc. The notification manager can also be a notification that appears in the status bar at the top of the system in the form of a chart or scroll bar text, such as a notification of an application running in the background. The notification manager can also be a notification that appears on the display screen in the form of a dialog window, such as prompting a text message in the status bar, issuing a prompt tone, vibrating the electronic device, flashing the indicator light, etc.
[0089] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system. The core library consists of two parts: one is the function that the Java language needs to call, and the other is the Android core library. The application layer and the application framework layer run in the virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0090] The system library can include multiple functional modules, such as: surface manager, media library, 3D graphics processing library (such as: OpenGL ES), 2D graphics engine (such as: SGL), etc. The surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications. The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc. The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis, and layer processing, etc. The 2D graphics engine is a drawing engine for 2D drawing.
[0091] The HAL layer is used to abstract the hardware. It hides the hardware interface details of a specific platform and provides a virtual hardware platform for the operating system, making it hardware-independent, so that it can be ported on multiple platforms. As an example of the present application, the HAL layer includes an interrupt interface A, an interrupt interface B, a DMA channel allocation interface, an initialization interface, and a data copy interface, wherein the interrupt interface A and the interrupt interface B are used for the display screen to call when an interrupt is generated; the DMA channel allocation interface is used to allocate a DMA channel; the initialization interface is used to initialize the DMA channel; and the data copy interface is used to call when copying data through the DMA channel. In one example, the initialization interface includes a first interface, a second interface, and a third interface, wherein the first interface is used to register the interrupt number of the DMA channel; the second interface is used to initialize the DMA channel, and the third interface is used to register the DMA callback function.
[0092] The kernel layer is a layer between hardware and software. The kernel layer contains at least DMA driver, display driver, camera driver, audio driver, and sensor driver. The DMA driver is used to load the DMA device 196 of the hardware layer. The display driver is used to load the display screen 194 of the hardware layer. In addition, the kernel layer also includes thread resources. For example, the thread resources include interface refresh threads, display threads, etc. The tasks executed by the threads in the thread resources can be determined by the upper layer.
[0093] The following is an illustrative description of the workflow of the software and hardware of the electronic device 100 in conjunction with capturing a photo scene.
[0094] When the touch sensor 180K receives a touch operation, the corresponding hardware interrupt is sent to the kernel layer. The kernel layer processes the touch operation into a raw input event (including touch coordinates, timestamp of the touch operation, and other information). The raw input event is stored in the kernel layer. The application framework layer obtains the raw input event from the kernel layer and identifies the control corresponding to the raw input event. For example, if the touch operation is a single-click operation and the control corresponding to the single-click operation is the control of the camera application icon, the camera application calls the interface of the application framework layer, starts the camera application, and then calls the kernel layer to start the camera driver to capture static images or videos through the camera 193.
[0095] It should be noted that the above Figure 2 and Figure 3 The electronic device shown is only exemplary, and the method provided in the embodiment of the present application can be applied to any electronic device with a DMA device and a dual frame buffer architecture.
[0096] For ease of understanding, a possible application scenario of the present application embodiment is introduced below. Figure 4 , the user triggers the application icon of the music application in the electronic device to play music. In response to the user's triggering operation on the application icon of the music application, the music application renders the image frame data of the music application interface through the interface refresh thread, and then sends the rendered image frame data to the display screen through the display thread, so that the music application interface is displayed on the display screen. In the process of playing music, the music application calls the business module to play music. Accordingly, the business module obtains the audio file, decodes the audio file, and then calls the audio device to play the decoded audio file through the audio device. In this process, the business module determines the total playback time and the playback time of the audio file, so that the playback progress of the audio file can be determined. The business module sends the playback progress related parameters to the interface refresh thread. In this way, the interface refresh thread locally renders the playback progress bar control based on the playback progress related parameters when the rendering timing is reached. Afterwards, the display thread sends the rendering result to the display screen for display, thereby realizing the update of the playback progress bar in the music application interface.
[0097] Of course, it should be noted that the above application scenarios are only exemplary. The method provided in the embodiments of the present application is not limited to the above application scenarios, but can also be applied to other UI interface display scenarios, which is not limited in the embodiments of the present application.
[0098] Based on the above embodiments, the data processing method provided by the embodiments of the present application is introduced below. Figure 5 , Figure 5is a flowchart of a data processing method according to an exemplary embodiment. As an example but not a limitation, the method is applied to the above Figure 2 and Figure 3 In the electronic device shown, the electronic device may be implemented through interaction of multiple modules, and specifically, may include part or all of the following contents:
[0099] Step 501: In response to a screen-on instruction, the power management service module controls the display screen to turn on the screen.
[0100] In one possible case, the screen-lighting instruction is triggered after the system of the electronic device is started. For example, in one example, when the electronic device is turned off, the user long presses the power-on control. In response to the user's long press operation on the power-on control, it is determined that the system startup operation is detected. In this case, the system starts, and after the system startup is completed, the power management service module receives the screen-lighting instruction. In another example, when the electronic device is turned on, the user triggers a system restart. At this time, the system of the electronic device restarts, and after the restart is completed, the power management service module receives the screen-lighting instruction.
[0101] In another possible situation, when the electronic device receives a screen-on operation while the screen is off, a screen-on instruction will also be triggered.
[0102] After receiving the screen-on instruction, in response to the screen-on instruction, the power management service module controls the display screen to light up, that is, the display screen of the electronic device enters the screen-on state.
[0103] Step 502: After the display screen is lit up, the interrupt interface A is called and an interrupt signal signal1 is sent to the interrupt interface A.
[0104] That is, when the display screen is lit, the display screen will generate an interrupt signal signal1 and report the interrupt. When reporting the interrupt, the display screen calls the interrupt interface A and sends the interrupt signal signal1 to the interrupt interface A.
[0105] In an example, the display screen can register an interrupt callback function to the interrupt interface A, so that the registered interrupt callback function is executed when the interrupt is reported, thereby calling the interrupt interface A and sending an interrupt signal signal1 to the interrupt interface A.
[0106] Step 503: After receiving the interrupt signal signal1, the interrupt interface A sends a trigger message message1 to the interface refresh thread.
[0107] Among them, the interface refresh thread runs after the electronic device is turned on, for example, it is scheduled by the CPU to run in the kernel of the electronic device. The interface refresh thread corresponds to a message queue Q1, and the message queue Q1 is used to store messages to be processed by the interface refresh thread. When there are messages in the message queue Q1, the interface refresh thread can process each message in the message queue Q1 in sequence according to the first-in-first-out principle. When there are no messages in the message queue Q1, it means that there are currently no messages that need to be processed by the interface refresh thread. At this time, the interface refresh thread is in a suspended state, waiting for the arrival of messages in the message queue Q1.
[0108] As an example of the present application, after receiving the interrupt signal signal1 from the display screen, the interrupt interface A stores a trigger message message1 into the message queue Q1 of the interface refresh thread, and the trigger message message1 is used to instruct the interface refresh thread to perform a rendering operation.
[0109] Step 504: After receiving the trigger message message1, the interface refresh thread renders the image frame data in the frame buffer buffer1.
[0110] Taking the screen lighting scenario after system startup as an example, after the system starts successfully, the main interface needs to be displayed on the display screen, so the desktop application will send the interface parameters related to the main interface to the interface refresh thread. For example, the interface parameters include controls, text, images and other parameters.
[0111] When the interface refresh thread receives the trigger message message1, it determines that the rendering time has arrived. Therefore, the interface refresh thread renders based on the interface parameters of the main interface to obtain the image frame data P1. The interface refresh thread stores the image frame data P1 in the frame buffer buffer1 and waits for the next rendering time.
[0112] Step 505: After calling the interrupt interface A, the display screen calls the interrupt interface A once every first preset time period and sends an interrupt signal signal1 to the interrupt interface A.
[0113] As an example of the present application, the display screen can periodically generate an interrupt signal signal1 after calling the interrupt interface A for the first time, that is, periodically call the interrupt interface A and send the interrupt signal signal1 to the interrupt interface A, and the period duration is the first preset duration.
[0114] As an example of the present application, the first preset duration may be 16.6ms. Since in the process of interacting with electronic devices, a frame rate below 60Hz will give the user a stuttering visual experience, the refresh rate of the image frame data is usually required to be at least 16.6ms, that is, the display screen is required to refresh the image frame data every 16.6ms. Therefore, the display screen generates an interrupt signal signal1 every 16.6ms, so that the interface refresh thread and the display thread can complete the rendering and display operations of the image frame data within 16.6ms.
[0115] It should be noted that there is no strict execution order between step 505 and step 503 .
[0116] Step 506: After receiving the interrupt signal signal1, the interrupt interface A sends a trigger message message2 to the display thread.
[0117] Similarly, the display thread also runs after the electronic device is turned on, for example, it is scheduled by the CPU to run in the kernel of the electronic device. The display thread also corresponds to its own message queue Q2, that is, the message queue Q2 is used to store messages to be processed by the display thread. When there are messages in the message queue Q2, the display thread can process them one by one according to the first-in-first-out principle according to the order in which the messages in its message queue Q2 are stored. When there are no messages in the message queue Q2, it means that there are currently no messages that need to be processed by the display thread. At this time, the display thread is in a suspended state, waiting for the arrival of messages in the message queue Q2.
[0118] As an example of the present application, when the interrupt interface A receives the interrupt signal signal1 again after the screen is turned on, it stores a trigger message message2 into the message queue Q2 of the display thread to instruct the display thread to copy the image frame data in the frame buffer buffer1 to the frame buffer buffer2.
[0119] According to the previous records, interrupt interface A may receive interrupt signal signal1 multiple times. When interrupt signal signal1 is received for the first time after the screen is turned on, interrupt interface A will send trigger message message1 to the interface refresh thread. When interrupt signal signal1 is not received for the first time, interrupt interface A will send trigger message message2 to the display thread. Therefore, as an example of the present application, in order to determine to whom the trigger message needs to be sent when interrupt signal signal1 is received, interrupt interface A can determine whether it is the first time to receive interrupt signal signal1 after receiving it. If it is the first time to receive after the screen is turned on, perform the above step 503. Otherwise, if it is not the first time to receive after the screen is turned on, perform step 506 and subsequent operations.
[0120] Step 507: The display thread creates a target object, which is used to monitor the DMA interrupt signal. The DMA interrupt signal is used to indicate the completion of a data copy.
[0121] After receiving the trigger message message2 sent by the interrupt interface A, it is determined that the image frame data P1 in the frame buffer buffer1 needs to be copied to the frame buffer buffer2. As an example of the present application, the display thread copies the data through the DMA channel. Since the DMA channel can complete the data copy independently, that is, the CPU is not involved in the data copy process, in order to be able to know whether the DMA channel has completed the data copy, the display thread creates a target object before calling the DMA channel for data copy, so that the DMA interrupt signal can be monitored through the created target object later, so that when the DMA interrupt signal is monitored, it can be determined that a data copy operation has been completed through the DMA channel.
[0122] As an example of this application, the display thread copies data through two DMA channels. Therefore, please refer to Figure 6 When creating a target object, the display thread can create two objects, that is, the target object includes two objects, for example, a first object sem1 and a second object sem2, so as to monitor the DMA interrupt signal signal2 triggered by the DMA device when completing data copying through one DMA channel through the first object sem1, and monitor the DMA interrupt signal signal3 triggered by the DMA device when completing data copying through another DMA channel through the second object sem2.
[0123] It is worth mentioning that copying data through two DMA channels can shorten the data copy time to 1.7 milliseconds, thus reducing the data copy time, thereby improving the display frame rate of the image frame data. In addition, since the DMA device is managed by the CPU, the CPU time will still be consumed during the operation of the DMA device. If more DMA channels are used for data copying, more CPU time will be consumed. Therefore, in the embodiment of the present application, copying data through two DMA channels can ensure that the data copy time is shortened while avoiding as much time overhead as possible for the CPU.
[0124] Of course, it should be noted that the embodiment of the present application is only described by taking data copying through two DMA channels as an example. In one example, data copying can also be performed through only one DMA channel. In this case, the number of target objects is one. It is also worth noting that compared with data copying through the CPU, data copying through a single DMA channel can shorten the data copying time.
[0125] Step 508: The display thread calls the DMA channel allocation interface to request allocation of the first DMA channel and the second DMA channel.
[0126] For ease of description and understanding, the two DMA channels requested for allocation will be referred to as the first DMA channel and the second DMA channel respectively.
[0127] Please continue to refer to Figure 6 When the display thread needs to copy data through the DMA channel, the DMA channel allocation interface is called. Exemplarily, a channel allocation request can be sent to the DMA channel allocation interface to request the DMA channel allocation interface to allocate an available DMA channel for the display thread.
[0128] Since two DMA channels are used for data copying in the embodiment of the present application, as an example, the display thread can call the DMA channel allocation interface twice to request the DMA channel allocation interface to allocate two DMA channels. That is, after the display thread calls the DMA channel allocation interface once, it calls the DMA channel allocation interface again. Each call can request the DMA channel allocation interface to allocate a DMA channel, so after two calls, the DMA channel allocation interface can be requested to allocate two DMA channels.
[0129] Step 509: The DMA channel allocation interface allocates a first DMA channel and a second DMA channel to the display thread.
[0130] As mentioned above, an electronic device is usually equipped with one or more DMA devices, and a single DMA device has one or more DMA channels. Some of the multiple DMA channels may be currently occupied, while some are not occupied. The DMA channel allocation interface can request the DMA device to select two DMA channels from the unoccupied DMA channels, for example, randomly or according to a preset strategy, and allocate the selected two DMA channels to the display thread for data copying.
[0131] As an example of the present application, after allocating the first DMA channel and the second DMA channel, the DMA channel allocation interface can assign a first interrupt number to the first DMA channel and a second interrupt number to the second DMA channel, where the first interrupt number is used to initialize the first DMA channel and the second interrupt number is used to initialize the second DMA channel.
[0132] Step 510: The DMA channel allocation interface notifies the display thread that the DMA channel allocation is completed.
[0133] That is, after the DMA channel allocation interface allocates the first DMA channel and the second DMA channel to the display thread, it notifies the display thread that the DMA channel allocation has been completed. In one example, the DMA channel allocation interface sends the first interrupt number and the second interrupt number respectively allocated to the first DMA channel and the second DMA channel to the display thread.
[0134] In one example, the DMA channel allocation interface may send two different handles to the display thread to send the first interrupt number and the second interrupt number to the display thread through the respective handles.
[0135] In one example, when the display thread calls the DMA channel allocation interface twice, the DMA channel allocation interface sends the first interrupt number and the second interrupt number to the display thread in response to each call. For example, when it is called for the first time, after the allocation of the first DMA channel is completed, the DMA channel allocation interface sends handle 1 to the display thread to send the first interrupt number to the display thread, and when it is called for the second time, after the allocation of the second DMA channel is completed, the DMA channel allocation interface sends handle 2 to the display thread to send the second interrupt number to the display thread.
[0136] Step 511: The display thread calls the initialization interface to request initialization of the first DMA channel and the second DMA channel.
[0137] As an example of this application, see Figure 6 and Figure 7 , the display thread initializes the first DMA channel, and the implementation process of initializing the second DMA channel includes the following sub-steps:
[0138] A1: The display thread sends an interrupt number registration request to the first interface, where the interrupt number registration request is used to request registration of the first interrupt number and the second interrupt number.
[0139] As an example of the present application, the display thread sends an interrupt number registration request to the first interface twice. For example, after receiving the first interrupt number, the interrupt number registration request is sent to the first interface. At this time, the interrupt number registration request carries the first interrupt number. And after receiving the second interrupt number, the interrupt number registration request is sent to the first interface again. At this time, the interrupt number registration request carries the second interrupt number.
[0140] A2: The first interface registers the first interrupt number and the second interrupt number.
[0141] In an implementation, the first interface registers a first interrupt number of a first DMA channel with the DMA device, and registers a second interrupt number of a second DMA channel with the DMA device.
[0142] A3: The first interface sends a registration success notification to the display thread, where the registration success notification is used to indicate that registration of the interrupt number is completed.
[0143] That is, after registering the first interrupt number of the first DMA channel and the second interrupt number of the second DMA channel, the first interface notifies the display thread to complete the registration of the interrupt number. To this end, the first interface may send a registration completion notification to the display thread.
[0144] A4: The display thread sends an initialization request to the second interface, where the initialization request is used to request initialization of the first DMA channel and the second DMA channel.
[0145] Similarly, the display thread may call the second interface twice to request initialization of the first DMA channel and initialization of the second DMA channel respectively.
[0146] A5: The second interface initializes the first DMA channel and initializes the second DMA channel.
[0147] That is, before using the first DMA channel and the second DMA channel, the first DMA channel and the second DMA channel need to be initialized respectively. In one example, the second interface requests the DMA device to initialize the first DMA channel and the second DMA channel. During the initialization process, the DMA device initializes the first DMA channel using the first interrupt number registered by the first interface, and initializes the second DMA channel using the second interrupt number registered by the first interface.
[0148] A6: The second interface sends an initialization completion notification to the display thread.
[0149] That is, after the second interface completes initialization of the first DMA channel and the second DMA channel, it notifies the display thread of the completion of initialization. In one example, the second interface sends an initialization completion notification to the display thread to notify the display thread of the completion of initialization through the initialization completion notification.
[0150] A7: The display thread calls the third interface and registers the first DMA callback function and the second DMA callback function to the third interface. The first DMA callback function is used for the DMA device to report an interrupt after completing a data copy through the first DMA channel, and the second DMA callback function is used for the DMA device to report an interrupt after completing a data copy through the second DMA channel.
[0151] In implementation, after receiving the initialization completion notification for the first DMA channel, the display thread calls the third interface and registers the first DMA callback function, and after receiving the initialization completion notification for the second DMA channel, the display thread calls the third interface again and registers the second DMA callback function.
[0152] At this point, the initialization of the first DMA channel and the initialization of the second DMA channel are completed, and then data can be copied through the first DMA channel and the second DMA channel. For details, please refer to the following steps.
[0153] Step 512: The display thread calls the data copy interface and sends data copy parameters to the data copy interface.
[0154] The data copy parameters are used by the DMA device when copying data through the first DMA channel and the second DMA channel. The data copy parameters are generally used by the DMA device to determine which image frame data in the frame buffer buffer1 is to be copied, and to which position in buffer2 it is to be copied. In an example, the data copy parameters include the amount of image frame data to be transmitted this time, the starting address information of the image frame data to be transmitted in the frame buffer buffer1, and the starting address information of the image frame data to be transmitted in the frame buffer buffer2.
[0155] For an example, see Figure 6 , showing that after registering the first DMA callback function with the third interface, the thread calls the data copy interface and sends the first data copy parameter to the data copy interface to request data copy through the first DMA channel, and after registering the second DMA callback function with the third interface, the thread calls the data copy interface again and sends the first data copy parameter to the data copy interface to request data copy through the second DMA channel.
[0156] It should be noted that, since the image frame data copied through the first DMA channel is different from the image frame data copied through the second DMA channel, the first data copy parameter is different from the second data copy parameter.
[0157] Step 513: The data copy interface requests the DMA device to copy data through the first DMA channel and the second DMA channel.
[0158] Step 514: The DMA device copies data via the first DMA channel and the second DMA channel.
[0159] As an example of the present application, when copying data from frame buffer buffer1 to frame buffer buffer2, the entire frame is required to be copied, that is, all image frame data in frame buffer buffer1 is copied to frame buffer buffer2, and the image frame data size in frame buffer buffer1 is generally about 650KB. Since a single DMA channel can only copy about 61KB of data each time, that is, the maximum amount of data that can be copied is about 61KB, it is generally necessary to perform multiple cyclic copies through the first DMA channel and the second DMA channel.
[0160] It should be noted that the display thread can know in advance the maximum amount of data that can be copied by a single DMA channel each time.
[0161] As an example of the present application, since the copy operation is performed through the first DMA channel and the second DMA channel, the display thread can pre-set the image frame data that needs to be copied each time by the first DMA channel and the second DMA channel, that is, set which part of the image frame data in the frame buffer buffer1 is copied each time through the first DMA channel, and which part of the image frame data in the frame buffer buffer1 is copied each time through the second DMA channel.
[0162] In implementation, when the data copy interface calls the first DMA channel to copy data, the first DMA channel copies data based on the first data copy parameter. In one example, the first data copy parameter includes the starting address information and data volume of the image frame data to be copied in the frame buffer buffer1, for example, the data volume is 61KB, and also includes the starting address information of the image frame data to be copied in the frame buffer buffer2. In this way, the DMA device copies part of the image frame data indicated by the first data copy parameter from the frame buffer buffer1 to the frame buffer buffer2 through the first DMA channel. It is not difficult to understand that these image frame data are stored in the frame buffer buffer2 starting from the starting address of the frame buffer buffer2.
[0163] Similarly, when the data copy interface calls the second DMA channel to copy data, the second DMA channel copies data based on the second data copy parameter. In one example, the second data copy parameter includes the starting address information and data volume of the image frame data to be copied in the frame buffer buffer1. For example, the starting address information is the address information corresponding to the position offset by 61KB of data volume from the starting address of the frame buffer buffer1, and the data volume is 61KB. In addition, the second data copy parameter also includes the starting address information of the image frame data to be copied in the frame buffer buffer2. For example, the position indicated by the starting address information of the image frame data to be copied in the frame buffer buffer2 is the position offset by 61KB of data volume from the starting address of the frame buffer buffer2. In this way, the DMA device copies part of the image frame data indicated by the second data copy parameter from the frame buffer buffer1 to the frame buffer buffer2 through the second DMA channel.
[0164] Step 515: After completing a data copy through the first DMA channel and the second DMA channel, the DMA device calls the initialization interface and reports a DMA interrupt signal to the initialization interface.
[0165] Specifically, after the DMA device completes a data copy operation through the first DMA channel, it generates a DMA interrupt signal signal2, and the DMA device executes the first DMA callback function to report the DMA interrupt signal signal2 to the third interface in the initialization interface. Similarly, after the DMA device completes a data copy operation through the second DMA channel, it generates a DMA interrupt signal signal3, and the DMA device executes the second DMA callback function to report the interrupt signal signal3 to the third interface in the initialization interface.
[0166] Step 516: The initialization interface reports the DMA device DMA interrupt signal signal2 and the DMA interrupt signal signal3 to the display thread.
[0167] Step 517: The display thread receives the DMA interrupt signal signal2 through the first object sem1, and receives the DMA interrupt signal signal3 through the second object sem2.
[0168] As mentioned above, the display thread creates the first object sem1 and the second object sem2 before requesting the allocation of the DMA channel. Figure 6As shown, after copying data through the first DMA channel and the second DMA channel, the display thread waits for the DMA interrupt signal (including DMA interrupt signal signal2 and DMA interrupt signal signal3) through the first object sem1 and the second object sem2, so as to release the first object sem1 and the second object sem2 when the data copy is completed. When the third interface in the initialization interface reports the DMA interrupt signal signal2, the display thread can receive the DMA interrupt signal signal2 through the first object sem1, so as to know that the first DMA channel has completed a data copy. Similarly, when the third interface in the initialization interface reports the DMA interrupt signal signal3, the display thread can receive the DMA interrupt signal signal3 through the second object sem2, so as to know that the second DMA channel has completed a data copy.
[0169] Step 518: The display thread determines whether all the image frame data in the frame buffer buffer1 has been copied.
[0170] As an example of this application, please refer to Figure 6 , while the display thread is waiting for the interrupt signal through the first object sem1 and the second object sem2, it is determined whether the DMA interrupt signal is successfully received. If it is successfully received, it means that one copy is completed. In this case, it is determined whether all the image frame data in the frame buffer buffer1 are copied. Of course, if it is not successfully received, for example, if the DMA interrupt signal is not received for a long time, it means that the copy may be abnormal. In this case, the first object and the second object can be released, as well as the first DMA channel and the second DMA channel, so as to reallocate and initialize the two DMA channels for data copying.
[0171] As an example but not limitation, the specific implementation of the display thread determining whether all the image frame data in the frame buffer buffer1 has been copied may include: after successfully receiving the DMA interrupt signal, the display thread may determine the number of DMA interrupt signals received, and then multiply the number by the maximum amount of data copied each time by a single DMA channel (such as 61KB). If the multiplication result is less than the amount of data to be copied, it is determined that the copying is not completed; otherwise, if the multiplication result is equal to the amount of data to be copied, it is determined that the copying is completed.
[0172] Of course, in another implementation, the display thread can determine whether the copying is completed based on the actual copying of the data in the first frame buffer. For example, if it is determined that this is the last copy, that is, there is no data to be copied in the first buffer, the copying is determined to be completed.
[0173] It should be noted that Figure 6The implementation process shown is described by taking the example of determining whether the copying is completed before each data copying through the first DMA channel and the second DMA channel. In another example, when the data is copied through the first DMA channel and the second DMA channel for the first time after the first DMA channel and the second DMA channel are initialized, the determination step may not be performed, but the determination may be performed in a subsequent cycle, which is not limited in the embodiments of the present application.
[0174] Step 519: When it is determined that all copies are completed, the display thread releases the first object and the second object, and releases the first DMA channel and the second DMA channel.
[0175] As an example of the present application, releasing the first DMA channel includes deinitializing the first DMA channel, canceling the registration of the first DMA channel, and deleting the allocated first DMA channel.
[0176] Similarly, the process of releasing the second DMA channel can refer to the implementation process of releasing the first DMA channel, which will not be repeated here.
[0177] It should be noted that the above is an example of the display thread confirming that all copies are completed. In one possible case, see Figure 6 If all the image frame data in the frame buffer buffer1 are not copied to the frame buffer buffer2, the display thread continues to call the data copy interface to perform the next data copy operation through the first DMA channel and the second DMA channel, and waits for the next DMA interrupt signal signal2 through the first object sem1, and waits for the next DMA interrupt signal signal3 through the second object sem2.
[0178] It should be noted that the calling of the first DMA channel and the second DMA channel by the display thread may be executed asynchronously.
[0179] Step 520: The display thread sends a trigger message message3 to the interface refresh thread.
[0180] The trigger message message3 is used to trigger the interface refresh thread to continue rendering the next frame of image frame data.
[0181] Step 521: After receiving the trigger message message3, the interface refresh thread renders the next frame of image data to the frame buffer buffer1.
[0182] After receiving the trigger message message3, the interface refresh thread renders the next frame of image frame data P2, and then writes the image frame data P2 into the frame buffer buffer1.
[0183] Step 522: When receiving the next trigger message messag2, the display thread sends the image frame data in the frame buffer buffer2 to the display screen.
[0184] After receiving the next trigger message messag2, the display thread sends the image frame data P1 in the frame buffer buffer2 to the display screen. That is, after completing each copy task, if the display thread receives the trigger message message2 sent by the interrupt interface A again, it executes the image sending operation.
[0185] Step 523: The display screen displays the image frame data.
[0186] That is, the display screen displays the image frame data P1.
[0187] Step 524: The display screen reports an interrupt signal signal4 to the interrupt interface B.
[0188] That is, after the display screen refreshes the image frame data, an interrupt signal signal4 is generated and an interrupt report is performed. When the interrupt is reported, the display screen calls the interrupt interface B and sends the interrupt signal signal4 to the interrupt interface B.
[0189] Step 525: Interrupt interface B sends a trigger message message4 to the display thread.
[0190] Correspondingly, after receiving the trigger message message4, the display thread again copies the data in the frame buffer buffer1 to the frame buffer buffer2 through the first DMA channel and the second DMA channel. Figure 5 , the display thread returns to the operation of step 507. Afterwards, the loop operation from step 523 to step 507 is repeatedly executed while the electronic device is on the screen, that is, the interrupt signal signal4 generated by the display screen triggers the display thread to copy data through the first DMA channel and the second DMA channel. After the display thread completes the data copy, the interface refresh thread is triggered to render in the frame buffer buffer1, and the periodic interrupt signal signal1 generated by the display screen triggers the display thread to send the image for display.
[0191] In an embodiment of the present application, when receiving a first trigger message, the first thread copies the first image frame data in the first frame buffer to the second frame buffer through the DMA channel, and the first trigger message is triggered after the display screen of the electronic device completes the display of the previous frame of the second image frame data. The first thread sends a rendering instruction to the second thread to trigger the second thread to render the next frame of the third image frame data to the first frame buffer. When receiving a second trigger message, the first thread sends the first image frame data in the second frame buffer to the display screen to display the first image frame data through the display screen, and the second trigger message is triggered periodically. In this way, data copying through the DMA channel can increase the data copying speed, thereby reducing the data copying time, and further increasing the display frame rate of the image frame data.
[0192] Please refer to Figure 8 , Figure 8 is a flow chart of a data processing method according to another exemplary embodiment. The method can be applied to the above Figure 2 and Figure 3 In the electronic device shown, the method may include part or all of the following contents:
[0193] Step 801: When receiving a first trigger message, the first thread copies the first image frame data in the first frame buffer to the second frame buffer through the DMA channel. The first trigger message is triggered after the display screen of the electronic device completes displaying the previous frame of the second image frame data.
[0194] In one example, the first trigger message is the above Figure 5 The trigger message message4 in the embodiment shown. The first thread is the above Figure 5 The display thread in the embodiment shown. The first frame buffer is Figure 5 In the embodiment shown, the frame buffer buffer1 and the second frame buffer are Figure 5 In the frame buffer buffer2 of the embodiment shown, the first image frame data is Figure 5 In the embodiment shown, the image frame data P2, the second image frame data is Figure 5 Image frame data P1 in the illustrated embodiment.
[0195] As an example of the present application, in the case of receiving the first trigger message, the first thread copies the first image frame data from the first frame buffer to the second frame buffer through the first DMA channel and the second DMA channel.
[0196] As an example of the present application, upon receiving the first trigger message, the first thread calls the DMA channel allocation interface to request the allocation of the first DMA channel and the second DMA channel. The first thread calls the initialization interface to initialize the first DMA channel and the second DMA channel respectively. The first thread calls the data copy interface to copy the first image frame data from the first frame buffer to the second frame buffer through the first DMA channel and the second DMA channel. For specific implementation, please refer to the above Figure 5 Steps 507 to 518 in the illustrated embodiment.
[0197] As an example of the present application, the amount of data in the first frame buffer is greater than the sum of the maximum amount of data that can be copied by the first DMA channel and the second DMA channel at one time, for example, the amount of data in the first buffer is 650KB, the maximum amount of data that can be copied by the first DMA channel and the second DMA channel at one time is 61KB, and the sum of the maximum amount of data that can be copied by the first DMA channel and the second DMA channel at one time is 122KB. In this case, the first thread calls the data copy interface to copy the first image frame data from the first frame buffer to the second frame buffer through the first DMA channel and the second DMA channel, including: the first thread calls the data copy interface multiple times to copy the first image frame data through the first DMA channel and the second DMA channel multiple times. Each time the first thread calls the data copy interface, it determines whether the first image frame data in the first frame buffer is copied to the second frame buffer. In the case that the first image frame data in the first frame buffer is not copied to the second frame buffer, the first thread continues to call the data copy interface to continue to copy the first image frame data through the first DMA channel and the second DMA channel until the first image frame data in the first frame buffer is copied to the second frame buffer.
[0198] As an example of the present application, the first thread calls the data copy interface multiple times to copy the first image frame data through the first DMA channel and the second DMA channel multiple times. The specific implementation includes: the first thread determines the first data copy parameter and the second data copy parameter related to the data to be copied this time during each copy of the first image frame data through the first DMA channel and the second DMA channel. The first data copy parameter is used for the first DMA channel to copy the data, and the second data copy parameter is used for the second DMA channel to copy the data. The first thread sends the first data copy parameter and the second data copy parameter to the data copy interface, so that the first DMA channel copies the first image frame data based on the first data copy parameter, and the second DMA channel copies the first image frame data based on the second data copy parameter.
[0199] As an example of the present application, when receiving the first trigger message, the first thread copies the first image frame data from the first frame buffer to the second frame buffer through the first DMA channel and the second DMA channel, and then releases the first DMA channel and the second DMA channel. The specific implementation can be seen in the above Figure 5 Step 519 in the illustrated embodiment.
[0200] In the case of receiving the first trigger message, before the first thread copies the first image frame data in the first frame buffer to the second frame buffer through the DMA channel, the display screen calls the first interrupt interface after completing the display of the second image frame data, and reports the first interrupt signal to the first interrupt interface. After receiving the first interrupt signal, the first interrupt interface sends the first trigger message to the first thread.
[0201] Exemplarily, the first interrupt interface is the above-mentioned interrupt interface B, and the first interrupt signal is the above-mentioned interrupt signal signal4.
[0202] As an example of the present application, the second image frame data is the first image frame data displayed after the electronic device turns on the screen. In this case, when receiving the first trigger message, before the first thread copies the first image frame data in the first frame buffer to the second frame buffer through the direct memory access DMA channel, in response to the screen turn-on operation, the display screen enters the screen turn-on state, and the display screen periodically reports the second interrupt signal to the second interrupt interface. When the second interrupt interface determines that it is the first time to receive the second interrupt signal, it sends a third trigger message to the second thread, and when it is determined that it is not the first time to receive the second interrupt signal, it sends a second trigger message to the first thread. After receiving the third trigger message, the second thread renders the second image frame data to the first frame buffer, and after receiving the second trigger message, the first thread copies the second image frame data from the first frame buffer to the second frame buffer through the DMA channel. The first thread sends a rendering instruction to the second thread to trigger the second thread to render the first image frame data to the first frame buffer. After the first thread receives the second trigger message again, it sends the second image frame data in the second frame buffer to the display screen for display.
[0203] Exemplarily, the second interrupt interface is the above-mentioned interrupt interface A. The second interrupt signal is the above-mentioned interrupt signal signal1. The second trigger message is the above-mentioned trigger message message2, and the third trigger message is the above-mentioned trigger message message1.
[0204] Step 802: The first thread sends a rendering instruction to the second thread to trigger the second thread to render the next frame of third image frame data to the first frame buffer.
[0205] In an example, the rendering instruction may be the trigger message message3 mentioned above.
[0206] Step 803: when receiving the second trigger message, the first thread sends the first image frame data in the second frame buffer to the display screen, so as to display the first image frame data through the display screen. The second trigger message is triggered periodically.
[0207] Exemplarily, the cycle duration is 16.6 ms.
[0208] In an embodiment of the present application, when receiving a first trigger message, the first thread copies the first image frame data in the first frame buffer to the second frame buffer through the DMA channel, and the first trigger message is triggered after the display screen of the electronic device completes the display of the previous frame of the second image frame data. The first thread sends a rendering instruction to the second thread to trigger the second thread to render the next frame of the third image frame data to the first frame buffer. When receiving a second trigger message, the first thread sends the first image frame data in the second frame buffer to the display screen to display the first image frame data through the display screen, and the second trigger message is triggered periodically. In this way, data copying through the DMA channel can increase the data copying speed, thereby reducing the data copying time, and further increasing the display frame rate of the image frame data.
[0209] 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 instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (such as: coaxial cable, optical fiber, data subscriber line (Digital Subscriber Line, DSL)) or wireless (such as: infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access, or a data storage device such as a server or data center that includes one or more available media integrations. The available medium may be a magnetic medium (such as a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a digital versatile disc (DVD)), or a semiconductor medium (such as a solid state disk (SSD)).
[0210] The above are optional embodiments provided for the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the technical scope disclosed in the present application shall be included in the protection scope of the present application.
Claims
1. A method for data processing, characterized in that: Applied to electronic equipment, the method comprises: In the case of receiving the first trigger message, the first thread copies the first image frame data in the first frame buffer to the second frame buffer through the first direct memory access DMA channel and the second DMA channel, the first trigger message is triggered after the display screen of the electronic device completes displaying the previous frame of the second image frame data, the first frame buffer is used for rendering the image frame data, the second frame buffer is used for sending the image, and the first thread's calls to the first DMA channel and the second DMA channel are executed asynchronously; The first thread sends a rendering instruction to the second thread to trigger the second thread to render a next frame of third image frame data to the first frame buffer; In the case of receiving a second trigger message, the first thread sends the first image frame data in the second frame buffer to the display screen, so as to display the first image frame data through the display screen, and the second trigger message is periodically triggered; Wherein, in the case of receiving the first trigger message, the first thread copies the first image frame data in the first frame buffer to the second frame buffer through the first direct memory access DMA channel and the second DMA channel, including: In case of receiving the first trigger message, the first thread calls a DMA channel allocation interface to request allocation of the first DMA channel and the second DMA channel; The first thread calls an initialization interface to initialize the first DMA channel and the second DMA channel respectively; When the amount of data in the first frame buffer is greater than the sum of the maximum amount of data that can be copied by the first DMA channel and the second DMA channel at one time, the first thread calls the data copy interface multiple times, and in each call of the data copy interface to copy the first image frame data through the first DMA channel and the second DMA channel, determines a first data copy parameter and a second data copy parameter related to the data to be copied this time, the first data copy parameter is used for the first DMA channel to copy data, and the second data copy parameter is used for the second DMA channel to copy data; The first thread sends the first data copy parameter and the second data copy parameter to the data copy interface, so that the first DMA channel copies the first image frame data based on the first data copy parameter, and the second DMA channel copies the first image frame data based on the second data copy parameter; Each time the first thread calls the data copy interface, it determines whether to copy all the first image frame data in the first frame buffer to the second frame buffer; When all the first image frame data in the first frame buffer are not copied to the second frame buffer, the first thread continues to call the data copy interface to continue copying the first image frame data through the first DMA channel and the second DMA channel until all the first image frame data in the first frame buffer are copied to the second frame buffer.
2. The method according to claim 1, characterized in that In the case of receiving the first trigger message, after the first thread copies the first image frame data in the first frame buffer to the second frame buffer through the first direct memory access DMA channel and the second DMA channel, the method further includes: The first thread releases the first DMA channel and the second DMA channel.
3. The method according to claim 1 or 2, characterized in that The method further comprises: before the first thread copies the first image frame data in the first frame buffer to the second frame buffer through the first direct memory access DMA channel and the second DMA channel when receiving the first trigger message; After the display screen completes displaying the second image frame data, the display screen calls the first interrupt interface and reports a first interrupt signal to the first interrupt interface; After receiving the first interrupt signal, the first interrupt interface sends the first trigger message to the first thread.
4. The method according to claim 1 or 2, characterized in that: The second image frame data is the first image frame data displayed after the screen of the electronic device is turned on; The method further comprises: before the first thread copies the first image frame data in the first frame buffer to the second frame buffer through the first direct memory access DMA channel and the second DMA channel when receiving the first trigger message; In response to the screen-on operation, the display screen enters a screen-on state; The display screen periodically reports a second interrupt signal to the second interrupt interface; The second interrupt interface sends a third trigger message to the second thread when it is determined that the second interrupt signal is received for the first time, and sends the second trigger message to the first thread when it is determined that the second interrupt signal is not received for the first time; After receiving the third trigger message, the second thread renders the second image frame data to the first frame buffer; After receiving the second trigger message, the first thread copies the second image frame data from the first frame buffer to the second frame buffer through the DMA channel; The first thread sends the rendering instruction to the second thread to trigger the second thread to render the first image frame data to the first frame buffer; After receiving the second trigger message again, the first thread sends the second image frame data in the second frame buffer to the display screen for display.
5. An electronic device, characterized in that: The electronic device comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the method according to any one of claims 1 to 4 when executing the computer program.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Image display method and device, readable storage medium and electronic device
CN109035131A
