drivers/gpu/drm/vkms/vkms_connector.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/vkms/vkms_connector.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/vkms/vkms_connector.c- Extension
.c- Size
- 2691 bytes
- Lines
- 97
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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_atomic_helper.hdrm/drm_edid.hdrm/drm_managed.hdrm/drm_probe_helper.hvkms_config.hvkms_connector.h
Detected Declarations
function vkms_connector_detectfunction vkms_config_for_each_connectorfunction vkms_conn_get_modesfunction vkms_trigger_connector_hotplug
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
#include <drm/drm_atomic_helper.h>
#include <drm/drm_edid.h>
#include <drm/drm_managed.h>
#include <drm/drm_probe_helper.h>
#include "vkms_config.h"
#include "vkms_connector.h"
static enum drm_connector_status vkms_connector_detect(struct drm_connector *connector,
bool force)
{
struct drm_device *dev = connector->dev;
struct vkms_device *vkmsdev = drm_device_to_vkms_device(dev);
struct vkms_connector *vkms_connector;
enum drm_connector_status status;
struct vkms_config_connector *connector_cfg;
vkms_connector = drm_connector_to_vkms_connector(connector);
/*
* The connector configuration might not exist if its configfs directory
* was deleted. Therefore, use the configuration if present or keep the
* current status if we can not access it anymore.
*/
status = connector->status;
vkms_config_for_each_connector(vkmsdev->config, connector_cfg) {
if (connector_cfg->connector == vkms_connector)
status = vkms_config_connector_get_status(connector_cfg);
}
return status;
}
static const struct drm_connector_funcs vkms_connector_funcs = {
.detect = vkms_connector_detect,
.fill_modes = drm_helper_probe_single_connector_modes,
.reset = drm_atomic_helper_connector_reset,
.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
};
static int vkms_conn_get_modes(struct drm_connector *connector)
{
int count;
/* Use the default modes list from DRM */
count = drm_add_modes_noedid(connector, XRES_MAX, YRES_MAX);
drm_set_preferred_mode(connector, XRES_DEF, YRES_DEF);
return count;
}
static struct drm_encoder *vkms_conn_best_encoder(struct drm_connector *connector)
{
struct drm_encoder *encoder;
drm_connector_for_each_possible_encoder(connector, encoder)
return encoder;
return NULL;
}
static const struct drm_connector_helper_funcs vkms_conn_helper_funcs = {
.get_modes = vkms_conn_get_modes,
.best_encoder = vkms_conn_best_encoder,
};
struct vkms_connector *vkms_connector_init(struct vkms_device *vkmsdev)
{
struct drm_device *dev = &vkmsdev->drm;
struct vkms_connector *connector;
int ret;
connector = drmm_kzalloc(dev, sizeof(*connector), GFP_KERNEL);
if (!connector)
return ERR_PTR(-ENOMEM);
ret = drmm_connector_init(dev, &connector->base, &vkms_connector_funcs,
DRM_MODE_CONNECTOR_VIRTUAL, NULL);
if (ret)
return ERR_PTR(ret);
drm_connector_helper_add(&connector->base, &vkms_conn_helper_funcs);
return connector;
}
Annotation
- Immediate include surface: `drm/drm_atomic_helper.h`, `drm/drm_edid.h`, `drm/drm_managed.h`, `drm/drm_probe_helper.h`, `vkms_config.h`, `vkms_connector.h`.
- Detected declarations: `function vkms_connector_detect`, `function vkms_config_for_each_connector`, `function vkms_conn_get_modes`, `function vkms_trigger_connector_hotplug`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source 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.