0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 #include <linux/input.h>
0024 #include <linux/adb.h>
0025 #include <linux/pmu.h>
0026 #include "via-pmu-event.h"
0027
0028 static struct input_dev *pmu_input_dev;
0029
0030 static int __init via_pmu_event_init(void)
0031 {
0032 int err;
0033
0034
0035 if (pmu_get_model() != PMU_KEYLARGO_BASED)
0036 return -ENODEV;
0037
0038 pmu_input_dev = input_allocate_device();
0039 if (!pmu_input_dev)
0040 return -ENOMEM;
0041
0042 pmu_input_dev->name = "PMU";
0043 pmu_input_dev->id.bustype = BUS_HOST;
0044 pmu_input_dev->id.vendor = 0x0001;
0045 pmu_input_dev->id.product = 0x0001;
0046 pmu_input_dev->id.version = 0x0100;
0047
0048 set_bit(EV_KEY, pmu_input_dev->evbit);
0049 set_bit(EV_SW, pmu_input_dev->evbit);
0050 set_bit(KEY_POWER, pmu_input_dev->keybit);
0051 set_bit(SW_LID, pmu_input_dev->swbit);
0052
0053 err = input_register_device(pmu_input_dev);
0054 if (err)
0055 input_free_device(pmu_input_dev);
0056 return err;
0057 }
0058
0059 void via_pmu_event(int key, int down)
0060 {
0061
0062 if (unlikely(!pmu_input_dev))
0063 return;
0064
0065 switch (key) {
0066 case PMU_EVT_POWER:
0067 input_report_key(pmu_input_dev, KEY_POWER, down);
0068 break;
0069 case PMU_EVT_LID:
0070 input_report_switch(pmu_input_dev, SW_LID, down);
0071 break;
0072 default:
0073
0074 return;
0075 }
0076
0077 input_sync(pmu_input_dev);
0078 }
0079
0080 late_initcall(via_pmu_event_init);