Re: [PATCH] ACPI: Platform driver to support App Hot Startup (PNP0C32)

Ângelo Miguel Arrifano
2008-08-31T22:21:37Z

On Sun, 31 Aug 2008 23:00:38 +0100
Matthew Garrett <mjg59@srcf.ucam.org> wrote:

> On Mon, Sep 01, 2008 at 12:38:56AM +0200, Ângelo Miguel Arrifano wrote:
> > On Thu, 28 Aug 2008 14:40:55 +0100
> > Matthew Garrett <mjg59@srcf.ucam.org> wrote:
> > + else if (event == QUICKSTART_EVENT_RUNTIME) {
> > + input_report_key(quickstart_input, quickstart->btn->id, 1);
> > + input_sync(quickstart_input);
> > + input_report_key(quickstart_input, quickstart->btn->id, 0);
> > + input_sync(quickstart_input);
> >
> > The button usage ID is used as key code.
>
> Right, that's probably not how you want to do it. Keycodes should be the
> things in include/linux/input.h. The problem you have is that there's no
> way of mapping the usage ID to the keycode without knowing the specific
> laptop layout. The right way of doing this is to use the usage ID as a
> scancode, and then implement the get and setkeycode functions. Userspace
> can then alter the keymap. Check the wistron_btns driver for an example
> of this.
>
> > Buffer dump:
> > QBTN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00
> > DBTN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00
> > MUBN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00
> > PIBN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 06 00 00 00 00 00 00 00
> > WEBN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00
> > LVBN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00
> > VOBN: 03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00
> > +---------------------+
> > Does it return a QWORD?? Why is it at the end of the buffer?
>
> This is the raw dump of what GHID returns? I'm not quite clear on what's
> going on here.

Yes, GHID returns a auto-allocated buffer of 32bytes.

For instance, the returned buffer for WEBN device is:
03 00 00 00 01 00 00 00 58 78 6c 4c 00 81 ff ff 00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00
/\
4 is the button usage ID (see bellow). I don't know why is in that place and why the rest of the garbage.
>
> > + /* <<The GHID method can return a BYTE, WORD, or DWORD.
> > + * The value must be encoded in little-endian byte
> > + * order (least significant byte first).>> */
> > + ACPI_MOVE_32_TO_32(&usageid, buffer.pointer + (buffer.length - 8));
> > + quickstart->btn->id = usageid;
> >
> > I need your help in here, I doubt this code runs for anyone but me.
>
> Right. For instance, GHID on another system I have here is just:
>
> Method (GHID, 0, NotSerialized)
> {
> Acquire (MUT1, 0xFFFF)
> And (MBTB, 0x02, Local0)
> Release (MUT1)
> If (Local0)
> {
> Notify (DAL2, 0x02)
> }
>
> Return (Buffer (One)
> {
> 0x02
> })
>
> which doesn't look like your code would cope at all.

The GHID method here is also similar:

Method (GHID, 0, NotSerialized)
{
If (LEqual (HOTB, 0x10))
{
Notify (WEBN, 0x02)
Store (Zero, HOTB)
}

Return (Buffer (One)
{
/* 0000 */ 0x04
})
}

Shouldn't GHID be returning a 1 byte buffer?
>
> --
> Matthew Garrett | mjg59@srcf.ucam.org

Are you able to dump the returned buffer somewhere?

Thanks,
Angelo Arrifano