Android Qcom Display learning (13)

The link to the general table of contents and the introduction to each part of this series of articles: Android Qcom Display Learning (Zero)
In the previous article dump GraphicBuffer, I learned that setColorTransform is called in eye protection mode and is applied to each layer, so I wanted to learn more about color. It is for the screen, not for a single Layer. The pictures produced by Screencap do not have color mode.

Detailed analysis of Android10 Night Light implementation of color
gamut, color depth, color difference and other parameters of the display screen, one of the important indicators of the screen

Android native support mode

frameworks/base/services/core/java/com/android/server/display/color/DisplayTransformManager.java setColorMode
frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp SurfaceFlinger::onTransact

In eye protection mode, only DisplayTransformManager::setColorMatrix is ​​called through applyTint to adjust the color temperature. In
color mode, DisplayTransformManager::setColorMode is called through setColorMode to adjust the color mode.

Four color modes natively supported by Android

(1)COLOR_MODE_NATURAL      COLOR_SATURATION_NATURAL + DISPLAY_COLOR_MANAGED
(2)COLOR_MODE_BOOSTED      COLOR_SATURATION_BOOSTED + DISPLAY_COLOR_MANAGED
(3)COLOR_MODE_SATURATED    COLOR_SATURATION_NATURAL + DISPLAY_COLOR_UNMANAGED 
(4)COLOR_MODE_AUTOMATIC    COLOR_SATURATION_NATURAL + DISPLAY_COLOR_ENHANCED

Mainly set based on the following four parameters: (1)saturation (2)color display mode (3)compositionColorMode color mode (4)level color conversion

1.applySaturation(saturation)

Can be communicated with SurfaceFlinger via SURFACE_FLINGER_TRANSACTION_SATURATION = 1022 via the "persist.sys.sf.color_saturation" setting

COLOR_SATURATION_NATURAL = 1.0f;
COLOR_SATURATION_BOOSTED = 1.1f;

2.setDisplayColor(color)

Can communicate with SurfaceFlinger via SURFACE_FLINGER_TRANSACTION_DISPLAY_COLOR = 1023 via the "persist.sys.sf.native_mode" setting

DISPLAY_COLOR_MANAGED = 0;
DISPLAY_COLOR_UNMANAGED = 1;
DISPLAY_COLOR_ENHANCED = 2;

3.setDisplayColor(compositionColorMode)

Can be communicated with SurfaceFlinger via SURFACE_FLINGER_TRANSACTION_DISPLAY_COLOR = 1023 via the "persist.sys.sf.color_mode" setting

COLOR_MODE_INVALID = -1;
COLOR_MODE_DEFAULT = 0;
COLOR_MODE_BT601_625 = 1;
COLOR_MODE_BT601_625_UNADJUSTED = 2;
COLOR_MODE_BT601_525 = 3;
COLOR_MODE_BT601_525_UNADJUSTED = 4;
COLOR_MODE_BT709 = 5;
COLOR_MODE_DCI_P3 = 6;
COLOR_MODE_SRGB = 7;
COLOR_MODE_ADOBE_RGB = 8;
COLOR_MODE_DISPLAY_P3 = 9;

4.setColorMatrix(level)

Set the color temperature through setMatrix and communicate with SurfaceFlinger through SURFACE_FLINGER_TRANSACTION_COLOR_MATRIX = 1015

LEVEL_COLOR_MATRIX_NIGHT_DISPLAY = 100;
LEVEL_COLOR_MATRIX_DISPLAY_WHITE_BALANCE = 125;

色温调节范围设置
<integer name="config_nightDisplayColorTemperatureMin">2596</integer>
<integer name="config_nightDisplayColorTemperatureMax">4082</integer>

The default setting is the supported Display white balance, but this function is not turned on. You can modify it as follows.

packages/apps/Settings/res/xml/display_settings.xml Settings.APK
<SwitchPreference
     android:key="display_white_balance"
     android:title="@string/display_white_balance_title"
     android:summary="@string/display_white_balance_summary"
     settings:controller="com.android.settings.display.DisplayWhiteBalancePreferenceController"/>
	 
DisplayWhiteBalancePreferenceController getAvailabilityStatus 
    DisplayWhiteBalanceTintController isDisplayWhiteBalanceAvailable
	    ColorDisplayManager  config_displayWhiteBalanceAvailable (services.jar)
		
frameworks/base/core/res/res/values/config.xml framework-res.apk
-<bool name="config_displayWhiteBalanceAvailable">false</bool>
+<bool name="config_displayWhiteBalanceAvailable">true</bool>

After opening it, it had no effect, and then I discovered that I need AmbientSensor.AmbientColorTemperatureSensor environmental color temperature sensor support to keep updating Temperature.

In fact, it is very simple to achieve this manual white balance adjustment. For those new to the framework, three days is enough. Add or modify the following files.

packages/apps/Settings/res/xml/display_settings.xml
packages/apps/Settings/res/xml/whitebalance_display_settings.xml
packages/apps/Settings/src/com/android/settings/display/DisplayWhiteBalancePreferenceController.java
packages/apps/Settings/src/com/android/settings/display/WhiteBalanceIntensityPreferenceController.java
packages/apps/Settings/src/com/android/settings/display/WhiteBalanceSettings.java

First-level menu display_settings.xml Second-level menu whitebalance_display_settings.xml
WhiteBalanceSettings.java layout related
DisplayWhiteBalancePreferenceController.java control function switch
WhiteBalanceIntensityPreferenceController control manual adjustment sliding

The com.android.settings.widget.PrimarySwitchPreference switch is separate from the left area. The left side jumps to the second level
SwitchPreference switch and the whole area will jump to the second level menu. Preference has no switch, and the whole area jumps to the second level.

<com.android.settings.widget.PrimarySwitchPreference
            android:key="display_white_balance"
            android:title="@string/display_white_balance_title"
            android:fragment="com.android.settings.display.WhiteBalanceSettings"
            android:summary="@string/display_white_balance_summary"
            settings:controller="com.android.settings.display.DisplayWhiteBalancePreferenceController"
            settings:keywords="@string/keywords_display_night_display"/>
			
<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:settings="http://schemas.android.com/apk/res-auto"
    android:title="@string/display_white_balance_title"
    settings:keywords="@string/display_white_balance_title">

    <com.android.settings.widget.SeekBarPreference
        android:key="whitebalance_temperature"
        android:title="@string/night_display_temperature_title"
        settings:keywords="@string/keywords_color_temperature"
        settings:controller="com.android.settings.display.WhiteBalanceIntensityPreferenceController"
        settings:unavailableSliceSubtitle="@string/night_display_not_currently_on"/>

</PreferenceScreen>

Add a control interface with Settings.apk, mainly to obtain and set color temperature. It should be noted that since there is no AmbientSensor, the new
DisplayWhiteBalanceController object will fail and you need to log out. ValidateArguments will be judged to be a null object.

framework/base/core/java/android/hardware/display/ColorDisplayManager.java
framework/base/core/java/android/hardware/display/IColorDisplayManager.aidl
framework/base/core/java/android/hardware/display/WhiteBalanceListener.java
framework/base/core/res/res/values/config.xml
framework/base/services/core/java/com/android/server/display/color/ColorDisplayService.java
framework/base/services/core/java/com/android/server/display/color/DisplayWhiteBalanceTintController.java
framework/base/services/core/java/com/android/server/display/whitebalance/DisplayWhiteBalanceController.java	
framework/base/services/core/java/com/android/server/display/whitebalance/DisplayWhiteBalanceFactory.java

Android color mode gamut

       In fact, the color gamut can also be called color space, which refers to the range of colors that can be expressed by the color representation model, and refers to the total number of colors that a technical system can produce. The maximum range in the figure below is the color space acceptable to the human eye, and the color gamut standards on the market are all subsets of it. The higher the color gamut, the richer the colors and the closer they are to the real colors seen by the naked eye.

Insert image description here
       Wide color gamut is used to describe devices and color spaces that can reproduce more colors than the sRGB color space. In the original era of CRT and TN screens, the color gamut was small. Maybe it used to be called a wide color gamut if it reached 70% of the sRGB color gamut, but now there are better technology blessings (IPS screen, OLED screen, QLED screen ), the color gamut needs to be increased to 90% sRGB to be satisfied.

       The color gamut standard of SRGB/NTSC/DCI-P3 is widely used in the mobile phone screen industry. Since the size of the color gamut space is inconsistent, the promotion may tend to use a larger proportion range. I have asked the module factory before, and it is different. The standard source of the screen color gamut is mainly based on the material of the screen. The driver IC mainly affects the gamma brightness and has less impact on the color gamut. In the process of customer selection, the priority of the color gamut is not the first, but the size of the screen. And performance are the main factors in selection. Unless there are special requirements for color gamut, generally the color gamut is above 65% NTSC + the gamma parameter of the IC is adjusted well, and the overall quality of the screen is still good. Generally speaking, the higher the color gamut under the same standard, the better, but it does not mean that a high color gamut can truly display colors. The color gamut must be matched with color restoration to reflect the true performance of the monitor in terms of color.

1.sRGB

The sRGB color gamut is a color space jointly developed by Microsoft and HP in 1996. It is also the color space currently supported by Microsoft's Windows system and many native software by default.

2.NTSC

The standard specified by the NTSC color gamut (National Television Standards Committee) is not directly compatible with computer systems and cannot completely cover sRGB. 100% sRGB ≈ 72% NTSC

3.DCI-P3

DCI-P3 is a color gamut used in digital cinemas. It is a color gamut standard that is dominated by human visual experience and matches as much as possible the entire color gamut that can be displayed in movie scenes. It is not the standard with the widest color gamut (the latest standard is BT.2020), but it has a wider red/green range above the Rec.709 standard.

4.Adobe RGB

Adobe RGB is a color space launched by Adobe, a professional software manufacturer, in 1998. The original intention was to include both sRGB (a color space commonly used in computers) and CMYK (a color space commonly used in printing). With the development of CCD/CMOS, photos taken Digital photos can not only be displayed and edited normally on a computer, but can also be printed with lossless and correct colors.

Android eye protection mode color temperature

Insert image description here
       Color temperature is used to describe common warm and cold colors. When debugging AWB with Camera Tunning, it will involve artificial light sources D65 (6500K) and D50 (5000K). It is adjusted through the ISP algorithm under different color temperatures to offset the color cast caused by color temperature. In fluorescent lamps Shooting in a room will look green, shooting under indoor tungsten lighting will look yellowish, and shooting in the shade of sunlight will look bluish.
       There is no specific standard for color temperature, it depends on the adaptability of individual glasses. It generally tests the stability of the white point color temperature of the display device under different brightness levels of the screen (such as five brightness levels of 0%, 25%, 50%, 75%, and 100%), so that the electronic product screen can display pure white. Under the D65 standard, color temperature 6500K is marked as normal, below 6500K is on the warm side, and above 6500K is on the cold side. The test results show a specification of ±500K based on the standard color temperature value of 6500K, which means that the display device has only very low tonal transitions in grayscale.

Guess you like

Origin blog.csdn.net/qq_40405527/article/details/126921620