aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsbrissen <sbrissen@hotmail.com>2013-12-13 15:22:39 -0500
committersbrissen <sbrissen@hotmail.com>2013-12-13 15:22:39 -0500
commitf959eb8087220a7730d017196bc79ea7ee08fdc4 (patch)
tree8521cd32fb0072b62eade0d6479c67d9ad1877ef
parent07c7bb5f972f20c31fe34b8ea4dd38eb33b9bcc0 (diff)
downloaddevice_samsung_kona-common-f959eb8087220a7730d017196bc79ea7ee08fdc4.zip
device_samsung_kona-common-f959eb8087220a7730d017196bc79ea7ee08fdc4.tar.gz
device_samsung_kona-common-f959eb8087220a7730d017196bc79ea7ee08fdc4.tar.bz2
kona-common: add consumerir hal
credits: Aaron Jackson http://review.cyanogenmod.org/#/c/55741/ Change-Id: Iff173da6f728ab28fe1b9d91dba4156a3c63e14b
-rw-r--r--consumerir/Android.mk28
-rw-r--r--consumerir/consumerir.c130
-rw-r--r--irda/Android.mk13
-rw-r--r--irda/irda.c75
-rwxr-xr-xkona-common.mk9
5 files changed, 164 insertions, 91 deletions
diff --git a/consumerir/Android.mk b/consumerir/Android.mk
new file mode 100644
index 0000000..de7f9c3
--- /dev/null
+++ b/consumerir/Android.mk
@@ -0,0 +1,28 @@
+# Copyright (C) 2013 The Android Open Source 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.
+
+# HAL module implementation stored in
+# hw/<POWERS_HARDWARE_MODULE_ID>.<ro.hardware>.so
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := consumerir.exynos4
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
+LOCAL_SRC_FILES := consumerir.c
+LOCAL_SHARED_LIBRARIES := liblog libcutils
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/consumerir/consumerir.c b/consumerir/consumerir.c
new file mode 100644
index 0000000..327beb4
--- /dev/null
+++ b/consumerir/consumerir.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2013 The Android Open Source 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.
+ */
+#define LOG_TAG "ConsumerIrHal"
+
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <cutils/log.h>
+#include <hardware/hardware.h>
+#include <hardware/consumerir.h>
+
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+
+static const consumerir_freq_range_t consumerir_freqs[] = {
+ {.min = 30000, .max = 30000},
+ {.min = 33000, .max = 33000},
+ {.min = 36000, .max = 36000},
+ {.min = 38000, .max = 38000},
+ {.min = 40000, .max = 40000},
+ {.min = 56000, .max = 56000},
+};
+
+int fd = 0;
+static int consumerir_transmit(struct consumerir_device *dev,
+ int carrier_freq, int pattern[], int pattern_len)
+{
+ int strlen;
+ int i;
+ char buffer[1024];
+
+ memset(buffer, 0, 1024);
+
+ /* write the header */
+ strlen = sprintf(buffer, "%d,", carrier_freq);
+
+ /* write out the timing pattern */
+ for (i = 0; i < pattern_len; i++)
+ {
+ strlen += sprintf(buffer + strlen, "%d,", pattern[i]);
+ }
+
+ buffer[strlen - 1] = 0;
+
+ write(fd, buffer, strlen - 1);
+
+ return 0;
+}
+
+static int consumerir_get_num_carrier_freqs(struct consumerir_device *dev)
+{
+ return ARRAY_SIZE(consumerir_freqs);
+}
+
+static int consumerir_get_carrier_freqs(struct consumerir_device *dev,
+ size_t len, consumerir_freq_range_t *ranges)
+{
+ size_t to_copy = ARRAY_SIZE(consumerir_freqs);
+
+ to_copy = len < to_copy ? len : to_copy;
+ memcpy(ranges, consumerir_freqs, to_copy * sizeof(consumerir_freq_range_t));
+ return to_copy;
+}
+
+static int consumerir_close(hw_device_t *dev)
+{
+ free(dev);
+ close(fd);
+ return 0;
+}
+
+/*
+ * Generic device handling
+ */
+static int consumerir_open(const hw_module_t* module, const char* name,
+ hw_device_t** device)
+{
+ if (strcmp(name, CONSUMERIR_TRANSMITTER) != 0) {
+ return -EINVAL;
+ }
+ if (device == NULL) {
+ ALOGE("NULL device on open");
+ return -EINVAL;
+ }
+
+ consumerir_device_t *dev = malloc(sizeof(consumerir_device_t));
+ memset(dev, 0, sizeof(consumerir_device_t));
+
+ dev->common.tag = HARDWARE_DEVICE_TAG;
+ dev->common.version = 0;
+ dev->common.module = (struct hw_module_t*) module;
+ dev->common.close = consumerir_close;
+
+ dev->transmit = consumerir_transmit;
+ dev->get_num_carrier_freqs = consumerir_get_num_carrier_freqs;
+ dev->get_carrier_freqs = consumerir_get_carrier_freqs;
+
+ *device = (hw_device_t*) dev;
+ fd = open("/sys/class/sec/sec_ir/ir_send", O_RDWR);
+ return 0;
+}
+
+static struct hw_module_methods_t consumerir_module_methods = {
+ .open = consumerir_open,
+};
+
+consumerir_module_t HAL_MODULE_INFO_SYM = {
+ .common = {
+ .tag = HARDWARE_MODULE_TAG,
+ .module_api_version = CONSUMERIR_MODULE_API_VERSION_1_0,
+ .hal_api_version = HARDWARE_HAL_API_VERSION,
+ .id = CONSUMERIR_HARDWARE_MODULE_ID,
+ .name = "Consumer IR Module",
+ .author = "The CyanogenMod Project",
+ .methods = &consumerir_module_methods,
+ },
+};
diff --git a/irda/Android.mk b/irda/Android.mk
deleted file mode 100644
index 1659626..0000000
--- a/irda/Android.mk
+++ /dev/null
@@ -1,13 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-# HAL module implemenation stored in
-# hw/<POWERS_HARDWARE_MODULE_ID>.<ro.hardware>.so
-include $(CLEAR_VARS)
-
-LOCAL_PRELINK_MODULE := false
-LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
-LOCAL_SHARED_LIBRARIES := liblog libcutils libhardware libdl
-LOCAL_SRC_FILES := irda.c
-LOCAL_MODULE:= irda.exynos4
-LOCAL_MODULE_TAGS := optional
-include $(BUILD_SHARED_LIBRARY)
diff --git a/irda/irda.c b/irda/irda.c
deleted file mode 100644
index 0068685..0000000
--- a/irda/irda.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2013 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.
- */
-
-#include <errno.h>
-
-#define LOG_TAG "irda"
-#include <cutils/log.h>
-#include <cutils/sockets.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <hardware/irda.h>
-#include <errno.h>
-
-#define IRDA_DEBUG 1
-
-int fd = 0;
-
-void irda_send_ircode(char* buffer, int length)
-{
- int retval;
-
- retval = write(fd, buffer, length);
-
- return;
-}
-
-static int open_irda(const struct hw_module_t* module, char const* name,
- struct hw_device_t** device)
-{
- struct irda_device_t *dev = malloc(sizeof(struct irda_device_t));
- memset(dev, 0, sizeof(*dev));
-
- dev->common.tag = HARDWARE_DEVICE_TAG;
- dev->common.version = 0;
- dev->common.module = (struct hw_module_t*)module;
- dev->send_ircode = irda_send_ircode;
-
- *device = (struct hw_device_t*) dev;
-
- fd = open("/sys/class/sec/sec_ir/ir_send", O_RDWR);
- if(fd < 0) {
- ALOGE("Unable to open IR device: %d - %s",errno,strerror(errno));
- return fd;
- }
-
- return 0;
-}
-
-static struct hw_module_methods_t irda_module_methods = {
- .open = open_irda
-};
-
-struct hw_module_t HAL_MODULE_INFO_SYM = {
- .tag = HARDWARE_MODULE_TAG,
- .module_api_version = 1,
- .hal_api_version = 0,
- .id = IRDA_HARDWARE_MODULE_ID,
- .name = "Irda HW Module",
- .author = "The CyanogenMod Project",
- .methods = &irda_module_methods,
-};
diff --git a/kona-common.mk b/kona-common.mk
index 479fba6..09e25f7 100755
--- a/kona-common.mk
+++ b/kona-common.mk
@@ -55,9 +55,12 @@ PRODUCT_PACKAGES += \
PRODUCT_PACKAGES += \
sensors.smdk4x12
-# IRDA
-#PRODUCT_PACKAGES += \
-# irda.exynos4
+# IR packages
+PRODUCT_PACKAGES += \
+ consumerir.exynos4
+
+PRODUCT_COPY_FILES += \
+ frameworks/native/data/etc/android.hardware.consumerir.xml:system/etc/permissions/android.hardware.consumerir.xml
PRODUCT_PROPERTY_OVERRIDES += \
ro.cm.hardware.cabc=/sys/class/mdnie/mdnie/cabc