drivers/gpu/drm/vkms/vkms_config.c

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

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/vkms/vkms_config.c
Extension
.c
Size
17964 bytes
Lines
650
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

vkms_config_plane_for_each_possible_crtc(plane_cfg, idx, possible_crtc) {
			if (possible_crtc != crtc_cfg)
				continue;

			if (type == DRM_PLANE_TYPE_PRIMARY) {
				if (has_primary_plane) {
					drm_info(dev, "Multiple primary planes\n");
					return false;
				}

				has_primary_plane = true;
			} else if (type == DRM_PLANE_TYPE_CURSOR) {
				if (has_cursor_plane) {
					drm_info(dev, "Multiple cursor planes\n");
					return false;
				}

				has_cursor_plane = true;
			}
		}
	}

	if (!has_primary_plane) {
		drm_info(dev, "Primary plane not found\n");
		return false;
	}

	return true;
}

static bool valid_plane_possible_crtcs(const struct vkms_config *config)
{
	struct drm_device *dev = config->dev ? &config->dev->drm : NULL;
	struct vkms_config_plane *plane_cfg;

	vkms_config_for_each_plane(config, plane_cfg) {
		if (xa_empty(&plane_cfg->possible_crtcs)) {
			drm_info(dev, "All planes must have at least one possible CRTC\n");
			return false;
		}
	}

	return true;
}

static bool valid_crtc_number(const struct vkms_config *config)
{
	struct drm_device *dev = config->dev ? &config->dev->drm : NULL;
	size_t n_crtcs;

	n_crtcs = list_count_nodes((struct list_head *)&config->crtcs);
	if (n_crtcs <= 0 || n_crtcs >= 32) {
		drm_info(dev, "The number of CRTCs must be between 1 and 31\n");
		return false;
	}

	return true;
}

static bool valid_encoder_number(const struct vkms_config *config)
{
	struct drm_device *dev = config->dev ? &config->dev->drm : NULL;
	size_t n_encoders;

	n_encoders = list_count_nodes((struct list_head *)&config->encoders);
	if (n_encoders <= 0 || n_encoders >= 32) {
		drm_info(dev, "The number of encoders must be between 1 and 31\n");
		return false;
	}

	return true;
}

static bool valid_encoder_possible_crtcs(const struct vkms_config *config)
{
	struct drm_device *dev = config->dev ? &config->dev->drm : NULL;
	struct vkms_config_crtc *crtc_cfg;
	struct vkms_config_encoder *encoder_cfg;

	vkms_config_for_each_encoder(config, encoder_cfg) {
		if (xa_empty(&encoder_cfg->possible_crtcs)) {
			drm_info(dev, "All encoders must have at least one possible CRTC\n");
			return false;
		}
	}

	vkms_config_for_each_crtc(config, crtc_cfg) {
		bool crtc_has_encoder = false;

		vkms_config_for_each_encoder(config, encoder_cfg) {

Annotation

Implementation Notes