drivers/gpu/drm/drm_client_event.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_client_event.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/drm_client_event.c
Extension
.c
Size
5343 bytes
Lines
215
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

// SPDX-License-Identifier: GPL-2.0 or MIT
/*
 * Copyright 2018 Noralf Trønnes
 */

#include <linux/export.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/seq_file.h>

#include <drm/drm_client.h>
#include <drm/drm_client_event.h>
#include <drm/drm_debugfs.h>
#include <drm/drm_device.h>
#include <drm/drm_drv.h>
#include <drm/drm_print.h>

#include "drm_internal.h"

/**
 * drm_client_dev_unregister - Unregister clients
 * @dev: DRM device
 *
 * This function releases all clients by calling each client's
 * &drm_client_funcs.unregister callback. The callback function
 * is responsibe for releaseing all resources including the client
 * itself.
 *
 * The helper drm_dev_unregister() calls this function. Drivers
 * that use it don't need to call this function themselves.
 */
void drm_client_dev_unregister(struct drm_device *dev)
{
	struct drm_client_dev *client, *tmp;

	if (!drm_core_check_feature(dev, DRIVER_MODESET))
		return;

	mutex_lock(&dev->clientlist_mutex);
	list_for_each_entry_safe(client, tmp, &dev->clientlist, list) {
		list_del(&client->list);
		/*
		 * Unregistering consumes and frees the client.
		 */
		if (client->funcs && client->funcs->unregister)
			client->funcs->unregister(client);
		else
			drm_client_release(client);
	}
	mutex_unlock(&dev->clientlist_mutex);
}
EXPORT_SYMBOL(drm_client_dev_unregister);

static void drm_client_hotplug(struct drm_client_dev *client)
{
	struct drm_device *dev = client->dev;
	int ret;

	if (!client->funcs || !client->funcs->hotplug)
		return;

	if (client->hotplug_failed)
		return;

	if (client->suspended) {
		client->hotplug_pending = true;
		return;
	}

	client->hotplug_pending = false;
	ret = client->funcs->hotplug(client);
	drm_dbg_kms(dev, "%s: ret=%d\n", client->name, ret);
	if (ret)
		client->hotplug_failed = true;
}

/**
 * drm_client_dev_hotplug - Send hotplug event to clients
 * @dev: DRM device
 *
 * This function calls the &drm_client_funcs.hotplug callback on the attached clients.
 *
 * drm_kms_helper_hotplug_event() calls this function, so drivers that use it
 * don't need to call this function themselves.
 */
void drm_client_dev_hotplug(struct drm_device *dev)
{
	struct drm_client_dev *client;

	if (!drm_core_check_feature(dev, DRIVER_MODESET))

Annotation

Implementation Notes