Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/drm2/linux drm: Move acpi_check_dsm &c. fro...



details:   https://anonhg.NetBSD.org/src/rev/1a23ee7262fb
branches:  trunk
changeset: 362438:1a23ee7262fb
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Feb 27 14:22:21 2022 +0000

description:
drm: Move acpi_check_dsm &c. from intel_acpi.c to new linux_acpi.c.

diffstat:

 sys/external/bsd/drm2/dist/drm/i915/display/intel_acpi.c |   89 +-----------
 sys/external/bsd/drm2/include/linux/acpi.h               |   17 ++-
 sys/external/bsd/drm2/linux/files.drmkms_linux           |    3 +-
 sys/external/bsd/drm2/linux/linux_acpi.c                 |  117 +++++++++++++++
 4 files changed, 137 insertions(+), 89 deletions(-)

diffs (278 lines):

diff -r 66ed8745906d -r 1a23ee7262fb sys/external/bsd/drm2/dist/drm/i915/display/intel_acpi.c
--- a/sys/external/bsd/drm2/dist/drm/i915/display/intel_acpi.c  Sun Feb 27 14:20:30 2022 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/display/intel_acpi.c  Sun Feb 27 14:22:21 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intel_acpi.c,v 1.6 2022/02/27 14:20:30 riastradh Exp $ */
+/*     $NetBSD: intel_acpi.c,v 1.7 2022/02/27 14:22:21 riastradh Exp $ */
 
 // SPDX-License-Identifier: GPL-2.0
 /*
@@ -8,7 +8,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intel_acpi.c,v 1.6 2022/02/27 14:20:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intel_acpi.c,v 1.7 2022/02/27 14:22:21 riastradh Exp $");
 
 #include <linux/pci.h>
 #include <linux/acpi.h>
@@ -32,91 +32,6 @@
 #define        package         Package
 #define        pointer         Pointer
 #define        value           Value
-
-static ACPI_OBJECT *
-acpi_evaluate_dsm(ACPI_HANDLE handle, const guid_t *uuid, int rev, int func,
-    ACPI_OBJECT *argv4)
-{
-       ACPI_OBJECT_LIST arg;
-       ACPI_OBJECT params[4];
-       ACPI_BUFFER buf;
-       ACPI_STATUS rv;
-
-       if (handle == NULL)
-               handle = ACPI_ROOT_OBJECT;
-
-       arg.Count = 4;
-       arg.Pointer = params;
-       params[0].Type = ACPI_TYPE_BUFFER;
-       params[0].Buffer.Length = 16;
-       params[0].Buffer.Pointer = (char *)__UNCONST(uuid);
-       params[1].Type = ACPI_TYPE_INTEGER;
-       params[1].Integer.Value = rev;
-       params[2].Type = ACPI_TYPE_INTEGER;
-       params[2].Integer.Value = func;
-       if (argv4 != NULL) {
-               params[3] = *argv4;
-       } else {
-               params[3].Type = ACPI_TYPE_PACKAGE;
-               params[3].Package.Count = 0;
-               params[3].Package.Elements = NULL;
-       }
-
-       buf.Pointer = NULL;
-       buf.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
-
-       rv = AcpiEvaluateObject(handle, "_DSM", &arg, &buf);
-       if (ACPI_SUCCESS(rv))
-               return (ACPI_OBJECT *)buf.Pointer;
-       return NULL;
-}
-
-static inline ACPI_OBJECT *
-acpi_evaluate_dsm_typed(ACPI_HANDLE handle, const guid_t *uuid, int rev,
-    int func, ACPI_OBJECT *argv4, ACPI_OBJECT_TYPE type)
-{
-       ACPI_OBJECT *obj;
-
-       obj = acpi_evaluate_dsm(handle, uuid, rev, func, argv4);
-       if (obj != NULL && obj->Type != type) {
-               ACPI_FREE(obj);
-               obj = NULL;
-       }
-       return obj;
-}
-
-#define        ACPI_INIT_DSM_ARGV4(cnt, eles)          \
-{                                              \
-       .Package.Type = ACPI_TYPE_PACKAGE,      \
-       .Package.Count = (cnt),                 \
-       .Package.Elements = (eles)              \
-}
-
-static bool
-acpi_check_dsm(ACPI_HANDLE handle, const guid_t *uuid, int rev, uint64_t funcs)
-{
-       ACPI_OBJECT *obj;
-       uint64_t mask = 0;
-       int i;
-
-       if (funcs == 0)
-               return false;
-
-       obj = acpi_evaluate_dsm(handle, uuid, rev, 0, NULL);
-       if (obj == NULL)
-               return false;
-
-       if (obj->Type == ACPI_TYPE_INTEGER)
-               mask = obj->Integer.Value;
-       else if (obj->Type == ACPI_TYPE_BUFFER)
-               for (i = 0; i < obj->Buffer.Length && i < 8; i++)
-                       mask |= (uint64_t)obj->Buffer.Pointer[i] << (i * 8);
-       ACPI_FREE(obj);
-
-       if ((mask & 0x1) == 0x1 && (mask & funcs) == funcs)
-               return true;
-       return false;
-}
 #endif
 
 #define INTEL_DSM_REVISION_ID 1 /* For Calpella anyway... */
diff -r 66ed8745906d -r 1a23ee7262fb sys/external/bsd/drm2/include/linux/acpi.h
--- a/sys/external/bsd/drm2/include/linux/acpi.h        Sun Feb 27 14:20:30 2022 +0000
+++ b/sys/external/bsd/drm2/include/linux/acpi.h        Sun Feb 27 14:22:21 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpi.h,v 1.6 2021/12/19 11:38:04 riastradh Exp $       */
+/*     $NetBSD: acpi.h,v 1.7 2022/02/27 14:22:21 riastradh Exp $       */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -44,6 +44,21 @@
 #include <dev/acpi/acpivar.h>
 #endif
 
+#include <linux/types.h>
 #include <linux/uuid.h>
 
+typedef ACPI_HANDLE acpi_handle;
+typedef ACPI_OBJECT_TYPE acpi_object_type;
+typedef ACPI_STATUS acpi_status;
+
+#define        acpi_evaluate_dsm       linux_acpi_evaluate_dsm
+#define        acpi_evaluate_dsm_typed linux_acpi_evaluate_dsm_typed
+#define        acpi_check_dsm          linux_acpi_check_dsm
+
+union acpi_object *acpi_evaluate_dsm(acpi_handle, const guid_t *,
+    uint64_t, uint64_t, union acpi_object *);
+union acpi_object *acpi_evaluate_dsm_typed(acpi_handle, const guid_t *,
+    uint64_t, uint64_t, union acpi_object *, acpi_object_type);
+bool acpi_check_dsm(acpi_handle, const guid_t *, uint64_t, uint64_t);
+
 #endif  /* _LINUX_ACPI_H_ */
diff -r 66ed8745906d -r 1a23ee7262fb sys/external/bsd/drm2/linux/files.drmkms_linux
--- a/sys/external/bsd/drm2/linux/files.drmkms_linux    Sun Feb 27 14:20:30 2022 +0000
+++ b/sys/external/bsd/drm2/linux/files.drmkms_linux    Sun Feb 27 14:22:21 2022 +0000
@@ -1,10 +1,11 @@
-#       $NetBSD: files.drmkms_linux,v 1.40 2021/12/19 12:28:04 riastradh Exp $
+#       $NetBSD: files.drmkms_linux,v 1.41 2022/02/27 14:22:21 riastradh Exp $
 
 define drmkms_linux: i2cexec, i2c_bitbang
 
 makeoptions    drmkms_linux    "CPPFLAGS.drmkms_linux"+="-I$S/external/bsd/common/include"
 makeoptions    drmkms_linux    "CPPFLAGS.drmkms_linux"+="-I$S/external/bsd/drm2/include"
 
+file   external/bsd/drm2/linux/linux_acpi.c            drmkms_linux
 file   external/bsd/drm2/linux/linux_atomic64.c        drmkms_linux
 file   external/bsd/drm2/linux/linux_backlight.c       drmkms_linux
 file   external/bsd/drm2/linux/linux_dma_buf.c         drmkms_linux
diff -r 66ed8745906d -r 1a23ee7262fb sys/external/bsd/drm2/linux/linux_acpi.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/external/bsd/drm2/linux/linux_acpi.c  Sun Feb 27 14:22:21 2022 +0000
@@ -0,0 +1,117 @@
+/*     $NetBSD: linux_acpi.c,v 1.1 2022/02/27 14:22:21 riastradh Exp $ */
+
+/*-
+ * Copyright (c) 2022 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: linux_acpi.c,v 1.1 2022/02/27 14:22:21 riastradh Exp $");
+
+#include <linux/acpi.h>
+
+union acpi_object *
+acpi_evaluate_dsm(acpi_handle handle, const guid_t *uuid, u64 rev, u64 func,
+    union acpi_object *argv4)
+{
+       ACPI_OBJECT_LIST arg;
+       ACPI_OBJECT params[4];
+       ACPI_BUFFER buf;
+       ACPI_STATUS rv;
+
+       if (handle == NULL)
+               handle = ACPI_ROOT_OBJECT;
+
+       arg.Count = 4;
+       arg.Pointer = params;
+       params[0].Type = ACPI_TYPE_BUFFER;
+       params[0].Buffer.Length = 16;
+       params[0].Buffer.Pointer = (char *)__UNCONST(uuid);
+       params[1].Type = ACPI_TYPE_INTEGER;
+       params[1].Integer.Value = rev;
+       params[2].Type = ACPI_TYPE_INTEGER;
+       params[2].Integer.Value = func;
+       if (argv4 != NULL) {
+               params[3] = *argv4;
+       } else {
+               params[3].Type = ACPI_TYPE_PACKAGE;
+               params[3].Package.Count = 0;
+               params[3].Package.Elements = NULL;
+       }
+
+       buf.Pointer = NULL;
+       buf.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
+
+       rv = AcpiEvaluateObject(handle, "_DSM", &arg, &buf);
+       if (ACPI_SUCCESS(rv))
+               return (ACPI_OBJECT *)buf.Pointer;
+       return NULL;
+}
+
+union acpi_object *
+acpi_evaluate_dsm_typed(acpi_handle handle, const guid_t *uuid, u64 rev,
+    u64 func, union acpi_object *argv4, acpi_object_type type)
+{
+       union acpi_object *obj;
+
+       obj = acpi_evaluate_dsm(handle, uuid, rev, func, argv4);
+       if (obj != NULL && obj->Type != type) {
+               ACPI_FREE(obj);
+               obj = NULL;
+       }
+       return obj;
+}
+
+#define        ACPI_INIT_DSM_ARGV4(cnt, eles)          \
+{                                              \
+       .Package.Type = ACPI_TYPE_PACKAGE,      \
+       .Package.Count = (cnt),                 \
+       .Package.Elements = (eles)              \
+}
+
+bool
+acpi_check_dsm(acpi_handle handle, const guid_t *uuid, u64 rev, u64 funcs)
+{
+       ACPI_OBJECT *obj;
+       uint64_t mask = 0;
+       int i;
+
+       if (funcs == 0)
+               return false;
+
+       obj = acpi_evaluate_dsm(handle, uuid, rev, 0, NULL);
+       if (obj == NULL)
+               return false;
+
+       if (obj->Type == ACPI_TYPE_INTEGER)
+               mask = obj->Integer.Value;
+       else if (obj->Type == ACPI_TYPE_BUFFER)
+               for (i = 0; i < obj->Buffer.Length && i < 8; i++)
+                       mask |= (uint64_t)obj->Buffer.Pointer[i] << (i * 8);
+       ACPI_FREE(obj);
+
+       if ((mask & 0x1) == 0x1 && (mask & funcs) == funcs)
+               return true;
+       return false;
+}



Home | Main Index | Thread Index | Old Index