PATCH - acpi psm0 not working

From: Nate Lawson <nate_at_root.org>
Date: Tue, 16 Dec 2003 23:12:04 -0800 (PST)
If your mouse or other device is not working, this patch may help.  To see
if you need it, dump your ASL and do:

   grep _CID foo.asl | grep Package

If you get output from this command, this patch may help.  It enables
package evaluation for the _CID object.  If it helps you, please send me
the dmesg it adds, something like this:

acpi cids: 1 - 0x130fd041,

Thanks,
Nate

Index: sys/dev/acpica/acpi.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpica/acpi.c,v
retrieving revision 1.109
diff -u -r1.109 acpi.c
--- sys/dev/acpica/acpi.c	9 Dec 2003 06:29:57 -0000	1.109
+++ sys/dev/acpica/acpi.c	17 Dec 2003 07:03:07 -0000
_at__at_ -105,8 +105,8 _at__at_
 			u_long count, u_int flags);
 static int	acpi_release_resource(device_t bus, device_t child, int type,
 			int rid, struct resource *r);
-static u_int32_t acpi_isa_get_logicalid(device_t dev);
-static u_int32_t acpi_isa_get_compatid(device_t dev);
+static uint32_t	acpi_isa_get_logicalid(device_t dev);
+static int	acpi_isa_get_compatid(device_t dev, uint32_t *cids, int count);
 static int	acpi_isa_pnp_probe(device_t bus, device_t child,
 			struct isa_pnp_id *ids);
 static void	acpi_probe_children(device_t bus);
_at__at_ -800,12 +800,12 _at__at_
 	 | (PNP_HEXTONUM(s[6]) << 24)		\
 	 | (PNP_HEXTONUM(s[5]) << 28))

-static u_int32_t
+static uint32_t
 acpi_isa_get_logicalid(device_t dev)
 {
-    ACPI_HANDLE		h;
     ACPI_DEVICE_INFO	devinfo;
     ACPI_BUFFER		buf = {sizeof(devinfo), &devinfo};
+    ACPI_HANDLE		h;
     ACPI_STATUS		error;
     u_int32_t		pnpid;
     ACPI_LOCK_DECL;
_at__at_ -827,40 +827,65 _at__at_
     pnpid = PNP_EISAID(devinfo.HardwareId.Value);

 out:
+    /* XXX leaking memory for devinfo.CompatibilityId.Id array? */
     ACPI_UNLOCK;
     return_VALUE (pnpid);
 }

-static u_int32_t
-acpi_isa_get_compatid(device_t dev)
+static int
+acpi_isa_get_compatid(device_t dev, uint32_t *cids, int count)
 {
+    ACPI_DEVICE_INFO	devinfo;
+    ACPI_BUFFER		buf = {sizeof(devinfo), &devinfo};
     ACPI_HANDLE		h;
     ACPI_STATUS		error;
-    u_int32_t		pnpid;
+    uint32_t		*pnpid;
+    int			valid, i;
     ACPI_LOCK_DECL;

     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);

-    pnpid = 0;
+    pnpid = cids;
+    valid = 0;
     ACPI_LOCK;

-    /* Fetch and validate the HID */
+    /* Fetch and validate the CID */
     if ((h = acpi_get_handle(dev)) == NULL)
 	goto out;
-    if (ACPI_FAILURE(error = acpi_EvaluateInteger(h, "_CID", &pnpid)))
+    error = AcpiGetObjectInfo(h, &buf);
+    if (ACPI_FAILURE(error))
 	goto out;
+    if ((devinfo.Valid & ACPI_VALID_CID) == 0)
+	goto out;
+
+    if (devinfo.CompatibilityId.Count < count)
+	count = devinfo.CompatibilityId.Count;
+    for (i = 0; i < count; i++) {
+	if (strncmp(devinfo.CompatibilityId.Id[i].Value, "PNP", 3) != 0)
+	    continue;
+	*pnpid++ = PNP_EISAID(devinfo.CompatibilityId.Id[i].Value);
+	valid++;
+    }
+
+    /* XXX */
+    if (valid == 0)
+	goto out;
+    printf("acpi cids: %d - ", valid);
+    for (i = 0; i < valid; i++)
+	printf("%#x, ", cids[i]);
+    printf("\n");

 out:
+    /* XXX leaking memory for devinfo.CompatibilityId.Id array? */
     ACPI_UNLOCK;
-    return_VALUE (pnpid);
+    return_VALUE (valid);
 }

-
 static int
 acpi_isa_pnp_probe(device_t bus, device_t child, struct isa_pnp_id *ids)
 {
-    int			result;
-    u_int32_t		lid, cid;
+    int			result, cid_count, i;
+    uint32_t		lid, cids[8];

     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);

_at__at_ -873,17 +898,23 _at__at_

     /* Scan the supplied IDs for a match */
     lid = acpi_isa_get_logicalid(child);
-    cid = acpi_isa_get_compatid(child);
+    cid_count = acpi_isa_get_compatid(child, cids, 8);
     while (ids && ids->ip_id) {
-	if (lid == ids->ip_id || cid == ids->ip_id) {
+	if (lid == ids->ip_id) {
 	    result = 0;
 	    goto out;
 	}
+	for (i = 0; i < cid_count; i++) {
+	    if (cids[i] == ids->ip_id) {
+		result = 0;
+		goto out;
+	    }
+	}
 	ids++;
     }

  out:
-    return_VALUE(result);
+    return_VALUE (result);
 }

 /*
Received on Tue Dec 16 2003 - 22:12:03 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:34 UTC