diff options
author | Steve Kondik <steve@cyngn.com> | 2016-07-18 02:36:42 -0700 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2016-07-20 10:07:31 -0700 |
commit | 86cae92291f728d0eca637573ecbe6e0a53ccf1a (patch) | |
tree | 577cc188e1b9fc69b006135fbb480b1848a29e1d /sdk/src/java/cyanogenmod | |
parent | 25d708141814289067587e504a0bb33a76c28a78 (diff) | |
download | vendor_cmsdk-86cae92291f728d0eca637573ecbe6e0a53ccf1a.zip vendor_cmsdk-86cae92291f728d0eca637573ecbe6e0a53ccf1a.tar.gz vendor_cmsdk-86cae92291f728d0eca637573ecbe6e0a53ccf1a.tar.bz2 |
livedisplay: Add support for direct color balance control
* We currently use the DisplayColorCalibration API for setting display
temperature which makes a lot of guesses about what temperature
the display really is. Some devices will support the new ColorBalance
API (via QDCM or other mechanism), which offers a calibrated
alternative. Add support for this, which will supercede DCC if
available.
* Additionally, define the available color temperature range as a
set of overlayable values so this can be specified per-device.
This range will be mapped to balance values using the power curve
calculations in the new MathUtils class.
Change-Id: I99608c09807b747d962680293c7b0cee8d669003
Diffstat (limited to 'sdk/src/java/cyanogenmod')
5 files changed, 97 insertions, 4 deletions
diff --git a/sdk/src/java/cyanogenmod/hardware/CMHardwareManager.java b/sdk/src/java/cyanogenmod/hardware/CMHardwareManager.java index 7765b94..d31ce9b 100644 --- a/sdk/src/java/cyanogenmod/hardware/CMHardwareManager.java +++ b/sdk/src/java/cyanogenmod/hardware/CMHardwareManager.java @@ -20,6 +20,7 @@ import android.os.IBinder; import android.os.RemoteException; import android.os.ServiceManager; import android.util.Log; +import android.util.Range; import cyanogenmod.app.CMContextConstants; @@ -129,6 +130,11 @@ public final class CMHardwareManager { */ public static final int FEATURE_UNIQUE_DEVICE_ID = 0x10000; + /** + * Color balance + */ + public static final int FEATURE_COLOR_BALANCE = 0x20000; + private static final List<Integer> BOOLEAN_FEATURES = Arrays.asList( FEATURE_ADAPTIVE_BACKLIGHT, FEATURE_COLOR_ENHANCEMENT, @@ -803,6 +809,39 @@ public final class CMHardwareManager { return false; } + public Range<Integer> getColorBalanceRange() { + int min = 0; + int max = 0; + try { + if (checkService()) { + min = sService.getColorBalanceMin(); + max = sService.getColorBalanceMax(); + } + } catch (RemoteException e) { + } + return new Range<Integer>(min, max); + } + + public int getColorBalance() { + try { + if (checkService()) { + return sService.getColorBalance(); + } + } catch (RemoteException e) { + } + return 0; + } + + public boolean setColorBalance(int value) { + try { + if (checkService()) { + return sService.setColorBalance(value); + } + } catch (RemoteException e) { + } + return false; + } + /** * @return true if service is valid */ diff --git a/sdk/src/java/cyanogenmod/hardware/ICMHardwareService.aidl b/sdk/src/java/cyanogenmod/hardware/ICMHardwareService.aidl index a1ae65b..6fbaf66 100644 --- a/sdk/src/java/cyanogenmod/hardware/ICMHardwareService.aidl +++ b/sdk/src/java/cyanogenmod/hardware/ICMHardwareService.aidl @@ -58,4 +58,9 @@ interface ICMHardwareService { boolean isSunlightEnhancementSelfManaged(); String getUniqueDeviceId(); + + int getColorBalanceMin(); + int getColorBalanceMax(); + int getColorBalance(); + boolean setColorBalance(int value); } diff --git a/sdk/src/java/cyanogenmod/hardware/LiveDisplayConfig.java b/sdk/src/java/cyanogenmod/hardware/LiveDisplayConfig.java index 81945f7..81cdca3 100644 --- a/sdk/src/java/cyanogenmod/hardware/LiveDisplayConfig.java +++ b/sdk/src/java/cyanogenmod/hardware/LiveDisplayConfig.java @@ -23,6 +23,7 @@ import static cyanogenmod.hardware.LiveDisplayManager.MODE_OFF; import android.os.Parcel; import android.os.Parcelable; +import android.util.Range; import java.util.BitSet; @@ -50,10 +51,15 @@ public class LiveDisplayConfig implements Parcelable { private final boolean mDefaultCABC; private final boolean mDefaultColorEnhancement; + private final Range<Integer> mColorTemperatureRange; + private final Range<Integer> mColorBalanceRange; + public LiveDisplayConfig(BitSet capabilities, int defaultMode, int defaultDayTemperature, int defaultNightTemperature, boolean defaultAutoOutdoorMode, boolean defaultAutoContrast, - boolean defaultCABC, boolean defaultColorEnhancement) { + boolean defaultCABC, boolean defaultColorEnhancement, + Range<Integer> colorTemperatureRange, + Range<Integer> colorBalanceRange) { super(); mCapabilities = (BitSet) capabilities.clone(); mAllModes.set(MODE_FIRST, MODE_LAST); @@ -64,6 +70,8 @@ public class LiveDisplayConfig implements Parcelable { mDefaultAutoOutdoorMode = defaultAutoOutdoorMode; mDefaultCABC = defaultCABC; mDefaultColorEnhancement = defaultColorEnhancement; + mColorTemperatureRange = colorTemperatureRange; + mColorBalanceRange = colorBalanceRange; } private LiveDisplayConfig(Parcel parcel) { @@ -80,6 +88,10 @@ public class LiveDisplayConfig implements Parcelable { boolean defaultAutoOutdoorMode = false; boolean defaultCABC = false; boolean defaultColorEnhancement = false; + int minColorTemperature = 0; + int maxColorTemperature = 0; + int minColorBalance = 0; + int maxColorBalance = 0; if (parcelableVersion >= Build.CM_VERSION_CODES.FIG) { capabilities = parcel.readLong(); @@ -90,6 +102,10 @@ public class LiveDisplayConfig implements Parcelable { defaultAutoOutdoorMode = parcel.readInt() == 1; defaultCABC = parcel.readInt() == 1; defaultColorEnhancement = parcel.readInt() == 1; + minColorTemperature = parcel.readInt(); + maxColorTemperature = parcel.readInt(); + minColorBalance = parcel.readInt(); + maxColorBalance = parcel.readInt(); } // set temps @@ -102,6 +118,8 @@ public class LiveDisplayConfig implements Parcelable { mDefaultAutoOutdoorMode = defaultAutoOutdoorMode; mDefaultCABC = defaultCABC; mDefaultColorEnhancement = defaultColorEnhancement; + mColorTemperatureRange = Range.create(minColorTemperature, maxColorTemperature); + mColorBalanceRange = Range.create(minColorBalance, maxColorBalance); // Complete parcel info for the concierge parcelInfo.complete(); @@ -118,6 +136,8 @@ public class LiveDisplayConfig implements Parcelable { sb.append(" defaultAutoContrast=").append(mDefaultAutoContrast); sb.append(" defaultCABC=").append(mDefaultCABC); sb.append(" defaultColorEnhancement=").append(mDefaultColorEnhancement); + sb.append(" colorTemperatureRange=").append(mColorTemperatureRange); + sb.append(" colorBalanceRange=").append(mColorBalanceRange); return sb.toString(); } @@ -141,6 +161,10 @@ public class LiveDisplayConfig implements Parcelable { out.writeInt(mDefaultAutoOutdoorMode ? 1 : 0); out.writeInt(mDefaultCABC ? 1 : 0); out.writeInt(mDefaultColorEnhancement ? 1 : 0); + out.writeInt(mColorTemperatureRange.getLower()); + out.writeInt(mColorTemperatureRange.getUpper()); + out.writeInt(mColorBalanceRange.getLower()); + out.writeInt(mColorBalanceRange.getUpper()); // Complete the parcel info for the concierge parcelInfo.complete(); @@ -243,6 +267,24 @@ public class LiveDisplayConfig implements Parcelable { return mDefaultColorEnhancement; } + /** + * Get the range of supported color temperatures + * + * @return range in Kelvin + */ + public Range<Integer> getColorTemperatureRange() { + return mColorTemperatureRange; + } + + /** + * Get the range of supported color balance + * + * @return linear range which maps into the temperature range curve + */ + public Range<Integer> getColorBalanceRange() { + return mColorBalanceRange; + } + /** @hide */ public static final Parcelable.Creator<LiveDisplayConfig> CREATOR = new Parcelable.Creator<LiveDisplayConfig>() { diff --git a/sdk/src/java/cyanogenmod/hardware/LiveDisplayManager.java b/sdk/src/java/cyanogenmod/hardware/LiveDisplayManager.java index abfd158..5a39a98 100644 --- a/sdk/src/java/cyanogenmod/hardware/LiveDisplayManager.java +++ b/sdk/src/java/cyanogenmod/hardware/LiveDisplayManager.java @@ -102,10 +102,17 @@ public class LiveDisplayManager { */ public static final int FEATURE_DISPLAY_MODES = 15; + /** + * System supports direct range-based control of display + * color balance (temperature). This is preferred over + * simple RGB adjustment. + */ + public static final int FEATURE_COLOR_BALANCE = 16; + /** @hide */ public static final int FEATURE_FIRST = FEATURE_CABC; /** @hide */ - public static final int FEATURE_LAST = FEATURE_DISPLAY_MODES; + public static final int FEATURE_LAST = FEATURE_COLOR_BALANCE; private static final String TAG = "LiveDisplay"; diff --git a/sdk/src/java/cyanogenmod/providers/CMSettings.java b/sdk/src/java/cyanogenmod/providers/CMSettings.java index 38c8b67..528518f 100644 --- a/sdk/src/java/cyanogenmod/providers/CMSettings.java +++ b/sdk/src/java/cyanogenmod/providers/CMSettings.java @@ -1311,7 +1311,7 @@ public final class CMSettings { /** @hide */ public static final Validator DISPLAY_TEMPERATURE_DAY_VALIDATOR = - new InclusiveIntegerRangeValidator(1000, 10000); + new InclusiveIntegerRangeValidator(0, 100000); /** * Color temperature of the display at night @@ -1320,7 +1320,7 @@ public final class CMSettings { /** @hide */ public static final Validator DISPLAY_TEMPERATURE_NIGHT_VALIDATOR = - new InclusiveIntegerRangeValidator(1000, 10000); + new InclusiveIntegerRangeValidator(0, 100000); /** * Display color temperature adjustment mode, one of DAY (default), NIGHT, or AUTO. |