drivers/gpu/drm/nouveau/nouveau_acpi.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/nouveau/nouveau_acpi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/nouveau/nouveau_acpi.c- Extension
.c- Size
- 10708 bytes
- Lines
- 399
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/pci.hlinux/acpi.hlinux/slab.hlinux/mxm-wmi.hlinux/vga_switcheroo.hdrm/drm_edid.hacpi/video.hnouveau_drv.hnouveau_acpi.h
Detected Declarations
function nouveau_is_optimusfunction nouveau_is_v1_dsmfunction nouveau_optimus_dsmfunction acpi_check_dsmfunction nouveau_dsmfunction nouveau_dsm_switch_muxfunction nouveau_dsm_set_discrete_statefunction nouveau_dsm_switchtofunction nouveau_dsm_power_statefunction nouveau_dsm_get_client_idfunction nouveau_dsm_pci_probefunction nouveau_dsm_detectfunction nouveau_register_dsm_handlerfunction nouveau_switcheroo_optimus_dsmfunction nouveau_unregister_dsm_handlerfunction nouveau_register_dsm_handlerfunction nouveau_acpi_video_backlight_use_nativefunction nouveau_acpi_video_register_backlight
Annotated Snippet
bool nouveau_is_optimus(void) {
return nouveau_dsm_priv.optimus_detected;
}
bool nouveau_is_v1_dsm(void) {
return nouveau_dsm_priv.dsm_detected;
}
#ifdef CONFIG_VGA_SWITCHEROO
static const guid_t nouveau_dsm_muid =
GUID_INIT(0x9D95A0A0, 0x0060, 0x4D48,
0xB3, 0x4D, 0x7E, 0x5F, 0xEA, 0x12, 0x9F, 0xD4);
static const guid_t nouveau_op_dsm_muid =
GUID_INIT(0xA486D8F8, 0x0BDA, 0x471B,
0xA7, 0x2B, 0x60, 0x42, 0xA6, 0xB5, 0xBE, 0xE0);
static int nouveau_optimus_dsm(acpi_handle handle, int func, int arg, uint32_t *result)
{
int i;
union acpi_object *obj;
char args_buff[4];
union acpi_object argv4 = {
.buffer.type = ACPI_TYPE_BUFFER,
.buffer.length = 4,
.buffer.pointer = args_buff
};
/* ACPI is little endian, AABBCCDD becomes {DD,CC,BB,AA} */
for (i = 0; i < 4; i++)
args_buff[i] = (arg >> i * 8) & 0xFF;
*result = 0;
obj = acpi_evaluate_dsm_typed(handle, &nouveau_op_dsm_muid, 0x00000100,
func, &argv4, ACPI_TYPE_BUFFER);
if (!obj) {
acpi_handle_info(handle, "failed to evaluate _DSM\n");
return AE_ERROR;
} else {
if (obj->buffer.length == 4) {
*result |= obj->buffer.pointer[0];
*result |= (obj->buffer.pointer[1] << 8);
*result |= (obj->buffer.pointer[2] << 16);
*result |= (obj->buffer.pointer[3] << 24);
}
ACPI_FREE(obj);
}
return 0;
}
/*
* On some platforms, _DSM(nouveau_op_dsm_muid, func0) has special
* requirements on the fourth parameter, so a private implementation
* instead of using acpi_check_dsm().
*/
static int nouveau_dsm_get_optimus_functions(acpi_handle handle)
{
int result;
/*
* Function 0 returns a Buffer containing available functions.
* The args parameter is ignored for function 0, so just put 0 in it
*/
if (nouveau_optimus_dsm(handle, 0, 0, &result))
return 0;
/*
* ACPI Spec v4 9.14.1: if bit 0 is zero, no function is supported.
* If the n-th bit is enabled, function n is supported
*/
if (result & 1 && result & (1 << NOUVEAU_DSM_OPTIMUS_CAPS))
return result;
return 0;
}
static int nouveau_dsm(acpi_handle handle, int func, int arg)
{
int ret = 0;
union acpi_object *obj;
union acpi_object argv4 = {
.integer.type = ACPI_TYPE_INTEGER,
.integer.value = arg,
};
obj = acpi_evaluate_dsm_typed(handle, &nouveau_dsm_muid, 0x00000102,
func, &argv4, ACPI_TYPE_INTEGER);
if (!obj) {
acpi_handle_info(handle, "failed to evaluate _DSM\n");
return AE_ERROR;
Annotation
- Immediate include surface: `linux/pci.h`, `linux/acpi.h`, `linux/slab.h`, `linux/mxm-wmi.h`, `linux/vga_switcheroo.h`, `drm/drm_edid.h`, `acpi/video.h`, `nouveau_drv.h`.
- Detected declarations: `function nouveau_is_optimus`, `function nouveau_is_v1_dsm`, `function nouveau_optimus_dsm`, `function acpi_check_dsm`, `function nouveau_dsm`, `function nouveau_dsm_switch_mux`, `function nouveau_dsm_set_discrete_state`, `function nouveau_dsm_switchto`, `function nouveau_dsm_power_state`, `function nouveau_dsm_get_client_id`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.