mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-21 08:46:49 +07:00
c06de56121
-----BEGIN PGP SIGNATURE----- iQFSBAABCAA8FiEEq68RxlopcLEwq+PEeb4+QwBBGIYFAlxqHJYeHHRvcnZhbGRz QGxpbnV4LWZvdW5kYXRpb24ub3JnAAoJEHm+PkMAQRiGWl8H/jPI4EipzD2GbnjZ GaFpMBBjcXBaVmoA+Y69so+7BHx1Ql+5GQtqbK0RHJRb9qEPLw3FBhHNjM/N8Sgf nSrK+GnBZp9s+k/NR/Yf2RacUR3jhz+Q9JEoQd3u9bFUeQyvE8Rf3vgtoBBwFOfz +t7N1memYVF3asLGWB4e4sP1YVMGfseTQpSPojvM30YWM86Bv+QtSx1AGgHczQIM kMKealR8ZPelN6JAXgLhQ5opDojBrE4YKB98pwsMDI6abz0Tz2JLFEUTTxsv5XNN o/Iz+XDoylskEyxN2unNWfHx7Swkvoklog8J/hDg5XlTvipL/WkT66PHBgcGMNvj BW9GgU8= =ZizU -----END PGP SIGNATURE----- Merge v5.0-rc7 into drm-next Backmerging for nouveau and imx that needed some fixes for next pulls. Signed-off-by: Dave Airlie <airlied@redhat.com>
119 lines
2.8 KiB
C
119 lines
2.8 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
#include "vkms_drv.h"
|
|
#include <drm/drm_atomic_helper.h>
|
|
#include <drm/drm_probe_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,
|
|
.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 const struct drm_encoder_funcs vkms_encoder_funcs = {
|
|
.destroy = drm_encoder_cleanup,
|
|
};
|
|
|
|
static int vkms_conn_get_modes(struct drm_connector *connector)
|
|
{
|
|
int count;
|
|
|
|
count = drm_add_modes_noedid(connector, XRES_MAX, YRES_MAX);
|
|
drm_set_preferred_mode(connector, XRES_DEF, YRES_DEF);
|
|
|
|
return count;
|
|
}
|
|
|
|
static const struct drm_connector_helper_funcs vkms_conn_helper_funcs = {
|
|
.get_modes = vkms_conn_get_modes,
|
|
};
|
|
|
|
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, *cursor = NULL;
|
|
int ret;
|
|
|
|
primary = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_PRIMARY);
|
|
if (IS_ERR(primary))
|
|
return PTR_ERR(primary);
|
|
|
|
if (enable_cursor) {
|
|
cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR);
|
|
if (IS_ERR(cursor)) {
|
|
ret = PTR_ERR(cursor);
|
|
goto err_cursor;
|
|
}
|
|
}
|
|
|
|
ret = vkms_crtc_init(dev, crtc, primary, cursor);
|
|
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;
|
|
}
|
|
|
|
drm_connector_helper_add(connector, &vkms_conn_helper_funcs);
|
|
|
|
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_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:
|
|
if (enable_cursor)
|
|
drm_plane_cleanup(cursor);
|
|
|
|
err_cursor:
|
|
drm_plane_cleanup(primary);
|
|
|
|
return ret;
|
|
}
|