xref: /linux/drivers/gpu/drm/gma500/gem.h (revision 24bce201d79807b668bf9d9e0aca801c5c0d5f78)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /**************************************************************************
3  * Copyright (c) 2014 Patrik Jakobsson
4  * All Rights Reserved.
5  *
6  **************************************************************************/
7 
8 #ifndef _GEM_H
9 #define _GEM_H
10 
11 #include <linux/kernel.h>
12 
13 #include <drm/drm_gem.h>
14 
15 struct drm_device;
16 
17 /*
18  * PSB GEM object
19  */
20 
21 struct psb_gem_object {
22 	struct drm_gem_object base;
23 
24 	struct resource resource;	/* GTT resource for our allocation */
25 	u32 offset;			/* GTT offset of our object */
26 	int in_gart;			/* Currently in the GART (ref ct) */
27 	bool stolen;			/* Backed from stolen RAM */
28 	bool mmapping;			/* Is mmappable */
29 	struct page **pages;		/* Backing pages if present */
30 };
31 
32 static inline struct psb_gem_object *to_psb_gem_object(struct drm_gem_object *obj)
33 {
34 	return container_of(obj, struct psb_gem_object, base);
35 }
36 
37 struct psb_gem_object *
38 psb_gem_create(struct drm_device *dev, u64 size, const char *name, bool stolen, u32 align);
39 
40 int psb_gem_pin(struct psb_gem_object *pobj);
41 void psb_gem_unpin(struct psb_gem_object *pobj);
42 
43 /*
44  * Memory management
45  */
46 
47 int psb_gem_mm_init(struct drm_device *dev);
48 void psb_gem_mm_fini(struct drm_device *dev);
49 int psb_gem_mm_resume(struct drm_device *dev);
50 
51 #endif
52