summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanislav Vorobiov <s.vorobiov@samsung.com>2014-06-16 19:51:14 +0400
committerQuanxian Wang <quanxian.wang@intel.com>2014-10-15 12:07:07 +0800
commitc9a8bb234df83a94424ccf9371551a184c45e361 (patch)
tree973c330372c8bca8e6d20cc2b5537823ee84f44c
parent2c6eee194070ca9654e396b52edede99c8c4e35b (diff)
downloadlibdrm-c9a8bb234df83a94424ccf9371551a184c45e361.tar.gz
libdrm-c9a8bb234df83a94424ccf9371551a184c45e361.tar.bz2
libdrm-c9a8bb234df83a94424ccf9371551a184c45e361.zip
VIGS: Support DP memory
DP memory is used by some of the tizen gstreamer plugins, TBM and X.Org video driver. Its main purpose is to share GEM buffers between media decoding and presentation layers Change-Id: Ie377119b46d6033355bf6ce00adc01e36096742a Signed-off-by: Stanislav Vorobiov <s.vorobiov@samsung.com>
-rw-r--r--include/drm/vigs_drm.h43
-rw-r--r--vigs/Makefile.am2
-rw-r--r--vigs/vigs.c128
-rw-r--r--vigs/vigs.h25
4 files changed, 196 insertions, 2 deletions
diff --git a/include/drm/vigs_drm.h b/include/drm/vigs_drm.h
index 1694801d..7abf0433 100644
--- a/include/drm/vigs_drm.h
+++ b/include/drm/vigs_drm.h
@@ -33,7 +33,7 @@
/*
* Bump this whenever driver interface changes.
*/
-#define DRM_VIGS_DRIVER_VERSION 12
+#define DRM_VIGS_DRIVER_VERSION 13
/*
* Surface access flags.
@@ -42,6 +42,17 @@
#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;
@@ -140,6 +151,28 @@ struct drm_vigs_plane_set_zpos
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
@@ -156,6 +189,9 @@ struct drm_vigs_plane_set_zpos
#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 + \
@@ -187,4 +223,9 @@ struct drm_vigs_plane_set_zpos
#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
diff --git a/vigs/Makefile.am b/vigs/Makefile.am
index 195bbf31..03f7d351 100644
--- a/vigs/Makefile.am
+++ b/vigs/Makefile.am
@@ -12,7 +12,7 @@ AM_CFLAGS = \
libdrm_vigs_la_LTLIBRARIES = libdrm_vigs.la
libdrm_vigs_ladir = $(libdir)
-libdrm_vigs_la_LDFLAGS = -version-number 7:0:0 -no-undefined
+libdrm_vigs_la_LDFLAGS = -version-number 8:0:0 -no-undefined
libdrm_vigs_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
libdrm_vigs_la_SOURCES = vigs.c
diff --git a/vigs/vigs.c b/vigs/vigs.c
index 0e1a4181..36236f7a 100644
--- a/vigs/vigs.c
+++ b/vigs/vigs.c
@@ -673,3 +673,131 @@ int vigs_drm_plane_set_zpos(struct vigs_drm_device *dev,
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;
+}
diff --git a/vigs/vigs.h b/vigs/vigs.h
index 08300904..34e08db0 100644
--- a/vigs/vigs.h
+++ b/vigs/vigs.h
@@ -244,6 +244,31 @@ int vigs_drm_plane_set_zpos(struct vigs_drm_device *dev,
* @}
*/
+/*
+ * DP functions.
+ * @{
+ */
+
+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);
+
+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);
+
+/*
+ * @}
+ */
+
#ifdef __cplusplus
};
#endif /* __cplusplus */