.. | .. |
---|
1 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
---|
2 | 2 | |
---|
3 | 3 | #include "vkms_drv.h" |
---|
4 | | -#include <drm/drm_crtc_helper.h> |
---|
5 | 4 | #include <drm/drm_atomic_helper.h> |
---|
| 5 | +#include <drm/drm_probe_helper.h> |
---|
| 6 | +#include <drm/drm_simple_kms_helper.h> |
---|
6 | 7 | |
---|
7 | 8 | static void vkms_connector_destroy(struct drm_connector *connector) |
---|
8 | 9 | { |
---|
9 | | - drm_connector_unregister(connector); |
---|
10 | 10 | drm_connector_cleanup(connector); |
---|
11 | 11 | } |
---|
12 | 12 | |
---|
.. | .. |
---|
16 | 16 | .reset = drm_atomic_helper_connector_reset, |
---|
17 | 17 | .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, |
---|
18 | 18 | .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, |
---|
23 | 19 | }; |
---|
24 | 20 | |
---|
25 | 21 | static int vkms_conn_get_modes(struct drm_connector *connector) |
---|
.. | .. |
---|
36 | 32 | .get_modes = vkms_conn_get_modes, |
---|
37 | 33 | }; |
---|
38 | 34 | |
---|
39 | | -int vkms_output_init(struct vkms_device *vkmsdev) |
---|
| 35 | +int vkms_output_init(struct vkms_device *vkmsdev, int index) |
---|
40 | 36 | { |
---|
41 | 37 | struct vkms_output *output = &vkmsdev->output; |
---|
42 | 38 | struct drm_device *dev = &vkmsdev->drm; |
---|
43 | 39 | struct drm_connector *connector = &output->connector; |
---|
44 | 40 | struct drm_encoder *encoder = &output->encoder; |
---|
45 | 41 | struct drm_crtc *crtc = &output->crtc; |
---|
46 | | - struct drm_plane *primary; |
---|
| 42 | + struct drm_plane *primary, *cursor = NULL; |
---|
47 | 43 | int ret; |
---|
48 | 44 | |
---|
49 | | - primary = vkms_plane_init(vkmsdev); |
---|
| 45 | + primary = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_PRIMARY, index); |
---|
50 | 46 | if (IS_ERR(primary)) |
---|
51 | 47 | return PTR_ERR(primary); |
---|
52 | 48 | |
---|
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); |
---|
54 | 58 | if (ret) |
---|
55 | 59 | goto err_crtc; |
---|
56 | 60 | |
---|
.. | .. |
---|
63 | 67 | |
---|
64 | 68 | drm_connector_helper_add(connector, &vkms_conn_helper_funcs); |
---|
65 | 69 | |
---|
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); |
---|
74 | 71 | if (ret) { |
---|
75 | 72 | DRM_ERROR("Failed to init encoder\n"); |
---|
76 | 73 | goto err_encoder; |
---|
.. | .. |
---|
83 | 80 | goto err_attach; |
---|
84 | 81 | } |
---|
85 | 82 | |
---|
| 83 | + ret = vkms_enable_writeback_connector(vkmsdev); |
---|
| 84 | + if (ret) |
---|
| 85 | + DRM_ERROR("Failed to init writeback connector\n"); |
---|
| 86 | + |
---|
86 | 87 | drm_mode_config_reset(dev); |
---|
87 | 88 | |
---|
88 | 89 | return 0; |
---|
.. | .. |
---|
91 | 92 | drm_encoder_cleanup(encoder); |
---|
92 | 93 | |
---|
93 | 94 | err_encoder: |
---|
94 | | - drm_connector_unregister(connector); |
---|
95 | | - |
---|
96 | | -err_connector_register: |
---|
97 | 95 | drm_connector_cleanup(connector); |
---|
98 | 96 | |
---|
99 | 97 | err_connector: |
---|
100 | 98 | drm_crtc_cleanup(crtc); |
---|
101 | 99 | |
---|
102 | 100 | err_crtc: |
---|
| 101 | + if (enable_cursor) |
---|
| 102 | + drm_plane_cleanup(cursor); |
---|
| 103 | + |
---|
| 104 | +err_cursor: |
---|
103 | 105 | drm_plane_cleanup(primary); |
---|
| 106 | + |
---|
104 | 107 | return ret; |
---|
105 | 108 | } |
---|