Kristian Høgsberg wrote:
> On 6/12/07, Thomas Hellström <[EMAIL PROTECTED]> wrote:
>> Dave Airlie wrote:
>> > Anyone objections to pulling over the ttm interface ioctl changes?
>> >
>> > These are going to be annoying no matter when I do it .. so I'd like
>> > to get it out of the way..
>> >
>> > Dave.
>> OK, so I've pushed some changes, the most important of which are ioctl
>> arg support for tiled buffers, 64-bit alignment and 64-bit buffer object
>> flag members.
>>
>> Mesa will need a recompilation with the new libdrm headers, since I've
>> changed the type of the function arguments to
>> drmBOCreate and drmBOValdate.
>
> I was reviewing the xf86mm.h interface, and I was wondering, do we
> really need to put the structs in the header?  Could we get away with
> just adding a couple of accessor functions and then keeping the
> structs opaque?  I don't which fields of the fence and bo structs are
> internal details and which are to be accessed by users of the library.
> Something like the attached patch, modulo a couple couple of accessor
> functions?
>
> cheers,
> Kristian
>
Kristian,
This is OK with me. It will add an extra malloc / free for every buffer 
object creation / destruction,
but will make it easier to maintain in the future, (and we can get rid 
of the padding for future expansion).

However, it requires some changes to Mesa as well.

/Thomas

> ------------------------------------------------------------------------
>
> diff --git a/libdrm/Makefile.am b/libdrm/Makefile.am
> index e7e07e4..6fad3e1 100644
> --- a/libdrm/Makefile.am
> +++ b/libdrm/Makefile.am
> @@ -23,7 +23,8 @@ libdrm_ladir = $(libdir)
>  libdrm_la_LDFLAGS = -version-number 2:3:0 -no-undefined
>  
>  AM_CFLAGS = -I$(top_srcdir)/shared-core
> -libdrm_la_SOURCES = xf86drm.c xf86drmHash.c xf86drmRandom.c xf86drmSL.c
> +libdrm_la_SOURCES = \
> +     xf86drm.c xf86drmHash.c xf86drmRandom.c xf86drmSL.c internal.h
>  
>  libdrmincludedir = ${includedir}
>  libdrminclude_HEADERS = xf86drm.h xf86mm.h
> diff --git a/libdrm/internal.h b/libdrm/internal.h
> new file mode 100644
> index 0000000..2ac67f2
> --- /dev/null
> +++ b/libdrm/internal.h
> @@ -0,0 +1,127 @@
> +/**************************************************************************
> + * 
> + * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND. USA.
> + * 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, sub license, 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 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 NON-INFRINGEMENT. IN NO EVENT SHALL
> + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY 
> CLAIM, 
> + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
> + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 
> + * USE OR OTHER DEALINGS IN THE SOFTWARE.
> + *
> + * The above copyright notice and this permission notice (including the
> + * next paragraph) shall be included in all copies or substantial portions
> + * of the Software.
> + * 
> + * 
> + **************************************************************************/
> +
> +#ifndef _INTERNAL_H_
> +#define _INTERNAL_H_
> +
> +/*
> + * List macros heavily inspired by the Linux kernel
> + * list handling. No list looping yet.
> + */
> +
> +typedef struct _drmMMListHead
> +{
> +    struct _drmMMListHead *prev;
> +    struct _drmMMListHead *next;
> +} drmMMListHead;
> +
> +#define DRMINITLISTHEAD(__item)                     \
> +  do{                                               \
> +    (__item)->prev = (__item);                      \
> +    (__item)->next = (__item);                      \
> +  } while (0)
> +
> +#define DRMLISTADD(__item, __list)           \
> +  do {                                               \
> +    (__item)->prev = (__list);                       \
> +    (__item)->next = (__list)->next;         \
> +    (__list)->next->prev = (__item);         \
> +    (__list)->next = (__item);                       \
> +  } while (0)
> +
> +#define DRMLISTADDTAIL(__item, __list)               \
> +  do {                                               \
> +    (__item)->next = (__list);                       \
> +    (__item)->prev = (__list)->prev;         \
> +    (__list)->prev->next = (__item);         \
> +    (__list)->prev = (__item);                       \
> +  } while(0)
> +
> +#define DRMLISTDEL(__item)                   \
> +  do {                                               \
> +    (__item)->prev->next = (__item)->next;   \
> +    (__item)->next->prev = (__item)->prev;   \
> +  } while(0)
> +
> +#define DRMLISTDELINIT(__item)                       \
> +  do {                                               \
> +    (__item)->prev->next = (__item)->next;   \
> +    (__item)->next->prev = (__item)->prev;   \
> +    (__item)->next = (__item);                       \
> +    (__item)->prev = (__item);                       \
> +  } while(0)
> +
> +#define DRMLISTENTRY(__type, __item, __field)   \
> +    ((__type *)(((char *) (__item)) - offsetof(__type, __field)))
> +
> +struct _drmFence
> +{
> +    unsigned handle;
> +    int class;
> +    unsigned type; 
> +    unsigned flags;
> +    unsigned signaled;
> +};
> +
> +struct _drmBO
> +{
> +    drm_bo_type_t type;
> +    unsigned handle;
> +    drm_u64_t mapHandle;
> +    unsigned flags;
> +    unsigned mask;
> +    unsigned mapFlags;
> +    unsigned long size;
> +    unsigned long offset;
> +    unsigned long start;
> +    unsigned replyFlags;
> +    unsigned fenceFlags;
> +    unsigned pageAlignment;
> +    void *virtual;
> +    void *mapVirtual;
> +    int mapCount;
> +};
> +
> +typedef struct _drmBONode
> +{
> +    drmMMListHead head;
> +    drmBO *buf;
> +    drm_bo_arg_t bo_arg;
> +    unsigned long arg0;
> +    unsigned long arg1;
> +} drmBONode;
> +
> +struct _drmBOList {
> +    unsigned numTarget;
> +    unsigned numCurrent;
> +    unsigned numOnList;
> +    drmMMListHead list;
> +    drmMMListHead free;
> +};
> +
> +#endif
> diff --git a/libdrm/xf86drm.c b/libdrm/xf86drm.c
> index 1f242fe..62a219d 100644
> --- a/libdrm/xf86drm.c
> +++ b/libdrm/xf86drm.c
> @@ -50,6 +50,8 @@
>  #include <sys/time.h>
>  #include <stdarg.h>
>  #include "drm.h"
> +#include "xf86mm.h"
> +#include "internal.h"
>  
>  /* Not all systems have MAP_FAILED defined */
>  #ifndef MAP_FAILED
> diff --git a/libdrm/xf86mm.h b/libdrm/xf86mm.h
> index b3822d4..bcc8b5f 100644
> --- a/libdrm/xf86mm.h
> +++ b/libdrm/xf86mm.h
> @@ -42,104 +42,9 @@
>   * User space only needs to refcount object usage within the same 
> application.
>   */
>  
> -
> -/*
> - * List macros heavily inspired by the Linux kernel
> - * list handling. No list looping yet.
> - */
> -
> -typedef struct _drmMMListHead
> -{
> -    struct _drmMMListHead *prev;
> -    struct _drmMMListHead *next;
> -} drmMMListHead;
> -
> -#define DRMINITLISTHEAD(__item)                     \
> -  do{                                               \
> -    (__item)->prev = (__item);                      \
> -    (__item)->next = (__item);                      \
> -  } while (0)
> -
> -#define DRMLISTADD(__item, __list)           \
> -  do {                                               \
> -    (__item)->prev = (__list);                       \
> -    (__item)->next = (__list)->next;         \
> -    (__list)->next->prev = (__item);         \
> -    (__list)->next = (__item);                       \
> -  } while (0)
> -
> -#define DRMLISTADDTAIL(__item, __list)               \
> -  do {                                               \
> -    (__item)->next = (__list);                       \
> -    (__item)->prev = (__list)->prev;         \
> -    (__list)->prev->next = (__item);         \
> -    (__list)->prev = (__item);                       \
> -  } while(0)
> -
> -#define DRMLISTDEL(__item)                   \
> -  do {                                               \
> -    (__item)->prev->next = (__item)->next;   \
> -    (__item)->next->prev = (__item)->prev;   \
> -  } while(0)
> -
> -#define DRMLISTDELINIT(__item)                       \
> -  do {                                               \
> -    (__item)->prev->next = (__item)->next;   \
> -    (__item)->next->prev = (__item)->prev;   \
> -    (__item)->next = (__item);                       \
> -    (__item)->prev = (__item);                       \
> -  } while(0)
> -
> -#define DRMLISTENTRY(__type, __item, __field)   \
> -    ((__type *)(((char *) (__item)) - offsetof(__type, __field)))
> -
> -typedef struct _drmFence
> -{
> -    unsigned handle;
> -    int class;
> -    unsigned type; 
> -    unsigned flags;
> -    unsigned signaled;
> -    unsigned pad[4]; /* for future expansion */
> -} drmFence;
> -
> -typedef struct _drmBO
> -{
> -    drm_bo_type_t type;
> -    unsigned handle;
> -    drm_u64_t mapHandle;
> -    unsigned flags;
> -    unsigned mask;
> -    unsigned mapFlags;
> -    unsigned long size;
> -    unsigned long offset;
> -    unsigned long start;
> -    unsigned replyFlags;
> -    unsigned fenceFlags;
> -    unsigned pageAlignment;
> -    void *virtual;
> -    void *mapVirtual;
> -    int mapCount;
> -    unsigned pad[8];     /* for future expansion */
> -} drmBO;
> -
> -typedef struct _drmBONode
> -{
> -    drmMMListHead head;
> -    drmBO *buf;
> -    drm_bo_arg_t bo_arg;
> -    unsigned long arg0;
> -    unsigned long arg1;
> -} drmBONode;
> -
> -typedef struct _drmBOList {
> -    unsigned numTarget;
> -    unsigned numCurrent;
> -    unsigned numOnList;
> -    drmMMListHead list;
> -    drmMMListHead free;
> -} drmBOList;
> -
> +typedef struct _drmFence drmFence;
> +typedef struct _drmBO drmBO;
> +typedef struct _drmBOList drmBOList;
>  
>  /*
>   * Fence functions.
>   




-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to