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