vi: Use ReadBuffer/WriteBuffer functions for TransactParcel.
This commit is contained in:
parent
fc1b425520
commit
8f84665775
@ -453,85 +453,60 @@ private:
|
||||
SetPreallocatedBuffer = 14
|
||||
};
|
||||
|
||||
void TransactParcel(u32 id, TransactionId transaction, const std::vector<u8>& input_data,
|
||||
VAddr output_addr, u64 output_size) {
|
||||
auto buffer_queue = nv_flinger->GetBufferQueue(id);
|
||||
|
||||
if (transaction == TransactionId::Connect) {
|
||||
IGBPConnectRequestParcel request{input_data};
|
||||
IGBPConnectResponseParcel response{1280, 720};
|
||||
std::vector<u8> response_buffer = response.Serialize();
|
||||
Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size());
|
||||
} else if (transaction == TransactionId::SetPreallocatedBuffer) {
|
||||
IGBPSetPreallocatedBufferRequestParcel request{input_data};
|
||||
|
||||
buffer_queue->SetPreallocatedBuffer(request.data.slot, request.buffer);
|
||||
|
||||
IGBPSetPreallocatedBufferResponseParcel response{};
|
||||
std::vector<u8> response_buffer = response.Serialize();
|
||||
Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size());
|
||||
} else if (transaction == TransactionId::DequeueBuffer) {
|
||||
IGBPDequeueBufferRequestParcel request{input_data};
|
||||
|
||||
u32 slot = buffer_queue->DequeueBuffer(request.data.pixel_format, request.data.width,
|
||||
request.data.height);
|
||||
|
||||
IGBPDequeueBufferResponseParcel response{slot};
|
||||
std::vector<u8> response_buffer = response.Serialize();
|
||||
Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size());
|
||||
} else if (transaction == TransactionId::RequestBuffer) {
|
||||
IGBPRequestBufferRequestParcel request{input_data};
|
||||
|
||||
auto& buffer = buffer_queue->RequestBuffer(request.slot);
|
||||
|
||||
IGBPRequestBufferResponseParcel response{buffer};
|
||||
std::vector<u8> response_buffer = response.Serialize();
|
||||
Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size());
|
||||
} else if (transaction == TransactionId::QueueBuffer) {
|
||||
IGBPQueueBufferRequestParcel request{input_data};
|
||||
|
||||
buffer_queue->QueueBuffer(request.data.slot, request.data.transform);
|
||||
|
||||
IGBPQueueBufferResponseParcel response{1280, 720};
|
||||
std::vector<u8> response_buffer = response.Serialize();
|
||||
Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size());
|
||||
} else if (transaction == TransactionId::Query) {
|
||||
IGBPQueryRequestParcel request{input_data};
|
||||
|
||||
u32 value =
|
||||
buffer_queue->Query(static_cast<NVFlinger::BufferQueue::QueryType>(request.type));
|
||||
|
||||
IGBPQueryResponseParcel response{value};
|
||||
std::vector<u8> response_buffer = response.Serialize();
|
||||
Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size());
|
||||
} else if (transaction == TransactionId::CancelBuffer) {
|
||||
LOG_WARNING(Service_VI, "(STUBBED) called, transaction=CancelBuffer");
|
||||
} else {
|
||||
ASSERT_MSG(false, "Unimplemented");
|
||||
}
|
||||
}
|
||||
|
||||
void TransactParcel(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
u32 id = rp.Pop<u32>();
|
||||
auto transaction = static_cast<TransactionId>(rp.Pop<u32>());
|
||||
u32 flags = rp.Pop<u32>();
|
||||
auto buffer_queue = nv_flinger->GetBufferQueue(id);
|
||||
|
||||
LOG_DEBUG(Service_VI, "called, transaction=%x", transaction);
|
||||
|
||||
if (ctx.BufferDescriptorA()[0].Size() != 0) {
|
||||
auto& input_buffer = ctx.BufferDescriptorA()[0];
|
||||
auto& output_buffer = ctx.BufferDescriptorB()[0];
|
||||
std::vector<u8> input_data(input_buffer.Size());
|
||||
Memory::ReadBlock(input_buffer.Address(), input_data.data(), input_buffer.Size());
|
||||
TransactParcel(id, transaction, input_data, output_buffer.Address(),
|
||||
output_buffer.Size());
|
||||
if (transaction == TransactionId::Connect) {
|
||||
IGBPConnectRequestParcel request{ctx.ReadBuffer()};
|
||||
IGBPConnectResponseParcel response{1280, 720};
|
||||
ctx.WriteBuffer(response.Serialize());
|
||||
} else if (transaction == TransactionId::SetPreallocatedBuffer) {
|
||||
IGBPSetPreallocatedBufferRequestParcel request{ctx.ReadBuffer()};
|
||||
|
||||
buffer_queue->SetPreallocatedBuffer(request.data.slot, request.buffer);
|
||||
|
||||
IGBPSetPreallocatedBufferResponseParcel response{};
|
||||
ctx.WriteBuffer(response.Serialize());
|
||||
} else if (transaction == TransactionId::DequeueBuffer) {
|
||||
IGBPDequeueBufferRequestParcel request{ctx.ReadBuffer()};
|
||||
|
||||
u32 slot = buffer_queue->DequeueBuffer(request.data.pixel_format, request.data.width,
|
||||
request.data.height);
|
||||
|
||||
IGBPDequeueBufferResponseParcel response{slot};
|
||||
ctx.WriteBuffer(response.Serialize());
|
||||
} else if (transaction == TransactionId::RequestBuffer) {
|
||||
IGBPRequestBufferRequestParcel request{ctx.ReadBuffer()};
|
||||
|
||||
auto& buffer = buffer_queue->RequestBuffer(request.slot);
|
||||
|
||||
IGBPRequestBufferResponseParcel response{buffer};
|
||||
ctx.WriteBuffer(response.Serialize());
|
||||
} else if (transaction == TransactionId::QueueBuffer) {
|
||||
IGBPQueueBufferRequestParcel request{ctx.ReadBuffer()};
|
||||
|
||||
buffer_queue->QueueBuffer(request.data.slot, request.data.transform);
|
||||
|
||||
IGBPQueueBufferResponseParcel response{1280, 720};
|
||||
ctx.WriteBuffer(response.Serialize());
|
||||
} else if (transaction == TransactionId::Query) {
|
||||
IGBPQueryRequestParcel request{ctx.ReadBuffer()};
|
||||
|
||||
u32 value =
|
||||
buffer_queue->Query(static_cast<NVFlinger::BufferQueue::QueryType>(request.type));
|
||||
|
||||
IGBPQueryResponseParcel response{value};
|
||||
ctx.WriteBuffer(response.Serialize());
|
||||
} else if (transaction == TransactionId::CancelBuffer) {
|
||||
LOG_WARNING(Service_VI, "(STUBBED) called, transaction=CancelBuffer");
|
||||
} else {
|
||||
auto& input_buffer = ctx.BufferDescriptorX()[0];
|
||||
auto& output_buffer = ctx.BufferDescriptorC()[0];
|
||||
std::vector<u8> input_data(input_buffer.size);
|
||||
Memory::ReadBlock(input_buffer.Address(), input_data.data(), input_buffer.size);
|
||||
TransactParcel(id, transaction, input_data, output_buffer.Address(),
|
||||
output_buffer.Size());
|
||||
ASSERT_MSG(false, "Unimplemented");
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
|
Loading…
Reference in New Issue
Block a user