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.

Dependency Surface

Detected Declarations

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

Implementation Notes