| @@ -1,70 +1,72 @@ | | | @@ -1,70 +1,72 @@ |
1 | /* $NetBSD: radeon_acpi.c,v 1.5 2024/04/16 14:34:02 riastradh Exp $ */ | | 1 | /* $NetBSD: radeon_acpi.c,v 1.6 2024/04/18 23:33:15 riastradh Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright 2012 Advanced Micro Devices, Inc. | | 4 | * Copyright 2012 Advanced Micro Devices, Inc. |
5 | * | | 5 | * |
6 | * Permission is hereby granted, free of charge, to any person obtaining a | | 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
7 | * copy of this software and associated documentation files (the "Software"), | | 7 | * copy of this software and associated documentation files (the "Software"), |
8 | * to deal in the Software without restriction, including without limitation | | 8 | * to deal in the Software without restriction, including without limitation |
9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | | 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
10 | * and/or sell copies of the Software, and to permit persons to whom the | | 10 | * and/or sell copies of the Software, and to permit persons to whom the |
11 | * Software is furnished to do so, subject to the following conditions: | | 11 | * Software is furnished to do so, subject to the following conditions: |
12 | * | | 12 | * |
13 | * The above copyright notice and this permission notice shall be included in | | 13 | * The above copyright notice and this permission notice shall be included in |
14 | * all copies or substantial portions of the Software. | | 14 | * all copies or substantial portions of the Software. |
15 | * | | 15 | * |
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | | 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | | 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | | 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
19 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | | 19 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | | 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | | 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
22 | * OTHER DEALINGS IN THE SOFTWARE. | | 22 | * OTHER DEALINGS IN THE SOFTWARE. |
23 | * | | 23 | * |
24 | */ | | 24 | */ |
25 | | | 25 | |
26 | #include <sys/cdefs.h> | | 26 | #include <sys/cdefs.h> |
27 | __KERNEL_RCSID(0, "$NetBSD: radeon_acpi.c,v 1.5 2024/04/16 14:34:02 riastradh Exp $"); | | 27 | __KERNEL_RCSID(0, "$NetBSD: radeon_acpi.c,v 1.6 2024/04/18 23:33:15 riastradh Exp $"); |
28 | | | 28 | |
29 | #include <linux/acpi.h> | | 29 | #include <linux/acpi.h> |
30 | #include <linux/pci.h> | | 30 | #include <linux/pci.h> |
31 | #include <linux/pm_runtime.h> | | 31 | #include <linux/pm_runtime.h> |
32 | #include <linux/power_supply.h> | | 32 | #include <linux/power_supply.h> |
33 | #include <linux/slab.h> | | 33 | #include <linux/slab.h> |
34 | | | 34 | |
35 | #include <acpi/acpi_bus.h> | | 35 | #include <acpi/acpi_bus.h> |
36 | #include <acpi/video.h> | | 36 | #include <acpi/video.h> |
37 | | | 37 | |
38 | #include <drm/drm_crtc_helper.h> | | 38 | #include <drm/drm_crtc_helper.h> |
39 | #include <drm/drm_probe_helper.h> | | 39 | #include <drm/drm_probe_helper.h> |
40 | | | 40 | |
41 | #include "atom.h" | | 41 | #include "atom.h" |
42 | #include "radeon.h" | | 42 | #include "radeon.h" |
43 | #include "radeon_acpi.h" | | 43 | #include "radeon_acpi.h" |
44 | | | 44 | |
45 | #ifdef __NetBSD__ | | 45 | #ifdef __NetBSD__ |
46 | #include <dev/acpi/acpi_pci.h> | | 46 | #include <dev/acpi/acpi_pci.h> |
47 | #include <dev/acpi/acpireg.h> | | 47 | #include <dev/acpi/acpireg.h> |
48 | #define _COMPONENT ACPI_DISPLAY_COMPONENT | | 48 | #define _COMPONENT ACPI_DISPLAY_COMPONENT |
49 | ACPI_MODULE_NAME("radeon_acpi") | | 49 | ACPI_MODULE_NAME("radeon_acpi") |
50 | #include <linux/nbsd-namespace-acpi.h> | | 50 | #include <linux/nbsd-namespace-acpi.h> |
51 | #endif | | 51 | #endif |
52 | | | 52 | |
| | | 53 | #ifndef __NetBSD__ /* XXX radeon acpi */ |
53 | #if defined(CONFIG_VGA_SWITCHEROO) | | 54 | #if defined(CONFIG_VGA_SWITCHEROO) |
54 | bool radeon_atpx_dgpu_req_power_for_displays(void); | | 55 | bool radeon_atpx_dgpu_req_power_for_displays(void); |
55 | #else | | 56 | #else |
56 | static inline bool radeon_atpx_dgpu_req_power_for_displays(void) { return false; } | | 57 | static inline bool radeon_atpx_dgpu_req_power_for_displays(void) { return false; } |
57 | #endif | | 58 | #endif |
| | | 59 | #endif |
58 | | | 60 | |
59 | #define ACPI_AC_CLASS "ac_adapter" | | 61 | #define ACPI_AC_CLASS "ac_adapter" |
60 | | | 62 | |
61 | extern void radeon_pm_acpi_event_handler(struct radeon_device *rdev); | | 63 | extern void radeon_pm_acpi_event_handler(struct radeon_device *rdev); |
62 | | | 64 | |
63 | struct atif_verify_interface { | | 65 | struct atif_verify_interface { |
64 | u16 size; /* structure size in bytes (includes size field) */ | | 66 | u16 size; /* structure size in bytes (includes size field) */ |
65 | u16 version; /* version */ | | 67 | u16 version; /* version */ |
66 | u32 notification_mask; /* supported notifications mask */ | | 68 | u32 notification_mask; /* supported notifications mask */ |
67 | u32 function_bits; /* supported functions bit vector */ | | 69 | u32 function_bits; /* supported functions bit vector */ |
68 | } __packed; | | 70 | } __packed; |
69 | | | 71 | |
70 | struct atif_system_params { | | 72 | struct atif_system_params { |