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 ISP2401 28 /** 29 * Virtual Input System. (Input System 2401) 30 */ 31 typedef isp2401_input_system_cfg_t ia_css_isys_descr_t; 32 /* end of Virtual Input System */ 33 #endif 34 35 input_system_err_t ia_css_isys_init(void); 36 void ia_css_isys_uninit(void); 37 enum mipi_port_id ia_css_isys_port_to_mipi_port( 38 enum mipi_port_id api_port); 39 40 #if defined(ISP2401) 41 42 /** 43 * @brief Register one (virtual) stream. This is used to track when all 44 * virtual streams are configured inside the input system. The CSI RX is 45 * only started when all registered streams are configured. 46 * 47 * @param[in] port CSI port 48 * @param[in] isys_stream_id Stream handle generated with ia_css_isys_generate_stream_id() 49 * Must be lower than SH_CSS_MAX_ISYS_CHANNEL_NODES 50 * @return 0 if successful, -EINVAL if 51 * there is already a stream registered with the same handle 52 */ 53 int ia_css_isys_csi_rx_register_stream( 54 enum mipi_port_id port, 55 uint32_t isys_stream_id); 56 57 /** 58 * @brief Unregister one (virtual) stream. This is used to track when all 59 * virtual streams are configured inside the input system. The CSI RX is 60 * only started when all registered streams are configured. 61 * 62 * @param[in] port CSI port 63 * @param[in] isys_stream_id Stream handle generated with ia_css_isys_generate_stream_id() 64 * Must be lower than SH_CSS_MAX_ISYS_CHANNEL_NODES 65 * @return 0 if successful, -EINVAL if 66 * there is no stream registered with that handle 67 */ 68 int ia_css_isys_csi_rx_unregister_stream( 69 enum mipi_port_id port, 70 uint32_t isys_stream_id); 71 72 int ia_css_isys_convert_compressed_format( 73 struct ia_css_csi2_compression *comp, 74 struct isp2401_input_system_cfg_s *cfg); 75 unsigned int ia_css_csi2_calculate_input_system_alignment( 76 enum atomisp_input_format fmt_type); 77 #endif 78 79 #if !defined(ISP2401) 80 /* CSS Receiver */ 81 void ia_css_isys_rx_configure( 82 const rx_cfg_t *config, 83 const enum ia_css_input_mode input_mode); 84 85 void ia_css_isys_rx_disable(void); 86 87 void ia_css_isys_rx_enable_all_interrupts(enum mipi_port_id port); 88 89 unsigned int ia_css_isys_rx_get_interrupt_reg(enum mipi_port_id port); 90 void ia_css_isys_rx_get_irq_info(enum mipi_port_id port, 91 unsigned int *irq_infos); 92 void ia_css_isys_rx_clear_irq_info(enum mipi_port_id port, 93 unsigned int irq_infos); 94 unsigned int ia_css_isys_rx_translate_irq_infos(unsigned int bits); 95 96 #endif /* #if !defined(ISP2401) */ 97 98 /* @brief Translate format and compression to format type. 99 * 100 * @param[in] input_format The input format. 101 * @param[in] compression The compression scheme. 102 * @param[out] fmt_type Pointer to the resulting format type. 103 * @return Error code. 104 * 105 * Translate an input format and mipi compression pair to the fmt_type. 106 * This is normally done by the sensor, but when using the input fifo, this 107 * format type must be sumitted correctly by the application. 108 */ 109 int ia_css_isys_convert_stream_format_to_mipi_format( 110 enum atomisp_input_format input_format, 111 mipi_predictor_t compression, 112 unsigned int *fmt_type); 113 114 #ifdef ISP2401 115 /** 116 * Virtual Input System. (Input System 2401) 117 */ 118 ia_css_isys_error_t ia_css_isys_stream_create( 119 ia_css_isys_descr_t *isys_stream_descr, 120 ia_css_isys_stream_h isys_stream, 121 uint32_t isys_stream_id); 122 123 void ia_css_isys_stream_destroy( 124 ia_css_isys_stream_h isys_stream); 125 126 ia_css_isys_error_t ia_css_isys_stream_calculate_cfg( 127 ia_css_isys_stream_h isys_stream, 128 ia_css_isys_descr_t *isys_stream_descr, 129 ia_css_isys_stream_cfg_t *isys_stream_cfg); 130 131 void ia_css_isys_csi_rx_lut_rmgr_init(void); 132 133 void ia_css_isys_csi_rx_lut_rmgr_uninit(void); 134 135 bool ia_css_isys_csi_rx_lut_rmgr_acquire( 136 csi_rx_backend_ID_t backend, 137 csi_mipi_packet_type_t packet_type, 138 csi_rx_backend_lut_entry_t *entry); 139 140 void ia_css_isys_csi_rx_lut_rmgr_release( 141 csi_rx_backend_ID_t backend, 142 csi_mipi_packet_type_t packet_type, 143 csi_rx_backend_lut_entry_t *entry); 144 145 void ia_css_isys_ibuf_rmgr_init(void); 146 147 void ia_css_isys_ibuf_rmgr_uninit(void); 148 149 bool ia_css_isys_ibuf_rmgr_acquire( 150 u32 size, 151 uint32_t *start_addr); 152 153 void ia_css_isys_ibuf_rmgr_release( 154 uint32_t *start_addr); 155 156 void ia_css_isys_dma_channel_rmgr_init(void); 157 158 void ia_css_isys_dma_channel_rmgr_uninit(void); 159 160 bool ia_css_isys_dma_channel_rmgr_acquire( 161 isys2401_dma_ID_t dma_id, 162 isys2401_dma_channel *channel); 163 164 void ia_css_isys_dma_channel_rmgr_release( 165 isys2401_dma_ID_t dma_id, 166 isys2401_dma_channel *channel); 167 168 void ia_css_isys_stream2mmio_sid_rmgr_init(void); 169 170 void ia_css_isys_stream2mmio_sid_rmgr_uninit(void); 171 172 bool ia_css_isys_stream2mmio_sid_rmgr_acquire( 173 stream2mmio_ID_t stream2mmio, 174 stream2mmio_sid_ID_t *sid); 175 176 void ia_css_isys_stream2mmio_sid_rmgr_release( 177 stream2mmio_ID_t stream2mmio, 178 stream2mmio_sid_ID_t *sid); 179 180 /* end of Virtual Input System */ 181 #endif 182 183 #endif /* __IA_CSS_ISYS_H__ */ 184