DRM_IOCTL_DEF_DRV(ROCKCHIP_GEM_CPU_RELEASE,
rockchip_gem_cpu_release_ioctl,
DRM_UNLOCKED | DRM_AUTH | DRM_RENDER_ALLOW),
+ DRM_IOCTL_DEF_DRV(ROCKCHIP_GEM_GET_PHYS, rockchip_gem_get_phys_ioctl,
+ DRM_UNLOCKED | DRM_AUTH | DRM_RENDER_ALLOW),
};
static const struct file_operations rockchip_drm_driver_fops = {
&args->offset);
}
+int rockchip_gem_get_phys_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file_priv)
+{
+ struct drm_rockchip_gem_phys *args = data;
+ struct rockchip_gem_object *rk_obj;
+ struct drm_gem_object *obj;
+
+ obj = drm_gem_object_lookup(dev, file_priv, args->handle);
+ if (!obj) {
+ DRM_ERROR("failed to lookup gem object.\n");
+ return -EINVAL;
+ }
+ rk_obj = to_rockchip_obj(obj);
+
+ if (!(rk_obj->flags & ROCKCHIP_BO_CONTIG)) {
+ DRM_ERROR("Can't get phys address from non-continus buf.\n");
+ return -EINVAL;
+ }
+
+ args->phy_addr = page_to_phys(rk_obj->pages[0]);
+
+ return 0;
+}
+
int rockchip_gem_create_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
int rockchip_gem_map_offset_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
+int rockchip_gem_get_phys_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file_priv);
+
/*
* acquire gem object for CPU access.
*/
uint32_t handle;
};
+struct drm_rockchip_gem_phys {
+ uint32_t handle;
+ uint32_t phy_addr;
+};
+
/**
* A structure for getting buffer offset.
*
#define DRM_ROCKCHIP_GEM_MAP_OFFSET 0x01
#define DRM_ROCKCHIP_GEM_CPU_ACQUIRE 0x02
#define DRM_ROCKCHIP_GEM_CPU_RELEASE 0x03
+#define DRM_ROCKCHIP_GEM_GET_PHYS 0x04
#define DRM_ROCKCHIP_RGA_GET_VER 0x20
#define DRM_ROCKCHIP_RGA_SET_CMDLIST 0x21
#define DRM_IOCTL_ROCKCHIP_GEM_CPU_RELEASE DRM_IOWR(DRM_COMMAND_BASE + \
DRM_ROCKCHIP_GEM_CPU_RELEASE, struct drm_rockchip_gem_cpu_release)
+#define DRM_IOCTL_ROCKCHIP_GEM_GET_PHYS DRM_IOWR(DRM_COMMAND_BASE + \
+ DRM_ROCKCHIP_GEM_GET_PHYS, struct drm_rockchip_gem_phys)
+
#define DRM_IOCTL_ROCKCHIP_RGA_GET_VER DRM_IOWR(DRM_COMMAND_BASE + \
DRM_ROCKCHIP_RGA_GET_VER, struct drm_rockchip_rga_get_ver)