1 // Copyright (C) 2023 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "stream-servers/magma/IntelDrmDecoder.h"
16
17 #include "RenderThreadInfoMagma.h"
18
19 #include <sys/ioctl.h>
20 #include <unistd.h>
21
22 namespace gfxstream {
23 namespace magma {
24
Create()25 std::unique_ptr<IntelDrmDecoder> IntelDrmDecoder::Create() {
26 std::unique_ptr<IntelDrmDecoder> decoder(new IntelDrmDecoder());
27 return decoder;
28 }
29
30 #define MAGMA_DECODER_BIND_METHOD(method) \
31 magma_server_context_t::method = [](auto ...args) { \
32 auto decoder = RenderThreadInfoMagma::get()->m_magmaDec.get(); \
33 return static_cast<IntelDrmDecoder*>(decoder)->method(args...); \
34 }
35
IntelDrmDecoder()36 IntelDrmDecoder::IntelDrmDecoder() : Decoder() {
37 MAGMA_DECODER_BIND_METHOD(magma_device_import);
38 MAGMA_DECODER_BIND_METHOD(magma_device_release);
39 MAGMA_DECODER_BIND_METHOD(magma_device_query);
40 MAGMA_DECODER_BIND_METHOD(magma_device_create_connection);
41 MAGMA_DECODER_BIND_METHOD(magma_connection_release);
42 MAGMA_DECODER_BIND_METHOD(magma_connection_create_buffer);
43 MAGMA_DECODER_BIND_METHOD(magma_connection_release_buffer);
44 MAGMA_DECODER_BIND_METHOD(magma_connection_create_semaphore);
45 MAGMA_DECODER_BIND_METHOD(magma_connection_release_semaphore);
46 MAGMA_DECODER_BIND_METHOD(magma_buffer_export);
47 MAGMA_DECODER_BIND_METHOD(magma_semaphore_signal);
48 MAGMA_DECODER_BIND_METHOD(magma_semaphore_reset);
49 MAGMA_DECODER_BIND_METHOD(magma_poll);
50 MAGMA_DECODER_BIND_METHOD(magma_connection_get_error);
51 MAGMA_DECODER_BIND_METHOD(magma_connection_create_context);
52 MAGMA_DECODER_BIND_METHOD(magma_connection_release_context);
53 MAGMA_DECODER_BIND_METHOD(magma_connection_map_buffer);
54 MAGMA_DECODER_BIND_METHOD(magma_connection_unmap_buffer);
55 }
56
magma_device_import(magma_handle_t device_channel,magma_device_t * device_out)57 magma_status_t IntelDrmDecoder::magma_device_import(
58 magma_handle_t device_channel,
59 magma_device_t* device_out) {
60 return MAGMA_STATUS_UNIMPLEMENTED;
61 }
62
magma_device_release(magma_device_t device)63 void IntelDrmDecoder::magma_device_release(
64 magma_device_t device) {
65 }
66
magma_device_query(magma_device_t device,uint64_t id,magma_handle_t * result_buffer_out,uint64_t * result_out)67 magma_status_t IntelDrmDecoder::magma_device_query(
68 magma_device_t device,
69 uint64_t id,
70 magma_handle_t* result_buffer_out,
71 uint64_t* result_out) {
72 *result_buffer_out = MAGMA_INVALID_OBJECT_ID;
73 *result_out = 0;
74 return MAGMA_STATUS_UNIMPLEMENTED;
75 }
76
magma_device_create_connection(magma_device_t device,magma_connection_t * connection_out)77 magma_status_t IntelDrmDecoder::magma_device_create_connection(
78 magma_device_t device,
79 magma_connection_t* connection_out) {
80 *connection_out = MAGMA_INVALID_OBJECT_ID;
81 return MAGMA_STATUS_UNIMPLEMENTED;
82 }
83
magma_connection_release(magma_connection_t connection)84 void IntelDrmDecoder::magma_connection_release(
85 magma_connection_t connection) {
86 }
87
magma_connection_create_buffer(magma_connection_t connection,uint64_t size,uint64_t * size_out,magma_buffer_t * buffer_out,magma_buffer_id_t * id_out)88 magma_status_t IntelDrmDecoder::magma_connection_create_buffer(
89 magma_connection_t connection,
90 uint64_t size,
91 uint64_t* size_out,
92 magma_buffer_t* buffer_out,
93 magma_buffer_id_t* id_out) {
94 *size_out = 0;
95 *buffer_out = MAGMA_INVALID_OBJECT_ID;
96 *id_out = MAGMA_INVALID_OBJECT_ID;
97 return MAGMA_STATUS_UNIMPLEMENTED;
98 }
99
magma_connection_release_buffer(magma_connection_t connection,magma_buffer_t buffer)100 void IntelDrmDecoder::magma_connection_release_buffer(
101 magma_connection_t connection,
102 magma_buffer_t buffer) {
103 }
104
magma_connection_create_semaphore(magma_connection_t magma_connection,magma_semaphore_t * semaphore_out,magma_semaphore_id_t * id_out)105 magma_status_t IntelDrmDecoder::magma_connection_create_semaphore(
106 magma_connection_t magma_connection,
107 magma_semaphore_t* semaphore_out,
108 magma_semaphore_id_t* id_out) {
109 *semaphore_out = MAGMA_INVALID_OBJECT_ID;
110 *id_out = MAGMA_INVALID_OBJECT_ID;
111 return MAGMA_STATUS_UNIMPLEMENTED;
112 }
113
magma_connection_release_semaphore(magma_connection_t connection,magma_semaphore_t semaphore)114 void IntelDrmDecoder::magma_connection_release_semaphore(
115 magma_connection_t connection,
116 magma_semaphore_t semaphore) {
117 }
118
magma_buffer_export(magma_buffer_t buffer,magma_handle_t * buffer_handle_out)119 magma_status_t IntelDrmDecoder::magma_buffer_export(
120 magma_buffer_t buffer,
121 magma_handle_t* buffer_handle_out) {
122 *buffer_handle_out = MAGMA_INVALID_OBJECT_ID;
123 return MAGMA_STATUS_UNIMPLEMENTED;
124 }
125
magma_semaphore_signal(magma_semaphore_t semaphore)126 void IntelDrmDecoder::magma_semaphore_signal(
127 magma_semaphore_t semaphore) {
128 }
129
magma_semaphore_reset(magma_semaphore_t semaphore)130 void IntelDrmDecoder::magma_semaphore_reset(
131 magma_semaphore_t semaphore) {
132 }
133
magma_poll(magma_poll_item_t * items,uint32_t count,uint64_t timeout_ns)134 magma_status_t IntelDrmDecoder::magma_poll(
135 magma_poll_item_t* items,
136 uint32_t count,
137 uint64_t timeout_ns) {
138 return MAGMA_STATUS_UNIMPLEMENTED;
139 }
140
magma_connection_get_error(magma_connection_t connection)141 magma_status_t IntelDrmDecoder::magma_connection_get_error(
142 magma_connection_t connection) {
143 return MAGMA_STATUS_UNIMPLEMENTED;
144 }
145
magma_connection_create_context(magma_connection_t connection,uint32_t * context_id_out)146 magma_status_t IntelDrmDecoder::magma_connection_create_context(
147 magma_connection_t connection,
148 uint32_t* context_id_out) {
149 *context_id_out = MAGMA_INVALID_OBJECT_ID;
150 return MAGMA_STATUS_UNIMPLEMENTED;
151 }
152
magma_connection_release_context(magma_connection_t connection,uint32_t context_id)153 void IntelDrmDecoder::magma_connection_release_context(
154 magma_connection_t connection,
155 uint32_t context_id) {
156 }
157
magma_connection_map_buffer(magma_connection_t connection,uint64_t hw_va,magma_buffer_t buffer,uint64_t offset,uint64_t length,uint64_t map_flags)158 magma_status_t IntelDrmDecoder::magma_connection_map_buffer(
159 magma_connection_t connection,
160 uint64_t hw_va,
161 magma_buffer_t buffer,
162 uint64_t offset,
163 uint64_t length,
164 uint64_t map_flags) {
165 return MAGMA_STATUS_UNIMPLEMENTED;
166 }
167
magma_connection_unmap_buffer(magma_connection_t connection,uint64_t hw_va,magma_buffer_t buffer)168 void IntelDrmDecoder::magma_connection_unmap_buffer(
169 magma_connection_t connection,
170 uint64_t hw_va,
171 magma_buffer_t buffer) {
172 }
173
174 } // namespace magma
175 } // namespace gfxstream
176