*/
#include <misc/trinity.h>
-#include <misc/npu_sched_ioctl.h>
#include <sys/ioctl.h>
#include <sys/fcntl.h>
* @param[in] dev_id device id
*/
TrinityVision2API::TrinityVision2API (int dev_id)
- : DriverAPI (dev_id), sched_dev_fd_ (-1), is_cuse_ (false) {
+ : DriverAPI (dev_id), is_cuse_ (false) {
int num_devs;
if (dev_id > max_num_devs) {
this->dev_id_ = -1;
return;
}
-
- /* Try to open a scheduler device */
- this->sched_dev_fd_ = ::open ("/dev/npusched", O_RDWR);
}
/** @brief destructor of emulation API driver */
TrinityVision2API::~TrinityVision2API () {
if (dev_fd_ >= 0)
::close (dev_fd_);
- if (sched_dev_fd_ >= 0)
- ::close (sched_dev_fd_);
}
int
if (input_config == nullptr)
return -EINVAL;
- if (sched_dev_fd_ >= 0) {
- struct npu_sched_ioctl_create_param param;
- struct npu_sched_ioctl_task_attribute task_attrib;
- struct npu_sched_ioctl_task_id task_id;
-
- param.id = getpid ();
- param.is_rt = false;
- param.nice_value = input_config->priority;
- param.num_subtasks = 1; /* FIXME */
-
- ret = ioctl (sched_dev_fd_, NPU_SCHED_CREATE_TASK, ¶m);
- if (ret != 0)
- return -errno;
-
- task_attrib.task_handle = param.handle;
- task_attrib.subtask_idx = 0;
- /* reference attributes from VD */
- task_attrib.wcet = 420000; /* worst-case execution time */
- task_attrib.deadline = 8000000;
- task_attrib.period = 32000000;
- task_attrib.yield = 10250000;
- ret = ioctl (sched_dev_fd_, NPU_SCHED_SET_TASK_ATTRIB, &task_attrib);
- if (ret != 0)
- return -errno;
-
- task_id.task_handle = param.handle;
- task_id.subtask_idx = 0;
- task_id.id = 0x0; /* FIXME */
- ret = ioctl (sched_dev_fd_, NPU_SCHED_SET_TASK_ID, &task_id);
- if (ret != 0)
- return -errno;
-
- ret = ioctl (sched_dev_fd_, NPU_SCHED_ACTIVATE_TASK, ¶m.handle);
- if (ret != 0)
- return -errno;
-
- input_config->task_handle = param.handle;
- }
-
/* translate dmabuf FDs to cuse-compatible ones */
if (is_cuse_) {
CuseElement *elem;
this->munmap (segt, PAGE_SIZE);
}
+ /**
+ * TODO: this value is an indicator whether to use VD NPU Scheduler.
+ * When VD NPU manager is available, set this value properly.
+ */
+ input_config->task_handle = UINT32_MAX;
+
ret = ioctl (this->getDeviceFD (), TRINITY_IOCTL_RUN_INPUT, input_config);
if (ret != 0)
return -errno;