Path: blob/master/drivers/macintosh/via-pmu-event.c
15111 views
/*1* via-pmu event device for reporting some events that come through the PMU2*3* Copyright 2006 Johannes Berg <[email protected]>4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License as published by7* the Free Software Foundation; either version 2 of the License, or8* (at your option) any later version.9*10* This program is distributed in the hope that it will be useful, but11* WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or13* NON INFRINGEMENT. See the GNU General Public License for more14* details.15*16* You should have received a copy of the GNU General Public License17* along with this program; if not, write to the Free Software18* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA19*20*/2122#include <linux/input.h>23#include <linux/adb.h>24#include <linux/pmu.h>25#include "via-pmu-event.h"2627static struct input_dev *pmu_input_dev;2829static int __init via_pmu_event_init(void)30{31int err;3233/* do other models report button/lid status? */34if (pmu_get_model() != PMU_KEYLARGO_BASED)35return -ENODEV;3637pmu_input_dev = input_allocate_device();38if (!pmu_input_dev)39return -ENOMEM;4041pmu_input_dev->name = "PMU";42pmu_input_dev->id.bustype = BUS_HOST;43pmu_input_dev->id.vendor = 0x0001;44pmu_input_dev->id.product = 0x0001;45pmu_input_dev->id.version = 0x0100;4647set_bit(EV_KEY, pmu_input_dev->evbit);48set_bit(EV_SW, pmu_input_dev->evbit);49set_bit(KEY_POWER, pmu_input_dev->keybit);50set_bit(SW_LID, pmu_input_dev->swbit);5152err = input_register_device(pmu_input_dev);53if (err)54input_free_device(pmu_input_dev);55return err;56}5758void via_pmu_event(int key, int down)59{6061if (unlikely(!pmu_input_dev))62return;6364switch (key) {65case PMU_EVT_POWER:66input_report_key(pmu_input_dev, KEY_POWER, down);67break;68case PMU_EVT_LID:69input_report_switch(pmu_input_dev, SW_LID, down);70break;71default:72/* no such key handled */73return;74}7576input_sync(pmu_input_dev);77}7879late_initcall(via_pmu_event_init);808182