aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/isys/interface/ia_css_isys.h
blob: 8c005db9766e2fa09e9fe9126b42dcb54df72e60 (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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#ifndef ISP2401
/*
 * Support for Intel Camera Imaging ISP subsystem.
 * Copyright (c) 2015, Intel Corporation.
 *
 * 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.
 */
#else
/**
Support for Intel Camera Imaging ISP subsystem.
Copyright (c) 2010 - 2015, Intel Corporation.

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.
*/
#endif

#ifndef __IA_CSS_ISYS_H__
#define __IA_CSS_ISYS_H__

#include <type_support.h>
#include <input_system.h>
#include <ia_css_input_port.h>
#include <ia_css_stream_format.h>
#include <ia_css_stream_public.h>
#include <system_global.h>
#include "ia_css_isys_comm.h"

#ifdef USE_INPUT_SYSTEM_VERSION_2401
/**
 * Virtual Input System. (Input System 2401)
 */
typedef input_system_cfg_t	ia_css_isys_descr_t;
/* end of Virtual Input System */
#endif

#if defined(USE_INPUT_SYSTEM_VERSION_2) || defined(USE_INPUT_SYSTEM_VERSION_2401)
input_system_error_t ia_css_isys_init(void);
void ia_css_isys_uninit(void);
enum mipi_port_id ia_css_isys_port_to_mipi_port(
	enum mipi_port_id api_port);
#endif

#if defined(USE_INPUT_SYSTEM_VERSION_2401)

/**
 * @brief Register one (virtual) stream. This is used to track when all
 * virtual streams are configured inside the input system. The CSI RX is
 * only started when all registered streams are configured.
 *
 * @param[in]	port		CSI port
 * @param[in]	isys_stream_id	Stream handle generated with ia_css_isys_generate_stream_id()
 *				Must be lower than SH_CSS_MAX_ISYS_CHANNEL_NODES
 * @return			IA_CSS_SUCCESS if successful, IA_CSS_ERR_INTERNAL_ERROR if
 *				there is already a stream registered with the same handle
 */
enum ia_css_err ia_css_isys_csi_rx_register_stream(
	enum mipi_port_id port,
	uint32_t isys_stream_id);

/**
 * @brief Unregister one (virtual) stream. This is used to track when all
 * virtual streams are configured inside the input system. The CSI RX is
 * only started when all registered streams are configured.
 *
 * @param[in]	port		CSI port
 * @param[in]	isys_stream_id	Stream handle generated with ia_css_isys_generate_stream_id()
 *				Must be lower than SH_CSS_MAX_ISYS_CHANNEL_NODES
 * @return			IA_CSS_SUCCESS if successful, IA_CSS_ERR_INTERNAL_ERROR if
 *				there is no stream registered with that handle
 */
enum ia_css_err ia_css_isys_csi_rx_unregister_stream(
	enum mipi_port_id port,
	uint32_t isys_stream_id);

enum ia_css_err ia_css_isys_convert_compressed_format(
		struct ia_css_csi2_compression *comp,
		struct input_system_cfg_s *cfg);
unsigned int ia_css_csi2_calculate_input_system_alignment(
	enum atomisp_input_format fmt_type);
#endif

#if !defined(USE_INPUT_SYSTEM_VERSION_2401)
/* CSS Receiver */
void ia_css_isys_rx_configure(
	const rx_cfg_t *config,
	const enum ia_css_input_mode input_mode);

void ia_css_isys_rx_disable(void);

void ia_css_isys_rx_enable_all_interrupts(enum mipi_port_id port);

unsigned int ia_css_isys_rx_get_interrupt_reg(enum mipi_port_id port);
void ia_css_isys_rx_get_irq_info(enum mipi_port_id port,
				 unsigned int *irq_infos);
void ia_css_isys_rx_clear_irq_info(enum mipi_port_id port,
				   unsigned int irq_infos);
unsigned int ia_css_isys_rx_translate_irq_infos(unsigned int bits);

#endif /* #if !defined(USE_INPUT_SYSTEM_VERSION_2401) */

/* @brief Translate format and compression to format type.
 *
 * @param[in]	input_format	The input format.
 * @param[in]	compression	The compression scheme.
 * @param[out]	fmt_type	Pointer to the resulting format type.
 * @return			Error code.
 *
 * Translate an input format and mipi compression pair to the fmt_type.
 * This is normally done by the sensor, but when using the input fifo, this
 * format type must be sumitted correctly by the application.
 */
enum ia_css_err ia_css_isys_convert_stream_format_to_mipi_format(
		enum atomisp_input_format input_format,
		mipi_predictor_t compression,
		unsigned int *fmt_type);

#ifdef USE_INPUT_SYSTEM_VERSION_2401
/**
 * Virtual Input System. (Input System 2401)
 */
extern ia_css_isys_error_t ia_css_isys_stream_create(
		ia_css_isys_descr_t	*isys_stream_descr,
		ia_css_isys_stream_h	isys_stream,
		uint32_t isys_stream_id);

extern void ia_css_isys_stream_destroy(
		ia_css_isys_stream_h	isys_stream);

extern ia_css_isys_error_t ia_css_isys_stream_calculate_cfg(
		ia_css_isys_stream_h		isys_stream,
		ia_css_isys_descr_t		*isys_stream_descr,
		ia_css_isys_stream_cfg_t	*isys_stream_cfg);

extern void ia_css_isys_csi_rx_lut_rmgr_init(void);

extern void ia_css_isys_csi_rx_lut_rmgr_uninit(void);

extern bool ia_css_isys_csi_rx_lut_rmgr_acquire(
	csi_rx_backend_ID_t		backend,
	csi_mipi_packet_type_t		packet_type,
	csi_rx_backend_lut_entry_t	*entry);

extern void ia_css_isys_csi_rx_lut_rmgr_release(
	csi_rx_backend_ID_t		backend,
	csi_mipi_packet_type_t		packet_type,
	csi_rx_backend_lut_entry_t	*entry);


extern void ia_css_isys_ibuf_rmgr_init(void);

extern void ia_css_isys_ibuf_rmgr_uninit(void);

extern bool ia_css_isys_ibuf_rmgr_acquire(
	uint32_t	size,
	uint32_t	*start_addr);

extern void ia_css_isys_ibuf_rmgr_release(
	uint32_t	*start_addr);

extern void ia_css_isys_dma_channel_rmgr_init(void);

extern void ia_css_isys_dma_channel_rmgr_uninit(void);

extern bool ia_css_isys_dma_channel_rmgr_acquire(
	isys2401_dma_ID_t	dma_id,
	isys2401_dma_channel	*channel);

extern void ia_css_isys_dma_channel_rmgr_release(
	isys2401_dma_ID_t	dma_id,
	isys2401_dma_channel	*channel);

extern void ia_css_isys_stream2mmio_sid_rmgr_init(void);

extern void ia_css_isys_stream2mmio_sid_rmgr_uninit(void);

extern bool ia_css_isys_stream2mmio_sid_rmgr_acquire(
	stream2mmio_ID_t	stream2mmio,
	stream2mmio_sid_ID_t	*sid);

extern void ia_css_isys_stream2mmio_sid_rmgr_release(
	stream2mmio_ID_t	stream2mmio,
	stream2mmio_sid_ID_t	*sid);

/* end of Virtual Input System */
#endif

#endif				/* __IA_CSS_ISYS_H__ */