Loading...
1/**************************************************************************
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#include <drm/drm_gem.h>
25
26/* This wants cleaning up with respect to the psb_dev and un-needed stuff */
27struct psb_gtt {
28 uint32_t gatt_start;
29 uint32_t mmu_gatt_start;
30 uint32_t gtt_start;
31 uint32_t gtt_phys_start;
32 unsigned gtt_pages;
33 unsigned gatt_pages;
34 unsigned long stolen_size;
35 unsigned long vram_stolen_size;
36 struct rw_semaphore sem;
37};
38
39/* Exported functions */
40extern int psb_gtt_init(struct drm_device *dev, int resume);
41extern void psb_gtt_takedown(struct drm_device *dev);
42
43/* Each gtt_range describes an allocation in the GTT area */
44struct gtt_range {
45 struct resource resource; /* Resource for our allocation */
46 u32 offset; /* GTT offset of our object */
47 struct drm_gem_object gem; /* GEM high level stuff */
48 int in_gart; /* Currently in the GART (ref ct) */
49 bool stolen; /* Backed from stolen RAM */
50 bool mmapping; /* Is mmappable */
51 struct page **pages; /* Backing pages if present */
52 int npage; /* Number of backing pages */
53 int roll; /* Roll applied to the GTT entries */
54};
55
56extern struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len,
57 const char *name, int backed,
58 u32 align);
59extern void psb_gtt_kref_put(struct gtt_range *gt);
60extern void psb_gtt_free_range(struct drm_device *dev, struct gtt_range *gt);
61extern int psb_gtt_pin(struct gtt_range *gt);
62extern void psb_gtt_unpin(struct gtt_range *gt);
63extern void psb_gtt_roll(struct drm_device *dev,
64 struct gtt_range *gt, int roll);
65extern int psb_gtt_restore(struct drm_device *dev);
66#endif
1/* SPDX-License-Identifier: GPL-2.0-only */
2/**************************************************************************
3 * Copyright (c) 2007-2008, Intel Corporation.
4 * All Rights Reserved.
5 *
6 **************************************************************************/
7
8#ifndef _PSB_GTT_H_
9#define _PSB_GTT_H_
10
11#include <drm/drm_gem.h>
12
13struct drm_psb_private;
14
15/* This wants cleaning up with respect to the psb_dev and un-needed stuff */
16struct psb_gtt {
17 uint32_t gatt_start;
18 uint32_t mmu_gatt_start;
19 uint32_t gtt_start;
20 uint32_t gtt_phys_start;
21 unsigned gtt_pages;
22 unsigned gatt_pages;
23 unsigned long stolen_size;
24 unsigned long vram_stolen_size;
25};
26
27/* Exported functions */
28int psb_gtt_init(struct drm_device *dev);
29void psb_gtt_fini(struct drm_device *dev);
30int psb_gtt_resume(struct drm_device *dev);
31
32int psb_gtt_allocate_resource(struct drm_psb_private *pdev, struct resource *res,
33 const char *name, resource_size_t size, resource_size_t align,
34 bool stolen, u32 *offset);
35
36uint32_t psb_gtt_mask_pte(uint32_t pfn, int type);
37void psb_gtt_insert_pages(struct drm_psb_private *pdev, const struct resource *res,
38 struct page **pages);
39void psb_gtt_remove_pages(struct drm_psb_private *pdev, const struct resource *res);
40
41#endif