Ambient light detection method, electronic device, chip system and storage medium
By switching the sampling mode and adjusting the gain value in the ambient light sensor and extending the acquisition cycle, the high power consumption problem of electronic equipment caused by the ambient light sensor is solved, and the accuracy of data acquisition is maintained while reducing power consumption.
Patent Information
- Application Number
- CN202110905134.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-06
- Publication Date
- 2025-08-29
- Estimated Expiration
- 2041-08-06
AI Technical Summary
When ambient light sensor collects ambient light data, it causes large power consumption of electronic devices, especially when it is in a dormant state during the non-integrated time period.
By switching the sampling mode of the ambient light sensor under certain conditions, switching from the first sampling mode to the second sampling mode is extended to reduce the acquisition frequency, and reducing power consumption in combination with gain value adjustment.
It effectively reduces the power consumption of electronic devices, while maintaining accurate collection of ambient light data while meeting the conditions of light stability, reducing the processor's data reporting frequency and further reducing power consumption.
Smart Images

Figure CN115931115B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of ambient light sensors, and in particular to an ambient light detection method, electronic equipment, chip system and storage medium. Background Art
[0002] Ambient light sensors sense the intensity of ambient light. Electronic devices equipped with these sensors can adjust the brightness of their displays based on the ambient light data collected by the sensors. This improves the user's visual experience when viewing content displayed on the display by adjusting the display brightness to match the ambient light intensity. Furthermore, when ambient light intensity is low, the display brightness can be dimmed, reducing the electronic device's power consumption.
[0003] When collecting ambient light data, an ambient light sensor typically does so in a specific collection cycle. For example, a collection cycle consists of an integration period and a non-integration period. The ambient light sensor collects ambient light data during the integration period and does not collect data during the non-integration period. In other words, the ambient light sensor is in a dormant state during the non-integration period. However, this method of collecting ambient light data still consumes significant power for electronic devices. Summary of the Invention
[0004] The present application provides an ambient light detection method, electronic device, chip system and storage medium to solve the problem of high power consumption of electronic devices.
[0005] To achieve the above objectives, this application adopts the following technical solutions:
[0006] In a first aspect, the present application provides a method for detecting ambient light, which is applied to an electronic device, the electronic device including a first processor and a second processor, the method comprising:
[0007] The first processor obtains a first value collected by an ambient light sensor on the electronic device in a first sampling mode;
[0008] The first processor sends a first value to the second processor;
[0009] The second processor receives the first value;
[0010] The second processor sends first information to the first processor based on the first value, the first information corresponding to the second sampling pattern;
[0011] In response to receiving the first information, the first processor instructs the ambient light sensor to collect ambient light based on a second sampling mode, where a collection period of the second sampling mode is greater than a collection period of the first sampling mode.
[0012] In an embodiment of the present application, when the ambient light sensor collects ambient light data (including the first value) in a first sampling mode and meets certain conditions, the ambient light sensor switches from the first sampling mode to a second sampling mode. The second sampling mode has a longer collection period than the first sampling mode and the same integration time, which is equivalent to the ambient light sensor extending the sleep time in the second sampling mode. Therefore, the power consumption of the electronic device in the second sampling mode will be lower than that in the first sampling mode, thereby reducing the power consumption of the electronic device; and when the first processor determines whether to switch the sampling mode based on the ambient light data, the frequency of the first processor reporting the ambient light data to the second processor is also reduced, thereby further reducing power consumption.
[0013] In an implementation of the first aspect, the acquisition period includes an integration time and a sleep time; and the integration time of the second sampling mode is the same as that of the first sampling mode.
[0014] In an implementation of the first aspect, the second processor sending the first information to the first processor based on the first value includes:
[0015] The second processor determines a maximum value and a minimum value in the first ambient light data, where the first ambient light data includes the first value and the ambient light data stored in the first storage space, where the ambient light data stored in the first storage space is ambient light data that meets the storage condition and is stored after the second processor clears the first storage space for the last time;
[0016] If the absolute value of the difference between the maximum value and the minimum value in the first ambient light data is less than the first threshold, the second processor stores the first value in the first storage space;
[0017] After storing the first value in the first storage space, if the ambient light data stored in the first storage space is a first amount of ambient light data, the second processor sends first information to the first processor.
[0018] In an implementation of the first aspect, the ambient light data that meets the storage condition includes:
[0019] After the second processor clears the first storage space, the first ambient light data received is the ambient light data that meets the storage condition;
[0020] If the absolute value of the difference between the ambient light data currently received by the second processor and the maximum value and the minimum value of the ambient light data currently stored in the first storage space is less than the first threshold, the currently received ambient light data is ambient light data that meets the storage condition;
[0021] The conditions for clearing the first storage space include:
[0022] If the absolute value of the difference between the maximum and minimum values of the ambient light data currently received by the second processor and the ambient light data currently stored in the first storage space is not less than the first threshold and less than the second threshold, the condition for clearing the first storage space is met.
[0023] In an implementation of the first aspect, after the first processor instructs the ambient light sensor to collect ambient light based on the second sampling mode, the method further includes:
[0024] The first processor obtains a second value collected by the ambient light sensor in a second sampling mode;
[0025] The first processor sends a second value to the second processor;
[0026] The second processor receives the second value;
[0027] The second processor sends second information to the first processor based on the second value, the second information corresponding to the first sampling pattern;
[0028] In response to receiving the second information, the first processor instructs the ambient light sensor to collect ambient light based on a first sampling pattern.
[0029] In an implementation of the first aspect, the second processor sending the second information to the first processor based on the second value includes:
[0030] The second processor determines a maximum value and a minimum value in the received second ambient light data, where the second ambient light data is ambient light data collected after the ambient light sensor switches to the second sampling mode, and the second ambient light data includes a second value;
[0031] If the absolute value of the difference between the maximum and minimum values in the second ambient light data is greater than or equal to the first threshold and the absolute value of the difference between the maximum and minimum values in the second ambient light data is less than the second threshold, the second processor sends second information to the first processor.
[0032] In an implementation of the first aspect, after the first processor instructs the ambient light sensor to collect ambient light based on the second sampling mode, the method further includes:
[0033] The first processor obtains a third value collected by the ambient light sensor in the second sampling mode;
[0034] The first processor sends a third value to the second processor;
[0035] The second processor receives the third value;
[0036] The second processor sends third information to the first processor based on the third value, where the third information corresponds to the third sampling pattern;
[0037] In response to receiving the third information, the first processor instructs the ambient light sensor to collect ambient light based on a third sampling mode.
[0038] In an implementation of the first aspect, the second processor sending the third information to the first processor based on the third value includes:
[0039] The second processor determines a maximum value and a minimum value in the received third ambient light data, where the third ambient light data is ambient light data collected after the ambient light sensor switches to the second sampling mode, and the third ambient light data includes a third value;
[0040] If the absolute value of the difference between the maximum value and the minimum value in the third ambient light data is greater than or equal to the second threshold, the second processor sends third information to the first processor.
[0041] In an implementation of the first aspect, after the first processor instructs the ambient light sensor to collect ambient light based on the third sampling mode, the method further includes:
[0042] The first processor obtains a fourth value collected by the ambient light sensor in a third sampling mode;
[0043] The first processor sends a fourth value to the second processor;
[0044] The second processor receives the fourth value;
[0045] The second processor sends fourth information to the first processor based on the fourth value, where the fourth information corresponds to the first sampling pattern;
[0046] In response to receiving the fourth information, the first processor instructs the ambient light sensor to collect ambient light based on the first sampling mode.
[0047] In an implementation of the first aspect, the second processor sending fourth information to the first processor based on the fourth value includes:
[0048] The second processor determines a maximum value and a minimum value of the fourth ambient light data, where the fourth ambient light data includes the fourth value and the ambient light data stored in the first storage space, where the ambient light data stored in the first storage space is ambient light data that meets the storage condition and is stored after the second processor clears the first storage space for the last time;
[0049] If the absolute value of the difference between the maximum value and the minimum value in the fourth ambient light data is less than the second threshold, the second processor stores the fourth value in the first storage space;
[0050] After storing the fourth value in the first storage space, if the ambient light data stored in the first storage space is the second amount of ambient light data, the second processor sends fourth information to the first processor.
[0051] In an implementation of the first aspect, after the first processor instructs the ambient light sensor to collect ambient light based on the first sampling mode, the method further includes:
[0052] The first processor obtains a fifth value collected by the ambient light sensor in the first sampling mode;
[0053] The first processor sends a fifth value to the second processor;
[0054] The second processor receives the fifth value;
[0055] The second processor sends fifth information to the first processor based on the fifth value, where the fifth information corresponds to the third sampling pattern;
[0056] In response to receiving the fifth information, the first processor instructs the ambient light sensor to collect ambient light based on a third sampling mode.
[0057] In an implementation of the first aspect, the second processor sending fifth information to the first processor based on the fifth value includes:
[0058] The second processor determines a maximum value and a minimum value of fifth ambient light data, where the fifth ambient light data includes the fifth value and ambient light data stored in the first storage space, where the ambient light data stored in the first storage space is ambient light data that meets the first storage condition and is stored after the second processor clears the first storage space for the last time;
[0059] In an implementation of the first aspect, the method further includes:
[0060] The first processor obtains a sixth value collected by the ambient light sensor in any sampling mode, where the sixth value is ambient light data collected by the ambient light sensor in the first gain value, and any sampling mode includes the first sampling mode, the second sampling mode, and the third sampling mode;
[0061] If the sixth value is not within the first range, the first processor adjusts the gain value of the ambient light sensor to a second gain value;
[0062] The first processor instructs the ambient light sensor to collect ambient light based on a fourth sampling mode, where an acquisition period of the fourth sampling mode is shorter than an acquisition period of the first sampling mode; the first processor obtains a seventh value collected by the ambient light sensor using the fourth sampling mode and the second gain value;
[0063] If the seventh value is within the first range, the first processor instructs the ambient light sensor to collect ambient light in the first sampling mode, and the first processor sends the seventh value and seventh information to the second processor;
[0064] The second processor receives the seventh value and seventh information, where the seventh information is used to indicate that the ambient light sensor is switched to the first sampling mode;
[0065] The second processor clears the first storage space based on the seventh information;
[0066] After clearing the first storage space, the second processor stores the seventh value in the first storage space.
[0067] In an implementation of the first aspect, if an absolute value of a difference between a maximum value and a minimum value in the first ambient light data is less than a first threshold, the second processor storing the first value in the first storage space includes:
[0068] The second processor obtains the brightness level of the first value based on the first value;
[0069] If the absolute value of the difference between the maximum value and the minimum value in the first ambient light data is smaller than the first threshold corresponding to the brightness level of the first value, the second processor stores the first value in the first storage space.
[0070] In an implementation of the first aspect, the brightness levels include: a first brightness level, a second brightness level, a third brightness level, and a fourth brightness level; a threshold between the first brightness level and the second brightness level is a first threshold; a threshold between the second brightness level and the third brightness level is a second threshold, and a threshold between the third brightness level and the fourth brightness level is a third threshold; the first threshold is less than the second threshold, and the second threshold is less than the third threshold.
[0071] The second processor obtains the brightness level of the first value based on the first value, including:
[0072] Determining a relationship between the first value and the second critical value;
[0073] If the first value is equal to the second critical value, the brightness level at which the first value is located is the brightness level at which the second critical value is located;
[0074] If the first value is less than the second critical value, determining the relationship between the first value and the first critical value;
[0075] If the first value is less than the first critical value, the brightness level at which the first value is located is the first brightness level; if the first value is greater than the first critical value, the brightness level at which the first value is located is the second brightness level; if the first value is equal to the first critical value, the brightness level at which the first value is located is the brightness level at which the first critical value is located;
[0076] If the first value is greater than the second critical value, determining the relationship between the first value and the third critical value;
[0077] If the first value is less than the third critical value, the brightness level where the first value is located is the third brightness level; if the first value is greater than the third critical value, the brightness level where the first value is located is the fourth brightness level; if the first value is equal to the third critical value, the brightness level where the first value is located is the brightness level where the third critical value is located.
[0078] In an implementation of the first aspect, in response to the display screen of the electronic device being switched to a screen-off state, the first processor instructs the ambient light sensor to collect ambient light in a second sampling mode.
[0079] In an implementation of the first aspect, when the display screen of the electronic device is in a screen-off state, the method further includes:
[0080] The first processor obtains an eighth value collected by the ambient light sensor in the second sampling mode, where the eighth value is ambient light data collected by the ambient light sensor in the third gain value;
[0081] If the eighth value is not within the first range, the first processor adjusts the gain value of the ambient light sensor to a fourth gain value;
[0082] The first processor instructs the ambient light sensor to collect ambient light based on a fourth sampling mode, where an acquisition period of the fourth sampling mode is shorter than an acquisition period of the second sampling mode; the first processor obtains a ninth value collected by the ambient light sensor using the fourth sampling mode and the fourth gain value;
[0083] If the ninth value is within the first range, the first processor instructs the ambient light sensor to collect ambient light in the second sampling mode, and the first processor sends the ninth value to the second processor.
[0084] In an implementation of the first aspect, the electronic device further includes: an ambient light sensor driver, an ambient light sensor, a HWC module, and a noise algorithm library. The method includes:
[0085] The first processor drives the ambient light sensor to obtain a first value collected by the ambient light sensor in a first sampling mode;
[0086] The first processor drives the ambient light sensor to send a first value to the HWC module;
[0087] The second processor receives the first value through the HWC module, and the second processor sends the first value to the noise algorithm library through the HWC module;
[0088] The second processor sends the first information to the HWC module based on the first value through the noise algorithm library;
[0089] The second processor sends first information to the ambient light sensor driver through the HWC module, where the first information corresponds to the second sampling mode;
[0090] In response to receiving the first information, the first processor drives the ambient light sensor to instruct the ambient light sensor to collect ambient light based on a second sampling mode, where a collection period of the second sampling mode is greater than a collection period of the first sampling mode.
[0091] In a second aspect, the present application provides a method for detecting ambient light, which is applied to an electronic device, the electronic device including a second processor, and the method comprising:
[0092] The second processor receives a first value, where the first value is ambient light data collected by an ambient light sensor of the electronic device in a first sampling mode;
[0093] The second processor determines a maximum value and a minimum value in the first ambient light data, where the first ambient light data includes the first value and the ambient light data stored in the first storage space, where the ambient light data stored in the first storage space is ambient light data that meets the storage condition and is stored after the second processor clears the first storage space for the last time;
[0094] If the absolute value of the difference between the maximum value and the minimum value in the first ambient light data is less than the first threshold, the second processor stores the first value in the first storage space;
[0095] After storing the first value in the first storage space, if the ambient light data stored in the first storage space is a first amount of ambient light data, the second processor sends first information to the first processor of the electronic device, and the first information is used to instruct the first processor to control the ambient light sensor to collect ambient light based on a second sampling mode, and the collection period of the second sampling mode is greater than the collection period of the first sampling mode.
[0096] In an implementation of the second aspect, the method further includes:
[0097] The second processor receives a seventh value and seventh information, where the seventh information indicates that the ambient light sensor switches from a gain adjustment mode to a first sampling mode, where the gain adjustment mode of the ambient light sensor is a mode in which the first processor adjusts the gain value of the ambient light sensor when the collected ambient light data is not within the first range;
[0098] The second processor clears the first storage space based on the seventh information;
[0099] After clearing the first storage space, the second processor stores the seventh value in the first storage space.
[0100] In an implementation of the second aspect, if an absolute value of a difference between a maximum value and a minimum value in the first ambient light data is less than a first threshold, the second processor storing the first value in the first storage space includes:
[0101] The second processor obtains the brightness level of the first value based on the first value;
[0102] If the absolute value of the difference between the maximum value and the minimum value in the first ambient light data is smaller than the first threshold corresponding to the brightness level of the first value, the second processor stores the first value in the first storage space.
[0103] In an implementation of the second aspect, the brightness levels include: a first brightness level, a second brightness level, a third brightness level, and a fourth brightness level; a threshold between the first brightness level and the second brightness level is a first threshold; a threshold between the second brightness level and the third brightness level is a second threshold, and a threshold between the third brightness level and the fourth brightness level is a third threshold; the first threshold is less than the second threshold, and the second threshold is less than the third threshold.
[0104] The second processor obtains the brightness level of the first value based on the first value, including:
[0105] Determining a relationship between the first value and the second critical value;
[0106] If the first value is equal to the second critical value, the brightness level at which the first value is located is the brightness level at which the second critical value is located;
[0107] If the first value is less than the second critical value, determining the relationship between the first value and the first critical value;
[0108] If the first value is less than the first critical value, the brightness level at which the first value is located is the first brightness level; if the first value is greater than the first critical value, the brightness level at which the first value is located is the second brightness level; if the first value is equal to the first critical value, the brightness level at which the first value is located is the brightness level at which the first critical value is located;
[0109] If the first value is greater than the second critical value, determining the relationship between the first value and the third critical value;
[0110] If the first value is less than the third critical value, the brightness level where the first value is located is the third brightness level; if the first value is greater than the third critical value, the brightness level where the first value is located is the fourth brightness level; if the first value is equal to the third critical value, the brightness level where the first value is located is the brightness level where the third critical value is located.
[0111] In an implementation of the second aspect, the ambient light data that meets the storage conditions includes:
[0112] After the second processor clears the first storage space, the first ambient light data received is the ambient light data that meets the storage condition;
[0113] If the absolute value of the difference between the ambient light data currently received by the second processor and the maximum value and the minimum value of the ambient light data currently stored in the first storage space is less than the first threshold, the currently received ambient light data is ambient light data that meets the storage condition;
[0114] The conditions for clearing the first storage space include:
[0115] If the absolute value of the difference between the maximum and minimum values of the ambient light data currently received by the second processor and the ambient light data currently stored in the first storage space is not less than the first threshold and less than the second threshold, the condition for clearing the first storage space is met.
[0116] In a third aspect, the present application provides a method for detecting ambient light, which is applied to an electronic device, the electronic device including a first processor, and the method comprising:
[0117] The first processor obtains a first value collected by an ambient light sensor on the electronic device in a first sampling mode;
[0118] The first processor determines a maximum value and a minimum value in the first ambient light data, where the first ambient light data includes the first value and the ambient light data stored in the first storage space, where the ambient light data stored in the first storage space is ambient light data that meets the storage condition and is stored after the first processor clears the first storage space for the last time;
[0119] If the absolute value of the difference between the maximum value and the minimum value in the first ambient light data is less than the first threshold, the first processor stores the first value in the first storage space;
[0120] After storing the first value in the first storage space, if the ambient light data stored in the first storage space is a first amount of ambient light data, the first processor instructs the ambient light sensor to collect ambient light based on a second sampling mode, and the collection period of the second sampling mode is greater than the collection period of the first sampling mode.
[0121] In a fourth aspect, an electronic device is provided, comprising a processor, the processor being configured to run a computer program stored in a memory to implement any one of the methods of the first aspect of the present application.
[0122] In a fifth aspect, a chip system is provided, comprising a processor coupled to a memory, wherein the processor executes a computer program stored in the memory to implement any method of the second aspect or the third aspect of the present application.
[0123] In a sixth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by one or more processors, it implements any one of the methods of the second aspect and / or the method of the third aspect of the present application.
[0124] In a seventh aspect, the present application provides a computer program product, which, when executed on a device, enables the device to execute any one of the methods of the second aspect and / or the method of the third aspect of the present application.
[0125] It can be understood that the beneficial effects of the second to seventh aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0126] Figure 1 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;
[0127] Figure 2 A diagram showing the positional relationship between an ambient light sensor and a display screen in an electronic device provided in an embodiment of the present application;
[0128] Figure 3 Another positional relationship diagram of an ambient light sensor and a display screen in an electronic device provided in an embodiment of the present application;
[0129] Figure 4 Another positional relationship diagram of an ambient light sensor and a display screen in an electronic device provided in an embodiment of the present application;
[0130] Figure 5 A diagram showing the position relationship of target areas on a display screen provided in an embodiment of the present application;
[0131] Figure 6 A diagram showing the relationship between the ambient light sensor and the target area on the display screen provided in an embodiment of the present application;
[0132] Figure 7 A diagram of a technical architecture relied upon by the ambient light detection method provided in an embodiment of the present application;
[0133] Figure 8 A schematic diagram of a collection cycle of ambient light collected by the ambient light sensor provided in an embodiment of the present application;
[0134] Figure 9 for Figure 8 A schematic diagram of various time nodes for image refresh and backlight adjustment within one acquisition cycle in the embodiment shown;
[0135] Figure 10 Based on Figure 7 A timing flow chart of the ambient light detection method implemented by the technical architecture shown;
[0136] Figure 11 for Figure 10 The timing flow chart between the various modules in the AP processor provided in the embodiment of the present application is shown in the embodiment;
[0137] Figure 12 Based on Figure 9 A schematic diagram of calculating the integrated noise of image noise and backlight noise at each time node provided by the illustrated embodiment;
[0138] Figure 13 A schematic diagram of various time nodes for image refresh and backlight adjustment along the time axis within an acquisition cycle provided by an embodiment of the present application;
[0139] Figure 14 Based on Figure 13 A schematic diagram of calculating the integrated noise of image noise and backlight noise at each time node provided by the illustrated embodiment;
[0140] Figure 15 A diagram showing the sampling modes and switching relationships of the ambient light sensor in the bright screen state provided by an embodiment of the present application;
[0141] Figure 16 A timing diagram of the ambient light sensor provided in an embodiment of the present application when maintaining the current sampling mode and switching the sampling mode;
[0142] Figure 17 A timing diagram of the ambient light sensor provided in an embodiment of the present application when switching to a gain adjustment mode and switching back to a normal sampling mode;
[0143] Figure 18 For the embodiment of this application Figure 7 The technical architecture diagram after adding intelligent adjustment sampling mode to the technical architecture shown above;
[0144] Figure 19 A schematic diagram of a process for determining whether changes in ambient light data are stable, provided in an embodiment of the present application;
[0145] Figure 20 The embodiment of this application provides Figure 19 Schematic diagram of stable ambient light data obtained by the stability judgment process shown;
[0146] Figure 21 A schematic diagram of another process for determining whether changes in ambient light data are stable, provided in an embodiment of the present application;
[0147] Figure 22 The embodiment of this application provides Figure 21 Schematic diagram of stable ambient light data obtained by the stability judgment process shown;
[0148] Figure 23 A schematic diagram of a process for obtaining a threshold value in a stability determination process provided in an embodiment of the present application;
[0149] Figure 24 A schematic diagram of another process for obtaining a threshold value in a stability determination process provided in an embodiment of the present application;
[0150] Figure 25 A diagram showing the sampling modes and switching relationships of the ambient light sensor in the screen-off state provided in an embodiment of the present application;
[0151] Figure 26 A diagram illustrating the sampling mode switching process of the ambient light sensor in the bright screen state provided in an embodiment of the present application. DETAILED DESCRIPTION
[0152] In the following description, specific details such as specific system structures and technologies are provided for illustration rather than limitation to facilitate a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details.
[0153] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or collections thereof.
[0154] It should also be understood that in the embodiments of this application, "one or more" refers to one, two, or more than two; "and / or" describes the relationship between associated objects, indicating that three relationships can exist; for example, A and / or B can mean: A exists alone, A and B exist simultaneously, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the associated objects are in an "or" relationship.
[0155] In addition, in the description of this application specification and the appended claims, the terms "first", "second", "third", "fourth", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0156] References to "one embodiment" or "some embodiments" in this specification mean that a particular feature, structure, or characteristic described in conjunction with that embodiment is included in one or more embodiments of the present application. Thus, phrases such as "in one embodiment," "in some embodiments," "in other embodiments," and "in other embodiments" appearing in various places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more but not all embodiments," unless otherwise specifically emphasized. The terms "including," "comprising," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.
[0157] The ambient light detection method provided in the embodiments of the present application can be applied to electronic devices equipped with a display screen and an ambient light sensor. The electronic device can be a tablet computer, a mobile phone, a wearable device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), or other electronic device. The embodiments of the present application do not limit the specific type of electronic device.
[0158] Figure 1 The schematic diagram of the structure of an electronic device is shown. The 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, a camera 193, a display 194, and a subscriber identification module (SIM) card interface 195. The sensor module 180 may include a pressure sensor 180A, a touch sensor 180K, an ambient light sensor 180L, etc.
[0159] It should be understood that the structures illustrated in the embodiments of the present application do 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, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0160] 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 processing unit (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. Among them, different processing units can be independent devices or integrated into one or more processors. For example, the processor 110 is used to execute the data processing method in the embodiment of the present application.
[0161] 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.
[0162] Processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 110 is a cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 110. If processor 110 needs to use the same instruction or data again, it can directly retrieve it from the memory. This avoids duplicate accesses, reduces processor 110 latency, and thus improves system efficiency.
[0163] The USB interface 130 is an interface that complies with USB standards, and may be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 may be used to connect a charger to charge the electronic device 100, and may also be used to transfer data between the electronic device 100 and peripheral devices.
[0164] 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 via the external memory interface 120 to implement data storage functions. For example, files such as music and videos can be stored on the external memory card.
[0165] The internal memory 121 can be used to store computer executable program code, which includes 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. The program storage area may store an operating system and at least one application required for a function (such as a sound playback function, an image playback function, etc.).
[0166] 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.
[0167] The charging management module 140 is configured 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 the wired charger via the USB interface 130.
[0168] 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 to provide power to the processor 110, the internal memory 121, the external memory, the display 194, the camera 193, and the wireless communication module 160.
[0169] In some other embodiments, the power management module 141 may also be provided in the processor 110. In some other embodiments, the power management module 141 and the charging management module 140 may also be provided in the same device.
[0170] 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.
[0171] Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In other embodiments, the antennas can be used in conjunction with a tuning switch.
[0172] The mobile communication module 150 can provide wireless communication solutions, including 2G / 3G / 4G / 5G, for the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low-noise amplifier (LNA), and the like. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, filter and amplify the received electromagnetic waves, and transmit them to the modem processor for demodulation. The mobile communication module 150 can also amplify the signals modulated by the modem processor and convert them into electromagnetic waves for radiation via the antenna 1.
[0173] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, frequency modulate it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.
[0174] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150 , and antenna 2 is coupled to wireless communication module 160 , so that electronic device 100 can communicate with the network and other devices through wireless communication technology.
[0175] The electronic device 100 can implement audio functions such as music playback and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.
[0176] The audio module 170 is used to convert digital audio signals into analog audio signals for output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be provided in the processor 110, or some functional modules of the audio module 170 can be provided in the processor 110.
[0177] The speaker 170A, also called a "speaker", is used to convert audio electrical signals into sound signals. The electronic device 100 can listen to music or listen to hands-free calls through the speaker 170A.
[0178] The receiver 170B, also called a "handset", is used to convert audio electrical signals into sound signals. When the electronic device 100 receives a call or a voice message, the user can place the receiver 170B close to the ear to hear the voice.
[0179] Microphone 170C, also known as "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak by putting their mouth close to the microphone 170C to input the sound signal into the microphone 170C. The electronic device 100 can be provided with at least one microphone 170C. In other embodiments, the electronic device 100 can be provided with two microphones 170C, which can not only monitor voice information but also realize noise reduction function. In other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to realize the collection of sound signals, noise reduction, identification of sound sources, and directional recording functions. For example, the microphone 170C can be used to collect voice information involved in the embodiments of the present application.
[0180] The headphone jack 170D is used to connect a wired headphone and can be the USB interface 130 or a 3.5mm open mobile terminal platform (OMTP) standard interface or a cellular telecommunications industry association of the USA (CTIA) standard interface.
[0181] The pressure sensor 180A is used to sense pressure signals and convert them into electrical signals. In some embodiments, the pressure sensor 180A can be provided on the display screen 194. There are many types of pressure sensors 180A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. A capacitive pressure sensor can be a device comprising at least two parallel plates having a conductive material. When a force acts on the pressure sensor 180A, the capacitance between the electrodes changes. The electronic device 100 determines the intensity of the pressure based on the change in capacitance. When a touch operation is applied to the display screen 194, the electronic device 100 detects the intensity of the touch operation based on the pressure sensor 180A. The electronic device 100 can also calculate the position of the touch based on the detection signal of the pressure sensor 180A.
[0182] The touch sensor 180K is also called a "touch panel." The touch sensor 180K can be disposed on the display screen 194. 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 applied thereto or in the vicinity thereof. The touch sensor can transmit the detected touch operations to the application processor to determine the type of touch event. Visual output related to the touch operations can be provided via the display screen 194. In other embodiments, the touch sensor 180K can also be disposed on the surface of the electronic device 100, in a location different from that of the display screen 194.
[0183] Ambient light sensor 180L is used to sense ambient light brightness. Electronic device 100 can adaptively adjust the brightness of display screen 194 based on the perceived ambient light. Ambient light sensor 180L can also be used to automatically adjust white balance when taking photos. Ambient light sensor 180L can also work with proximity light sensor 180G to detect whether electronic device 100 is in a pocket to prevent accidental touches.
[0184] The buttons 190 include a power button, a volume button, and the like. The buttons 190 may be mechanical buttons or touch buttons. 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.
[0185] Motor 191 can generate vibration prompts. Motor 191 can be used for incoming call vibration prompts and can also be used for touch vibration feedback.
[0186] Electronic device 100 implements display functionality through a GPU, display screen 194, and an application processor. A GPU is a microprocessor for image processing that connects display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or modify display information.
[0187] The display screen 194 is used to display images, videos, etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194 , where N is a positive integer greater than 1.
[0188] The camera 193 is used to capture still images or videos. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.
[0189] The SIM card interface 195 is used to connect a SIM card. The SIM card can be connected to and disconnected from the electronic device 100 by inserting or removing the SIM card into or from the SIM card interface 195. The electronic device 100 may support one or N SIM card interfaces, where N is a positive integer greater than one.
[0190] The embodiments of the present application do not particularly limit the specific structure of the execution body of the ambient light detection method. As long as the code recording the ambient light detection method of the embodiments of the present application can be executed to communicate according to the ambient light detection method provided by the embodiments of the present application. For example, the execution body of the ambient light detection method provided by the embodiments of the present application can be a functional module in an electronic device that can call and execute a program, or a communication device used in an electronic device, such as a chip.
[0191] Figure 2 This is a front view of the positional relationship between the display screen and the ambient light sensor in the electronic device provided in an embodiment of the present application.
[0192] like Figure 2 As shown, the projection of the ambient light sensor on the electronic device's display is located in the upper half of the electronic device's display. When a user holds the electronic device, the ambient light sensor located in the upper half of the electronic device can detect the light intensity and color temperature of the environment in front of the electronic device (the orientation of the display screen in the electronic device). This light intensity and color temperature are used to adjust the brightness and color temperature of the electronic device's display screen, thereby achieving a better visual effect. For example, in a dark environment, the display screen will not be too bright to cause glare, and in a bright environment, the display screen will not be too dim to cause unclear vision.
[0193] like Figure 3 The figure shows the side position relationship between the display screen and the ambient light sensor in the electronic device. The display screen of the electronic device includes, from top to bottom, a glass cover (translucent), a display module and a protective film, wherein the top and bottom here are used to represent the orientation relationship when the display screen of the electronic device is placed upward. Since the ambient light sensor needs to collect the ambient light above the display screen of the electronic device, a part of the display module in the display screen can be dug out, and the ambient light sensor is placed in this part, which is equivalent to the ambient light sensor being placed below the glass cover plate in the display screen and being on the same layer as the display module. It should be noted that the detection direction of the ambient light sensor and the orientation of the display screen in the electronic device ( Figure 3 The display screen in the electronic device is oriented upwards in the diagram. Obviously, this ambient light sensor placement sacrifices some display area. This ambient light sensor placement is no longer suitable when pursuing a high screen-to-body ratio.
[0194] like Figure 4As shown, another setting method of the ambient light sensor provided in an embodiment of the present application. The ambient light sensor is transferred from the bottom of the glass cover to the bottom of the display module. For example, the ambient light sensor is located below the operation (Active area, AA) area in the OLED screen display module, and the AA area is the area in the display module that can display image content. This setting method of the ambient light sensor does not sacrifice the display area. However, the OLED screen is a self-luminous display screen. When the OLED screen displays an image, the user can see the image from above the display screen. Similarly, the ambient light sensor located below the OLED screen can also collect the light corresponding to the image displayed by the OLED screen. Therefore, the ambient light collected by the ambient light sensor includes the light emitted by the display screen and the real ambient light from the outside world. If you want to accurately obtain the real ambient light from the outside world, in addition to obtaining the ambient light collected by the ambient light sensor, you also need to obtain the light emitted by the display screen.
[0195] pass Figure 4 It is understood that since the ambient light sensor is located below the AA area, the installation of the ambient light sensor does not sacrifice the AA area of the display module. Therefore, the projection of the ambient light sensor on the display screen can be located anywhere on the front of the display screen, and is not limited to the following configuration: the projection of the ambient light sensor on the display screen is located at the top of the front of the display screen.
[0196] Regardless of where the ambient light sensor is located below the AA zone, the projected area of the ambient light sensor on the display is much smaller than the display itself. Therefore, not all light from the entire display interferes with the ambient light collected by the ambient light sensor. Instead, light from the display area above the ambient light sensor and a certain area around the display above the ambient light sensor interferes with the ambient light collected by the ambient light sensor.
[0197] As an example, the photosensitive area of the ambient light sensor has a photosensitive angle. The ambient light sensor can receive light within the photosensitive angle but cannot receive light outside the photosensitive angle. Figure 5 The light emitted by point A above the ambient light sensor (within the light-sensing angle) and the light emitted by point B above a certain range around the ambient light sensor (within the light-sensing angle) will both interfere with the ambient light collected by the ambient light sensor. Figure 5The light emitted by point C, which is farther away from the ambient light sensor (outside the photosensitive angle), will not interfere with the ambient light collected by the ambient light sensor. For the sake of convenience, the display area in the display screen that interferes with the ambient light collected by the ambient light sensor can be recorded as the target area. The position of the target area in the display screen is determined by the specific position of the ambient light sensor below the AA area. As an example, the target area can be a square area centered on the center point of the ambient light sensor with a side length of a certain length (for example, 80 microns, 90 microns, 100 microns). Of course, the target area can also be an area of other shapes that interferes with the light collected by the ambient light sensor obtained by measurement.
[0198] As another example, Figure 6 This is a front view of an OLED screen of an electronic device provided in an embodiment of the present application, as shown in FIG. Figure 6 As shown, the electronic device includes a housing and an OLED screen display interface of the electronic device. The corresponding area of the display interface is area AA, and the ambient light sensor is located behind area AA. The center point of the target area coincides with the center point of the ambient light sensor.
[0199] It should be noted that the ambient light sensor is a device that may have different appearances and shapes depending on the manufacturer. The center point of the ambient light sensor in the embodiment of the present application is the center point of the photosensitive area where the ambient light sensor collects ambient light. Figure 6 The target area shown is larger than the projection area of the ambient light sensor on the OLED screen. In actual applications, the target area may also be smaller than or equal to the projection area of the ambient light sensor on the OLED screen. However, the target area is usually larger than the photosensitive area of the ambient light sensor. As mentioned above, the actual ambient light in the outside world is equal to the ambient light collected by the ambient light sensor minus the light emitted by the display screen. The light emitted by the display screen has been determined to be the light emitted by the target area. The light emitted by the target area is the light generated by the display content of the target area. The interference of the display content on the ambient light collected by the ambient light sensor comes from two parts: the RGB pixel information of the displayed image and the brightness of the displayed image. Through the above analysis, it can be understood that the interference with the ambient light collected by the ambient light sensor is respectively: the RGB pixel information of the image displayed in the target area and the brightness information of the target area. As an example, if the pixel value of a pixel is (r, g, b) and the brightness is L, then the normalized brightness of the pixel is: L×(r / 255) 2.2 , L×(g / 255) 2.2 , L×(b / 255) 2.2 .
[0200] For ease of description, the image corresponding to the target area can be denoted as the target image, and the interference of the target image's RGB pixel information and brightness information on the ambient light collected by the ambient light sensor can be denoted as fusion noise. The ambient light collected by the ambient light sensor can be denoted as the initial ambient light, and the actual external ambient light can be denoted as the target ambient light.
[0201] From the above description, it can be concluded that the target ambient light is equal to the initial ambient light minus the fusion noise at each moment in the time period of collecting the initial ambient light. In this embodiment of the application, the process of calculating the fusion noise based on the RGB pixel information and the brightness information is referred to as the noise fusion process.
[0202] When the display screen is in the display state, the RGB pixel information of the image displayed in the target area may change, and the brightness information of the displayed image may also change. Regardless of whether the RGB pixel information of the image displayed in the target area changes, or the brightness information of the displayed image changes, it may cause the fusion noise to change. Therefore, it is necessary to calculate the subsequent fusion noise based on the changed information (RGB pixel information or brightness information). If the image in the target area remains unchanged for a long time, it is only necessary to calculate the fusion noise when the brightness of the display screen changes. Therefore, in order to reduce the frequency of calculating the fusion noise, the target area can be an area where the image displayed on the display screen changes less frequently. For example, the status bar area at the top of the front of the electronic device. The projection of the ambient light sensor on the display screen is located to the right of the status bar area of the display screen. Of course, it can also be located to the left of the status bar area, or in the middle of the status bar area. The embodiment of the present application does not limit the specific position of the ambient light sensor.
[0203] The following will be Figure 7 The technical architecture corresponding to the method for obtaining target ambient light through initial ambient light and content displayed on a display screen provided in an embodiment of the present application is described.
[0204] like Figure 7 As shown, the processor in the electronic device is a multi-core processor, which includes at least: an AP (application processor) processor and an SCP (sensor coprocessor) processor. The AP processor is the application processor in the electronic device, and the operating system, user interface, and application programs all run on the AP processor. The SCP processor is a coprocessor that can assist the AP processor in tasks related to images and sensors (for example, ambient light sensors).
[0205] Figure 7Only the AP processor and SCP processor are shown. In practical applications, the multi-core processor may also include other processors. For example, when the electronic device is a mobile phone, the multi-core processor may also include a baseband (BP) processor that runs the mobile phone's radio frequency communication control software and is responsible for sending and receiving data.
[0206] Figure 7 The AP processor only shows the content related to the embodiments of the present application. The implementation of the embodiments of the present application needs to rely on the following layers in the AP processor: application layer (Application), java framework layer (Framework Java), native framework layer (Framework native), hardware abstraction layer (HAL), kernel layer (kernel) and hardware layer (hardware).
[0207] Figure 7 The SCP processor in the example can be understood as a sensor hub that can control sensors and process sensor data. The implementation of the present application embodiment relies on the following components in the SCP processor: the Hub APK, the Hub FWK, the Hub DRV, and the Hub hardware.
[0208] There are various applications in the application layer of the AP processor. Figure 7 , application A and application B are shown. Taking application A as an example, after the user starts application A, the display screen will display the interface of application A. Specifically, application A sends the display parameters of the interface to be displayed by application A (for example, the memory address and color of the interface to be displayed) to the display engine service.
[0209] The display engine service in the AP processor sends the received display parameters of the interface to be displayed to the SurfaceFlinger of the native framework layer (Framework native) of the AP processor.
[0210] SurfaceFlinger in the native framework layer (Framework native) of the AP processor is responsible for controlling the fusion of the interface (surface). As an example, the overlapping area of at least two overlapping interfaces is calculated. The interface here may be the interface presented by the status bar, system bar, application itself (the interface to be displayed by application A), wallpaper, background, etc. Therefore, SurfaceFlinger can not only obtain the display parameters of the interface to be displayed by application A, but also obtain the display parameters of other interfaces.
[0211] The hardware abstraction layer (HAL) of the AP processor is called the Hardware Composer (HWC). The HWC is the system's interface synthesis and display module, providing hardware support for the SurfaceFlinger service. In step A1, SurfaceFlinger sends the display parameters (e.g., memory address, color, etc.) of each interface to the HWC through interfaces (e.g., setLayerBuffer, setLayerColor) for interface fusion.
[0212] Typically, when compositing an image (for example, when an electronic device displays an image, it needs to combine the status bar, system bar, application itself, and wallpaper background), the HWC obtains the composite image based on the display parameters of each interface through the HWC's underlying hardware (for example, a hardware compositor). The HWC in the hardware abstraction layer of the AP processor sends the image synthesized by the underlying hardware to the OLED driver, see step A2.
[0213] The OLED driver in the AP processor's core layer sends the synthesized image to the display subsystem (DSS) in the AP processor's hardware layer (see step A3). The display subsystem (DSS) in the AP processor's hardware layer can perform secondary processing on the synthesized image (for example, HDR10 processing to enhance image quality), and then send the processed image for display. In actual applications, secondary processing can also be omitted. In this example, the display subsystem in the AP processor's hardware layer sends the synthesized image to the OLED screen for display.
[0214] Taking the startup of application A as an example, the synthesized image displayed on the OLED screen is the interface synthesized from the interface to be displayed by application A and the interface corresponding to the status bar.
[0215] In the above manner, the OLED screen can complete one image refresh and display.
[0216] In an embodiment of the present application, the display subsystem (DSS) can be controlled to store the entire frame image (or an image larger than the target area in the entire frame image, or an image corresponding to the target area in the entire frame image) in the memory of the kernel layer of the AP processor before sending the secondary processed image (or synthesized image) for display. Since this process involves concurrently writing back image frame data, this memory can be referred to as concurrent write back (CWB) memory, see step A4.
[0217] In this embodiment of the present application, the display subsystem stores an entire frame of image in the CWB memory of the AP processor as an example. After the display subsystem successfully stores the entire frame of image in the CWB memory, the display subsystem can send a storage success signal to the HWC. The entire frame of image corresponding to the image stored in the CWB memory by the display subsystem can be recorded as the image to be refreshed (the image to be refreshed can also be understood as the image after the current refresh).
[0218] The AP processor may also be configured to allow the HWC to access the CWB memory. Upon receiving a storage success signal from the display subsystem, the HWC may obtain the target image from the CWB memory, as shown in step A5.
[0219] It should be noted that regardless of whether the CWB memory stores a full-frame image or an image of a partial region within the full-frame image, the HWC can obtain the target image from the CWB memory. The process of the HWC obtaining the target image from the CWB memory can be referred to as the HWC cutting out the image from the CWB memory.
[0220] For ease of description, the image stored in the CWB memory by the display subsystem can also be referred to as a regional image. As previously mentioned, a regional image can be a full-frame image, a target image, or an image between the range of the target image and the range of the regional image. The range of the target image can be understood as the range defined by the length and width of the target image. The range of the full-frame image can also be defined by the length and width.
[0221] For example, the size of the full-frame image is X1 (pixels) × Y1 (pixels), the size of the target image is X2 (pixels) × Y2 (pixels), and the size of the regional image is X3 (pixels) × Y3 (pixels). X3 satisfies X1 ≥ X3 ≥ X2, and Y3 satisfies Y1 ≥ Y3 ≥ Y2.
[0222] Of course, when X3=X1 and Y3=Y1, the regional image is the full-frame image. When X3=X2 and Y3=Y2, the regional image is the target image.
[0223] Continuing with application A as an example, when application A needs to adjust brightness due to switching interfaces, application A sends the brightness to be adjusted to the display engine service.
[0224] The display engine service in the AP processor sends the brightness to be adjusted to the core node in the core layer of the AP processor, so that the relevant hardware can adjust the brightness of the OLED screen according to the brightness to be adjusted stored in the core node.
[0225] According to the above method, the OLED screen can complete one brightness adjustment.
[0226] In the embodiment of the present application, the HWC may be configured to obtain the brightness to be adjusted from the core node, and the brightness to be adjusted may also be recorded as the brightness after this adjustment. For details, see step A5'.
[0227] In a specific implementation, the HWC can monitor whether the data stored in the kernel node changes based on the uevent mechanism. After monitoring the data changes in the kernel node, the HWC obtains the currently stored data from the kernel node, that is, the brightness value to be adjusted (the brightness value to be adjusted is used to adjust the brightness of the display screen, so it can also be recorded as the brightness value of the display screen). After the HWC obtains the target image or the brightness information to be adjusted, it can send the target image or the brightness information to be adjusted to the noise algorithm library of the hardware abstraction layer of the AP processor. See step A6. The noise algorithm library can calculate the fusion noise of the target image refresh moment after each target image is obtained. After each brightness is obtained, the fusion noise of the brightness adjustment moment is calculated. The noise algorithm library stores the calculated fusion noise in the noise memory of the noise algorithm library.
[0228] In practical applications, after the HWC acquires the target image, it can store it and send the target image's storage address to the noise algorithm library. The noise algorithm library can then cache the latest target image frame by recording the address. After acquiring the brightness to be adjusted, the HWC can send the brightness to the noise algorithm library. The noise algorithm library can then cache the latest brightness. For ease of description, the subsequent embodiments of this application will be described as the HWC sending the target image to the noise algorithm library. In practical applications, this can mean that the HWC acquires the target image, stores it, and sends the target image's storage address to the noise algorithm library.
[0229] As an example, after the noise algorithm library receives the storage address of the first frame of the target image, it caches the storage address of the first frame of the target image. Each time a new target image storage address is subsequently received, the storage address of the new target image is used as the storage address of the latest cached target image. Correspondingly, after the noise algorithm library receives the first brightness, it caches the first brightness, and each time a new brightness is subsequently received, the new brightness is used as the latest cached brightness. In the embodiment of the present application, the noise algorithm library caches the acquired target image and brightness value to the data repository. The target image and brightness value stored in the data repository can both be recorded as screen data, that is, the screen data stored in the data repository includes: target image and brightness value.
[0230] In addition, in order to describe the transmission relationship between the target image, the brightness to be adjusted, and other parameters, the embodiment of the present application is described as an example in which the HWC sends the target image, the brightness to be adjusted, and other parameters to the noise algorithm library. In actual application, the relationship between the HWC and the noise algorithm library is that the HWC calls the noise algorithm library. When the HWC calls the noise algorithm library, the HWC inputs the target image (the storage address of the target image) and the brightness to be adjusted as independent variables of the calculation model in the noise algorithm library to the noise algorithm library. Other parameters will not be given as examples one by one.
[0231] Since brightness adjustment and image refresh are two completely independent processes, the image may be refreshed at a certain moment while the brightness remains unchanged. In this case, the target image corresponding to the refreshed image and the current brightness (the brightness value stored in the noise algorithm library before the time indicated by the timestamp of the target image) are used to calculate the fusion noise at this moment. For the sake of convenience, the fusion noise calculated due to image refresh at the image refresh moment can be recorded as the image noise at the image refresh moment. Similarly, if the image is not refreshed at a certain moment but the brightness is adjusted, the fusion noise at this moment is calculated using the adjusted brightness and the current target image (the target image stored in the noise algorithm library before the time indicated by the timestamp of the brightness value). For the sake of convenience, the fusion noise calculated due to brightness adjustment at the brightness adjustment moment can be recorded as the backlight noise at the brightness adjustment moment.
[0232] The target image and brightness sent by the HWC to the noise algorithm library are both timestamped. Accordingly, the image noise and backlight noise calculated by the noise algorithm library are also timestamped. The image noise timestamp is the same as the target image timestamp, and the backlight noise timestamp is the same as the brightness to be adjusted. The image noise timestamp should strictly be the image refresh time. In practical applications, other time points close to the image refresh time can also be used as the image refresh time. For example, the start time (or end time, or any time between the start and end time) when the HWC executes the cutout operation from the CWB memory to obtain the target image is used as the image refresh time. The backlight noise timestamp should strictly be the backlight adjustment time. In practical applications, other time points close to the backlight adjustment time can also be used as the backlight adjustment time. For example, the start time (or end time, or any time between the start and end time) when the HWC executes the brightness to be adjusted from the core node is used as the brightness adjustment time. The image noise timestamp and backlight noise timestamp facilitate subsequent denoising of the initial ambient light collected by the ambient light sensor over a time span to obtain the target ambient light. The noise algorithm library stores the image noise and backlight noise in the noise memory. When the noise algorithm library stores the image noise, it also stores the timestamp of the image noise. When the noise algorithm library stores the backlight noise, it also stores the timestamp of the backlight noise.
[0233] After startup (typically, the ambient light sensor starts up after the electronic device is powered on), the ambient light sensor (ALS) in the SCP processor's hardware layer collects initial ambient light information at a specific acquisition cycle. The SCP processor's ambient light sensor transmits this initial ambient light information to the ambient light sensor driver (ALSDRV) in the SCP processor's hub driver layer (Hub DRV), as shown in step E2.
[0234] At the SCP processor's hub driver (Hub DRV) layer, the ambient light sensor driver (ALS DRV) preprocesses the initial ambient light information to generate raw values for the four RGBC channels. The SCP processor's hub driver layer transmits these raw values to the ambient light sensor application at the SCP processor's hub application layer (see step E3).
[0235] The ambient light sensor of the cooperative application layer of the SCP processor sends the raw values on the four RGBC channels and other related data (for example, the start time and end time of each initial ambient light acquisition by the ambient light sensor) to the HWC of the AP processor through the first inter-core communication (communication between the ambient light sensor application of the SCP processor and the HWC of the AP processor), see step E4.
[0236] After the HWC in the AP processor obtains the initial ambient light data reported by the SCP processor, the HWC in the AP processor may send the initial ambient light data to the noise algorithm library (see step A6).
[0237] As previously mentioned, the noise algorithm library can calculate the image noise at the image refresh moment and the backlight noise at the brightness adjustment moment, and store the calculated image noise and backlight noise in the noise memory within the noise algorithm library. In practical applications, the noise algorithm library can not only calculate the image noise at the image refresh moment and the backlight noise at the brightness adjustment moment, but can also, after obtaining the acquisition start and end times of the initial ambient light, obtain the integrated noise between the acquisition start and end times of the initial ambient light based on the image noise and backlight noise stored in the noise memory. The noise algorithm library deducts the integrated noise between the acquisition start and end times of the initial ambient light from the initial ambient light to obtain the target ambient light.
[0238] It can be understood from the description of the above noise algorithm library that the noise calculation library contains a variety of calculation models. For example, the first algorithm model is used to calculate and obtain the fused noise based on the target image and brightness. The second algorithm model is used to obtain the integral noise between the acquisition start time and the acquisition end time of the initial ambient light based on the fused noise at each moment. The third algorithm model is used to obtain the target ambient light based on the initial ambient light and the integral noise. In actual applications, the noise algorithm library may also include other calculation models. For example, in the process of obtaining the target ambient light based on the target image, brightness, and initial ambient light, if the raw values on the four channels of the initial ambient light are filtered, then there is a model for filtering the raw values on the four channels of the initial ambient light. The embodiments of this application will not cite other models one by one.
[0239] The noise algorithm library's inputs include the target image and brightness captured by the HWC at various times, and the initial ambient light data obtained by the HWC from the SCP processor. The noise algorithm library's output is the raw value of the target ambient light, which can be recorded as the second value. In this embodiment of the present application, the process of the HWC sending the target image, brightness, and initial ambient light to the noise algorithm library is referred to as step A6.
[0240] After obtaining the target ambient light, the noise calculation library needs to return the target data to the HWC. This process is recorded as step A7. In actual applications, the output of the noise algorithm library is the raw value of the target ambient light on the four channels.
[0241] The HWC in the AP processor sends the raw values of the four channels of the target ambient light returned by the noise algorithm library to the ambient light sensor application in the cooperative application layer of the SCP processor through the first inter-core communication, see step A8.
[0242] After obtaining the raw values of the four channels of target ambient light, the ambient light sensor of the co-driving layer of the SCP processor stores the raw values of the four channels of target ambient light in the ambient light memory of the co-driving layer (see step E5).
[0243] The SCP processor's co-driver layer includes a calculation module. This calculation model obtains the raw values of the four target ambient light channels from memory (see step E6). At the end of each integration, the ambient light sensor generates an integration interrupt signal, which it sends to the ambient light sensor driver. The ambient light sensor driver then calls the calculation module, triggering the calculation model to obtain the raw values of the four target ambient light channels from memory.
[0244] Since the ambient light sensor driver triggers the calculation module to obtain the raw value of the target ambient light only after the current integration is completed, the raw value of the target ambient light obtained at this time is the raw value of the target ambient light in the previous integration period.
[0245] by Figure 8 Taking the illustrated embodiment as an example, after the integration ends at time t1, the ambient light sensor obtains the initial ambient light from time t0 to time t1. The SCP processor sends the initial ambient light from time t0 to time t1 to the AP processor, which then calculates and obtains the raw value of the target ambient light from time t0 to time t1. The AP processor then sends the raw value of the target ambient light from time t0 to time t1 to the SCP processor. The SCP processor then stores the raw value of the target ambient light from time t0 to time t1 in its memory.
[0246] After the integration completes at time t3, the ambient light sensor obtains the initial ambient light from time t2 to time t3, and the SCP processor sends the initial ambient light from time t2 to time t3 to the AP processor. Each time the ambient light sensor completes integration, an integration interrupt signal is generated. The ambient light sensor sends this integration interrupt signal to the ambient light sensor driver, which calls the calculation module, triggering the calculation model to obtain the currently stored raw value of the target ambient light from time t0 to time t1 from the memory. Since this is after time t3, the calculation module calculates the lux value of the target ambient light after time t3 based on the raw value of the target ambient light from time t0 to time t1. In other words, the lux value of the target ambient light calculated by the SCP processor during period T2 is the lux value of the actual ambient light during period T1.
[0247] As previously mentioned, the ambient light sensor in the SCP processor generates an integration interrupt signal (which is sent to the ambient light sensor driver) after integration completes (time t3). After time t3, the initial ambient light for period T2 is sent to the AP processor. Only after the AP processor calculates the target ambient light does it send the target ambient light for period T2 to the SCP processor, which then stores the target ambient light for period T2 in memory. If the SCP processor uses the raw value of the target ambient light for period T2 to calculate the lux value, it must wait from the moment the ambient light sensor driver receives the integration interrupt signal until the AP processor transmits the target ambient light to the SCP processor's memory. Only then can the ambient light sensor driver in the SCP processor invoke the calculation module to retrieve the raw value of the target ambient light for period T2 from memory. This waiting period is determined by at least the time corresponding to the SCP processor sending the initial ambient light to the AP processor, the AP processor calculating the target ambient light based on the initial ambient light and other relevant data, and the AP processor sending the target ambient light to the SCP processor's memory. This waiting period is relatively long and variable. Therefore, the ambient light sensor driver in the SCP processor can be configured to call the calculation module to retrieve the raw value of the target ambient light from the previous cycle from the memory upon receiving the integration interrupt signal from the second data acquisition cycle, and then calculate the lux value based on the raw value of the target ambient light from the previous cycle. The lux value of the target ambient light can be recorded as the third value, and the third value and the second value are the lux value and raw value of the same target ambient light.
[0248] The calculation module in the SCP processor's cooperative driver layer calculates the lux value of the target ambient light based on the raw values of the four target ambient light channels. The calculation module in the SCP processor sends the calculated lux value of the target ambient light to the ambient light sensor application in the cooperative application layer through the interface of the cooperative framework layer (see steps E7 and E8).
[0249] The ambient light sensor application of the cooperative application layer in the SCP processor transmits the lux value of the target ambient light to the light service (lightservice) of the native framework layer in the AP processor through the second inter-core communication (communication from the SCP processor to the light service of the AP processor), see step E9.
[0250] The LightService can send the lux value of the target ambient light to the Display Engine Service. The Display Engine Service can send this lux value to the upper layer so that applications in the application layer can determine whether to adjust the brightness. The Display Engine Service can also send this lux value to the kernel node so that the relevant hardware can adjust the brightness of the display based on the lux value of the target ambient light stored in the kernel node.
[0251] After describing the technical architecture on which the method for obtaining the target ambient light depends, the process of obtaining the target ambient light based on the target image, brightness, and initial ambient light collected by the ambient light sensor will be described from the perspective of the acquisition cycle of the ambient light sensor.
[0252] As can be understood from the above example, the target image and the brightness to be adjusted are both acquired by the HWC. Therefore, there is a sequential order in the HWC's acquisition of the target image and the brightness to be adjusted. After the HWC acquires the target image or the brightness to be adjusted, it sends the target image or the brightness to be adjusted to the noise algorithm library. The HWC also sends the target image or the brightness to be adjusted to the noise algorithm library in a sequential order. Accordingly, there is also a sequential order in the time at which the noise algorithm library receives the target image and the brightness to be adjusted. However, even if there is a sequential order in the time at which the noise algorithm library receives the target image and the brightness to be adjusted, since the HWC may acquire the target image and the brightness to be adjusted at the same time scale, the timestamps of the target image and the brightness to be adjusted may be the same. As an example, within the same millisecond (the 5th millisecond), the HWC first executes the acquisition of the brightness to be adjusted and then executes the acquisition of the target image. Although there is a sequential order in the HWC's execution, the timestamps of the target image and the brightness to be adjusted are both the 5th millisecond.
[0253] See also Figure 8 The ambient light sensor collects ambient light in a certain time period T. The ambient light sensor collects light from t0 to t2 (collection period T1), from t2 to t4 (collection period T2), and from t4 to t6 (collection period T3) each constitutes a collection period. Within the collection period T1, the actual collection time of the ambient light sensor is from t0 to t1. The ambient light sensor can be in a dormant state during the period from t1 to t2. The embodiments of the present application are described as follows: the ambient light collection period is fixed (i.e., the values of T1, T2, and T3 are the same) and the duration of the integration period is fixed.
[0254] As an example, a collection period of 350ms (t2-t0) can be used. During a collection period, the ambient light sensor actually collects data for 50ms (t1-t0). Therefore, during a collection period, the ambient light sensor is in a dormant state for 300ms (t2-t1). The 350ms, 50ms, and 300ms in the above examples are for illustrative purposes only and are not intended to be limiting.
[0255] For ease of description, the time period during which the ambient light sensor actually collects light (eg, t0 to t1) can be recorded as the integration time period, and the time period during which the ambient light sensor does not start collecting light (eg, t1 to t2) can be recorded as the non-integration time period.
[0256] The image displayed on the display of an electronic device is refreshed at a certain frequency. Taking 60Hz as an example, it is equivalent to refreshing the display of the electronic device 60 times per second, or refreshing the image every 16.7ms. Therefore, when the display of the electronic device displays an image, the image refresh will occur during the acquisition cycle of the ambient light sensor. When the image displayed on the display is refreshed, the AP processor executes Figure 7 In the technical architecture shown, steps A1 to A6 (sending the target image) are executed repeatedly as long as the image is refreshed, starting from time t0, by the HWC in the AP processor, which controls the CWB to write back continuously.
[0257] It should be noted that the embodiment of the present application takes a refresh rate of 60 Hz as an example. In actual applications, a refresh rate of 120 Hz or other refresh rates can also be used. The embodiment of the present application takes the above steps A1 to A6 (sending the target image) as an example, where each frame is refreshed. In actual applications, the above steps A1 to A6 (sending the target image) can also be repeated every frame (or two frames, etc.).
[0258] However, brightness adjustment does not have a fixed periodicity, so brightness adjustment may also occur during the ambient light sensor's acquisition cycle. When brightness adjustment occurs, HWC also performs Figure 7 Steps A5' to A6 (sending the brightness to be adjusted) in the technical architecture shown.
[0259] After each integration of the ambient light sensor (i.e., after t1, after t3, after t5, etc.), the SCP processor reports the initial ambient light data collected during this integration process (for example, the raw values of the four channels of the initial ambient light and the integration start and end times of this integration process) to the HWC of the AP processor. The HWC of the AP processor sends the relevant data of the initial ambient light to the noise algorithm library, which calculates the target ambient light through the noise algorithm library.
[0260] See also Figure 9 , taking one acquisition cycle as an example, at t 01 Time (the same time as t0), t 03 time, t 04 time and t 11 The time is the image refresh time, at t 02 time and t 12 The moment is the brightness adjustment moment. Therefore, the AP processor can calculate t in real time. 01 Image noise at time t 02 Backlight noise at time t 03 Image noise at time t 04 Image noise at time t 11The image noise and t 12 After the integration ends (time t1), the noise memory of the AP processor stores: 01 Image noise at time t 02 Backlight noise at time t 03 The image noise and t 04 Image noise at the moment.
[0261] After the integration ends (time t1), the ambient light sensor obtains the initial ambient light and the integration time period. The SCP processor reports the initial ambient light data to the AP processor. The noise calculation module in the AP processor obtains the t1 from the noise memory according to the start and end time of the integration time period. 01 Image noise at time t 02 Backlight noise at time t 03 Image noise at time t 04 The noise calculation library calculates the target ambient light based on the initial ambient light collected during the integration period and the image noise and backlight noise that affect this integration period.
[0262] During the non-integration period (t1 to t2), since HWC always controls CWB write back, HWC has no effect on t 11 The refresh image at the moment is also cut out to obtain the target image, and the noise algorithm library also calculates t 11 Image noise at time t. Non-integration time period t 12 The brightness changes at every moment, and the noise algorithm library also calculates t 12 However, when calculating the target ambient light, the fusion noise required is the fusion noise that interferes with the initial ambient light obtained during this integration period. Therefore, there is no need to 11 The image noise and t 12 The backlight noise at the moment can also be used to obtain the target ambient light of this integration period. In practical applications, the noise algorithm library computer obtains t 11 The image noise and t 12 After the backlight noise of the moment, it is also necessary to 11 The image noise and t 12 The backlight noise at each moment is stored in the noise memory.
[0263] The above examples are based on Figure 7 From the perspective of technical architecture, based on Figure 9 The process of acquiring target ambient light is described from the perspective of the acquisition cycle of the ambient light sensor. Figure 7 The technical architecture shown and Figure 9The following describes one acquisition cycle of the ambient light sensor Figure 10 The illustrated embodiment provides a timing process diagram for acquiring target ambient light.
[0264] The above description clearly shows that the AP processor's image noise calculation process triggered by image refresh, backlight noise calculation triggered by brightness adjustment, and initial ambient light acquisition by the SCP processor are independent and have no sequential order. The AP processor's noise algorithm library processes the target image, brightness, and initial ambient light obtained from these three independent processes to produce the target ambient light.
[0265] Figure 10 The step numbers and Figure 7 The same step numbers in the technical architecture shown here indicate that the same steps are being performed. Figure 7 The details of the embodiment shown are described in detail in Figure 10 The illustrated embodiment will be briefly described.
[0266] Combine Figure 9 , starting from time t0, the image is refreshed. At the same time, the ambient light sensor enters an integration period and starts to collect the initial ambient light.
[0267] Accordingly, in Figure 10 In step E1, the ambient light sensor in the hardware layer of the SCP processor enters an integration period, from t0 (t 01 ) moment to start collecting the initial ambient light.
[0268] Step A1, image t0(t 01 ) is refreshed at all times. SurfaceFlinger in the native framework layer of the AP processor sends the display parameters of the interface to the HWC in the hardware abstraction layer of the AP processor. The HWC can send the display parameters of each layer of the interface sent by SurfaceFlinger to the hardware at the bottom of the HWC. The hardware at the bottom of the HWC obtains the composite image of each layer of the interface based on the display parameters of each layer of the interface. The hardware at the bottom of the HWC returns the composite image to the HWC.
[0269] In step A2, the HWC in the hardware abstraction layer of the AP processor sends the synthesized image to the OLED driver in the core layer of the AP processor.
[0270] In step A3, the OLED driver in the core layer of the AP processor sends the synthesized image to the display subsystem in the hardware layer of the AP processor.
[0271] In step A4, the display subsystem in the hardware layer of the AP processor stores the image before display in the CWB memory in the core layer of the AP processor.
[0272] In an embodiment of the present application, after the HWC sends the synthesized image to the OLED driver, the HWC will wait for a storage success signal sent by the display subsystem.
[0273] After the display subsystem successfully stores the pre-display image in the CWB memory, it sends a successful storage signal to the HWC. Upon receiving the successful storage signal from the display subsystem, the HWC extracts the target image from the pre-display image stored in the CWB memory in the kernel layer.
[0274] In step A5, the HWC in the hardware abstraction layer of the AP processor obtains the target image by clipping the image before display stored in the CWB memory in the kernel layer.
[0275] Step A6: After the HWC in the hardware abstraction layer of the AP processor obtains the target image, it sends the target image to the noise algorithm library of this layer. After receiving the target image, the noise algorithm library calculates t based on the target image and the current brightness information cached. 01 During the execution of steps A1 to A6, the ambient light sensor in the hardware layer of the SCP processor is in the integration process within one acquisition cycle.
[0276] Combine Figure 9 , at t 02 At this moment, the ambient light sensor is still in the integration period and is collecting the initial ambient light. 02 At this moment, the brightness of the display changes, triggering the execution Figure 10 Step B1 in .
[0277] exist Figure 10 In step B1( Figure 7 In step A5′ of the architecture shown, the HWC of the hardware abstraction layer of the AP processor obtains t from the core node in the core layer of the AP processor. 02 Brightness information at the moment.
[0278] Step B2 (step A6), the HWC of the hardware abstraction layer of the AP processor will 02 The brightness information at the moment is sent to the noise algorithm library, and the noise algorithm library 02 The brightness information at the moment and the cached target image currently displayed are calculated to obtain t 02 Backlight noise at all times.
[0279] During the execution of step B1 to step B2, the ambient light sensor in the auxiliary hardware layer of the SCP processor is always in the integration process within one acquisition cycle.
[0280] After step B2, the noise memory of the noise algorithm library stores t 01 The image noise and t 02 Backlight noise at all times.
[0281] Combine Figure 9 , at t 03 At this moment, the ambient light sensor is still in the integration period and is collecting the initial ambient light. 03 At this moment, the image is refreshed.
[0282] exist Figure 10 Since the image is refreshed, steps C1 to C6 are continued to be executed. Steps C1 to C6 can refer to the descriptions in A1 to A6 and are not repeated here.
[0283] During the execution of steps C1 to C6, the ambient light sensor in the auxiliary hardware layer of the SCP processor is still in the integration process within one acquisition cycle.
[0284] After step C6, the noise memory of the noise algorithm library stores t 01 Image noise at time t 02 Backlight noise at time t 03 Image noise at the moment.
[0285] See also Figure 9 , at t 04 At this moment, the ambient light sensor is still in the integration period and is collecting the initial ambient light. 04 At this moment, the image is refreshed.
[0286] exist Figure 10 Since the image is refreshed, steps D1 to D6 are continued to be executed. Steps D1 to D6 can refer to the descriptions in A1 to A6 and are not repeated here.
[0287] During the execution of steps D1 to D6, the ambient light sensor in the auxiliary hardware layer of the SCP processor is still in the integration process within one acquisition cycle.
[0288] After step D6, the noise memory of the noise algorithm library stores t 01 Image noise at time t 02 Backlight noise at time t 03 The image noise and t 04 Image noise at the moment.
[0289] Combine Figure 9At time t1, the ambient light sensor integration ends. After the ambient light sensor integration ends (time t1), the ambient light sensor obtains the initial ambient light. Figure 10 In the process, the SCP processor starts to execute steps E2, E3, and E4, and sends the relevant data of the initial ambient light (raw values on the four RGBC channels, integration start time, and integration end time) to the HWC of the hardware abstraction layer of the AP processor.
[0290] Combine Figure 9 , during the non-integration period, the image may also be refreshed (e.g., t 11 The image is refreshed at that moment), and the brightness may also change (for example, t 12 Therefore, during the non-integration period, Figure 10 Steps F1 to F6 still exist in Figure 10 Steps F1 to F5 are omitted, and specific reference may be made to steps A1 to A5), so that t 11 The image noise at the moment is stored in the noise memory of the noise algorithm library. In the non-integration time period, there are still steps G1 to G2 ( Figure 9 Step G1 is omitted, and the details can be referred to step B1), so that t 12 The backlight noise at each moment is stored in the noise memory of the noise algorithm library.
[0291] In step A6', the HWC in the hardware abstraction layer of the AP processor sends the initial ambient light data to the noise algorithm library. The noise algorithm library calculates the target ambient light based on the initial ambient light data and the image noise and backlight noise that interfere with the initial ambient light.
[0292] pass Figure 10 It can be understood that the integration start and end times of the ambient light sensor are controlled by the clock corresponding to the ambient light sensor; the process of calculating image noise by the AP processor is controlled by the image refresh clock; and the process of calculating backlight noise by the AP processor is controlled by the backlight adjustment time. Therefore, the execution of step A1 (or, step C1, step D1, step F1) is triggered by the image refresh. The execution of step B1 (or step G1) is triggered by the brightness adjustment. The integration start and end times of the ambient light sensor are completely based on the pre-set acquisition cycle and the duration of each integration. Therefore, the execution of step E2 is triggered by the end of the ambient light sensor integration.
[0293] From the perspective of the triggering event, these three processes are completely independent. However, the results obtained by these three processes (image noise, backlight noise, and initial ambient light) are linked together through the denoising process after the ambient light sensor integration period ends. The initial ambient light integrated in the denoising process is the initial ambient light collected by the ambient light sensor in the current acquisition cycle, and the image noise and backlight noise removed during the denoising process are image noise and backlight noise that may interfere with the initial ambient light collected in the current acquisition cycle.
[0294] By analyzing the structure of the ambient light under the screen, the embodiment of the present application can obtain: the factors that interfere with the ambient light collected by the ambient light sensor include the display content of the display area directly above the photosensitive area of the ambient light sensor and directly above a certain area around the photosensitive area of the ambient light sensor. The display content is divided into two parts: the RGB pixel information and the brightness information of the displayed image. Therefore, the noise calculation library in the embodiment of the present application obtains the fused noise by fusing the RGB pixel information and the brightness information of the target image. Then, the integral noise of the integral time period of the initial ambient light is obtained based on the fused noise. The target ambient light is obtained by removing the integral noise that interferes with the initial ambient light obtained from the integration time period of the ambient light sensor. Since the interfering part is removed, accurate target ambient light can be obtained, and the versatility is strong.
[0295] In addition, since the AP processor of the electronic device can obtain the target image and brightness information, the AP processor also obtains image noise and backlight noise. The SCP processor can obtain the initial ambient light. Therefore, the SCP processor can send the initial ambient light to the AP processor, which then processes the initial ambient light and the fused noise to obtain the target ambient light. This avoids the problem of the AP processor frequently sending the target image (or image noise) and brightness information (or backlight noise) to the SCP processor, which would result in excessive inter-core communication and high power consumption.
[0296] Furthermore, the DSS in the AP processor can store the pre-display image (the image to be displayed in the current refresh) in the CWB memory. The HWC in the AP processor extracts the target image from the pre-display image stored in the CWB memory to calculate the fused noise. This method generates accurate fused noise with low power consumption.
[0297] It should also be noted that the brightness of the display screen needs to be adjusted according to the target ambient light only when the display screen displays an image. When the display screen does not display any image, it is not necessary to adjust the brightness of the display screen according to the target ambient light. Therefore, the AP processor also needs to monitor the screen turning on and off events of the display screen. When the screen is on, the target ambient light detection method provided in the embodiment of the present application is executed. When the screen is off, the AP processor may not execute steps A4 to A6. Similarly, the SCP processor may also control the ambient light sensor to stop collecting the initial ambient light when the screen is off, and the SCP processor may no longer execute steps E2 to E5.
[0298] In order to have a clearer understanding of the execution inside the AP processor, the timing diagram between the various modules inside the AP processor is described. Figure 10 In the embodiment shown, t is obtained 01 Image noise at time t 02 The backlight noise at the moment is used as an example to describe it.
[0299] Figure 11 In the illustrated embodiment, when refreshing an image, each module in the AP processor performs the following steps:
[0300] In step 1100 , after the display engine service obtains the display parameters of the interface to be displayed from the application in the application layer, the display engine service sends the display parameters of the interface to be displayed to SurfaceFlinger.
[0301] In step 1101, after SurfaceFlinger obtains the display parameters of the interface to be displayed of application A from the display engine service, it sends the display parameters (for example, memory address, color, etc.) of each interface (the interface to be displayed of application A, the status bar interface, etc.) to HWC through the interface (for example, setLayerBuffer, setLayerColor).
[0302] Step 1102: After the HWC receives the display parameters of each interface, the HWC obtains a synthesized image according to the display parameters of the interface to be displayed through the hardware at the bottom of the HWC.
[0303] Step 1103: After the HWC obtains the image synthesized by the underlying hardware, it sends the synthesized image to the OLED driver.
[0304] Step 1104: After receiving the synthesized image sent by the HWC, the OLED driver sends the synthesized image to the display subsystem.
[0305] Step 1105: After receiving the synthesized image, the display subsystem performs secondary processing on the synthesized image to obtain the image before display.
[0306] Step 1106: The display subsystem stores the image before display in the CWB memory.
[0307] It should be noted that since the OLED screen needs to refresh the image, the display subsystem also needs to send the image before display to the display screen for display.
[0308] In the embodiment of the present application, the step of the display subsystem sending the image before display to the display screen for display and the step of the display subsystem storing the image before display in the CWB memory are two independent steps and there is no strict order of precedence.
[0309] Step 1107: After the display subsystem successfully stores the image before display in the CWB memory, it can send a storage success signal to the HWC.
[0310] Step 1108: After receiving the signal of successful storage, the HWC cuts out the target image from the image before display stored in the CWB memory, and the moment when the HWC starts to execute the acquisition of the target image is used as the timestamp of the target image.
[0311] Step 1109: After the HWC obtains the target image and timestamp, it sends the target image and timestamp to the noise algorithm library.
[0312] Step 1110: The noise algorithm library calculates and obtains the image noise (t 01 The timestamp of the image noise is the timestamp of the target image for obtaining the image noise. The noise algorithm library stores the image noise and the timestamp of the image noise.
[0313] When adjusting brightness, each submodule in the AP processor performs the following steps:
[0314] In step 1111 , after the display engine service obtains the brightness to be adjusted from application A in the application layer, the display engine service sends the brightness to be adjusted to the kernel node.
[0315] In step 1112, after the HWC monitors the data change in the core node, it obtains the brightness to be adjusted from the core node. The time when the HWC obtains the brightness to be adjusted from the core node is the timestamp of the brightness to be adjusted.
[0316] In actual applications, HWC has been monitoring whether there are any data changes in the kernel nodes.
[0317] In step 1113, the HWC sends the timestamp of the adjusted brightness and the brightness to be adjusted to the noise algorithm library.
[0318] Step 1114: The noise algorithm library calculates and obtains the backlight noise (t 02 The timestamp of the backlight noise is the timestamp of the brightness to be adjusted when the backlight noise is obtained. The noise algorithm library stores the backlight noise and the timestamp of the backlight noise.
[0319] After an integration period ends, the SCP processor sends the initial ambient light collected during the integration period to the HWC in the AP processor.
[0320] In step 1115, the HWC of the AP processor receives the initial ambient light and the integration start time and integration end time of the initial ambient light sent by the SCP processor.
[0321] In step 1116, after the HWC receives the initial ambient light and the integration start time and integration end time of the initial ambient light sent by the SCP processor, it sends the initial ambient light and the integration start time and integration end time of the initial ambient light to the noise algorithm library.
[0322] In step 1117, the noise algorithm library calculates the integrated noise based on the image noise and the corresponding timestamp, the backlight noise and the corresponding timestamp, and the integration start time and integration end time of the initial ambient light. The noise algorithm library calculates the backlight noise based on the integrated noise and the initial ambient light.
[0323] The embodiment of the present application focuses on describing the timing logic diagram between various modules when the AP processor obtains the target ambient light.
[0324] The following will introduce Figure 7 The noise algorithm library in the illustrated embodiment calculates a process of obtaining the target ambient light according to the target image, brightness, and initial ambient light.
[0325] In step 1, each time the noise calculation library obtains a target image, it calculates the image noise at the target image refresh moment based on the target image and the brightness of the display screen at the target image refresh moment; each time the noise calculation library obtains a brightness, it calculates the backlight noise at the brightness adjustment moment based on the brightness and the target image at the brightness adjustment moment.
[0326] Although image noise and backlight noise have different names, the calculation process is both based on a frame of target image and a brightness value.
[0327] The target image consists of multiple pixels. First, a weighted sum calculation is performed based on the RGB value of each pixel and its weighting coefficient to obtain the weighted RGB value of the target image. The weighting coefficient for each pixel is determined by the distance between the pixel's coordinates and the reference coordinates of the target image. The coordinates of the center point of the ambient light sensor's photosensitive area can be used as the reference coordinates of the target image.
[0328] In step 2, the noise calculation library calculates the fused noise based on the weighted RGB values and brightness of the target image. This fused noise can be calculated using a table lookup (where the table contains the fused noise corresponding to the weighted RGB values and brightness of the target image) or a pre-set function (where the independent variables are the weighted RGB values and brightness of the target image, and the dependent variable is the fused noise). The fused noise obtained in this case is the raw value of the four channels.
[0329] Step 3: The noise calculation library calculates the integrated noise within the integration time period of the initial ambient light based on the fused noise at each moment.
[0330] It's important to note that image noise isn't generated by the image refresh process itself. During the integration period, the interference with the initial ambient light before the image refresh is the image noise corresponding to the pre-refresh image. During the period after the image refresh, the interference with the initial ambient light is the image noise corresponding to the refreshed image.
[0331] Similarly, backlight noise isn't generated by the brightness adjustment process itself. During the integration period, the interference with the initial ambient light before brightness adjustment is the backlight noise corresponding to the pre-adjustment brightness. During the period after brightness adjustment, the interference with the initial ambient light is the backlight noise corresponding to the adjusted brightness.
[0332] As mentioned above, the noise memory stores the image noise and backlight noise at each moment calculated by the noise algorithm library. The noise stored in the noise memory is collectively referred to as fusion noise.
[0333] Step A1: The AP processor retrieves the fused noise from the exit position of the noise memory through the noise algorithm library, and updates the exit position of the noise memory or the fused noise at the exit position through the noise algorithm library.
[0334] Step B1: If the timestamp corresponding to the currently retrieved fused noise is at or before the first time, the AP processor continues to execute step A1 through the noise algorithm library until the currently retrieved fused noise is after the first time.
[0335] Step B2: If the currently retrieved fusion noise is after the first time, the AP processor performs the following steps using the noise algorithm library:
[0336] Step C1: If the timestamp of the currently retrieved fusion noise is for the first time after the first time and before the second time, then calculate the integrated noise between the first time and the time corresponding to the timestamp of the currently retrieved fusion noise based on the previously retrieved fusion noise, and continue executing from step A1;
[0337] Step C2: If the timestamp of the currently retrieved fusion noise is after the first time for the first time and is at or after the second time, then calculate the integrated noise between the first time and the second time based on the previously retrieved fusion noise, and continue to execute step D1;
[0338] Step C3: If the timestamp of the currently retrieved fusion noise is not the first time after the first time and is before the second time, then calculate the integrated noise between the time corresponding to the timestamp of the previously retrieved fusion noise and the time corresponding to the timestamp of the currently retrieved fusion noise based on the previously retrieved fusion noise; and continue executing from step A1;
[0339] Step C4: If the timestamp of the currently retrieved fusion noise is not the first time after the first time, and is at or after the second time, then calculate the integrated noise between the time corresponding to the timestamp of the last retrieved fusion noise and the second time based on the last retrieved fusion noise, and continue to execute step D1;
[0340] Step D1 : obtaining target ambient light according to the integrated noise between the first time and the second time and the initial ambient light.
[0341] The first time is the start time of an integration time period, and the second time is the end time of the same integration time period.
[0342] When the noise memory is a FIFO (First Input First Output) memory, a dual-port buffer with a first-in, first-out mechanism is used. A FIFO memory has two ports: one for input and one for output. In this memory structure, the first data that enters the memory is the first to be removed. Accordingly, the order in which data is removed is the same as the order in which data was entered. The FIFO memory's exit location is the storage address corresponding to the FIFO memory's output port.
[0343] When the FIFO memory moves out a data, the process is as follows: starting from the exit position (the first position), the fusion noise stored in the exit position is removed, then the data in the second position starting from the exit position is moved to the exit position, and the data in the third position starting from the exit position is moved to the second position starting from the exit position, and so on.
[0344] Of course, in actual applications, after removing the fused noise stored in the first position (A1) starting from the exit position (the first position, A1), the exit position of the memory can be updated to the second position (A2). After removing the fused noise stored in the current exit position (A2) again, the exit position of the memory is updated to the third position (A3), and so on.
[0345] The process of obtaining the target ambient light based on the above calculation can be referred to Figure 12 The embodiments to Figure 14 The embodiment shown.
[0346] See also Figure 12 , Figure 12 The noise calculation library in the AP processor provided in the embodiment of the present application calculates the process of integrating noise based on image noise and backlight noise. Figure 9 and Figure 10 Description of each moment in the embodiment shown: at t 01 Refresh the image at all times and obtain t 01 Image noise at time t 02 Adjust the brightness at all times to obtain t 02 Backlight noise at time t 03 Refresh the image at all times and obtain t 03 Image noise at time t 04 Refresh the image at all times and obtain t 04 Image noise at the moment.
[0347] From t 01 Time to t 02 At time t, the displayed image is 01 The image is refreshed at time t, and the display brightness is t 01 Brightness at the moment (t 01 The brightness at the moment is the brightness value stored in the noise algorithm library at t 01 The latest stored brightness value before the moment t 01 The image noise at time t 01 The image refreshed at time t 01 Therefore, the initial ambient light contains noise with a duration of "t 02 -t 01 ", timestamp is t01 image noise.
[0348] From t 02 Time to t 03 At time t, the brightness of the display is 02 After the brightness is adjusted at all times, the image displayed on the display is t 01 The image after refresh at time t 02 The backlight noise at time t 02 The brightness after adjustment is displayed on the screen. 01 Therefore, the initial ambient light contains noise with a duration of "t 03 -t 02 ", timestamp is t 02 Backlight noise at all times.
[0349] From t 03 Time to t 04 At time t, the displayed image is 03 The image is refreshed at time t, and the display brightness is t 02 Brightness after adjustment at any moment, t 03 The image noise at time t 03 The image refreshed at time t 02 Therefore, the initial ambient light contains noise with a duration of "t 04 -t 03 ", timestamp is t 03 image noise.
[0350] From t 04 From time t to time t1, the displayed image is t 04 The image is refreshed at time t, and the display brightness is t 02 Brightness after adjustment at any moment, t 04 The image noise at time t 04 The image refreshed at time t 02 Therefore, the initial ambient light contains noise with a duration of "t1-t 04 ", timestamp is t 04 image noise.
[0351] Based on the above understanding, when calculating the integrated noise, the AP processor:
[0352] t 01 The image noise at time t 01 Time to t 02 The initial ambient light at the moment causes interference;
[0353] t 02Backlight noise at time t 02 Time to t 03 The initial ambient light at the moment causes interference;
[0354] t 03 The image noise at time t 03 Time to t 04 The initial ambient light at the moment causes interference;
[0355] t 04 The image noise at time t 04 The initial ambient light from time t to time t1 causes interference.
[0356] Therefore, we can calculate t 01 Time to t 02 The integrated noise at time t 02 Time to t 03 The integrated noise at time t 03 Time to t 04 The integrated noise at time t 04 The integrated noise from time t to time t1.
[0357] For t 01 Time to t 02 The integrated noise at the moment is: (t 02 -t 01 ) / (t1-t0)×N t01 .
[0358] For t 02 Time to t 03 The integrated noise at the moment is: (t 03 -t 02 ) / (t1-t0)×N t02 .
[0359] For t 03 Time to t 04 The integrated noise at the moment is: (t 04 -t 03 ) / (t1-t0)×N t03 .
[0360] For t 04 The integrated noise from time to time t1 is: (t1-t 04 ) / (t1-t0)×N t04 .
[0361] Among them, N t01 Indicates t 01 The fusion noise at time N t02 Indicates t 02 The fusion noise at time N t03 Indicates t03 The fusion noise at time N t04 Indicates t 04 The fusion noise of the moment.
[0362] Each sub-time period within the integral time period (t 01 to t 02 , t 02 to t 03 , t 03 to t 04 , t 04 The integrated noise from t1 to t2 is added together to get the integrated noise of the entire integration period.
[0363] In the above example, the start time of the integration period is exactly the time of image refresh, that is, the image noise at the start time of the integration period can be obtained.
[0364] In practical applications, the integration period may not start at the image refresh or backlight adjustment time. In this case, it is necessary to obtain the fused noise corresponding to the most recent change time (image refresh or backlight adjustment time) before the start of the current integration period.
[0365] See also Figure 13 As shown, the noise calculation library in the AP processor provided in the embodiment of the present application obtains the integration time period (t 01 Schematic diagram of the integrated noise from time t to time t1, t 01 The moment is no longer the start time of this integration period, but an image refresh time within this integration period. The most recent change time (image refresh time or brightness adjustment time) before the start of this integration period is t -1 The moment is the image refresh moment.
[0366] See also Figure 14 As shown in the figure, if the most recent change moment before the start of this integration period is the image refresh moment, the image noise corresponding to the image refresh moment will affect the image from time t0 to t 01 The initial ambient light at the moment causes interference.
[0367] Of course, if the most recent change moment is the brightness adjustment moment, the backlight noise corresponding to the brightness adjustment moment will affect the brightness from t0 to t 01 The initial ambient light at the moment causes interference.
[0368] Figure 14 In the embodiment shown, the integrated noises corresponding to the sub-time periods in the integration time period are respectively:
[0369] For time t0 to t 01 The integrated noise at the moment is: (t01 -t0) / (t1-t0)×N t-1 .
[0370] For t 01 Time to t 02 The integrated noise at the moment is: (t 02 -t 01 ) / (t1-t0)×N t01 .
[0371] For t 02 Time to t 03 The integrated noise at the moment is: (t 03 -t 02 ) / (t1-t0)×N t02 .
[0372] For t 03 Time to t 04 The integrated noise at the moment is: (t 04 -t 03 ) / (t1-t0)×N t03 .
[0373] For t 04 The integrated noise from time to time t1 is: (t1-t 04 ) / (t1-t0)×N t04 .
[0374] Among them, N t-1 Indicates t -1 The fusion noise at time N t01 Indicates t 01 The fusion noise at time N t02 Indicates t 02 The fusion noise at time N t03 Indicates t 03 The fusion noise at time N t04 Indicates t 04 The fusion noise of the moment.
[0375] From the above example, we can understand that the obtained integrated noise is also the raw value of the four channels.
[0376] The timestamps in the above examples are all different. In actual applications, the HWC may execute both the process of acquiring the target image and the process of acquiring the brightness to be adjusted within a time unit (for example, within 1 ms). However, the timestamps of the target image acquired at that moment and the brightness to be adjusted are the same.
[0377] If there is a target image and brightness value with the same timestamp, and the noise algorithm library receives the target image first, the noise algorithm library first calculates the image noise based on the target image and the latest brightness value before the target image. When calculating the backlight noise corresponding to the brightness value, the backlight noise is calculated based on the target image and brightness value with the same timestamp;
[0378] If there is a target image and brightness value with the same timestamp, and the noise algorithm library receives the brightness value first, the noise algorithm library first calculates the backlight noise based on the brightness value and the latest target image before the brightness value. When calculating the image noise corresponding to the target image, the image noise is calculated based on the target image and brightness value with the same timestamp.
[0379] The noise algorithm library receives the target image first, calculates the image noise, and stores it in the noise memory. The fused noise stored in the noise memory is sequentially ordered. Before storing it in the noise memory, the library determines whether the currently stored fused noise is after the timestamp of the previously stored fused noise. If so, the fused noise is stored. If it is before or equal to the timestamp of the previously stored fused noise, the currently stored noise is discarded. Therefore, the backlight noise calculated later is discarded.
[0380] In practical applications, the timestamp of the target image can be the time when the HWC begins to retrieve the target image from the CWB writeback memory. The timestamp of the luminance value can be the time when the HWC begins to retrieve the luminance value from the kernel node. While retrieving the target image, the HWC may switch to retrieving the luminance value. Therefore, although the HWC first retrieves the target image and then retrieves the luminance value, the timestamp of the luminance value is later than the timestamp of the target image. In practical applications, the HWC may first retrieve the luminance value and send it to the noise algorithm library, which calculates and stores the backlight noise. The HWC then retrieves the target image and sends it to the noise algorithm library, which calculates and stores the image noise. This results in the timestamp of the image noise currently being stored representing a time before the timestamp of the previously stored backlight noise.
[0381] Step 4: The noise algorithm library removes the integrated noise of the entire integration time period from the initial ambient light to obtain the target ambient light.
[0382] In this embodiment of the present application, the initial ambient light data sent by the SCP processor to the HWC of the AP processor is in the form of raw values of the four RGBC channels. The HWC also sends the initial ambient light data to the noise algorithm library in the form of raw values of the four RGBC channels. In step 3, the raw values of the four channels of integrated noise are obtained. Therefore, in this step, the four-channel raw values of the initial ambient light and the four-channel raw values of the integrated noise are calculated to obtain the four-channel raw values of the target ambient light.
[0383] After the noise algorithm library calculates the raw values of the four channels of the target ambient light, it can send the raw values of the four channels of the target ambient light to the SCP processor. The SCP processor calculates the lux value of the target ambient light based on the raw values of the four channels of the target ambient light.
[0384] As an example, the lux value may be obtained by weighting the raw value of each channel by a coefficient of each channel (the coefficient may be provided by the manufacturer of the ambient light sensor).
[0385] As previously mentioned, ambient light sensors can detect the initial ambient light in the environment where the electronic device is located using a fixed acquisition cycle and a fixed integration time. However, in some scenarios, using this fixed acquisition cycle and fixed integration time often results in excessive power consumption or a poor user experience.
[0386] In some scenarios, the brightness of the environment where the electronic device is located changes little. In order to reduce power consumption, the integration time of the ambient light sensor can be kept unchanged, and the sleep time of the ambient light sensor can be extended, which is equivalent to extending the acquisition period (or, keeping the integration time of the ambient light sensor unchanged and extending the acquisition period of the ambient light sensor is equivalent to extending the sleep period). Therefore, a normal sampling mode (recorded as the first sampling mode) and a slow sampling mode (recorded as the second sampling mode) can be set for the ambient light sensor. The ambient light sensor mainly uses the normal sampling mode. When the brightness of the environment where the electronic device is located changes little, the sampling mode of the ambient light sensor can be switched to the slow sampling mode.
[0387] As an example, in normal sampling mode, the acquisition period can be 350ms, the integration time can be 50ms, and the sleep time is 300ms. The acquisition period of the slow sampling mode is longer than that of the normal sampling mode. For example, it can be set to the longest acquisition period supported by the ambient light sensor; of course, it can also be set to any time between the acquisition period in normal sampling mode and the longest supported acquisition period. In the embodiment of the present application, the acquisition period of the slow sampling mode can be set to the longest supported acquisition period of 711ms, and the integration time is the same as the integration time of the normal sampling mode, which is also 50ms, so the sleep time is 661ms.
[0388] In another scenario, the brightness of the electronic device's environment varies significantly. To quickly adjust the brightness of the electronic device's display based on the ambient light data collected by the ambient light sensor to improve the user's visual experience, the ambient light sensor's collection cycle needs to be shortened. The ambient light sensor still primarily operates in normal sampling mode. If the brightness of the electronic device's environment varies significantly, the ambient light sensor's sampling mode can be switched to fast sampling mode (referred to as the third sampling mode).
[0389] As an example, the acquisition period of the fast sampling mode may be 100 ms, the integration time may be 50 ms, and the sleep time is 50 ms.
[0390] In addition, it should be noted that the implementation of the embodiments of the present application is not necessarily limited to electronic devices with under-screen ambient light sensors.
[0391] If used in electronic devices without under-screen ambient light sensors, the setting of slow sampling mode is equivalent to extending the sleep time of the ambient light sensor, which can reduce power consumption.
[0392] If a slow sampling mode is set in an electronic device with an under-screen ambient light sensor, the sleep time of the ambient light sensor is extended, thereby reducing the frequency of the SCP processor reporting ambient light data and the AP processor processing ambient light data, which can also reduce power consumption. In addition, the number of times noise is removed from the initial ambient light collected by the ambient light sensor is also reduced, thereby further reducing power consumption.
[0393] Of course, if used in electronic devices with under-screen ambient light sensors, since the noise that interferes with the initial ambient light is the noise corresponding to the image displayed in the target area during the integration period and the brightness of the display screen, it can also be set to only acquire the target image during the integration period (or a time range that includes the integration period), and not acquire the target image during other time periods. If the sleep time is extended, the total time required to acquire the target image is correspondingly reduced, which also greatly reduces power consumption.
[0394] Since switching sampling modes is not necessarily limited to electronic devices with under-screen ambient light sensors, the data collected by the ambient light sensor will be recorded as ambient light data in subsequent embodiments. If the subsequent embodiments are applied to electronic devices with under-screen ambient light sensors, the ambient light data in the embodiments of this application will be the initial ambient light collected by the ambient light sensor.
[0395] When an ambient light sensor collects ambient light data, it simulates the human eye's perception of surrounding light intensity. To ensure that the ambient light data reported to the sensor driver more closely resembles human perception, the sensor multiplies the collected raw data by a certain coefficient (the gain). This yields ambient light data that more accurately reflects the intensity of light received by the human eye. However, this gain value varies across different brightness ranges, leading to the need for gain adjustment.
[0396] As an example, in a very bright environment, the raw data collected by the ambient light sensor is relatively large. To ensure that the ambient light data reported to the ambient light sensor driver based on the raw data is within an appropriate range (e.g., the range [a, b]), a smaller gain value and the current raw data can be used to obtain the reported ambient light data. In a very dark environment, the raw data collected by the ambient light sensor is relatively small. To ensure that the ambient light data obtained by the ambient light sensor based on the raw data is also within an appropriate range, a larger gain value and the current raw data can be used to obtain the ambient light data.
[0397] In one implementation, the ambient light sensor acquires ambient light data (raw values) at a specific gain value. The ambient light sensor reports the ambient light data (raw values) to the ambient light sensor driver. If the ambient light sensor driver determines that the received raw values exceed a preset range, indicating that the currently used gain value is inappropriate, the ambient light sensor driver adjusts the ambient light sensor's gain value. The ambient light sensor then continues to acquire raw values in the next acquisition cycle using the adjusted gain value.
[0398] In addition, the ambient light sensor driver will not send the currently collected raw value that exceeds the preset range to the AP processor, but will discard the raw value.
[0399] In another implementation, the ambient light sensor acquires ambient light data (raw value) at a certain gain and determines whether the acquired ambient light data (raw value) exceeds a preset range. If so, a specific bit in a preset register is set to a specific character. The ambient light sensor driver determines whether to adjust the ambient light sensor gain by reading the specific character in the specific bit in the register.
[0400] It should be noted that the focus of the embodiments of this application is not on how to adjust the gain of the ambient light sensor. Rather, the above example illustrates that a gain adjustment event occurs on the SCP processor side. Furthermore, during the gain adjustment, if the ambient light data exceeds the range, the out-of-range ambient light data will not be reported to the AP processor.
[0401] In actual applications, the gain value is not appropriate, usually because the brightness of the environment where the electronic device is located changes significantly. Therefore, in order to improve the user experience, the AP processor needs to quickly obtain ambient light data to quickly adjust the display screen of the electronic device. Therefore, when adjusting the gain, the acquisition period of the ambient light sensor is shorter than that in the normal sampling mode. For the sake of convenience, this sampling mode can be recorded as the gain adjustment mode (also referred to as the fourth sampling mode). In the gain adjustment mode, the acquisition period can be 60ms, the integration time can be 50ms, and the sleep time is 10ms.
[0402] It should be noted that the numbers used to represent the acquisition period, integration time and sleep time in the above-mentioned sampling modes are only used for examples and are not intended to be limiting.
[0403] Typically, after the electronic device is powered on, it can control the ambient light sensor to operate in a normal sampling mode, and then switch to a slow sampling mode or a fast sampling mode according to changes in the environment where the ambient light sensor is located.
[0404] Of course, when the ambient light sensor operates in the slow sampling mode or the fast sampling mode, it can also switch back to the normal sampling mode according to changes in the environment where the ambient light sensor is located.
[0405] When the ambient light data collected by the ambient light sensor exceeds the range [a, b], the sensor switches to the gain adjustment mode. After the gain adjustment is completed, the sensor can switch back to the normal sampling mode.
[0406] For details on other switching between the sampling modes, please refer to the description of the subsequent embodiments.
[0407] In order to more clearly illustrate the switching conditions between the various sampling modes, the following embodiments are used for illustration.
[0408] In a specific implementation, the ambient light sensor is used to detect information related to the environment and light intensity of the electronic device. Therefore, the ambient light data collected by the ambient light sensor can be used as a basis for switching between modes.
[0409] When used in electronic devices without an under-screen ambient light sensor, the ambient light data collected by the ambient light sensor can be understood as data about the surrounding environment of the electronic device. Therefore, the ambient light data collected by the ambient light sensor can be used as the basis for switching between modes.
[0410] When used in electronic devices with under-display ambient light sensors, the ambient light data collected by the sensor consists of two components: noise and true ambient light data. If the ambient light data collected by the sensor is stable within a certain range, both the noise and true ambient light data are considered stable. Therefore, the ambient light data collected by the sensor can also be used as a basis for switching between modes.
[0411] Of course, in actual applications, there may be a situation where both the real ambient light and noise in the outside world change significantly, but the ambient light data of the real ambient light and noise combined change slightly. Usually, when judging whether the ambient light data is stable, the change of multiple consecutive ambient light data is used to judge stability. Therefore, even if this situation exists (the real ambient light in the outside world changes significantly, and the current noise just compensates for this large change), it is possible that the current single ambient light data is stable, but the changes of the subsequent multiple consecutive ambient light data will usually become larger (it is impossible for the noise to just compensate for this change multiple times in a row). Therefore, in actual applications, if the change of multiple consecutive ambient light data is used to judge stability, this situation can be ignored.
[0412] As previously mentioned, in the embodiments of the present application, the ambient light data (initial ambient light) collected by the ambient light sensor can be deducted from the noise to obtain the actual ambient light (target ambient light). Therefore, in the embodiments of the present application, the target ambient light data in the above embodiments can also be used as the basis for switching between modes. The embodiments of the present application are not limited to this.
[0413] Of course, in actual applications, the collected ambient light data and the target ambient light data can be used as conditions for determining stability at the same time, and this is not limited to the embodiments of the present application.
[0414] As mentioned above, the condition for switching to the gain adjustment mode in the above sampling mode is related to the value of the ambient light data itself; the switching between the slow sampling mode, normal sampling mode and fast sampling mode in the above sampling mode is related to the change of the ambient light data.
[0415] Therefore, for the switching conditions between slow sampling mode, normal sampling mode, and fast sampling mode, two change thresholds C1 (referred to as the first threshold) and C2 (referred to as the second threshold) can be set, where C1 is less than C2. Change threshold C1 is the critical threshold for switching between slow sampling mode and normal sampling mode, and C2 is the critical threshold for switching between normal sampling mode and fast sampling mode. The change threshold corresponds to the change in ambient light data collected by the ambient light sensor.
[0416] Of course, in actual applications, more or fewer sampling modes than those in the above embodiment may be set, and the present embodiment does not impose any limitation on this.
[0417] In addition, quantity thresholds N1 (recorded as the first quantity), N2 (recorded as the second quantity), N3 and N4 can also be set as quantity conditions of ambient light data during switching; of course, in actual applications, time thresholds (T1, T2, T3 and T4) corresponding to the quantity thresholds can also be set, and please refer to the description of subsequent embodiments for details.
[0418] For ease of description, the embodiment of the present application describes the change of the ambient light data as being not less than 0. That is, the change of the ambient light data is obtained by subtracting the smaller value from the larger value in the ambient light data.
[0419] See also Figure 15 After an electronic device is powered on, the ambient light sensor in the electronic device is usually in normal sampling mode. When the ambient light sensor of the electronic device is in normal sampling mode, if there are N1 consecutive (or within T1 time) ambient light data changes that are stable within the range [0, C1), the ambient light sensor can be controlled to switch to slow sampling mode; if ambient light data is received such that the ambient light data changes within the range [C2, +∞), the ambient light sensor can be controlled to switch to fast sampling mode.
[0420] When the ambient light sensor in the electronic device is in slow sampling mode, if the ambient light data changes stably within the range of [0, C1), the slow sampling mode is maintained; if ambient light data is received, causing the ambient light data change to appear within the range of [C1, C2), the ambient light sensor can be controlled to switch to normal sampling mode; if ambient light data is received, causing the ambient light data change to appear within the range of [C2, +∞), the ambient light sensor can be controlled to switch to fast sampling mode.
[0421] When the ambient light sensor in an electronic device is in fast sampling mode, if there are N2 consecutive (or within T2 time) ambient light data changes within the range [0, C2), the ambient light sensor can be controlled to switch to normal sampling mode. To avoid excessive power consumption, after the number of ambient light data acquired exceeds N3 (N3 is greater than N2), or after switching to fast sampling mode for T3 time, even if the ambient light data changes are not stable within the range [0, C2), it is necessary to switch to normal sampling mode. The values of N1 and N2 can be equal.
[0422] Regardless of the sampling mode (normal sampling mode, slow sampling mode, or fast sampling mode) the ambient light sensor operates in, as long as an event requiring gain adjustment occurs (the ambient light data overflows the preset range), the ambient light sensor can be controlled to switch to gain adjustment mode. If the gain value is adjusted so that the obtained raw value is within the range [a, b] or a preset number of adjustments (e.g., N4) is completed, or after switching to gain adjustment mode for T4 time, the gain adjustment mode is exited and the normal sampling mode is switched at the same time. The values of N3 and N4 can be equal.
[0423] As previously mentioned, the ambient light sensor driver in the SCP processor is required to control the ambient light sensor to collect ambient light. Therefore, the ambient light sensor driver configures the ambient light sensor's collection cycle or sleep duration (the integration duration is fixed). The process for determining the switching conditions between the various modes can run on the SCP processor (denoted as the first processor) or the AP processor (denoted as the second processor).
[0424] See also Figure 16 Taking the AP processor as an example, during the i-th acquisition cycle, the ambient light sensor obtains ambient light data (raw value) using the currently set gain value. The ambient light sensor then reports this data to the ambient light sensor driver. The ambient light sensor driver then sends this data to the calculation module, which converts the raw ambient light data into lux data. The calculation module then sends this ambient light data (lux value) to the ambient light sensor application. The ambient light sensor application then sends this data to the HWC module in the AP processor via inter-core communication.
[0425] See also Figure 16 The HWC module in the AP processor sends the ambient light data (lux value) to the noise algorithm library. The noise algorithm library determines whether to switch to a different sampling mode based on the received ambient light data and the current sampling mode. If the current sampling mode is maintained, the AP processor continues to wait for the ambient light data to be sent in the next (i+1) acquisition cycle.
[0426] See also Figure 16 In the (i+1)th acquisition cycle, the ambient light sensor obtains ambient light data (raw value) using the currently set gain value. The ambient light sensor reports this data to the ambient light sensor driver. The ambient light sensor driver sends this data to the calculation module, which converts the raw ambient light data into lux data. The calculation module sends this ambient light data (lux value) to the ambient light sensor application. The ambient light sensor application sends this data to the HWC module in the AP processor through inter-core communication.
[0427] See also Figure 16 The HWC module in the AP processor sends the ambient light data (lux value) to the noise algorithm library. The noise algorithm library determines whether to switch to another sampling mode based on the received ambient light data and the current sampling mode. If the noise algorithm library in the AP processor determines that it needs to switch to another sampling mode based on the received ambient light data and the current sampling mode, the noise algorithm library returns the sampling mode to be switched to the HWC module. The HWC module sends the sampling mode to be switched to the ambient light sensor application in the SCP processor through inter-core communication. The ambient light sensor application sends the sampling mode to be switched to the ambient light sensor driver. The ambient light sensor driver stores the relevant parameters of the sampling mode to be switched (for example, the sleep duration or the acquisition cycle) in the register of the ambient light sensor itself. The ambient light sensor collects ambient light based on the relevant parameters stored in the register.
[0428] The ambient light sensor continues to obtain the ambient light data collected in the (i+2)th collection cycle according to the switched sampling mode, and continues to send it to the AP processor in the above manner.
[0429] Of course, the SCP processor can also send relevant information such as the collection cycle or sleep duration when sending the ambient light data (for example, the collection cycle or sleep duration can be obtained from a register). The AP processor can determine the current sampling mode of the ambient light sensor based on the received collection cycle or sleep duration and other relevant information.
[0430] It should be noted that before the SCP processor sends the ambient light data to the AP processor, it may pre-process the ambient light data (for example, normalize the gain processing) and then send the pre-processed ambient light data to the AP processor. Of course, in actual applications, the SCP processor may also send the ambient light data and the gain value corresponding to the ambient light data to the AP processor, and the AP processor may pre-process the ambient light data based on the gain value corresponding to the ambient light data to obtain the pre-processed ambient light data.
[0431] in addition, Figure 16 In the illustrated embodiment, during the (i+1)th acquisition cycle, the duration from when the ambient light sensor obtains ambient light data at the end of integration to when the ambient light sensor driver stores the sleep duration corresponding to the sampling mode to be switched in the register is typically on the order of milliseconds (typically several milliseconds). That is, the ambient light sensor can obtain information related to the sampling mode to be switched during the sleep period during the (i+1)th acquisition cycle.
[0432] The ambient light sensor driver can indicate that the sleep duration of the ambient light sensor in the i+1th acquisition cycle is the sleep duration corresponding to the sampling mode before switching, and the sleep duration of the i+2th acquisition cycle is the sleep duration corresponding to the sampling mode after switching; it can also indicate that the sleep duration of the ambient light sensor in the i+1th acquisition cycle is the sleep duration corresponding to the sampling mode after switching.
[0433] Of course, in order to enable the ambient light sensor to quickly switch to another sampling mode and promptly obtain ambient light data in the other sampling mode, the ambient light sensor can also be instructed to sleep for a shorter duration in the (i+1)th acquisition cycle, whichever corresponds to the sleep duration corresponding to the sampling mode before the switch and the sleep duration corresponding to the sampling mode after the switch. Of course, in the (i+2)th acquisition cycle, the sleep duration is set according to the sleep duration of the mode after the switch.
[0434] As an example, if the normal sampling mode is switched to the slow sampling mode, the sleep duration of the current acquisition cycle is executed according to the sleep duration of the normal sampling mode.
[0435] If the mode is switched from slow sampling mode to normal sampling mode, the sleep duration of the current acquisition cycle is based on the sleep duration of the normal sampling mode.
[0436] If the mode is switched from slow sampling mode or normal sampling mode to fast sampling mode, the sleep duration of the current acquisition cycle is based on the sleep duration of the fast sampling mode.
[0437] If the fast sampling mode is switched to the normal sampling mode, the sleep duration of the current acquisition cycle is based on the sleep duration of the fast sampling mode.
[0438] If the mode is switched to gain adjustment mode, the sleep duration of the current acquisition cycle is executed according to the sleep duration of the gain adjustment mode.
[0439] Of course, in actual applications, on the SCP processor side, when it is determined that the sampling mode needs to be switched (including switching to the gain adjustment mode), how the ambient light sensor switches to another sampling mode can be determined based on the internal logic of the ambient light sensor driver that controls the ambient light sensor. This embodiment of the present application is not limited to this.
[0440] From the above examples, it can be understood that the noise algorithm library in the AP processor triggers switching to fast sampling mode, slow sampling mode, or normal sampling mode based on the received ambient light data, and the ambient light sensor in the SCP processor triggers switching to gain adjustment mode.
[0441] Reference Figure 17 As shown, in actual applications, multiple gain values and the range [a, b] of the raw value collected by the ambient light sensor can be preset.
[0442] In the jth acquisition cycle, the ambient light sensor obtains ambient light data with the current gain value Z3 and reports it to the ambient light sensor driver. The ambient light sensor driver determines that the ambient light data (obtained based on the gain value Z3) is less than a and exceeds the range, then the ambient light sensor driver adjusts the gain value of the ambient light sensor to Z4 (Z4 is greater than Z3).
[0443] In the j+1th acquisition cycle, the ambient light sensor reads the ambient light data with a gain value of Z4 and reports it to the ambient light sensor driver; the ambient light sensor driver determines that the ambient light data currently read with the gain value of Z4 is still less than a and exceeds the range; the ambient light sensor driver then continues to adjust the gain value of the ambient light sensor to Z5 (Z5 is greater than Z4).
[0444] In the j+2th acquisition cycle, the ambient light sensor reads the ambient light data with a gain value of Z5 and reports it to the ambient light sensor driver; if the ambient light sensor driver determines that the ambient light data read with the gain value Z5 is within the range of [a, b], the gain adjustment is completed, and the ambient light sensor driver can send the ambient light data to the AP processor.
[0445] pass Figure 17 It can be understood that the SCP processor can also switch the gain adjustment mode without the participation of the AP processor. During the period when the SCP processor adjusts the gain, the SCP processor will not send ambient light data that exceeds the range of [a, b] to the AP processor. The SCP will send the collected ambient light data to the AP processor only when it switches from the gain adjustment mode to the normal sampling mode. As mentioned above, it is necessary to return to the normal sampling mode at this time. The SCP processor controls the ambient light sensor to operate in the normal sampling mode by modifying the acquisition cycle or sleep time stored in the register. The SCP processor reports the ambient light data and information such as the acquisition cycle or sleep time stored in the register to the AP processor. That is, when reporting the ambient light data in the j+2th acquisition cycle, the acquisition cycle or sleep time stored in the register can be reported at the same time. In actual applications, the SCP processor can report the acquisition cycle or sleep time each time it reports the ambient light data ( Figure 16 not shown).
[0446] In actual applications, the integration durations of the various modes are the same, but the difference lies in the sleep duration. Either the acquisition period or the sleep duration can be reported. The AP processor can determine the current sampling mode of the ambient light sensor based on either the acquisition period or the sleep duration.
[0447] See also Figure 18 , which is a technical architecture diagram provided in an embodiment of the present application.
[0448] If the sampling mode of the ambient light sensor is set to be intelligently adjustable, you need to Figure 7 The following content is added to the technical architecture shown.
[0449] Combine Figure 16 As shown, after the ambient light sensor obtains the initial ambient light, the ambient light sensor driver obtains the initial ambient light in raw format. The ambient light sensor driver can call the calculation module to obtain the initial ambient light in lux format based on the initial ambient light in raw format.
[0450] Figure 7 In the technical architecture shown, the ambient light sensor driver can report the initial ambient light in raw format in step E3, so Figure 18 In the technical architecture shown, the data reported in step E3 and step E4 may include not only the initial ambient light in raw format, but also the initial ambient light in lux format.
[0451] Combine Figure 16 As shown, after the AP processor receives the initial ambient light, it may be necessary to return the sleep time to the SCP processor in some cases so that the ambient light sensor switches to the sampling mode.
[0452] Combine Figure 7 As shown, after the AP processor receives the initial ambient light, it can obtain the target ambient light and needs to return the target ambient light to the SCP processor.
[0453] It should be noted that the target ambient light sent by the AP processor to the SCP processor and the sleep time sent by the AP processor to the SCP processor are different inter-core communication information.
[0454] Taking the sleep duration returned by the AP processor to the SCP processor as an example, the HWC in the AP processor sends the sleep duration to the ambient light sensor application, which in turn sends the sleep duration to the ambient light sensor driver. The ambient light sensor driver then writes the sleep duration to a register in the ambient light sensor. The ambient light sensor then uses the sleep duration stored in the register to collect ambient light.
[0455] After describing the various sampling modes and the conditions for switching between different sampling modes, the following example describes the process of determining whether the ambient light data changes are stable (N1 consecutive ambient light data changes are stable within the range [0, C1)) when the AP processor switches from the normal sampling mode to the slow sampling mode.
[0456] As an example, the ambient light data collected by the ambient light sensor can be stored in a pre-set data storage structure. The data storage structure can be a ring storage structure. When the data queue stored in the ring storage structure is empty, the first data stored in the ring storage structure is the first ambient light data described in subsequent embodiments of this application.
[0457] See also Figure 19 The first ambient light data D1 is considered to be stable data and is stored in the data storage structure (FIFO). The storage structure for storing ambient light data is recorded as the first storage space.
[0458] For the second ambient light data D2, if the absolute value of the difference between the second ambient light data D2 and the first ambient light data D1 is less than C1, the second ambient light data D2 is stable and is stored in the data storage structure in sequence.
[0459] If the absolute value of the difference between the second ambient light data D2 and the first ambient light data D1 is greater than or equal to C1, the second ambient light data D2 is unstable, causing the ambient light change to be greater than or equal to C1, and the FIFO is cleared to wait for the first ambient light data to arrive. Of course, in actual applications, the currently received ambient light data D2 can also be stored in the FIFO as the first ambient light data.
[0460] For the third ambient light data D3, if the absolute value of the difference between the third ambient light data D3 and the first ambient light data D1 is less than C1, and the absolute value of the difference between the third ambient light data D3 and the second ambient light data D2 is less than C1, then the third ambient light data D3 is stable and is stored in the data storage structure in sequence. At this point, three stable ambient light data are obtained.
[0461] If any of the above conditions is not met, the third ambient light data D3 is unstable, making the ambient light change greater than or equal to C1, and the FIFO is cleared to wait for the first ambient light data to arrive. Of course, in actual applications, the currently received ambient light data D3 can also be stored in the FIFO as the first ambient light data.
[0462] For the fourth ambient light data D4, if the absolute value of the difference between the fourth ambient light data D4 and the first ambient light data D1 is less than C1, and the absolute value of the difference between the fourth ambient light data D4 and the third ambient light data D3 is less than C1, then the fourth ambient light data D4 is stable and is stored in the data storage structure in sequence. At this point, four stable ambient light data are obtained.
[0463] If any of the above conditions is not met, the fourth ambient light data D4 is unstable, making the ambient light change greater than or equal to C1, and the FIFO is cleared to wait for the first ambient light data to arrive. Of course, in actual applications, the currently received ambient light data D4 can also be stored in the FIFO as the first ambient light data.
[0464] …
[0465] For the i-th ambient light data Di, if the absolute value of the difference between the i-th ambient light data Di and the first ambient light data D1 is less than C1, and the absolute value of the difference between the i-th ambient light data D1 and the i-1-th ambient light data D(i-1) is less than C1, then the i-th ambient light data Di is stable and continues to be stored in the data storage structure in sequence. At this time, i stable ambient light data are obtained.
[0466] If any of the above conditions is not met, the i-th ambient light data Di is unstable, so that the ambient light change is greater than or equal to C1, and the FIFO is cleared to wait for the first ambient light data to arrive. Of course, in actual applications, the currently received ambient light data Di can also be stored in the FIFO as the first ambient light data.
[0467] When the changes in N1 continuously received ambient light data are all less than C1, it means that the environment where the electronic device is located is relatively stable, and the current normal sampling mode can be switched to the slow sampling mode.
[0468] It can be understood from the above example that if the absolute value of the difference between the ambient light data received each time and the first ambient light data is less than C1, and the absolute value of the difference between the ambient light data received each time and the previous ambient light data is less than C1, then the currently received ambient light data is stable, and the currently received ambient light data is stored in the data storage structure in sequence.
[0469] In addition, it should be noted that if the current sampling mode is not the normal sampling mode but the fast sampling mode, the threshold in the above example is not C1 but C2, and the other stability determination processes remain the same. This embodiment of the application will not describe in detail the stability determination process when the AP processor switches from the fast sampling mode to the normal sampling mode (N2 consecutive ambient light data changes are stable within the range of [0, C2)).
[0470] In addition, it should be noted that since it is possible to switch to the fast sampling mode in the normal sampling mode, when the absolute value of any difference is greater than or equal to C1, it is also necessary to determine whether the absolute value of the difference is greater than or equal to C2. If the absolute value of any difference is greater than or equal to C2, it is necessary to switch to the fast sampling mode.
[0471] As mentioned above, the ambient light data stored in the data storage structure forms a data queue. The ambient light data stored first in the data queue corresponds to the head of the queue, and the ambient light data stored last corresponds to the tail of the queue.
[0472] If the number of ambient light data that the data storage structure can store is greater than or equal to N1, then when there are N1 ambient light data in the data queue stored in the data storage structure, it is determined that the condition for switching from the normal sampling mode to the slow sampling mode is met.
[0473] In the above embodiment, the first ambient light data is used as the reference, and each new ambient light data is compared with the first ambient light data and the previous ambient light data. Figure 20 When the upper limit (D1+C1) and the lower limit (D1-C1) in the illustrated embodiment are between the upper limit and the lower limit (the difference between the upper limit and the lower limit is 2C1), and the change of two consecutive ambient light data is less than C1, it is determined that the change of N1 ambient light data is stable within the range of [0, C1).
[0474] However, if the change in the environment is a gradual change, that is, the ambient light data increases or decreases in sequence. Although the absolute value of the difference between two consecutive ambient light data is less than C1, the absolute value of the difference between two ambient light data separated by several data points is greater than or equal to C1. For details, please refer to Figure 20 From the data D5 and data D8, it is clear that the absolute value of the difference between data D5 and data D8 is greater than C1. That is, the change between data D5 and data D8 is not stable within the range of [0, C1).
[0475] In order to solve the above problems, the embodiments of the present application also provide another more accurate stability determination process.
[0476] See also Figure 21 , for the first ambient light data D1, it is considered to be stable data and is stored in the data storage structure.
[0477] For the second ambient light data D2, the larger value of the first ambient light data D1 and the second ambient light data D2 is used as the maximum value, and the smaller value of the first ambient light data D1 and the second ambient light data D2 is used as the minimum value. If the difference between the maximum and minimum values is less than C1, the second ambient light data is considered stable and stored in the data storage structure.
[0478] Otherwise, if the second ambient light data D2 is unstable, causing the ambient light change to be greater than or equal to C1, the FIFO is cleared and the first ambient light data is awaited. Of course, in practical applications, the currently received ambient light data D2 can also be stored in the FIFO as the first ambient light data. For the third ambient light data D3, the largest of the third ambient light data D3, the currently stored maximum value, and the minimum value is updated to the maximum value, and the smallest of the third ambient light data D3, the currently stored maximum value, and the minimum value is updated to the minimum value. At this point, if the difference between the updated maximum value and the updated minimum value is less than C1, the third ambient light data is considered stable and is stored in the data storage structure.
[0479] Otherwise, if the third ambient light data D3 is unstable, causing the ambient light change to be greater than or equal to C1, the FIFO is cleared and the first ambient light data is awaited. Of course, in practical applications, the currently received ambient light data D3 can also be stored in the FIFO as the first ambient light data.
[0480] For the fourth ambient light data D4, the largest of the fourth ambient light data D4, the currently stored maximum value, and the currently stored minimum value is updated to the maximum value, and the smallest of the fourth ambient light data D4, the currently stored maximum value, and the minimum value is updated to the minimum value. At this time, if the difference between the updated maximum value and the updated minimum value is less than C1, the fourth ambient light data is considered stable and is stored in the data storage structure.
[0481] Otherwise, if the fourth ambient light data D4 is unstable, causing the ambient light change to be greater than or equal to C1, the FIFO is cleared and the first ambient light data is awaited. Of course, in practical applications, the currently received ambient light data D4 can also be stored in the FIFO as the first ambient light data.
[0482] …
[0483] For the i-th ambient light data Di, the largest of the i-th ambient light data Di, the currently stored maximum value, and the minimum value is updated to the maximum value, and the smallest of the i-th ambient light data Di, the currently stored maximum value, and the minimum value is updated to the minimum value. At this time, if the difference between the updated maximum value and the updated minimum value is less than C1, the i-th ambient light data Di is considered stable and stored in the data storage structure.
[0484] Otherwise, if the i-th ambient light data Di is unstable, causing the ambient light change to be greater than or equal to C1, the FIFO is cleared and the first ambient light data is awaited. Of course, in practical applications, the currently received ambient light data Di can also be stored in the FIFO as the first ambient light data.
[0485] From the above example, it can be understood that if the difference between the updated maximum value and the updated minimum value is greater than or equal to C1, the currently received ambient light data is considered unstable, causing the ambient light change to be greater than or equal to C1. In this case, the ambient light data stored in the data storage structure can be cleared and the first ambient light data can be waited for. Alternatively, the currently received ambient light data can be stored in the FIFO as the first ambient light data.
[0486] Since the maximum and minimum values are updated every time an ambient light data is received, the updated maximum and minimum values are the maximum and minimum values from the first ambient light data (the first one after the FIFO is cleared) to the currently received ambient light data. Therefore, if the absolute value of the difference between the maximum and minimum values is less than C1, then the absolute value of the difference between any two ambient light data from the first ambient light data to the currently received ambient light data is less than C1. Therefore, through Figure 21 The stability judgment method shown can make N1 ambient light data all limited to Figure 22 When the upper limit and the lower limit in the embodiment shown are between (the difference between the upper limit and the lower limit is C1), it is determined that the changes in N1 ambient light data are stable within the range of [0, C1), thereby solving the problem. Figure 20 Problem in the illustrated embodiment.
[0487] This embodiment can also be applied to the stability determination process when the AP processor switches from the fast sampling mode to the normal sampling mode (N2 consecutive ambient light data changes are stable within the range of [0, C2)). This embodiment of the application will not be repeated.
[0488] In practice, users' visual perception of light intensity varies in different ambient lighting scenarios. For example, in darkness, users can easily detect the faint light of fireflies. In contrast, in bright sunlight, users are less likely to detect bright streetlights. Therefore, it is necessary to classify ambient light data into multiple levels, with different stability thresholds C1 set for each level.
[0489] As an example, if the ambient light data is in the range of [0, 5], it can be recorded as range level 1, and C1 is 2.
[0490] If the ambient light data is within the range of (5, 20], it can be recorded as range level 2, and C1 is 3.
[0491] If the ambient light data is in the range of (20, 100], it can be recorded as range level 3, and C1 is 6.
[0492] If the ambient light data is within the range of (100, +∞), it can be recorded as range level 4, and C1 is 5% (or 6%, 7%, 8%, etc.) of the first ambient light data (the first ambient light data after the FIFO is cleared).
[0493] When obtaining C1 corresponding to different range levels, the specific value of C1 can be obtained based on the range level of the lux value of the currently received ambient light data.
[0494] See also Figure 23 , upon receiving the ambient light data, first determine whether the currently received ambient light data is within range level 1. If so, determine that the currently received ambient light data belongs to the range of [0, 5], and the corresponding threshold is 2.
[0495] If not, it continues to determine whether the currently received ambient light data is within range level 2. If so, it is determined that the currently received ambient light data belongs to the range of (5, 20], and the corresponding threshold is 3.
[0496] If not, it continues to determine whether the currently received ambient light data is within range level 3. If so, it is determined that the currently received ambient light data belongs to the range of (20, 100], and the corresponding threshold is 6.
[0497] If not, it is determined that the currently received ambient light data belongs to range level 4, and the corresponding threshold is 5% of the first ambient light data.
[0498] Through the above process, it can be understood that when there are k groups of range levels, there are correspondingly k range sets consisting of numerical elements. Since no two range sets in the k range sets have the same numerical elements, the k range sets can be sorted based on the size of the numerical elements in the range sets. As an example, the k range sets can be sorted from small to large, with the numerical elements in the first range set being smaller than the numerical elements in the second range set, the numerical elements in the second range set being smaller than the numerical elements in the third range set, ... the numerical elements in the k-1 range set being smaller than the numerical elements in the k range set. Of course, the k range sets can also be sorted from large to small.
[0499] Each time an ambient light data point is received, the system performs judgments based on the sorted range set according to the above logic until the corresponding threshold value is obtained. In the best case, the corresponding threshold value can be obtained on the first judgment; in the worst case, the corresponding threshold value can be obtained after k-1 judgments.
[0500] In actual applications, if the normal sampling mode is used as an example, ambient light data is obtained every 350ms, and the threshold value needs to be determined according to the threshold value determination method provided in the above embodiment, resulting in excessive power consumption. Therefore, the embodiment of the present application can adopt the following method to reduce power consumption.
[0501] Take the four ranges in the above embodiment as an example: [0, 5] range, (5, 20] range, (20, 100] range, (100, +∞) range. First, determine three critical values between the four ranges: 5 (E1), 20 (E2), 10 (E3).
[0502] See also Figure 24 ,Since if the ambient light data is equal to the critical value at any time of ,judgment, it is possible to determine which level the received ambient light data belongs to, and ,there is no need to continue the subsequent judgment process. Figure 24 In the illustrated embodiment, the case of being equal to is ignored, and only the case of being greater than or less than is described.
[0503] After receiving the ambient light data, the ambient light data may be compared with a critical value E2 (20);
[0504] If it is less than E2(20), then continue to compare with the smaller critical value E1(5); if it is less than E1(5), then it belongs to the range of [0, 5], that is, range level 1, and the threshold C1 can be obtained as 2; if it is greater than E1(5), then it belongs to the range of (5, 20], that is, range level 2, and the threshold C1 can be obtained as 3.
[0505] If it is greater than E2 (20), it continues to be compared with the larger critical value E3 (100). If it is less than E3 (100), it belongs to the range of (20, 100], that is, range level 3, and the threshold C1 can be obtained as 6; if it is greater than E3 (100), it belongs to the range of (100, +∞), that is, range level 4, and the threshold C1 can be obtained as 5% of the first ambient light data.
[0506] In addition, it should be noted that in the embodiment of the present application, the four range levels divided above can be recorded as the first brightness level, the second brightness level, the third brightness level, and the fourth brightness level. The critical value between the first brightness level and the second brightness level is the first critical value; the critical value between the second brightness level and the third brightness level is the second critical value, and the critical value between the third brightness level and the fourth brightness level is the third critical value. The first critical value is less than the second critical value, and the second critical value is less than the third critical value.
[0507] In practical applications, each of the first brightness level, the second brightness level, the third brightness level, and the fourth brightness level may further include one or more sub-brightness levels.
[0508] As an example, the first brightness level can be further subdivided into multiple sub-brightness levels (for example, the range [0, 5] can be further subdivided into the [0, 2] sub-brightness level and the (2, 3] sub-brightness level). When it is determined that the currently received ambient light data belongs to the first brightness level, it is further possible to continue to determine which sub-brightness level of the first brightness level the currently received ambient light data belongs to based on the above-mentioned determination method. That is, although the embodiment of the present application takes four brightness levels as an example, in actual applications, more than four brightness levels may be included.
[0509] From the above example, it can be understood that if there are k range levels (the most detailed range level) in total, k-1 critical values need to be determined, and the k-1 critical values are sorted from large to small or from small to large.
[0510] For example, sorting from smallest to largest selects the pth critical value from the k-1 critical values as the basis for the first judgment. If the ambient light data is less than the pth critical value, then select another critical value less than the pth critical value (from the 1st critical value to the p-1th critical value) as the basis for the second judgment.
[0511] In this way, each time a critical value is selected as a judgment criterion, try to choose a critical value that is closer to the middle of the available critical values. For example, if there are 2m+1 possible critical values, try to choose the mth critical value. If there are 2m possible critical values, try to choose the m-1th or mth critical value to improve efficiency.
[0512] In the embodiment of the present application, threshold C2 is a switching condition related to the fast sampling mode. As previously mentioned, when the change corresponding to the currently received ambient light data is too large (greater than C2), it will switch to the fast sampling mode. Therefore, threshold C2 is usually a relatively large value. In this case, there is no need to set a range level related to the brightness value, nor is there a need to set different thresholds C2 for different range levels. That is, threshold C2 in the embodiment of the present application can be a fixed value.
[0513] The above example takes the electronic device's screen-on state as an example. In actual applications, when the electronic device is in the screen-off state, for example, the screen-off state, the always on display (AOD) state, etc., the ambient light sensor also needs to collect ambient light data according to the collection cycle.
[0514] See also Figure 25 , which is a switching relationship diagram of the sampling mode of the ambient light sensor in the screen-off state provided in an embodiment of the present application.
[0515] In the screen-off state, the ambient light sensor can mainly operate in the slow sampling mode. For example, after the electronic device switches from the screen-on state to the screen-off state, the ambient light sensor operates in the slow sampling mode.
[0516] Of course, if an event occurs that requires adjustment of the gain value, the ambient light sensor can be controlled to switch to the gain adjustment mode. If the ambient light data obtained by adjusting the gain value is within the range of [a, b] or the gain value is adjusted a sufficient number of times (for example, N4) or after switching to the gain adjustment mode for T4 time, the gain adjustment mode is exited and the slow sampling mode is returned.
[0517] To have a clearer understanding of the above example, you can Figure 26 The illustrated embodiment describes the switching process between modes.
[0518] During this switching process, after the electronic device is powered on, the ambient light sensor on the electronic device operates in normal sampling mode. Then, in step S1, the normal sampling mode is switched to slow sampling mode; then, in step S2, the slow sampling mode is switched to fast sampling mode; then, in step S3, the fast sampling mode is switched to normal sampling mode; and finally, the normal sampling mode is switched to fast sampling mode.
[0519] Of course, in the slow sampling mode, if the conditions for switching to the normal sampling mode are met, the slow sampling mode can be switched to the normal sampling mode through step S2 ′.
[0520] In slow sampling mode, fast sampling mode, and normal sampling mode, if the ambient light data obtained by the SCP processor overflows, the system switches to gain adjustment mode. In gain adjustment mode, if gain adjustment is completed, the system returns to normal sampling mode.
[0521] In the specific implementation, the ambient light sensor operates in normal sampling mode. N1 and N2 are both 10, and C2 is a fixed value.
[0522] The SCP processor obtains ambient light data H1 collected by the ambient light sensor on the electronic device in a collection period corresponding to a normal sampling mode; the ambient light data H1 is within the range of [a, b] and does not overflow.
[0523] The SCP processor sends the ambient light data H1 to the AP processor.
[0524] The AP processor stores the ambient light data H1 as first ambient light data in the FIFO.
[0525] The SCP processor obtains ambient light data H2 collected by the ambient light sensor on the electronic device in a collection period corresponding to a normal sampling mode; the ambient light data H2 is within the range of [a, b] and does not overflow.
[0526] The SCP processor sends the ambient light data H2 to the AP processor.
[0527] After receiving the ambient light data H2, the AP processor obtains a corresponding threshold value C1 based on the level range of H2.
[0528] The AP processor obtains a maximum value and a minimum value based on the ambient light data H1 and the ambient light data H2.
[0529] If the absolute value of the difference between the maximum value and the minimum value is smaller than C1, the AP processor stores the ambient light data H2 as the second ambient light data in the FIFO.
[0530] …
[0531] The SCP processor obtains ambient light data H10 (recorded as a first value) collected by the ambient light sensor on the electronic device in a collection period corresponding to a normal sampling mode; the ambient light data H10 is within the range of [a, b] and does not overflow.
[0532] The SCP processor sends the ambient light data H10 to the AP processor.
[0533] After receiving the ambient light data H10 , the AP processor obtains a corresponding threshold value C1 based on the level range of H10 .
[0534] The AP processor updates the maximum and minimum values based on the ambient light data H10 and the currently stored maximum and minimum values. It should be noted that the maximum and minimum values obtained at this time are the maximum and minimum values of the first ambient light data composed of H10 and the ambient light data stored in the FIFO.
[0535] The absolute value of the difference between the updated maximum value and the updated minimum value is smaller than C1, and the AP processor stores the ambient light data H10 as the tenth ambient light data in the FIFO.
[0536] At this time, 10 consecutive ambient light data have been stored, and the changes are all within the range of [0, C1). The AP processor clears the FIFO and sends information to the SCP processor indicating that the mode has been switched to a slow sampling mode (which may be a unique identifier corresponding to the sampling mode to be switched, or the sleep time or acquisition period of the sampling mode to be switched, etc.). This information is recorded as the first information.
[0537] As can be understood from the above examples, in normal sampling mode, the conditions for storing the currently received ambient light data include: the first ambient light data received after the FIFO is cleared; or, after the maximum and minimum values of the currently received ambient light data are updated, the absolute value of the difference between the maximum and minimum values is less than C1. For ease of description, this condition for storing ambient light data is referred to as the first storage condition. This first storage condition is the storage condition in normal sampling mode.
[0538] It should be noted that the conditions for determining stability may vary in different sampling modes. For example, in normal sampling mode, the condition for determining stability is that N1 ambient light data changes are stable within the range [0, C1), while in fast sampling mode, the condition for determining stability is that N2 ambient light data changes are stable within the range [0, C2). Therefore, when the AP processor determines that the sampling mode needs to be switched, it clears the FIFO.
[0539] The SCP processor receives information indicating switching to the slow sampling mode, and modifies the relevant information (sleep time or acquisition cycle) in the register to instruct the ambient light sensor to collect ambient light data with the sleep time or acquisition cycle stored in the register.
[0540] At this time, after step S1 , the ambient light sensor switches to the slow sampling mode.
[0541] The ambient light sensor collects ambient light data H11 in a slow sampling mode.
[0542] The SCP processor obtains ambient light data H11 collected by the ambient light sensor on the electronic device in a collection period corresponding to the slow sampling mode; the ambient light data H11 is within the range of [a, b] and does not overflow.
[0543] The SCP processor sends the ambient light data H11 to the AP processor.
[0544] The AP processor stores the ambient light data H11 as the first ambient light data in the FIFO.
[0545] The ambient light sensor collects ambient light data H12 in a slow sampling mode.
[0546] The SCP processor obtains ambient light data H12 (recorded as a third value) collected by the ambient light sensor on the electronic device in a collection period corresponding to the slow sampling mode; the ambient light data H12 is within the range of [a, b] and does not overflow.
[0547] The SCP processor sends the ambient light data H12 to the AP processor.
[0548] The AP processor obtains the corresponding threshold C1 based on the level range of H12.
[0549] The AP processor obtains the maximum and minimum values based on the ambient light data H12 and H11. The currently received ambient light data and the ambient light data stored in the FIFO constitute the third ambient light data, and the maximum and minimum values obtained at this time are the maximum and minimum values of the second ambient light data.
[0550] If the absolute value of the difference between the maximum value and the minimum value is greater than C2, the AP processor clears the FIFO and determines to switch the sampling mode to the fast sampling mode.
[0551] It should be noted that if the absolute value of the difference between the maximum value and the minimum value is greater than or equal to C1, and the absolute value of the difference is less than C2, the AP processor determines to switch the sampling mode to the normal sampling mode, that is, execute Figure 26 The embodiment of the present application takes step S2 switching to the fast sampling mode as an example.
[0552] The AP processor sends information indicating switching to the fast sampling mode to the SCP processor, where the information is recorded as third information.
[0553] To facilitate differentiation, the ambient light data H12 that causes the current slow sampling mode to switch to the normal sampling mode can be recorded as the second value. The information sent by the AP processor to the SCP processor indicating the switch from the slow sampling mode to the normal sampling mode is recorded as the second information. The currently received ambient light data H12 and the ambient light data stored in the FIFO constitute the second ambient light data.
[0554] The ambient light data H12 that causes the current slow sampling mode to switch to the fast sampling mode is recorded as a third value. The information sent by the AP processor to the SCP processor indicating the switch from the slow sampling mode to the fast sampling mode is recorded as third information. The currently received ambient light data H12 and the ambient light data stored in the FIFO constitute the third ambient light data.
[0555] In addition, it should be noted that in the slow sampling mode, it is not necessary to determine whether there is a certain amount of ambient light data whose changes are stable within a certain range. Therefore, in the slow sampling mode, the FIFO can be not cleared before switching to other sampling modes. Of course, in the slow sampling mode, the switch to other sampling modes will not be made only if the change in ambient light data is always less than C1. Therefore, the FIFO will not be cleared before switching to other sampling modes (normal sampling mode and fast sampling mode) in the slow sampling mode. Therefore, it is understood that in the slow sampling mode, before switching to other sampling modes (normal sampling mode and fast sampling mode), the received ambient light data is stored in accordance with the first storage condition; or in the slow sampling mode, before switching to other sampling modes (normal sampling mode and fast sampling mode), the received ambient light data meets the storage conditions.
[0556] The SCP processor receives information indicating switching to the fast sampling mode, and modifies the relevant information (sleep time or acquisition cycle) in the register to instruct the ambient light sensor to collect ambient light data with the sleep time or acquisition cycle stored in the register.
[0557] At this time, after step S2, the ambient light sensor switches to the fast sampling mode.
[0558] The ambient light sensor collects ambient light data H13 in a fast sampling mode.
[0559] The SCP processor obtains ambient light data H13 collected by the ambient light sensor on the electronic device in a collection period corresponding to the fast sampling mode; the ambient light data H13 is within the range of [a, b] and does not overflow.
[0560] The SCP processor sends the ambient light data H13 to the AP processor.
[0561] The AP processor stores the ambient light data H13 as the first ambient light data in the FIFO.
[0562] The SCP processor obtains ambient light data H14 collected by the ambient light sensor on the electronic device in a collection period corresponding to the fast sampling mode; the ambient light data H14 is within the range of [a, b] and does not overflow.
[0563] The SCP processor sends the ambient light data H14 to the AP processor.
[0564] After receiving the ambient light data H14 , the AP processor obtains the maximum value and the minimum value based on the ambient light data H13 and the ambient light data H14 .
[0565] If the absolute value of the difference between the maximum value and the minimum value is less than C2, the AP processor stores the ambient light data H14 as the second ambient light data in the FIFO.
[0566] …
[0567] The SCP processor obtains ambient light data H22 (recorded as the fourth value) collected by the ambient light sensor on the electronic device in a collection period corresponding to the fast sampling mode; the ambient light data H22 is within the range of [a, b] and does not overflow.
[0568] The SCP processor sends the ambient light data H22 to the AP processor.
[0569] After receiving the ambient light data H22, the AP processor updates the maximum and minimum values based on the ambient light data H22 and the currently stored maximum and minimum values. It should be noted that the maximum and minimum values obtained at this time are the maximum and minimum values of the fourth ambient light data composed of H22 and the ambient light data stored in the FIFO.
[0570] The absolute value of the difference between the updated maximum value and the updated minimum value is smaller than C2, and the AP processor stores the ambient light data H22 as the tenth ambient light data in the FIFO.
[0571] At this point, 10 consecutive ambient light data have been obtained, and the changes are all within the range of [0, C2), so the AP processor sends information indicating switching to the normal sampling mode to the SCP processor. This information is recorded as the fourth information.
[0572] As can be understood from the above examples, in normal sampling mode, the conditions for storing the currently received ambient light data include: the first ambient light data received after the FIFO is cleared; or, after the maximum and minimum values of the currently received ambient light data are updated, the absolute value of the difference between the maximum and minimum values is less than C2. For ease of description, this condition for storing ambient light data is referred to as the second storage condition. This second storage condition is the storage condition in rapid sampling mode.
[0573] At this time, since the normal sampling mode is about to be switched, the AP processor can clear the FIFO to determine stability in the normal sampling mode.
[0574] The SCP processor receives information indicating switching to the normal sampling mode, and modifies the relevant information in the register to instruct the ambient light sensor to collect ambient light data according to the sleep time or collection period stored in the register.
[0575] At this time, after step S3, the ambient light sensor switches to the normal sampling mode.
[0576] The SCP processor obtains ambient light data H23 collected by the ambient light sensor on the electronic device in a collection period corresponding to the normal sampling mode; the ambient light data H23 is within the range of [a, b] and does not overflow.
[0577] The SCP processor sends the ambient light data H23 to the AP processor.
[0578] After receiving the ambient light data H23, the AP processor stores the ambient light data H23 as the first ambient light data in the FIFO.
[0579] The SCP processor obtains ambient light data H24 (recorded as the fifth value) collected by the ambient light sensor on the electronic device in a collection period corresponding to the normal sampling mode; the ambient light data H24 is within the range of [a, b] and does not overflow.
[0580] The SCP processor sends the ambient light data H24 to the AP processor.
[0581] After receiving the ambient light data H24, the AP processor obtains a corresponding threshold value C1 based on the level range of H24.
[0582] The AP processor obtains the maximum value and the minimum value based on the ambient light data H24 and the ambient light data H23. The currently received ambient light data H24 and the ambient light data stored in the FIFO are recorded as the fifth ambient light data.
[0583] If the absolute value of the difference between the maximum value and the minimum value is greater than C2, the AP processor clears the FIFO and sends information indicating switching to the fast sampling mode to the SCP processor. This information is recorded as the fifth information.
[0584] The SCP processor receives information indicating switching to the fast sampling mode, and modifies relevant information in the register to instruct the ambient light sensor to collect ambient light data according to the sleep time or collection period stored in the register.
[0585] At this time, after step S4, the ambient light sensor switches to the fast sampling mode.
[0586] In the above process, if any ambient light data collected by the ambient light sensor overflows (any ambient light data from H1 to H24 is not within the range of [a, b]), the SCP processor will Figure 17 The illustrated embodiment controls the ambient light sensor to operate in the gain adjustment mode until it switches to the normal sampling mode.
[0587] In this embodiment of the present application, ambient light data that overflows the [a, b] range (referred to as the first range) is recorded as the sixth value, and the ambient light sensor collects the sixth value based on the first gain value. In this embodiment of the present application, the gain value adjusted from the first gain value is recorded as the second gain value, and the ambient light data collected by the ambient light sensor at the second gain value is recorded as the seventh value. If the seventh value does not overflow, the ambient light sensor adjusts the sleep duration to the sleep duration of the normal sampling mode, and the SCP processor sends the seventh value and seventh information indicating a switch to the normal sampling mode to the AP processor.
[0588] In actual applications, in the screen-off state, it is also possible to switch from the slow sampling mode to the gain adjustment mode, and then from the gain adjustment mode to the slow sampling mode. Refer to the description of the above embodiment. In the screen-off state, the overflowed ambient light data collected by the ambient light sensor in the slow sampling mode is recorded as the eighth value. When the ambient light sensor collects the eighth value, it is collected based on the third gain value. In the embodiment of the present application, the gain value adjusted from the third gain value is recorded as the fourth gain value, and the ambient light data collected by the ambient light sensor at the fourth gain value is recorded as the ninth value. If the ninth value does not overflow, the ambient light sensor will adjust the sleep time to the sleep time of the slow sampling mode, and the SCP processor will send the ninth value to the AP processor.
[0589] In the above embodiments, the SCP processor side obtains ambient light data and reports it to the AP processor; the AP processor side obtains data feature values of the ambient light data to determine whether to switch the sampling mode.
[0590] In actual applications, the SCP processor side obtains ambient light data and can also obtain data feature values of the ambient light data to determine whether to switch the sampling mode. That is, the above stability judgment algorithm running in the noise algorithm library of the AP processor can be loaded into the SCP processor.
[0591] The embodiment of the present application will not describe in detail the detailed process of the SCP processor obtaining the ambient light data and the SCP processor obtaining the data characteristic value of the ambient light data to determine whether to switch the sampling mode.
[0592] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0593] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0594] An embodiment of the present application further provides a computer program product. When the computer program product is run on an electronic device, the electronic device can implement the steps in the above-mentioned various method embodiments.
[0595] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program, when executed by the processor, can implement the steps of the above-mentioned various method embodiments. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to an electronic device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electric carrier signal, a telecommunication signal and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0596] The present application also provides a chip system, comprising a processor coupled to a memory, the processor executing a computer program stored in the memory to implement the steps of any method embodiment of the present application. The chip system can be a single chip or a chip module composed of multiple chips.
[0597] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.
[0598] Those skilled in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0599] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included in the scope of protection of the present application.
Claims
1. A method for detecting ambient light, characterized in that: Applied to an electronic device, the electronic device includes: a first processor and a second processor, the method includes: The first processor obtains a first value collected by an ambient light sensor on the electronic device in a first sampling mode; The first processor sends the first value to the second processor; The second processor receives the first value; The second processor sends first information to the first processor based on the first value, the first information corresponding to a second sampling mode; In response to receiving the first information, the first processor instructs the ambient light sensor to collect ambient light based on the second sampling mode, where the collection period of the second sampling mode is greater than the collection period of the first sampling mode, the collection period includes an integration period and a sleep period, and the integration period of the second sampling mode is the same as that of the first sampling mode.
2. The method according to claim 1, wherein The second processor sending first information to the first processor based on the first value includes: The second processor determines a maximum value and a minimum value in first ambient light data, where the first ambient light data includes the first value and ambient light data stored in a first storage space, where the ambient light data stored in the first storage space is ambient light data that meets a first storage condition and is stored after the second processor last clears the first storage space; If the absolute value of the difference between the maximum value and the minimum value in the first ambient light data is less than a first threshold, the second processor stores the first value in the first storage space; After storing the first value in the first storage space, if the ambient light data stored in the first storage space is a first amount of ambient light data, the second processor sends the first information to the first processor.
3. The method according to claim 1, wherein After the first processor instructs the ambient light sensor to collect ambient light based on the second sampling mode, the method further includes: The first processor obtains a second value collected by the ambient light sensor in the second sampling mode; The first processor sends the second value to the second processor; The second processor receives the second value; The second processor sends second information to the first processor based on the second value, where the second information corresponds to the first sampling mode; In response to receiving the second information, the first processor instructs the ambient light sensor to collect ambient light based on the first sampling mode.
4. The method according to claim 3, wherein The second processor sending second information to the first processor based on the second value includes: The second processor determines a maximum value and a minimum value in the received second ambient light data, where the second ambient light data is ambient light data collected after the ambient light sensor switches to the second sampling mode, and the second ambient light data includes the second value; If the absolute value of the difference between the maximum and minimum values in the second ambient light data is greater than or equal to a first threshold, and the absolute value of the difference between the maximum and minimum values in the second ambient light data is less than a second threshold, the second processor sends the second information to the first processor.
5. The method according to claim 1, wherein After the first processor instructs the ambient light sensor to collect ambient light based on the second sampling mode, the method further includes: Acquiring, by the first processor, a third value collected by the ambient light sensor in the second sampling mode; The first processor sends the third value to the second processor; The second processor receives the third value; The second processor sends third information to the first processor based on the third value, where the third information corresponds to a third sampling mode; In response to receiving the third information, the first processor instructs the ambient light sensor to collect ambient light based on the third sampling mode.
6. The method according to claim 5, wherein The second processor sending third information to the first processor based on the third value includes: The second processor determines a maximum value and a minimum value in the received third ambient light data, where the third ambient light data is ambient light data collected after the ambient light sensor switches to the second sampling mode, and the third ambient light data includes the third value; If the absolute value of the difference between the maximum value and the minimum value in the third ambient light data is greater than or equal to a second threshold, the second processor sends the third information to the first processor.
7. The method according to claim 5, wherein After the first processor instructs the ambient light sensor to collect ambient light based on the third sampling mode, the method further includes: Acquiring, by the first processor, a fourth value collected by the ambient light sensor in the third sampling mode; The first processor sends the fourth value to the second processor; The second processor receives the fourth value; The second processor sends fourth information to the first processor based on the fourth value, where the fourth information corresponds to the first sampling mode; In response to receiving the fourth information, the first processor instructs the ambient light sensor to collect ambient light based on the first sampling mode.
8. The method according to claim 7, wherein The second processor sending fourth information to the first processor based on the fourth value includes: The second processor determines a maximum value and a minimum value of fourth ambient light data, where the fourth ambient light data includes the fourth value and ambient light data stored in the first storage space, where the ambient light data stored in the first storage space is ambient light data that meets a second storage condition and is stored after the second processor last clears the first storage space; If the absolute value of the difference between the maximum value and the minimum value in the fourth ambient light data is less than a second threshold, the second processor stores the fourth value in the first storage space; After storing the fourth value in the first storage space, if the ambient light data stored in the first storage space is a second amount of ambient light data, the second processor sends the fourth information to the first processor.
9. The method according to claim 3, 4, 7 or 8, wherein: After the first processor instructs the ambient light sensor to collect ambient light based on the first sampling mode, the method further includes: The first processor obtains a fifth value collected by the ambient light sensor in the first sampling mode; The first processor sends the fifth value to the second processor; The second processor receives the fifth value; The second processor sends fifth information to the first processor based on the fifth value, where the fifth information corresponds to a third sampling mode; In response to receiving the fifth information, the first processor instructs the ambient light sensor to collect ambient light based on the third sampling mode.
10. The method according to claim 9, wherein The second processor sending fifth information to the first processor based on the fifth value includes: The second processor determines a maximum value and a minimum value of fifth ambient light data, where the fifth ambient light data includes the fifth value and ambient light data stored in the first storage space, where the ambient light data stored in the first storage space is ambient light data that meets the first storage condition and is stored after the second processor clears the first storage space for the last time; If the absolute value of the difference between the maximum value and the minimum value in the fifth ambient light data is greater than or equal to a second threshold, the second processor sends fifth information to the first processor.
11. The method according to any one of claims 1 to 8, characterized in that The method further comprises: The first processor obtains a sixth value collected by the ambient light sensor in any sampling mode, where the sixth value is ambient light data collected by the ambient light sensor in a first gain value, and the any sampling mode includes the first sampling mode, the second sampling mode, and the third sampling mode; If the sixth value is not within the first range, the first processor adjusts the gain value of the ambient light sensor to a second gain value; The first processor instructs the ambient light sensor to collect ambient light based on a fourth sampling mode, where a collection period of the fourth sampling mode is shorter than a collection period of the first sampling mode; the first processor obtains a seventh value collected by the ambient light sensor using the fourth sampling mode and the second gain value; If the seventh value is within the first range, the first processor instructs the ambient light sensor to collect ambient light in the first sampling mode, and the first processor sends the seventh value and seventh information to the second processor; The second processor receives the seventh value and the seventh information, where the seventh information is used to indicate that the ambient light sensor is switched to the first sampling mode; The second processor clears the first storage space based on the seventh information; After clearing the first storage space, the second processor stores the seventh value in the first storage space.
12. The method according to claim 2, wherein If the absolute value of the difference between the maximum value and the minimum value in the first ambient light data is less than a first threshold, the second processor stores the first value in the first storage space, including: The second processor obtains a brightness level of the first value based on the first value; If the absolute value of the difference between the maximum value and the minimum value in the first ambient light data is smaller than a first threshold corresponding to the brightness level of the first value, the second processor stores the first value in the first storage space.
13. The method according to claim 12, wherein: The brightness levels include: a first brightness level, a second brightness level, a third brightness level, and a fourth brightness level; the threshold between the first brightness level and the second brightness level is a first threshold value; the threshold between the second brightness level and the third brightness level is a second threshold value; the threshold between the third brightness level and the fourth brightness level is a third threshold value; the first threshold value is less than the second threshold value, and the second threshold value is less than the third threshold value; The second processor obtains the brightness level of the first value based on the first value, including: determining a relationship between the first value and the second critical value; If the first value is equal to the second critical value, the brightness level at which the first value is located is the brightness level at which the second critical value is located; If the first value is less than the second critical value, determining the relationship between the first value and the first critical value; If the first value is less than the first critical value, the brightness level at which the first value is located is the first brightness level; if the first value is greater than the first critical value, the brightness level at which the first value is located is the second brightness level; if the first value is equal to the first critical value, the brightness level at which the first value is located is the brightness level at which the first critical value is located; If the first value is greater than the second critical value, determining the relationship between the first value and the third critical value; If the first value is less than the third critical value, the brightness level at which the first value is located is the third brightness level; if the first value is greater than the third critical value, the brightness level at which the first value is located is the fourth brightness level; if the first value is equal to the third critical value, the brightness level at which the first value is located is the brightness level at which the third critical value is located.
14. The method according to any one of claims 1 to 8, characterized in that The display screen of the electronic device is in a bright screen state.
15. The method according to any one of claims 1 to 8, characterized in that The method further comprises: In response to the display screen of the electronic device being switched to a screen-off state, the first processor instructs the ambient light sensor to collect ambient light in a second sampling mode.
16. The method according to claim 15, wherein When the display screen of the electronic device is in a screen-off state, the method further includes: The first processor obtains an eighth value collected by the ambient light sensor in the second sampling mode, where the eighth value is ambient light data collected by the ambient light sensor in the third gain value; If the eighth value is not within the first range, the first processor adjusts the gain value of the ambient light sensor to a fourth gain value; The first processor instructs the ambient light sensor to collect ambient light based on a fourth sampling mode, where a collection period of the fourth sampling mode is shorter than a collection period of the second sampling mode; the first processor obtains a ninth value collected by the ambient light sensor using the fourth sampling mode and the fourth gain value; If the ninth value is within the first range, the first processor instructs the ambient light sensor to collect ambient light in a second sampling mode, and the first processor sends the ninth value to the second processor.
17. The method according to claim 2, wherein The ambient light data meeting the first storage condition includes: After the second processor clears the first storage space, the first ambient light data received is the ambient light data that meets the first storage condition; If an absolute value of a difference between the maximum value and the minimum value of the ambient light data currently received by the second processor and the ambient light data currently stored in the first storage space is less than a first threshold, the currently received ambient light data satisfies the first storage condition; The condition for the second processor to clear the first storage space includes: In normal sampling mode, if the absolute value of the difference between the maximum and minimum values of the ambient light data currently received by the second processor and the ambient light data currently stored in the first storage space is not less than the first threshold and less than the second threshold, the condition for clearing the first storage space is met.
18. The method according to claim 1, wherein The electronic device further includes: an ambient light sensor driver, an ambient light sensor, a HWC module, and a noise algorithm library. The method includes: The first processor drives the ambient light sensor to obtain a first value collected by the ambient light sensor in a first sampling mode; The first processor drives the ambient light sensor to send the first value to the HWC module; The second processor receives the first value through the HWC module, and the second processor sends the first value to the noise algorithm library through the HWC module; The second processor sends first information to the HWC module based on the first value through a noise algorithm library; The second processor sends the first information to the ambient light sensor driver through the HWC module, where the first information corresponds to a second sampling mode; In response to receiving the first information, the first processor drives the ambient light sensor to instruct the ambient light sensor to collect ambient light based on the second sampling mode, where a collection period of the second sampling mode is greater than a collection period of the first sampling mode.
19. A method for detecting ambient light, characterized in that: Applied to an electronic device, the electronic device includes a second processor, and the method includes: The second processor receives a first value, where the first value is ambient light data collected by an ambient light sensor of the electronic device in a first sampling mode; The second processor determines a maximum value and a minimum value in first ambient light data, where the first ambient light data includes the first value and ambient light data stored in a first storage space, where the ambient light data stored in the first storage space is ambient light data that meets a storage condition and is stored after the second processor last clears the first storage space; If the absolute value of the difference between the maximum value and the minimum value in the first ambient light data is less than a first threshold, the second processor stores the first value in the first storage space; After storing the first value in the first storage space, if the ambient light data stored in the first storage space is a first amount of ambient light data, the second processor sends first information to the first processor of the electronic device, and the first information is used to instruct the first processor to control the ambient light sensor to collect ambient light based on a second sampling mode. The collection period of the second sampling mode is greater than the collection period of the first sampling mode. The collection period includes an integration period and a sleep period. The integration period of the second sampling mode is the same as that of the first sampling mode.
20. The method according to claim 19, wherein The method further comprises: The second processor receives a seventh value and seventh information, where the seventh information is used to indicate that the ambient light sensor switches from a gain adjustment mode to the first sampling mode, where the gain adjustment mode of the ambient light sensor is a mode in which the first processor adjusts the gain value of the ambient light sensor when the ambient light data collected by the ambient light sensor is not within the first range; The second processor clears the first storage space based on the seventh information; After clearing the first storage space, the second processor stores the seventh value in the first storage space.
21. The method according to claim 19, wherein If the absolute value of the difference between the maximum value and the minimum value in the first ambient light data is less than a first threshold, the second processor stores the first value in the first storage space, including: The second processor obtains a brightness level of the first value based on the first value; If the absolute value of the difference between the maximum value and the minimum value in the first ambient light data is smaller than a first threshold corresponding to the brightness level of the first value, the second processor stores the first value in the first storage space.
22. The method according to claim 21, wherein The brightness levels include: a first brightness level, a second brightness level, a third brightness level, and a fourth brightness level; the threshold between the first brightness level and the second brightness level is a first threshold value; the threshold between the second brightness level and the third brightness level is a second threshold value; the threshold between the third brightness level and the fourth brightness level is a third threshold value; the first threshold value is less than the second threshold value, and the second threshold value is less than the third threshold value; The second processor obtains the brightness level of the first value based on the first value, including: determining a relationship between the first value and the second critical value; If the first value is equal to the second critical value, the brightness level at which the first value is located is the brightness level at which the second critical value is located; If the first value is less than the second critical value, determining the relationship between the first value and the first critical value; If the first value is less than the first critical value, the brightness level at which the first value is located is the first brightness level; if the first value is greater than the first critical value, the brightness level at which the first value is located is the second brightness level; if the first value is equal to the first critical value, the brightness level at which the first value is located is the brightness level at which the first critical value is located; If the first value is greater than the second critical value, determining the relationship between the first value and the third critical value; If the first value is less than the third critical value, the brightness level at which the first value is located is the third brightness level; if the first value is greater than the third critical value, the brightness level at which the first value is located is the fourth brightness level; if the first value is equal to the third critical value, the brightness level at which the first value is located is the brightness level at which the third critical value is located.
23. The method according to any one of claims 19 to 22, wherein: The ambient light data meeting the storage conditions includes: After the second processor clears the first storage space, the first ambient light data received is the ambient light data that meets the storage condition; If an absolute value of a difference between the maximum value and the minimum value of the ambient light data currently received by the second processor and the ambient light data currently stored in the first storage space is less than a first threshold, the currently received ambient light data is ambient light data that meets the storage condition; The conditions for clearing the first storage space include: If the absolute value of the difference between the maximum and minimum values of the ambient light data currently received by the second processor and the ambient light data currently stored in the first storage space is not less than the first threshold and less than the second threshold, the condition for clearing the first storage space is met.
24. A method for detecting ambient light, characterized in that: Applied to an electronic device, the electronic device includes a first processor, and the method includes: The first processor obtains a first value collected by an ambient light sensor on the electronic device in a first sampling mode; The first processor determines a maximum value and a minimum value in first ambient light data, where the first ambient light data includes the first value and ambient light data stored in a first storage space, where the ambient light data stored in the first storage space is ambient light data that meets a storage condition and is stored after the first processor last clears the first storage space; If the absolute value of the difference between the maximum value and the minimum value in the first ambient light data is less than a first threshold, the first processor stores the first value in the first storage space; After storing the first value in the first storage space, if the ambient light data stored in the first storage space is a first amount of ambient light data, the first processor instructs the ambient light sensor to collect ambient light based on a second sampling mode, the collection period of the second sampling mode is greater than the collection period of the first sampling mode, the collection period includes an integration time and a sleep time, and the integration time of the second sampling mode is the same as that of the first sampling mode.
25. An electronic device, characterized in that: The electronic device includes a first processor and a second processor, where the first processor and the second processor are configured to run a computer program stored in a memory, so that the electronic device implements the method according to any one of claims 1 to 24.
26. A chip system, characterized in that: The device comprises a processor coupled to a memory, and the processor executes a computer program stored in the memory to implement the method according to any one of claims 1 to 24.
27. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed on a processor, the method according to any one of claims 1 to 24 is implemented.
Citation Information
Patent Citations
Method and device for adjusting backlight brightness of display screen of terminal and terminal
CN105702230A
Ambient light detection method, ambient light detection device, terminal equipment and storage medium
CN112710388A