Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 30561
b: refs/heads/master
c: 9e8e30a
h: refs/heads/master
i:
  30559: dafb09c
v: v3
  • Loading branch information
Johannes Berg authored and Dmitry Torokhov committed Jun 26, 2006
1 parent a9dd1cd commit 249eb1e
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ca56fe07f46e1c174b544e714be183f1476fecea
refs/heads/master: 9e8e30a0cc0ccb43773d14d8b8b84bcc585e9cc1
2 changes: 1 addition & 1 deletion trunk/drivers/macintosh/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ obj-$(CONFIG_MAC_EMUMOUSEBTN) += mac_hid.o
obj-$(CONFIG_INPUT_ADBHID) += adbhid.o
obj-$(CONFIG_ANSLCD) += ans-lcd.o

obj-$(CONFIG_ADB_PMU) += via-pmu.o
obj-$(CONFIG_ADB_PMU) += via-pmu.o via-pmu-event.o
obj-$(CONFIG_PMAC_BACKLIGHT) += via-pmu-backlight.o
obj-$(CONFIG_ADB_CUDA) += via-cuda.o
obj-$(CONFIG_PMAC_APM_EMU) += apm_emu.o
Expand Down
80 changes: 80 additions & 0 deletions trunk/drivers/macintosh/via-pmu-event.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* via-pmu event device for reporting some events that come through the PMU
*
* Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
*
* 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, GOOD TITLE or
* NON INFRINGEMENT. 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/input.h>
#include <linux/adb.h>
#include <linux/pmu.h>
#include "via-pmu-event.h"

static struct input_dev *pmu_input_dev;

static int __init via_pmu_event_init(void)
{
int err;

/* do other models report button/lid status? */
if (pmu_get_model() != PMU_KEYLARGO_BASED)
return -ENODEV;

pmu_input_dev = input_allocate_device();
if (!pmu_input_dev)
return -ENOMEM;

pmu_input_dev->name = "PMU";
pmu_input_dev->id.bustype = BUS_HOST;
pmu_input_dev->id.vendor = 0x0001;
pmu_input_dev->id.product = 0x0001;
pmu_input_dev->id.version = 0x0100;

set_bit(EV_KEY, pmu_input_dev->evbit);
set_bit(EV_SW, pmu_input_dev->evbit);
set_bit(KEY_POWER, pmu_input_dev->keybit);
set_bit(SW_LID, pmu_input_dev->swbit);

err = input_register_device(pmu_input_dev);
if (err)
input_free_device(pmu_input_dev);
return err;
}

void via_pmu_event(int key, int down)
{

if (unlikely(!pmu_input_dev))
return;

switch (key) {
case PMU_EVT_POWER:
input_report_key(pmu_input_dev, KEY_POWER, down);
break;
case PMU_EVT_LID:
input_report_switch(pmu_input_dev, SW_LID, down);
break;
default:
/* no such key handled */
return;
}

input_sync(pmu_input_dev);
}

late_initcall(via_pmu_event_init);
8 changes: 8 additions & 0 deletions trunk/drivers/macintosh/via-pmu-event.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef __VIA_PMU_EVENT_H
#define __VIA_PMU_EVENT_H

#define PMU_EVT_POWER 0
#define PMU_EVT_LID 1
extern void via_pmu_event(int key, int down);

#endif /* __VIA_PMU_EVENT_H */
8 changes: 8 additions & 0 deletions trunk/drivers/macintosh/via-pmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
#include <asm/open_pic.h>
#endif

#include "via-pmu-event.h"

/* Some compile options */
#undef SUSPEND_USES_PMU
#define DEBUG_SLEEP
Expand Down Expand Up @@ -1427,6 +1429,12 @@ pmu_handle_data(unsigned char *data, int len, struct pt_regs *regs)
if (pmu_battery_count)
query_battery_state();
pmu_pass_intr(data, len);
/* len == 6 is probably a bad check. But how do I
* know what PMU versions send what events here? */
if (len == 6) {
via_pmu_event(PMU_EVT_POWER, !!(data[1]&8));
via_pmu_event(PMU_EVT_LID, data[1]&1);
}
} else {
pmu_pass_intr(data, len);
}
Expand Down

0 comments on commit 249eb1e

Please sign in to comment.