drivers/gpu/drm/bridge/aux-hpd-bridge.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/bridge/aux-hpd-bridge.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/bridge/aux-hpd-bridge.c
Extension
.c
Size
5716 bytes
Lines
212
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

struct drm_aux_hpd_bridge_data {
	struct drm_bridge bridge;
	struct device *dev;
};

static void drm_aux_hpd_bridge_release(struct device *dev)
{
	struct auxiliary_device *adev = to_auxiliary_dev(dev);

	ida_free(&drm_aux_hpd_bridge_ida, adev->id);

	of_node_put(adev->dev.platform_data);
	of_node_put(adev->dev.of_node);

	kfree(adev);
}

static void drm_aux_hpd_bridge_free_adev(void *_adev)
{
	auxiliary_device_uninit(_adev);
}

/**
 * devm_drm_dp_hpd_bridge_alloc - allocate a HPD DisplayPort bridge
 * @parent: device instance providing this bridge
 * @np: device node pointer corresponding to this bridge instance
 *
 * Creates a simple DRM bridge with the type set to
 * DRM_MODE_CONNECTOR_DisplayPort, which terminates the bridge chain and is
 * able to send the HPD events.
 *
 * Return: bridge auxiliary device pointer or an error pointer
 */
struct auxiliary_device *devm_drm_dp_hpd_bridge_alloc(struct device *parent, struct device_node *np)
{
	struct auxiliary_device *adev;
	int ret;

	adev = kzalloc_obj(*adev);
	if (!adev)
		return ERR_PTR(-ENOMEM);

	ret = ida_alloc(&drm_aux_hpd_bridge_ida, GFP_KERNEL);
	if (ret < 0) {
		kfree(adev);
		return ERR_PTR(ret);
	}

	adev->id = ret;
	adev->name = "dp_hpd_bridge";
	adev->dev.parent = parent;
	adev->dev.release = drm_aux_hpd_bridge_release;
	adev->dev.platform_data = of_node_get(np);

	device_set_of_node_from_dev(&adev->dev, parent);

	ret = auxiliary_device_init(adev);
	if (ret) {
		of_node_put(adev->dev.platform_data);
		of_node_put(adev->dev.of_node);
		ida_free(&drm_aux_hpd_bridge_ida, adev->id);
		kfree(adev);
		return ERR_PTR(ret);
	}

	ret = devm_add_action_or_reset(parent, drm_aux_hpd_bridge_free_adev, adev);
	if (ret)
		return ERR_PTR(ret);

	return adev;
}
EXPORT_SYMBOL_GPL(devm_drm_dp_hpd_bridge_alloc);

static void drm_aux_hpd_bridge_del_adev(void *_adev)
{
	auxiliary_device_delete(_adev);
}

/**
 * devm_drm_dp_hpd_bridge_add - register a HDP DisplayPort bridge
 * @dev: struct device to tie registration lifetime to
 * @adev: bridge auxiliary device to be registered
 *
 * Returns: zero on success or a negative errno
 */
int devm_drm_dp_hpd_bridge_add(struct device *dev, struct auxiliary_device *adev)
{
	int ret;

	ret = auxiliary_device_add(adev);

Annotation

Implementation Notes