]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/blob - drivers/media/platform/tegra/vi/vi.h
media: tegra_camera: add SoC fops for CSI
[sojka/nv-tegra/linux-3.10.git] / drivers / media / platform / tegra / vi / vi.h
1 /*
2  * drivers/video/tegra/host/vi/vi.h
3  *
4  * Tegra Graphics Host VI
5  *
6  * Copyright (c) 2012-2016, 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_VI_H__
22 #define __NVHOST_VI_H__
23
24 #include <linux/platform/tegra/isomgr.h>
25 #include <linux/tegra-powergate.h>
26 #include <linux/clk/tegra.h>
27
28 #include "camera/mc_common.h"
29 #include "chip_support.h"
30 #include "csi/csi.h"
31
32 #define VI_CFG_INTERRUPT_MASK_0                         0x8c
33 #define VI_CFG_INTERRUPT_STATUS_0                       0x98
34
35 #define CSI_CSI_PIXEL_PARSER_A_INTERRUPT_MASK_0         0x850
36 #define CSI_CSI_PIXEL_PARSER_A_STATUS_0                 0x854
37 #define PPA_FIFO_OVRF                                   (1 << 5)
38
39 #define CSI_CSI_PIXEL_PARSER_B_INTERRUPT_MASK_0         0x884
40 #define CSI_CSI_PIXEL_PARSER_B_STATUS_0                 0x888
41 #define PPB_FIFO_OVRF                                   (1 << 5)
42
43 #define VI_CSI_0_ERROR_STATUS                           0x184
44 #define VI_CSI_1_ERROR_STATUS                           0x284
45 #define VI_CSI_0_WD_CTRL                                0x18c
46 #define VI_CSI_1_WD_CTRL                                0x28c
47 #define VI_CSI_0_ERROR_INT_MASK_0                       0x188
48 #define VI_CSI_1_ERROR_INT_MASK_0                       0x288
49
50 #ifdef TEGRA_21X_OR_HIGHER_CONFIG
51 #define VI_CSI_2_ERROR_STATUS                           0x384
52 #define VI_CSI_3_ERROR_STATUS                           0x484
53 #define VI_CSI_2_WD_CTRL                                0x38c
54 #define VI_CSI_3_WD_CTRL                                0x48c
55 #define VI_CSI_2_ERROR_INT_MASK_0                       0x388
56 #define VI_CSI_3_ERROR_INT_MASK_0                       0x488
57 #define VI_CSI_4_ERROR_STATUS                           0x584
58 #define VI_CSI_5_ERROR_STATUS                           0x684
59 #define VI_CSI_4_WD_CTRL                                0x58c
60 #define VI_CSI_5_WD_CTRL                                0x68c
61 #define VI_CSI_4_ERROR_INT_MASK_0                       0x588
62 #define VI_CSI_5_ERROR_INT_MASK_0                       0x688
63
64 #define CSI_PHY_CIL_COMMAND_0                           0x908
65 #define CSI_A_PHY_CIL_ENABLE_SHIFT                      0
66 #define CSI_B_PHY_CIL_ENABLE_SHIFT                      8
67 #define CSI1_PHY_CIL_COMMAND_0                          0x1108
68 #define CSI2_PHY_CIL_COMMAND_0                          0x1908
69
70 #define CSI1_CSI_PIXEL_PARSER_A_INTERRUPT_MASK_0        0x1050
71 #define CSI1_CSI_PIXEL_PARSER_A_STATUS_0                0x1054
72 #define CSI1_CSI_PIXEL_PARSER_B_INTERRUPT_MASK_0        0x1084
73 #define CSI1_CSI_PIXEL_PARSER_B_STATUS_0                0x1088
74 #define CSI2_CSI_PIXEL_PARSER_A_INTERRUPT_MASK_0        0x1850
75 #define CSI2_CSI_PIXEL_PARSER_A_STATUS_0                0x1854
76 #define CSI2_CSI_PIXEL_PARSER_B_INTERRUPT_MASK_0        0x1884
77 #define CSI2_CSI_PIXEL_PARSER_B_STATUS_0                0x1888
78
79 #define NUM_VI_WATCHDOG                                                 6
80 #else
81 #define NUM_VI_WATCHDOG                                                 2
82 #endif
83
84 typedef void (*callback)(void *);
85
86 struct tegra_vi_stats {
87         atomic_t overflow;
88 };
89
90 struct tegra_vi_fops {
91         int (*soc_power_on)(struct tegra_mc_vi *vi);
92         void (*soc_power_off)(struct tegra_mc_vi *vi);
93 };
94
95 struct tegra_vi_channel_fops {
96         void (*soc_channel_ec_init)(struct tegra_channel *chan);
97         void (*soc_channel_ec_recover)(struct tegra_channel *chan);
98         int (*soc_channel_capture_setup)(struct tegra_channel *chan);
99         void (*soc_channel_capture_frame_init)(struct tegra_channel *chan,
100                         struct tegra_channel_buffer *buf, u32 *thresh);
101         void (*soc_channel_capture_frame_enable)(struct tegra_channel *chan);
102         int (*soc_channel_capture_frame)(struct tegra_channel *chan,
103                         struct timespec *ts, u32 *thresh);
104         int (*soc_channel_capture_done)(struct tegra_channel *chan,
105                         struct tegra_channel_buffer *buf,
106                         struct timespec *ts);
107         int (*soc_channel_error_status)(struct tegra_channel *chan);
108         int (*soc_channel_stop_streaming)(struct tegra_channel *chan);
109 };
110
111 struct tegra_vi_data {
112         struct nvhost_device_data *info;
113         struct tegra_vi_fops *vi_fops;
114         struct tegra_vi_channel_fops *channel_fops;
115         struct tegra_csi_fops *csi_fops;
116 };
117
118 struct vi {
119         struct tegra_camera *camera;
120         struct platform_device *ndev;
121         struct device *dev;
122         struct tegra_vi_data *data;
123         struct tegra_mc_vi mc_vi;
124         struct tegra_csi_device csi;
125
126         struct regulator *reg;
127         struct dentry *debugdir;
128         struct tegra_vi_stats vi_out;
129         struct workqueue_struct *vi_workqueue;
130         struct work_struct stats_work;
131         struct work_struct mfi_cb_work;
132 #if defined(CONFIG_TEGRA_ISOMGR)
133         tegra_isomgr_handle isomgr_handle;
134 #endif
135         int vi_irq;
136         uint vi_bypass_bw;
137         uint max_bw;
138         struct mutex update_la_lock;
139         bool master_deinitialized;
140         bool tpg_opened;
141         bool sensor_opened;
142         bool bypass;
143 };
144
145 extern const struct file_operations tegra_vi_ctrl_ops;
146 int nvhost_vi_prepare_poweroff(struct platform_device *);
147 int nvhost_vi_finalize_poweron(struct platform_device *);
148
149 void nvhost_vi_reset_all(struct platform_device *);
150 struct vi *tegra_vi_get(void);
151 int vi_v4l2_set_la(struct vi *tegra_vi, u32 vi_bypass_bw, bool is_ioctl);
152
153 #ifdef CONFIG_VIDEO_TEGRA_VI
154 int tegra_vi_register_mfi_cb(callback cb, void *cb_arg);
155 int tegra_vi_unregister_mfi_cb(void);
156 #else
157 static inline int tegra_vi_register_mfi_cb(callback cb, void *cb_arg)
158 {
159         return -ENOSYS;
160 }
161 static inline int tegra_vi_unregister_mfi_cb(void)
162 {
163         return -ENOSYS;
164 }
165 #endif
166 #endif