]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/blob - drivers/video/tegra/host/nvhost_channel.h
video: tegra: host: Fix channel refcount issues
[sojka/nv-tegra/linux-3.10.git] / drivers / video / tegra / host / nvhost_channel.h
1 /*
2  * drivers/video/tegra/host/nvhost_channel.h
3  *
4  * Tegra Graphics Host Channel
5  *
6  * Copyright (c) 2010-2014, NVIDIA Corporation.  All rights reserved.
7  *
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.
11  *
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
15  * more details.
16  *
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/>.
19  */
20
21 #ifndef __NVHOST_CHANNEL_H
22 #define __NVHOST_CHANNEL_H
23
24 #include <linux/cdev.h>
25 #include <linux/io.h>
26 #include "nvhost_cdma.h"
27
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
33
34 struct nvhost_master;
35 struct platform_device;
36 struct nvhost_channel;
37 struct nvhost_hwctx;
38
39 struct nvhost_channel_ops {
40         const char *soc_name;
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);
46 };
47
48 struct nvhost_channel {
49         struct nvhost_channel_ops ops;
50         int refcount;
51         int chid;
52         int dev_chid;
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;
59
60         /* the address space block here
61          * belongs to the module. but for
62          * now just keep it here */
63         struct nvhost_as *as;
64
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;
69 };
70
71 #define channel_op(ch)          (ch->ops)
72
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);
85
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);
89
90 int nvhost_channel_read_reg(struct nvhost_channel *channel,
91         struct nvhost_hwctx *hwctx,
92         u32 offset, u32 *value);
93
94 struct nvhost_channel *nvhost_alloc_channel_internal(int chindex,
95         int max_channels);
96
97 int nvhost_channel_save_context(struct nvhost_channel *ch);
98 void nvhost_channel_init_gather_filter(struct nvhost_channel *ch);
99
100 struct nvhost_hwctx *nvhost_channel_get_file_hwctx(int fd);
101
102 struct nvhost_hwctx_handler *nvhost_alloc_hwctx_handler(u32 syncpt,
103         u32 waitbase, struct nvhost_channel *ch);
104
105 #endif