[RFC libdrm] Add NVIDIA Tegra support

2012-12-05 Thread Arto Merilainen
On 12/04/2012 05:13 PM, Thierry Reding wrote:
> +int drm_tegra_open(const char *path, struct drm_tegra **devicep)
> +{
> +   struct drm_tegra *device;
> +   int err;
> +
> +   if (!path || !devicep)
> +   return -EINVAL;
> +
> +   device = calloc(1, sizeof(*device));
> +   if (!device)
> +   return -ENOMEM;
> +
> +   DRMINITLISTHEAD(>bo_list);
> +
> +   device->fd = open(path, O_RDWR);
> +   if (device->fd < 0) {
> +   err = -errno;
> +   free(device);
> +   return err;
> +   }
> +
> +   *devicep = device;
> +
> +   return 0;
> +}

I think you shouldn't ask the path from the application (=DDX) here, but 
use drmOpen() that automatically finds the correct device for you.

I'd also prefer letting the application open and close the device and 
modify drm_tegra_open() to take the fd as a parameter. That way the DDX 
could easily access also all generic libdrm functions.

- Arto


[RFC libdrm] Add NVIDIA Tegra support

2012-12-05 Thread Thierry Reding
On Wed, Dec 05, 2012 at 09:39:11AM +0200, Arto Merilainen wrote:
> On 12/04/2012 05:13 PM, Thierry Reding wrote:
> >+int drm_tegra_open(const char *path, struct drm_tegra **devicep)
> >+{
> >+   struct drm_tegra *device;
> >+   int err;
> >+
> >+   if (!path || !devicep)
> >+   return -EINVAL;
> >+
> >+   device = calloc(1, sizeof(*device));
> >+   if (!device)
> >+   return -ENOMEM;
> >+
> >+   DRMINITLISTHEAD(>bo_list);
> >+
> >+   device->fd = open(path, O_RDWR);
> >+   if (device->fd < 0) {
> >+   err = -errno;
> >+   free(device);
> >+   return err;
> >+   }
> >+
> >+   *devicep = device;
> >+
> >+   return 0;
> >+}
> 
> I think you shouldn't ask the path from the application (=DDX) here,
> but use drmOpen() that automatically finds the correct device for
> you.
> 
> I'd also prefer letting the application open and close the device
> and modify drm_tegra_open() to take the fd as a parameter. That way
> the DDX could easily access also all generic libdrm functions.

Good points, I'll take those into account.

Thanks,
Thierry
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: 



Re: [RFC libdrm] Add NVIDIA Tegra support

2012-12-05 Thread Arto Merilainen

On 12/04/2012 05:13 PM, Thierry Reding wrote:

+int drm_tegra_open(const char *path, struct drm_tegra **devicep)
+{
+   struct drm_tegra *device;
+   int err;
+
+   if (!path || !devicep)
+   return -EINVAL;
+
+   device = calloc(1, sizeof(*device));
+   if (!device)
+   return -ENOMEM;
+
+   DRMINITLISTHEAD(device-bo_list);
+
+   device-fd = open(path, O_RDWR);
+   if (device-fd  0) {
+   err = -errno;
+   free(device);
+   return err;
+   }
+
+   *devicep = device;
+
+   return 0;
+}


I think you shouldn't ask the path from the application (=DDX) here, but 
use drmOpen() that automatically finds the correct device for you.


I'd also prefer letting the application open and close the device and 
modify drm_tegra_open() to take the fd as a parameter. That way the DDX 
could easily access also all generic libdrm functions.


- Arto
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[RFC libdrm] Add NVIDIA Tegra support

2012-12-04 Thread Thierry Reding
On Tue, Dec 04, 2012 at 09:28:25AM -0600, Rob Clark wrote:
> On Tue, Dec 4, 2012 at 9:13 AM, Thierry Reding
>  wrote:
> > +int drm_tegra_bo_new(struct drm_tegra *device, uint32_t flags, uint32_t 
> > size,
> > +struct drm_tegra_bo **bop)
> > +{
> > +   struct drm_tegra_gem_create args;
> > +   struct drm_tegra_bo *bo;
> > +   struct tegra_bo *priv;
> > +   int err;
> > +
> > +   if (!device || size == 0 || !bop)
> > +   return -EINVAL;
> > +
> > +   bo = calloc(1, sizeof(*bo));
> > +   if (!bo)
> > +   return -ENOMEM;
> > +
> > +   priv = tegra_bo(bo);
> > +
> > +   DRMLISTINITHEAD(>list);
> > +   atomic_set(>ref, 1);
> > +   bo->device = device;
> > +   bo->flags = flags;
> > +   bo->size = size;
> > +
> > +   memset(, 0, sizeof(args));
> > +   args.flags = flags;
> > +   args.size = size;
> > +
> > +   err = drmCommandWriteRead(device->fd, DRM_TEGRA_GEM_CREATE, ,
> > + sizeof(args));
> > +   if (err < 0) {
> > +   err = -errno;
> > +   free(bo);
> > +   return err;
> > +   }
> > +
> > +   DRMLISTADD(>list, >bo_list);
> > +   bo->handle = args.handle;
> > +   bo->offset = args.offset;
> 
> btw, x11 can rapidly create/destroy temporary pixmaps.. which don't
> necessarily need userspace access.  You might prefer to avoid creating
> mmap offset on GEM bo creation, and instead do this only if userspace
> needs to mmap the bo

Ah, so that's the reason for the MMAP IOCTL provided by other DRMs. Yes,
that might be better in the long run. For now I don't think it makes
much of a difference since the GEM objects are backed by CMA, and
therefore the offset will be created along with the GEM anyway.

With Terje's upcoming rework that handles all the allocations in host1x
this should become more important, especially when the mapping is done
through the Tegra30's IOMMU.

I'll rework that. Thanks for the quick reply.

Thierry
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: 



[RFC libdrm] Add NVIDIA Tegra support

2012-12-04 Thread Thierry Reding
Add the libdrm_tegra helper library to encapsulate Tegra-specific
interfaces to the DRM.

Furthermore, Tegra is added to the list of supported chips in the
modetest and vbltest programs.

Signed-off-by: Thierry Reding 
---
 Makefile.am   |   6 +-
 configure.ac  |  15 ++-
 include/drm/Makefile.am   |   1 +
 include/drm/tegra_drm.h   |  48 ++
 tegra/Makefile.am |  17 
 tegra/libdrm_tegra.pc.in  |  11 +++
 tegra/tegra.c | 227 ++
 tegra/tegra.h |  51 +++
 tests/modetest/modetest.c |   2 +-
 tests/vbltest/vbltest.c   |   2 +-
 10 files changed, 376 insertions(+), 4 deletions(-)
 create mode 100644 include/drm/tegra_drm.h
 create mode 100644 tegra/Makefile.am
 create mode 100644 tegra/libdrm_tegra.pc.in
 create mode 100644 tegra/tegra.c
 create mode 100644 tegra/tegra.h

diff --git a/Makefile.am b/Makefile.am
index 8ecd9d9..e90ae43 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -49,7 +49,11 @@ if HAVE_EXYNOS
 EXYNOS_SUBDIR = exynos
 endif

-SUBDIRS = . $(LIBKMS_SUBDIR) $(INTEL_SUBDIR) $(NOUVEAU_SUBDIR) 
$(RADEON_SUBDIR) $(OMAP_SUBDIR) $(EXYNOS_SUBDIR) tests include man
+if HAVE_TEGRA
+TEGRA_SUBDIR = tegra
+endif
+
+SUBDIRS = . $(LIBKMS_SUBDIR) $(INTEL_SUBDIR) $(NOUVEAU_SUBDIR) 
$(RADEON_SUBDIR) $(OMAP_SUBDIR) $(EXYNOS_SUBDIR) $(TEGRA_SUBDIR) tests include 
man

 libdrm_la_LTLIBRARIES = libdrm.la
 libdrm_ladir = $(libdir)
diff --git a/configure.ac b/configure.ac
index 0c19929..72d6dfa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -114,6 +114,11 @@ AC_ARG_ENABLE(exynos-experimental-api,
  [Enable support for EXYNOS's experimental API (default: 
disabled)]),
  [EXYNOS=$enableval], [EXYNOS=no])

+AC_ARG_ENABLE(tegra-experimental-api,
+ AS_HELP_STRING([--enable-tegra-experimental-api],
+ [Enable support for Tegra's experimental API (default: 
disabled)]),
+ [TEGRA=$enableval], [TEGRA=no])
+
 dnl ===
 dnl check compiler flags
 AC_DEFUN([LIBDRM_CC_TRY_FLAG], [
@@ -222,6 +227,11 @@ if test "x$EXYNOS" = xyes; then
AC_DEFINE(HAVE_EXYNOS, 1, [Have EXYNOS support])
 fi

+AM_CONDITIONAL(HAVE_TEGRA, [test "x$TEGRA" = xyes])
+if test "x$TEGRA" = xyes; then
+   AC_DEFINE(HAVE_TEGRA, 1, [Have Tegra support])
+fi
+
 AC_ARG_ENABLE([cairo-tests],
   [AS_HELP_STRING([--enable-cairo-tests],
   [Enable support for Cairo rendering in tests 
(default: auto)])],
@@ -247,7 +257,7 @@ if test "x$HAVE_LIBUDEV" = xyes; then
 fi
 AM_CONDITIONAL(HAVE_LIBUDEV, [test "x$HAVE_LIBUDEV" = xyes])

-if test "x$INTEL" != "xno" -o "x$RADEON" != "xno" -o "x$NOUVEAU" != "xno" -o 
"x$OMAP" != "xno"; then
+if test "x$INTEL" != "xno" -o "x$RADEON" != "xno" -o "x$NOUVEAU" != "xno" -o 
"x$OMAP" != "xno" -o "x$TEGRA" != "xno"; then
 # Check for atomic intrinsics
 AC_CACHE_CHECK([for native atomic primitives], drm_cv_atomic_primitives,
 [
@@ -358,6 +368,8 @@ AC_CONFIG_FILES([
omap/libdrm_omap.pc
exynos/Makefile
exynos/libdrm_exynos.pc
+   tegra/Makefile
+   tegra/libdrm_tegra.pc
tests/Makefile
tests/modeprint/Makefile
tests/modetest/Makefile
@@ -380,4 +392,5 @@ echo "  Radeon API $RADEON"
 echo "  Nouveau API$NOUVEAU"
 echo "  OMAP API   $OMAP"
 echo "  EXYNOS API $EXYNOS"
+echo "  Tegra API  $TEGRA"
 echo ""
diff --git a/include/drm/Makefile.am b/include/drm/Makefile.am
index 2923ab4..3e33ed0 100644
--- a/include/drm/Makefile.am
+++ b/include/drm/Makefile.am
@@ -35,6 +35,7 @@ klibdrminclude_HEADERS = \
radeon_drm.h \
savage_drm.h \
sis_drm.h \
+   tegra_drm.h \
via_drm.h \
mach64_drm.h

diff --git a/include/drm/tegra_drm.h b/include/drm/tegra_drm.h
new file mode 100644
index 000..eaec602
--- /dev/null
+++ b/include/drm/tegra_drm.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright ? 2012 Thierry Reding
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY 

[RFC libdrm] Add NVIDIA Tegra support

2012-12-04 Thread Thierry Reding
Hi,

I mentioned in a reply to Terje's patch series for 2D acceleration that
I had prototyped some libdrm support a few weeks back. I've spent a bit
of time cleaning it up and decided to post it for early review.

There's really not much interesting code here. A basic API is provided
along with two IOCTLs that can be used to create Tegra-specific GEM, as
opposed to dumb buffer objects. Given the various comments on Terje's
proposed IOCTLs I wanted to make sure that these will be safe. I've seen
that other chips use 64-bit fields for the size and offset of buffer
objects and I wonder if those are really necessary.

Linux kernel patches for the IOCTLs are also in the works and I hope to
get around to posting them this week. Obviously there will be some
overlap between this and what Terje posted in his series, but it should
be easy to synchronize.

Thierry

Thierry Reding (1):
  libdrm: Add NVIDIA Tegra support

 Makefile.am   |   6 +-
 configure.ac  |  15 ++-
 include/drm/Makefile.am   |   1 +
 include/drm/tegra_drm.h   |  48 ++
 tegra/Makefile.am |  17 
 tegra/libdrm_tegra.pc.in  |  11 +++
 tegra/tegra.c | 227 ++
 tegra/tegra.h |  51 +++
 tests/modetest/modetest.c |   2 +-
 tests/vbltest/vbltest.c   |   2 +-
 10 files changed, 376 insertions(+), 4 deletions(-)
 create mode 100644 include/drm/tegra_drm.h
 create mode 100644 tegra/Makefile.am
 create mode 100644 tegra/libdrm_tegra.pc.in
 create mode 100644 tegra/tegra.c
 create mode 100644 tegra/tegra.h

-- 
1.8.0.1



[RFC libdrm] Add NVIDIA Tegra support

2012-12-04 Thread Rob Clark
On Tue, Dec 4, 2012 at 9:13 AM, Thierry Reding
 wrote:
> +int drm_tegra_bo_new(struct drm_tegra *device, uint32_t flags, uint32_t size,
> +struct drm_tegra_bo **bop)
> +{
> +   struct drm_tegra_gem_create args;
> +   struct drm_tegra_bo *bo;
> +   struct tegra_bo *priv;
> +   int err;
> +
> +   if (!device || size == 0 || !bop)
> +   return -EINVAL;
> +
> +   bo = calloc(1, sizeof(*bo));
> +   if (!bo)
> +   return -ENOMEM;
> +
> +   priv = tegra_bo(bo);
> +
> +   DRMLISTINITHEAD(>list);
> +   atomic_set(>ref, 1);
> +   bo->device = device;
> +   bo->flags = flags;
> +   bo->size = size;
> +
> +   memset(, 0, sizeof(args));
> +   args.flags = flags;
> +   args.size = size;
> +
> +   err = drmCommandWriteRead(device->fd, DRM_TEGRA_GEM_CREATE, ,
> + sizeof(args));
> +   if (err < 0) {
> +   err = -errno;
> +   free(bo);
> +   return err;
> +   }
> +
> +   DRMLISTADD(>list, >bo_list);
> +   bo->handle = args.handle;
> +   bo->offset = args.offset;

btw, x11 can rapidly create/destroy temporary pixmaps.. which don't
necessarily need userspace access.  You might prefer to avoid creating
mmap offset on GEM bo creation, and instead do this only if userspace
needs to mmap the bo

BR,
-R

> +
> +   *bop = bo;
> +
> +   return 0;
> +}


[RFC libdrm] Add NVIDIA Tegra support

2012-12-04 Thread Thierry Reding
Hi,

I mentioned in a reply to Terje's patch series for 2D acceleration that
I had prototyped some libdrm support a few weeks back. I've spent a bit
of time cleaning it up and decided to post it for early review.

There's really not much interesting code here. A basic API is provided
along with two IOCTLs that can be used to create Tegra-specific GEM, as
opposed to dumb buffer objects. Given the various comments on Terje's
proposed IOCTLs I wanted to make sure that these will be safe. I've seen
that other chips use 64-bit fields for the size and offset of buffer
objects and I wonder if those are really necessary.

Linux kernel patches for the IOCTLs are also in the works and I hope to
get around to posting them this week. Obviously there will be some
overlap between this and what Terje posted in his series, but it should
be easy to synchronize.

Thierry

Thierry Reding (1):
  libdrm: Add NVIDIA Tegra support

 Makefile.am   |   6 +-
 configure.ac  |  15 ++-
 include/drm/Makefile.am   |   1 +
 include/drm/tegra_drm.h   |  48 ++
 tegra/Makefile.am |  17 
 tegra/libdrm_tegra.pc.in  |  11 +++
 tegra/tegra.c | 227 ++
 tegra/tegra.h |  51 +++
 tests/modetest/modetest.c |   2 +-
 tests/vbltest/vbltest.c   |   2 +-
 10 files changed, 376 insertions(+), 4 deletions(-)
 create mode 100644 include/drm/tegra_drm.h
 create mode 100644 tegra/Makefile.am
 create mode 100644 tegra/libdrm_tegra.pc.in
 create mode 100644 tegra/tegra.c
 create mode 100644 tegra/tegra.h

-- 
1.8.0.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[RFC libdrm] Add NVIDIA Tegra support

2012-12-04 Thread Thierry Reding
Add the libdrm_tegra helper library to encapsulate Tegra-specific
interfaces to the DRM.

Furthermore, Tegra is added to the list of supported chips in the
modetest and vbltest programs.

Signed-off-by: Thierry Reding thierry.red...@avionic-design.de
---
 Makefile.am   |   6 +-
 configure.ac  |  15 ++-
 include/drm/Makefile.am   |   1 +
 include/drm/tegra_drm.h   |  48 ++
 tegra/Makefile.am |  17 
 tegra/libdrm_tegra.pc.in  |  11 +++
 tegra/tegra.c | 227 ++
 tegra/tegra.h |  51 +++
 tests/modetest/modetest.c |   2 +-
 tests/vbltest/vbltest.c   |   2 +-
 10 files changed, 376 insertions(+), 4 deletions(-)
 create mode 100644 include/drm/tegra_drm.h
 create mode 100644 tegra/Makefile.am
 create mode 100644 tegra/libdrm_tegra.pc.in
 create mode 100644 tegra/tegra.c
 create mode 100644 tegra/tegra.h

diff --git a/Makefile.am b/Makefile.am
index 8ecd9d9..e90ae43 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -49,7 +49,11 @@ if HAVE_EXYNOS
 EXYNOS_SUBDIR = exynos
 endif
 
-SUBDIRS = . $(LIBKMS_SUBDIR) $(INTEL_SUBDIR) $(NOUVEAU_SUBDIR) 
$(RADEON_SUBDIR) $(OMAP_SUBDIR) $(EXYNOS_SUBDIR) tests include man
+if HAVE_TEGRA
+TEGRA_SUBDIR = tegra
+endif
+
+SUBDIRS = . $(LIBKMS_SUBDIR) $(INTEL_SUBDIR) $(NOUVEAU_SUBDIR) 
$(RADEON_SUBDIR) $(OMAP_SUBDIR) $(EXYNOS_SUBDIR) $(TEGRA_SUBDIR) tests include 
man
 
 libdrm_la_LTLIBRARIES = libdrm.la
 libdrm_ladir = $(libdir)
diff --git a/configure.ac b/configure.ac
index 0c19929..72d6dfa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -114,6 +114,11 @@ AC_ARG_ENABLE(exynos-experimental-api,
  [Enable support for EXYNOS's experimental API (default: 
disabled)]),
  [EXYNOS=$enableval], [EXYNOS=no])
 
+AC_ARG_ENABLE(tegra-experimental-api,
+ AS_HELP_STRING([--enable-tegra-experimental-api],
+ [Enable support for Tegra's experimental API (default: 
disabled)]),
+ [TEGRA=$enableval], [TEGRA=no])
+
 dnl ===
 dnl check compiler flags
 AC_DEFUN([LIBDRM_CC_TRY_FLAG], [
@@ -222,6 +227,11 @@ if test x$EXYNOS = xyes; then
AC_DEFINE(HAVE_EXYNOS, 1, [Have EXYNOS support])
 fi
 
+AM_CONDITIONAL(HAVE_TEGRA, [test x$TEGRA = xyes])
+if test x$TEGRA = xyes; then
+   AC_DEFINE(HAVE_TEGRA, 1, [Have Tegra support])
+fi
+
 AC_ARG_ENABLE([cairo-tests],
   [AS_HELP_STRING([--enable-cairo-tests],
   [Enable support for Cairo rendering in tests 
(default: auto)])],
@@ -247,7 +257,7 @@ if test x$HAVE_LIBUDEV = xyes; then
 fi
 AM_CONDITIONAL(HAVE_LIBUDEV, [test x$HAVE_LIBUDEV = xyes])
 
-if test x$INTEL != xno -o x$RADEON != xno -o x$NOUVEAU != xno -o 
x$OMAP != xno; then
+if test x$INTEL != xno -o x$RADEON != xno -o x$NOUVEAU != xno -o 
x$OMAP != xno -o x$TEGRA != xno; then
 # Check for atomic intrinsics
 AC_CACHE_CHECK([for native atomic primitives], drm_cv_atomic_primitives,
 [
@@ -358,6 +368,8 @@ AC_CONFIG_FILES([
omap/libdrm_omap.pc
exynos/Makefile
exynos/libdrm_exynos.pc
+   tegra/Makefile
+   tegra/libdrm_tegra.pc
tests/Makefile
tests/modeprint/Makefile
tests/modetest/Makefile
@@ -380,4 +392,5 @@ echo   Radeon API $RADEON
 echo   Nouveau API$NOUVEAU
 echo   OMAP API   $OMAP
 echo   EXYNOS API $EXYNOS
+echo   Tegra API  $TEGRA
 echo 
diff --git a/include/drm/Makefile.am b/include/drm/Makefile.am
index 2923ab4..3e33ed0 100644
--- a/include/drm/Makefile.am
+++ b/include/drm/Makefile.am
@@ -35,6 +35,7 @@ klibdrminclude_HEADERS = \
radeon_drm.h \
savage_drm.h \
sis_drm.h \
+   tegra_drm.h \
via_drm.h \
mach64_drm.h
 
diff --git a/include/drm/tegra_drm.h b/include/drm/tegra_drm.h
new file mode 100644
index 000..eaec602
--- /dev/null
+++ b/include/drm/tegra_drm.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright © 2012 Thierry Reding
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the Software),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * 

Re: [RFC libdrm] Add NVIDIA Tegra support

2012-12-04 Thread Thierry Reding
On Tue, Dec 04, 2012 at 09:28:25AM -0600, Rob Clark wrote:
 On Tue, Dec 4, 2012 at 9:13 AM, Thierry Reding
 thierry.red...@avionic-design.de wrote:
  +int drm_tegra_bo_new(struct drm_tegra *device, uint32_t flags, uint32_t 
  size,
  +struct drm_tegra_bo **bop)
  +{
  +   struct drm_tegra_gem_create args;
  +   struct drm_tegra_bo *bo;
  +   struct tegra_bo *priv;
  +   int err;
  +
  +   if (!device || size == 0 || !bop)
  +   return -EINVAL;
  +
  +   bo = calloc(1, sizeof(*bo));
  +   if (!bo)
  +   return -ENOMEM;
  +
  +   priv = tegra_bo(bo);
  +
  +   DRMLISTINITHEAD(priv-list);
  +   atomic_set(priv-ref, 1);
  +   bo-device = device;
  +   bo-flags = flags;
  +   bo-size = size;
  +
  +   memset(args, 0, sizeof(args));
  +   args.flags = flags;
  +   args.size = size;
  +
  +   err = drmCommandWriteRead(device-fd, DRM_TEGRA_GEM_CREATE, args,
  + sizeof(args));
  +   if (err  0) {
  +   err = -errno;
  +   free(bo);
  +   return err;
  +   }
  +
  +   DRMLISTADD(priv-list, device-bo_list);
  +   bo-handle = args.handle;
  +   bo-offset = args.offset;
 
 btw, x11 can rapidly create/destroy temporary pixmaps.. which don't
 necessarily need userspace access.  You might prefer to avoid creating
 mmap offset on GEM bo creation, and instead do this only if userspace
 needs to mmap the bo

Ah, so that's the reason for the MMAP IOCTL provided by other DRMs. Yes,
that might be better in the long run. For now I don't think it makes
much of a difference since the GEM objects are backed by CMA, and
therefore the offset will be created along with the GEM anyway.

With Terje's upcoming rework that handles all the allocations in host1x
this should become more important, especially when the mapping is done
through the Tegra30's IOMMU.

I'll rework that. Thanks for the quick reply.

Thierry


pgp04bfAF9t0f.pgp
Description: PGP signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [RFC libdrm] Add NVIDIA Tegra support

2012-12-04 Thread Thierry Reding
On Wed, Dec 05, 2012 at 09:39:11AM +0200, Arto Merilainen wrote:
 On 12/04/2012 05:13 PM, Thierry Reding wrote:
 +int drm_tegra_open(const char *path, struct drm_tegra **devicep)
 +{
 +   struct drm_tegra *device;
 +   int err;
 +
 +   if (!path || !devicep)
 +   return -EINVAL;
 +
 +   device = calloc(1, sizeof(*device));
 +   if (!device)
 +   return -ENOMEM;
 +
 +   DRMINITLISTHEAD(device-bo_list);
 +
 +   device-fd = open(path, O_RDWR);
 +   if (device-fd  0) {
 +   err = -errno;
 +   free(device);
 +   return err;
 +   }
 +
 +   *devicep = device;
 +
 +   return 0;
 +}
 
 I think you shouldn't ask the path from the application (=DDX) here,
 but use drmOpen() that automatically finds the correct device for
 you.
 
 I'd also prefer letting the application open and close the device
 and modify drm_tegra_open() to take the fd as a parameter. That way
 the DDX could easily access also all generic libdrm functions.

Good points, I'll take those into account.

Thanks,
Thierry


pgppGZ2o49WQg.pgp
Description: PGP signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel