blob: 43a25c853357d4e9b2d51b2049b8a12794bfc714 [file] [log] [blame]
Arto Merilainende2ba662013-03-22 16:34:08 +02001/*
2 * Tegra host1x GEM implementation
3 *
4 * Copyright (c) 2012-2013, NVIDIA Corporation.
5 *
Thierry Reding9a2ac2d2014-02-11 15:52:01 +01006 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
Arto Merilainende2ba662013-03-22 16:34:08 +02009 */
10
11#ifndef __HOST1X_GEM_H
12#define __HOST1X_GEM_H
13
Thierry Reding35d747a2013-09-24 16:30:32 +020014#include <linux/host1x.h>
15
Arto Merilainende2ba662013-03-22 16:34:08 +020016#include <drm/drm.h>
17#include <drm/drmP.h>
18
Thierry Redingc134f012014-06-03 14:48:12 +020019#define TEGRA_BO_BOTTOM_UP (1 << 0)
20
21enum tegra_bo_tiling_mode {
22 TEGRA_BO_TILING_MODE_PITCH,
23 TEGRA_BO_TILING_MODE_TILED,
24 TEGRA_BO_TILING_MODE_BLOCK,
25};
26
27struct tegra_bo_tiling {
28 enum tegra_bo_tiling_mode mode;
29 unsigned long value;
30};
Thierry Reding773af772013-10-04 22:34:01 +020031
Arto Merilainende2ba662013-03-22 16:34:08 +020032struct tegra_bo {
33 struct drm_gem_object gem;
34 struct host1x_bo base;
Thierry Reding773af772013-10-04 22:34:01 +020035 unsigned long flags;
Thierry Reding38003912013-12-12 10:00:43 +010036 struct sg_table *sgt;
Arto Merilainende2ba662013-03-22 16:34:08 +020037 dma_addr_t paddr;
38 void *vaddr;
Thierry Redingc134f012014-06-03 14:48:12 +020039
40 struct tegra_bo_tiling tiling;
Arto Merilainende2ba662013-03-22 16:34:08 +020041};
42
43static inline struct tegra_bo *to_tegra_bo(struct drm_gem_object *gem)
44{
45 return container_of(gem, struct tegra_bo, gem);
46}
47
Thierry Reding773af772013-10-04 22:34:01 +020048struct tegra_bo *tegra_bo_create(struct drm_device *drm, unsigned int size,
49 unsigned long flags);
Arto Merilainende2ba662013-03-22 16:34:08 +020050struct tegra_bo *tegra_bo_create_with_handle(struct drm_file *file,
Thierry Reding773af772013-10-04 22:34:01 +020051 struct drm_device *drm,
52 unsigned int size,
53 unsigned long flags,
54 unsigned int *handle);
Arto Merilainende2ba662013-03-22 16:34:08 +020055void tegra_bo_free_object(struct drm_gem_object *gem);
Arto Merilainende2ba662013-03-22 16:34:08 +020056int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm,
57 struct drm_mode_create_dumb *args);
58int tegra_bo_dumb_map_offset(struct drm_file *file, struct drm_device *drm,
59 uint32_t handle, uint64_t *offset);
Arto Merilainende2ba662013-03-22 16:34:08 +020060
61int tegra_drm_mmap(struct file *file, struct vm_area_struct *vma);
62
63extern const struct vm_operations_struct tegra_bo_vm_ops;
64
Thierry Reding38003912013-12-12 10:00:43 +010065struct dma_buf *tegra_gem_prime_export(struct drm_device *drm,
66 struct drm_gem_object *gem,
67 int flags);
68struct drm_gem_object *tegra_gem_prime_import(struct drm_device *drm,
69 struct dma_buf *buf);
70
Arto Merilainende2ba662013-03-22 16:34:08 +020071#endif