This commit adds the essential infrastructure for around CRTCs which is composed of: a new data struct for output data information, a function for creating planes, and a simple encoder attached to the connector. Finally, due to the introduction of a new initialization function, connectors were moved from vkms_drv.c to vkms_display.c. Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com> Reviewed-by: Haneen Mohammed <hamohammed.sa@gmail.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com> Link: https://patchwork.freedesktop.org/patch/msgid/b6e27bc6a54f5cb340658fa5969f7b48fbfbf1b7.1526514457.git.rodrigosiqueiramelo@gmail.com
92 lines
2.2 KiB
C
92 lines
2.2 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*/
|
|
|
|
#include "vkms_drv.h"
|
|
#include <drm/drm_crtc_helper.h>
|
|
|
|
static void vkms_connector_destroy(struct drm_connector *connector)
|
|
{
|
|
drm_connector_unregister(connector);
|
|
drm_connector_cleanup(connector);
|
|
}
|
|
|
|
static const struct drm_connector_funcs vkms_connector_funcs = {
|
|
.fill_modes = drm_helper_probe_single_connector_modes,
|
|
.destroy = vkms_connector_destroy,
|
|
};
|
|
|
|
static const struct drm_encoder_funcs vkms_encoder_funcs = {
|
|
.destroy = drm_encoder_cleanup,
|
|
};
|
|
|
|
int vkms_output_init(struct vkms_device *vkmsdev)
|
|
{
|
|
struct vkms_output *output = &vkmsdev->output;
|
|
struct drm_device *dev = &vkmsdev->drm;
|
|
struct drm_connector *connector = &output->connector;
|
|
struct drm_encoder *encoder = &output->encoder;
|
|
struct drm_crtc *crtc = &output->crtc;
|
|
struct drm_plane *primary;
|
|
int ret;
|
|
|
|
primary = vkms_plane_init(vkmsdev);
|
|
if (IS_ERR(primary))
|
|
return PTR_ERR(primary);
|
|
|
|
ret = vkms_crtc_init(dev, crtc, primary, NULL);
|
|
if (ret)
|
|
goto err_crtc;
|
|
|
|
ret = drm_connector_init(dev, connector, &vkms_connector_funcs,
|
|
DRM_MODE_CONNECTOR_VIRTUAL);
|
|
if (ret) {
|
|
DRM_ERROR("Failed to init connector\n");
|
|
goto err_connector;
|
|
}
|
|
|
|
ret = drm_connector_register(connector);
|
|
if (ret) {
|
|
DRM_ERROR("Failed to register connector\n");
|
|
goto err_connector_register;
|
|
}
|
|
|
|
ret = drm_encoder_init(dev, encoder, &vkms_encoder_funcs,
|
|
DRM_MODE_ENCODER_VIRTUAL, NULL);
|
|
if (ret) {
|
|
DRM_ERROR("Failed to init encoder\n");
|
|
goto err_encoder;
|
|
}
|
|
encoder->possible_crtcs = 1;
|
|
|
|
ret = drm_mode_connector_attach_encoder(connector, encoder);
|
|
if (ret) {
|
|
DRM_ERROR("Failed to attach connector to encoder\n");
|
|
goto err_attach;
|
|
}
|
|
|
|
drm_mode_config_reset(dev);
|
|
|
|
return 0;
|
|
|
|
err_attach:
|
|
drm_encoder_cleanup(encoder);
|
|
|
|
err_encoder:
|
|
drm_connector_unregister(connector);
|
|
|
|
err_connector_register:
|
|
drm_connector_cleanup(connector);
|
|
|
|
err_connector:
|
|
drm_crtc_cleanup(crtc);
|
|
|
|
err_crtc:
|
|
drm_plane_cleanup(primary);
|
|
return ret;
|
|
}
|