2 * drivers/video/tegra/host/nvhost_channel.h
4 * Tegra Graphics Host Channel
6 * Copyright (c) 2010-2014, NVIDIA Corporation. All rights reserved.
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License,
10 * version 2, as published by the Free Software Foundation.
12 * This program is distributed in the hope it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef __NVHOST_CHANNEL_H
22 #define __NVHOST_CHANNEL_H
24 #include <linux/cdev.h>
26 #include "nvhost_cdma.h"
28 #define NVHOST_MAX_WAIT_CHECKS 256
29 #define NVHOST_MAX_GATHERS 512
30 #define NVHOST_MAX_HANDLES 1280
31 #define NVHOST_MAX_POWERGATE_IDS 2
32 #define NVHOST_INVALID_CHANNEL -1
35 struct platform_device;
36 struct nvhost_channel;
39 struct nvhost_channel_ops {
41 int (*init)(struct nvhost_channel *,
42 struct nvhost_master *);
43 int (*submit)(struct nvhost_job *job);
44 int (*save_context)(struct nvhost_channel *channel);
45 int (*init_gather_filter)(struct nvhost_channel *ch);
48 struct nvhost_channel {
49 struct nvhost_channel_ops ops;
53 struct mutex submitlock;
54 void __iomem *aperture;
55 struct nvhost_hwctx *cur_ctx;
56 struct platform_device *dev;
57 struct nvhost_hwctx_handler *ctxhandler;
58 struct nvhost_cdma cdma;
60 /* the address space block here
61 * belongs to the module. but for
62 * now just keep it here */
65 /* error notificatiers used channel submit timeout */
66 struct dma_buf *error_notifier_ref;
67 struct nvhost_notification *error_notifier;
68 void *error_notifier_va;
71 #define channel_op(ch) (ch->ops)
73 int nvhost_alloc_channels(struct nvhost_master *host);
74 int nvhost_channel_map(struct nvhost_device_data *pdata,
75 struct nvhost_channel **ch);
76 int nvhost_channel_unmap(struct nvhost_channel *ch);
77 int nvhost_channel_release(struct nvhost_device_data *pdata);
78 int nvhost_channel_list_free(struct nvhost_master *host);
79 struct nvhost_channel *nvhost_check_channel(struct nvhost_device_data *pdata);
80 int nvhost_channel_init(struct nvhost_channel *ch,
81 struct nvhost_master *dev);
82 int nvhost_channel_submit(struct nvhost_job *job);
83 void nvhost_set_notifier(struct nvhost_channel *ch, __u32 error);
84 void nvhost_free_error_notifiers(struct nvhost_channel *ch);
86 void nvhost_getchannel(struct nvhost_channel *ch);
87 void nvhost_putchannel(struct nvhost_channel *ch, int cnt);
88 int nvhost_channel_suspend(struct nvhost_channel *ch);
90 int nvhost_channel_read_reg(struct nvhost_channel *channel,
91 struct nvhost_hwctx *hwctx,
92 u32 offset, u32 *value);
94 struct nvhost_channel *nvhost_alloc_channel_internal(int chindex,
97 int nvhost_channel_save_context(struct nvhost_channel *ch);
98 void nvhost_channel_init_gather_filter(struct nvhost_channel *ch);
100 struct nvhost_hwctx *nvhost_channel_get_file_hwctx(int fd);
102 struct nvhost_hwctx_handler *nvhost_alloc_hwctx_handler(u32 syncpt,
103 u32 waitbase, struct nvhost_channel *ch);