summaryrefslogtreecommitdiffstats
path: root/include/media/vi.h
blob: 29165d249a0698a2f0361f27e8f59aa7f24ee51e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
 * Tegra Graphics Host VI
 *
 * Copyright (c) 2012-2018, NVIDIA CORPORATION. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __NVHOST_VI_H__
#define __NVHOST_VI_H__

#include <linux/tegra-powergate.h>
#include <linux/clk/tegra.h>

#include <media/mc_common.h>
#include "chip_support.h"

#define VI_CFG_INTERRUPT_MASK_0				0x8c
#define VI_CFG_INTERRUPT_STATUS_0			0x98

#define CSI_CSI_PIXEL_PARSER_A_INTERRUPT_MASK_0		0x850
#define CSI_CSI_PIXEL_PARSER_A_STATUS_0			0x854
#define PPA_FIFO_OVRF					(1 << 5)

#define CSI_CSI_PIXEL_PARSER_B_INTERRUPT_MASK_0		0x884
#define CSI_CSI_PIXEL_PARSER_B_STATUS_0			0x888
#define PPB_FIFO_OVRF					(1 << 5)

#define VI_CSI_0_ERROR_STATUS				0x184
#define VI_CSI_1_ERROR_STATUS				0x284
#define VI_CSI_0_WD_CTRL				0x18c
#define VI_CSI_1_WD_CTRL				0x28c
#define VI_CSI_0_ERROR_INT_MASK_0			0x188
#define VI_CSI_1_ERROR_INT_MASK_0			0x288

#ifdef TEGRA_21X_OR_HIGHER_CONFIG
#define VI_CSI_2_ERROR_STATUS				0x384
#define VI_CSI_3_ERROR_STATUS				0x484
#define VI_CSI_4_ERROR_STATUS				0x584
#define VI_CSI_5_ERROR_STATUS				0x684

#define VI_CSI_2_WD_CTRL				0x38c
#define VI_CSI_3_WD_CTRL				0x48c
#define VI_CSI_4_WD_CTRL				0x58c
#define VI_CSI_5_WD_CTRL				0x68c

#define VI_CSI_2_ERROR_INT_MASK_0			0x388
#define VI_CSI_3_ERROR_INT_MASK_0			0x488
#define VI_CSI_4_ERROR_INT_MASK_0			0x588
#define VI_CSI_5_ERROR_INT_MASK_0			0x688

#define CSI1_CSI_PIXEL_PARSER_A_INTERRUPT_MASK_0	0x1050
#define CSI1_CSI_PIXEL_PARSER_A_STATUS_0		0x1054
#define CSI1_CSI_PIXEL_PARSER_B_INTERRUPT_MASK_0	0x1084
#define CSI1_CSI_PIXEL_PARSER_B_STATUS_0		0x1088
#define CSI2_CSI_PIXEL_PARSER_A_INTERRUPT_MASK_0	0x1850
#define CSI2_CSI_PIXEL_PARSER_A_STATUS_0		0x1854
#define CSI2_CSI_PIXEL_PARSER_B_INTERRUPT_MASK_0	0x1884
#define CSI2_CSI_PIXEL_PARSER_B_STATUS_0		0x1888

#define NUM_VI_WATCHDOG					6
#else
#define NUM_VI_WATCHDOG					2
#endif

typedef void (*callback)(void *);

struct tegra_vi_stats {
	atomic_t overflow;
};

struct tegra_vi_mfi_ctx;

struct vi {
	struct tegra_camera *camera;
	struct platform_device *ndev;
	struct device *dev;
	struct tegra_vi_data *data;
	struct tegra_mc_vi mc_vi;
	struct tegra_csi_device csi;

	struct regulator *reg;
	struct dentry *debugdir;
	struct tegra_vi_stats vi_out;
	struct work_struct stats_work;
	struct tegra_vi_mfi_ctx *mfi_ctx;
	int vi_irq;
	uint vi_bypass_bw;
	uint max_bw;
	bool master_deinitialized;
	bool tpg_opened;
	bool sensor_opened;
	bool bypass;
};

extern const struct file_operations tegra_vi_ctrl_ops;
int nvhost_vi_prepare_poweroff(struct platform_device *);
int nvhost_vi_finalize_poweron(struct platform_device *);

void nvhost_vi_reset_all(struct platform_device *);
struct vi *tegra_vi_get(void);
int vi_v4l2_set_la(struct vi *tegra_vi, u32 vi_bypass_bw, bool is_ioctl);

int tegra_vi_register_mfi_cb(callback cb, void *cb_arg);
int tegra_vi_unregister_mfi_cb(void);

bool tegra_vi_has_mfi_callback(void);
int tegra_vi_mfi_event_notify(struct tegra_vi_mfi_ctx *mfi_ctx, u8 channel);
int tegra_vi_init_mfi(struct tegra_vi_mfi_ctx **mfi_ctx, u8 num_channels);
void tegra_vi_deinit_mfi(struct tegra_vi_mfi_ctx **mfi_ctx);
#endif