|
|
@ -37,59 +37,43 @@ CDmaPusher::CDmaPusher(GPU& gpu_)
|
|
|
|
|
|
|
|
|
|
|
|
CDmaPusher::~CDmaPusher() = default;
|
|
|
|
CDmaPusher::~CDmaPusher() = default;
|
|
|
|
|
|
|
|
|
|
|
|
void CDmaPusher::Push(ChCommandHeaderList&& entries) {
|
|
|
|
void CDmaPusher::ProcessEntries(ChCommandHeaderList&& entries) {
|
|
|
|
cdma_queue.push(std::move(entries));
|
|
|
|
for (const auto& value : entries) {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CDmaPusher::DispatchCalls() {
|
|
|
|
|
|
|
|
while (!cdma_queue.empty()) {
|
|
|
|
|
|
|
|
Step();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CDmaPusher::Step() {
|
|
|
|
|
|
|
|
const auto entries{cdma_queue.front()};
|
|
|
|
|
|
|
|
cdma_queue.pop();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<u32> values(entries.size());
|
|
|
|
|
|
|
|
std::memcpy(values.data(), entries.data(), entries.size() * sizeof(u32));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (const u32 value : values) {
|
|
|
|
|
|
|
|
if (mask != 0) {
|
|
|
|
if (mask != 0) {
|
|
|
|
const auto lbs = static_cast<u32>(std::countr_zero(mask));
|
|
|
|
const auto lbs = static_cast<u32>(std::countr_zero(mask));
|
|
|
|
mask &= ~(1U << lbs);
|
|
|
|
mask &= ~(1U << lbs);
|
|
|
|
ExecuteCommand(static_cast<u32>(offset + lbs), value);
|
|
|
|
ExecuteCommand(offset + lbs, value.raw);
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
} else if (count != 0) {
|
|
|
|
} else if (count != 0) {
|
|
|
|
--count;
|
|
|
|
--count;
|
|
|
|
ExecuteCommand(static_cast<u32>(offset), value);
|
|
|
|
ExecuteCommand(offset, value.raw);
|
|
|
|
if (incrementing) {
|
|
|
|
if (incrementing) {
|
|
|
|
++offset;
|
|
|
|
++offset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const auto mode = static_cast<ChSubmissionMode>((value >> 28) & 0xf);
|
|
|
|
const auto mode = value.submission_mode.Value();
|
|
|
|
switch (mode) {
|
|
|
|
switch (mode) {
|
|
|
|
case ChSubmissionMode::SetClass: {
|
|
|
|
case ChSubmissionMode::SetClass: {
|
|
|
|
mask = value & 0x3f;
|
|
|
|
mask = value.value & 0x3f;
|
|
|
|
offset = (value >> 16) & 0xfff;
|
|
|
|
offset = value.method_offset;
|
|
|
|
current_class = static_cast<ChClassId>((value >> 6) & 0x3ff);
|
|
|
|
current_class = static_cast<ChClassId>((value.value >> 6) & 0x3ff);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case ChSubmissionMode::Incrementing:
|
|
|
|
case ChSubmissionMode::Incrementing:
|
|
|
|
case ChSubmissionMode::NonIncrementing:
|
|
|
|
case ChSubmissionMode::NonIncrementing:
|
|
|
|
count = value & 0xffff;
|
|
|
|
count = value.value;
|
|
|
|
offset = (value >> 16) & 0xfff;
|
|
|
|
offset = value.method_offset;
|
|
|
|
incrementing = mode == ChSubmissionMode::Incrementing;
|
|
|
|
incrementing = mode == ChSubmissionMode::Incrementing;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case ChSubmissionMode::Mask:
|
|
|
|
case ChSubmissionMode::Mask:
|
|
|
|
mask = value & 0xffff;
|
|
|
|
mask = value.value;
|
|
|
|
offset = (value >> 16) & 0xfff;
|
|
|
|
offset = value.method_offset;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case ChSubmissionMode::Immediate: {
|
|
|
|
case ChSubmissionMode::Immediate: {
|
|
|
|
const u32 data = value & 0xfff;
|
|
|
|
const u32 data = value.value & 0xfff;
|
|
|
|
offset = (value >> 16) & 0xfff;
|
|
|
|
offset = value.method_offset;
|
|
|
|
ExecuteCommand(static_cast<u32>(offset), data);
|
|
|
|
ExecuteCommand(offset, data);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
default:
|
|
|
@ -102,8 +86,8 @@ void CDmaPusher::Step() {
|
|
|
|
void CDmaPusher::ExecuteCommand(u32 state_offset, u32 data) {
|
|
|
|
void CDmaPusher::ExecuteCommand(u32 state_offset, u32 data) {
|
|
|
|
switch (current_class) {
|
|
|
|
switch (current_class) {
|
|
|
|
case ChClassId::NvDec:
|
|
|
|
case ChClassId::NvDec:
|
|
|
|
ThiStateWrite(nvdec_thi_state, state_offset, {data});
|
|
|
|
ThiStateWrite(nvdec_thi_state, offset, data);
|
|
|
|
switch (static_cast<ThiMethod>(state_offset)) {
|
|
|
|
switch (static_cast<ThiMethod>(offset)) {
|
|
|
|
case ThiMethod::IncSyncpt: {
|
|
|
|
case ThiMethod::IncSyncpt: {
|
|
|
|
LOG_DEBUG(Service_NVDRV, "NVDEC Class IncSyncpt Method");
|
|
|
|
LOG_DEBUG(Service_NVDRV, "NVDEC Class IncSyncpt Method");
|
|
|
|
const auto syncpoint_id = static_cast<u32>(data & 0xFF);
|
|
|
|
const auto syncpoint_id = static_cast<u32>(data & 0xFF);
|
|
|
@ -120,7 +104,7 @@ void CDmaPusher::ExecuteCommand(u32 state_offset, u32 data) {
|
|
|
|
LOG_DEBUG(Service_NVDRV, "NVDEC method 0x{:X}",
|
|
|
|
LOG_DEBUG(Service_NVDRV, "NVDEC method 0x{:X}",
|
|
|
|
static_cast<u32>(nvdec_thi_state.method_0));
|
|
|
|
static_cast<u32>(nvdec_thi_state.method_0));
|
|
|
|
nvdec_processor->ProcessMethod(static_cast<Nvdec::Method>(nvdec_thi_state.method_0),
|
|
|
|
nvdec_processor->ProcessMethod(static_cast<Nvdec::Method>(nvdec_thi_state.method_0),
|
|
|
|
{data});
|
|
|
|
data);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -144,7 +128,7 @@ void CDmaPusher::ExecuteCommand(u32 state_offset, u32 data) {
|
|
|
|
case ThiMethod::SetMethod1:
|
|
|
|
case ThiMethod::SetMethod1:
|
|
|
|
LOG_DEBUG(Service_NVDRV, "VIC method 0x{:X}, Args=({})",
|
|
|
|
LOG_DEBUG(Service_NVDRV, "VIC method 0x{:X}, Args=({})",
|
|
|
|
static_cast<u32>(vic_thi_state.method_0), data);
|
|
|
|
static_cast<u32>(vic_thi_state.method_0), data);
|
|
|
|
vic_processor->ProcessMethod(static_cast<Vic::Method>(vic_thi_state.method_0), {data});
|
|
|
|
vic_processor->ProcessMethod(static_cast<Vic::Method>(vic_thi_state.method_0), data);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -153,7 +137,7 @@ void CDmaPusher::ExecuteCommand(u32 state_offset, u32 data) {
|
|
|
|
case ChClassId::Host1x:
|
|
|
|
case ChClassId::Host1x:
|
|
|
|
// This device is mainly for syncpoint synchronization
|
|
|
|
// This device is mainly for syncpoint synchronization
|
|
|
|
LOG_DEBUG(Service_NVDRV, "Host1X Class Method");
|
|
|
|
LOG_DEBUG(Service_NVDRV, "Host1X Class Method");
|
|
|
|
host1x_processor->ProcessMethod(static_cast<Host1x::Method>(state_offset), {data});
|
|
|
|
host1x_processor->ProcessMethod(static_cast<Host1x::Method>(offset), data);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
UNIMPLEMENTED_MSG("Current class not implemented {:X}", static_cast<u32>(current_class));
|
|
|
|
UNIMPLEMENTED_MSG("Current class not implemented {:X}", static_cast<u32>(current_class));
|
|
|
@ -161,10 +145,9 @@ void CDmaPusher::ExecuteCommand(u32 state_offset, u32 data) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CDmaPusher::ThiStateWrite(ThiRegisters& state, u32 state_offset,
|
|
|
|
void CDmaPusher::ThiStateWrite(ThiRegisters& state, u32 state_offset, u32 argument) {
|
|
|
|
const std::vector<u32>& arguments) {
|
|
|
|
u8* const offset_ptr = reinterpret_cast<u8*>(&state) + sizeof(u32) * state_offset;
|
|
|
|
u8* const state_offset_ptr = reinterpret_cast<u8*>(&state) + sizeof(u32) * state_offset;
|
|
|
|
std::memcpy(offset_ptr, &argument, sizeof(u32));
|
|
|
|
std::memcpy(state_offset_ptr, arguments.data(), sizeof(u32) * arguments.size());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace Tegra
|
|
|
|
} // namespace Tegra
|
|
|
|