summaryrefslogtreecommitdiffstats
path: root/cmhw/org/cyanogenmod/hardware
diff options
context:
space:
mode:
authorSteve Kondik <steve@cyngn.com>2016-07-21 23:58:40 -0700
committerSteve Kondik <steve@cyngn.com>2016-08-08 12:34:27 -0700
commitec15025b00e200249af05813b9582eb8e6998e78 (patch)
tree2772bbae3603c9a6e8f26dce6b84098e1383af9a /cmhw/org/cyanogenmod/hardware
parent3c1ac7370878878eee051f7f249e39799df8a3f4 (diff)
downloadandroid_hardware_cyanogen-ec15025b00e200249af05813b9582eb8e6998e78.tar.gz
android_hardware_cyanogen-ec15025b00e200249af05813b9582eb8e6998e78.tar.bz2
android_hardware_cyanogen-ec15025b00e200249af05813b9582eb8e6998e78.zip
cmhw: Add support for picture adjustment via LiveDisplay native API
Change-Id: I8a923f1b0cfacf61d0d2b92fcd105375c6d91926
Diffstat (limited to 'cmhw/org/cyanogenmod/hardware')
-rw-r--r--cmhw/org/cyanogenmod/hardware/LiveDisplayVendorImpl.java21
-rw-r--r--cmhw/org/cyanogenmod/hardware/PictureAdjustment.java141
2 files changed, 158 insertions, 4 deletions
diff --git a/cmhw/org/cyanogenmod/hardware/LiveDisplayVendorImpl.java b/cmhw/org/cyanogenmod/hardware/LiveDisplayVendorImpl.java
index 9a5c578..36a19a2 100644
--- a/cmhw/org/cyanogenmod/hardware/LiveDisplayVendorImpl.java
+++ b/cmhw/org/cyanogenmod/hardware/LiveDisplayVendorImpl.java
@@ -17,8 +17,10 @@
package org.cyanogenmod.hardware;
import android.util.Log;
+import android.util.Range;
import cyanogenmod.hardware.DisplayMode;
+import cyanogenmod.hardware.HSIC;
/**
* This class loads an implementation of the LiveDisplay native interface.
@@ -31,6 +33,7 @@ public class LiveDisplayVendorImpl {
public static final int COLOR_BALANCE = 0x2;
public static final int OUTDOOR_MODE = 0x4;
public static final int ADAPTIVE_BACKLIGHT = 0x8;
+ public static final int PICTURE_ADJUSTMENT = 0x10;
private static boolean sNativeLibraryLoaded;
private static int sFeatures;
@@ -39,12 +42,13 @@ public class LiveDisplayVendorImpl {
try {
System.loadLibrary("jni_livedisplay");
- sFeatures = native_getSupportedFeatures();
-
- if (sFeatures > 0) {
- sNativeLibraryLoaded = true;
+ final int features = native_getSupportedFeatures();
+ if (features > 0) {
Log.i(TAG, "Using native LiveDisplay backend (features: " + sFeatures + ")");
}
+
+ sNativeLibraryLoaded = features > 0;
+ sFeatures = features;
} catch (Throwable t) {
sNativeLibraryLoaded = false;
sFeatures = 0;
@@ -72,4 +76,13 @@ public class LiveDisplayVendorImpl {
public static native int native_getColorBalance();
public static native boolean native_setColorBalance(int value);
+ public static native boolean native_setPictureAdjustment(final HSIC hsic);
+ public static native HSIC native_getPictureAdjustment();
+ public static native HSIC native_getDefaultPictureAdjustment();
+
+ public static native Range<Float> native_getHueRange();
+ public static native Range<Float> native_getSaturationRange();
+ public static native Range<Float> native_getIntensityRange();
+ public static native Range<Float> native_getContrastRange();
+ public static native Range<Float> native_getSaturationThresholdRange();
}
diff --git a/cmhw/org/cyanogenmod/hardware/PictureAdjustment.java b/cmhw/org/cyanogenmod/hardware/PictureAdjustment.java
new file mode 100644
index 0000000..dc0b68a
--- /dev/null
+++ b/cmhw/org/cyanogenmod/hardware/PictureAdjustment.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2016 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.cyanogenmod.hardware;
+
+import android.util.Range;
+
+import cyanogenmod.hardware.HSIC;
+
+/**
+ * Color balance support
+ *
+ * Color balance controls allow direct adjustment of display color temperature
+ * using a range of values. A zero implies no adjustment, negative values
+ * move towards warmer temperatures, and positive values move towards
+ * cool temperatures.
+ */
+public class PictureAdjustment {
+
+ private static final boolean sHasNativeSupport =
+ LiveDisplayVendorImpl.hasNativeFeature(LiveDisplayVendorImpl.PICTURE_ADJUSTMENT);
+
+ /**
+ * Whether device supports color balance control
+ *
+ * @return boolean Supported devices must return always true
+ */
+ public static boolean isSupported() {
+ return sHasNativeSupport;
+ }
+
+ /**
+ * This method returns the current picture adjustment values
+ *
+ * @return HSIC
+ */
+ public static HSIC getHSIC() {
+ if (sHasNativeSupport) {
+ return LiveDisplayVendorImpl.native_getPictureAdjustment();
+ }
+ return null;
+ }
+
+ /**
+ * This method returns the default picture adjustment for the current mode
+ *
+ * @return HSIC
+ */
+ public static HSIC getDefaultHSIC() {
+ if (sHasNativeSupport) {
+ return LiveDisplayVendorImpl.native_getDefaultPictureAdjustment();
+ }
+ return null;
+ }
+
+ /**
+ * This method allows to set the picture adjustment
+ *
+ * @param hsic
+ * @return boolean Must be false if feature is not supported or the operation
+ * failed; true in any other case.
+ */
+ public static boolean setHSIC(final HSIC hsic) {
+ if (sHasNativeSupport) {
+ return LiveDisplayVendorImpl.native_setPictureAdjustment(hsic);
+ }
+ return false;
+ }
+
+ /**
+ * Get the range available for hue adjustment
+ * @return range
+ */
+ public static Range<Float> getHueRange() {
+ if (sHasNativeSupport) {
+ return LiveDisplayVendorImpl.native_getHueRange();
+ }
+ return new Range(0.0f, 0.0f);
+ }
+
+ /**
+ * Get the range available for saturation adjustment
+ * @return range
+ */
+ public static Range<Float> getSaturationRange() {
+ if (sHasNativeSupport) {
+ return LiveDisplayVendorImpl.native_getSaturationRange();
+ }
+ return new Range(0.0f, 0.0f);
+ }
+
+ /**
+ * Get the range available for intensity adjustment
+ * @return range
+ */
+ public static Range<Float> getIntensityRange() {
+ if (sHasNativeSupport) {
+ return LiveDisplayVendorImpl.native_getIntensityRange();
+ }
+ return new Range(0.0f, 0.0f);
+ }
+
+ /**
+ * Get the range available for contrast adjustment
+ * @return range
+ */
+ public static Range<Float> getContrastRange() {
+ if (sHasNativeSupport) {
+ return LiveDisplayVendorImpl.native_getContrastRange();
+ }
+ return new Range(0.0f, 0.0f);
+ }
+
+ /**
+ * Get the range available for saturation threshold adjustment
+ *
+ * This is an adjustable lower limit where the image is fully
+ * desaturated.
+ *
+ * @return range
+ */
+ public static Range<Float> getSaturationThresholdRange() {
+ if (sHasNativeSupport) {
+ return LiveDisplayVendorImpl.native_getSaturationThresholdRange();
+ }
+ return new Range(0.0f, 0.0f);
+ }
+}