hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/drivers/gpu/drm/vkms/vkms_output.c
....@@ -1,12 +1,12 @@
11 // SPDX-License-Identifier: GPL-2.0+
22
33 #include "vkms_drv.h"
4
-#include <drm/drm_crtc_helper.h>
54 #include <drm/drm_atomic_helper.h>
5
+#include <drm/drm_probe_helper.h>
6
+#include <drm/drm_simple_kms_helper.h>
67
78 static void vkms_connector_destroy(struct drm_connector *connector)
89 {
9
- drm_connector_unregister(connector);
1010 drm_connector_cleanup(connector);
1111 }
1212
....@@ -16,10 +16,6 @@
1616 .reset = drm_atomic_helper_connector_reset,
1717 .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
1818 .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
19
-};
20
-
21
-static const struct drm_encoder_funcs vkms_encoder_funcs = {
22
- .destroy = drm_encoder_cleanup,
2319 };
2420
2521 static int vkms_conn_get_modes(struct drm_connector *connector)
....@@ -36,21 +32,29 @@
3632 .get_modes = vkms_conn_get_modes,
3733 };
3834
39
-int vkms_output_init(struct vkms_device *vkmsdev)
35
+int vkms_output_init(struct vkms_device *vkmsdev, int index)
4036 {
4137 struct vkms_output *output = &vkmsdev->output;
4238 struct drm_device *dev = &vkmsdev->drm;
4339 struct drm_connector *connector = &output->connector;
4440 struct drm_encoder *encoder = &output->encoder;
4541 struct drm_crtc *crtc = &output->crtc;
46
- struct drm_plane *primary;
42
+ struct drm_plane *primary, *cursor = NULL;
4743 int ret;
4844
49
- primary = vkms_plane_init(vkmsdev);
45
+ primary = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_PRIMARY, index);
5046 if (IS_ERR(primary))
5147 return PTR_ERR(primary);
5248
53
- ret = vkms_crtc_init(dev, crtc, primary, NULL);
49
+ if (enable_cursor) {
50
+ cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR, index);
51
+ if (IS_ERR(cursor)) {
52
+ ret = PTR_ERR(cursor);
53
+ goto err_cursor;
54
+ }
55
+ }
56
+
57
+ ret = vkms_crtc_init(dev, crtc, primary, cursor);
5458 if (ret)
5559 goto err_crtc;
5660
....@@ -63,14 +67,7 @@
6367
6468 drm_connector_helper_add(connector, &vkms_conn_helper_funcs);
6569
66
- ret = drm_connector_register(connector);
67
- if (ret) {
68
- DRM_ERROR("Failed to register connector\n");
69
- goto err_connector_register;
70
- }
71
-
72
- ret = drm_encoder_init(dev, encoder, &vkms_encoder_funcs,
73
- DRM_MODE_ENCODER_VIRTUAL, NULL);
70
+ ret = drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_VIRTUAL);
7471 if (ret) {
7572 DRM_ERROR("Failed to init encoder\n");
7673 goto err_encoder;
....@@ -83,6 +80,10 @@
8380 goto err_attach;
8481 }
8582
83
+ ret = vkms_enable_writeback_connector(vkmsdev);
84
+ if (ret)
85
+ DRM_ERROR("Failed to init writeback connector\n");
86
+
8687 drm_mode_config_reset(dev);
8788
8889 return 0;
....@@ -91,15 +92,17 @@
9192 drm_encoder_cleanup(encoder);
9293
9394 err_encoder:
94
- drm_connector_unregister(connector);
95
-
96
-err_connector_register:
9795 drm_connector_cleanup(connector);
9896
9997 err_connector:
10098 drm_crtc_cleanup(crtc);
10199
102100 err_crtc:
101
+ if (enable_cursor)
102
+ drm_plane_cleanup(cursor);
103
+
104
+err_cursor:
103105 drm_plane_cleanup(primary);
106
+
104107 return ret;
105108 }