drm: move ttm global code to core drm
I wrote this for the prime sharing work, but I also noticed other external non-upstream drivers from a large company carrying a similiar patch, so I may as well ship it in master. Signed-off-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
@@ -663,6 +663,8 @@ struct drm_gem_open {
|
||||
#define DRM_IOCTL_UNLOCK DRM_IOW( 0x2b, struct drm_lock)
|
||||
#define DRM_IOCTL_FINISH DRM_IOW( 0x2c, struct drm_lock)
|
||||
|
||||
#define DRM_IOCTL_GEM_PRIME_OPEN DRM_IOWR(0x2e, struct drm_gem_open)
|
||||
|
||||
#define DRM_IOCTL_AGP_ACQUIRE DRM_IO( 0x30)
|
||||
#define DRM_IOCTL_AGP_RELEASE DRM_IO( 0x31)
|
||||
#define DRM_IOCTL_AGP_ENABLE DRM_IOW( 0x32, struct drm_agp_mode)
|
||||
|
||||
@@ -1453,6 +1453,8 @@ void drm_gem_vm_open(struct vm_area_struct *vma);
|
||||
void drm_gem_vm_close(struct vm_area_struct *vma);
|
||||
int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
|
||||
|
||||
#include "drm_global.h"
|
||||
|
||||
static inline void
|
||||
drm_gem_object_reference(struct drm_gem_object *obj)
|
||||
{
|
||||
|
||||
53
include/drm/drm_global.h
Normal file
53
include/drm/drm_global.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2008-2009 VMware, Inc., Palo Alto, CA., 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 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 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.
|
||||
*
|
||||
**************************************************************************/
|
||||
/*
|
||||
* Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
|
||||
*/
|
||||
|
||||
#ifndef _DRM_GLOBAL_H_
|
||||
#define _DRM_GLOBAL_H_
|
||||
enum drm_global_types {
|
||||
DRM_GLOBAL_TTM_MEM = 0,
|
||||
DRM_GLOBAL_TTM_BO,
|
||||
DRM_GLOBAL_TTM_OBJECT,
|
||||
DRM_GLOBAL_NUM
|
||||
};
|
||||
|
||||
struct drm_global_reference {
|
||||
enum drm_global_types global_type;
|
||||
size_t size;
|
||||
void *object;
|
||||
int (*init) (struct drm_global_reference *);
|
||||
void (*release) (struct drm_global_reference *);
|
||||
};
|
||||
|
||||
extern void drm_global_init(void);
|
||||
extern void drm_global_release(void);
|
||||
extern int drm_global_item_ref(struct drm_global_reference *ref);
|
||||
extern void drm_global_item_unref(struct drm_global_reference *ref);
|
||||
|
||||
#endif
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "ttm/ttm_memory.h"
|
||||
#include "ttm/ttm_module.h"
|
||||
#include "drm_mm.h"
|
||||
#include "drm_global.h"
|
||||
#include "linux/workqueue.h"
|
||||
#include "linux/fs.h"
|
||||
#include "linux/spinlock.h"
|
||||
@@ -362,7 +363,7 @@ struct ttm_bo_driver {
|
||||
*/
|
||||
|
||||
struct ttm_bo_global_ref {
|
||||
struct ttm_global_reference ref;
|
||||
struct drm_global_reference ref;
|
||||
struct ttm_mem_global *mem_glob;
|
||||
};
|
||||
|
||||
@@ -687,8 +688,8 @@ extern int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
|
||||
extern void ttm_mem_io_free(struct ttm_bo_device *bdev,
|
||||
struct ttm_mem_reg *mem);
|
||||
|
||||
extern void ttm_bo_global_release(struct ttm_global_reference *ref);
|
||||
extern int ttm_bo_global_init(struct ttm_global_reference *ref);
|
||||
extern void ttm_bo_global_release(struct drm_global_reference *ref);
|
||||
extern int ttm_bo_global_init(struct drm_global_reference *ref);
|
||||
|
||||
extern int ttm_bo_device_release(struct ttm_bo_device *bdev);
|
||||
|
||||
|
||||
@@ -35,26 +35,6 @@
|
||||
struct kobject;
|
||||
|
||||
#define TTM_PFX "[TTM] "
|
||||
|
||||
enum ttm_global_types {
|
||||
TTM_GLOBAL_TTM_MEM = 0,
|
||||
TTM_GLOBAL_TTM_BO,
|
||||
TTM_GLOBAL_TTM_OBJECT,
|
||||
TTM_GLOBAL_NUM
|
||||
};
|
||||
|
||||
struct ttm_global_reference {
|
||||
enum ttm_global_types global_type;
|
||||
size_t size;
|
||||
void *object;
|
||||
int (*init) (struct ttm_global_reference *);
|
||||
void (*release) (struct ttm_global_reference *);
|
||||
};
|
||||
|
||||
extern void ttm_global_init(void);
|
||||
extern void ttm_global_release(void);
|
||||
extern int ttm_global_item_ref(struct ttm_global_reference *ref);
|
||||
extern void ttm_global_item_unref(struct ttm_global_reference *ref);
|
||||
extern struct kobject *ttm_get_kobj(void);
|
||||
|
||||
#endif /* _TTM_MODULE_H_ */
|
||||
|
||||
Reference in New Issue
Block a user