drivers/platform/chrome/chromeos_privacy_screen.c
Source file repositories/reference/linux-study-clean/drivers/platform/chrome/chromeos_privacy_screen.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/chrome/chromeos_privacy_screen.c- Extension
.c- Size
- 4510 bytes
- Lines
- 151
- Domain
- Driver Families
- Bucket
- drivers/platform
- 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/acpi.hlinux/platform_device.hdrm/drm_privacy_screen_driver.h
Detected Declarations
function chromeos_privacy_screen_get_hw_statefunction chromeos_privacy_screen_set_sw_statefunction chromeos_privacy_screen_probefunction chromeos_privacy_screen_remove
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* ChromeOS Privacy Screen support
*
* Copyright (C) 2022 Google LLC
*
* This is the Chromeos privacy screen provider, present on certain chromebooks,
* represented by a GOOG0010 device in the ACPI. This ACPI device, if present,
* will cause the i915 drm driver to probe defer until this driver registers
* the privacy-screen.
*/
#include <linux/acpi.h>
#include <linux/platform_device.h>
#include <drm/drm_privacy_screen_driver.h>
/*
* The DSM (Device Specific Method) constants below are the agreed API with
* the firmware team, on how to control privacy screen using ACPI methods.
*/
#define PRIV_SCRN_DSM_REVID 1 /* DSM version */
#define PRIV_SCRN_DSM_FN_GET_STATUS 1 /* Get privacy screen status */
#define PRIV_SCRN_DSM_FN_ENABLE 2 /* Enable privacy screen */
#define PRIV_SCRN_DSM_FN_DISABLE 3 /* Disable privacy screen */
static const guid_t chromeos_privacy_screen_dsm_guid =
GUID_INIT(0xc7033113, 0x8720, 0x4ceb,
0x90, 0x90, 0x9d, 0x52, 0xb3, 0xe5, 0x2d, 0x73);
static void
chromeos_privacy_screen_get_hw_state(struct drm_privacy_screen
*drm_privacy_screen)
{
union acpi_object *obj;
struct device *privacy_screen =
drm_privacy_screen_get_drvdata(drm_privacy_screen);
acpi_handle handle = ACPI_HANDLE(privacy_screen);
obj = acpi_evaluate_dsm(handle, &chromeos_privacy_screen_dsm_guid,
PRIV_SCRN_DSM_REVID,
PRIV_SCRN_DSM_FN_GET_STATUS, NULL);
if (!obj) {
dev_err(privacy_screen,
"_DSM failed to get privacy-screen state\n");
return;
}
if (obj->type != ACPI_TYPE_INTEGER)
dev_err(privacy_screen,
"Bad _DSM to get privacy-screen state\n");
else if (obj->integer.value == 1)
drm_privacy_screen->hw_state = drm_privacy_screen->sw_state =
PRIVACY_SCREEN_ENABLED;
else
drm_privacy_screen->hw_state = drm_privacy_screen->sw_state =
PRIVACY_SCREEN_DISABLED;
ACPI_FREE(obj);
}
static int
chromeos_privacy_screen_set_sw_state(struct drm_privacy_screen
*drm_privacy_screen,
enum drm_privacy_screen_status state)
{
union acpi_object *obj = NULL;
struct device *privacy_screen =
drm_privacy_screen_get_drvdata(drm_privacy_screen);
acpi_handle handle = ACPI_HANDLE(privacy_screen);
if (state == PRIVACY_SCREEN_DISABLED) {
obj = acpi_evaluate_dsm(handle,
&chromeos_privacy_screen_dsm_guid,
PRIV_SCRN_DSM_REVID,
PRIV_SCRN_DSM_FN_DISABLE, NULL);
} else if (state == PRIVACY_SCREEN_ENABLED) {
obj = acpi_evaluate_dsm(handle,
&chromeos_privacy_screen_dsm_guid,
PRIV_SCRN_DSM_REVID,
PRIV_SCRN_DSM_FN_ENABLE, NULL);
} else {
dev_err(privacy_screen,
"Bad attempt to set privacy-screen status to %u\n",
state);
return -EINVAL;
}
if (!obj) {
dev_err(privacy_screen,
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/platform_device.h`, `drm/drm_privacy_screen_driver.h`.
- Detected declarations: `function chromeos_privacy_screen_get_hw_state`, `function chromeos_privacy_screen_set_sw_state`, `function chromeos_privacy_screen_probe`, `function chromeos_privacy_screen_remove`.
- Atlas domain: Driver Families / drivers/platform.
- 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.