mirror of
https://github.com/torvalds/linux.git
synced 2026-05-24 07:03:03 +02:00
drm/vkms: Extract vkms_connector header
Up until now, the logic to manage connectors was in vkms_output.c. Since more options will be added to connectors in the future, extract the code to its own file. Refactor, no functional changes. Reviewed-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-2-jose.exposito89@gmail.com Signed-off-by: Maxime Ripard <mripard@kernel.org>
This commit is contained in:
parent
2d4d775d11
commit
6fdbc11502
|
|
@ -6,6 +6,7 @@ vkms-y := \
|
|||
vkms_formats.o \
|
||||
vkms_crtc.o \
|
||||
vkms_composer.o \
|
||||
vkms_writeback.o
|
||||
vkms_writeback.o \
|
||||
vkms_connector.o
|
||||
|
||||
obj-$(CONFIG_DRM_VKMS) += vkms.o
|
||||
|
|
|
|||
50
drivers/gpu/drm/vkms/vkms_connector.c
Normal file
50
drivers/gpu/drm/vkms/vkms_connector.c
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#include <drm/drm_atomic_helper.h>
|
||||
#include <drm/drm_edid.h>
|
||||
#include <drm/drm_managed.h>
|
||||
#include <drm/drm_probe_helper.h>
|
||||
|
||||
#include "vkms_connector.h"
|
||||
|
||||
static const struct drm_connector_funcs vkms_connector_funcs = {
|
||||
.fill_modes = drm_helper_probe_single_connector_modes,
|
||||
.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;
|
||||
|
||||
/* Use the default modes list from DRM */
|
||||
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,
|
||||
};
|
||||
|
||||
struct drm_connector *vkms_connector_init(struct vkms_device *vkmsdev)
|
||||
{
|
||||
struct drm_device *dev = &vkmsdev->drm;
|
||||
struct drm_connector *connector;
|
||||
int ret;
|
||||
|
||||
connector = drmm_kzalloc(dev, sizeof(*connector), GFP_KERNEL);
|
||||
if (!connector)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
ret = drmm_connector_init(dev, connector, &vkms_connector_funcs,
|
||||
DRM_MODE_CONNECTOR_VIRTUAL, NULL);
|
||||
if (ret)
|
||||
return ERR_PTR(ret);
|
||||
|
||||
drm_connector_helper_add(connector, &vkms_conn_helper_funcs);
|
||||
|
||||
return connector;
|
||||
}
|
||||
17
drivers/gpu/drm/vkms/vkms_connector.h
Normal file
17
drivers/gpu/drm/vkms/vkms_connector.h
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
|
||||
#ifndef _VKMS_CONNECTOR_H_
|
||||
#define _VKMS_CONNECTOR_H_
|
||||
|
||||
#include "vkms_drv.h"
|
||||
|
||||
/**
|
||||
* vkms_connector_init() - Initialize a connector
|
||||
* @vkmsdev: VKMS device containing the connector
|
||||
*
|
||||
* Returns:
|
||||
* The connector or an error on failure.
|
||||
*/
|
||||
struct drm_connector *vkms_connector_init(struct vkms_device *vkmsdev);
|
||||
|
||||
#endif /* _VKMS_CONNECTOR_H_ */
|
||||
|
|
@ -1,32 +1,8 @@
|
|||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#include "vkms_connector.h"
|
||||
#include "vkms_drv.h"
|
||||
#include <drm/drm_atomic_helper.h>
|
||||
#include <drm/drm_edid.h>
|
||||
#include <drm/drm_managed.h>
|
||||
#include <drm/drm_probe_helper.h>
|
||||
|
||||
static const struct drm_connector_funcs vkms_connector_funcs = {
|
||||
.fill_modes = drm_helper_probe_single_connector_modes,
|
||||
.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;
|
||||
|
||||
/* Use the default modes list from DRM */
|
||||
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)
|
||||
{
|
||||
|
|
@ -73,21 +49,12 @@ int vkms_output_init(struct vkms_device *vkmsdev)
|
|||
}
|
||||
}
|
||||
|
||||
connector = drmm_kzalloc(dev, sizeof(*connector), GFP_KERNEL);
|
||||
if (!connector) {
|
||||
DRM_ERROR("Failed to allocate connector\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
ret = drmm_connector_init(dev, connector, &vkms_connector_funcs,
|
||||
DRM_MODE_CONNECTOR_VIRTUAL, NULL);
|
||||
if (ret) {
|
||||
connector = vkms_connector_init(vkmsdev);
|
||||
if (IS_ERR(connector)) {
|
||||
DRM_ERROR("Failed to init connector\n");
|
||||
return ret;
|
||||
return PTR_ERR(connector);
|
||||
}
|
||||
|
||||
drm_connector_helper_add(connector, &vkms_conn_helper_funcs);
|
||||
|
||||
encoder = drmm_kzalloc(dev, sizeof(*encoder), GFP_KERNEL);
|
||||
if (!encoder) {
|
||||
DRM_ERROR("Failed to allocate encoder\n");
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user