diff -Naur linux-2.6.16.orig/drivers/misc/ezx/Kconfig linux-2.6.16/drivers/misc/ezx/Kconfig --- linux-2.6.16.orig/drivers/misc/ezx/Kconfig 2006-08-28 23:32:42.000000000 +0200 +++ linux-2.6.16/drivers/misc/ezx/Kconfig 2006-08-20 13:15:11.000000000 +0200 @@ -13,6 +13,9 @@ config KEYLIGHT_A780 tristate "Device driver for Motorola A780 keylight" +config VIBRATOR_A780 + tristate "Device driver for Motorola A780 vibrator" + config FMRADIO_E680 tristate "Device driver for Motorola E680 FM Radio" diff -Naur linux-2.6.16.orig/drivers/misc/ezx/Makefile linux-2.6.16/drivers/misc/ezx/Makefile --- linux-2.6.16.orig/drivers/misc/ezx/Makefile 2006-08-28 23:32:42.000000000 +0200 +++ linux-2.6.16/drivers/misc/ezx/Makefile 2006-08-20 13:52:46.000000000 +0200 @@ -6,6 +6,7 @@ obj-$(CONFIG_KEYPAD_A780) += keypad.o obj-$(CONFIG_KEYPAD_E680) += keypad.o obj-$(CONFIG_KEYLIGHT_A780) += keylight.o +obj-$(CONFIG_VIBRATOR_A780) += vibrator.o obj-$(CONFIG_FMRADIO_E680) += fmradio.o obj-$(CONFIG_PANIC_LOG) += log.o diff -Naur linux-2.6.16.orig/drivers/misc/ezx/ssp_pcap_main.c linux-2.6.16/drivers/misc/ezx/ssp_pcap_main.c --- linux-2.6.16.orig/drivers/misc/ezx/ssp_pcap_main.c 2006-08-28 23:32:42.000000000 +0200 +++ linux-2.6.16/drivers/misc/ezx/ssp_pcap_main.c 2006-08-20 14:02:50.000000000 +0200 @@ -1275,6 +1275,7 @@ EXPORT_SYMBOL(ssp_pcap_open); EXPORT_SYMBOL(SSP_PCAP_bit_set); EXPORT_SYMBOL(SSP_PCAP_bit_clean); +EXPORT_SYMBOL(SSP_PCAP_V_VIB_level_set); /*--------------------------------------------------------------------------- diff -Naur linux-2.6.16.orig/drivers/misc/ezx/vibrator.c linux-2.6.16/drivers/misc/ezx/vibrator.c --- linux-2.6.16.orig/drivers/misc/ezx/vibrator.c 1970-01-01 01:00:00.000000000 +0100 +++ linux-2.6.16/drivers/misc/ezx/vibrator.c 2006-08-28 23:50:26.000000000 +0200 @@ -0,0 +1,300 @@ +/* + * linux/drivers/misc/ezx/vibrator.c --- vibrator driver on ezx + * + * Support for the Motorola Ezx A780 Development Platform. + * + * Linux 2.6 port of Motorolas vibrator char device by: + * zhouqiong Jun 20,2002 created + * Jin Lihong(w20076) Jan 02,2004 (1) Port from UDC e680 kernel of jem vob. + * (2) reorganize file header + * Jin Lihong(w20076) Apr.13,2004,LIBdd96876 reorganise file header + * + * Author: Andre Roth + * Created: Aug 19, 2006 + * Copyright: GPL + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "vibrator.h" +#include "ssp_pcap.h" +#include + +static int vibrator_open_cnt = 0; +static int active=0; +static int voltage=0; + +MODULE_LICENSE("GPL"); + +#ifdef CONFIG_PM +static struct pm_dev *pm_dev; +#endif + +#ifdef CONFIG_PM +static int ezx_vibrator_pm_callback(struct pm_dev *pm_dev, pm_request_t req, void *data) +{ + switch(req) + { + case PM_SUSPEND: + if(active) + { + SSP_vibrate_stop_command(); + } + break; + break; + case PM_RESUME: + if(active) + { + switch(voltage) + { + case 0: + SSP_PCAP_V_VIB_level_set(PCAP_VIBRATOR_VOLTAGE_LEVEL0); + break; + case 1: + SSP_PCAP_V_VIB_level_set(PCAP_VIBRATOR_VOLTAGE_LEVEL1); + break; + case 2: + SSP_PCAP_V_VIB_level_set(PCAP_VIBRATOR_VOLTAGE_LEVEL2); + break; + case 3: + SSP_PCAP_V_VIB_level_set(PCAP_VIBRATOR_VOLTAGE_LEVEL3); + break; + default: + break; + } + SSP_vibrate_start_command(); + } + break; + default: + break; + } + return 0; +} +#endif + +static int vibrator_open(struct inode *inode,struct file *file) +{ + if( !vibrator_open_cnt ) + { + vibrator_open_cnt++; + ssp_pcap_open(SSP_PCAP_AUDIO_OPEN); +#ifdef CONFIG_PM + pm_dev = pm_register(PM_SYS_DEV, 0, ezx_vibrator_pm_callback); +#endif +#ifdef EZX_OSS_DEBUG + printk("open vibrator \n"); +#endif + return 0; + } + else + return -EBUSY; +} + +static int vibrator_close(struct inode *inode,struct file *file) +{ + vibrator_open_cnt--; + + if ( vibrator_open_cnt == 0 ) + { +#ifdef CONFIG_PM + pm_unregister(pm_dev); +#endif +#ifdef EZX_OSS_DEBUG + printk("close vibrator \n"); +#endif + } + + return 0; +} + +static int vibrator_ioctl(struct inode *inode,struct file *file,unsigned int cmd,unsigned long arg) +{ + int ret = 0; + + switch( cmd ) + { + case VIBRATOR_ENABLE: +#ifdef EZX_OSS_DEBUG + printk("enable vibrator \n"); +#endif + // ret = get_user(val, (int *) arg); + if (ret) + return ret; + switch( arg ) + { + case 0: +#ifdef EZX_OSS_DEBUG + printk("vibrator level 0 \n"); +#endif + ret = SSP_PCAP_V_VIB_level_set(PCAP_VIBRATOR_VOLTAGE_LEVEL0); + active = 1; + voltage = 0; + SSP_vibrate_start_command(); + break; + case 1: +#ifdef EZX_OSS_DEBUG + printk("vibrator level 1 \n"); +#endif + ret = SSP_PCAP_V_VIB_level_set(PCAP_VIBRATOR_VOLTAGE_LEVEL1); + active = 1; + voltage = 1; + SSP_vibrate_start_command(); + break; + case 2: +#ifdef EZX_OSS_DEBUG + printk("vibrator level 2 \n"); +#endif + ret = SSP_PCAP_V_VIB_level_set(PCAP_VIBRATOR_VOLTAGE_LEVEL2); + active = 1; + voltage = 2; + SSP_vibrate_start_command(); + break; + case 3: +#ifdef EZX_OSS_DEBUG + printk("vibrator level 3 \n"); +#endif + ret = SSP_PCAP_V_VIB_level_set(PCAP_VIBRATOR_VOLTAGE_LEVEL3); + active = 1; + voltage = 3; + SSP_vibrate_start_command(); + break; + default: +#ifdef EZX_OSS_DEBUG + printk("vibrator level error \n"); +#endif + return -EINVAL; + } + return 0; //put_user(ret, (int *) arg); + + case VIBRATOR_DISABLE: +#ifdef EZX_OSS_DEBUG + printk("disable vibrator \n"); +#endif + ret = 0; + active = 0; + SSP_vibrate_stop_command(); + return 0; //put_user(ret, (int *) arg); + default: + return -EINVAL; + } + return 0; +} + +static ssize_t vibrator_write(struct file *file, const char __user *buf, size_t count, loff_t *offset) +{ + unsigned char level = 0; + int ret; + if (*offset < 0) + return -EINVAL; + if (count <= 0) + return 0; + if (*offset != 0) + return 0; + + if( copy_from_user((unsigned char *)&level, buf, sizeof(unsigned char))) + return -EFAULT; + + switch( level ) + { + case '0': +#ifdef EZX_OSS_DEBUG + printk("stop vibrator \n"); +#endif + active = 0; + SSP_vibrate_stop_command(); + break; + case '1': +#ifdef EZX_OSS_DEBUG + printk("vibrator level 0 \n"); +#endif + ret = SSP_PCAP_V_VIB_level_set(PCAP_VIBRATOR_VOLTAGE_LEVEL0); + active = 1; + voltage = 0; + SSP_vibrate_start_command(); + break; + case '2': +#ifdef EZX_OSS_DEBUG + printk("vibrator level 1 \n"); +#endif + ret = SSP_PCAP_V_VIB_level_set(PCAP_VIBRATOR_VOLTAGE_LEVEL1); + active = 1; + voltage = 1; + SSP_vibrate_start_command(); + break; + case '3': +#ifdef EZX_OSS_DEBUG + printk("vibrator level 2 \n"); +#endif + ret = SSP_PCAP_V_VIB_level_set(PCAP_VIBRATOR_VOLTAGE_LEVEL2); + active = 1; + voltage = 2; + SSP_vibrate_start_command(); + break; + case '4': +#ifdef EZX_OSS_DEBUG + printk("vibrator level 3 \n"); +#endif + ret = SSP_PCAP_V_VIB_level_set(PCAP_VIBRATOR_VOLTAGE_LEVEL3); + active = 1; + voltage = 3; + SSP_vibrate_start_command(); + break; + default: +#ifdef EZX_OSS_DEBUG + printk("vibrator level error \n"); +#endif + } + return count; +} + +static struct file_operations vibrator_fops = { + .owner = THIS_MODULE, + .ioctl = vibrator_ioctl, + .open = vibrator_open, + .write = vibrator_write, + .release = vibrator_close, +}; + +static struct miscdevice vibrator_dev = { + VIBRATOR_MINOR, + "vibrator", + &vibrator_fops, +}; + +int init_vibrator(void) +{ + int ret; + + ret = misc_register(&vibrator_dev); + if( ret < 0 ){ + printk("Sorry,registering the vibrator device failed.\n"); + return ret; + } +#ifdef CONFIG_PM + pm_dev = pm_register(PM_SYS_DEV, 0, ezx_vibrator_pm_callback); +#endif + return 0; +} +void clean_vibrator(void) +{ + misc_deregister(&vibrator_dev); +#ifdef CONFIG_PM + pm_unregister(pm_dev); +#endif +} + +module_init(init_vibrator); +module_exit(clean_vibrator); + diff -Naur linux-2.6.16.orig/drivers/misc/ezx/vibrator.h linux-2.6.16/drivers/misc/ezx/vibrator.h --- linux-2.6.16.orig/drivers/misc/ezx/vibrator.h 1970-01-01 01:00:00.000000000 +0100 +++ linux-2.6.16/drivers/misc/ezx/vibrator.h 2006-08-28 23:48:38.000000000 +0200 @@ -0,0 +1,34 @@ +/* + * linux/drivers/misc/ezx/vibrator.h + * + * History: + * zhouqiong Jun 20,2002 created + * Jin Lihong(w20076) Jan 02,2004 (1) Port from UDC e680 kernel of jem vob. + * (2) reorganize file header + * Jin Lihong(w20076) Apr.13,2004,LIBdd96876 reorganise file header + * + * Andre Roth Aug 19, 2006 linux 2.6 port + */ + +#ifndef EZX_VIBRATOR_H +#define EZX_VIBRATOR_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + + +#define VIBRATOR_MINOR 234 +#define VIBRATOR_IOCTL_BASE 0xbb +#define VIBRATOR_ENABLE _IOW (VIBRATOR_IOCTL_BASE,1,int) +#define VIBRATOR_DISABLE _IO (VIBRATOR_IOCTL_BASE,2) + +#define EZX_OSS_DEBUG + +#ifdef __cplusplus +} +#endif +#endif +