summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Gernoth <michael@gernoth.net>2016-01-13 23:06:07 +0100
committerMichael Gernoth <michael@gernoth.net>2016-01-13 23:07:03 +0100
commit9ce39213f4e21a5b080a101245ec63893e3e3a14 (patch)
tree0f6c75be928d0fe4c593df2fa2345d672c6a7ff8
parented9b5b7f948a5141fdd8f9d18a17a67c31590110 (diff)
downloadhardware_ti_omap4-9ce39213f4e21a5b080a101245ec63893e3e3a14.zip
hardware_ti_omap4-9ce39213f4e21a5b080a101245ec63893e3e3a14.tar.gz
hardware_ti_omap4-9ce39213f4e21a5b080a101245ec63893e3e3a14.tar.bz2
add CMHW for ColorCalibration/LiveDisplay
This uses the color phase rotation hardware of Omap4 to set RGB calibration values. Change-Id: I101953fbac46235a178824f9d94470b4fe558b76
-rw-r--r--cmhw/org/cyanogenmod/hardware/DisplayColorCalibration.java85
1 files changed, 85 insertions, 0 deletions
diff --git a/cmhw/org/cyanogenmod/hardware/DisplayColorCalibration.java b/cmhw/org/cyanogenmod/hardware/DisplayColorCalibration.java
new file mode 100644
index 0000000..bc6cc85
--- /dev/null
+++ b/cmhw/org/cyanogenmod/hardware/DisplayColorCalibration.java
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ */
+
+ /*
+ * According to the OMAP color phase correction documentation,
+ * this happens:
+ *
+ * +- -+ +- -+ +- -+
+ * | Rout | | Rr Rg Rb | | Rin |
+ * | | 1 | | | |
+ * | Gout | = --- * | Gr Gg Gb | * | Gin |
+ * | | 256 | | | |
+ * | Bout | | Br Bg Bb | | Bin |
+ * +- -+ +- -+ +- -+
+ *
+ * So to get the unmodified color, the values for Rr, Gg and Bb should
+ * be set to 256, all others to 0. The values are 10 bit signed.
+ *
+ * This interface is exposed via sysfs and takes one line in the format:
+ * Rr Rg Rb Gr Gg Gb Br Bg Bb
+ */
+
+package org.cyanogenmod.hardware;
+
+import org.cyanogenmod.hardware.util.FileUtils;
+
+public class DisplayColorCalibration {
+ private static final String COLOR_FILE = "/sys/devices/platform/omapdss/manager0/cpr_coef";
+ private static final String COLOR_FILE_CTRL = "/sys/devices/platform/omapdss/manager0/cpr_enable";
+ private static int last_rgb[] = { 256, 256, 256 };
+
+ public static boolean isSupported() {
+ return true;
+ }
+
+ public static int getMaxValue() {
+ return 256;
+ }
+
+ public static int getMinValue() {
+ return 0;
+ }
+
+ public static int getDefValue() {
+ return getMaxValue();
+ }
+
+ public static String getCurColors() {
+ return last_rgb[0] + " " + last_rgb[1] + " " + last_rgb[2];
+ }
+
+ public static boolean setColors(String colors) {
+ String rgb[] = colors.split(" ");
+ String cpr_coefs = rgb[0] + " 0 0 0 " + rgb[1] + " 0 0 0 " + rgb[2];
+
+ if (last_rgb[0] == Integer.parseInt(rgb[0]) &&
+ last_rgb[1] == Integer.parseInt(rgb[1]) &&
+ last_rgb[2] == Integer.parseInt(rgb[2])) {
+ return true;
+ }
+
+ if (!FileUtils.writeLine(COLOR_FILE, cpr_coefs)) {
+ return false;
+ }
+
+ last_rgb[0] = Integer.parseInt(rgb[0]);
+ last_rgb[1] = Integer.parseInt(rgb[1]);
+ last_rgb[2] = Integer.parseInt(rgb[2]);
+
+ return FileUtils.writeLine(COLOR_FILE_CTRL, "1");
+ }
+}