skyline/app/src/main/cpp/skyline/services/nvdrv/driver.h
PixelyIon fe5061a8e0 Address CR Comments (#132) + Change Core Migration API
This addresses all CR comments including more codebase-wide changes arising from certain review comments like proper usage of its/it's and consistent contraction of it is into it's. 

An overhaul was made to the presentation and formatting of `KThread.h` and `LoadBalance` works has been superseded by `GetOptimalCoreForThread` which can be used alongside `InsertThread` or `MigrateToCore`. It makes the API far more atomic and neater. This was a major point of contention for the design prior, it's simplified some code and potentially improved performance.
2021-03-05 14:55:34 +05:30

77 lines
2.7 KiB
C++

// SPDX-License-Identifier: MPL-2.0
// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
#pragma once
#include "devices/nvhost_syncpoint.h"
#define NVDEVICE_LIST \
NVDEVICE(NvHostCtrl, nvHostCtrl, "/dev/nvhost-ctrl") \
NVDEVICE(NvHostChannel, nvHostGpu, "/dev/nvhost-gpu") \
NVDEVICE(NvHostChannel, nvHostNvdec, "/dev/nvhost-nvdec") \
NVDEVICE(NvHostChannel, nvHostVic, "/dev/nvhost-vic") \
NVDEVICE(NvMap, nvMap, "/dev/nvmap") \
NVDEVICE(NvHostAsGpu, nvHostAsGpu, "/dev/nvhost-as-gpu") \
NVDEVICE(NvHostCtrlGpu, nvHostCtrlGpu, "/dev/nvhost-ctrl-gpu")
namespace skyline::service::nvdrv {
namespace device {
class NvDevice;
#define NVDEVICE(type, name, path) class type;
NVDEVICE_LIST
#undef NVDEVICE
}
/**
* @brief nvnflinger:dispdrv or nns::hosbinder::IHOSBinderDriver is responsible for writing buffers to the display
*/
class Driver {
private:
const DeviceState &state;
std::vector<std::shared_ptr<device::NvDevice>> devices; //!< A vector of shared pointers to NvDevice object that correspond to FDs
u32 fdIndex{}; //!< The next file descriptor to assign
public:
NvHostSyncpoint hostSyncpoint;
#define NVDEVICE(type, name, path) std::weak_ptr<device::type> name;
NVDEVICE_LIST
#undef NVDEVICE
Driver(const DeviceState &state);
/**
* @brief Open a specific device and return a FD
* @param path The path of the device to open an FD to
* @return The file descriptor to the device
*/
u32 OpenDevice(std::string_view path);
/**
* @brief Returns a particular device with a specific FD
* @param fd The file descriptor to retrieve
* @return A shared pointer to the device
*/
std::shared_ptr<device::NvDevice> GetDevice(u32 fd);
/**
* @brief Returns a particular device with a specific FD
* @tparam objectClass The class of the device to return
* @param fd The file descriptor to retrieve
* @return A shared pointer to the device
*/
template<typename objectClass>
inline std::shared_ptr<objectClass> GetDevice(u32 fd) {
return std::static_pointer_cast<objectClass>(GetDevice(fd));
}
/**
* @brief Closes the specified device with its file descriptor
*/
void CloseDevice(u32 fd);
};
extern std::weak_ptr<Driver> driver; //!< A globally shared instance of the Driver
}