early-access version 4106
This commit is contained in:
@@ -775,6 +775,9 @@ add_library(core STATIC
|
||||
hle/service/nvnflinger/graphic_buffer_producer.h
|
||||
hle/service/nvnflinger/hos_binder_driver_server.cpp
|
||||
hle/service/nvnflinger/hos_binder_driver_server.h
|
||||
hle/service/nvnflinger/hardware_composer.cpp
|
||||
hle/service/nvnflinger/hardware_composer.h
|
||||
hle/service/nvnflinger/hwc_layer.h
|
||||
hle/service/nvnflinger/nvnflinger.cpp
|
||||
hle/service/nvnflinger/nvnflinger.h
|
||||
hle/service/nvnflinger/parcel.h
|
||||
|
||||
@@ -31,8 +31,11 @@ void LoopProcess(Core::System& system) {
|
||||
// Error Context
|
||||
server_manager->RegisterNamedService("ectx:aw", std::make_shared<ECTX_AW>(system));
|
||||
|
||||
// Notification Services for application
|
||||
server_manager->RegisterNamedService("notif:a", std::make_shared<NOTIF_A>(system));
|
||||
// Notification Services
|
||||
server_manager->RegisterNamedService(
|
||||
"notif:a", std::make_shared<INotificationServicesForApplication>(system));
|
||||
server_manager->RegisterNamedService("notif:s",
|
||||
std::make_shared<INotificationServices>(system));
|
||||
|
||||
// Time
|
||||
auto time = std::make_shared<Time::TimeManager>(system);
|
||||
|
||||
@@ -6,48 +6,31 @@
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/hle/service/cmif_serialization.h"
|
||||
#include "core/hle/service/glue/notif.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "core/hle/service/kernel_helpers.h"
|
||||
|
||||
namespace Service::Glue {
|
||||
|
||||
NOTIF_A::NOTIF_A(Core::System& system_) : ServiceFramework{system_, "notif:a"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{500, &NOTIF_A::RegisterAlarmSetting, "RegisterAlarmSetting"},
|
||||
{510, &NOTIF_A::UpdateAlarmSetting, "UpdateAlarmSetting"},
|
||||
{520, &NOTIF_A::ListAlarmSettings, "ListAlarmSettings"},
|
||||
{530, &NOTIF_A::LoadApplicationParameter, "LoadApplicationParameter"},
|
||||
{540, &NOTIF_A::DeleteAlarmSetting, "DeleteAlarmSetting"},
|
||||
{1000, &NOTIF_A::Initialize, "Initialize"},
|
||||
};
|
||||
// clang-format on
|
||||
namespace {
|
||||
|
||||
constexpr inline std::size_t MaxAlarms = 8;
|
||||
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
NOTIF_A::~NOTIF_A() = default;
|
||||
|
||||
void NOTIF_A::RegisterAlarmSetting(HLERequestContext& ctx) {
|
||||
const auto alarm_setting_buffer_size = ctx.GetReadBufferSize(0);
|
||||
const auto application_parameter_size = ctx.GetReadBufferSize(1);
|
||||
|
||||
ASSERT_MSG(alarm_setting_buffer_size == sizeof(AlarmSetting),
|
||||
"alarm_setting_buffer_size is not 0x40 bytes");
|
||||
ASSERT_MSG(application_parameter_size <= sizeof(ApplicationParameter),
|
||||
"application_parameter_size is bigger than 0x400 bytes");
|
||||
|
||||
AlarmSetting new_alarm{};
|
||||
memcpy(&new_alarm, ctx.ReadBuffer(0).data(), sizeof(AlarmSetting));
|
||||
|
||||
// TODO: Count alarms per game id
|
||||
if (alarms.size() >= max_alarms) {
|
||||
Result NotificationServiceImpl::RegisterAlarmSetting(AlarmSettingId* out_alarm_setting_id,
|
||||
const AlarmSetting& alarm_setting,
|
||||
std::span<const u8> application_parameter) {
|
||||
if (alarms.size() > MaxAlarms) {
|
||||
LOG_ERROR(Service_NOTIF, "Alarm limit reached");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultUnknown);
|
||||
return;
|
||||
R_THROW(ResultUnknown);
|
||||
}
|
||||
|
||||
ASSERT_MSG(application_parameter.size() <= sizeof(ApplicationParameter),
|
||||
"application_parameter_size is bigger than 0x400 bytes");
|
||||
|
||||
AlarmSetting new_alarm = alarm_setting;
|
||||
new_alarm.alarm_setting_id = last_alarm_setting_id++;
|
||||
alarms.push_back(new_alarm);
|
||||
|
||||
@@ -55,100 +38,82 @@ void NOTIF_A::RegisterAlarmSetting(HLERequestContext& ctx) {
|
||||
|
||||
LOG_WARNING(Service_NOTIF,
|
||||
"(STUBBED) called, application_parameter_size={}, setting_id={}, kind={}, muted={}",
|
||||
application_parameter_size, new_alarm.alarm_setting_id, new_alarm.kind,
|
||||
application_parameter.size(), new_alarm.alarm_setting_id, new_alarm.kind,
|
||||
new_alarm.muted);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(new_alarm.alarm_setting_id);
|
||||
*out_alarm_setting_id = new_alarm.alarm_setting_id;
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void NOTIF_A::UpdateAlarmSetting(HLERequestContext& ctx) {
|
||||
const auto alarm_setting_buffer_size = ctx.GetReadBufferSize(0);
|
||||
const auto application_parameter_size = ctx.GetReadBufferSize(1);
|
||||
|
||||
ASSERT_MSG(alarm_setting_buffer_size == sizeof(AlarmSetting),
|
||||
"alarm_setting_buffer_size is not 0x40 bytes");
|
||||
ASSERT_MSG(application_parameter_size <= sizeof(ApplicationParameter),
|
||||
Result NotificationServiceImpl::UpdateAlarmSetting(const AlarmSetting& alarm_setting,
|
||||
std::span<const u8> application_parameter) {
|
||||
ASSERT_MSG(application_parameter.size() <= sizeof(ApplicationParameter),
|
||||
"application_parameter_size is bigger than 0x400 bytes");
|
||||
|
||||
AlarmSetting alarm_setting{};
|
||||
memcpy(&alarm_setting, ctx.ReadBuffer(0).data(), sizeof(AlarmSetting));
|
||||
|
||||
const auto alarm_it = GetAlarmFromId(alarm_setting.alarm_setting_id);
|
||||
if (alarm_it != alarms.end()) {
|
||||
LOG_DEBUG(Service_NOTIF, "Alarm updated");
|
||||
*alarm_it = alarm_setting;
|
||||
// TODO: Save application parameter data
|
||||
}
|
||||
|
||||
LOG_WARNING(Service_NOTIF,
|
||||
"(STUBBED) called, application_parameter_size={}, setting_id={}, kind={}, muted={}",
|
||||
application_parameter_size, alarm_setting.alarm_setting_id, alarm_setting.kind,
|
||||
application_parameter.size(), alarm_setting.alarm_setting_id, alarm_setting.kind,
|
||||
alarm_setting.muted);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void NOTIF_A::ListAlarmSettings(HLERequestContext& ctx) {
|
||||
Result NotificationServiceImpl::ListAlarmSettings(s32* out_count,
|
||||
std::span<AlarmSetting> out_alarms) {
|
||||
LOG_INFO(Service_NOTIF, "called, alarm_count={}", alarms.size());
|
||||
|
||||
// TODO: Only return alarms of this game id
|
||||
ctx.WriteBuffer(alarms);
|
||||
const auto count = std::min(out_alarms.size(), alarms.size());
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
out_alarms[i] = alarms[i];
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(static_cast<u32>(alarms.size()));
|
||||
*out_count = static_cast<s32>(count);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void NOTIF_A::LoadApplicationParameter(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto alarm_setting_id{rp.Pop<AlarmSettingId>()};
|
||||
|
||||
Result NotificationServiceImpl::LoadApplicationParameter(u32* out_size,
|
||||
std::span<u8> out_application_parameter,
|
||||
AlarmSettingId alarm_setting_id) {
|
||||
const auto alarm_it = GetAlarmFromId(alarm_setting_id);
|
||||
if (alarm_it == alarms.end()) {
|
||||
LOG_ERROR(Service_NOTIF, "Invalid alarm setting id={}", alarm_setting_id);
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultUnknown);
|
||||
return;
|
||||
R_THROW(ResultUnknown);
|
||||
}
|
||||
|
||||
// TODO: Read application parameter related to this setting id
|
||||
ApplicationParameter application_parameter{};
|
||||
|
||||
LOG_WARNING(Service_NOTIF, "(STUBBED) called, alarm_setting_id={}", alarm_setting_id);
|
||||
std::memcpy(out_application_parameter.data(), application_parameter.data(),
|
||||
std::min(sizeof(application_parameter), out_application_parameter.size()));
|
||||
|
||||
ctx.WriteBuffer(application_parameter);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(static_cast<u32>(application_parameter.size()));
|
||||
*out_size = static_cast<u32>(application_parameter.size());
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void NOTIF_A::DeleteAlarmSetting(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto alarm_setting_id{rp.Pop<AlarmSettingId>()};
|
||||
|
||||
Result NotificationServiceImpl::DeleteAlarmSetting(AlarmSettingId alarm_setting_id) {
|
||||
std::erase_if(alarms, [alarm_setting_id](const AlarmSetting& alarm) {
|
||||
return alarm.alarm_setting_id == alarm_setting_id;
|
||||
});
|
||||
|
||||
LOG_INFO(Service_NOTIF, "called, alarm_setting_id={}", alarm_setting_id);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void NOTIF_A::Initialize(HLERequestContext& ctx) {
|
||||
Result NotificationServiceImpl::Initialize(u64 aruid) {
|
||||
// TODO: Load previous alarms from config
|
||||
|
||||
LOG_WARNING(Service_NOTIF, "(STUBBED) called");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
std::vector<NOTIF_A::AlarmSetting>::iterator NOTIF_A::GetAlarmFromId(
|
||||
std::vector<AlarmSetting>::iterator NotificationServiceImpl::GetAlarmFromId(
|
||||
AlarmSettingId alarm_setting_id) {
|
||||
return std::find_if(alarms.begin(), alarms.end(),
|
||||
[alarm_setting_id](const AlarmSetting& alarm) {
|
||||
@@ -156,4 +121,174 @@ std::vector<NOTIF_A::AlarmSetting>::iterator NOTIF_A::GetAlarmFromId(
|
||||
});
|
||||
}
|
||||
|
||||
INotificationServicesForApplication::INotificationServicesForApplication(Core::System& system_)
|
||||
: ServiceFramework{system_, "notif:a"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{500, D<&INotificationServicesForApplication::RegisterAlarmSetting>, "RegisterAlarmSetting"},
|
||||
{510, D<&INotificationServicesForApplication::UpdateAlarmSetting>, "UpdateAlarmSetting"},
|
||||
{520, D<&INotificationServicesForApplication::ListAlarmSettings>, "ListAlarmSettings"},
|
||||
{530, D<&INotificationServicesForApplication::LoadApplicationParameter>, "LoadApplicationParameter"},
|
||||
{540, D<&INotificationServicesForApplication::DeleteAlarmSetting>, "DeleteAlarmSetting"},
|
||||
{1000, D<&INotificationServicesForApplication::Initialize>, "Initialize"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
INotificationServicesForApplication::~INotificationServicesForApplication() = default;
|
||||
|
||||
Result INotificationServicesForApplication::RegisterAlarmSetting(
|
||||
Out<AlarmSettingId> out_alarm_setting_id,
|
||||
InLargeData<AlarmSetting, BufferAttr_HipcMapAlias> alarm_setting,
|
||||
InBuffer<BufferAttr_HipcMapAlias> application_parameter) {
|
||||
R_RETURN(impl.RegisterAlarmSetting(out_alarm_setting_id.Get(), *alarm_setting,
|
||||
application_parameter));
|
||||
}
|
||||
|
||||
Result INotificationServicesForApplication::UpdateAlarmSetting(
|
||||
InLargeData<AlarmSetting, BufferAttr_HipcMapAlias> alarm_setting,
|
||||
InBuffer<BufferAttr_HipcMapAlias> application_parameter) {
|
||||
R_RETURN(impl.UpdateAlarmSetting(*alarm_setting, application_parameter));
|
||||
}
|
||||
|
||||
Result INotificationServicesForApplication::ListAlarmSettings(
|
||||
Out<s32> out_count, OutArray<AlarmSetting, BufferAttr_HipcMapAlias> out_alarms) {
|
||||
R_RETURN(impl.ListAlarmSettings(out_count.Get(), out_alarms));
|
||||
}
|
||||
|
||||
Result INotificationServicesForApplication::LoadApplicationParameter(
|
||||
Out<u32> out_size, OutBuffer<BufferAttr_HipcMapAlias> out_application_parameter,
|
||||
AlarmSettingId alarm_setting_id) {
|
||||
R_RETURN(
|
||||
impl.LoadApplicationParameter(out_size.Get(), out_application_parameter, alarm_setting_id));
|
||||
}
|
||||
|
||||
Result INotificationServicesForApplication::DeleteAlarmSetting(AlarmSettingId alarm_setting_id) {
|
||||
R_RETURN(impl.DeleteAlarmSetting(alarm_setting_id));
|
||||
}
|
||||
|
||||
Result INotificationServicesForApplication::Initialize(ClientAppletResourceUserId aruid) {
|
||||
R_RETURN(impl.Initialize(*aruid));
|
||||
}
|
||||
|
||||
class INotificationSystemEventAccessor final
|
||||
: public ServiceFramework<INotificationSystemEventAccessor> {
|
||||
public:
|
||||
explicit INotificationSystemEventAccessor(Core::System& system_)
|
||||
: ServiceFramework{system_, "INotificationSystemEventAccessor"},
|
||||
service_context{system_, "INotificationSystemEventAccessor"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, D<&INotificationSystemEventAccessor::GetSystemEvent>, "GetSystemEvent"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
RegisterHandlers(functions);
|
||||
|
||||
notification_event =
|
||||
service_context.CreateEvent("INotificationSystemEventAccessor:NotificationEvent");
|
||||
}
|
||||
|
||||
~INotificationSystemEventAccessor() {
|
||||
service_context.CloseEvent(notification_event);
|
||||
}
|
||||
|
||||
private:
|
||||
Result GetSystemEvent(OutCopyHandle<Kernel::KReadableEvent> out_readable_event) {
|
||||
LOG_WARNING(Service_NOTIF, "(STUBBED) called");
|
||||
|
||||
*out_readable_event = ¬ification_event->GetReadableEvent();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
KernelHelpers::ServiceContext service_context;
|
||||
Kernel::KEvent* notification_event;
|
||||
};
|
||||
|
||||
INotificationServices::INotificationServices(Core::System& system_)
|
||||
: ServiceFramework{system_, "notif:s"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{500, D<&INotificationServices::RegisterAlarmSetting>, "RegisterAlarmSetting"},
|
||||
{510, D<&INotificationServices::UpdateAlarmSetting>, "UpdateAlarmSetting"},
|
||||
{520, D<&INotificationServices::ListAlarmSettings>, "ListAlarmSettings"},
|
||||
{530, D<&INotificationServices::LoadApplicationParameter>, "LoadApplicationParameter"},
|
||||
{540, D<&INotificationServices::DeleteAlarmSetting>, "DeleteAlarmSetting"},
|
||||
{1000, D<&INotificationServices::Initialize>, "Initialize"},
|
||||
{1010, nullptr, "ListNotifications"},
|
||||
{1020, nullptr, "DeleteNotification"},
|
||||
{1030, nullptr, "ClearNotifications"},
|
||||
{1040, D<&INotificationServices::OpenNotificationSystemEventAccessor>, "OpenNotificationSystemEventAccessor"},
|
||||
{1500, nullptr, "SetNotificationPresentationSetting"},
|
||||
{1510, D<&INotificationServices::GetNotificationPresentationSetting>, "GetNotificationPresentationSetting"},
|
||||
{2000, nullptr, "GetAlarmSetting"},
|
||||
{2001, nullptr, "GetAlarmSettingWithApplicationParameter"},
|
||||
{2010, nullptr, "MuteAlarmSetting"},
|
||||
{2020, nullptr, "IsAlarmSettingReady"},
|
||||
{8000, nullptr, "RegisterAppletResourceUserId"},
|
||||
{8010, nullptr, "UnregisterAppletResourceUserId"},
|
||||
{8999, nullptr, "GetCurrentTime"},
|
||||
{9000, nullptr, "GetAlarmSettingNextNotificationTime"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
INotificationServices::~INotificationServices() = default;
|
||||
|
||||
Result INotificationServices::RegisterAlarmSetting(
|
||||
Out<AlarmSettingId> out_alarm_setting_id,
|
||||
InLargeData<AlarmSetting, BufferAttr_HipcMapAlias> alarm_setting,
|
||||
InBuffer<BufferAttr_HipcMapAlias> application_parameter) {
|
||||
R_RETURN(impl.RegisterAlarmSetting(out_alarm_setting_id.Get(), *alarm_setting,
|
||||
application_parameter));
|
||||
}
|
||||
|
||||
Result INotificationServices::UpdateAlarmSetting(
|
||||
InLargeData<AlarmSetting, BufferAttr_HipcMapAlias> alarm_setting,
|
||||
InBuffer<BufferAttr_HipcMapAlias> application_parameter) {
|
||||
R_RETURN(impl.UpdateAlarmSetting(*alarm_setting, application_parameter));
|
||||
}
|
||||
|
||||
Result INotificationServices::ListAlarmSettings(
|
||||
Out<s32> out_count, OutArray<AlarmSetting, BufferAttr_HipcMapAlias> out_alarms) {
|
||||
R_RETURN(impl.ListAlarmSettings(out_count.Get(), out_alarms));
|
||||
}
|
||||
|
||||
Result INotificationServices::LoadApplicationParameter(
|
||||
Out<u32> out_size, OutBuffer<BufferAttr_HipcMapAlias> out_application_parameter,
|
||||
AlarmSettingId alarm_setting_id) {
|
||||
R_RETURN(
|
||||
impl.LoadApplicationParameter(out_size.Get(), out_application_parameter, alarm_setting_id));
|
||||
}
|
||||
|
||||
Result INotificationServices::DeleteAlarmSetting(AlarmSettingId alarm_setting_id) {
|
||||
R_RETURN(impl.DeleteAlarmSetting(alarm_setting_id));
|
||||
}
|
||||
|
||||
Result INotificationServices::Initialize(ClientAppletResourceUserId aruid) {
|
||||
R_RETURN(impl.Initialize(*aruid));
|
||||
}
|
||||
|
||||
Result INotificationServices::OpenNotificationSystemEventAccessor(
|
||||
Out<SharedPointer<INotificationSystemEventAccessor>> out_notification_system_event_accessor) {
|
||||
LOG_WARNING(Service_NOTIF, "(STUBBED) called");
|
||||
|
||||
*out_notification_system_event_accessor =
|
||||
std::make_shared<INotificationSystemEventAccessor>(system);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result INotificationServices::GetNotificationPresentationSetting(
|
||||
Out<NotificationPresentationSetting> out_notification_presentation_setting,
|
||||
NotificationChannel notification_channel) {
|
||||
LOG_WARNING(Service_NOTIF, "(STUBBED) called");
|
||||
|
||||
*out_notification_presentation_setting = {};
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
} // namespace Service::Glue
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "common/uuid.h"
|
||||
#include "core/hle/service/cmif_types.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
namespace Core {
|
||||
@@ -15,58 +16,117 @@ class System;
|
||||
|
||||
namespace Service::Glue {
|
||||
|
||||
class NOTIF_A final : public ServiceFramework<NOTIF_A> {
|
||||
// This is nn::notification::AlarmSettingId
|
||||
using AlarmSettingId = u16;
|
||||
static_assert(sizeof(AlarmSettingId) == 0x2, "AlarmSettingId is an invalid size");
|
||||
|
||||
using ApplicationParameter = std::array<u8, 0x400>;
|
||||
static_assert(sizeof(ApplicationParameter) == 0x400, "ApplicationParameter is an invalid size");
|
||||
|
||||
struct DailyAlarmSetting {
|
||||
s8 hour;
|
||||
s8 minute;
|
||||
};
|
||||
static_assert(sizeof(DailyAlarmSetting) == 0x2, "DailyAlarmSetting is an invalid size");
|
||||
|
||||
struct WeeklyScheduleAlarmSetting {
|
||||
INSERT_PADDING_BYTES_NOINIT(0xA);
|
||||
std::array<DailyAlarmSetting, 0x7> day_of_week;
|
||||
};
|
||||
static_assert(sizeof(WeeklyScheduleAlarmSetting) == 0x18,
|
||||
"WeeklyScheduleAlarmSetting is an invalid size");
|
||||
|
||||
// This is nn::notification::AlarmSetting
|
||||
struct AlarmSetting {
|
||||
AlarmSettingId alarm_setting_id;
|
||||
u8 kind;
|
||||
u8 muted;
|
||||
INSERT_PADDING_BYTES_NOINIT(0x4);
|
||||
Common::UUID account_id;
|
||||
u64 application_id;
|
||||
INSERT_PADDING_BYTES_NOINIT(0x8);
|
||||
WeeklyScheduleAlarmSetting schedule;
|
||||
};
|
||||
static_assert(sizeof(AlarmSetting) == 0x40, "AlarmSetting is an invalid size");
|
||||
|
||||
enum class NotificationChannel : u8 {
|
||||
Unknown0 = 0,
|
||||
};
|
||||
|
||||
struct NotificationPresentationSetting {
|
||||
INSERT_PADDING_BYTES_NOINIT(0x10);
|
||||
};
|
||||
static_assert(sizeof(NotificationPresentationSetting) == 0x10,
|
||||
"NotificationPresentationSetting is an invalid size");
|
||||
|
||||
class NotificationServiceImpl {
|
||||
public:
|
||||
explicit NOTIF_A(Core::System& system_);
|
||||
~NOTIF_A() override;
|
||||
Result RegisterAlarmSetting(AlarmSettingId* out_alarm_setting_id,
|
||||
const AlarmSetting& alarm_setting,
|
||||
std::span<const u8> application_parameter);
|
||||
Result UpdateAlarmSetting(const AlarmSetting& alarm_setting,
|
||||
std::span<const u8> application_parameter);
|
||||
Result ListAlarmSettings(s32* out_count, std::span<AlarmSetting> out_alarms);
|
||||
Result LoadApplicationParameter(u32* out_size, std::span<u8> out_application_parameter,
|
||||
AlarmSettingId alarm_setting_id);
|
||||
Result DeleteAlarmSetting(AlarmSettingId alarm_setting_id);
|
||||
Result Initialize(u64 aruid);
|
||||
|
||||
private:
|
||||
static constexpr std::size_t max_alarms = 8;
|
||||
|
||||
// This is nn::notification::AlarmSettingId
|
||||
using AlarmSettingId = u16;
|
||||
static_assert(sizeof(AlarmSettingId) == 0x2, "AlarmSettingId is an invalid size");
|
||||
|
||||
using ApplicationParameter = std::array<u8, 0x400>;
|
||||
static_assert(sizeof(ApplicationParameter) == 0x400, "ApplicationParameter is an invalid size");
|
||||
|
||||
struct DailyAlarmSetting {
|
||||
s8 hour;
|
||||
s8 minute;
|
||||
};
|
||||
static_assert(sizeof(DailyAlarmSetting) == 0x2, "DailyAlarmSetting is an invalid size");
|
||||
|
||||
struct WeeklyScheduleAlarmSetting {
|
||||
INSERT_PADDING_BYTES(0xA);
|
||||
std::array<DailyAlarmSetting, 0x7> day_of_week;
|
||||
};
|
||||
static_assert(sizeof(WeeklyScheduleAlarmSetting) == 0x18,
|
||||
"WeeklyScheduleAlarmSetting is an invalid size");
|
||||
|
||||
// This is nn::notification::AlarmSetting
|
||||
struct AlarmSetting {
|
||||
AlarmSettingId alarm_setting_id;
|
||||
u8 kind;
|
||||
u8 muted;
|
||||
INSERT_PADDING_BYTES(0x4);
|
||||
Common::UUID account_id;
|
||||
u64 application_id;
|
||||
INSERT_PADDING_BYTES(0x8);
|
||||
WeeklyScheduleAlarmSetting schedule;
|
||||
};
|
||||
static_assert(sizeof(AlarmSetting) == 0x40, "AlarmSetting is an invalid size");
|
||||
|
||||
void RegisterAlarmSetting(HLERequestContext& ctx);
|
||||
void UpdateAlarmSetting(HLERequestContext& ctx);
|
||||
void ListAlarmSettings(HLERequestContext& ctx);
|
||||
void LoadApplicationParameter(HLERequestContext& ctx);
|
||||
void DeleteAlarmSetting(HLERequestContext& ctx);
|
||||
void Initialize(HLERequestContext& ctx);
|
||||
|
||||
std::vector<AlarmSetting>::iterator GetAlarmFromId(AlarmSettingId alarm_setting_id);
|
||||
|
||||
std::vector<AlarmSetting> alarms{};
|
||||
AlarmSettingId last_alarm_setting_id{};
|
||||
};
|
||||
|
||||
class INotificationServicesForApplication final
|
||||
: public ServiceFramework<INotificationServicesForApplication> {
|
||||
public:
|
||||
explicit INotificationServicesForApplication(Core::System& system_);
|
||||
~INotificationServicesForApplication() override;
|
||||
|
||||
private:
|
||||
Result RegisterAlarmSetting(Out<AlarmSettingId> out_alarm_setting_id,
|
||||
InLargeData<AlarmSetting, BufferAttr_HipcMapAlias> alarm_setting,
|
||||
InBuffer<BufferAttr_HipcMapAlias> application_parameter);
|
||||
Result UpdateAlarmSetting(InLargeData<AlarmSetting, BufferAttr_HipcMapAlias> alarm_setting,
|
||||
InBuffer<BufferAttr_HipcMapAlias> application_parameter);
|
||||
Result ListAlarmSettings(Out<s32> out_count,
|
||||
OutArray<AlarmSetting, BufferAttr_HipcMapAlias> out_alarms);
|
||||
Result LoadApplicationParameter(Out<u32> out_size,
|
||||
OutBuffer<BufferAttr_HipcMapAlias> out_application_parameter,
|
||||
AlarmSettingId alarm_setting_id);
|
||||
Result DeleteAlarmSetting(AlarmSettingId alarm_setting_id);
|
||||
Result Initialize(ClientAppletResourceUserId aruid);
|
||||
|
||||
NotificationServiceImpl impl;
|
||||
};
|
||||
|
||||
class INotificationSystemEventAccessor;
|
||||
|
||||
class INotificationServices final : public ServiceFramework<INotificationServices> {
|
||||
public:
|
||||
explicit INotificationServices(Core::System& system_);
|
||||
~INotificationServices() override;
|
||||
|
||||
private:
|
||||
Result RegisterAlarmSetting(Out<AlarmSettingId> out_alarm_setting_id,
|
||||
InLargeData<AlarmSetting, BufferAttr_HipcMapAlias> alarm_setting,
|
||||
InBuffer<BufferAttr_HipcMapAlias> application_parameter);
|
||||
Result UpdateAlarmSetting(InLargeData<AlarmSetting, BufferAttr_HipcMapAlias> alarm_setting,
|
||||
InBuffer<BufferAttr_HipcMapAlias> application_parameter);
|
||||
Result ListAlarmSettings(Out<s32> out_count,
|
||||
OutArray<AlarmSetting, BufferAttr_HipcMapAlias> out_alarms);
|
||||
Result LoadApplicationParameter(Out<u32> out_size,
|
||||
OutBuffer<BufferAttr_HipcMapAlias> out_application_parameter,
|
||||
AlarmSettingId alarm_setting_id);
|
||||
Result DeleteAlarmSetting(AlarmSettingId alarm_setting_id);
|
||||
Result Initialize(ClientAppletResourceUserId aruid);
|
||||
Result OpenNotificationSystemEventAccessor(Out<SharedPointer<INotificationSystemEventAccessor>>
|
||||
out_notification_system_event_accessor);
|
||||
Result GetNotificationPresentationSetting(
|
||||
Out<NotificationPresentationSetting> out_notification_presentation_setting,
|
||||
NotificationChannel notification_channel);
|
||||
|
||||
NotificationServiceImpl impl;
|
||||
};
|
||||
} // namespace Service::Glue
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <boost/container/small_vector.hpp>
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/core.h"
|
||||
@@ -38,19 +40,30 @@ NvResult nvdisp_disp0::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> in
|
||||
void nvdisp_disp0::OnOpen(NvCore::SessionId session_id, DeviceFD fd) {}
|
||||
void nvdisp_disp0::OnClose(DeviceFD fd) {}
|
||||
|
||||
void nvdisp_disp0::flip(u32 buffer_handle, u32 offset, android::PixelFormat format, u32 width,
|
||||
u32 height, u32 stride, android::BufferTransformFlags transform,
|
||||
const Common::Rectangle<int>& crop_rect,
|
||||
std::array<Service::Nvidia::NvFence, 4>& fences, u32 num_fences) {
|
||||
const DAddr addr = nvmap.GetHandleAddress(buffer_handle);
|
||||
LOG_TRACE(Service,
|
||||
"Drawing from address {:X} offset {:08X} Width {} Height {} Stride {} Format {}",
|
||||
addr, offset, width, height, stride, format);
|
||||
void nvdisp_disp0::Composite(std::span<const Nvnflinger::HwcLayer> sorted_layers) {
|
||||
std::vector<Tegra::FramebufferConfig> output_layers;
|
||||
std::vector<Service::Nvidia::NvFence> output_fences;
|
||||
output_layers.reserve(sorted_layers.size());
|
||||
output_fences.reserve(sorted_layers.size());
|
||||
|
||||
const Tegra::FramebufferConfig framebuffer{addr, offset, width, height,
|
||||
stride, format, transform, crop_rect};
|
||||
for (auto& layer : sorted_layers) {
|
||||
output_layers.emplace_back(Tegra::FramebufferConfig{
|
||||
.address = nvmap.GetHandleAddress(layer.buffer_handle),
|
||||
.offset = layer.offset,
|
||||
.width = layer.width,
|
||||
.height = layer.height,
|
||||
.stride = layer.stride,
|
||||
.pixel_format = layer.format,
|
||||
.transform_flags = layer.transform,
|
||||
.crop_rect = layer.crop_rect,
|
||||
});
|
||||
|
||||
system.GPU().RequestSwapBuffers(&framebuffer, fences, num_fences);
|
||||
for (size_t i = 0; i < layer.acquire_fence.num_fences; i++) {
|
||||
output_fences.push_back(layer.acquire_fence.fences[i]);
|
||||
}
|
||||
}
|
||||
|
||||
system.GPU().RequestComposite(std::move(output_layers), std::move(output_fences));
|
||||
system.SpeedLimiter().DoSpeedLimiting(system.CoreTiming().GetGlobalTimeUs());
|
||||
system.GetPerfStats().EndSystemFrame();
|
||||
system.GetPerfStats().BeginSystemFrame();
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
#include "common/common_types.h"
|
||||
#include "common/math_util.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvdevice.h"
|
||||
#include "core/hle/service/nvnflinger/buffer_transform_flags.h"
|
||||
#include "core/hle/service/nvnflinger/pixel_format.h"
|
||||
#include "core/hle/service/nvnflinger/hwc_layer.h"
|
||||
|
||||
namespace Service::Nvidia::NvCore {
|
||||
class Container;
|
||||
@@ -35,11 +34,8 @@ public:
|
||||
void OnOpen(NvCore::SessionId session_id, DeviceFD fd) override;
|
||||
void OnClose(DeviceFD fd) override;
|
||||
|
||||
/// Performs a screen flip, drawing the buffer pointed to by the handle.
|
||||
void flip(u32 buffer_handle, u32 offset, android::PixelFormat format, u32 width, u32 height,
|
||||
u32 stride, android::BufferTransformFlags transform,
|
||||
const Common::Rectangle<int>& crop_rect,
|
||||
std::array<Service::Nvidia::NvFence, 4>& fences, u32 num_fences);
|
||||
/// Performs a screen flip, compositing each buffer.
|
||||
void Composite(std::span<const Nvnflinger::HwcLayer> sorted_layers);
|
||||
|
||||
Kernel::KEvent* QueryEvent(u32 event_id) override;
|
||||
|
||||
|
||||
+215
@@ -0,0 +1,215 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include <boost/container/small_vector.hpp>
|
||||
|
||||
#include "common/microprofile.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvdisp_disp0.h"
|
||||
#include "core/hle/service/nvnflinger/buffer_item.h"
|
||||
#include "core/hle/service/nvnflinger/buffer_item_consumer.h"
|
||||
#include "core/hle/service/nvnflinger/buffer_queue_producer.h"
|
||||
#include "core/hle/service/nvnflinger/hardware_composer.h"
|
||||
#include "core/hle/service/nvnflinger/hwc_layer.h"
|
||||
#include "core/hle/service/nvnflinger/ui/graphic_buffer.h"
|
||||
#include "core/hle/service/vi/display/vi_display.h"
|
||||
#include "core/hle/service/vi/layer/vi_layer.h"
|
||||
|
||||
namespace Service::Nvnflinger {
|
||||
|
||||
namespace {
|
||||
|
||||
s32 NormalizeSwapInterval(f32* out_speed_scale, s32 swap_interval) {
|
||||
if (swap_interval <= 0) {
|
||||
// As an extension, treat nonpositive swap interval as speed multiplier.
|
||||
if (out_speed_scale) {
|
||||
*out_speed_scale = 2.f * static_cast<f32>(1 - swap_interval);
|
||||
}
|
||||
|
||||
swap_interval = 1;
|
||||
}
|
||||
|
||||
if (swap_interval >= 5) {
|
||||
// As an extension, treat high swap interval as precise speed control.
|
||||
if (out_speed_scale) {
|
||||
*out_speed_scale = static_cast<f32>(swap_interval) / 100.f;
|
||||
}
|
||||
|
||||
swap_interval = 1;
|
||||
}
|
||||
|
||||
return swap_interval;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
HardwareComposer::HardwareComposer() = default;
|
||||
HardwareComposer::~HardwareComposer() = default;
|
||||
|
||||
u32 HardwareComposer::ComposeLocked(f32* out_speed_scale, VI::Display& display,
|
||||
Nvidia::Devices::nvdisp_disp0& nvdisp, u32 frame_advance) {
|
||||
boost::container::small_vector<HwcLayer, 2> composition_stack;
|
||||
|
||||
m_frame_number += frame_advance;
|
||||
|
||||
// Release any necessary framebuffers.
|
||||
for (auto& [layer_id, framebuffer] : m_framebuffers) {
|
||||
if (framebuffer.release_frame_number > m_frame_number) {
|
||||
// Not yet ready to release this framebuffer.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!framebuffer.is_acquired) {
|
||||
// Already released.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (auto* layer = display.FindLayer(layer_id); layer != nullptr) {
|
||||
// TODO: support release fence
|
||||
// This is needed to prevent screen tearing
|
||||
layer->GetConsumer().ReleaseBuffer(framebuffer.item, android::Fence::NoFence());
|
||||
framebuffer.is_acquired = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Set default speed limit to 100%.
|
||||
*out_speed_scale = 1.0f;
|
||||
|
||||
// Determine the number of vsync periods to wait before composing again.
|
||||
std::optional<s32> swap_interval{};
|
||||
bool has_acquired_buffer{};
|
||||
|
||||
// Acquire all necessary framebuffers.
|
||||
for (size_t i = 0; i < display.GetNumLayers(); i++) {
|
||||
auto& layer = display.GetLayer(i);
|
||||
auto layer_id = layer.GetLayerId();
|
||||
|
||||
// Try to fetch the framebuffer (either new or stale).
|
||||
const auto result = this->CacheFramebufferLocked(layer, layer_id);
|
||||
|
||||
// If we failed, skip this layer.
|
||||
if (result == CacheStatus::NoBufferAvailable) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If we acquired a new buffer, we need to present.
|
||||
if (result == CacheStatus::BufferAcquired) {
|
||||
has_acquired_buffer = true;
|
||||
}
|
||||
|
||||
const auto& buffer = m_framebuffers[layer_id];
|
||||
const auto& item = buffer.item;
|
||||
const auto& igbp_buffer = *item.graphic_buffer;
|
||||
|
||||
// TODO: get proper Z-index from layer
|
||||
composition_stack.emplace_back(HwcLayer{
|
||||
.buffer_handle = igbp_buffer.BufferId(),
|
||||
.offset = igbp_buffer.Offset(),
|
||||
.format = igbp_buffer.ExternalFormat(),
|
||||
.width = igbp_buffer.Width(),
|
||||
.height = igbp_buffer.Height(),
|
||||
.stride = igbp_buffer.Stride(),
|
||||
.z_index = 0,
|
||||
.transform = static_cast<android::BufferTransformFlags>(item.transform),
|
||||
.crop_rect = item.crop,
|
||||
.acquire_fence = item.fence,
|
||||
});
|
||||
|
||||
// We need to compose again either before this frame is supposed to
|
||||
// be released, or exactly on the vsync period it should be released.
|
||||
const s32 item_swap_interval = NormalizeSwapInterval(out_speed_scale, item.swap_interval);
|
||||
|
||||
// TODO: handle cases where swap intervals are relatively prime. So far,
|
||||
// only swap intervals of 0, 1 and 2 have been observed, but if 3 were
|
||||
// to be introduced, this would cause an issue.
|
||||
if (swap_interval) {
|
||||
swap_interval = std::min(*swap_interval, item_swap_interval);
|
||||
} else {
|
||||
swap_interval = item_swap_interval;
|
||||
}
|
||||
}
|
||||
|
||||
// If any new buffers were acquired, we can present.
|
||||
if (has_acquired_buffer) {
|
||||
// Sort by Z-index.
|
||||
std::stable_sort(composition_stack.begin(), composition_stack.end(),
|
||||
[&](auto& l, auto& r) { return l.z_index < r.z_index; });
|
||||
|
||||
// Composite.
|
||||
nvdisp.Composite(composition_stack);
|
||||
}
|
||||
|
||||
// Render MicroProfile.
|
||||
MicroProfileFlip();
|
||||
|
||||
// Advance by at least one frame.
|
||||
return swap_interval.value_or(1);
|
||||
}
|
||||
|
||||
void HardwareComposer::RemoveLayerLocked(VI::Display& display, LayerId layer_id) {
|
||||
// Check if we are tracking a slot with this layer_id.
|
||||
const auto it = m_framebuffers.find(layer_id);
|
||||
if (it == m_framebuffers.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Try to release the buffer item.
|
||||
auto* const layer = display.FindLayer(layer_id);
|
||||
if (layer && it->second.is_acquired) {
|
||||
layer->GetConsumer().ReleaseBuffer(it->second.item, android::Fence::NoFence());
|
||||
}
|
||||
|
||||
// Erase the slot.
|
||||
m_framebuffers.erase(it);
|
||||
}
|
||||
|
||||
bool HardwareComposer::TryAcquireFramebufferLocked(VI::Layer& layer, Framebuffer& framebuffer) {
|
||||
// Attempt the update.
|
||||
const auto status = layer.GetConsumer().AcquireBuffer(&framebuffer.item, {}, false);
|
||||
if (status != android::Status::NoError) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We succeeded, so set the new release frame info.
|
||||
framebuffer.release_frame_number =
|
||||
NormalizeSwapInterval(nullptr, framebuffer.item.swap_interval);
|
||||
framebuffer.is_acquired = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
HardwareComposer::CacheStatus HardwareComposer::CacheFramebufferLocked(VI::Layer& layer,
|
||||
LayerId layer_id) {
|
||||
// Check if this framebuffer is already present.
|
||||
const auto it = m_framebuffers.find(layer_id);
|
||||
if (it != m_framebuffers.end()) {
|
||||
// If it's currently still acquired, we are done.
|
||||
if (it->second.is_acquired) {
|
||||
return CacheStatus::CachedBufferReused;
|
||||
}
|
||||
|
||||
// Try to acquire a new item.
|
||||
if (this->TryAcquireFramebufferLocked(layer, it->second)) {
|
||||
// We got a new item.
|
||||
return CacheStatus::BufferAcquired;
|
||||
} else {
|
||||
// We didn't acquire a new item, but we can reuse the slot.
|
||||
return CacheStatus::CachedBufferReused;
|
||||
}
|
||||
}
|
||||
|
||||
// Framebuffer is not present, so try to create it.
|
||||
Framebuffer framebuffer{};
|
||||
|
||||
if (this->TryAcquireFramebufferLocked(layer, framebuffer)) {
|
||||
// Move the buffer item into a new slot.
|
||||
m_framebuffers.emplace(layer_id, std::move(framebuffer));
|
||||
|
||||
// We succeeded.
|
||||
return CacheStatus::BufferAcquired;
|
||||
}
|
||||
|
||||
// We couldn't acquire the buffer item, so don't create a slot.
|
||||
return CacheStatus::NoBufferAvailable;
|
||||
}
|
||||
|
||||
} // namespace Service::Nvnflinger
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <boost/container/flat_map.hpp>
|
||||
|
||||
#include "core/hle/service/nvnflinger/buffer_item.h"
|
||||
|
||||
namespace Service::Nvidia::Devices {
|
||||
class nvdisp_disp0;
|
||||
}
|
||||
|
||||
namespace Service::VI {
|
||||
class Display;
|
||||
class Layer;
|
||||
} // namespace Service::VI
|
||||
|
||||
namespace Service::Nvnflinger {
|
||||
|
||||
using LayerId = u64;
|
||||
|
||||
class HardwareComposer {
|
||||
public:
|
||||
explicit HardwareComposer();
|
||||
~HardwareComposer();
|
||||
|
||||
u32 ComposeLocked(f32* out_speed_scale, VI::Display& display,
|
||||
Nvidia::Devices::nvdisp_disp0& nvdisp, u32 frame_advance);
|
||||
void RemoveLayerLocked(VI::Display& display, LayerId layer_id);
|
||||
|
||||
private:
|
||||
// TODO: do we want to track frame number in vi instead?
|
||||
u64 m_frame_number{0};
|
||||
|
||||
private:
|
||||
using ReleaseFrameNumber = u64;
|
||||
|
||||
struct Framebuffer {
|
||||
android::BufferItem item{};
|
||||
ReleaseFrameNumber release_frame_number{};
|
||||
bool is_acquired{false};
|
||||
};
|
||||
|
||||
enum class CacheStatus : u32 {
|
||||
NoBufferAvailable,
|
||||
BufferAcquired,
|
||||
CachedBufferReused,
|
||||
};
|
||||
|
||||
boost::container::flat_map<LayerId, Framebuffer> m_framebuffers{};
|
||||
|
||||
private:
|
||||
bool TryAcquireFramebufferLocked(VI::Layer& layer, Framebuffer& framebuffer);
|
||||
CacheStatus CacheFramebufferLocked(VI::Layer& layer, LayerId layer_id);
|
||||
};
|
||||
|
||||
} // namespace Service::Nvnflinger
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/math_util.h"
|
||||
#include "core/hle/service/nvdrv/nvdata.h"
|
||||
#include "core/hle/service/nvnflinger/buffer_transform_flags.h"
|
||||
#include "core/hle/service/nvnflinger/pixel_format.h"
|
||||
#include "core/hle/service/nvnflinger/ui/fence.h"
|
||||
|
||||
namespace Service::Nvnflinger {
|
||||
|
||||
struct HwcLayer {
|
||||
u32 buffer_handle;
|
||||
u32 offset;
|
||||
android::PixelFormat format;
|
||||
u32 width;
|
||||
u32 height;
|
||||
u32 stride;
|
||||
s32 z_index;
|
||||
android::BufferTransformFlags transform;
|
||||
Common::Rectangle<int> crop_rect;
|
||||
android::Fence acquire_fence;
|
||||
};
|
||||
|
||||
} // namespace Service::Nvnflinger
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "core/hle/service/nvnflinger/buffer_item_consumer.h"
|
||||
#include "core/hle/service/nvnflinger/buffer_queue_core.h"
|
||||
#include "core/hle/service/nvnflinger/fb_share_buffer_manager.h"
|
||||
#include "core/hle/service/nvnflinger/hardware_composer.h"
|
||||
#include "core/hle/service/nvnflinger/hos_binder_driver_server.h"
|
||||
#include "core/hle/service/nvnflinger/nvnflinger.h"
|
||||
#include "core/hle/service/nvnflinger/ui/graphic_buffer.h"
|
||||
@@ -279,45 +280,19 @@ void Nvnflinger::Compose() {
|
||||
SCOPE_EXIT({ display.SignalVSyncEvent(); });
|
||||
|
||||
// Don't do anything for displays without layers.
|
||||
if (!display.HasLayers())
|
||||
continue;
|
||||
|
||||
// TODO(Subv): Support more than 1 layer.
|
||||
VI::Layer& layer = display.GetLayer(0);
|
||||
|
||||
android::BufferItem buffer{};
|
||||
const auto status = layer.GetConsumer().AcquireBuffer(&buffer, {}, false);
|
||||
|
||||
if (status != android::Status::NoError) {
|
||||
if (!display.HasLayers()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto& igbp_buffer = *buffer.graphic_buffer;
|
||||
|
||||
if (!system.IsPoweredOn()) {
|
||||
return; // We are likely shutting down
|
||||
}
|
||||
|
||||
// Now send the buffer to the GPU for drawing.
|
||||
// TODO(Subv): Support more than just disp0. The display device selection is probably based
|
||||
// on which display we're drawing (Default, Internal, External, etc)
|
||||
auto nvdisp = nvdrv->GetDevice<Nvidia::Devices::nvdisp_disp0>(disp_fd);
|
||||
ASSERT(nvdisp);
|
||||
|
||||
Common::Rectangle<int> crop_rect{
|
||||
static_cast<int>(buffer.crop.Left()), static_cast<int>(buffer.crop.Top()),
|
||||
static_cast<int>(buffer.crop.Right()), static_cast<int>(buffer.crop.Bottom())};
|
||||
|
||||
nvdisp->flip(igbp_buffer.BufferId(), igbp_buffer.Offset(), igbp_buffer.ExternalFormat(),
|
||||
igbp_buffer.Width(), igbp_buffer.Height(), igbp_buffer.Stride(),
|
||||
static_cast<android::BufferTransformFlags>(buffer.transform), crop_rect,
|
||||
buffer.fence.fences, buffer.fence.num_fences);
|
||||
|
||||
MicroProfileFlip();
|
||||
|
||||
swap_interval = buffer.swap_interval;
|
||||
|
||||
layer.GetConsumer().ReleaseBuffer(buffer, android::Fence::NoFence());
|
||||
swap_interval = display.GetComposer().ComposeLocked(&compose_speed_scale, display, *nvdisp,
|
||||
swap_interval);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,15 +309,16 @@ s64 Nvnflinger::GetNextTicks() const {
|
||||
speed_scale = 0.01f;
|
||||
}
|
||||
}
|
||||
|
||||
// Adjust by speed limit determined during composition.
|
||||
speed_scale /= compose_speed_scale;
|
||||
|
||||
if (system.GetNVDECActive() && settings.use_video_framerate.GetValue()) {
|
||||
// Run at intended presentation rate during video playback.
|
||||
speed_scale = 1.f;
|
||||
}
|
||||
|
||||
// As an extension, treat nonpositive swap interval as framerate multiplier.
|
||||
const f32 effective_fps = swap_interval <= 0 ? 120.f * static_cast<f32>(1 - swap_interval)
|
||||
: 60.f / static_cast<f32>(swap_interval);
|
||||
|
||||
const f32 effective_fps = 60.f / static_cast<f32>(swap_interval);
|
||||
return static_cast<s64>(speed_scale * (1000000000.f / effective_fps));
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ class BufferQueueProducer;
|
||||
namespace Service::Nvnflinger {
|
||||
|
||||
class FbShareBufferManager;
|
||||
class HardwareComposer;
|
||||
class HosBinderDriverServer;
|
||||
|
||||
class Nvnflinger final {
|
||||
@@ -143,6 +144,7 @@ private:
|
||||
u32 next_buffer_queue_id = 1;
|
||||
|
||||
s32 swap_interval = 1;
|
||||
f32 compose_speed_scale = 1.0f;
|
||||
|
||||
bool is_abandoned = false;
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "core/hle/service/nvnflinger/buffer_queue_consumer.h"
|
||||
#include "core/hle/service/nvnflinger/buffer_queue_core.h"
|
||||
#include "core/hle/service/nvnflinger/buffer_queue_producer.h"
|
||||
#include "core/hle/service/nvnflinger/hardware_composer.h"
|
||||
#include "core/hle/service/nvnflinger/hos_binder_driver_server.h"
|
||||
#include "core/hle/service/vi/display/vi_display.h"
|
||||
#include "core/hle/service/vi/layer/vi_layer.h"
|
||||
@@ -43,6 +44,7 @@ Display::Display(u64 id, std::string name_,
|
||||
KernelHelpers::ServiceContext& service_context_, Core::System& system_)
|
||||
: display_id{id}, name{std::move(name_)}, hos_binder_driver_server{hos_binder_driver_server_},
|
||||
service_context{service_context_} {
|
||||
hardware_composer = std::make_unique<Nvnflinger::HardwareComposer>();
|
||||
vsync_event = service_context.CreateEvent(fmt::format("Display VSync Event {}", id));
|
||||
}
|
||||
|
||||
@@ -81,8 +83,6 @@ void Display::SignalVSyncEvent() {
|
||||
|
||||
void Display::CreateLayer(u64 layer_id, u32 binder_id,
|
||||
Service::Nvidia::NvCore::Container& nv_core) {
|
||||
ASSERT_MSG(layers.empty(), "Only one layer is supported per display at the moment");
|
||||
|
||||
auto [core, producer, consumer] = CreateBufferQueue(service_context, nv_core.GetNvMapFile());
|
||||
|
||||
auto buffer_item_consumer = std::make_shared<android::BufferItemConsumer>(std::move(consumer));
|
||||
|
||||
@@ -11,9 +11,14 @@
|
||||
#include "common/common_types.h"
|
||||
#include "core/hle/result.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Kernel {
|
||||
class KEvent;
|
||||
}
|
||||
class KReadableEvent;
|
||||
} // namespace Kernel
|
||||
|
||||
namespace Service::android {
|
||||
class BufferQueueProducer;
|
||||
@@ -24,8 +29,9 @@ class ServiceContext;
|
||||
}
|
||||
|
||||
namespace Service::Nvnflinger {
|
||||
class HardwareComposer;
|
||||
class HosBinderDriverServer;
|
||||
}
|
||||
} // namespace Service::Nvnflinger
|
||||
|
||||
namespace Service::Nvidia::NvCore {
|
||||
class Container;
|
||||
@@ -118,6 +124,10 @@ public:
|
||||
///
|
||||
const Layer* FindLayer(u64 layer_id) const;
|
||||
|
||||
Nvnflinger::HardwareComposer& GetComposer() const {
|
||||
return *hardware_composer;
|
||||
}
|
||||
|
||||
private:
|
||||
u64 display_id;
|
||||
std::string name;
|
||||
@@ -125,6 +135,7 @@ private:
|
||||
KernelHelpers::ServiceContext& service_context;
|
||||
|
||||
std::vector<std::unique_ptr<Layer>> layers;
|
||||
std::unique_ptr<Nvnflinger::HardwareComposer> hardware_composer;
|
||||
Kernel::KEvent* vsync_event{};
|
||||
bool is_abandoned{};
|
||||
};
|
||||
|
||||
@@ -195,8 +195,9 @@ private:
|
||||
void GetSharedBufferMemoryHandleId(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const u64 buffer_id = rp.PopRaw<u64>();
|
||||
const u64 aruid = ctx.GetPID();
|
||||
|
||||
LOG_INFO(Service_VI, "called. buffer_id={:#x}", buffer_id);
|
||||
LOG_INFO(Service_VI, "called. buffer_id={:#x}, aruid={:#x}", buffer_id, aruid);
|
||||
|
||||
struct OutputParameters {
|
||||
s32 nvmap_handle;
|
||||
@@ -206,7 +207,7 @@ private:
|
||||
OutputParameters out{};
|
||||
Nvnflinger::SharedMemoryPoolLayout layout{};
|
||||
const auto result = nvnflinger.GetSystemBufferManager().GetSharedBufferMemoryHandleId(
|
||||
&out.size, &out.nvmap_handle, &layout, buffer_id, 0);
|
||||
&out.size, &out.nvmap_handle, &layout, buffer_id, aruid);
|
||||
|
||||
ctx.WriteBuffer(&layout, sizeof(layout));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user