File indexing completed on 2024-11-10 04:57:26
0001 /* 0002 SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #include "drmclientbuffer.h" 0008 #include "display.h" 0009 #include "utils/common.h" 0010 0011 #include "qwayland-server-drm.h" 0012 0013 namespace KWin 0014 { 0015 0016 static constexpr int s_version = 2; 0017 0018 class DrmClientBufferIntegrationPrivate : public QtWaylandServer::wl_drm 0019 { 0020 public: 0021 explicit DrmClientBufferIntegrationPrivate(Display *display); 0022 0023 QString nodeName; 0024 0025 protected: 0026 void drm_bind_resource(Resource *resource) override; 0027 void drm_authenticate(Resource *resource, uint32_t id) override; 0028 void drm_create_buffer(Resource *resource, 0029 uint32_t id, 0030 uint32_t name, 0031 int32_t width, 0032 int32_t height, 0033 uint32_t stride, 0034 uint32_t format) override; 0035 void drm_create_planar_buffer(Resource *resource, 0036 uint32_t id, 0037 uint32_t name, 0038 int32_t width, 0039 int32_t height, 0040 uint32_t format, 0041 int32_t offset0, 0042 int32_t stride0, 0043 int32_t offset1, 0044 int32_t stride1, 0045 int32_t offset2, 0046 int32_t stride2) override; 0047 void drm_create_prime_buffer(Resource *resource, 0048 uint32_t id, 0049 int32_t name, 0050 int32_t width, 0051 int32_t height, 0052 uint32_t format, 0053 int32_t offset0, 0054 int32_t stride0, 0055 int32_t offset1, 0056 int32_t stride1, 0057 int32_t offset2, 0058 int32_t stride2) override; 0059 }; 0060 0061 DrmClientBufferIntegrationPrivate::DrmClientBufferIntegrationPrivate(Display *display) 0062 : QtWaylandServer::wl_drm(*display, s_version) 0063 { 0064 } 0065 0066 void DrmClientBufferIntegrationPrivate::drm_bind_resource(Resource *resource) 0067 { 0068 send_device(resource->handle, nodeName); 0069 send_capabilities(resource->handle, capability_prime); 0070 } 0071 0072 void DrmClientBufferIntegrationPrivate::drm_authenticate(Resource *resource, uint32_t id) 0073 { 0074 send_authenticated(resource->handle); 0075 } 0076 0077 void DrmClientBufferIntegrationPrivate::drm_create_buffer(Resource *resource, 0078 uint32_t id, 0079 uint32_t name, 0080 int32_t width, 0081 int32_t height, 0082 uint32_t stride, 0083 uint32_t format) 0084 { 0085 wl_resource_post_error(resource->handle, 0, "wl_drm.create_buffer is not implemented"); 0086 } 0087 0088 void DrmClientBufferIntegrationPrivate::drm_create_planar_buffer(Resource *resource, 0089 uint32_t id, 0090 uint32_t name, 0091 int32_t width, 0092 int32_t height, 0093 uint32_t format, 0094 int32_t offset0, 0095 int32_t stride0, 0096 int32_t offset1, 0097 int32_t stride1, 0098 int32_t offset2, 0099 int32_t stride2) 0100 { 0101 wl_resource_post_error(resource->handle, 0, "wl_drm.create_planar_buffer is not implemented"); 0102 } 0103 0104 void DrmClientBufferIntegrationPrivate::drm_create_prime_buffer(Resource *resource, 0105 uint32_t id, 0106 int32_t name, 0107 int32_t width, 0108 int32_t height, 0109 uint32_t format, 0110 int32_t offset0, 0111 int32_t stride0, 0112 int32_t offset1, 0113 int32_t stride1, 0114 int32_t offset2, 0115 int32_t stride2) 0116 { 0117 close(name); 0118 wl_resource_post_error(resource->handle, 0, "wl_drm.create_prime_buffer is not implemented"); 0119 } 0120 0121 DrmClientBufferIntegration::DrmClientBufferIntegration(Display *display) 0122 : QObject(display) 0123 , d(std::make_unique<DrmClientBufferIntegrationPrivate>(display)) 0124 { 0125 } 0126 0127 DrmClientBufferIntegration::~DrmClientBufferIntegration() 0128 { 0129 } 0130 0131 void DrmClientBufferIntegration::setDevice(const QString &node) 0132 { 0133 d->nodeName = node; 0134 } 0135 0136 } // namespace KWin 0137 0138 #include "moc_drmclientbuffer.cpp"