blob: 6538b56780c2a916e817d44080e952c37bba8a89 [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>
Daniel Vetterd9fc9412014-09-23 15:46:53 +020018#include <drm/drm_gem.h>
Arto Merilainende2ba662013-03-22 16:34:08 +020019
Thierry Redingc134f012014-06-03 14:48:12 +020020#define TEGRA_BO_BOTTOM_UP (1 << 0)
21
22enum tegra_bo_tiling_mode {
23 TEGRA_BO_TILING_MODE_PITCH,
24 TEGRA_BO_TILING_MODE_TILED,
25 TEGRA_BO_TILING_MODE_BLOCK,
26};
27
28struct tegra_bo_tiling {
29 enum tegra_bo_tiling_mode mode;
30 unsigned long value;
31};
Thierry Reding773af772013-10-04 22:34:01 +020032
Arto Merilainende2ba662013-03-22 16:34:08 +020033struct tegra_bo {
34 struct drm_gem_object gem;
35 struct host1x_bo base;
Thierry Reding773af772013-10-04 22:34:01 +020036 unsigned long flags;
Thierry Reding38003912013-12-12 10:00:43 +010037 struct sg_table *sgt;
Arto Merilainende2ba662013-03-22 16:34:08 +020038 dma_addr_t paddr;
39 void *vaddr;
Thierry Redingc134f012014-06-03 14:48:12 +020040
41 struct tegra_bo_tiling tiling;
Arto Merilainende2ba662013-03-22 16:34:08 +020042};
43
44static inline struct tegra_bo *to_tegra_bo(struct drm_gem_object *gem)
45{
46 return container_of(gem, struct tegra_bo, gem);
47}
48
Thierry Reding773af772013-10-04 22:34:01 +020049struct tegra_bo *tegra_bo_create(struct drm_device *drm, unsigned int size,
50 unsigned long flags);
Arto Merilainende2ba662013-03-22 16:34:08 +020051struct tegra_bo *tegra_bo_create_with_handle(struct drm_file *file,
Thierry Reding773af772013-10-04 22:34:01 +020052 struct drm_device *drm,
53 unsigned int size,
54 unsigned long flags,
55 unsigned int *handle);
Arto Merilainende2ba662013-03-22 16:34:08 +020056void tegra_bo_free_object(struct drm_gem_object *gem);
Arto Merilainende2ba662013-03-22 16:34:08 +020057int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm,
58 struct drm_mode_create_dumb *args);
59int tegra_bo_dumb_map_offset(struct drm_file *file, struct drm_device *drm,
60 uint32_t handle, uint64_t *offset);
Arto Merilainende2ba662013-03-22 16:34:08 +020061
62int tegra_drm_mmap(struct file *file, struct vm_area_struct *vma);
63
64extern const struct vm_operations_struct tegra_bo_vm_ops;
65
Thierry Reding38003912013-12-12 10:00:43 +010066struct dma_buf *tegra_gem_prime_export(struct drm_device *drm,
67 struct drm_gem_object *gem,
68 int flags);
69struct drm_gem_object *tegra_gem_prime_import(struct drm_device *drm,
70 struct dma_buf *buf);
71
Arto Merilainende2ba662013-03-22 16:34:08 +020072#endif