mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-30 12:49:36 +00:00
![Ville Syrjälä](/assets/img/avatar_default.png)
drm_crtc.h has no need for drm_edid.h, so don't include it. Avoids useless rebuilds of the entire universe when touching drm_edid.h. Quite a few placs do currently depend on drm_edid.h without actually including it directly. All of those need to be fixed up. v2: Fix up i915 and msm some more v3: Fix alphabetical ordering (Sam) Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20220614090245.30283-1-ville.syrjala@linux.intel.com Acked-by: Sam Ravnborg <sam@ravnborg.org> Acked-by: Jani Nikula <jani.nikula@intel.com>
127 lines
3.1 KiB
C
127 lines
3.1 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
#include "vkms_drv.h"
|
|
#include <drm/drm_atomic_helper.h>
|
|
#include <drm/drm_edid.h>
|
|
#include <drm/drm_probe_helper.h>
|
|
#include <drm/drm_simple_kms_helper.h>
|
|
|
|
static void vkms_connector_destroy(struct drm_connector *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 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,
|
|
};
|
|
|
|
static int vkms_add_overlay_plane(struct vkms_device *vkmsdev, int index,
|
|
struct drm_crtc *crtc)
|
|
{
|
|
struct vkms_plane *overlay;
|
|
|
|
overlay = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_OVERLAY, index);
|
|
if (IS_ERR(overlay))
|
|
return PTR_ERR(overlay);
|
|
|
|
if (!overlay->base.possible_crtcs)
|
|
overlay->base.possible_crtcs = drm_crtc_mask(crtc);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int vkms_output_init(struct vkms_device *vkmsdev, int index)
|
|
{
|
|
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 vkms_plane *primary, *cursor = NULL;
|
|
int ret;
|
|
int writeback;
|
|
unsigned int n;
|
|
|
|
primary = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_PRIMARY, index);
|
|
if (IS_ERR(primary))
|
|
return PTR_ERR(primary);
|
|
|
|
if (vkmsdev->config->overlay) {
|
|
for (n = 0; n < NUM_OVERLAY_PLANES; n++) {
|
|
ret = vkms_add_overlay_plane(vkmsdev, index, crtc);
|
|
if (ret)
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
if (vkmsdev->config->cursor) {
|
|
cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR, index);
|
|
if (IS_ERR(cursor))
|
|
return PTR_ERR(cursor);
|
|
}
|
|
|
|
ret = vkms_crtc_init(dev, crtc, &primary->base, &cursor->base);
|
|
if (ret)
|
|
return ret;
|
|
|
|
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_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_VIRTUAL);
|
|
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;
|
|
}
|
|
|
|
if (vkmsdev->config->writeback) {
|
|
writeback = vkms_enable_writeback_connector(vkmsdev);
|
|
if (writeback)
|
|
DRM_ERROR("Failed to init writeback connector\n");
|
|
}
|
|
|
|
drm_mode_config_reset(dev);
|
|
|
|
return 0;
|
|
|
|
err_attach:
|
|
drm_encoder_cleanup(encoder);
|
|
|
|
err_encoder:
|
|
drm_connector_cleanup(connector);
|
|
|
|
err_connector:
|
|
drm_crtc_cleanup(crtc);
|
|
|
|
return ret;
|
|
}
|