summaryrefslogtreecommitdiffstats
path: root/cmhw/org/cyanogenmod/hardware
diff options
context:
space:
mode:
authorZiyan <jaraidaniel@gmail.com>2014-12-16 19:06:47 +0100
committerZiyan <jaraidaniel@gmail.com>2015-04-11 20:24:52 +0200
commit933f7c54d837ebb23b0eefdb3e6567844e7c1785 (patch)
treed6314b9df4857a5e49004d29b31011cfe99a3dc1 /cmhw/org/cyanogenmod/hardware
parentf95bcd758c53c36ee201dbc6b44bf5f15d846898 (diff)
downloaddevice_samsung_tuna-933f7c54d837ebb23b0eefdb3e6567844e7c1785.zip
device_samsung_tuna-933f7c54d837ebb23b0eefdb3e6567844e7c1785.tar.gz
device_samsung_tuna-933f7c54d837ebb23b0eefdb3e6567844e7c1785.tar.bz2
tuna: add support for CMHW
- Adaptive backlight - Color and gamma calibration - LTO - Vibrator control Also switched to cyanogenmod_tuna_defconfig, since these features require non-stock kernel configs. Change-Id: I5d5b0999c91690eb4c46ce33b6040bc52c0d9cb9
Diffstat (limited to 'cmhw/org/cyanogenmod/hardware')
-rw-r--r--cmhw/org/cyanogenmod/hardware/AdaptiveBacklight.java67
-rw-r--r--cmhw/org/cyanogenmod/hardware/DisplayColorCalibration.java88
-rw-r--r--cmhw/org/cyanogenmod/hardware/DisplayGammaCalibration.java79
-rw-r--r--cmhw/org/cyanogenmod/hardware/LongTermOrbits.java62
-rw-r--r--cmhw/org/cyanogenmod/hardware/VibratorHW.java52
5 files changed, 348 insertions, 0 deletions
diff --git a/cmhw/org/cyanogenmod/hardware/AdaptiveBacklight.java b/cmhw/org/cyanogenmod/hardware/AdaptiveBacklight.java
new file mode 100644
index 0000000..a04b304
--- /dev/null
+++ b/cmhw/org/cyanogenmod/hardware/AdaptiveBacklight.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2013 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 org.cyanogenmod.hardware.util.FileUtils;
+import java.io.File;
+
+/**
+ * Adaptive backlight support (this refers to technologies like NVIDIA SmartDimmer,
+ * QCOM CABL or Samsung CABC).
+ */
+public class AdaptiveBacklight {
+ private static String FILE_CAB = "/sys/class/backlight/s6e8aa0/acl_set";
+
+ /**
+ * Whether device supports an adaptive backlight technology.
+ *
+ * @return boolean Supported devices must return always true
+ */
+ public static boolean isSupported() {
+ File f = new File(FILE_CAB);
+ return f.isFile();
+ }
+
+ /**
+ * This method return the current activation status of the adaptive backlight technology.
+ *
+ * @return boolean Must be false when adaptive backlight is not supported or not activated, or
+ * the operation failed while reading the status; true in any other case.
+ */
+ public static boolean isEnabled() {
+ if (Integer.parseInt(FileUtils.readOneLine(FILE_CAB)) == 1) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * This method allows to setup adaptive backlight technology status.
+ *
+ * @param status The new adaptive backlight status
+ * @return boolean Must be false if adaptive backlight is not supported or the operation
+ * failed; true in any other case.
+ */
+ public static boolean setEnabled(boolean status) {
+ if (status == true) {
+ return FileUtils.writeLine(FILE_CAB, "1");
+ } else {
+ return FileUtils.writeLine(FILE_CAB, "0");
+ }
+ }
+}
diff --git a/cmhw/org/cyanogenmod/hardware/DisplayColorCalibration.java b/cmhw/org/cyanogenmod/hardware/DisplayColorCalibration.java
new file mode 100644
index 0000000..b021e6c
--- /dev/null
+++ b/cmhw/org/cyanogenmod/hardware/DisplayColorCalibration.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2013 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 org.cyanogenmod.hardware.util.FileUtils;
+import java.io.File;
+
+public class DisplayColorCalibration {
+ private static final String[] COLOR_FILE = new String[] {
+ "/sys/class/misc/samoled_color/red_multiplier",
+ "/sys/class/misc/samoled_color/green_multiplier",
+ "/sys/class/misc/samoled_color/blue_multiplier"
+ };
+ private static final String COLOR_FILE_V2 = "/sys/class/misc/colorcontrol/multiplier";
+
+ public static boolean isSupported() {
+ if (new File(COLOR_FILE_V2).exists()) {
+ return true;
+ }
+ for (String filePath : COLOR_FILE) {
+ if (!new File(filePath).exists()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static int getMaxValue() {
+ return 2000000000; // Real value: 4000000000
+ }
+
+ public static int getMinValue() {
+ return 0;
+ }
+
+ public static int getDefValue() {
+ return 1000000000; // Real value: 2000000000
+ }
+
+ public static String getCurColors() {
+ StringBuilder values = new StringBuilder();
+ if (new File(COLOR_FILE_V2).exists()) {
+ String[] valuesSplit = FileUtils.readOneLine(COLOR_FILE_V2).split(" ");
+ for (int i = 0; i < valuesSplit.length; i++) {
+ values.append(Long.toString(Long.valueOf(valuesSplit[i]) / 2)).append(" ");
+ }
+ } else {
+ for (String filePath : COLOR_FILE) {
+ values.append(Long.toString(Long.valueOf(
+ FileUtils.readOneLine(filePath)) / 2)).append(" ");
+ }
+ }
+ return values.toString();
+ }
+
+ public static boolean setColors(String colors) {
+ String[] valuesSplit = colors.split(" ");
+ if (new File(COLOR_FILE_V2).exists()) {
+ StringBuilder realColors = new StringBuilder();
+ for (int i = 0; i < valuesSplit.length; i++) {
+ realColors.append(Long.toString(Long.valueOf(valuesSplit[i]) * 2)).append(" ");
+ }
+ return FileUtils.writeLine(COLOR_FILE_V2, realColors.toString());
+ } else {
+ boolean result = true;
+ for (int i = 0; i < valuesSplit.length; i++) {
+ String targetFile = COLOR_FILE[i];
+ result &= FileUtils.writeLine(targetFile, Long.toString(
+ Long.valueOf(valuesSplit[i]) * 2));
+ }
+ return result;
+ }
+ }
+}
diff --git a/cmhw/org/cyanogenmod/hardware/DisplayGammaCalibration.java b/cmhw/org/cyanogenmod/hardware/DisplayGammaCalibration.java
new file mode 100644
index 0000000..8be53c0
--- /dev/null
+++ b/cmhw/org/cyanogenmod/hardware/DisplayGammaCalibration.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2013 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 org.cyanogenmod.hardware.util.FileUtils;
+import java.io.File;
+
+public class DisplayGammaCalibration {
+ private static final String[] GAMMA_FILE = new String[] {
+ "/sys/class/misc/samoled_color/red_v1_offset",
+ "/sys/class/misc/samoled_color/green_v1_offset",
+ "/sys/class/misc/samoled_color/blue_v1_offset"
+ };
+ private static final String GAMMA_FILE_V2 = "/sys/class/misc/colorcontrol/v1_offset";
+
+ public static boolean isSupported() {
+ if (new File(GAMMA_FILE_V2).exists()) {
+ return true;
+ }
+ for (String filePath : GAMMA_FILE) {
+ if (!new File(filePath).exists()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static int getNumberOfControls() {
+ return 1;
+ }
+
+ public static int getMaxValue(int control) {
+ return 20;
+ }
+
+ public static int getMinValue(int control) {
+ return -20;
+ }
+
+ public static String getCurGamma(int control) {
+ if (new File(GAMMA_FILE_V2).exists()) {
+ return FileUtils.readOneLine(GAMMA_FILE_V2);
+ } else {
+ StringBuilder values = new StringBuilder();
+ for (String filePath : GAMMA_FILE) {
+ values.append(FileUtils.readOneLine(filePath)).append(" ");
+ }
+ return values.toString();
+ }
+ }
+
+ public static boolean setGamma(int control, String gamma) {
+ if (new File(GAMMA_FILE_V2).exists()) {
+ return FileUtils.writeLine(GAMMA_FILE_V2, gamma);
+ } else {
+ String[] valuesSplit = gamma.split(" ");
+ boolean result = true;
+ for (int i = 0; i < valuesSplit.length; i++) {
+ String targetFile = GAMMA_FILE[i];
+ result &= FileUtils.writeLine(targetFile, valuesSplit[i]);
+ }
+ return result;
+ }
+ }
+}
diff --git a/cmhw/org/cyanogenmod/hardware/LongTermOrbits.java b/cmhw/org/cyanogenmod/hardware/LongTermOrbits.java
new file mode 100644
index 0000000..3122402
--- /dev/null
+++ b/cmhw/org/cyanogenmod/hardware/LongTermOrbits.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2013 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 java.io.File;
+
+/**
+ * Long Term Orbits (LTO) support.
+ */
+public class LongTermOrbits {
+
+ // We use the "7 day" data file
+ private static final String LTO_SRC = "http://gllto.glpals.com/7day/v2/latest/lto2.dat";
+ private static final File LTO_DST = new File("/data/gps/lto.dat");
+ private static final long DOWNLOAD_INTERVAL_DEFAULT = 259200000; /* 3 days */
+
+ /**
+ * Whether device supports the LTO technology.
+ *
+ * @return boolean Supported devices must return always true.
+ */
+ public static boolean isSupported() { return true; }
+
+ /**
+ * Returns the source location of the LTO data.
+ *
+ * @return String The LTO source location.
+ */
+ public static String getSourceLocation() { return LTO_SRC; }
+
+ /**
+ * Returns the source location of the LTO data.
+ *
+ * @return File The LTO source location.
+ */
+ public static File getDestinationLocation() { return LTO_DST; }
+
+ /**
+ * Returns the interval in milliseconds to trigger the LTO data download.<br/>
+ * <br/>
+ * As convenience, implementations should set the download interval to the half of the
+ * validity of the downloaded data.
+ *
+ * @return long The download interval in milliseconds
+ */
+ public static long getDownloadInterval() { return DOWNLOAD_INTERVAL_DEFAULT; }
+
+}
diff --git a/cmhw/org/cyanogenmod/hardware/VibratorHW.java b/cmhw/org/cyanogenmod/hardware/VibratorHW.java
new file mode 100644
index 0000000..8bb2509
--- /dev/null
+++ b/cmhw/org/cyanogenmod/hardware/VibratorHW.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2013 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 org.cyanogenmod.hardware.util.FileUtils;
+import java.io.File;
+
+public class VibratorHW {
+ private static String AMP_PATH = "/sys/vibrator/pwmvalue";
+
+ public static boolean isSupported() {
+ return new File(AMP_PATH).exists();
+ }
+
+ public static int getMaxIntensity() {
+ return 100;
+ }
+
+ public static int getMinIntensity() {
+ return 0;
+ }
+
+ public static int getWarningThreshold() {
+ return -1;
+ }
+
+ public static int getCurIntensity() {
+ return Integer.parseInt(FileUtils.readOneLine(AMP_PATH));
+ }
+
+ public static int getDefaultIntensity() {
+ return 85;
+ }
+
+ public static boolean setIntensity(int intensity) {
+ return FileUtils.writeLine(AMP_PATH, String.valueOf(intensity));
+ }
+}