#include <media/v4l2-dev.h>
#include <media/v4l2-event.h>
#include "mmu/isp_mmu.h"
#include "mmu/sh_mmu_mrfld.h"
#include "hmm/hmm_bo.h"
#include "hmm/hmm.h"
#include "atomisp_compat.h"
#include "atomisp_internal.h"
#include "atomisp_cmd.h"
#include "atomisp-regs.h"
#include "atomisp_fops.h"
#include "atomisp_ioctl.h"
#include "ia_css_debug.h"
#include "ia_css_isp_param.h"
#include "sh_css_hrt.h"
#include "ia_css_isys.h"
#include <linux/io.h>
#include <linux/pm_runtime.h>
#define MAX_ACC_STAGES …
#define NO_LINK …
static DEFINE_SPINLOCK(mmio_lock);
enum frame_info_type { … };
struct bayer_ds_factor { … };
static void atomisp_css2_hw_store_8(hrt_address addr, uint8_t data)
{ … }
static void atomisp_css2_hw_store_16(hrt_address addr, uint16_t data)
{ … }
void atomisp_css2_hw_store_32(hrt_address addr, uint32_t data)
{ … }
static uint8_t atomisp_css2_hw_load_8(hrt_address addr)
{ … }
static uint16_t atomisp_css2_hw_load_16(hrt_address addr)
{ … }
static uint32_t atomisp_css2_hw_load_32(hrt_address addr)
{ … }
static void atomisp_css2_hw_store(hrt_address addr, const void *from, uint32_t n)
{ … }
static void atomisp_css2_hw_load(hrt_address addr, void *to, uint32_t n)
{ … }
static int __printf(1, 0) atomisp_vprintk(const char *fmt, va_list args)
{ … }
void atomisp_load_uint32(hrt_address addr, uint32_t *data)
{ … }
static int hmm_get_mmu_base_addr(struct device *dev, unsigned int *mmu_base_addr)
{ … }
static void __dump_pipe_config(struct atomisp_sub_device *asd,
struct atomisp_stream_env *stream_env,
unsigned int pipe_id)
{ … }
static void __dump_stream_config(struct atomisp_sub_device *asd,
struct atomisp_stream_env *stream_env)
{ … }
static int __destroy_stream(struct atomisp_sub_device *asd,
struct atomisp_stream_env *stream_env)
{ … }
static int __destroy_streams(struct atomisp_sub_device *asd)
{ … }
static int __create_stream(struct atomisp_sub_device *asd,
struct atomisp_stream_env *stream_env)
{ … }
static int __create_streams(struct atomisp_sub_device *asd)
{ … }
static int __destroy_stream_pipes(struct atomisp_sub_device *asd,
struct atomisp_stream_env *stream_env)
{ … }
static int __destroy_pipes(struct atomisp_sub_device *asd)
{ … }
void atomisp_destroy_pipes_stream(struct atomisp_sub_device *asd)
{ … }
static void __apply_additional_pipe_config(
struct atomisp_sub_device *asd,
struct atomisp_stream_env *stream_env,
enum ia_css_pipe_id pipe_id)
{ … }
static bool is_pipe_valid_to_current_run_mode(struct atomisp_sub_device *asd,
enum ia_css_pipe_id pipe_id)
{ … }
static int __create_pipe(struct atomisp_sub_device *asd,
struct atomisp_stream_env *stream_env,
enum ia_css_pipe_id pipe_id)
{ … }
static int __create_pipes(struct atomisp_sub_device *asd)
{ … }
int atomisp_create_pipes_stream(struct atomisp_sub_device *asd)
{ … }
int atomisp_css_update_stream(struct atomisp_sub_device *asd)
{ … }
int atomisp_css_init(struct atomisp_device *isp)
{ … }
static inline int __set_css_print_env(struct atomisp_device *isp, int opt)
{ … }
int atomisp_css_load_firmware(struct atomisp_device *isp)
{ … }
void atomisp_css_uninit(struct atomisp_device *isp)
{ … }
int atomisp_css_irq_translate(struct atomisp_device *isp,
unsigned int *infos)
{ … }
void atomisp_css_rx_get_irq_info(enum mipi_port_id port,
unsigned int *infos)
{ … }
void atomisp_css_rx_clear_irq_info(enum mipi_port_id port,
unsigned int infos)
{ … }
int atomisp_css_irq_enable(struct atomisp_device *isp,
enum ia_css_irq_info info, bool enable)
{ … }
void atomisp_css_init_struct(struct atomisp_sub_device *asd)
{ … }
int atomisp_q_video_buffer_to_css(struct atomisp_sub_device *asd,
struct ia_css_frame *frame,
enum atomisp_input_stream_id stream_id,
enum ia_css_buffer_type css_buf_type,
enum ia_css_pipe_id css_pipe_id)
{ … }
int atomisp_q_metadata_buffer_to_css(struct atomisp_sub_device *asd,
struct atomisp_metadata_buf *metadata_buf,
enum atomisp_input_stream_id stream_id,
enum ia_css_pipe_id css_pipe_id)
{ … }
int atomisp_q_s3a_buffer_to_css(struct atomisp_sub_device *asd,
struct atomisp_s3a_buf *s3a_buf,
enum atomisp_input_stream_id stream_id,
enum ia_css_pipe_id css_pipe_id)
{ … }
int atomisp_q_dis_buffer_to_css(struct atomisp_sub_device *asd,
struct atomisp_dis_buf *dis_buf,
enum atomisp_input_stream_id stream_id,
enum ia_css_pipe_id css_pipe_id)
{ … }
int atomisp_css_start(struct atomisp_sub_device *asd)
{ … }
void atomisp_css_update_isp_params(struct atomisp_sub_device *asd)
{ … }
void atomisp_css_update_isp_params_on_pipe(struct atomisp_sub_device *asd,
struct ia_css_pipe *pipe)
{ … }
int atomisp_css_queue_buffer(struct atomisp_sub_device *asd,
enum atomisp_input_stream_id stream_id,
enum ia_css_pipe_id pipe_id,
enum ia_css_buffer_type buf_type,
struct atomisp_css_buffer *isp_css_buffer)
{ … }
int atomisp_css_dequeue_buffer(struct atomisp_sub_device *asd,
enum atomisp_input_stream_id stream_id,
enum ia_css_pipe_id pipe_id,
enum ia_css_buffer_type buf_type,
struct atomisp_css_buffer *isp_css_buffer)
{ … }
int atomisp_css_allocate_stat_buffers(struct atomisp_sub_device *asd,
u16 stream_id,
struct atomisp_s3a_buf *s3a_buf,
struct atomisp_dis_buf *dis_buf,
struct atomisp_metadata_buf *md_buf)
{ … }
void atomisp_css_free_3a_buffer(struct atomisp_s3a_buf *s3a_buf)
{ … }
void atomisp_css_free_dis_buffer(struct atomisp_dis_buf *dis_buf)
{ … }
void atomisp_css_free_metadata_buffer(struct atomisp_metadata_buf *metadata_buf)
{ … }
void atomisp_css_free_stat_buffers(struct atomisp_sub_device *asd)
{ … }
int atomisp_css_get_grid_info(struct atomisp_sub_device *asd,
enum ia_css_pipe_id pipe_id)
{ … }
int atomisp_alloc_3a_output_buf(struct atomisp_sub_device *asd)
{ … }
int atomisp_alloc_dis_coef_buf(struct atomisp_sub_device *asd)
{ … }
int atomisp_alloc_metadata_output_buf(struct atomisp_sub_device *asd)
{ … }
void atomisp_free_metadata_output_buf(struct atomisp_sub_device *asd)
{ … }
void atomisp_css_temp_pipe_to_pipe_id(struct atomisp_sub_device *asd,
struct atomisp_css_event *current_event)
{ … }
int atomisp_css_isys_set_resolution(struct atomisp_sub_device *asd,
enum atomisp_input_stream_id stream_id,
struct v4l2_mbus_framefmt *ffmt,
int isys_stream)
{ … }
int atomisp_css_input_set_resolution(struct atomisp_sub_device *asd,
enum atomisp_input_stream_id stream_id,
struct v4l2_mbus_framefmt *ffmt)
{ … }
void atomisp_css_input_set_binning_factor(struct atomisp_sub_device *asd,
enum atomisp_input_stream_id stream_id,
unsigned int bin_factor)
{ … }
void atomisp_css_input_set_bayer_order(struct atomisp_sub_device *asd,
enum atomisp_input_stream_id stream_id,
enum ia_css_bayer_order bayer_order)
{ … }
void atomisp_css_isys_set_link(struct atomisp_sub_device *asd,
enum atomisp_input_stream_id stream_id,
int link,
int isys_stream)
{ … }
void atomisp_css_isys_set_valid(struct atomisp_sub_device *asd,
enum atomisp_input_stream_id stream_id,
bool valid,
int isys_stream)
{ … }
void atomisp_css_isys_set_format(struct atomisp_sub_device *asd,
enum atomisp_input_stream_id stream_id,
enum atomisp_input_format format,
int isys_stream)
{ … }
void atomisp_css_input_set_format(struct atomisp_sub_device *asd,
enum atomisp_input_stream_id stream_id,
enum atomisp_input_format format)
{ … }
int atomisp_css_set_default_isys_config(struct atomisp_sub_device *asd,
enum atomisp_input_stream_id stream_id,
struct v4l2_mbus_framefmt *ffmt)
{ … }
void atomisp_css_isys_two_stream_cfg_update_stream1(
struct atomisp_sub_device *asd,
enum atomisp_input_stream_id stream_id,
enum atomisp_input_format input_format,
unsigned int width, unsigned int height)
{ … }
void atomisp_css_isys_two_stream_cfg_update_stream2(
struct atomisp_sub_device *asd,
enum atomisp_input_stream_id stream_id,
enum atomisp_input_format input_format,
unsigned int width, unsigned int height)
{ … }
int atomisp_css_input_set_effective_resolution(
struct atomisp_sub_device *asd,
enum atomisp_input_stream_id stream_id,
unsigned int width, unsigned int height)
{ … }
void atomisp_css_video_set_dis_envelope(struct atomisp_sub_device *asd,
unsigned int dvs_w, unsigned int dvs_h)
{ … }
void atomisp_css_input_set_two_pixels_per_clock(
struct atomisp_sub_device *asd,
bool two_ppc)
{ … }
void atomisp_css_enable_dz(struct atomisp_sub_device *asd, bool enable)
{ … }
void atomisp_css_capture_set_mode(struct atomisp_sub_device *asd,
enum ia_css_capture_mode mode)
{ … }
void atomisp_css_input_set_mode(struct atomisp_sub_device *asd,
enum ia_css_input_mode mode)
{ … }
void atomisp_css_capture_enable_online(struct atomisp_sub_device *asd,
unsigned short stream_index, bool enable)
{ … }
void atomisp_css_preview_enable_online(struct atomisp_sub_device *asd,
unsigned short stream_index, bool enable)
{ … }
int atomisp_css_input_configure_port(
struct atomisp_sub_device *asd,
enum mipi_port_id port,
unsigned int num_lanes,
unsigned int timeout,
unsigned int mipi_freq,
enum atomisp_input_format metadata_format,
unsigned int metadata_width,
unsigned int metadata_height)
{ … }
void atomisp_css_stop(struct atomisp_sub_device *asd, bool in_reset)
{ … }
void atomisp_css_continuous_set_num_raw_frames(
struct atomisp_sub_device *asd,
int num_frames)
{ … }
static enum ia_css_pipe_mode __pipe_id_to_pipe_mode(
struct atomisp_sub_device *asd,
enum ia_css_pipe_id pipe_id)
{ … }
static void __configure_output(struct atomisp_sub_device *asd,
unsigned int stream_index,
unsigned int width, unsigned int height,
unsigned int min_width,
enum ia_css_frame_format format,
enum ia_css_pipe_id pipe_id)
{ … }
static void __configure_capture_pp_input(struct atomisp_sub_device *asd,
unsigned int width, unsigned int height,
enum ia_css_pipe_id pipe_id)
{ … }
static void __configure_preview_pp_input(struct atomisp_sub_device *asd,
unsigned int width, unsigned int height,
enum ia_css_pipe_id pipe_id)
{ … }
static void __configure_video_pp_input(struct atomisp_sub_device *asd,
unsigned int width, unsigned int height,
enum ia_css_pipe_id pipe_id)
{ … }
static void __configure_vf_output(struct atomisp_sub_device *asd,
unsigned int width, unsigned int height,
unsigned int min_width,
enum ia_css_frame_format format,
enum ia_css_pipe_id pipe_id)
{ … }
static int __get_frame_info(struct atomisp_sub_device *asd,
unsigned int stream_index,
struct ia_css_frame_info *info,
enum frame_info_type type,
enum ia_css_pipe_id pipe_id)
{ … }
static unsigned int atomisp_get_pipe_index(struct atomisp_sub_device *asd)
{ … }
int atomisp_get_css_frame_info(struct atomisp_sub_device *asd,
struct ia_css_frame_info *frame_info)
{ … }
int atomisp_css_copy_configure_output(struct atomisp_sub_device *asd,
unsigned int stream_index,
unsigned int width, unsigned int height,
unsigned int padded_width,
enum ia_css_frame_format format)
{ … }
int atomisp_css_preview_configure_output(struct atomisp_sub_device *asd,
unsigned int width, unsigned int height,
unsigned int min_width,
enum ia_css_frame_format format)
{ … }
int atomisp_css_capture_configure_output(struct atomisp_sub_device *asd,
unsigned int width, unsigned int height,
unsigned int min_width,
enum ia_css_frame_format format)
{ … }
int atomisp_css_video_configure_output(struct atomisp_sub_device *asd,
unsigned int width, unsigned int height,
unsigned int min_width,
enum ia_css_frame_format format)
{ … }
int atomisp_css_video_configure_viewfinder(
struct atomisp_sub_device *asd,
unsigned int width, unsigned int height,
unsigned int min_width,
enum ia_css_frame_format format)
{ … }
int atomisp_css_capture_configure_viewfinder(
struct atomisp_sub_device *asd,
unsigned int width, unsigned int height,
unsigned int min_width,
enum ia_css_frame_format format)
{ … }
int atomisp_css_video_get_viewfinder_frame_info(
struct atomisp_sub_device *asd,
struct ia_css_frame_info *info)
{ … }
int atomisp_css_capture_get_viewfinder_frame_info(
struct atomisp_sub_device *asd,
struct ia_css_frame_info *info)
{ … }
int atomisp_css_copy_get_output_frame_info(
struct atomisp_sub_device *asd,
unsigned int stream_index,
struct ia_css_frame_info *info)
{ … }
int atomisp_css_preview_get_output_frame_info(
struct atomisp_sub_device *asd,
struct ia_css_frame_info *info)
{ … }
int atomisp_css_capture_get_output_frame_info(
struct atomisp_sub_device *asd,
struct ia_css_frame_info *info)
{ … }
int atomisp_css_video_get_output_frame_info(
struct atomisp_sub_device *asd,
struct ia_css_frame_info *info)
{ … }
int atomisp_css_preview_configure_pp_input(
struct atomisp_sub_device *asd,
unsigned int width, unsigned int height)
{ … }
int atomisp_css_capture_configure_pp_input(
struct atomisp_sub_device *asd,
unsigned int width, unsigned int height)
{ … }
int atomisp_css_video_configure_pp_input(
struct atomisp_sub_device *asd,
unsigned int width, unsigned int height)
{ … }
int atomisp_css_offline_capture_configure(struct atomisp_sub_device *asd,
int num_captures, unsigned int skip, int offset)
{ … }
int atomisp_css_exp_id_capture(struct atomisp_sub_device *asd, int exp_id)
{ … }
int atomisp_css_exp_id_unlock(struct atomisp_sub_device *asd, int exp_id)
{ … }
int atomisp_css_capture_enable_xnr(struct atomisp_sub_device *asd,
bool enable)
{ … }
void atomisp_css_set_ctc_table(struct atomisp_sub_device *asd,
struct ia_css_ctc_table *ctc_table)
{ … }
void atomisp_css_set_anr_thres(struct atomisp_sub_device *asd,
struct ia_css_anr_thres *anr_thres)
{ … }
void atomisp_css_set_dvs_6axis(struct atomisp_sub_device *asd,
struct ia_css_dvs_6axis_config *dvs_6axis)
{ … }
void atomisp_css_video_set_dis_vector(struct atomisp_sub_device *asd,
struct atomisp_dis_vector *vector)
{ … }
static int atomisp_compare_dvs_grid(struct atomisp_sub_device *asd,
struct atomisp_dvs_grid_info *atomgrid)
{ … }
void atomisp_css_set_dvs2_coefs(struct atomisp_sub_device *asd,
struct ia_css_dvs2_coefficients *coefs)
{ … }
int atomisp_css_set_dis_coefs(struct atomisp_sub_device *asd,
struct atomisp_dis_coefficients *coefs)
{ … }
void atomisp_css_set_zoom_factor(struct atomisp_sub_device *asd,
unsigned int zoom)
{ … }
void atomisp_css_set_formats_config(struct atomisp_sub_device *asd,
struct ia_css_formats_config *formats_config)
{ … }
int atomisp_css_get_wb_config(struct atomisp_sub_device *asd,
struct atomisp_wb_config *config)
{ … }
int atomisp_css_get_ob_config(struct atomisp_sub_device *asd,
struct atomisp_ob_config *config)
{ … }
int atomisp_css_get_dp_config(struct atomisp_sub_device *asd,
struct atomisp_dp_config *config)
{ … }
int atomisp_css_get_de_config(struct atomisp_sub_device *asd,
struct atomisp_de_config *config)
{ … }
int atomisp_css_get_nr_config(struct atomisp_sub_device *asd,
struct atomisp_nr_config *config)
{ … }
int atomisp_css_get_ee_config(struct atomisp_sub_device *asd,
struct atomisp_ee_config *config)
{ … }
int atomisp_css_get_tnr_config(struct atomisp_sub_device *asd,
struct atomisp_tnr_config *config)
{ … }
int atomisp_css_get_ctc_table(struct atomisp_sub_device *asd,
struct atomisp_ctc_table *config)
{ … }
int atomisp_css_get_gamma_table(struct atomisp_sub_device *asd,
struct atomisp_gamma_table *config)
{ … }
int atomisp_css_get_gc_config(struct atomisp_sub_device *asd,
struct atomisp_gc_config *config)
{ … }
int atomisp_css_get_3a_config(struct atomisp_sub_device *asd,
struct atomisp_3a_config *config)
{ … }
int atomisp_css_get_formats_config(struct atomisp_sub_device *asd,
struct atomisp_formats_config *config)
{ … }
int atomisp_css_get_zoom_factor(struct atomisp_sub_device *asd,
unsigned int *zoom)
{ … }
int atomisp_css_get_dis_stat(struct atomisp_sub_device *asd,
struct atomisp_dis_statistics *stats)
{ … }
struct ia_css_shading_table *atomisp_css_shading_table_alloc(
unsigned int width, unsigned int height)
{ … }
void atomisp_css_set_shading_table(struct atomisp_sub_device *asd,
struct ia_css_shading_table *table)
{ … }
void atomisp_css_shading_table_free(struct ia_css_shading_table *table)
{ … }
struct ia_css_morph_table *atomisp_css_morph_table_allocate(
unsigned int width, unsigned int height)
{ … }
void atomisp_css_set_morph_table(struct atomisp_sub_device *asd,
struct ia_css_morph_table *table)
{ … }
void atomisp_css_get_morph_table(struct atomisp_sub_device *asd,
struct ia_css_morph_table *table)
{ … }
void atomisp_css_morph_table_free(struct ia_css_morph_table *table)
{ … }
static bool atomisp_css_isr_get_stream_id(struct ia_css_pipe *css_pipe,
struct atomisp_device *isp,
enum atomisp_input_stream_id *stream_id)
{ … }
int atomisp_css_isr_thread(struct atomisp_device *isp)
{ … }
bool atomisp_css_valid_sof(struct atomisp_device *isp)
{ … }
int atomisp_css_debug_dump_isp_binary(void)
{ … }
int atomisp_css_dump_sp_raw_copy_linecount(bool reduced)
{ … }
static const char * const fw_type_name[] = …;
static const char * const fw_acc_type_name[] = …;
int atomisp_css_dump_blob_infor(struct atomisp_device *isp)
{ … }
void atomisp_css_set_isp_config_id(struct atomisp_sub_device *asd,
uint32_t isp_config_id)
{ … }
void atomisp_css_set_isp_config_applied_frame(struct atomisp_sub_device *asd,
struct ia_css_frame *output_frame)
{ … }
int atomisp_get_css_dbgfunc(void)
{ … }
int atomisp_set_css_dbgfunc(struct atomisp_device *isp, int opt)
{ … }
void atomisp_en_dz_capt_pipe(struct atomisp_sub_device *asd, bool enable)
{ … }
struct ia_css_dvs_grid_info *atomisp_css_get_dvs_grid_info(
struct ia_css_grid_info *grid_info)
{ … }