1 /* 2 * Copyright (C) 2012 Texas Instruments Inc 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License as 6 * published by the Free Software Foundation version 2. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License 14 * along with this program; if not, write to the Free Software 15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 * 17 * Contributors: 18 * Manjunath Hadli <manjunath.hadli@ti.com> 19 * Prabhakar Lad <prabhakar.lad@ti.com> 20 */ 21 22 #ifndef _DAVINCI_VPFE_DM365_IPIPE_H 23 #define _DAVINCI_VPFE_DM365_IPIPE_H 24 25 #include <linux/platform_device.h> 26 27 #include <media/v4l2-ctrls.h> 28 #include <media/v4l2-subdev.h> 29 30 #include "davinci_vpfe_user.h" 31 #include "vpfe_video.h" 32 33 #define CEIL(a, b) (((a) + (b-1)) / (b)) 34 35 enum ipipe_noise_filter { 36 IPIPE_D2F_1ST = 0, 37 IPIPE_D2F_2ND = 1, 38 }; 39 40 /* Used for driver storage */ 41 struct ipipe_otfdpc_2_0 { 42 /* 0 - disable, 1 - enable */ 43 unsigned char en; 44 /* defect detection method */ 45 enum vpfe_ipipe_otfdpc_det_meth det_method; 46 /* Algorithm used. Applicable only when IPIPE_DPC_OTF_MIN_MAX2 is 47 * used 48 */ 49 enum vpfe_ipipe_otfdpc_alg alg; 50 struct vpfe_ipipe_otfdpc_2_0_cfg otfdpc_2_0; 51 }; 52 53 struct ipipe_otfdpc_3_0 { 54 /* 0 - disable, 1 - enable */ 55 unsigned char en; 56 /* defect detection method */ 57 enum vpfe_ipipe_otfdpc_det_meth det_method; 58 /* Algorithm used. Applicable only when IPIPE_DPC_OTF_MIN_MAX2 is 59 * used 60 */ 61 enum vpfe_ipipe_otfdpc_alg alg; 62 struct vpfe_ipipe_otfdpc_3_0_cfg otfdpc_3_0; 63 }; 64 65 /* Structure for configuring Luminance Adjustment module */ 66 struct ipipe_lum_adj { 67 /* Brightness adjustments */ 68 unsigned char brightness; 69 /* contrast adjustments */ 70 unsigned char contrast; 71 }; 72 73 enum ipipe_rgb2rgb { 74 IPIPE_RGB2RGB_1 = 0, 75 IPIPE_RGB2RGB_2 = 1, 76 }; 77 78 struct ipipe_module_params { 79 __u32 flag; 80 struct vpfe_ipipe_input_config input_config; 81 struct vpfe_ipipe_lutdpc lutdpc; 82 struct vpfe_ipipe_otfdpc otfdpc; 83 struct vpfe_ipipe_nf nf1; 84 struct vpfe_ipipe_nf nf2; 85 struct vpfe_ipipe_gic gic; 86 struct vpfe_ipipe_wb wbal; 87 struct vpfe_ipipe_cfa cfa; 88 struct vpfe_ipipe_rgb2rgb rgb2rgb1; 89 struct vpfe_ipipe_rgb2rgb rgb2rgb2; 90 struct vpfe_ipipe_gamma gamma; 91 struct vpfe_ipipe_3d_lut lut; 92 struct vpfe_ipipe_rgb2yuv rgb2yuv; 93 struct vpfe_ipipe_gbce gbce; 94 struct vpfe_ipipe_yuv422_conv yuv422_conv; 95 struct vpfe_ipipe_yee yee; 96 struct vpfe_ipipe_car car; 97 struct vpfe_ipipe_cgs cgs; 98 struct ipipe_lum_adj lum_adj; 99 }; 100 101 #define IPIPE_PAD_SINK 0 102 #define IPIPE_PAD_SOURCE 1 103 104 #define IPIPE_PADS_NUM 2 105 106 #define IPIPE_OUTPUT_NONE 0 107 #define IPIPE_OUTPUT_RESIZER (1 << 0) 108 109 enum ipipe_input_entity { 110 IPIPE_INPUT_NONE = 0, 111 IPIPE_INPUT_MEMORY = 1, 112 IPIPE_INPUT_CCDC = 2, 113 }; 114 115 116 struct vpfe_ipipe_device { 117 struct v4l2_subdev subdev; 118 struct media_pad pads[IPIPE_PADS_NUM]; 119 struct v4l2_mbus_framefmt formats[IPIPE_PADS_NUM]; 120 enum ipipe_input_entity input; 121 unsigned int output; 122 struct v4l2_ctrl_handler ctrls; 123 void __iomem *base_addr; 124 void __iomem *isp5_base_addr; 125 struct ipipe_module_params config; 126 }; 127 128 struct ipipe_module_if { 129 unsigned int param_offset; 130 unsigned int param_size; 131 unsigned int config_offset; 132 int (*set)(struct vpfe_ipipe_device *ipipe, void *param); 133 int (*get)(struct vpfe_ipipe_device *ipipe, void *param); 134 }; 135 136 /* data paths */ 137 enum ipipe_data_paths { 138 IPIPE_RAW2YUV, 139 /* Bayer RAW input to YCbCr output */ 140 IPIPE_RAW2RAW, 141 /* Bayer Raw to Bayer output */ 142 IPIPE_RAW2BOX, 143 /* Bayer Raw to Boxcar output */ 144 IPIPE_YUV2YUV 145 /* YUV Raw to YUV Raw output */ 146 }; 147 148 #define IPIPE_COLPTN_R_Ye 0x0 149 #define IPIPE_COLPTN_Gr_Cy 0x1 150 #define IPIPE_COLPTN_Gb_G 0x2 151 #define IPIPE_COLPTN_B_Mg 0x3 152 153 #define COLPAT_EE_SHIFT 0 154 #define COLPAT_EO_SHIFT 2 155 #define COLPAT_OE_SHIFT 4 156 #define COLPAT_OO_SHIFT 6 157 158 #define ipipe_sgrbg_pattern \ 159 (IPIPE_COLPTN_Gr_Cy << COLPAT_EE_SHIFT | \ 160 IPIPE_COLPTN_R_Ye << COLPAT_EO_SHIFT | \ 161 IPIPE_COLPTN_B_Mg << COLPAT_OE_SHIFT | \ 162 IPIPE_COLPTN_Gb_G << COLPAT_OO_SHIFT) 163 164 #define ipipe_srggb_pattern \ 165 (IPIPE_COLPTN_R_Ye << COLPAT_EE_SHIFT | \ 166 IPIPE_COLPTN_Gr_Cy << COLPAT_EO_SHIFT | \ 167 IPIPE_COLPTN_Gb_G << COLPAT_OE_SHIFT | \ 168 IPIPE_COLPTN_B_Mg << COLPAT_OO_SHIFT) 169 170 int vpfe_ipipe_register_entities(struct vpfe_ipipe_device *ipipe, 171 struct v4l2_device *v4l2_dev); 172 int vpfe_ipipe_init(struct vpfe_ipipe_device *ipipe, 173 struct platform_device *pdev); 174 void vpfe_ipipe_unregister_entities(struct vpfe_ipipe_device *ipipe); 175 void vpfe_ipipe_cleanup(struct vpfe_ipipe_device *ipipe, 176 struct platform_device *pdev); 177 void vpfe_ipipe_enable(struct vpfe_device *vpfe_dev, int en); 178 179 #endif /* _DAVINCI_VPFE_DM365_IPIPE_H */ 180