gma500: begin adding GEM
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / staging / gma500 / psb_gtt.h
blob1b5bec04b085889975ec017b4dca9fc014d418c1
1 /**************************************************************************
2 * Copyright (c) 2007-2008, Intel Corporation.
3 * All Rights Reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 **************************************************************************/
20 #ifndef _PSB_GTT_H_
21 #define _PSB_GTT_H_
23 #include <drm/drmP.h>
25 /*#include "img_types.h"*/
27 struct psb_gtt {
28 struct drm_device *dev;
29 int initialized;
30 uint32_t gatt_start;
31 uint32_t mmu_gatt_start;
32 uint32_t gtt_start;
33 uint32_t gtt_phys_start;
34 unsigned gtt_pages;
35 unsigned gatt_pages;
36 uint32_t stolen_base;
37 void *vram_addr;
38 uint32_t pge_ctl;
39 u16 gmch_ctrl;
40 unsigned long stolen_size;
41 unsigned long vram_stolen_size;
42 uint32_t *gtt_map;
43 struct rw_semaphore sem;
46 struct psb_gtt_mm {
47 struct drm_mm base;
48 struct drm_open_hash hash;
49 uint32_t count;
50 spinlock_t lock;
53 struct psb_gtt_hash_entry {
54 struct drm_open_hash ht;
55 uint32_t count;
56 struct drm_hash_item item;
59 struct psb_gtt_mem_mapping {
60 struct drm_mm_node *node;
61 struct drm_hash_item item;
64 /*Exported functions*/
65 extern int psb_gtt_init(struct psb_gtt *pg, int resume);
66 extern int psb_gtt_insert_pages(struct psb_gtt *pg, struct page **pages,
67 unsigned offset_pages, unsigned num_pages,
68 unsigned desired_tile_stride,
69 unsigned hw_tile_stride, int type);
70 extern int psb_gtt_remove_pages(struct psb_gtt *pg, unsigned offset_pages,
71 unsigned num_pages,
72 unsigned desired_tile_stride,
73 unsigned hw_tile_stride,
74 int rc_prot);
76 extern struct psb_gtt *psb_gtt_alloc(struct drm_device *dev);
77 extern void psb_gtt_takedown(struct psb_gtt *pg, int free);
78 extern int psb_gtt_map_meminfo(struct drm_device *dev,
79 void * hKernelMemInfo,
80 uint32_t *offset);
81 extern int psb_gtt_unmap_meminfo(struct drm_device *dev,
82 void * hKernelMemInfo);
83 extern int psb_gtt_mm_init(struct psb_gtt *pg);
84 extern void psb_gtt_mm_takedown(void);
86 /* Each gtt_range describes an allocation in the GTT area */
87 struct gtt_range {
88 struct resource resource;
89 u32 offset;
90 struct kref kref;
91 struct drm_gem_object gem; /* GEM high level stuff */
92 int in_gart; /* Currently in the GART */
93 int stolen; /* Backed from stolen RAM */
96 extern struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len,
97 const char *name, int backed);
98 extern void psb_gtt_kref_put(struct gtt_range *gt);
99 extern void psb_gtt_free_range(struct drm_device *dev, struct gtt_range *gt);
101 #endif