/*
* Bump this whenever driver interface changes.
*/
-#define DRM_VIGS_DRIVER_VERSION 12
+#define DRM_VIGS_DRIVER_VERSION 13
/*
* Surface access flags.
#define DRM_VIGS_SAF_WRITE 2
#define DRM_VIGS_SAF_MASK 3
+/*
+ * Number of DP framebuffers.
+ */
+#define DRM_VIGS_NUM_DP_FB_BUF 4
+
+/*
+ * DP memory types.
+ */
+#define DRM_VIGS_DP_FB_Y 2
+#define DRM_VIGS_DP_FB_C 3
+
struct drm_vigs_get_protocol_version
{
uint32_t version;
int zpos;
};
+struct drm_vigs_dp_create_surface
+{
+ uint32_t dp_plane;
+ uint32_t dp_fb_buf;
+ uint32_t dp_mem_flag;
+ uint32_t width;
+ uint32_t height;
+ uint32_t stride;
+ uint32_t format;
+ uint32_t handle;
+ uint32_t size;
+ uint32_t id;
+};
+
+struct drm_vigs_dp_open_surface
+{
+ uint32_t dp_plane;
+ uint32_t dp_fb_buf;
+ uint32_t dp_mem_flag;
+ uint32_t handle;
+};
+
#define DRM_VIGS_GET_PROTOCOL_VERSION 0x00
#define DRM_VIGS_CREATE_SURFACE 0x01
#define DRM_VIGS_CREATE_EXECBUFFER 0x02
#define DRM_VIGS_FENCE_UNREF 0x0D
#define DRM_VIGS_PLANE_SET_ZPOS 0x0E
+#define DRM_VIGS_DP_CREATE_SURFACE 0x20
+#define DRM_VIGS_DP_OPEN_SURFACE 0x21
+
#define DRM_IOCTL_VIGS_GET_PROTOCOL_VERSION DRM_IOR(DRM_COMMAND_BASE + \
DRM_VIGS_GET_PROTOCOL_VERSION, struct drm_vigs_get_protocol_version)
#define DRM_IOCTL_VIGS_CREATE_SURFACE DRM_IOWR(DRM_COMMAND_BASE + \
#define DRM_IOCTL_VIGS_PLANE_SET_ZPOS DRM_IOW(DRM_COMMAND_BASE + \
DRM_VIGS_PLANE_SET_ZPOS, struct drm_vigs_plane_set_zpos)
+#define DRM_IOCTL_VIGS_DP_CREATE_SURFACE DRM_IOWR(DRM_COMMAND_BASE + \
+ DRM_VIGS_DP_CREATE_SURFACE, struct drm_vigs_dp_create_surface)
+#define DRM_IOCTL_VIGS_DP_OPEN_SURFACE DRM_IOWR(DRM_COMMAND_BASE + \
+ DRM_VIGS_DP_OPEN_SURFACE, struct drm_vigs_dp_open_surface)
+
#endif
return (ret != 0) ? -errno : 0;
}
+
+int vigs_drm_dp_surface_create(struct vigs_drm_device *dev,
+ uint32_t dp_plane,
+ uint32_t dp_fb_buf,
+ uint32_t dp_mem_flag,
+ uint32_t width,
+ uint32_t height,
+ uint32_t stride,
+ uint32_t format,
+ struct vigs_drm_surface **sfc)
+{
+ struct vigs_drm_surface_impl *sfc_impl;
+ struct drm_vigs_dp_create_surface req =
+ {
+ .dp_plane = dp_plane,
+ .dp_fb_buf = dp_fb_buf,
+ .dp_mem_flag = dp_mem_flag,
+ .width = width,
+ .height = height,
+ .stride = stride,
+ .format = format,
+ };
+ int ret;
+
+ sfc_impl = calloc(sizeof(*sfc_impl), 1);
+
+ if (!sfc_impl) {
+ ret = -ENOMEM;
+ goto fail1;
+ }
+
+ ret = drmIoctl(dev->fd, DRM_IOCTL_VIGS_DP_CREATE_SURFACE, &req);
+
+ if (ret != 0) {
+ ret = -errno;
+ goto fail2;
+ }
+
+ vigs_drm_gem_impl_init((struct vigs_drm_gem_impl*)sfc_impl,
+ dev,
+ req.handle,
+ req.size,
+ 0);
+
+ sfc_impl->base.width = width;
+ sfc_impl->base.height = height;
+ sfc_impl->base.stride = stride;
+ sfc_impl->base.format = format;
+ sfc_impl->base.scanout = 0;
+ sfc_impl->base.id = req.id;
+
+ *sfc = &sfc_impl->base;
+
+ return 0;
+
+fail2:
+ free(sfc_impl);
+fail1:
+ *sfc = NULL;
+
+ return ret;
+}
+
+int vigs_drm_dp_surface_open(struct vigs_drm_device *dev,
+ uint32_t dp_plane,
+ uint32_t dp_fb_buf,
+ uint32_t dp_mem_flag,
+ struct vigs_drm_surface **sfc)
+{
+ struct vigs_drm_surface_impl *sfc_impl;
+ struct drm_vigs_dp_open_surface req =
+ {
+ .dp_plane = dp_plane,
+ .dp_fb_buf = dp_fb_buf,
+ .dp_mem_flag = dp_mem_flag
+ };
+ struct drm_vigs_surface_info info_req;
+ int ret;
+
+ sfc_impl = calloc(sizeof(*sfc_impl), 1);
+
+ if (!sfc_impl) {
+ ret = -ENOMEM;
+ goto fail1;
+ }
+
+ ret = drmIoctl(dev->fd, DRM_IOCTL_VIGS_DP_OPEN_SURFACE, &req);
+
+ if (ret != 0) {
+ ret = -errno;
+ goto fail2;
+ }
+
+ info_req.handle = req.handle;
+
+ ret = drmIoctl(dev->fd, DRM_IOCTL_VIGS_SURFACE_INFO, &info_req);
+
+ if (ret != 0) {
+ ret = -errno;
+ goto fail3;
+ }
+
+ vigs_drm_gem_impl_init((struct vigs_drm_gem_impl*)sfc_impl,
+ dev,
+ req.handle,
+ info_req.size,
+ 0);
+
+ sfc_impl->base.width = info_req.width;
+ sfc_impl->base.height = info_req.height;
+ sfc_impl->base.stride = info_req.stride;
+ sfc_impl->base.format = info_req.format;
+ sfc_impl->base.scanout = info_req.scanout;
+ sfc_impl->base.id = info_req.id;
+
+ *sfc = &sfc_impl->base;
+
+ return 0;
+
+fail3:
+ vigs_drm_gem_close(dev, req.handle);
+fail2:
+ free(sfc_impl);
+fail1:
+ *sfc = NULL;
+
+ return ret;
+}