[RFC PATCH v3 3/4] ipvr: user mode helper for ipvr drm driver

2014-12-01 Thread Cheng, Yao
Add Jon/Bob/Raf for detail review.
> -Original Message-
> From: Cheng, Yao
> Sent: Saturday, November 22, 2014 3:09
> To: intel-gfx at lists.freedesktop.org; dri-devel at lists.freedesktop.org;
> daniel.vetter at ffwll.ch; Kelley, Sean V; Chehab, John
> Cc: Jiang, Fei; dh.herrmann at gmail.com; jani.nikula at linux.intel.com;
> emil.l.velikov at gmail.com; ville.syrjala at linux.intel.com;
> jbarnes at virtuousgeek.org; daniel at fooishbar.org; Cheng, Yao
> Subject: [RFC PATCH v3 3/4] ipvr: user mode helper for ipvr drm driver
> 
> add usermode helper for the ipvr kernel driver.
> test_ioctl: test kernel driver by directly ioctl
> 
> v2:
> take Emil's comments
>   - correctly align ipvr_drm.h
> 
> v3:
> take Daniel Vetter and Daniel Stone's comments, and implement PRIME
>   - correctly align ipvr_drm.h
>   - use __u32 family in ipvr_drm.h
>   - rip out explicit fence from libdrm_ipvr
>   - implemented PRIME support
>   - add relocation fixup implementation
> 
> Signed-off-by: Yao Cheng 
> ---
>  Makefile.am|6 +-
>  Makefile.sources   |1 +
>  configure.ac   |   26 +-
>  include/drm/ipvr_drm.h |  278 +++
>  ipvr/Makefile.am   |   57 +++
>  ipvr/Makefile.sources  |5 +
>  ipvr/ipvr_bufmgr.h |  149 ++
>  ipvr/ipvr_bufmgr_gem.c | 1200
> 
>  ipvr/libdrm_ipvr.pc.in |   11 +
>  ipvr/test_ioctl.c  |  423 +
>  10 files changed, 2154 insertions(+), 2 deletions(-)
>  create mode 100644 include/drm/ipvr_drm.h
>  create mode 100644 ipvr/Makefile.am
>  create mode 100644 ipvr/Makefile.sources
>  create mode 100644 ipvr/ipvr_bufmgr.h
>  create mode 100644 ipvr/ipvr_bufmgr_gem.c
>  create mode 100644 ipvr/libdrm_ipvr.pc.in
>  create mode 100644 ipvr/test_ioctl.c
> 
> diff --git a/Makefile.am b/Makefile.am
> index 3952a88..2227add 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -33,6 +33,10 @@ if HAVE_INTEL
>  INTEL_SUBDIR = intel
>  endif
> 
> +if HAVE_IPVR
> +IPVR_SUBDIR = ipvr
> +endif
> +
>  if HAVE_NOUVEAU
>  NOUVEAU_SUBDIR = nouveau
>  endif
> @@ -53,7 +57,7 @@ if HAVE_FREEDRENO
>  FREEDRENO_SUBDIR = freedreno
>  endif
> 
> -SUBDIRS = . $(LIBKMS_SUBDIR) $(INTEL_SUBDIR) $(NOUVEAU_SUBDIR)
> $(RADEON_SUBDIR) $(OMAP_SUBDIR) $(EXYNOS_SUBDIR)
> $(FREEDRENO_SUBDIR) tests man
> +SUBDIRS = . $(LIBKMS_SUBDIR) $(INTEL_SUBDIR) $(IPVR_SUBDIR)
> $(NOUVEAU_SUBDIR) $(RADEON_SUBDIR) $(OMAP_SUBDIR)
> $(EXYNOS_SUBDIR) $(FREEDRENO_SUBDIR) tests man
> 
>  libdrm_la_LTLIBRARIES = libdrm.la
>  libdrm_ladir = $(libdir)
> diff --git a/Makefile.sources b/Makefile.sources
> index d86fb2a..96f8c60 100644
> --- a/Makefile.sources
> +++ b/Makefile.sources
> @@ -18,6 +18,7 @@ LIBDRM_INCLUDE_H_FILES := \
>   include/drm/drm_mode.h \
>   include/drm/drm_sarea.h \
>   include/drm/i915_drm.h \
> + include/drm/ipvr_drm.h \
>   include/drm/mach64_drm.h \
>   include/drm/mga_drm.h \
>   include/drm/nouveau_drm.h \
> diff --git a/configure.ac b/configure.ac
> index ee59b03..6dcf1b2 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -68,6 +68,11 @@ AC_ARG_ENABLE(intel,
> [Enable support for intel's KMS API (default: auto)]),
> [INTEL=$enableval], [INTEL=auto])
> 
> +AC_ARG_ENABLE(ipvr,
> +   AS_HELP_STRING([--disable-ipvr],
> +   [Enable support for baytrail's hardware VP8 decode (default:
> auto)]),
> +   [IPVR=$enableval], [IPVR=auto])
> +
>  AC_ARG_ENABLE(radeon,
> AS_HELP_STRING([--disable-radeon],
> [Enable support for radeon's KMS API (default: auto)]),
> @@ -204,7 +209,7 @@ if test "x$drm_cv_atomic_primitives" = "xlibatomic-
> ops"; then
>   AC_DEFINE(HAVE_LIB_ATOMIC_OPS, 1, [Enable if you have
> libatomic-ops-dev installed])
>  fi
> 
> -if test "x$INTEL" != "xno" -o "x$RADEON" != "xno" -o "x$NOUVEAU" !=
> "xno"; then
> +if test "x$INTEL" != "xno" -o "x$IPVR" != "xno" -o "x$RADEON" != "xno" -o
> "x$NOUVEAU" != "xno"; then
>   if test "x$drm_cv_atomic_primitives" = "xnone"; then
>   if test "x$INTEL" != "xauto"; then
>   if test "x$INTEL" != "xno"; then
> @@ -214,6 +219,14 @@ if test "x$INTEL" != "xno" -o "x$RADEON" != "xno" -o
> "x$NOUVEAU" != "xno"; then
>   AC_MSG_WARN([Disabling libdrm_intel

[RFC PATCH v3 3/4] ipvr: user mode helper for ipvr drm driver

2014-11-22 Thread Yao Cheng
add usermode helper for the ipvr kernel driver.
test_ioctl: test kernel driver by directly ioctl

v2:
take Emil's comments
- correctly align ipvr_drm.h

v3:
take Daniel Vetter and Daniel Stone's comments, and implement PRIME
- correctly align ipvr_drm.h
- use __u32 family in ipvr_drm.h
- rip out explicit fence from libdrm_ipvr
- implemented PRIME support
- add relocation fixup implementation

Signed-off-by: Yao Cheng 
---
 Makefile.am|6 +-
 Makefile.sources   |1 +
 configure.ac   |   26 +-
 include/drm/ipvr_drm.h |  278 +++
 ipvr/Makefile.am   |   57 +++
 ipvr/Makefile.sources  |5 +
 ipvr/ipvr_bufmgr.h |  149 ++
 ipvr/ipvr_bufmgr_gem.c | 1200 
 ipvr/libdrm_ipvr.pc.in |   11 +
 ipvr/test_ioctl.c  |  423 +
 10 files changed, 2154 insertions(+), 2 deletions(-)
 create mode 100644 include/drm/ipvr_drm.h
 create mode 100644 ipvr/Makefile.am
 create mode 100644 ipvr/Makefile.sources
 create mode 100644 ipvr/ipvr_bufmgr.h
 create mode 100644 ipvr/ipvr_bufmgr_gem.c
 create mode 100644 ipvr/libdrm_ipvr.pc.in
 create mode 100644 ipvr/test_ioctl.c

diff --git a/Makefile.am b/Makefile.am
index 3952a88..2227add 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -33,6 +33,10 @@ if HAVE_INTEL
 INTEL_SUBDIR = intel
 endif

+if HAVE_IPVR
+IPVR_SUBDIR = ipvr
+endif
+
 if HAVE_NOUVEAU
 NOUVEAU_SUBDIR = nouveau
 endif
@@ -53,7 +57,7 @@ if HAVE_FREEDRENO
 FREEDRENO_SUBDIR = freedreno
 endif

-SUBDIRS = . $(LIBKMS_SUBDIR) $(INTEL_SUBDIR) $(NOUVEAU_SUBDIR) 
$(RADEON_SUBDIR) $(OMAP_SUBDIR) $(EXYNOS_SUBDIR) $(FREEDRENO_SUBDIR) tests man
+SUBDIRS = . $(LIBKMS_SUBDIR) $(INTEL_SUBDIR) $(IPVR_SUBDIR) $(NOUVEAU_SUBDIR) 
$(RADEON_SUBDIR) $(OMAP_SUBDIR) $(EXYNOS_SUBDIR) $(FREEDRENO_SUBDIR) tests man

 libdrm_la_LTLIBRARIES = libdrm.la
 libdrm_ladir = $(libdir)
diff --git a/Makefile.sources b/Makefile.sources
index d86fb2a..96f8c60 100644
--- a/Makefile.sources
+++ b/Makefile.sources
@@ -18,6 +18,7 @@ LIBDRM_INCLUDE_H_FILES := \
include/drm/drm_mode.h \
include/drm/drm_sarea.h \
include/drm/i915_drm.h \
+   include/drm/ipvr_drm.h \
include/drm/mach64_drm.h \
include/drm/mga_drm.h \
include/drm/nouveau_drm.h \
diff --git a/configure.ac b/configure.ac
index ee59b03..6dcf1b2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -68,6 +68,11 @@ AC_ARG_ENABLE(intel,
  [Enable support for intel's KMS API (default: auto)]),
  [INTEL=$enableval], [INTEL=auto])

+AC_ARG_ENABLE(ipvr,
+ AS_HELP_STRING([--disable-ipvr],
+ [Enable support for baytrail's hardware VP8 decode (default: 
auto)]),
+ [IPVR=$enableval], [IPVR=auto])
+
 AC_ARG_ENABLE(radeon,
  AS_HELP_STRING([--disable-radeon],
  [Enable support for radeon's KMS API (default: auto)]),
@@ -204,7 +209,7 @@ if test "x$drm_cv_atomic_primitives" = "xlibatomic-ops"; 
then
AC_DEFINE(HAVE_LIB_ATOMIC_OPS, 1, [Enable if you have libatomic-ops-dev 
installed])
 fi

-if test "x$INTEL" != "xno" -o "x$RADEON" != "xno" -o "x$NOUVEAU" != "xno"; then
+if test "x$INTEL" != "xno" -o "x$IPVR" != "xno" -o "x$RADEON" != "xno" -o 
"x$NOUVEAU" != "xno"; then
if test "x$drm_cv_atomic_primitives" = "xnone"; then
if test "x$INTEL" != "xauto"; then
if test "x$INTEL" != "xno"; then
@@ -214,6 +219,14 @@ if test "x$INTEL" != "xno" -o "x$RADEON" != "xno" -o 
"x$NOUVEAU" != "xno"; then
AC_MSG_WARN([Disabling libdrm_intel. It depends on 
atomic operations, which were not found for your compiler/cpu. Try compiling 
with -march=native, or install the libatomics-op-dev package.])
INTEL=no
fi
+   if test "x$IPVR" != "xauto"; then
+   if test "x$IPVR" != "xno"; then
+   AC_MSG_ERROR([libdrm_ipvr depends upon atomic 
operations, which were not found for your compiler/cpu. Try compiling with 
-march=native, or install the libatomics-op-dev package, or, failing both of 
those, disable support for Baytrail VP8 by passing --disable-ipvr to 
./configure])
+   fi
+   else
+   AC_MSG_WARN([Disabling libdrm_ipvr. It depends on 
atomic operations, which were not found for your compiler/cpu. Try compiling 
with -march=native, or install the libatomics-op-dev package.])
+   INTEL=no
+   fi
if test "x$RADEON" != "xauto"; then
if test "x$RADEON" != "xno"; then
AC_MSG_ERROR([libdrm_radeon depends upon atomic 
operations, which were not found for your compiler/cpu. Try compiling with 
-march=native, or install the libatomics-op-dev package, or, failing both of 
those, disable support for Radeon GPUs by passing