drivers/gpu/drm/drm_client_modeset.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_client_modeset.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_client_modeset.c- Extension
.c- Size
- 34724 bytes
- Lines
- 1344
- 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
drm/drm_modeset_lock.hlinux/export.hlinux/module.hlinux/mutex.hlinux/slab.hlinux/string_helpers.hdrm/drm_atomic.hdrm/drm_client.hdrm/drm_connector.hdrm/drm_crtc.hdrm/drm_device.hdrm/drm_drv.hdrm/drm_edid.hdrm/drm_encoder.hdrm/drm_print.hdrm_crtc_internal.hdrm_internal.htests/drm_client_modeset_test.c
Detected Declarations
struct drm_client_offsetfunction drm_client_modeset_createfunction drm_client_modeset_releasefunction drm_client_for_each_modesetfunction drm_client_modeset_freefunction drm_client_find_modesetfunction drm_connector_get_tiled_modefunction list_for_each_entryfunction drm_connector_fallback_non_tiled_modefunction list_for_each_entryfunction drm_connector_preferred_modefunction list_for_each_entryfunction drm_connector_first_modefunction drm_connector_pick_cmdline_modefunction list_for_each_entryfunction drm_connector_enabledfunction drm_client_connectors_enabledfunction mode_replacefunction modes_destroyfunction drm_client_target_clonedfunction list_for_each_entryfunction drm_client_get_tile_offsetsfunction drm_client_target_preferredfunction connector_has_possible_crtcfunction drm_connector_for_each_possible_encoderfunction drm_client_pick_crtcsfunction drm_client_firmware_configfunction drm_client_modeset_probefunction drm_client_rotationfunction drm_client_modeset_commit_atomicfunction drm_client_for_each_modesetfunction __drm_atomic_helper_set_configfunction drm_client_modeset_commit_legacyfunction drm_client_for_each_modesetfunction drm_client_modeset_checkfunction drm_client_modeset_commit_lockedfunction drm_client_modeset_commitfunction drm_client_modeset_dpms_legacyfunction drm_client_modeset_dpmsfunction drm_client_modeset_wait_for_vblankexport drm_client_modeset_probeexport drm_client_rotationexport drm_client_modeset_checkexport drm_client_modeset_commit_lockedexport drm_client_modeset_commitexport drm_client_modeset_dpmsexport drm_client_modeset_wait_for_vblank
Annotated Snippet
struct drm_client_offset {
int x, y;
};
int drm_client_modeset_create(struct drm_client_dev *client)
{
struct drm_device *dev = client->dev;
unsigned int num_crtc = dev->mode_config.num_crtc;
unsigned int max_connector_count = 1;
struct drm_mode_set *modeset;
struct drm_crtc *crtc;
int i = 0;
/* Add terminating zero entry to enable index less iteration */
client->modesets = kzalloc_objs(*client->modesets, num_crtc + 1);
if (!client->modesets)
return -ENOMEM;
mutex_init(&client->modeset_mutex);
drm_for_each_crtc(crtc, dev)
client->modesets[i++].crtc = crtc;
/* Cloning is only supported in the single crtc case. */
if (num_crtc == 1)
max_connector_count = DRM_CLIENT_MAX_CLONED_CONNECTORS;
for (modeset = client->modesets; modeset->crtc; modeset++) {
modeset->connectors = kzalloc_objs(*modeset->connectors,
max_connector_count);
if (!modeset->connectors)
goto err_free;
}
return 0;
err_free:
drm_client_modeset_free(client);
return -ENOMEM;
}
static void drm_client_modeset_release(struct drm_client_dev *client)
{
struct drm_mode_set *modeset;
drm_client_for_each_modeset(modeset, client) {
int i;
drm_mode_destroy(client->dev, modeset->mode);
modeset->mode = NULL;
modeset->fb = NULL;
for (i = 0; i < modeset->num_connectors; i++) {
drm_connector_put(modeset->connectors[i]);
modeset->connectors[i] = NULL;
}
modeset->num_connectors = 0;
}
}
void drm_client_modeset_free(struct drm_client_dev *client)
{
struct drm_mode_set *modeset;
mutex_lock(&client->modeset_mutex);
drm_client_modeset_release(client);
drm_client_for_each_modeset(modeset, client)
kfree(modeset->connectors);
mutex_unlock(&client->modeset_mutex);
mutex_destroy(&client->modeset_mutex);
kfree(client->modesets);
}
static struct drm_mode_set *
drm_client_find_modeset(struct drm_client_dev *client, struct drm_crtc *crtc)
{
struct drm_mode_set *modeset;
drm_client_for_each_modeset(modeset, client)
if (modeset->crtc == crtc)
return modeset;
return NULL;
}
Annotation
- Immediate include surface: `drm/drm_modeset_lock.h`, `linux/export.h`, `linux/module.h`, `linux/mutex.h`, `linux/slab.h`, `linux/string_helpers.h`, `drm/drm_atomic.h`, `drm/drm_client.h`.
- Detected declarations: `struct drm_client_offset`, `function drm_client_modeset_create`, `function drm_client_modeset_release`, `function drm_client_for_each_modeset`, `function drm_client_modeset_free`, `function drm_client_find_modeset`, `function drm_connector_get_tiled_mode`, `function list_for_each_entry`, `function drm_connector_fallback_non_tiled_mode`, `function list_for_each_entry`.
- 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.