public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* RE: Lid support for ACPI
@ 2001-04-25 17:23 Grover, Andrew
  2001-04-25 20:22 ` Pavel Machek
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Grover, Andrew @ 2001-04-25 17:23 UTC (permalink / raw)
  To: 'Pavel Machek', acpi, kernel list

Pavel,

We already have lid support in the latest ACPI versions (not in the official
kernel yet.) You can download this code from
http://developer.intel.com/technology/iapc/acpi/downloads.htm .

It'd be great if you could focus your testing and patches on this code base
-- I think it's a lot better but it's still a work in progress.

Regards -- Andy

PS I'm not quite sure why you copied the acpi list *and* lkml.. ;-)

> -----Original Message-----
> From: Pavel Machek [mailto:pavel@suse.cz]
> Hi!
> 
> Here's lid support for ACPI, please apply.
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread
* RE: Lid support for ACPI
@ 2001-04-30  5:00 Grover, Andrew
  0 siblings, 0 replies; 8+ messages in thread
From: Grover, Andrew @ 2001-04-30  5:00 UTC (permalink / raw)
  To: 'Pavel Machek', Michael K. Johnson; +Cc: linux-kernel

(btw ACPI 2.0 spec section 12.1.1 discusses this)

> From: Pavel Machek [mailto:pavel@suse.cz]
> > No, the ACPI standard requires CPUs to shut themselves down before
> > any damage would occur from overheading.  Well, at least the 1.0b
> > version of the standard did; I haven't read 2.0 yet.

> BTW shut themselves down to halt, or shut themselves to 
> *very* low speed?

Both. When a CPU overheats, the OS implements either active (turning on a
fan) or passive (cpu throttling). If the temperature still exceeds the
critical threshold, the OS must shut down.

> Slow down to 10% speed is what my toshiba does. Is there way 
> back from such
> mode?

Once the temperature drops below the active and passive cooling thresholds,
the OS should stop its cooling measures, such as throttling.

That said, I seem to recall your laptop is doing throttling in a non-OS
visible way (BIOS) so I don't know under what circumstances it stops cpu
throttling.

Regards -- Andy


^ permalink raw reply	[flat|nested] 8+ messages in thread
* RE: Lid support for ACPI
@ 2001-04-25 20:54 Grover, Andrew
  0 siblings, 0 replies; 8+ messages in thread
From: Grover, Andrew @ 2001-04-25 20:54 UTC (permalink / raw)
  To: 'Pavel Machek', kernel list; +Cc: Acpi-linux (E-mail)

> > It'd be great if you could focus your testing and patches 
> on this code base
> > -- I think it's a lot better but it's still a work in progress.
> 
> Are you planning to merge to 2.4.4?

Planning on merging ASAP. That may be 2.4.4, we'll see.

> > PS I'm not quite sure why you copied the acpi list *and* lkml.. ;-)
> 
> Is acpi list some kind of lkml subset? [I wanted people to know that
> I'm playing with acpi. I probably should stop mailing to acpi list
> that I do not read...]

We have a dedicated list for ACPI so you should subscribe to it and use it.

Regards -- Andy


^ permalink raw reply	[flat|nested] 8+ messages in thread
* Lid support for ACPI
@ 2001-04-23  8:45 Pavel Machek
  0 siblings, 0 replies; 8+ messages in thread
From: Pavel Machek @ 2001-04-23  8:45 UTC (permalink / raw)
  To: acpi, andrew.grover, kernel list

Hi!

Here's lid support for ACPI, please apply.

								Pavel
--- clean/drivers/acpi/power.c	Wed Jan 31 16:14:33 2001
+++ linux/drivers/acpi/power.c	Sun Apr 22 23:02:25 2001
@@ -30,11 +30,11 @@
 int acpi_cmbatt_init(void);
 int acpi_cmbatt_terminate(void);
 
-/* ACPI-specific defines */
-#define ACPI_AC_ADAPTER_HID	"ACPI0003"
-
 static int ac_count = 0;
+static int lid_count = 0;
 static ACPI_HANDLE ac_handle = 0;
+static ACPI_HANDLE lid_handle = 0;
+
 
 /*
  * We found a device with the correct HID
@@ -60,11 +60,28 @@
 	}
 
 	printk(KERN_INFO "AC Adapter: found\n");
-
 	ac_handle = handle;
-
 	ac_count++;
+	return AE_OK;
+}
 
+static ACPI_STATUS
+acpi_found_lid(ACPI_HANDLE handle, u32 level, void *ctx, void **value)
+{
+	ACPI_DEVICE_INFO	info;
+
+	if (lid_count > 0) {
+		printk(KERN_ERR "Lid: more than one!\n");
+		return (AE_OK);
+	}
+
+	if (!(info.valid & ACPI_VALID_STA)) {
+		printk(KERN_ERR "Lid: _STA invalid\n");
+	}
+
+	printk(KERN_INFO "Lid: found\n");
+	lid_handle = handle;
+	lid_count++;
 	return AE_OK;
 }
 
@@ -101,23 +118,54 @@
 	return len;
 }
 
+static int
+proc_read_lid_status(char *page, char **start, off_t off,
+		     int count, int *eof, void *data)
+{
+	ACPI_OBJECT obj;
+	ACPI_BUFFER buf;
+
+	char *p = page;
+	int len;
+
+	buf.length = sizeof(obj);
+	buf.pointer = &obj;
+	if (!ACPI_SUCCESS(acpi_evaluate_object(lid_handle, "_LID", NULL, &buf))
+		|| obj.type != ACPI_TYPE_INTEGER) {
+		p += sprintf(p, "Could not read lid status\n");
+		goto end;
+	}
+
+	if (obj.integer.value)
+		p += sprintf(p, "open\n");
+	else
+		p += sprintf(p, "closed\n");
+
+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 len;
+}
+
 int
 acpi_power_init(void)
 {
-	acpi_get_devices(ACPI_AC_ADAPTER_HID, 
-			acpi_found_ac_adapter,
-			NULL,
-			NULL);
+	acpi_get_devices("ACPI0003", acpi_found_ac_adapter, NULL, NULL);
+	acpi_get_devices("PNP0C0D", acpi_found_lid, NULL, NULL);
 
 	if (!proc_mkdir("power", NULL))
-		return 0;
+		return -EBUSY;
 
-	if (ac_handle) {
-		create_proc_read_entry("power/ac", 0, NULL,
-			proc_read_ac_adapter_status, NULL);
-	}
+	if (ac_handle)
+		create_proc_read_entry("power/ac", 0, NULL, proc_read_ac_adapter_status, NULL);
+	if (lid_handle)
+		create_proc_read_entry("power/lid", 0, NULL, proc_read_lid_status, NULL);
 
 	acpi_cmbatt_init();
 
 	return 0;
 }
@@ -127,9 +176,8 @@
 {
 	acpi_cmbatt_terminate();
 
-	if (ac_handle) {
-		remove_proc_entry("power/ac", NULL);
-	}
+	if (ac_handle) remove_proc_entry("power/ac", NULL);
+	if (lid_handle) remove_proc_entry("power/lid", NULL);
 
 	remove_proc_entry("power", NULL);
 

-- 
I'm pavel@ucw.cz. "In my country we have almost anarchy and I don't care."
Panos Katsaloulis describing me w.r.t. patents at discuss@linmodems.org

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2001-04-30  5:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-04-25 17:23 Lid support for ACPI Grover, Andrew
2001-04-25 20:22 ` Pavel Machek
2001-04-25 22:13 ` Pavel Machek
2001-04-27 17:08 ` Michael K. Johnson
2001-04-29  1:42   ` Pavel Machek
  -- strict thread matches above, loose matches on Subject: below --
2001-04-30  5:00 Grover, Andrew
2001-04-25 20:54 Grover, Andrew
2001-04-23  8:45 Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox