Skip to content
Snippets Groups Projects
Commit ed80b2ab authored by Alexandre Bailon's avatar Alexandre Bailon
Browse files

Add a function to check the state of the APU


The driver creates the device before that the firmware is loaded
so we must check that the firmware is loaded and the APU is operational
before trying to use it.

Signed-off-by: default avatarAlexandre Bailon <abailon@baylibre.com>
parent 7f9b20eb
No related branches found
No related tags found
No related merge requests found
......@@ -623,3 +623,18 @@ int apu_dequeue_result(struct apu_drm_job *job, uint16_t *result,
return 0;
}
drm_public int apu_device_online(struct apu_drm_device *dev)
{
int ret;
struct drm_apu_state req = {
.device = dev->device_id,
};
ret = drmCommandWriteRead(dev->fd, DRM_APU_STATE, &req, sizeof(req));
if (ret)
return ret;
return req.flags & APU_ONLINE;
}
......@@ -69,23 +69,35 @@ struct drm_apu_gem_iommu_map {
uint64_t bo_device_addresses;
};
struct apu_job_event {
struct drm_event base;
uint32_t out_sync;
};
#define APU_ONLINE 1
#define APU_CRASHED 2
#define APU_TIMEDOUT 4
struct drm_apu_state {
uint32_t device;
uint32_t flags;
};
#define DRM_APU_GEM_NEW 0x00
#define DRM_APU_GEM_QUEUE 0x01
#define DRM_APU_GEM_DEQUEUE 0x02
#define DRM_APU_GEM_IOMMU_MAP 0x03
#define DRM_APU_GEM_IOMMU_UNMAP 0x04
#define DRM_APU_NUM_IOCTLS 0x05
#define DRM_APU_STATE 0x05
#define DRM_APU_NUM_IOCTLS 0x06
#define DRM_IOCTL_APU_GEM_NEW DRM_IOWR(DRM_COMMAND_BASE + DRM_APU_GEM_NEW, struct drm_apu_gem_new)
#define DRM_IOCTL_APU_GEM_QUEUE DRM_IOWR(DRM_COMMAND_BASE + DRM_APU_GEM_QUEUE, struct drm_apu_gem_queue)
#define DRM_IOCTL_APU_GEM_DEQUEUE DRM_IOWR(DRM_COMMAND_BASE + DRM_APU_GEM_DEQUEUE, struct drm_apu_gem_dequeue)
#define DRM_IOCTL_APU_GEM_IOMMU_MAP DRM_IOWR(DRM_COMMAND_BASE + DRM_APU_GEM_IOMMU_MAP, struct drm_apu_gem_iommu_map)
#define DRM_IOCTL_APU_GEM_IOMMU_UNMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_APU_GEM_IOMMU_UNMAP, struct drm_apu_gem_iommu_map)
#define DRM_IOCTL_APU_STATE DRM_IOWR(DRM_COMMAND_BASE + DRM_APU_STATE, struct drm_apu_state)
#if defined(__cplusplus)
}
......
......@@ -69,5 +69,6 @@ int apu_bo_iommu_map(struct apu_drm_device *dev,
int apu_bo_iommu_unmap(
struct apu_drm_device *dev,
struct apu_bo **bos, uint32_t count);
int apu_device_online(struct apu_drm_device *dev);
#endif /* APU_DRMIF_H_ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment