All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Zdeněk OGAR Skalák" <skalak-Bh/+Xfn7orxQjibfaplwYw@public.gmane.org>
Cc: Andrew Grover
	<andrew.grover-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	ACPI mailing list
	<acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Subject: LID state
Date: Thu, 19 Dec 2002 08:29:13 +0100	[thread overview]
Message-ID: <3E017549.5FA54255@monetplus.cz> (raw)
In-Reply-To: 20021218221142.GA321@elf.ucw.cz

[-- Attachment #1: Type: text/plain, Size: 680 bytes --]

Hi,

	should you try this patch? It's simple (& maybe stupid), but it adds 
/proc/acpi/button/lid/*/state, which is the actual state of the lid. So you no
longer have to count events for lid :-) When the event lid happens, just ask the
state ....

	It's done by acpi_evaluate_integer( "_LID" ). 

	This patch is for acpi-20021205 for 2.4.20. It should be applied in
drivers/acpi dir.
It modifies only acpi_drivers.h & button.c. 

	Don't know, if it is linux-like coded, so somebody should take a look at.

	By
		Zdenek OGAR Skalak

-- 
Ing. Zdeněk OGAR Skalák
Monet+ a.s.
Zámecká 365
763 14 Zlín - Štípa, CZ
Tel: +420 / 577 110 411,  Fax: +420 / 577 914 557

[-- Attachment #2: acpi.diff --]
[-- Type: text/plain, Size: 2140 bytes --]

diff -r -c original/acpi_drivers.h new/acpi_drivers.h
*** original/acpi_drivers.h	Mon Dec  9 15:01:10 2002
--- new/acpi_drivers.h	Wed Dec 18 14:12:46 2002
***************
*** 86,91 ****
--- 86,92 ----
  #define ACPI_BUTTON_DRIVER_NAME		"ACPI Button Driver"
  #define ACPI_BUTTON_CLASS		"button"
  #define ACPI_BUTTON_FILE_INFO		"info"
+ #define ACPI_BUTTON_FILE_STATE		"state"
  #define ACPI_BUTTON_TYPE_UNKNOWN	0x00
  #define ACPI_BUTTON_NOTIFY_STATUS	0x80
  
diff -r -c original/button.c new/button.c
*** original/button.c	Mon Dec  9 11:13:45 2002
--- new/button.c	Thu Dec 19 08:17:35 2002
***************
*** 102,107 ****
--- 102,145 ----
  	return_VALUE(len);
  }
  
+ static int
+ acpi_button_lid_read_state(
+ 	char			*page,
+ 	char			**start,
+ 	off_t			off,
+ 	int 			count,
+ 	int 			*eof,
+ 	void			*data)
+ {
+ 	struct acpi_button	*button = (struct acpi_button *) data;
+ 	char			*p = page;
+ 	int			len = 0;
+ 	acpi_status		status=AE_OK;
+ 	unsigned long		state;
+ 
+ 	ACPI_FUNCTION_TRACE("acpi_button_lid_read_state");
+ 
+ 	if (!button || !button->device)
+ 		goto end;
+ 
+ 	status=acpi_evaluate_integer(button->handle,"_LID",NULL,&state);
+ 	if (ACPI_FAILURE(status)){
+ 	    p += sprintf(p, "state:      unsupported\n");
+ 	}
+ 	else{
+ 	    p += sprintf(p, "state:      %lu\n",state); 
+ 	}
+ 
+ end:
+ 	len = (p - page);
+ 	if (len <= off+count) *eof = 1;
+ 	*start = page + off;
+ 	len -= off;
+ 	if (len>count) len = count;
+ 	if (len<0) len = 0;
+ 
+ 	return_VALUE(len);
+ }
  
  static int
  acpi_button_add_fs (
***************
*** 148,153 ****
--- 186,205 ----
  	else {
  		entry->read_proc = acpi_button_read_info;
  		entry->data = acpi_driver_data(device);
+ 	}
+ 	
+ 	if (button->type==ACPI_BUTTON_TYPE_LID){
+ 	    /* 'state' [R] */
+ 	    entry = create_proc_entry(ACPI_BUTTON_FILE_STATE,
+ 			S_IRUGO, acpi_device_dir(device));
+ 	    if (!entry)
+ 		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+ 			  "Unable to create '%s' fs entry\n",
+ 			   ACPI_BUTTON_FILE_STATE));
+ 	    else {
+ 		entry->read_proc = acpi_button_lid_read_state;
+ 		entry->data = acpi_driver_data(device);
+ 	    }
  	}
  
  	return_VALUE(0);

      reply	other threads:[~2002-12-19  7:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-18 22:11 Add mising static's to button.c Pavel Machek
2002-12-19  7:29 ` Zdeněk OGAR Skalák [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3E017549.5FA54255@monetplus.cz \
    --to=skalak-bh/+xfn7orxqjibfaplwyw@public.gmane.org \
    --cc=acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=andrew.grover-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.