aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/vkms/vkms_output.c
diff options
context:
space:
mode:
authorJosé Expósito <jose.exposito89@gmail.com>2025-02-18 11:12:12 +0100
committerMaxime Ripard <mripard@kernel.org>2025-03-07 10:58:27 +0100
commitb8776fc9b2863c55193f66e1146a89bbccd2b4e0 (patch)
tree2a284cacc72ca3908ead06a92214bc8da589746f /drivers/gpu/drm/vkms/vkms_output.c
parentdrm/vkms: Allow to configure multiple encoders (diff)
downloadlinux-b8776fc9b2863c55193f66e1146a89bbccd2b4e0.tar.gz
linux-b8776fc9b2863c55193f66e1146a89bbccd2b4e0.zip
drm/vkms: Allow to attach encoders and CRTCs
Add a list of possible CRTCs to the encoder configuration and helpers to attach and detach them. Now that the default configuration has its encoder and CRTC correctly attached, configure the output following the configuration. Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com> Co-developed-by: Louis Chauvet <louis.chauvet@bootlin.com> Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com> Signed-off-by: José Expósito <jose.exposito89@gmail.com> Link: https://patchwork.freedesktop.org/patch/msgid/20250218101214.5790-13-jose.exposito89@gmail.com Signed-off-by: Maxime Ripard <mripard@kernel.org>
Diffstat (limited to 'drivers/gpu/drm/vkms/vkms_output.c')
-rw-r--r--drivers/gpu/drm/vkms/vkms_output.c49
1 files changed, 29 insertions, 20 deletions
diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c
index f63bc8e3014b..8920d6b5d105 100644
--- a/drivers/gpu/drm/vkms/vkms_output.c
+++ b/drivers/gpu/drm/vkms/vkms_output.c
@@ -9,9 +9,9 @@ int vkms_output_init(struct vkms_device *vkmsdev)
{
struct drm_device *dev = &vkmsdev->drm;
struct vkms_connector *connector;
- struct drm_encoder *encoder;
struct vkms_config_plane *plane_cfg;
struct vkms_config_crtc *crtc_cfg;
+ struct vkms_config_encoder *encoder_cfg;
int ret;
int writeback;
@@ -61,32 +61,41 @@ int vkms_output_init(struct vkms_device *vkmsdev)
}
}
+ vkms_config_for_each_encoder(vkmsdev->config, encoder_cfg) {
+ struct vkms_config_crtc *possible_crtc;
+ unsigned long idx = 0;
+
+ encoder_cfg->encoder = drmm_kzalloc(dev, sizeof(*encoder_cfg->encoder), GFP_KERNEL);
+ if (!encoder_cfg->encoder) {
+ DRM_ERROR("Failed to allocate encoder\n");
+ return -ENOMEM;
+ }
+ ret = drmm_encoder_init(dev, encoder_cfg->encoder, NULL,
+ DRM_MODE_ENCODER_VIRTUAL, NULL);
+ if (ret) {
+ DRM_ERROR("Failed to init encoder\n");
+ return ret;
+ }
+
+ vkms_config_encoder_for_each_possible_crtc(encoder_cfg, idx, possible_crtc) {
+ encoder_cfg->encoder->possible_crtcs |=
+ drm_crtc_mask(&possible_crtc->crtc->crtc);
+ }
+ }
+
connector = vkms_connector_init(vkmsdev);
if (IS_ERR(connector)) {
DRM_ERROR("Failed to init connector\n");
return PTR_ERR(connector);
}
- encoder = drmm_kzalloc(dev, sizeof(*encoder), GFP_KERNEL);
- if (!encoder) {
- DRM_ERROR("Failed to allocate encoder\n");
- return -ENOMEM;
- }
- ret = drmm_encoder_init(dev, encoder, NULL,
- DRM_MODE_ENCODER_VIRTUAL, NULL);
- if (ret) {
- DRM_ERROR("Failed to init encoder\n");
- return ret;
- }
-
- vkms_config_for_each_crtc(vkmsdev->config, crtc_cfg)
- encoder->possible_crtcs = drm_crtc_mask(&crtc_cfg->crtc->crtc);
-
/* Attach the encoder and the connector */
- ret = drm_connector_attach_encoder(&connector->base, encoder);
- if (ret) {
- DRM_ERROR("Failed to attach connector to encoder\n");
- return ret;
+ vkms_config_for_each_encoder(vkmsdev->config, encoder_cfg) {
+ ret = drm_connector_attach_encoder(&connector->base, encoder_cfg->encoder);
+ if (ret) {
+ DRM_ERROR("Failed to attach connector to encoder\n");
+ return ret;
+ }
}
drm_mode_config_reset(dev);