drivers/gpu/drm/drm_privacy_screen.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_privacy_screen.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_privacy_screen.c- Extension
.c- Size
- 14288 bytes
- Lines
- 473
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/export.hlinux/kernel.hlinux/list.hlinux/module.hlinux/mutex.hlinux/slab.hdrm/drm_privacy_screen_machine.hdrm/drm_privacy_screen_consumer.hdrm/drm_privacy_screen_driver.hdrm_internal.h
Detected Declarations
function drm_privacy_screen_lookup_removefunction drm_privacy_screen_lookup_addfunction list_for_each_entryfunction ERR_PTRfunction list_for_each_entryfunction drm_privacy_screen_getfunction drm_privacy_screen_set_sw_statefunction drm_privacy_screen_get_statefunction drm_privacy_screen_get_statefunction drm_privacy_screen_register_notifierfunction sw_state_showfunction hw_state_showfunction drm_privacy_screen_device_releasefunction ERR_PTRfunction drm_privacy_screen_unregisterfunction drm_privacy_screen_call_notifier_chainexport drm_privacy_screen_lookup_addexport drm_privacy_screen_lookup_removeexport drm_privacy_screen_getexport drm_privacy_screen_putexport drm_privacy_screen_set_sw_stateexport drm_privacy_screen_get_stateexport drm_privacy_screen_register_notifierexport drm_privacy_screen_unregister_notifierexport drm_privacy_screen_registerexport drm_privacy_screen_unregisterexport drm_privacy_screen_call_notifier_chain
Annotated Snippet
if (strcmp(dev_name(&priv->dev), name) == 0) {
dev = get_device(&priv->dev);
break;
}
}
mutex_unlock(&drm_privacy_screen_devs_lock);
return dev ? to_drm_privacy_screen(dev) : NULL;
}
/**
* drm_privacy_screen_get - get a privacy-screen provider
* @dev: consumer-device for which to get a privacy-screen provider
* @con_id: (video)connector name for which to get a privacy-screen provider
*
* Get a privacy-screen provider for a privacy-screen attached to the
* display described by the @dev and @con_id parameters.
*
* Return:
* * A pointer to a &struct drm_privacy_screen on success.
* * ERR_PTR(-ENODEV) if no matching privacy-screen is found
* * ERR_PTR(-EPROBE_DEFER) if there is a matching privacy-screen,
* but it has not been registered yet.
*/
struct drm_privacy_screen *drm_privacy_screen_get(struct device *dev,
const char *con_id)
{
const char *dev_id = dev ? dev_name(dev) : NULL;
struct drm_privacy_screen_lookup *l;
struct drm_privacy_screen *priv;
const char *provider = NULL;
int match, best = -1;
/*
* For now we only support using a static lookup table, which is
* populated by the drm_privacy_screen_arch_init() call. This should
* be extended with device-tree / fw_node lookup when support is added
* for device-tree using hardware with a privacy-screen.
*
* The lookup algorithm was shamelessly taken from the clock
* framework:
*
* We do slightly fuzzy matching here:
* An entry with a NULL ID is assumed to be a wildcard.
* If an entry has a device ID, it must match
* If an entry has a connection ID, it must match
* Then we take the most specific entry - with the following order
* of precedence: dev+con > dev only > con only.
*/
mutex_lock(&drm_privacy_screen_lookup_lock);
list_for_each_entry(l, &drm_privacy_screen_lookup_list, list) {
match = 0;
if (l->dev_id) {
if (!dev_id || strcmp(l->dev_id, dev_id))
continue;
match += 2;
}
if (l->con_id) {
if (!con_id || strcmp(l->con_id, con_id))
continue;
match += 1;
}
if (match > best) {
provider = l->provider;
best = match;
}
}
mutex_unlock(&drm_privacy_screen_lookup_lock);
if (!provider)
return ERR_PTR(-ENODEV);
priv = drm_privacy_screen_get_by_name(provider);
if (!priv)
return ERR_PTR(-EPROBE_DEFER);
return priv;
}
EXPORT_SYMBOL(drm_privacy_screen_get);
/**
* drm_privacy_screen_put - release a privacy-screen reference
Annotation
- Immediate include surface: `linux/device.h`, `linux/export.h`, `linux/kernel.h`, `linux/list.h`, `linux/module.h`, `linux/mutex.h`, `linux/slab.h`, `drm/drm_privacy_screen_machine.h`.
- Detected declarations: `function drm_privacy_screen_lookup_remove`, `function drm_privacy_screen_lookup_add`, `function list_for_each_entry`, `function ERR_PTR`, `function list_for_each_entry`, `function drm_privacy_screen_get`, `function drm_privacy_screen_set_sw_state`, `function drm_privacy_screen_get_state`, `function drm_privacy_screen_get_state`, `function drm_privacy_screen_register_notifier`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.