1 /* 2 * linux-5.4/drivers/media/platform/sunxi-vin/vin-isp/sunxi_isp.h 3 * 4 * Copyright (c) 2007-2017 Allwinnertech Co., Ltd. 5 * 6 * This software is licensed under the terms of the GNU General Public 7 * License version 2, as published by the Free Software Foundation, and 8 * may be copied, distributed, and modified under those terms. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 */ 16 17 #ifndef _SUNXI_ISP_H_ 18 #define _SUNXI_ISP_H_ 19 #include <linux/videodev2.h> 20 #include <media/v4l2-ctrls.h> 21 #include <media/v4l2-subdev.h> 22 #include "../vin-video/vin_core.h" 23 #if defined CONFIG_ARCH_SUN8IW16P1 24 #include "isp520/isp520_reg_cfg.h" 25 #elif defined CONFIG_ARCH_SUN8IW19P1 26 #include "isp521/isp521_reg_cfg.h" 27 #elif defined CONFIG_ARCH_SUN50IW10 28 #include "isp522/isp522_reg_cfg.h" 29 #else 30 #include "isp500/isp500_reg_cfg.h" 31 #endif 32 #include "../vin-stat/vin_h3a.h" 33 34 enum isp_pad { 35 ISP_PAD_SINK, 36 ISP_PAD_SOURCE_ST, 37 ISP_PAD_SOURCE, 38 ISP_PAD_NUM, 39 }; 40 41 struct isp_pix_fmt { 42 u32 mbus_code; 43 enum isp_input_seq infmt; 44 u32 fourcc; 45 }; 46 47 struct sunxi_isp_ctrls { 48 struct v4l2_ctrl_handler handler; 49 50 struct v4l2_ctrl *wb_gain[4]; /* wb gain cluster */ 51 struct v4l2_ctrl *ae_win[4]; /* wb win cluster */ 52 struct v4l2_ctrl *af_win[4]; /* af win cluster */ 53 }; 54 55 struct isp_dev { 56 struct v4l2_subdev subdev; 57 struct media_pad isp_pads[ISP_PAD_NUM]; 58 struct v4l2_event event; 59 struct platform_device *pdev; 60 struct sunxi_isp_ctrls ctrls; 61 struct mutex subdev_lock; 62 struct vin_mm isp_stat; 63 struct vin_mm isp_load; 64 struct vin_mm isp_save; 65 struct vin_mm isp_lut_tbl; 66 struct vin_mm isp_drc_tbl; 67 struct vin_mm d3d_pingpong[3]; 68 struct vin_mm wdr_pingpong[2]; 69 #if defined CONFIG_ARCH_SUN8IW19P1 70 struct isp_lbc_cfg wdr_raw_lbc; 71 struct isp_lbc_cfg d3d_k_lbc; 72 struct isp_lbc_cfg d3d_raw_lbc; 73 #endif 74 struct isp_size err_size; 75 struct isp_debug_mode isp_dbg; 76 struct isp_pix_fmt *isp_fmt; 77 struct isp_size_settings isp_ob; 78 struct v4l2_mbus_framefmt mf; 79 struct isp_stat h3a_stat; 80 spinlock_t slock; 81 void __iomem *base; 82 struct work_struct s_sensor_stby_task; 83 int irq; 84 unsigned int ptn_isp_cnt; 85 unsigned int event_lost_cnt; 86 unsigned int hb_max; 87 unsigned int hb_min; 88 unsigned int isp_frame_number; 89 unsigned char id; 90 char is_empty; 91 char use_isp; 92 char runtime_flag; 93 bool nosend_ispoff; 94 char have_init; 95 char load_flag; 96 char f1_after_librun;/*fisrt frame after server run*/ 97 char left_right;/*0: process left, 1: process right*/ 98 char use_cnt; 99 char capture_mode; 100 char wdr_mode; 101 char sensor_lp_mode; 102 char ptn_type; 103 char large_image;/*2:get merge yuv, 1: get pattern raw (save in kernel), 0: normal*/ 104 #ifdef SUPPORT_PTN 105 char load_shadow[ISP_LOAD_DRAM_SIZE*3]; 106 #else 107 char load_shadow[ISP_LOAD_DRAM_SIZE]; 108 #endif 109 }; 110 111 void sunxi_isp_reset(struct isp_dev *isp); 112 int sunxi_isp_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *parms); 113 int sunxi_isp_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *parms); 114 void sunxi_isp_sensor_type(struct v4l2_subdev *sd, int use_isp); 115 void sunxi_isp_sensor_fps(struct v4l2_subdev *sd, int fps); 116 void sunxi_isp_debug(struct v4l2_subdev *sd, struct isp_debug_mode *isp_debug); 117 void sunxi_isp_ptn(struct v4l2_subdev *sd, unsigned int ptn_type); 118 void sunxi_isp_frame_sync_isr(struct v4l2_subdev *sd); 119 struct v4l2_subdev *sunxi_isp_get_subdev(int id); 120 struct v4l2_subdev *sunxi_stat_get_subdev(int id); 121 int sunxi_isp_platform_register(void); 122 void sunxi_isp_platform_unregister(void); 123 124 #endif /*_SUNXI_ISP_H_*/ 125