linux/drivers/media/pci/intel/ipu6/ipu6-fw-isys.h

/* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (C) 2013--2024 Intel Corporation */

#ifndef IPU6_FW_ISYS_H
#define IPU6_FW_ISYS_H

#include <linux/types.h>

struct device;
struct ipu6_isys;

/* Max number of Input/Output Pins */
#define IPU6_MAX_IPINS

#define IPU6_MAX_OPINS

#define IPU6_STREAM_ID_MAX
#define IPU6_NONSECURE_STREAM_ID_MAX
#define IPU6_DEV_SEND_QUEUE_SIZE
#define IPU6_NOF_SRAM_BLOCKS_MAX
#define IPU6_N_MAX_MSG_SEND_QUEUES
#define IPU6SE_STREAM_ID_MAX
#define IPU6SE_NONSECURE_STREAM_ID_MAX
#define IPU6SE_DEV_SEND_QUEUE_SIZE
#define IPU6SE_NOF_SRAM_BLOCKS_MAX
#define IPU6SE_N_MAX_MSG_SEND_QUEUES

/* Single return queue for all streams/commands type */
#define IPU6_N_MAX_MSG_RECV_QUEUES
/* Single device queue for high priority commands (bypass in-order queue) */
#define IPU6_N_MAX_DEV_SEND_QUEUES
/* Single dedicated send queue for proxy interface */
#define IPU6_N_MAX_PROXY_SEND_QUEUES
/* Single dedicated recv queue for proxy interface */
#define IPU6_N_MAX_PROXY_RECV_QUEUES
/* Send queues layout */
#define IPU6_BASE_PROXY_SEND_QUEUES
#define IPU6_BASE_DEV_SEND_QUEUES
#define IPU6_BASE_MSG_SEND_QUEUES
/* Recv queues layout */
#define IPU6_BASE_PROXY_RECV_QUEUES
#define IPU6_BASE_MSG_RECV_QUEUES
#define IPU6_N_MAX_RECV_QUEUES

#define IPU6_N_MAX_SEND_QUEUES
#define IPU6SE_N_MAX_SEND_QUEUES

/* Max number of planes for frame formats supported by the FW */
#define IPU6_PIN_PLANES_MAX

#define IPU6_FW_ISYS_SENSOR_TYPE_START
#define IPU6_FW_ISYS_SENSOR_TYPE_END
#define IPU6SE_FW_ISYS_SENSOR_TYPE_START
#define IPU6SE_FW_ISYS_SENSOR_TYPE_END
/*
 * Device close takes some time from last ack message to actual stopping
 * of the SP processor. As long as the SP processor runs we can't proceed with
 * clean up of resources.
 */
#define IPU6_ISYS_OPEN_RETRY
#define IPU6_ISYS_CLOSE_RETRY
#define IPU6_FW_CALL_TIMEOUT_JIFFIES

enum ipu6_fw_isys_resp_type {};

enum ipu6_fw_isys_send_type {};

enum ipu6_fw_isys_queue_type {};

enum ipu6_fw_isys_stream_source {};

#define IPU6_FW_ISYS_STREAM_SRC_CSI2_PORT0
#define IPU6_FW_ISYS_STREAM_SRC_CSI2_PORT1
#define IPU6_FW_ISYS_STREAM_SRC_CSI2_PORT2
#define IPU6_FW_ISYS_STREAM_SRC_CSI2_PORT3

#define IPU6_FW_ISYS_STREAM_SRC_CSI2_3PH_PORTA
#define IPU6_FW_ISYS_STREAM_SRC_CSI2_3PH_PORTB
#define IPU6_FW_ISYS_STREAM_SRC_CSI2_3PH_CPHY_PORT0
#define IPU6_FW_ISYS_STREAM_SRC_CSI2_3PH_CPHY_PORT1
#define IPU6_FW_ISYS_STREAM_SRC_CSI2_3PH_CPHY_PORT2
#define IPU6_FW_ISYS_STREAM_SRC_CSI2_3PH_CPHY_PORT3

#define IPU6_FW_ISYS_STREAM_SRC_MIPIGEN_PORT0
#define IPU6_FW_ISYS_STREAM_SRC_MIPIGEN_PORT1

/*
 * enum ipu6_fw_isys_mipi_vc: MIPI csi2 spec
 * supports up to 4 virtual per physical channel
 */
enum ipu6_fw_isys_mipi_vc {};

enum ipu6_fw_isys_frame_format_type {};

enum ipu6_fw_isys_pin_type {};

/*
 * enum ipu6_fw_isys_mipi_store_mode. Describes if long MIPI packets reach
 * MIPI SRAM with the long packet header or
 * if not, then only option is to capture it with pin type MIPI.
 */
enum ipu6_fw_isys_mipi_store_mode {};

enum ipu6_fw_isys_capture_mode {};

enum ipu6_fw_isys_sensor_mode {};

enum ipu6_fw_isys_error {};

enum ipu6_fw_proxy_error {};

/* firmware ABI structure below are aligned in firmware, no need pack */
struct ipu6_fw_isys_buffer_partition_abi {};

struct ipu6_fw_isys_fw_config {};

/*
 * struct ipu6_fw_isys_resolution_abi: Generic resolution structure.
 */
struct ipu6_fw_isys_resolution_abi {};

/**
 * struct ipu6_fw_isys_output_pin_payload_abi - ISYS output pin buffer
 * @out_buf_id: Points to output pin buffer - buffer identifier
 * @addr: Points to output pin buffer - CSS Virtual Address
 * @compress: Request frame compression (1), or  not (0)
 */
struct ipu6_fw_isys_output_pin_payload_abi {};

/**
 * struct ipu6_fw_isys_output_pin_info_abi - ISYS output pin info
 * @output_res: output pin resolution
 * @stride: output stride in Bytes (not valid for statistics)
 * @watermark_in_lines: pin watermark level in lines
 * @payload_buf_size: minimum size in Bytes of all buffers that will be
 *			supplied for capture on this pin
 * @ts_offsets: ts_offsets
 * @s2m_pixel_soc_pixel_remapping: pixel soc remapping (see the definition of
 *				   S2M_PIXEL_SOC_PIXEL_REMAPPING_FLAG_NO_REMAPPING)
 * @csi_be_soc_pixel_remapping: see s2m_pixel_soc_pixel_remapping
 * @send_irq: assert if pin event should trigger irq
 * @input_pin_id: related input pin id
 * @pt: pin type -real format "enum ipu6_fw_isys_pin_type"
 * @ft: frame format type -real format "enum ipu6_fw_isys_frame_format_type"
 * @reserved: a reserved field
 * @reserve_compression: reserve compression resources for pin
 * @snoopable: snoopable
 * @error_handling_enable: enable error handling
 * @sensor_type: sensor_type
 */
struct ipu6_fw_isys_output_pin_info_abi {};

/**
 * struct ipu6_fw_isys_input_pin_info_abi - ISYS input pin info
 * @input_res: input resolution
 * @dt: mipi data type ((enum ipu6_fw_isys_mipi_data_type)
 * @mipi_store_mode: defines if legacy long packet header will be stored or
 *		     discarded if discarded, output pin type for this
 *		     input pin can only be MIPI
 *		     (enum ipu6_fw_isys_mipi_store_mode)
 * @bits_per_pix: native bits per pixel
 * @mapped_dt: actual data type from sensor
 * @mipi_decompression: defines which compression will be in mipi backend
 * @crop_first_and_last_lines: Control whether to crop the first and last line
 *			       of the input image. Crop done by HW device.
 * @capture_mode: mode of capture, regular or burst, default value is regular
 * @reserved: a reserved field
 */
struct ipu6_fw_isys_input_pin_info_abi {};

/**
 * struct ipu6_fw_isys_cropping_abi - ISYS cropping coordinates
 * @top_offset: Top offset
 * @left_offset: Left offset
 * @bottom_offset: Bottom offset
 * @right_offset: Right offset
 */
struct ipu6_fw_isys_cropping_abi {};

/**
 * struct ipu6_fw_isys_stream_cfg_data_abi - ISYS stream configuration data
 * ISYS stream configuration data structure
 * @crop: for extended use and is not used in FW currently
 * @input_pins: input pin descriptors
 * @output_pins: output pin descriptors
 * @compfmt: de-compression setting for User Defined Data
 * @nof_input_pins: number of input pins
 * @nof_output_pins: number of output pins
 * @send_irq_sof_discarded: send irq on discarded frame sof response
 *		- if '1' it will override the send_resp_sof_discarded
 *		  and send the response
 *		- if '0' the send_resp_sof_discarded will determine
 *		  whether to send the response
 * @send_irq_eof_discarded: send irq on discarded frame eof response
 *		- if '1' it will override the send_resp_eof_discarded
 *		  and send the response
 *		- if '0' the send_resp_eof_discarded will determine
 *		  whether to send the response
 * @send_resp_sof_discarded: send response for discarded frame sof detected,
 *			     used only when send_irq_sof_discarded is '0'
 * @send_resp_eof_discarded: send response for discarded frame eof detected,
 *			     used only when send_irq_eof_discarded is '0'
 * @src: Stream source index e.g. MIPI_generator_0, CSI2-rx_1
 * @vc: MIPI Virtual Channel (up to 4 virtual per physical channel)
 * @isl_use: indicates whether stream requires ISL and how
 * @sensor_type: type of connected sensor, tobii or others, default is 0
 * @reserved: a reserved field
 * @reserved2: a reserved field
 */
struct ipu6_fw_isys_stream_cfg_data_abi {};

/**
 * struct ipu6_fw_isys_frame_buff_set_abi - ISYS frame buffer set (request)
 * @output_pins: output pin addresses
 * @send_irq_sof: send irq on frame sof response
 *		- if '1' it will override the send_resp_sof and
 *		  send the response
 *		- if '0' the send_resp_sof will determine whether to
 *		  send the response
 * @send_irq_eof: send irq on frame eof response
 *		- if '1' it will override the send_resp_eof and
 *		  send the response
 *		- if '0' the send_resp_eof will determine whether to
 *		  send the response
 * @send_irq_capture_ack: send irq on capture ack
 * @send_irq_capture_done: send irq on capture done
 * @send_resp_sof: send response for frame sof detected,
 *		   used only when send_irq_sof is '0'
 * @send_resp_eof: send response for frame eof detected,
 *		   used only when send_irq_eof is '0'
 * @send_resp_capture_ack: send response for capture ack event
 * @send_resp_capture_done: send response for capture done event
 * @reserved: a reserved field
 */
struct ipu6_fw_isys_frame_buff_set_abi {};

/**
 * struct ipu6_fw_isys_error_info_abi - ISYS error information
 * @error: error code if something went wrong
 * @error_details: depending on error code, it may contain additional error info
 */
struct ipu6_fw_isys_error_info_abi {};

/**
 * struct ipu6_fw_isys_resp_info_abi - ISYS firmware response
 * @buf_id: buffer ID
 * @pin: this var is only valid for pin event related responses,
 *     contains pin addresses
 * @error_info: error information from the FW
 * @timestamp: Time information for event if available
 * @stream_handle: stream id the response corresponds to
 * @type: response type (enum ipu6_fw_isys_resp_type)
 * @pin_id: pin id that the pin payload corresponds to
 * @reserved: a reserved field
 * @reserved2: a reserved field
 */
struct ipu6_fw_isys_resp_info_abi {};

/**
 * struct ipu6_fw_isys_proxy_error_info_abi - ISYS proxy error
 * @error: error code if something went wrong
 * @error_details: depending on error code, it may contain additional error info
 */
struct ipu6_fw_isys_proxy_error_info_abi {};

struct ipu6_fw_isys_proxy_resp_info_abi {};

/**
 * struct ipu6_fw_proxy_write_queue_token - ISYS proxy write queue token
 * @request_id: update id for the specific proxy write request
 * @region_index: Region id for the proxy write request
 * @offset: Offset of the write request according to the base address
 *	    of the region
 * @value: Value that is requested to be written with the proxy write request
 */
struct ipu6_fw_proxy_write_queue_token {};

/**
 * struct ipu6_fw_resp_queue_token - ISYS response queue token
 * @resp_info: response info
 */
struct ipu6_fw_resp_queue_token {};

/**
 * struct ipu6_fw_send_queue_token - ISYS send queue token
 * @buf_handle: buffer handle
 * @payload: payload
 * @send_type: send_type
 * @stream_id: stream_id
 */
struct ipu6_fw_send_queue_token {};

/**
 * struct ipu6_fw_proxy_resp_queue_token - ISYS proxy response queue token
 * @proxy_resp_info: proxy response info
 */
struct ipu6_fw_proxy_resp_queue_token {};

/**
 * struct ipu6_fw_proxy_send_queue_token - SYS proxy send queue token
 * @request_id: request_id
 * @region_index: region_index
 * @offset: offset
 * @value: value
 */
struct ipu6_fw_proxy_send_queue_token {};

void
ipu6_fw_isys_dump_stream_cfg(struct device *dev,
			     struct ipu6_fw_isys_stream_cfg_data_abi *cfg);
void
ipu6_fw_isys_dump_frame_buff_set(struct device *dev,
				 struct ipu6_fw_isys_frame_buff_set_abi *buf,
				 unsigned int outputs);
int ipu6_fw_isys_init(struct ipu6_isys *isys, unsigned int num_streams);
int ipu6_fw_isys_close(struct ipu6_isys *isys);
int ipu6_fw_isys_simple_cmd(struct ipu6_isys *isys,
			    const unsigned int stream_handle, u16 send_type);
int ipu6_fw_isys_complex_cmd(struct ipu6_isys *isys,
			     const unsigned int stream_handle,
			     void *cpu_mapped_buf, dma_addr_t dma_mapped_buf,
			     size_t size, u16 send_type);
int ipu6_fw_isys_send_proxy_token(struct ipu6_isys *isys,
				  unsigned int req_id,
				  unsigned int index,
				  unsigned int offset, u32 value);
void ipu6_fw_isys_cleanup(struct ipu6_isys *isys);
struct ipu6_fw_isys_resp_info_abi *
ipu6_fw_isys_get_resp(void *context, unsigned int queue);
void ipu6_fw_isys_put_resp(void *context, unsigned int queue);
#endif