1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Support for Intel Camera Imaging ISP subsystem. 4 * Copyright (c) 2010 - 2015, Intel Corporation. 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms and conditions of the GNU General Public License, 8 * version 2, as published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 * more details. 14 */ 15 16 #ifndef __IA_CSS_ISYS_H__ 17 #define __IA_CSS_ISYS_H__ 18 19 #include <type_support.h> 20 #include <input_system.h> 21 #include <ia_css_input_port.h> 22 #include <ia_css_stream_format.h> 23 #include <ia_css_stream_public.h> 24 #include <system_global.h> 25 #include "ia_css_isys_comm.h" 26 27 #ifdef USE_INPUT_SYSTEM_VERSION_2401 28 /** 29 * Virtual Input System. (Input System 2401) 30 */ 31 typedef input_system_cfg_t ia_css_isys_descr_t; 32 /* end of Virtual Input System */ 33 #endif 34 35 #if defined(USE_INPUT_SYSTEM_VERSION_2) || defined(USE_INPUT_SYSTEM_VERSION_2401) 36 input_system_error_t ia_css_isys_init(void); 37 void ia_css_isys_uninit(void); 38 enum mipi_port_id ia_css_isys_port_to_mipi_port( 39 enum mipi_port_id api_port); 40 #endif 41 42 #if defined(USE_INPUT_SYSTEM_VERSION_2401) 43 44 /** 45 * @brief Register one (virtual) stream. This is used to track when all 46 * virtual streams are configured inside the input system. The CSI RX is 47 * only started when all registered streams are configured. 48 * 49 * @param[in] port CSI port 50 * @param[in] isys_stream_id Stream handle generated with ia_css_isys_generate_stream_id() 51 * Must be lower than SH_CSS_MAX_ISYS_CHANNEL_NODES 52 * @return 0 if successful, -EINVAL if 53 * there is already a stream registered with the same handle 54 */ 55 int ia_css_isys_csi_rx_register_stream( 56 enum mipi_port_id port, 57 uint32_t isys_stream_id); 58 59 /** 60 * @brief Unregister one (virtual) stream. This is used to track when all 61 * virtual streams are configured inside the input system. The CSI RX is 62 * only started when all registered streams are configured. 63 * 64 * @param[in] port CSI port 65 * @param[in] isys_stream_id Stream handle generated with ia_css_isys_generate_stream_id() 66 * Must be lower than SH_CSS_MAX_ISYS_CHANNEL_NODES 67 * @return 0 if successful, -EINVAL if 68 * there is no stream registered with that handle 69 */ 70 int ia_css_isys_csi_rx_unregister_stream( 71 enum mipi_port_id port, 72 uint32_t isys_stream_id); 73 74 int ia_css_isys_convert_compressed_format( 75 struct ia_css_csi2_compression *comp, 76 struct input_system_cfg_s *cfg); 77 unsigned int ia_css_csi2_calculate_input_system_alignment( 78 enum atomisp_input_format fmt_type); 79 #endif 80 81 #if !defined(USE_INPUT_SYSTEM_VERSION_2401) 82 /* CSS Receiver */ 83 void ia_css_isys_rx_configure( 84 const rx_cfg_t *config, 85 const enum ia_css_input_mode input_mode); 86 87 void ia_css_isys_rx_disable(void); 88 89 void ia_css_isys_rx_enable_all_interrupts(enum mipi_port_id port); 90 91 unsigned int ia_css_isys_rx_get_interrupt_reg(enum mipi_port_id port); 92 void ia_css_isys_rx_get_irq_info(enum mipi_port_id port, 93 unsigned int *irq_infos); 94 void ia_css_isys_rx_clear_irq_info(enum mipi_port_id port, 95 unsigned int irq_infos); 96 unsigned int ia_css_isys_rx_translate_irq_infos(unsigned int bits); 97 98 #endif /* #if !defined(USE_INPUT_SYSTEM_VERSION_2401) */ 99 100 /* @brief Translate format and compression to format type. 101 * 102 * @param[in] input_format The input format. 103 * @param[in] compression The compression scheme. 104 * @param[out] fmt_type Pointer to the resulting format type. 105 * @return Error code. 106 * 107 * Translate an input format and mipi compression pair to the fmt_type. 108 * This is normally done by the sensor, but when using the input fifo, this 109 * format type must be sumitted correctly by the application. 110 */ 111 int ia_css_isys_convert_stream_format_to_mipi_format( 112 enum atomisp_input_format input_format, 113 mipi_predictor_t compression, 114 unsigned int *fmt_type); 115 116 #ifdef USE_INPUT_SYSTEM_VERSION_2401 117 /** 118 * Virtual Input System. (Input System 2401) 119 */ 120 ia_css_isys_error_t ia_css_isys_stream_create( 121 ia_css_isys_descr_t *isys_stream_descr, 122 ia_css_isys_stream_h isys_stream, 123 uint32_t isys_stream_id); 124 125 void ia_css_isys_stream_destroy( 126 ia_css_isys_stream_h isys_stream); 127 128 ia_css_isys_error_t ia_css_isys_stream_calculate_cfg( 129 ia_css_isys_stream_h isys_stream, 130 ia_css_isys_descr_t *isys_stream_descr, 131 ia_css_isys_stream_cfg_t *isys_stream_cfg); 132 133 void ia_css_isys_csi_rx_lut_rmgr_init(void); 134 135 void ia_css_isys_csi_rx_lut_rmgr_uninit(void); 136 137 bool ia_css_isys_csi_rx_lut_rmgr_acquire( 138 csi_rx_backend_ID_t backend, 139 csi_mipi_packet_type_t packet_type, 140 csi_rx_backend_lut_entry_t *entry); 141 142 void ia_css_isys_csi_rx_lut_rmgr_release( 143 csi_rx_backend_ID_t backend, 144 csi_mipi_packet_type_t packet_type, 145 csi_rx_backend_lut_entry_t *entry); 146 147 void ia_css_isys_ibuf_rmgr_init(void); 148 149 void ia_css_isys_ibuf_rmgr_uninit(void); 150 151 bool ia_css_isys_ibuf_rmgr_acquire( 152 u32 size, 153 uint32_t *start_addr); 154 155 void ia_css_isys_ibuf_rmgr_release( 156 uint32_t *start_addr); 157 158 void ia_css_isys_dma_channel_rmgr_init(void); 159 160 void ia_css_isys_dma_channel_rmgr_uninit(void); 161 162 bool ia_css_isys_dma_channel_rmgr_acquire( 163 isys2401_dma_ID_t dma_id, 164 isys2401_dma_channel *channel); 165 166 void ia_css_isys_dma_channel_rmgr_release( 167 isys2401_dma_ID_t dma_id, 168 isys2401_dma_channel *channel); 169 170 void ia_css_isys_stream2mmio_sid_rmgr_init(void); 171 172 void ia_css_isys_stream2mmio_sid_rmgr_uninit(void); 173 174 bool ia_css_isys_stream2mmio_sid_rmgr_acquire( 175 stream2mmio_ID_t stream2mmio, 176 stream2mmio_sid_ID_t *sid); 177 178 void ia_css_isys_stream2mmio_sid_rmgr_release( 179 stream2mmio_ID_t stream2mmio, 180 stream2mmio_sid_ID_t *sid); 181 182 /* end of Virtual Input System */ 183 #endif 184 185 #endif /* __IA_CSS_ISYS_H__ */ 186