blob: f5860a739bd8551fa60868b09ab61bb74b4c0edf [file] [log] [blame]
Alan Cox8c8f1c92011-11-03 18:21:09 +00001/**************************************************************************
2 * Copyright (c) 2007-2008, Intel Corporation.
3 * All Rights Reserved.
4 *
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.
8 *
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.
13 *
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.
17 *
18 **************************************************************************/
19
20#ifndef _PSB_GTT_H_
21#define _PSB_GTT_H_
22
23#include <drm/drmP.h>
24
25/* This wants cleaning up with respect to the psb_dev and un-needed stuff */
26struct psb_gtt {
27 uint32_t gatt_start;
28 uint32_t mmu_gatt_start;
29 uint32_t gtt_start;
30 uint32_t gtt_phys_start;
31 unsigned gtt_pages;
32 unsigned gatt_pages;
33 unsigned long stolen_size;
34 unsigned long vram_stolen_size;
35 struct rw_semaphore sem;
36};
37
38/* Exported functions */
39extern int psb_gtt_init(struct drm_device *dev, int resume);
40extern void psb_gtt_takedown(struct drm_device *dev);
41
42/* Each gtt_range describes an allocation in the GTT area */
43struct gtt_range {
44 struct resource resource; /* Resource for our allocation */
45 u32 offset; /* GTT offset of our object */
46 struct drm_gem_object gem; /* GEM high level stuff */
47 int in_gart; /* Currently in the GART (ref ct) */
48 bool stolen; /* Backed from stolen RAM */
49 bool mmapping; /* Is mmappable */
50 struct page **pages; /* Backing pages if present */
51 int npage; /* Number of backing pages */
Alan Coxa6ba5822011-11-29 22:27:22 +000052 int roll; /* Roll applied to the GTT entries */
Alan Cox8c8f1c92011-11-03 18:21:09 +000053};
54
55extern struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len,
Patrik Jakobssonc269c682014-01-06 02:39:10 +010056 const char *name, int backed,
57 u32 align);
Alan Cox8c8f1c92011-11-03 18:21:09 +000058extern void psb_gtt_kref_put(struct gtt_range *gt);
59extern void psb_gtt_free_range(struct drm_device *dev, struct gtt_range *gt);
60extern int psb_gtt_pin(struct gtt_range *gt);
61extern void psb_gtt_unpin(struct gtt_range *gt);
Alan Coxa6ba5822011-11-29 22:27:22 +000062extern void psb_gtt_roll(struct drm_device *dev,
63 struct gtt_range *gt, int roll);
Patrik Jakobsson070839e2013-04-05 23:56:18 +020064extern int psb_gtt_restore(struct drm_device *dev);
Alan Cox8c8f1c92011-11-03 18:21:09 +000065#endif