这个是mtk 增加的uart和nec红外模块的支持 , 以下主要针对driver的增加 , 应用部分也有 需要的可以私。
这个 修改主要在 MediaTek 平台上添加了红外接收驱动。这个驱动可以接收红外信号,并将其转换为对应的按键事件。
修改的文件:
device/btf/xxx8735_xxx/device.mk
kernel-3.10/drivers/misc/mediatek/Makefile.mt6735
kernel-3.10/drivers/misc/mediatek/ir/Makefile
kernel-3.10/drivers/misc/mediatek/ir/irrx.c
kernel-3.10/drivers/misc/mediatek/ir/irrx.h
packages/apps/IrrxService/Android.mk
packages/apps/IrrxService/IrrxService.apk
packages/apps/IrrxService/libs/arm/libserial_port.so
packages/apps/IrrxService/libs/arm64/libserial_port.so
文件修改说明:
device.mk
: 在产品包中添加了红外服务的库文件和 APK 文件。Makefile.mt6735
: 在 MediaTek 平台的驱动 Makefile 中添加了红外驱动的编译选项。Makefile
: 创建了红外驱动的 Makefile 文件,用于编译红外驱动的源代码文件。irrx.c
: 创建了红外驱动的源代码文件,实现了红外接收驱动的主要功能。irrx.h
: 创建了红外驱动的头文件,定义了红外驱动的数据结构和接口。Android.mk
: 创建了红外服务的 Makefile 文件,用于编译红外服务的 APK 文件和库文件。IrrxService.apk
: 添加了红外服务的 APK 文件,这是一个 Android 应用,用于接收红外驱动的按键事件,并将其转发给其他应用。libserial_port.so
: 添加了红外服务的库文件,这个库提供了串口通信的功能,用于接收红外信号。libserial_port.so
: 添加了红外服务的库文件,这个库提供了串口通信的功能,用于接收红外信号。
--- device/btf/xxx8735_xxx/device.mk | 8 + kernel-3.10/drivers/misc/mediatek/Makefile.mt6735 | 1 + kernel-3.10/drivers/misc/mediatek/ir/Makefile | 5 + kernel-3.10/drivers/misc/mediatek/ir/irrx.c | 257 +++++++++++++++++++++ kernel-3.10/drivers/misc/mediatek/ir/irrx.h | 17 ++ packages/apps/IrrxService/Android.mk | 11 + packages/apps/IrrxService/IrrxService.apk | Bin 0 -> 1774274 bytes .../apps/IrrxService/libs/arm/libserial_port.so | Bin 0 -> 5132 bytes .../apps/IrrxService/libs/arm64/libserial_port.so | Bin 0 -> 9616 bytes 9 files changed, 299 insertions(+) create mode 100755 kernel-3.10/drivers/misc/mediatek/ir/Makefile create mode 100755 kernel-3.10/drivers/misc/mediatek/ir/irrx.c create mode 100755 kernel-3.10/drivers/misc/mediatek/ir/irrx.h create mode 100755 packages/apps/IrrxService/Android.mk create mode 100755 packages/apps/IrrxService/IrrxService.apk create mode 100755 packages/apps/IrrxService/libs/arm/libserial_port.so create mode 100755 packages/apps/IrrxService/libs/arm64/libserial_port.so diff --git a/device/btf/xxx8735_xxx/device.mk b/device/btf/xxx8735_xxx/device.mk index 04bad6c..7be7c41 100755 --- a/device/btf/xxx8735_xxx/device.mk +++ b/device/btf/xxx8735_xxx/device.mk @@ -255,9 +255,17 @@ PRODUCT_PACKAGES += updateMac \ FactoryMode #endif +#shh add ir +PRODUCT_COPY_FILES += \ + packages/apps/IrrxService/libs/arm/libserial_port.so:system/lib/libserial_port.so \ + packages/apps/IrrxService/libs/arm64/libserial_port.so:system/lib64/libserial_port.so + +PRODUCT_PACKAGES += IrrxService + PRODUCT_PACKAGES += UsbCamera PRODUCT_PACKAGES += HdmiIn4a90 PRODUCT_PACKAGES += EasyBox + #PRODUCT_PACKAGES += BtfFactoryMode #PRODUCT_PACKAGES += A90_Test #PRODUCT_PACKAGES += Firefox diff --git a/kernel-3.10/drivers/misc/mediatek/Makefile.mt6735 b/kernel-3.10/drivers/misc/mediatek/Makefile.mt6735 index 41d61b0..c912fa4 100755 --- a/kernel-3.10/drivers/misc/mediatek/Makefile.mt6735 +++ b/kernel-3.10/drivers/misc/mediatek/Makefile.mt6735 @@ -13,6 +13,7 @@ endif obj-y += kpd_gpio/ obj-y += panel_dir/ obj-y += hdmi_det/ +obj-y += ir/ obj-$(CONFIG_MTK_CPU_STRESS) += cpu_stress/ obj-$(CONFIG_MTK_LASTPC) += lastpc/ diff --git a/kernel-3.10/drivers/misc/mediatek/ir/Makefile b/kernel-3.10/drivers/misc/mediatek/ir/Makefile new file mode 100755 index 0000000..cec12b2 --- /dev/null +++ b/kernel-3.10/drivers/misc/mediatek/ir/Makefile @@ -0,0 +1,5 @@ +include $(srctree)/drivers/misc/mediatek/Makefile.custom + +obj-y += irrx.o + + diff --git a/kernel-3.10/drivers/misc/mediatek/ir/irrx.c b/kernel-3.10/drivers/misc/mediatek/ir/irrx.c new file mode 100755 index 0000000..e10551f --- /dev/null +++ b/kernel-3.10/drivers/misc/mediatek/ir/irrx.c @@ -0,0 +1,257 @@ +/* + * Copyright (C) 2010 Trusted Logic S.A. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/fs.h> +#include <linux/slab.h> +#include <linux/init.h> +#include <linux/list.h> +#include <linux/i2c.h> +#include <linux/irq.h> +#include <linux/jiffies.h> +#include <linux/uaccess.h> +#include <linux/delay.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/platform_device.h> +#include <linux/gpio.h> +#include <linux/miscdevice.h> +#include <linux/spinlock.h> +#include <linux/dma-mapping.h> +#include <mach/mt_gpio.h> +#include <mach/eint.h> +#include <cust_gpio_usage.h> +#include <cust_eint.h> +#include <linux/wakelock.h> +#include <mach/mt_pm_ldo.h> +#include <linux/input.h> + +#include "irrx.h" + +#define DBG(x...) printk(x) + +#define IR_NAME "irrx" + +struct irRx_platform_data { + struct input_dev *input; + +}; +struct mutex write_mutex; +static unsigned int key_map[] = { + KEY_ESC, + KEY_1, + KEY_2, + KEY_3, + KEY_4, + KEY_5, + KEY_6, + KEY_7, + KEY_8, + KEY_9, + KEY_0, + KEY_BACKSPACE, + KEY_ENTER, + KEY_HOME, + KEY_UP, + KEY_PAGEUP, + KEY_LEFT, + KEY_RIGHT, + KEY_END, + KEY_DOWN, + KEY_PAGEDOWN, + KEY_INSERT, + KEY_DELETE, + KEY_MACRO, + KEY_MUTE, + KEY_VOLUMEDOWN, + KEY_VOLUMEUP, + KEY_POWER, + KEY_PAUSE, + KEY_STOP, + KEY_COPY, + KEY_MENU, + KEY_SETUP, + KEY_SLEEP, + KEY_WAKEUP, + KEY_BACK, + KEY_PLAYPAUSE, + KEY_EXIT, + KEY_CLOSE, + KEY_PLAY, + KEY_SOUND, + KEY_SEARCH, + KEY_SAVE, + KEY_HDMI_IN, + KEY_BTF_1, + KEY_BTF_2, + KEY_BTF_3, + KEY_BTF_4, + KEY_BTF_5, + KEY_BTF_6, + KEY_BTF_7, + KEY_BTF_8, + KEY_BTF_9, + KEY_OK , + KEY_SELECT, + KEY_CLEAR, + +}; + +static struct irRx_platform_data g_irRxPdata; + + +static void report_key(unsigned int key) +{ + int i = 0; + if (key == 0) + return; + for (i = 0;i < sizeof(key_map)/sizeof(key_map[0]);i++) + { + if (key == key_map[i]) + { + input_report_key(g_irRxPdata.input, key_map[i], 1); + input_sync(g_irRxPdata.input); + input_report_key(g_irRxPdata.input, key_map[i], 0); + input_sync(g_irRxPdata.input); + break; + } + } +} + +static ssize_t irrx_debug_store(struct class *class, struct class_attribute *attr, + const char *buf, size_t count) +{ + int value = 0; + ssize_t ret = 0; + if (!count) return count; + ret = sscanf(buf,"%d",&value); + if (ret != 1) + return -EINVAL; + report_key(value); + return count; +} + +static struct class_attribute irrx_class_attrs[] = { + __ATTR(state,0222,NULL,irrx_debug_store), + __ATTR_NULL, +}; + +static struct class irrx_cls = { + .name = "irrx", + .class_attrs = irrx_class_attrs, +}; + +static int ir_open(struct inode *inode, struct file *file) +{ + + return 0; + +} + +static ssize_t ir_write(struct file *filp, const char __user *buf, size_t count, loff_t *offset) +{ + char buffer[10] = {0}; + unsigned int key = 0; + mutex_lock(&write_mutex); + if (copy_from_user(buffer, buf, count)) + { + printk("%s copy from user err\n",__func__); + mutex_unlock(&write_mutex); + return -EFAULT; + } + + if (count >= 2) { + key = (buffer[0] << 8) | buffer[1]; + report_key(key); + } + mutex_unlock(&write_mutex); + return count; +} + +static const struct file_operations ir_fops_dev = { + .owner = THIS_MODULE, + .open = ir_open, + .write = ir_write, +}; + +static struct miscdevice ir_misc_dev = { + .minor = MISC_DYNAMIC_MINOR, + .name = IR_NAME, + .fops = &ir_fops_dev, + +}; + + +static int __init irRx_init(void) +{ + int ret = 0; + int i = 0; + + g_irRxPdata.input = input_allocate_device(); + if (!g_irRxPdata.input) { + ret = -1; + return ret; + } + + g_irRxPdata.input->name = "irrx"; + g_irRxPdata.input->phys = "irrx/input3"; + + g_irRxPdata.input->id.bustype = BUS_HOST; + g_irRxPdata.input->id.vendor = 0x0001; + g_irRxPdata.input->id.product = 0x0001; + g_irRxPdata.input->id.version = 0x0100; + + for (i = 0;i < sizeof(key_map)/sizeof(key_map[0]);i++) + input_set_capability(g_irRxPdata.input, EV_KEY,key_map[i]); + ret = input_register_device(g_irRxPdata.input); + if (ret) { + + goto fail1; + } + mutex_init(&write_mutex); + + ret = misc_register(&ir_misc_dev); + if (ret) { + goto fail2; + } + class_register(&irrx_cls); + return ret; + fail2: + input_unregister_device(g_irRxPdata.input); + fail1: + input_free_device(g_irRxPdata.input); + g_irRxPdata.input = NULL; + return ret; +} + +static void __exit irRx_exit(void) +{ + input_unregister_device(g_irRxPdata.input); + input_free_device(g_irRxPdata.input); + g_irRxPdata.input = NULL; + misc_deregister(&ir_misc_dev); +} + +module_init(irRx_init); +module_exit(irRx_exit); + +MODULE_AUTHOR("XXX"); +MODULE_DESCRIPTION("IR input driver"); +MODULE_LICENSE("GPL"); diff --git a/kernel-3.10/drivers/misc/mediatek/ir/irrx.h b/kernel-3.10/drivers/misc/mediatek/ir/irrx.h new file mode 100755 index 0000000..e479118 --- /dev/null +++ b/kernel-3.10/drivers/misc/mediatek/ir/irrx.h @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2010 Trusted Logic S.A. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ diff --git a/packages/apps/IrrxService/Android.mk b/packages/apps/IrrxService/Android.mk new file mode 100755 index 0000000..7c1518c --- /dev/null +++ b/packages/apps/IrrxService/Android.mk @@ -0,0 +1,11 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) +# Module name should match apk name to be installed +LOCAL_MODULE := IrrxService +LOCAL_MODULE_TAGS := optional +LOCAL_DEX_PREOPT := false +LOCAL_SRC_FILES := $(LOCAL_MODULE).apk +LOCAL_MODULE_CLASS := APPS +LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX) +LOCAL_CERTIFICATE := platform +include $(BUILD_PREBUILT) \ No newline at end of file diff --git a/packages/apps/IrrxService/IrrxService.apk b/packages/apps/IrrxService/IrrxService.apk