1231990Smp// SPDX-License-Identifier: GPL-2.0 259243Sobrien/* 359243Sobrien * Support for Intel Camera Imaging ISP subsystem. 459243Sobrien * Copyright (c) 2015, Intel Corporation. 559243Sobrien * 659243Sobrien * This program is free software; you can redistribute it and/or modify it 759243Sobrien * under the terms and conditions of the GNU General Public License, 859243Sobrien * version 2, as published by the Free Software Foundation. 959243Sobrien * 1059243Sobrien * This program is distributed in the hope it will be useful, but WITHOUT 1159243Sobrien * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1259243Sobrien * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 1359243Sobrien * more details. 1459243Sobrien */ 1559243Sobrien 1659243Sobrien#include "gdc_device.h" /* gdc_lut_store(), ... */ 17100616Smp#include "isp.h" /* ISP_VEC_ELEMBITS */ 1859243Sobrien#include "vamem.h" 1959243Sobrien#ifndef __INLINE_HMEM__ 2059243Sobrien#define __INLINE_HMEM__ 2159243Sobrien#endif 2259243Sobrien#include "hmem.h" 2359243Sobrien#define IA_CSS_INCLUDE_PARAMETERS 2459243Sobrien#define IA_CSS_INCLUDE_ACC_PARAMETERS 2559243Sobrien 2659243Sobrien#include "hmm.h" 2759243Sobrien#include "sh_css_params.h" 2859243Sobrien#include "ia_css_queue.h" 2959243Sobrien#include "sw_event_global.h" /* Event IDs */ 3059243Sobrien 3159243Sobrien#include "platform_support.h" 3259243Sobrien#include "assert_support.h" 3359243Sobrien#include "misc_support.h" /* NOT_USED */ 3459243Sobrien#include "math_support.h" /* max(), min() EVEN_FLOOR()*/ 35231990Smp 3659243Sobrien#include "ia_css_stream.h" 3759243Sobrien#include "sh_css_params_internal.h" 3859243Sobrien#include "sh_css_param_shading.h" 3959243Sobrien#include "sh_css_param_dvs.h" 4059243Sobrien#include "ia_css_refcount.h" 4159243Sobrien#include "sh_css_internal.h" 4259243Sobrien#include "ia_css_control.h" 4359243Sobrien#include "ia_css_shading.h" 4459243Sobrien#include "sh_css_defs.h" 4559243Sobrien#include "sh_css_sp.h" 4659243Sobrien#include "ia_css_pipeline.h" 47167465Smp#include "ia_css_debug.h" 4859243Sobrien 4959243Sobrien#include "ia_css_isp_param.h" 5059243Sobrien#include "ia_css_isp_params.h" 5159243Sobrien#include "ia_css_mipi.h" 5259243Sobrien#include "ia_css_morph.h" 5359243Sobrien#include "ia_css_host_data.h" 5459243Sobrien#include "ia_css_pipe.h" 5559243Sobrien#include "ia_css_pipe_binarydesc.h" 56167465Smp 5759243Sobrien/* Include all kernel host interfaces for ISP1 */ 5859243Sobrien 5959243Sobrien#include "anr/anr_1.0/ia_css_anr.host.h" 6059243Sobrien#include "cnr/cnr_1.0/ia_css_cnr.host.h" 6159243Sobrien#include "csc/csc_1.0/ia_css_csc.host.h" 6259243Sobrien#include "de/de_1.0/ia_css_de.host.h" 6359243Sobrien#include "dp/dp_1.0/ia_css_dp.host.h" 6459243Sobrien#include "bnr/bnr_1.0/ia_css_bnr.host.h" 6559243Sobrien#include "dvs/dvs_1.0/ia_css_dvs.host.h" 6659243Sobrien#include "fpn/fpn_1.0/ia_css_fpn.host.h" 6759243Sobrien#include "gc/gc_1.0/ia_css_gc.host.h" 6859243Sobrien#include "macc/macc_1.0/ia_css_macc.host.h" 6959243Sobrien#include "ctc/ctc_1.0/ia_css_ctc.host.h" 7059243Sobrien#include "ob/ob_1.0/ia_css_ob.host.h" 7159243Sobrien#include "raw/raw_1.0/ia_css_raw.host.h" 7259243Sobrien#include "fixedbds/fixedbds_1.0/ia_css_fixedbds_param.h" 73167465Smp#include "s3a/s3a_1.0/ia_css_s3a.host.h" 7459243Sobrien#include "sc/sc_1.0/ia_css_sc.host.h" 7559243Sobrien#include "sdis/sdis_1.0/ia_css_sdis.host.h" 7659243Sobrien#include "tnr/tnr_1.0/ia_css_tnr.host.h" 7759243Sobrien#include "uds/uds_1.0/ia_css_uds_param.h" 7859243Sobrien#include "wb/wb_1.0/ia_css_wb.host.h" 7959243Sobrien#include "ynr/ynr_1.0/ia_css_ynr.host.h" 8059243Sobrien#include "xnr/xnr_1.0/ia_css_xnr.host.h" 8159243Sobrien 8259243Sobrien/* Include additional kernel host interfaces for ISP2 */ 8359243Sobrien 8459243Sobrien#include "aa/aa_2/ia_css_aa2.host.h" 8559243Sobrien#include "anr/anr_2/ia_css_anr2.host.h" 8659243Sobrien#include "bh/bh_2/ia_css_bh.host.h" 8759243Sobrien#include "cnr/cnr_2/ia_css_cnr2.host.h" 88167465Smp#include "ctc/ctc1_5/ia_css_ctc1_5.host.h" 89167465Smp#include "de/de_2/ia_css_de2.host.h" 9059243Sobrien#include "gc/gc_2/ia_css_gc2.host.h" 91167465Smp#include "sdis/sdis_2/ia_css_sdis2.host.h" 9259243Sobrien#include "ynr/ynr_2/ia_css_ynr2.host.h" 9359243Sobrien#include "fc/fc_1.0/ia_css_formats.host.h" 94167465Smp 95167465Smp#include "xnr/xnr_3.0/ia_css_xnr3.host.h" 96167465Smp 97167465Smp 98167465Smp#include "sh_css_frac.h" 99167465Smp#include "ia_css_bufq.h" 100167465Smp 101167465Smpstatic size_t fpntbl_bytes(const struct ia_css_binary *binary) 102167465Smp{ 10359243Sobrien return array3_size(sizeof(char), 10459243Sobrien binary->in_frame_info.res.height, 10559243Sobrien binary->in_frame_info.padded_width); 10659243Sobrien} 10759243Sobrien 10859243Sobrienstatic size_t sctbl_bytes(const struct ia_css_binary *binary) 109167465Smp{ 11059243Sobrien return size_mul(sizeof(unsigned short), 11159243Sobrien array3_size(binary->sctbl_height, 11259243Sobrien binary->sctbl_aligned_width_per_color, 11359243Sobrien IA_CSS_SC_NUM_COLORS)); 114167465Smp} 11559243Sobrien 116167465Smpstatic size_t morph_plane_bytes(const struct ia_css_binary *binary) 117167465Smp{ 11859243Sobrien return array3_size(SH_CSS_MORPH_TABLE_ELEM_BYTES, 11959243Sobrien binary->morph_tbl_aligned_width, 120167465Smp binary->morph_tbl_height); 121167465Smp} 12259243Sobrien 123167465Smp/* We keep a second copy of the ptr struct for the SP to access. 12459243Sobrien Again, this would not be necessary on the chip. */ 125167465Smpstatic ia_css_ptr sp_ddr_ptrs; 12659243Sobrien 12759243Sobrien/* sp group address on DDR */ 12859243Sobrienstatic ia_css_ptr xmem_sp_group_ptrs; 129316958Sdchagin 13059243Sobrienstatic ia_css_ptr xmem_sp_stage_ptrs[IA_CSS_PIPE_ID_NUM] 131167465Smp[SH_CSS_MAX_STAGES]; 13259243Sobrienstatic ia_css_ptr xmem_isp_stage_ptrs[IA_CSS_PIPE_ID_NUM] 13359243Sobrien[SH_CSS_MAX_STAGES]; 13459243Sobrien 13559243Sobrienstatic ia_css_ptr default_gdc_lut; 13659243Sobrienstatic int interleaved_lut_temp[4][HRT_GDC_N]; 13759243Sobrien 13859243Sobrien/* END DO NOT MOVE INTO VIMALS_WORLD */ 13959243Sobrien 14059243Sobrien/* Digital Zoom lookup table. See documentation for more details about the 14159243Sobrien * contents of this table. 14259243Sobrien */ 143167465Smpstatic const int zoom_table[4][HRT_GDC_N] = { 14459243Sobrien { 145167465Smp 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 14659243Sobrien 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 147167465Smp 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 14859243Sobrien 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 14959243Sobrien 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 15059243Sobrien 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 15159243Sobrien 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 152167465Smp 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 15359243Sobrien 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 15459243Sobrien 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 15559243Sobrien 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 156167465Smp 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 15759243Sobrien -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, 15859243Sobrien -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, 15959243Sobrien -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, 160167465Smp -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, 161167465Smp -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, 16259243Sobrien -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, 163145479Smp -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, 16459243Sobrien -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, 16559243Sobrien -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, 166167465Smp -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, 16759243Sobrien -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, 16859243Sobrien -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, 169167465Smp -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, 170167465Smp -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, 17159243Sobrien -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, 172167465Smp -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, 17359243Sobrien -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, 17459243Sobrien -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, 17559243Sobrien -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, 17659243Sobrien -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, 17759243Sobrien -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, 17859243Sobrien -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, 17959243Sobrien -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, 180167465Smp -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, 18159243Sobrien -7 << 4, -7 << 4, -7 << 4, -7 << 4, -7 << 4, -7 << 4, -7 << 4, -7 << 4, 182167465Smp -7 << 4, -7 << 4, -7 << 4, -7 << 4, -7 << 4, -7 << 4, -7 << 4, -7 << 4, 18359243Sobrien -7 << 4, -7 << 4, -7 << 4, -7 << 4, -7 << 4, -7 << 4, -7 << 4, -7 << 4, 184167465Smp -7 << 4, -7 << 4, -7 << 4, -7 << 4, -7 << 4, -7 << 4, -7 << 4, -7 << 4, 18559243Sobrien -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, 18659243Sobrien -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, 18759243Sobrien -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, 18859243Sobrien -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, 18959243Sobrien -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, 19059243Sobrien -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, 19159243Sobrien -10 << 4, -10 << 4, -10 << 4, -10 << 4, -10 << 4, -10 << 4, -10 << 4, -10 << 4, 19259243Sobrien -10 << 4, -10 << 4, -10 << 4, -10 << 4, -10 << 4, -10 << 4, -10 << 4, -10 << 4, 193167465Smp -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, 19459243Sobrien -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, 19559243Sobrien -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, 19659243Sobrien -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, 19759243Sobrien -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, 19859243Sobrien -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, 19959243Sobrien -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, 20059243Sobrien -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, 20159243Sobrien -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, 20259243Sobrien -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, 20359243Sobrien -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, 204167465Smp -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, 20559243Sobrien -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, 206145479Smp -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, 207145479Smp -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, 208145479Smp -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, 209145479Smp -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, 21059243Sobrien -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, 21159243Sobrien -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, 212167465Smp -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, 21359243Sobrien -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, 21459243Sobrien -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, 215100616Smp -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, 21659243Sobrien -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, 21759243Sobrien -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, 21859243Sobrien -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, 21959243Sobrien -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 22059243Sobrien -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 22159243Sobrien -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 22259243Sobrien -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 22359243Sobrien -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 22459243Sobrien -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 22559243Sobrien -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 22659243Sobrien -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 227167465Smp -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 228167465Smp -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 22959243Sobrien -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 230167465Smp -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 231167465Smp -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 23259243Sobrien -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 23369408Sache -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 23469408Sache -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 23569408Sache -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 236231990Smp -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 237231990Smp -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 23869408Sache -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 239167465Smp -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 240167465Smp -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 241231990Smp -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 242167465Smp -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 243231990Smp -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, 244167465Smp -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, 245167465Smp -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, 24669408Sache -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, 24759243Sobrien -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, 24859243Sobrien -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, 24959243Sobrien -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, 25059243Sobrien -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, 251167465Smp -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, 25259243Sobrien -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, 25359243Sobrien -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, 254167465Smp -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, 255167465Smp -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, 25659243Sobrien -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, 25759243Sobrien -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, 25859243Sobrien -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, 259167465Smp -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, 26059243Sobrien -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, 26159243Sobrien -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, 26259243Sobrien -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, 26359243Sobrien -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, 26459243Sobrien -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, 26559243Sobrien -7 << 4, -7 << 4, -7 << 4, -7 << 4, -7 << 4, -7 << 4, -7 << 4, -7 << 4, 26659243Sobrien -7 << 4, -7 << 4, -7 << 4, -7 << 4, -7 << 4, -7 << 4, -7 << 4, -7 << 4, 26759243Sobrien -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, 268167465Smp -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, 26959243Sobrien -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, 270167465Smp -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, 27159243Sobrien -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, 27259243Sobrien -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4 27359243Sobrien }, 27459243Sobrien { 27569408Sache 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 27659243Sobrien 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 27759243Sobrien 2 << 4, 2 << 4, 2 << 4, 2 << 4, 2 << 4, 2 << 4, 2 << 4, 2 << 4, 27859243Sobrien 2 << 4, 2 << 4, 2 << 4, 2 << 4, 2 << 4, 2 << 4, 2 << 4, 2 << 4, 27969408Sache 4 << 4, 4 << 4, 4 << 4, 4 << 4, 4 << 4, 4 << 4, 4 << 4, 4 << 4, 28059243Sobrien 4 << 4, 4 << 4, 4 << 4, 4 << 4, 4 << 4, 4 << 4, 4 << 4, 4 << 4, 28159243Sobrien 7 << 4, 7 << 4, 7 << 4, 7 << 4, 7 << 4, 7 << 4, 7 << 4, 7 << 4, 28259243Sobrien 7 << 4, 7 << 4, 7 << 4, 7 << 4, 7 << 4, 7 << 4, 7 << 4, 7 << 4, 28359243Sobrien 9 << 4, 9 << 4, 9 << 4, 9 << 4, 9 << 4, 9 << 4, 9 << 4, 9 << 4, 28459243Sobrien 9 << 4, 9 << 4, 9 << 4, 9 << 4, 9 << 4, 9 << 4, 9 << 4, 9 << 4, 28559243Sobrien 12 << 4, 12 << 4, 12 << 4, 12 << 4, 12 << 4, 12 << 4, 12 << 4, 12 << 4, 28659243Sobrien 12 << 4, 12 << 4, 12 << 4, 12 << 4, 12 << 4, 12 << 4, 12 << 4, 12 << 4, 287167465Smp 16 << 4, 16 << 4, 16 << 4, 16 << 4, 16 << 4, 16 << 4, 16 << 4, 16 << 4, 28859243Sobrien 16 << 4, 16 << 4, 16 << 4, 16 << 4, 16 << 4, 16 << 4, 16 << 4, 16 << 4, 289145479Smp 19 << 4, 19 << 4, 19 << 4, 19 << 4, 19 << 4, 19 << 4, 19 << 4, 19 << 4, 290145479Smp 19 << 4, 19 << 4, 19 << 4, 19 << 4, 19 << 4, 19 << 4, 19 << 4, 19 << 4, 29159243Sobrien 23 << 4, 23 << 4, 23 << 4, 23 << 4, 23 << 4, 23 << 4, 23 << 4, 23 << 4, 29259243Sobrien 23 << 4, 23 << 4, 23 << 4, 23 << 4, 23 << 4, 23 << 4, 23 << 4, 23 << 4, 29359243Sobrien 27 << 4, 27 << 4, 27 << 4, 27 << 4, 27 << 4, 27 << 4, 27 << 4, 27 << 4, 29459243Sobrien 27 << 4, 27 << 4, 27 << 4, 27 << 4, 27 << 4, 27 << 4, 27 << 4, 27 << 4, 29559243Sobrien 31 << 4, 31 << 4, 31 << 4, 31 << 4, 31 << 4, 31 << 4, 31 << 4, 31 << 4, 29659243Sobrien 31 << 4, 31 << 4, 31 << 4, 31 << 4, 31 << 4, 31 << 4, 31 << 4, 31 << 4, 29759243Sobrien 35 << 4, 35 << 4, 35 << 4, 35 << 4, 35 << 4, 35 << 4, 35 << 4, 35 << 4, 29859243Sobrien 35 << 4, 35 << 4, 35 << 4, 35 << 4, 35 << 4, 35 << 4, 35 << 4, 35 << 4, 29959243Sobrien 39 << 4, 39 << 4, 39 << 4, 39 << 4, 39 << 4, 39 << 4, 39 << 4, 39 << 4, 30059243Sobrien 39 << 4, 39 << 4, 39 << 4, 39 << 4, 39 << 4, 39 << 4, 39 << 4, 39 << 4, 30159243Sobrien 43 << 4, 43 << 4, 43 << 4, 43 << 4, 43 << 4, 43 << 4, 43 << 4, 43 << 4, 30259243Sobrien 43 << 4, 43 << 4, 43 << 4, 43 << 4, 43 << 4, 43 << 4, 43 << 4, 43 << 4, 30359243Sobrien 48 << 4, 48 << 4, 48 << 4, 48 << 4, 48 << 4, 48 << 4, 48 << 4, 48 << 4, 30459243Sobrien 48 << 4, 48 << 4, 48 << 4, 48 << 4, 48 << 4, 48 << 4, 48 << 4, 48 << 4, 30559243Sobrien 53 << 4, 53 << 4, 53 << 4, 53 << 4, 53 << 4, 53 << 4, 53 << 4, 53 << 4, 30659243Sobrien 53 << 4, 53 << 4, 53 << 4, 53 << 4, 53 << 4, 53 << 4, 53 << 4, 53 << 4, 30759243Sobrien 58 << 4, 58 << 4, 58 << 4, 58 << 4, 58 << 4, 58 << 4, 58 << 4, 58 << 4, 30859243Sobrien 58 << 4, 58 << 4, 58 << 4, 58 << 4, 58 << 4, 58 << 4, 58 << 4, 58 << 4, 30959243Sobrien 62 << 4, 62 << 4, 62 << 4, 62 << 4, 62 << 4, 62 << 4, 62 << 4, 62 << 4, 31059243Sobrien 62 << 4, 62 << 4, 62 << 4, 62 << 4, 62 << 4, 62 << 4, 62 << 4, 62 << 4, 31159243Sobrien 67 << 4, 67 << 4, 67 << 4, 67 << 4, 67 << 4, 67 << 4, 67 << 4, 67 << 4, 31259243Sobrien 67 << 4, 67 << 4, 67 << 4, 67 << 4, 67 << 4, 67 << 4, 67 << 4, 67 << 4, 31359243Sobrien 73 << 4, 73 << 4, 73 << 4, 73 << 4, 73 << 4, 73 << 4, 73 << 4, 73 << 4, 31459243Sobrien 73 << 4, 73 << 4, 73 << 4, 73 << 4, 73 << 4, 73 << 4, 73 << 4, 73 << 4, 31559243Sobrien 78 << 4, 78 << 4, 78 << 4, 78 << 4, 78 << 4, 78 << 4, 78 << 4, 78 << 4, 31659243Sobrien 78 << 4, 78 << 4, 78 << 4, 78 << 4, 78 << 4, 78 << 4, 78 << 4, 78 << 4, 31759243Sobrien 83 << 4, 83 << 4, 83 << 4, 83 << 4, 83 << 4, 83 << 4, 83 << 4, 83 << 4, 318167465Smp 83 << 4, 83 << 4, 83 << 4, 83 << 4, 83 << 4, 83 << 4, 83 << 4, 83 << 4, 31959243Sobrien 88 << 4, 88 << 4, 88 << 4, 88 << 4, 88 << 4, 88 << 4, 88 << 4, 88 << 4, 320167465Smp 88 << 4, 88 << 4, 88 << 4, 88 << 4, 88 << 4, 88 << 4, 88 << 4, 88 << 4, 32159243Sobrien 94 << 4, 94 << 4, 94 << 4, 94 << 4, 94 << 4, 94 << 4, 94 << 4, 94 << 4, 322167465Smp 94 << 4, 94 << 4, 94 << 4, 94 << 4, 94 << 4, 94 << 4, 94 << 4, 94 << 4, 32359243Sobrien 99 << 4, 99 << 4, 99 << 4, 99 << 4, 99 << 4, 99 << 4, 99 << 4, 99 << 4, 324167465Smp 99 << 4, 99 << 4, 99 << 4, 99 << 4, 99 << 4, 99 << 4, 99 << 4, 99 << 4, 32559243Sobrien 105 << 4, 105 << 4, 105 << 4, 105 << 4, 105 << 4, 105 << 4, 105 << 4, 105 << 4, 32659243Sobrien 105 << 4, 105 << 4, 105 << 4, 105 << 4, 105 << 4, 105 << 4, 105 << 4, 105 << 4, 327167465Smp 110 << 4, 110 << 4, 110 << 4, 110 << 4, 110 << 4, 110 << 4, 110 << 4, 110 << 4, 32859243Sobrien 110 << 4, 110 << 4, 110 << 4, 110 << 4, 110 << 4, 110 << 4, 110 << 4, 110 << 4, 32959243Sobrien 116 << 4, 116 << 4, 116 << 4, 116 << 4, 116 << 4, 116 << 4, 116 << 4, 116 << 4, 33059243Sobrien 116 << 4, 116 << 4, 116 << 4, 116 << 4, 116 << 4, 116 << 4, 116 << 4, 116 << 4, 33159243Sobrien 121 << 4, 121 << 4, 121 << 4, 121 << 4, 121 << 4, 121 << 4, 121 << 4, 121 << 4, 33259243Sobrien 121 << 4, 121 << 4, 121 << 4, 121 << 4, 121 << 4, 121 << 4, 121 << 4, 121 << 4, 33359243Sobrien 127 << 4, 127 << 4, 127 << 4, 127 << 4, 127 << 4, 127 << 4, 127 << 4, 127 << 4, 33459243Sobrien 127 << 4, 127 << 4, 127 << 4, 127 << 4, 127 << 4, 127 << 4, 127 << 4, 127 << 4, 33559243Sobrien 132 << 4, 132 << 4, 132 << 4, 132 << 4, 132 << 4, 132 << 4, 132 << 4, 132 << 4, 33659243Sobrien 132 << 4, 132 << 4, 132 << 4, 132 << 4, 132 << 4, 132 << 4, 132 << 4, 132 << 4, 337167465Smp 138 << 4, 138 << 4, 138 << 4, 138 << 4, 138 << 4, 138 << 4, 138 << 4, 138 << 4, 33859243Sobrien 138 << 4, 138 << 4, 138 << 4, 138 << 4, 138 << 4, 138 << 4, 138 << 4, 138 << 4, 33959243Sobrien 144 << 4, 144 << 4, 144 << 4, 144 << 4, 144 << 4, 144 << 4, 144 << 4, 144 << 4, 34059243Sobrien 144 << 4, 144 << 4, 144 << 4, 144 << 4, 144 << 4, 144 << 4, 144 << 4, 144 << 4, 34159243Sobrien 149 << 4, 149 << 4, 149 << 4, 149 << 4, 149 << 4, 149 << 4, 149 << 4, 149 << 4, 34259243Sobrien 149 << 4, 149 << 4, 149 << 4, 149 << 4, 149 << 4, 149 << 4, 149 << 4, 149 << 4, 34359243Sobrien 154 << 4, 154 << 4, 154 << 4, 154 << 4, 154 << 4, 154 << 4, 154 << 4, 154 << 4, 34459243Sobrien 154 << 4, 154 << 4, 154 << 4, 154 << 4, 154 << 4, 154 << 4, 154 << 4, 154 << 4, 34559243Sobrien 160 << 4, 160 << 4, 160 << 4, 160 << 4, 160 << 4, 160 << 4, 160 << 4, 160 << 4, 34659243Sobrien 160 << 4, 160 << 4, 160 << 4, 160 << 4, 160 << 4, 160 << 4, 160 << 4, 160 << 4, 347167465Smp 165 << 4, 165 << 4, 165 << 4, 165 << 4, 165 << 4, 165 << 4, 165 << 4, 165 << 4, 34859243Sobrien 165 << 4, 165 << 4, 165 << 4, 165 << 4, 165 << 4, 165 << 4, 165 << 4, 165 << 4, 34959243Sobrien 170 << 4, 170 << 4, 170 << 4, 170 << 4, 170 << 4, 170 << 4, 170 << 4, 170 << 4, 35059243Sobrien 170 << 4, 170 << 4, 170 << 4, 170 << 4, 170 << 4, 170 << 4, 170 << 4, 170 << 4, 35159243Sobrien 176 << 4, 176 << 4, 176 << 4, 176 << 4, 176 << 4, 176 << 4, 176 << 4, 176 << 4, 35259243Sobrien 176 << 4, 176 << 4, 176 << 4, 176 << 4, 176 << 4, 176 << 4, 176 << 4, 176 << 4, 35359243Sobrien 181 << 4, 181 << 4, 181 << 4, 181 << 4, 181 << 4, 181 << 4, 181 << 4, 181 << 4, 35459243Sobrien 181 << 4, 181 << 4, 181 << 4, 181 << 4, 181 << 4, 181 << 4, 181 << 4, 181 << 4, 35559243Sobrien 186 << 4, 186 << 4, 186 << 4, 186 << 4, 186 << 4, 186 << 4, 186 << 4, 186 << 4, 35659243Sobrien 186 << 4, 186 << 4, 186 << 4, 186 << 4, 186 << 4, 186 << 4, 186 << 4, 186 << 4, 35759243Sobrien 191 << 4, 191 << 4, 191 << 4, 191 << 4, 191 << 4, 191 << 4, 191 << 4, 191 << 4, 35859243Sobrien 191 << 4, 191 << 4, 191 << 4, 191 << 4, 191 << 4, 191 << 4, 191 << 4, 191 << 4, 35959243Sobrien 195 << 4, 195 << 4, 195 << 4, 195 << 4, 195 << 4, 195 << 4, 195 << 4, 195 << 4, 36059243Sobrien 195 << 4, 195 << 4, 195 << 4, 195 << 4, 195 << 4, 195 << 4, 195 << 4, 195 << 4, 36159243Sobrien 200 << 4, 200 << 4, 200 << 4, 200 << 4, 200 << 4, 200 << 4, 200 << 4, 200 << 4, 36259243Sobrien 200 << 4, 200 << 4, 200 << 4, 200 << 4, 200 << 4, 200 << 4, 200 << 4, 200 << 4, 36359243Sobrien 205 << 4, 205 << 4, 205 << 4, 205 << 4, 205 << 4, 205 << 4, 205 << 4, 205 << 4, 36459243Sobrien 205 << 4, 205 << 4, 205 << 4, 205 << 4, 205 << 4, 205 << 4, 205 << 4, 205 << 4, 36559243Sobrien 209 << 4, 209 << 4, 209 << 4, 209 << 4, 209 << 4, 209 << 4, 209 << 4, 209 << 4, 36659243Sobrien 209 << 4, 209 << 4, 209 << 4, 209 << 4, 209 << 4, 209 << 4, 209 << 4, 209 << 4, 36759243Sobrien 213 << 4, 213 << 4, 213 << 4, 213 << 4, 213 << 4, 213 << 4, 213 << 4, 213 << 4, 36859243Sobrien 213 << 4, 213 << 4, 213 << 4, 213 << 4, 213 << 4, 213 << 4, 213 << 4, 213 << 4, 36959243Sobrien 218 << 4, 218 << 4, 218 << 4, 218 << 4, 218 << 4, 218 << 4, 218 << 4, 218 << 4, 37059243Sobrien 218 << 4, 218 << 4, 218 << 4, 218 << 4, 218 << 4, 218 << 4, 218 << 4, 218 << 4, 37159243Sobrien 222 << 4, 222 << 4, 222 << 4, 222 << 4, 222 << 4, 222 << 4, 222 << 4, 222 << 4, 37259243Sobrien 222 << 4, 222 << 4, 222 << 4, 222 << 4, 222 << 4, 222 << 4, 222 << 4, 222 << 4, 37359243Sobrien 225 << 4, 225 << 4, 225 << 4, 225 << 4, 225 << 4, 225 << 4, 225 << 4, 225 << 4, 37459243Sobrien 225 << 4, 225 << 4, 225 << 4, 225 << 4, 225 << 4, 225 << 4, 225 << 4, 225 << 4, 37559243Sobrien 229 << 4, 229 << 4, 229 << 4, 229 << 4, 229 << 4, 229 << 4, 229 << 4, 229 << 4, 37659243Sobrien 229 << 4, 229 << 4, 229 << 4, 229 << 4, 229 << 4, 229 << 4, 229 << 4, 229 << 4, 37759243Sobrien 232 << 4, 232 << 4, 232 << 4, 232 << 4, 232 << 4, 232 << 4, 232 << 4, 232 << 4, 37859243Sobrien 232 << 4, 232 << 4, 232 << 4, 232 << 4, 232 << 4, 232 << 4, 232 << 4, 232 << 4, 37959243Sobrien 236 << 4, 236 << 4, 236 << 4, 236 << 4, 236 << 4, 236 << 4, 236 << 4, 236 << 4, 38059243Sobrien 236 << 4, 236 << 4, 236 << 4, 236 << 4, 236 << 4, 236 << 4, 236 << 4, 236 << 4, 38159243Sobrien 239 << 4, 239 << 4, 239 << 4, 239 << 4, 239 << 4, 239 << 4, 239 << 4, 239 << 4, 38259243Sobrien 239 << 4, 239 << 4, 239 << 4, 239 << 4, 239 << 4, 239 << 4, 239 << 4, 239 << 4, 38359243Sobrien 241 << 4, 241 << 4, 241 << 4, 241 << 4, 241 << 4, 241 << 4, 241 << 4, 241 << 4, 38459243Sobrien 241 << 4, 241 << 4, 241 << 4, 241 << 4, 241 << 4, 241 << 4, 241 << 4, 241 << 4, 38559243Sobrien 244 << 4, 244 << 4, 244 << 4, 244 << 4, 244 << 4, 244 << 4, 244 << 4, 244 << 4, 38659243Sobrien 244 << 4, 244 << 4, 244 << 4, 244 << 4, 244 << 4, 244 << 4, 244 << 4, 244 << 4, 38759243Sobrien 246 << 4, 246 << 4, 246 << 4, 246 << 4, 246 << 4, 246 << 4, 246 << 4, 246 << 4, 38859243Sobrien 246 << 4, 246 << 4, 246 << 4, 246 << 4, 246 << 4, 246 << 4, 246 << 4, 246 << 4, 38959243Sobrien 248 << 4, 248 << 4, 248 << 4, 248 << 4, 248 << 4, 248 << 4, 248 << 4, 248 << 4, 390167465Smp 248 << 4, 248 << 4, 248 << 4, 248 << 4, 248 << 4, 248 << 4, 248 << 4, 248 << 4, 391167465Smp 250 << 4, 250 << 4, 250 << 4, 250 << 4, 250 << 4, 250 << 4, 250 << 4, 250 << 4, 39259243Sobrien 250 << 4, 250 << 4, 250 << 4, 250 << 4, 250 << 4, 250 << 4, 250 << 4, 250 << 4, 393167465Smp 252 << 4, 252 << 4, 252 << 4, 252 << 4, 252 << 4, 252 << 4, 252 << 4, 252 << 4, 394167465Smp 252 << 4, 252 << 4, 252 << 4, 252 << 4, 252 << 4, 252 << 4, 252 << 4, 252 << 4, 39559243Sobrien 253 << 4, 253 << 4, 253 << 4, 253 << 4, 253 << 4, 253 << 4, 253 << 4, 253 << 4, 39659243Sobrien 253 << 4, 253 << 4, 253 << 4, 253 << 4, 253 << 4, 253 << 4, 253 << 4, 253 << 4, 39759243Sobrien 254 << 4, 254 << 4, 254 << 4, 254 << 4, 254 << 4, 254 << 4, 254 << 4, 254 << 4, 398167465Smp 254 << 4, 254 << 4, 254 << 4, 254 << 4, 254 << 4, 254 << 4, 254 << 4, 254 << 4, 399167465Smp 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 40059243Sobrien 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 40159243Sobrien 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 40259243Sobrien 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4 40359243Sobrien }, 40459243Sobrien { 405167465Smp 256 << 4, 256 << 4, 256 << 4, 256 << 4, 256 << 4, 256 << 4, 256 << 4, 256 << 4, 406231990Smp 256 << 4, 256 << 4, 256 << 4, 256 << 4, 256 << 4, 256 << 4, 256 << 4, 256 << 4, 407167465Smp 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 40859243Sobrien 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 40959243Sobrien 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 41059243Sobrien 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 255 << 4, 41159243Sobrien 254 << 4, 254 << 4, 254 << 4, 254 << 4, 254 << 4, 254 << 4, 254 << 4, 254 << 4, 41259243Sobrien 254 << 4, 254 << 4, 254 << 4, 254 << 4, 254 << 4, 254 << 4, 254 << 4, 254 << 4, 41359243Sobrien 253 << 4, 253 << 4, 253 << 4, 253 << 4, 253 << 4, 253 << 4, 253 << 4, 253 << 4, 414231990Smp 253 << 4, 253 << 4, 253 << 4, 253 << 4, 253 << 4, 253 << 4, 253 << 4, 253 << 4, 415167465Smp 252 << 4, 252 << 4, 252 << 4, 252 << 4, 252 << 4, 252 << 4, 252 << 4, 252 << 4, 416167465Smp 252 << 4, 252 << 4, 252 << 4, 252 << 4, 252 << 4, 252 << 4, 252 << 4, 252 << 4, 41759243Sobrien 250 << 4, 250 << 4, 250 << 4, 250 << 4, 250 << 4, 250 << 4, 250 << 4, 250 << 4, 41859243Sobrien 250 << 4, 250 << 4, 250 << 4, 250 << 4, 250 << 4, 250 << 4, 250 << 4, 250 << 4, 41959243Sobrien 248 << 4, 248 << 4, 248 << 4, 248 << 4, 248 << 4, 248 << 4, 248 << 4, 248 << 4, 42059243Sobrien 248 << 4, 248 << 4, 248 << 4, 248 << 4, 248 << 4, 248 << 4, 248 << 4, 248 << 4, 421167465Smp 246 << 4, 246 << 4, 246 << 4, 246 << 4, 246 << 4, 246 << 4, 246 << 4, 246 << 4, 42259243Sobrien 246 << 4, 246 << 4, 246 << 4, 246 << 4, 246 << 4, 246 << 4, 246 << 4, 246 << 4, 42359243Sobrien 244 << 4, 244 << 4, 244 << 4, 244 << 4, 244 << 4, 244 << 4, 244 << 4, 244 << 4, 424167465Smp 244 << 4, 244 << 4, 244 << 4, 244 << 4, 244 << 4, 244 << 4, 244 << 4, 244 << 4, 42559243Sobrien 241 << 4, 241 << 4, 241 << 4, 241 << 4, 241 << 4, 241 << 4, 241 << 4, 241 << 4, 42659243Sobrien 241 << 4, 241 << 4, 241 << 4, 241 << 4, 241 << 4, 241 << 4, 241 << 4, 241 << 4, 427167465Smp 239 << 4, 239 << 4, 239 << 4, 239 << 4, 239 << 4, 239 << 4, 239 << 4, 239 << 4, 428167465Smp 239 << 4, 239 << 4, 239 << 4, 239 << 4, 239 << 4, 239 << 4, 239 << 4, 239 << 4, 42959243Sobrien 236 << 4, 236 << 4, 236 << 4, 236 << 4, 236 << 4, 236 << 4, 236 << 4, 236 << 4, 43059243Sobrien 236 << 4, 236 << 4, 236 << 4, 236 << 4, 236 << 4, 236 << 4, 236 << 4, 236 << 4, 43159243Sobrien 232 << 4, 232 << 4, 232 << 4, 232 << 4, 232 << 4, 232 << 4, 232 << 4, 232 << 4, 432167465Smp 232 << 4, 232 << 4, 232 << 4, 232 << 4, 232 << 4, 232 << 4, 232 << 4, 232 << 4, 43359243Sobrien 229 << 4, 229 << 4, 229 << 4, 229 << 4, 229 << 4, 229 << 4, 229 << 4, 229 << 4, 43459243Sobrien 229 << 4, 229 << 4, 229 << 4, 229 << 4, 229 << 4, 229 << 4, 229 << 4, 229 << 4, 43559243Sobrien 225 << 4, 225 << 4, 225 << 4, 225 << 4, 225 << 4, 225 << 4, 225 << 4, 225 << 4, 436167465Smp 225 << 4, 225 << 4, 225 << 4, 225 << 4, 225 << 4, 225 << 4, 225 << 4, 225 << 4, 43759243Sobrien 222 << 4, 222 << 4, 222 << 4, 222 << 4, 222 << 4, 222 << 4, 222 << 4, 222 << 4, 43859243Sobrien 222 << 4, 222 << 4, 222 << 4, 222 << 4, 222 << 4, 222 << 4, 222 << 4, 222 << 4, 43959243Sobrien 218 << 4, 218 << 4, 218 << 4, 218 << 4, 218 << 4, 218 << 4, 218 << 4, 218 << 4, 44059243Sobrien 218 << 4, 218 << 4, 218 << 4, 218 << 4, 218 << 4, 218 << 4, 218 << 4, 218 << 4, 44159243Sobrien 213 << 4, 213 << 4, 213 << 4, 213 << 4, 213 << 4, 213 << 4, 213 << 4, 213 << 4, 44259243Sobrien 213 << 4, 213 << 4, 213 << 4, 213 << 4, 213 << 4, 213 << 4, 213 << 4, 213 << 4, 44359243Sobrien 209 << 4, 209 << 4, 209 << 4, 209 << 4, 209 << 4, 209 << 4, 209 << 4, 209 << 4, 444167465Smp 209 << 4, 209 << 4, 209 << 4, 209 << 4, 209 << 4, 209 << 4, 209 << 4, 209 << 4, 44559243Sobrien 205 << 4, 205 << 4, 205 << 4, 205 << 4, 205 << 4, 205 << 4, 205 << 4, 205 << 4, 44659243Sobrien 205 << 4, 205 << 4, 205 << 4, 205 << 4, 205 << 4, 205 << 4, 205 << 4, 205 << 4, 44759243Sobrien 200 << 4, 200 << 4, 200 << 4, 200 << 4, 200 << 4, 200 << 4, 200 << 4, 200 << 4, 44859243Sobrien 200 << 4, 200 << 4, 200 << 4, 200 << 4, 200 << 4, 200 << 4, 200 << 4, 200 << 4, 44959243Sobrien 195 << 4, 195 << 4, 195 << 4, 195 << 4, 195 << 4, 195 << 4, 195 << 4, 195 << 4, 45059243Sobrien 195 << 4, 195 << 4, 195 << 4, 195 << 4, 195 << 4, 195 << 4, 195 << 4, 195 << 4, 45159243Sobrien 191 << 4, 191 << 4, 191 << 4, 191 << 4, 191 << 4, 191 << 4, 191 << 4, 191 << 4, 45259243Sobrien 191 << 4, 191 << 4, 191 << 4, 191 << 4, 191 << 4, 191 << 4, 191 << 4, 191 << 4, 45359243Sobrien 186 << 4, 186 << 4, 186 << 4, 186 << 4, 186 << 4, 186 << 4, 186 << 4, 186 << 4, 45459243Sobrien 186 << 4, 186 << 4, 186 << 4, 186 << 4, 186 << 4, 186 << 4, 186 << 4, 186 << 4, 45559243Sobrien 181 << 4, 181 << 4, 181 << 4, 181 << 4, 181 << 4, 181 << 4, 181 << 4, 181 << 4, 45659243Sobrien 181 << 4, 181 << 4, 181 << 4, 181 << 4, 181 << 4, 181 << 4, 181 << 4, 181 << 4, 45759243Sobrien 176 << 4, 176 << 4, 176 << 4, 176 << 4, 176 << 4, 176 << 4, 176 << 4, 176 << 4, 45859243Sobrien 176 << 4, 176 << 4, 176 << 4, 176 << 4, 176 << 4, 176 << 4, 176 << 4, 176 << 4, 45959243Sobrien 170 << 4, 170 << 4, 170 << 4, 170 << 4, 170 << 4, 170 << 4, 170 << 4, 170 << 4, 46059243Sobrien 170 << 4, 170 << 4, 170 << 4, 170 << 4, 170 << 4, 170 << 4, 170 << 4, 170 << 4, 46159243Sobrien 165 << 4, 165 << 4, 165 << 4, 165 << 4, 165 << 4, 165 << 4, 165 << 4, 165 << 4, 46259243Sobrien 165 << 4, 165 << 4, 165 << 4, 165 << 4, 165 << 4, 165 << 4, 165 << 4, 165 << 4, 46359243Sobrien 160 << 4, 160 << 4, 160 << 4, 160 << 4, 160 << 4, 160 << 4, 160 << 4, 160 << 4, 46459243Sobrien 160 << 4, 160 << 4, 160 << 4, 160 << 4, 160 << 4, 160 << 4, 160 << 4, 160 << 4, 46559243Sobrien 154 << 4, 154 << 4, 154 << 4, 154 << 4, 154 << 4, 154 << 4, 154 << 4, 154 << 4, 46659243Sobrien 154 << 4, 154 << 4, 154 << 4, 154 << 4, 154 << 4, 154 << 4, 154 << 4, 154 << 4, 46759243Sobrien 149 << 4, 149 << 4, 149 << 4, 149 << 4, 149 << 4, 149 << 4, 149 << 4, 149 << 4, 46859243Sobrien 149 << 4, 149 << 4, 149 << 4, 149 << 4, 149 << 4, 149 << 4, 149 << 4, 149 << 4, 46959243Sobrien 144 << 4, 144 << 4, 144 << 4, 144 << 4, 144 << 4, 144 << 4, 144 << 4, 144 << 4, 47059243Sobrien 144 << 4, 144 << 4, 144 << 4, 144 << 4, 144 << 4, 144 << 4, 144 << 4, 144 << 4, 47159243Sobrien 138 << 4, 138 << 4, 138 << 4, 138 << 4, 138 << 4, 138 << 4, 138 << 4, 138 << 4, 47259243Sobrien 138 << 4, 138 << 4, 138 << 4, 138 << 4, 138 << 4, 138 << 4, 138 << 4, 138 << 4, 47359243Sobrien 132 << 4, 132 << 4, 132 << 4, 132 << 4, 132 << 4, 132 << 4, 132 << 4, 132 << 4, 47459243Sobrien 132 << 4, 132 << 4, 132 << 4, 132 << 4, 132 << 4, 132 << 4, 132 << 4, 132 << 4, 475167465Smp 127 << 4, 127 << 4, 127 << 4, 127 << 4, 127 << 4, 127 << 4, 127 << 4, 127 << 4, 476167465Smp 127 << 4, 127 << 4, 127 << 4, 127 << 4, 127 << 4, 127 << 4, 127 << 4, 127 << 4, 47759243Sobrien 121 << 4, 121 << 4, 121 << 4, 121 << 4, 121 << 4, 121 << 4, 121 << 4, 121 << 4, 478145479Smp 121 << 4, 121 << 4, 121 << 4, 121 << 4, 121 << 4, 121 << 4, 121 << 4, 121 << 4, 479145479Smp 116 << 4, 116 << 4, 116 << 4, 116 << 4, 116 << 4, 116 << 4, 116 << 4, 116 << 4, 48059243Sobrien 116 << 4, 116 << 4, 116 << 4, 116 << 4, 116 << 4, 116 << 4, 116 << 4, 116 << 4, 48159243Sobrien 110 << 4, 110 << 4, 110 << 4, 110 << 4, 110 << 4, 110 << 4, 110 << 4, 110 << 4, 48259243Sobrien 110 << 4, 110 << 4, 110 << 4, 110 << 4, 110 << 4, 110 << 4, 110 << 4, 110 << 4, 48359243Sobrien 105 << 4, 105 << 4, 105 << 4, 105 << 4, 105 << 4, 105 << 4, 105 << 4, 105 << 4, 484167465Smp 105 << 4, 105 << 4, 105 << 4, 105 << 4, 105 << 4, 105 << 4, 105 << 4, 105 << 4, 48559243Sobrien 99 << 4, 99 << 4, 99 << 4, 99 << 4, 99 << 4, 99 << 4, 99 << 4, 99 << 4, 486167465Smp 99 << 4, 99 << 4, 99 << 4, 99 << 4, 99 << 4, 99 << 4, 99 << 4, 99 << 4, 48759243Sobrien 94 << 4, 94 << 4, 94 << 4, 94 << 4, 94 << 4, 94 << 4, 94 << 4, 94 << 4, 48859243Sobrien 94 << 4, 94 << 4, 94 << 4, 94 << 4, 94 << 4, 94 << 4, 94 << 4, 94 << 4, 48959243Sobrien 88 << 4, 88 << 4, 88 << 4, 88 << 4, 88 << 4, 88 << 4, 88 << 4, 88 << 4, 49059243Sobrien 88 << 4, 88 << 4, 88 << 4, 88 << 4, 88 << 4, 88 << 4, 88 << 4, 88 << 4, 49159243Sobrien 83 << 4, 83 << 4, 83 << 4, 83 << 4, 83 << 4, 83 << 4, 83 << 4, 83 << 4, 49259243Sobrien 83 << 4, 83 << 4, 83 << 4, 83 << 4, 83 << 4, 83 << 4, 83 << 4, 83 << 4, 49359243Sobrien 78 << 4, 78 << 4, 78 << 4, 78 << 4, 78 << 4, 78 << 4, 78 << 4, 78 << 4, 49459243Sobrien 78 << 4, 78 << 4, 78 << 4, 78 << 4, 78 << 4, 78 << 4, 78 << 4, 78 << 4, 49559243Sobrien 73 << 4, 73 << 4, 73 << 4, 73 << 4, 73 << 4, 73 << 4, 73 << 4, 73 << 4, 49659243Sobrien 73 << 4, 73 << 4, 73 << 4, 73 << 4, 73 << 4, 73 << 4, 73 << 4, 73 << 4, 49759243Sobrien 67 << 4, 67 << 4, 67 << 4, 67 << 4, 67 << 4, 67 << 4, 67 << 4, 67 << 4, 49859243Sobrien 67 << 4, 67 << 4, 67 << 4, 67 << 4, 67 << 4, 67 << 4, 67 << 4, 67 << 4, 49959243Sobrien 62 << 4, 62 << 4, 62 << 4, 62 << 4, 62 << 4, 62 << 4, 62 << 4, 62 << 4, 50059243Sobrien 62 << 4, 62 << 4, 62 << 4, 62 << 4, 62 << 4, 62 << 4, 62 << 4, 62 << 4, 50159243Sobrien 58 << 4, 58 << 4, 58 << 4, 58 << 4, 58 << 4, 58 << 4, 58 << 4, 58 << 4, 50259243Sobrien 58 << 4, 58 << 4, 58 << 4, 58 << 4, 58 << 4, 58 << 4, 58 << 4, 58 << 4, 503167465Smp 53 << 4, 53 << 4, 53 << 4, 53 << 4, 53 << 4, 53 << 4, 53 << 4, 53 << 4, 50459243Sobrien 53 << 4, 53 << 4, 53 << 4, 53 << 4, 53 << 4, 53 << 4, 53 << 4, 53 << 4, 50559243Sobrien 48 << 4, 48 << 4, 48 << 4, 48 << 4, 48 << 4, 48 << 4, 48 << 4, 48 << 4, 50659243Sobrien 48 << 4, 48 << 4, 48 << 4, 48 << 4, 48 << 4, 48 << 4, 48 << 4, 48 << 4, 507167465Smp 43 << 4, 43 << 4, 43 << 4, 43 << 4, 43 << 4, 43 << 4, 43 << 4, 43 << 4, 50859243Sobrien 43 << 4, 43 << 4, 43 << 4, 43 << 4, 43 << 4, 43 << 4, 43 << 4, 43 << 4, 50959243Sobrien 39 << 4, 39 << 4, 39 << 4, 39 << 4, 39 << 4, 39 << 4, 39 << 4, 39 << 4, 51059243Sobrien 39 << 4, 39 << 4, 39 << 4, 39 << 4, 39 << 4, 39 << 4, 39 << 4, 39 << 4, 51159243Sobrien 35 << 4, 35 << 4, 35 << 4, 35 << 4, 35 << 4, 35 << 4, 35 << 4, 35 << 4, 51259243Sobrien 35 << 4, 35 << 4, 35 << 4, 35 << 4, 35 << 4, 35 << 4, 35 << 4, 35 << 4, 51359243Sobrien 31 << 4, 31 << 4, 31 << 4, 31 << 4, 31 << 4, 31 << 4, 31 << 4, 31 << 4, 51459243Sobrien 31 << 4, 31 << 4, 31 << 4, 31 << 4, 31 << 4, 31 << 4, 31 << 4, 31 << 4, 51559243Sobrien 27 << 4, 27 << 4, 27 << 4, 27 << 4, 27 << 4, 27 << 4, 27 << 4, 27 << 4, 51659243Sobrien 27 << 4, 27 << 4, 27 << 4, 27 << 4, 27 << 4, 27 << 4, 27 << 4, 27 << 4, 517167465Smp 23 << 4, 23 << 4, 23 << 4, 23 << 4, 23 << 4, 23 << 4, 23 << 4, 23 << 4, 518167465Smp 23 << 4, 23 << 4, 23 << 4, 23 << 4, 23 << 4, 23 << 4, 23 << 4, 23 << 4, 51959243Sobrien 19 << 4, 19 << 4, 19 << 4, 19 << 4, 19 << 4, 19 << 4, 19 << 4, 19 << 4, 520167465Smp 19 << 4, 19 << 4, 19 << 4, 19 << 4, 19 << 4, 19 << 4, 19 << 4, 19 << 4, 52159243Sobrien 16 << 4, 16 << 4, 16 << 4, 16 << 4, 16 << 4, 16 << 4, 16 << 4, 16 << 4, 52259243Sobrien 16 << 4, 16 << 4, 16 << 4, 16 << 4, 16 << 4, 16 << 4, 16 << 4, 16 << 4, 52359243Sobrien 12 << 4, 12 << 4, 12 << 4, 12 << 4, 12 << 4, 12 << 4, 12 << 4, 12 << 4, 52459243Sobrien 12 << 4, 12 << 4, 12 << 4, 12 << 4, 12 << 4, 12 << 4, 12 << 4, 12 << 4, 525167465Smp 9 << 4, 9 << 4, 9 << 4, 9 << 4, 9 << 4, 9 << 4, 9 << 4, 9 << 4, 526167465Smp 9 << 4, 9 << 4, 9 << 4, 9 << 4, 9 << 4, 9 << 4, 9 << 4, 9 << 4, 52759243Sobrien 7 << 4, 7 << 4, 7 << 4, 7 << 4, 7 << 4, 7 << 4, 7 << 4, 7 << 4, 528167465Smp 7 << 4, 7 << 4, 7 << 4, 7 << 4, 7 << 4, 7 << 4, 7 << 4, 7 << 4, 52959243Sobrien 4 << 4, 4 << 4, 4 << 4, 4 << 4, 4 << 4, 4 << 4, 4 << 4, 4 << 4, 530167465Smp 4 << 4, 4 << 4, 4 << 4, 4 << 4, 4 << 4, 4 << 4, 4 << 4, 4 << 4, 53159243Sobrien 2 << 4, 2 << 4, 2 << 4, 2 << 4, 2 << 4, 2 << 4, 2 << 4, 2 << 4, 53259243Sobrien 2 << 4, 2 << 4, 2 << 4, 2 << 4, 2 << 4, 2 << 4, 2 << 4, 2 << 4 53359243Sobrien }, 53459243Sobrien { 53559243Sobrien 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 53659243Sobrien 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 53759243Sobrien -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, 53859243Sobrien -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, 539167465Smp -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, 54059243Sobrien -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, 54159243Sobrien -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, 54259243Sobrien -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, 54359243Sobrien -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, 54459243Sobrien -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, 54559243Sobrien -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, 54659243Sobrien -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, 54759243Sobrien -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, 54859243Sobrien -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, 54959243Sobrien -10 << 4, -10 << 4, -10 << 4, -10 << 4, -10 << 4, -10 << 4, -10 << 4, -10 << 4, 55059243Sobrien -10 << 4, -10 << 4, -10 << 4, -10 << 4, -10 << 4, -10 << 4, -10 << 4, -10 << 4, 55159243Sobrien -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, 55259243Sobrien -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, 553167465Smp -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, 55459243Sobrien -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, 55559243Sobrien -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, 55659243Sobrien -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, 55759243Sobrien -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, 55859243Sobrien -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, 55959243Sobrien -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, 56059243Sobrien -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, 56159243Sobrien -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, 56259243Sobrien -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, 56359243Sobrien -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, 56459243Sobrien -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, 56559243Sobrien -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, 56659243Sobrien -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, 567167465Smp -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 56859243Sobrien -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 56959243Sobrien -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 57059243Sobrien -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 57159243Sobrien -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, 57259243Sobrien -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, 57359243Sobrien -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, 57459243Sobrien -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, 57559243Sobrien -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, 57659243Sobrien -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, 57759243Sobrien -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 57859243Sobrien -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 579167465Smp -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 580167465Smp -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 58159243Sobrien -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, 582167465Smp -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, 58359243Sobrien -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 58459243Sobrien -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 585167465Smp -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, 586167465Smp -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, -19 << 4, 587167465Smp -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 588167465Smp -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, -18 << 4, 58959243Sobrien -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, 59059243Sobrien -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, 59159243Sobrien -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, 59259243Sobrien -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, 59359243Sobrien -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, 59459243Sobrien -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, -17 << 4, 59559243Sobrien -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, 59659243Sobrien -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, 597167465Smp -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, 59859243Sobrien -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, 59959243Sobrien -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, 60059243Sobrien -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, -16 << 4, 601145479Smp -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, 60259243Sobrien -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, -15 << 4, 603145479Smp -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, 60459243Sobrien -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, 60559243Sobrien -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, 60659243Sobrien -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, -14 << 4, 60759243Sobrien -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, 60859243Sobrien -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, -13 << 4, 60959243Sobrien -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, 61059243Sobrien -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, 611167465Smp -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, 612167465Smp -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, 61359243Sobrien -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, 61459243Sobrien -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, -12 << 4, 615167465Smp -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, 61659243Sobrien -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, 61759243Sobrien -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, 61859243Sobrien -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, -11 << 4, 61959243Sobrien -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, 62059243Sobrien -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, 62159243Sobrien -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, 62259243Sobrien -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, 62359243Sobrien -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, 624167465Smp -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, -9 << 4, 625145479Smp -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, 626145479Smp -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, -8 << 4, 627145479Smp -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, 62859243Sobrien -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, 629145479Smp -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, 630167465Smp -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, 63159243Sobrien -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, 63259243Sobrien -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, -6 << 4, 63359243Sobrien -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, 63459243Sobrien -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, -5 << 4, 63559243Sobrien -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, 636167465Smp -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, 63759243Sobrien -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, 638167465Smp -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, 639167465Smp -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, 64059243Sobrien -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, -4 << 4, 64159243Sobrien -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, 64259243Sobrien -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, -3 << 4, 64359243Sobrien -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, 64459243Sobrien -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, 64559243Sobrien -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, 64659243Sobrien -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, -2 << 4, 647167465Smp -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, 64859243Sobrien -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, 64959243Sobrien 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 65059243Sobrien 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 65159243Sobrien -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, 652145479Smp -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, -1 << 4, 65359243Sobrien 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 654145479Smp 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 65559243Sobrien 1 << 4, 1 << 4, 1 << 4, 1 << 4, 1 << 4, 1 << 4, 1 << 4, 1 << 4, 65659243Sobrien 1 << 4, 1 << 4, 1 << 4, 1 << 4, 1 << 4, 1 << 4, 1 << 4, 1 << 4, 65759243Sobrien 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 65859243Sobrien 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 65959243Sobrien 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 66059243Sobrien 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 66159243Sobrien 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 66259243Sobrien 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4, 0 << 4 663167465Smp } 66459243Sobrien}; 66559243Sobrien 66659243Sobrienstatic const struct ia_css_dz_config default_dz_config = { 667231990Smp HRT_GDC_N, 66859243Sobrien HRT_GDC_N, 66969408Sache { 67059243Sobrien \ 67159243Sobrien {0, 0}, \ 67259243Sobrien {0, 0}, \ 67359243Sobrien } 67459243Sobrien}; 67559243Sobrien 67659243Sobrienstatic const struct ia_css_vector default_motion_config = { 677167465Smp 0, 678167465Smp 0 67959243Sobrien}; 68059243Sobrien 681167465Smp/* ------ deprecated(bz675) : from ------ */ 68259243Sobrienstatic const struct ia_css_shading_settings default_shading_settings = { 68359243Sobrien 1 /* enable shading table conversion in the css 68459243Sobrien (This matches the legacy way.) */ 68559243Sobrien}; 68659243Sobrien 68759243Sobrien/* ------ deprecated(bz675) : to ------ */ 68859243Sobrien 68959243Sobrienstruct ia_css_isp_skc_dvs_statistics { 690167465Smp ia_css_ptr p_data; 691231990Smp}; 692167465Smp 693167465Smpstatic int 694167465Smpref_sh_css_ddr_address_map( 695167465Smp struct sh_css_ddr_address_map *map, 696167465Smp struct sh_css_ddr_address_map *out); 69769408Sache 69859243Sobrienstatic int 69969408Sachewrite_ia_css_isp_parameter_set_info_to_ddr( 700167465Smp struct ia_css_isp_parameter_set_info *me, 70159243Sobrien ia_css_ptr *out); 70259243Sobrien 70359243Sobrienstatic int 70459243Sobrienfree_ia_css_isp_parameter_set_info(ia_css_ptr ptr); 70559243Sobrien 706167465Smpstatic int 70759243Sobriensh_css_params_write_to_ddr_internal( 708167465Smp struct ia_css_pipe *pipe, 709167465Smp unsigned int pipe_id, 71059243Sobrien struct ia_css_isp_parameters *params, 71159243Sobrien const struct ia_css_pipeline_stage *stage, 71259243Sobrien struct sh_css_ddr_address_map *ddr_map, 71359243Sobrien struct sh_css_ddr_address_map_size *ddr_map_size); 71459243Sobrien 71559243Sobrienstatic int 71659243Sobriensh_css_create_isp_params(struct ia_css_stream *stream, 717167465Smp struct ia_css_isp_parameters **isp_params_out); 71859243Sobrien 71959243Sobrienstatic bool 72059243Sobriensh_css_init_isp_params_from_global(struct ia_css_stream *stream, 72159243Sobrien struct ia_css_isp_parameters *params, 722231990Smp bool use_default_config, 72359243Sobrien struct ia_css_pipe *pipe_in); 72469408Sache 72559243Sobrienstatic int 72659243Sobriensh_css_init_isp_params_from_config(struct ia_css_pipe *pipe, 72759243Sobrien struct ia_css_isp_parameters *params, 72859243Sobrien const struct ia_css_isp_config *config, 72959243Sobrien struct ia_css_pipe *pipe_in); 73059243Sobrien 73159243Sobrienstatic int 732167465Smpsh_css_set_global_isp_config_on_pipe( 73359243Sobrien struct ia_css_pipe *curr_pipe, 73459243Sobrien const struct ia_css_isp_config *config, 73559243Sobrien struct ia_css_pipe *pipe); 73659243Sobrien 73759243Sobrienstatic int 73859243Sobriensh_css_set_per_frame_isp_config_on_pipe( 73959243Sobrien struct ia_css_stream *stream, 74059243Sobrien const struct ia_css_isp_config *config, 74159243Sobrien struct ia_css_pipe *pipe); 74259243Sobrien 74359243Sobrienstatic int 74459243Sobriensh_css_update_uds_and_crop_info_based_on_zoom_region( 745167465Smp const struct ia_css_binary_info *info, 746167465Smp const struct ia_css_frame_info *in_frame_info, 74759243Sobrien const struct ia_css_frame_info *out_frame_info, 748167465Smp const struct ia_css_resolution *dvs_env, 749167465Smp const struct ia_css_dz_config *zoom, 75059243Sobrien const struct ia_css_vector *motion_vector, 75159243Sobrien struct sh_css_uds_info *uds, /* out */ 75259243Sobrien struct sh_css_crop_pos *sp_out_crop_pos, /* out */ 75359243Sobrien struct ia_css_resolution pipe_in_res, 75459243Sobrien bool enable_zoom); 75559243Sobrien 756167465Smpia_css_ptr 75759243Sobriensh_css_params_ddr_address_map(void) 758167465Smp{ 759167465Smp return sp_ddr_ptrs; 760167465Smp} 761167465Smp 762167465Smp/* **************************************************** 76359243Sobrien * Each coefficient is stored as 7bits to fit 2 of them into one 76459243Sobrien * ISP vector element, so we will store 4 coefficents on every 765167465Smp * memory word (32bits) 76659243Sobrien * 76759243Sobrien * 0: Coefficient 0 used bits 76859243Sobrien * 1: Coefficient 1 used bits 76959243Sobrien * 2: Coefficient 2 used bits 77059243Sobrien * 3: Coefficient 3 used bits 77159243Sobrien * x: not used 77259243Sobrien * 773167465Smp * xx33333332222222 | xx11111110000000 77459243Sobrien * 77559243Sobrien * *************************************************** 77659243Sobrien */ 77759243Sobrienstatic struct ia_css_host_data * 77859243Sobrienconvert_allocate_fpntbl(struct ia_css_isp_parameters *params) 77959243Sobrien{ 78059243Sobrien unsigned int i, j; 78159243Sobrien short *data_ptr; 78259243Sobrien struct ia_css_host_data *me; 78359243Sobrien unsigned int isp_format_data_size; 784167465Smp u32 *isp_format_data_ptr; 78559243Sobrien 78659243Sobrien assert(params); 78759243Sobrien 78859243Sobrien data_ptr = params->fpn_config.data; 78959243Sobrien isp_format_data_size = params->fpn_config.height * params->fpn_config.width * 79059243Sobrien sizeof(uint32_t); 79159243Sobrien 79259243Sobrien me = ia_css_host_data_allocate(isp_format_data_size); 79359243Sobrien 794167465Smp if (!me) 79559243Sobrien return NULL; 79659243Sobrien 79759243Sobrien isp_format_data_ptr = (uint32_t *)me->address; 79859243Sobrien 79959243Sobrien for (i = 0; i < params->fpn_config.height; i++) { 80059243Sobrien for (j = 0; 801167465Smp j < params->fpn_config.width; 80259243Sobrien j += 4, data_ptr += 4, isp_format_data_ptr++) { 803167465Smp int data = data_ptr[0] << 0 | 804167465Smp data_ptr[1] << 7 | 80559243Sobrien data_ptr[2] << 16 | 806167465Smp data_ptr[3] << 23; 807167465Smp *isp_format_data_ptr = data; 808167465Smp } 809167465Smp } 81059243Sobrien return me; 81159243Sobrien} 81259243Sobrien 81359243Sobrienstatic int 81459243Sobrienstore_fpntbl(struct ia_css_isp_parameters *params, ia_css_ptr ptr) 81559243Sobrien{ 81659243Sobrien struct ia_css_host_data *isp_data; 81759243Sobrien 818167465Smp assert(params); 81959243Sobrien assert(ptr != mmgr_NULL); 820167465Smp 82159243Sobrien isp_data = convert_allocate_fpntbl(params); 82259243Sobrien if (!isp_data) { 82359243Sobrien IA_CSS_LEAVE_ERR_PRIVATE(-ENOMEM); 82459243Sobrien return -ENOMEM; 82559243Sobrien } 82659243Sobrien ia_css_params_store_ia_css_host_data(ptr, isp_data); 82759243Sobrien 82859243Sobrien ia_css_host_data_free(isp_data); 82959243Sobrien return 0; 83059243Sobrien} 83159243Sobrien 83259243Sobrienstatic void 83359243Sobrienconvert_raw_to_fpn(struct ia_css_isp_parameters *params) 83459243Sobrien{ 83559243Sobrien int maxval = 0; 836167465Smp unsigned int i; 83759243Sobrien 83859243Sobrien assert(params); 83959243Sobrien 84059243Sobrien /* Find the maximum value in the table */ 84159243Sobrien for (i = 0; i < params->fpn_config.height * params->fpn_config.width; i++) { 84259243Sobrien int val = params->fpn_config.data[i]; 84359243Sobrien /* Make sure FPN value can be represented in 13-bit unsigned 84459243Sobrien * number (ISP precision - 1), but note that actual input range 84559243Sobrien * depends on precision of input frame data. 84659243Sobrien */ 84759243Sobrien if (val < 0) { 84859243Sobrien /* Checkpatch patch */ 84959243Sobrien val = 0; 85059243Sobrien } else if (val >= (1 << 13)) { 85159243Sobrien /* Checkpatch patch */ 852167465Smp /* MW: BUG, is "13" a system or application property */ 85359243Sobrien val = (1 << 13) - 1; 85459243Sobrien } 85559243Sobrien maxval = max(maxval, val); 85659243Sobrien } 85759243Sobrien /* Find the lowest shift value to remap the values in the range 85859243Sobrien * 0..maxval to 0..2^shiftval*63. 85959243Sobrien */ 86059243Sobrien params->fpn_config.shift = 0; 86159243Sobrien while (maxval > 63) { 86259243Sobrien /* MW: BUG, is "63" a system or application property */ 863167465Smp maxval >>= 1; 864167465Smp params->fpn_config.shift++; 86559243Sobrien } 866167465Smp /* Adjust the values in the table for the shift value */ 867167465Smp for (i = 0; i < params->fpn_config.height * params->fpn_config.width; i++) 868167465Smp ((unsigned short *)params->fpn_config.data)[i] >>= params->fpn_config.shift; 86959243Sobrien} 87059243Sobrien 871167465Smpstatic void 872167465Smpia_css_process_kernel(struct ia_css_stream *stream, 87359243Sobrien struct ia_css_isp_parameters *params, 87459243Sobrien void (*process)(unsigned int pipe_id, 875167465Smp const struct ia_css_pipeline_stage *stage, 87659243Sobrien struct ia_css_isp_parameters *params)) 877167465Smp{ 878167465Smp int i; 879167465Smp 88059243Sobrien for (i = 0; i < stream->num_pipes; i++) { 881167465Smp struct ia_css_pipe *pipe = stream->pipes[i]; 882167465Smp struct ia_css_pipeline *pipeline = ia_css_pipe_get_pipeline(pipe); 88359243Sobrien struct ia_css_pipeline_stage *stage; 88459243Sobrien 88559243Sobrien /* update the other buffers to the pipe specific copies */ 88659243Sobrien for (stage = pipeline->stages; stage; stage = stage->next) { 88759243Sobrien if (!stage || !stage->binary) continue; 88859243Sobrien process(pipeline->pipe_id, stage, params); 88959243Sobrien } 89059243Sobrien } 891167465Smp} 89259243Sobrien 89359243Sobrienstatic int 89459243Sobriensh_css_select_dp_10bpp_config(const struct ia_css_pipe *pipe, 89559243Sobrien bool *is_dp_10bpp) 89659243Sobrien{ 89759243Sobrien int err = 0; 89859243Sobrien /* Currently we check if 10bpp DPC configuration is required based 89959243Sobrien * on the use case,i.e. if BDS and DPC is both enabled. The more cleaner 90059243Sobrien * design choice would be to expose the type of DPC (either 10bpp or 13bpp) 90159243Sobrien * using the binary info, but the current control flow does not allow this 90259243Sobrien * implementation. (This is because the configuration is set before a 903167465Smp * binary is selected, and the binary info is not available) 904167465Smp */ 90559243Sobrien if ((!pipe) || (!is_dp_10bpp)) { 906167465Smp IA_CSS_LEAVE_ERR_PRIVATE(-EINVAL); 90759243Sobrien err = -EINVAL; 90859243Sobrien } else { 909167465Smp *is_dp_10bpp = false; 910167465Smp 911167465Smp /* check if DPC is enabled from the host */ 912167465Smp if (pipe->config.enable_dpc) { 91359243Sobrien /*check if BDS is enabled*/ 914167465Smp unsigned int required_bds_factor = SH_CSS_BDS_FACTOR_1_00; 91559243Sobrien 916167465Smp if ((pipe->config.bayer_ds_out_res.width != 0) && 91759243Sobrien (pipe->config.bayer_ds_out_res.height != 0)) { 91859243Sobrien if (0 == binarydesc_calculate_bds_factor( 91959243Sobrien pipe->config.input_effective_res, 92059243Sobrien pipe->config.bayer_ds_out_res, 92159243Sobrien &required_bds_factor)) { 92259243Sobrien if (required_bds_factor != SH_CSS_BDS_FACTOR_1_00) { 92359243Sobrien /*we use 10bpp BDS configuration*/ 92459243Sobrien *is_dp_10bpp = true; 925167465Smp } 92659243Sobrien } 92759243Sobrien } 92859243Sobrien } 92959243Sobrien } 93059243Sobrien 93159243Sobrien return err; 93259243Sobrien} 93359243Sobrien 93459243Sobrienint 93559243Sobriensh_css_set_black_frame(struct ia_css_stream *stream, 93659243Sobrien const struct ia_css_frame *raw_black_frame) 93759243Sobrien{ 93859243Sobrien struct ia_css_isp_parameters *params; 939167465Smp /* this function desperately needs to be moved to the ISP or SP such 940167465Smp * that it can use the DMA. 94159243Sobrien */ 942167465Smp unsigned int height, width, y, x, k, data; 943167465Smp ia_css_ptr ptr; 94459243Sobrien 94559243Sobrien assert(stream); 946167465Smp assert(raw_black_frame); 947167465Smp 948167465Smp params = stream->isp_params_configs; 949167465Smp height = raw_black_frame->frame_info.res.height; 95059243Sobrien width = raw_black_frame->frame_info.padded_width; 951167465Smp 95259243Sobrien ptr = raw_black_frame->data 95359243Sobrien + raw_black_frame->planes.raw.offset; 954167465Smp 95559243Sobrien IA_CSS_ENTER_PRIVATE("black_frame=%p", raw_black_frame); 95659243Sobrien 95759243Sobrien if (params->fpn_config.data && 95859243Sobrien (params->fpn_config.width != width || params->fpn_config.height != height)) { 95959243Sobrien kvfree(params->fpn_config.data); 96059243Sobrien params->fpn_config.data = NULL; 96159243Sobrien } 96259243Sobrien if (!params->fpn_config.data) { 963167465Smp params->fpn_config.data = kvmalloc(array3_size(height, width, sizeof(short)), 96459243Sobrien GFP_KERNEL); 96559243Sobrien if (!params->fpn_config.data) { 96659243Sobrien IA_CSS_ERROR("out of memory"); 96759243Sobrien IA_CSS_LEAVE_ERR_PRIVATE(-ENOMEM); 96859243Sobrien return -ENOMEM; 96959243Sobrien } 97059243Sobrien params->fpn_config.width = width; 97159243Sobrien params->fpn_config.height = height; 97259243Sobrien params->fpn_config.shift = 0; 97359243Sobrien } 97459243Sobrien 975167465Smp /* store raw to fpntbl */ 976167465Smp for (y = 0; y < height; y++) { 97759243Sobrien for (x = 0; x < width; x += (ISP_VEC_NELEMS * 2)) { 978167465Smp int ofs = y * width + x; 97959243Sobrien 98059243Sobrien for (k = 0; k < ISP_VEC_NELEMS; k += 2) { 981167465Smp hmm_load(ptr, (void *)(&data), sizeof(int)); 98259243Sobrien params->fpn_config.data[ofs + 2 * k] = 98359243Sobrien (short)(data & 0xFFFF); 98459243Sobrien params->fpn_config.data[ofs + 2 * k + 2] = 98559243Sobrien (short)((data >> 16) & 0xFFFF); 986167465Smp ptr += sizeof(int); /* byte system address */ 987167465Smp } 98859243Sobrien for (k = 0; k < ISP_VEC_NELEMS; k += 2) { 989167465Smp hmm_load(ptr, (void *)(&data), sizeof(int)); 99059243Sobrien params->fpn_config.data[ofs + 2 * k + 1] = 991167465Smp (short)(data & 0xFFFF); 99259243Sobrien params->fpn_config.data[ofs + 2 * k + 3] = 99359243Sobrien (short)((data >> 16) & 0xFFFF); 99459243Sobrien ptr += sizeof(int); /* byte system address */ 99559243Sobrien } 99659243Sobrien } 99759243Sobrien } 99859243Sobrien 99959243Sobrien /* raw -> fpn */ 1000167465Smp convert_raw_to_fpn(params); 100159243Sobrien 100259243Sobrien /* overwrite isp parameter */ 100359243Sobrien ia_css_process_kernel(stream, params, ia_css_kernel_process_param[IA_CSS_FPN_ID]); 100459243Sobrien 100559243Sobrien IA_CSS_LEAVE_ERR_PRIVATE(0); 100659243Sobrien 100759243Sobrien return 0; 100859243Sobrien} 100959243Sobrien 101059243Sobrienbool 101159243Sobriensh_css_params_set_binning_factor(struct ia_css_stream *stream, 1012167465Smp unsigned int binning_fact) 1013167465Smp{ 101459243Sobrien struct ia_css_isp_parameters *params; 101559243Sobrien 101659243Sobrien IA_CSS_ENTER_PRIVATE("void"); 1017167465Smp assert(stream); 101859243Sobrien 101959243Sobrien params = stream->isp_params_configs; 102059243Sobrien 102159243Sobrien if (params->sensor_binning != binning_fact) { 102259243Sobrien params->sensor_binning = binning_fact; 102359243Sobrien params->sc_table_changed = true; 102459243Sobrien } 1025167465Smp 102659243Sobrien IA_CSS_LEAVE_PRIVATE("void"); 1027167465Smp 102859243Sobrien return params->sc_table_changed; 1029167465Smp} 103059243Sobrien 1031static void 1032sh_css_set_shading_table(struct ia_css_stream *stream, 1033 struct ia_css_isp_parameters *params, 1034 const struct ia_css_shading_table *table) 1035{ 1036 IA_CSS_ENTER_PRIVATE(""); 1037 if (!table) 1038 return; 1039 assert(stream); 1040 1041 if (!table->enable) 1042 table = NULL; 1043 1044 if (table != params->sc_table) { 1045 params->sc_table = table; 1046 params->sc_table_changed = true; 1047 /* Not very clean, this goes to sh_css.c to invalidate the 1048 * shading table for all pipes. Should replaced by a loop 1049 * and a pipe-specific call. 1050 */ 1051 if (!params->output_frame) 1052 sh_css_invalidate_shading_tables(stream); 1053 } 1054 1055 IA_CSS_LEAVE_PRIVATE("void"); 1056} 1057 1058void 1059ia_css_params_store_ia_css_host_data( 1060 ia_css_ptr ddr_addr, 1061 struct ia_css_host_data *data) 1062{ 1063 assert(data); 1064 assert(data->address); 1065 assert(ddr_addr != mmgr_NULL); 1066 1067 IA_CSS_ENTER_PRIVATE(""); 1068 1069 hmm_store(ddr_addr, 1070 (void *)(data->address), 1071 (size_t)data->size); 1072 1073 IA_CSS_LEAVE_PRIVATE("void"); 1074} 1075 1076struct ia_css_host_data * 1077ia_css_params_alloc_convert_sctbl( 1078 const struct ia_css_pipeline_stage *stage, 1079 const struct ia_css_shading_table *shading_table) 1080{ 1081 const struct ia_css_binary *binary = stage->binary; 1082 struct ia_css_host_data *sctbl; 1083 unsigned int i, j, aligned_width; 1084 unsigned int sctbl_size; 1085 short int *ptr; 1086 1087 assert(binary); 1088 assert(shading_table); 1089 1090 IA_CSS_ENTER_PRIVATE(""); 1091 1092 if (!shading_table) { 1093 IA_CSS_LEAVE_PRIVATE("void"); 1094 return NULL; 1095 } 1096 1097 aligned_width = binary->sctbl_aligned_width_per_color; 1098 sctbl_size = shading_table->height * IA_CSS_SC_NUM_COLORS * aligned_width * 1099 sizeof(short); 1100 1101 sctbl = ia_css_host_data_allocate((size_t)sctbl_size); 1102 1103 if (!sctbl) 1104 return NULL; 1105 ptr = (short int *)sctbl->address; 1106 memset(ptr, 1107 0, 1108 sctbl_size); 1109 1110 for (i = 0; i < shading_table->height; i++) { 1111 for (j = 0; j < IA_CSS_SC_NUM_COLORS; j++) { 1112 memcpy(ptr, 1113 &shading_table->data[j] 1114 [i * shading_table->width], 1115 shading_table->width * sizeof(short)); 1116 ptr += aligned_width; 1117 } 1118 } 1119 1120 IA_CSS_LEAVE_PRIVATE("void"); 1121 return sctbl; 1122} 1123 1124int ia_css_params_store_sctbl( 1125 const struct ia_css_pipeline_stage *stage, 1126 ia_css_ptr sc_tbl, 1127 const struct ia_css_shading_table *sc_config) 1128{ 1129 struct ia_css_host_data *isp_sc_tbl; 1130 1131 IA_CSS_ENTER_PRIVATE(""); 1132 1133 if (!sc_config) { 1134 IA_CSS_LEAVE_PRIVATE("void"); 1135 return 0; 1136 } 1137 1138 isp_sc_tbl = ia_css_params_alloc_convert_sctbl(stage, sc_config); 1139 if (!isp_sc_tbl) { 1140 IA_CSS_LEAVE_ERR_PRIVATE(-ENOMEM); 1141 return -ENOMEM; 1142 } 1143 /* store the shading table to ddr */ 1144 ia_css_params_store_ia_css_host_data(sc_tbl, isp_sc_tbl); 1145 ia_css_host_data_free(isp_sc_tbl); 1146 1147 IA_CSS_LEAVE_PRIVATE("void"); 1148 1149 return 0; 1150} 1151 1152static void 1153sh_css_enable_pipeline(const struct ia_css_binary *binary) 1154{ 1155 if (!binary) 1156 return; 1157 1158 IA_CSS_ENTER_PRIVATE(""); 1159 1160 ia_css_isp_param_enable_pipeline(&binary->mem_params); 1161 1162 IA_CSS_LEAVE_PRIVATE("void"); 1163} 1164 1165static int 1166ia_css_process_zoom_and_motion( 1167 struct ia_css_isp_parameters *params, 1168 const struct ia_css_pipeline_stage *first_stage) 1169{ 1170 /* first_stage can be NULL */ 1171 const struct ia_css_pipeline_stage *stage; 1172 int err = 0; 1173 struct ia_css_resolution pipe_in_res; 1174 1175 pipe_in_res.width = 0; 1176 pipe_in_res.height = 0; 1177 1178 assert(params); 1179 1180 IA_CSS_ENTER_PRIVATE(""); 1181 1182 /* Go through all stages to udate uds and cropping */ 1183 for (stage = first_stage; stage; stage = stage->next) { 1184 struct ia_css_binary *binary; 1185 /* note: the var below is made static as it is quite large; 1186 if it is not static it ends up on the stack which could 1187 cause issues for drivers 1188 */ 1189 static struct ia_css_binary tmp_binary; 1190 1191 const struct ia_css_binary_xinfo *info = NULL; 1192 1193 binary = stage->binary; 1194 if (binary) { 1195 info = binary->info; 1196 } else { 1197 const struct sh_css_binary_args *args = &stage->args; 1198 const struct ia_css_frame_info *out_infos[IA_CSS_BINARY_MAX_OUTPUT_PORTS] = {NULL}; 1199 1200 out_infos[0] = ia_css_frame_get_info(args->out_frame[0]); 1201 1202 info = &stage->firmware->info.isp; 1203 ia_css_binary_fill_info(info, false, false, 1204 ATOMISP_INPUT_FORMAT_RAW_10, 1205 ia_css_frame_get_info(args->in_frame), 1206 NULL, 1207 out_infos, 1208 ia_css_frame_get_info(args->out_vf_frame), 1209 &tmp_binary, 1210 NULL, 1211 -1, true); 1212 binary = &tmp_binary; 1213 binary->info = info; 1214 } 1215 1216 if (stage == first_stage) { 1217 /* we will use pipe_in_res to scale the zoom crop region if needed */ 1218 pipe_in_res = binary->effective_in_frame_res; 1219 } 1220 1221 assert(stage->stage_num < SH_CSS_MAX_STAGES); 1222 if (params->dz_config.zoom_region.resolution.width == 0 && 1223 params->dz_config.zoom_region.resolution.height == 0) { 1224 sh_css_update_uds_and_crop_info( 1225 &info->sp, 1226 &binary->in_frame_info, 1227 &binary->out_frame_info[0], 1228 &binary->dvs_envelope, 1229 ¶ms->dz_config, 1230 ¶ms->motion_config, 1231 ¶ms->uds[stage->stage_num].uds, 1232 ¶ms->uds[stage->stage_num].crop_pos, 1233 stage->enable_zoom); 1234 } else { 1235 err = sh_css_update_uds_and_crop_info_based_on_zoom_region( 1236 &info->sp, 1237 &binary->in_frame_info, 1238 &binary->out_frame_info[0], 1239 &binary->dvs_envelope, 1240 ¶ms->dz_config, 1241 ¶ms->motion_config, 1242 ¶ms->uds[stage->stage_num].uds, 1243 ¶ms->uds[stage->stage_num].crop_pos, 1244 pipe_in_res, 1245 stage->enable_zoom); 1246 if (err) 1247 return err; 1248 } 1249 } 1250 params->isp_params_changed = true; 1251 1252 IA_CSS_LEAVE_PRIVATE("void"); 1253 return err; 1254} 1255 1256static void 1257sh_css_set_gamma_table(struct ia_css_isp_parameters *params, 1258 const struct ia_css_gamma_table *table) 1259{ 1260 if (!table) 1261 return; 1262 IA_CSS_ENTER_PRIVATE("table=%p", table); 1263 1264 assert(params); 1265 params->gc_table = *table; 1266 params->config_changed[IA_CSS_GC_ID] = true; 1267 1268 IA_CSS_LEAVE_PRIVATE("void"); 1269} 1270 1271static void 1272sh_css_get_gamma_table(const struct ia_css_isp_parameters *params, 1273 struct ia_css_gamma_table *table) 1274{ 1275 if (!table) 1276 return; 1277 IA_CSS_ENTER_PRIVATE("table=%p", table); 1278 1279 assert(params); 1280 *table = params->gc_table; 1281 1282 IA_CSS_LEAVE_PRIVATE("void"); 1283} 1284 1285static void 1286sh_css_set_ctc_table(struct ia_css_isp_parameters *params, 1287 const struct ia_css_ctc_table *table) 1288{ 1289 if (!table) 1290 return; 1291 1292 IA_CSS_ENTER_PRIVATE("table=%p", table); 1293 1294 assert(params); 1295 params->ctc_table = *table; 1296 params->config_changed[IA_CSS_CTC_ID] = true; 1297 1298 IA_CSS_LEAVE_PRIVATE("void"); 1299} 1300 1301static void 1302sh_css_get_ctc_table(const struct ia_css_isp_parameters *params, 1303 struct ia_css_ctc_table *table) 1304{ 1305 if (!table) 1306 return; 1307 1308 IA_CSS_ENTER_PRIVATE("table=%p", table); 1309 1310 assert(params); 1311 *table = params->ctc_table; 1312 1313 IA_CSS_LEAVE_PRIVATE("void"); 1314} 1315 1316static void 1317sh_css_set_macc_table(struct ia_css_isp_parameters *params, 1318 const struct ia_css_macc_table *table) 1319{ 1320 if (!table) 1321 return; 1322 1323 IA_CSS_ENTER_PRIVATE("table=%p", table); 1324 1325 assert(params); 1326 params->macc_table = *table; 1327 params->config_changed[IA_CSS_MACC_ID] = true; 1328 1329 IA_CSS_LEAVE_PRIVATE("void"); 1330} 1331 1332static void 1333sh_css_get_macc_table(const struct ia_css_isp_parameters *params, 1334 struct ia_css_macc_table *table) 1335{ 1336 if (!table) 1337 return; 1338 1339 IA_CSS_ENTER_PRIVATE("table=%p", table); 1340 1341 assert(params); 1342 *table = params->macc_table; 1343 1344 IA_CSS_LEAVE_PRIVATE("void"); 1345} 1346 1347void ia_css_morph_table_free( 1348 struct ia_css_morph_table *me) 1349{ 1350 unsigned int i; 1351 1352 if (!me) 1353 return; 1354 1355 IA_CSS_ENTER(""); 1356 1357 for (i = 0; i < IA_CSS_MORPH_TABLE_NUM_PLANES; i++) { 1358 if (me->coordinates_x[i]) { 1359 kvfree(me->coordinates_x[i]); 1360 me->coordinates_x[i] = NULL; 1361 } 1362 if (me->coordinates_y[i]) { 1363 kvfree(me->coordinates_y[i]); 1364 me->coordinates_y[i] = NULL; 1365 } 1366 } 1367 1368 kvfree(me); 1369 IA_CSS_LEAVE("void"); 1370} 1371 1372struct ia_css_morph_table *ia_css_morph_table_allocate( 1373 unsigned int width, 1374 unsigned int height) 1375{ 1376 unsigned int i; 1377 struct ia_css_morph_table *me; 1378 1379 IA_CSS_ENTER(""); 1380 1381 me = kvmalloc(sizeof(*me), GFP_KERNEL); 1382 if (!me) { 1383 IA_CSS_ERROR("out of memory"); 1384 return me; 1385 } 1386 1387 for (i = 0; i < IA_CSS_MORPH_TABLE_NUM_PLANES; i++) { 1388 me->coordinates_x[i] = NULL; 1389 me->coordinates_y[i] = NULL; 1390 } 1391 1392 for (i = 0; i < IA_CSS_MORPH_TABLE_NUM_PLANES; i++) { 1393 me->coordinates_x[i] = kvmalloc(height * width * 1394 sizeof(*me->coordinates_x[i]), 1395 GFP_KERNEL); 1396 me->coordinates_y[i] = kvmalloc(height * width * 1397 sizeof(*me->coordinates_y[i]), 1398 GFP_KERNEL); 1399 1400 if ((!me->coordinates_x[i]) || 1401 (!me->coordinates_y[i])) { 1402 ia_css_morph_table_free(me); 1403 me = NULL; 1404 return me; 1405 } 1406 } 1407 me->width = width; 1408 me->height = height; 1409 IA_CSS_LEAVE(""); 1410 return me; 1411} 1412 1413static int sh_css_params_default_morph_table( 1414 struct ia_css_morph_table **table, 1415 const struct ia_css_binary *binary) 1416{ 1417 /* MW 2400 advanced requires different scaling */ 1418 unsigned int i, j, k, step, width, height; 1419 short start_x[IA_CSS_MORPH_TABLE_NUM_PLANES] = { -8, 0, -8, 0, 0, -8 }, 1420 start_y[IA_CSS_MORPH_TABLE_NUM_PLANES] = { 0, 0, -8, -8, -8, 0 }; 1421 struct ia_css_morph_table *tab; 1422 1423 assert(table); 1424 assert(binary); 1425 1426 IA_CSS_ENTER_PRIVATE(""); 1427 1428 step = (ISP_VEC_NELEMS / 16) * 128; 1429 width = binary->morph_tbl_width; 1430 height = binary->morph_tbl_height; 1431 1432 tab = ia_css_morph_table_allocate(width, height); 1433 if (!tab) 1434 return -ENOMEM; 1435 1436 for (i = 0; i < IA_CSS_MORPH_TABLE_NUM_PLANES; i++) { 1437 short val_y = start_y[i]; 1438 1439 for (j = 0; j < height; j++) { 1440 short val_x = start_x[i]; 1441 unsigned short *x_ptr, *y_ptr; 1442 1443 x_ptr = &tab->coordinates_x[i][j * width]; 1444 y_ptr = &tab->coordinates_y[i][j * width]; 1445 for (k = 0; k < width; 1446 k++, x_ptr++, y_ptr++, val_x += (short)step) { 1447 if (k == 0) 1448 *x_ptr = 0; 1449 else if (k == width - 1) 1450 *x_ptr = val_x + 2 * start_x[i]; 1451 else 1452 *x_ptr = val_x; 1453 if (j == 0) 1454 *y_ptr = 0; 1455 else 1456 *y_ptr = val_y; 1457 } 1458 val_y += (short)step; 1459 } 1460 } 1461 *table = tab; 1462 1463 IA_CSS_LEAVE_ERR_PRIVATE(0); 1464 1465 return 0; 1466} 1467 1468static void 1469sh_css_set_morph_table(struct ia_css_isp_parameters *params, 1470 const struct ia_css_morph_table *table) 1471{ 1472 if (!table) 1473 return; 1474 1475 IA_CSS_ENTER_PRIVATE("table=%p", table); 1476 1477 assert(params); 1478 if (table->enable == false) 1479 table = NULL; 1480 params->morph_table = table; 1481 params->morph_table_changed = true; 1482 IA_CSS_LEAVE_PRIVATE("void"); 1483} 1484 1485void 1486ia_css_translate_3a_statistics( 1487 struct ia_css_3a_statistics *host_stats, 1488 const struct ia_css_isp_3a_statistics_map *isp_stats) 1489{ 1490 IA_CSS_ENTER(""); 1491 if (host_stats->grid.use_dmem) { 1492 IA_CSS_LOG("3A: DMEM"); 1493 ia_css_s3a_dmem_decode(host_stats, isp_stats->dmem_stats); 1494 } else { 1495 IA_CSS_LOG("3A: VMEM"); 1496 ia_css_s3a_vmem_decode(host_stats, isp_stats->vmem_stats_hi, 1497 isp_stats->vmem_stats_lo); 1498 } 1499 IA_CSS_LOG("3A: HMEM"); 1500 ia_css_s3a_hmem_decode(host_stats, isp_stats->hmem_stats); 1501 1502 IA_CSS_LEAVE("void"); 1503} 1504 1505void 1506ia_css_isp_3a_statistics_map_free(struct ia_css_isp_3a_statistics_map *me) 1507{ 1508 if (me) { 1509 if (me->data_allocated) { 1510 kvfree(me->data_ptr); 1511 me->data_ptr = NULL; 1512 me->data_allocated = false; 1513 } 1514 kvfree(me); 1515 } 1516} 1517 1518struct ia_css_isp_3a_statistics_map * 1519ia_css_isp_3a_statistics_map_allocate( 1520 const struct ia_css_isp_3a_statistics *isp_stats, 1521 void *data_ptr) 1522{ 1523 struct ia_css_isp_3a_statistics_map *me; 1524 /* Windows compiler does not like adding sizes to a void * 1525 * so we use a local char * instead. */ 1526 char *base_ptr; 1527 1528 me = kvmalloc(sizeof(*me), GFP_KERNEL); 1529 if (!me) { 1530 IA_CSS_LEAVE("cannot allocate memory"); 1531 goto err; 1532 } 1533 1534 me->data_ptr = data_ptr; 1535 me->data_allocated = !data_ptr; 1536 if (!data_ptr) { 1537 me->data_ptr = kvmalloc(isp_stats->size, GFP_KERNEL); 1538 if (!me->data_ptr) { 1539 IA_CSS_LEAVE("cannot allocate memory"); 1540 goto err; 1541 } 1542 } 1543 base_ptr = me->data_ptr; 1544 1545 me->size = isp_stats->size; 1546 /* GCC complains when we assign a char * to a void *, so these 1547 * casts are necessary unfortunately. */ 1548 me->dmem_stats = (void *)base_ptr; 1549 me->vmem_stats_hi = (void *)(base_ptr + isp_stats->dmem_size); 1550 me->vmem_stats_lo = (void *)(base_ptr + isp_stats->dmem_size + 1551 isp_stats->vmem_size); 1552 me->hmem_stats = (void *)(base_ptr + isp_stats->dmem_size + 1553 2 * isp_stats->vmem_size); 1554 1555 IA_CSS_LEAVE("map=%p", me); 1556 return me; 1557 1558err: 1559 kvfree(me); 1560 return NULL; 1561} 1562 1563int 1564ia_css_get_3a_statistics(struct ia_css_3a_statistics *host_stats, 1565 const struct ia_css_isp_3a_statistics *isp_stats) 1566{ 1567 struct ia_css_isp_3a_statistics_map *map; 1568 int ret = 0; 1569 1570 IA_CSS_ENTER("host_stats=%p, isp_stats=%p", host_stats, isp_stats); 1571 1572 assert(host_stats); 1573 assert(isp_stats); 1574 1575 map = ia_css_isp_3a_statistics_map_allocate(isp_stats, NULL); 1576 if (map) { 1577 hmm_load(isp_stats->data_ptr, map->data_ptr, isp_stats->size); 1578 ia_css_translate_3a_statistics(host_stats, map); 1579 ia_css_isp_3a_statistics_map_free(map); 1580 } else { 1581 IA_CSS_ERROR("out of memory"); 1582 ret = -ENOMEM; 1583 } 1584 1585 IA_CSS_LEAVE_ERR(ret); 1586 return ret; 1587} 1588 1589/* Parameter encoding is not yet orthogonal. 1590 This function hnadles some of the exceptions. 1591*/ 1592static void 1593ia_css_set_param_exceptions(const struct ia_css_pipe *pipe, 1594 struct ia_css_isp_parameters *params) 1595{ 1596 assert(params); 1597 1598 /* Copy also to DP. Should be done by the driver. */ 1599 params->dp_config.gr = params->wb_config.gr; 1600 params->dp_config.r = params->wb_config.r; 1601 params->dp_config.b = params->wb_config.b; 1602 params->dp_config.gb = params->wb_config.gb; 1603} 1604 1605static void 1606sh_css_set_nr_config(struct ia_css_isp_parameters *params, 1607 const struct ia_css_nr_config *config) 1608{ 1609 if (!config) 1610 return; 1611 assert(params); 1612 1613 IA_CSS_ENTER_PRIVATE("config=%p", config); 1614 1615 ia_css_nr_debug_dtrace(config, IA_CSS_DEBUG_TRACE_PRIVATE); 1616 params->nr_config = *config; 1617 params->yee_config.nr = *config; 1618 params->config_changed[IA_CSS_NR_ID] = true; 1619 params->config_changed[IA_CSS_YEE_ID] = true; 1620 params->config_changed[IA_CSS_BNR_ID] = true; 1621 1622 IA_CSS_LEAVE_PRIVATE("void"); 1623} 1624 1625static void 1626sh_css_set_ee_config(struct ia_css_isp_parameters *params, 1627 const struct ia_css_ee_config *config) 1628{ 1629 if (!config) 1630 return; 1631 assert(params); 1632 1633 IA_CSS_ENTER_PRIVATE("config=%p", config); 1634 ia_css_ee_debug_dtrace(config, IA_CSS_DEBUG_TRACE_PRIVATE); 1635 1636 params->ee_config = *config; 1637 params->yee_config.ee = *config; 1638 params->config_changed[IA_CSS_YEE_ID] = true; 1639 1640 IA_CSS_LEAVE_PRIVATE("void"); 1641} 1642 1643static void 1644sh_css_get_ee_config(const struct ia_css_isp_parameters *params, 1645 struct ia_css_ee_config *config) 1646{ 1647 if (!config) 1648 return; 1649 1650 IA_CSS_ENTER_PRIVATE("config=%p", config); 1651 1652 assert(params); 1653 *config = params->ee_config; 1654 1655 ia_css_ee_debug_dtrace(config, IA_CSS_DEBUG_TRACE_PRIVATE); 1656 IA_CSS_LEAVE_PRIVATE("void"); 1657} 1658 1659static void 1660sh_css_set_pipe_dvs_6axis_config(const struct ia_css_pipe *pipe, 1661 struct ia_css_isp_parameters *params, 1662 const struct ia_css_dvs_6axis_config *dvs_config) 1663{ 1664 if (!dvs_config) 1665 return; 1666 assert(params); 1667 assert(pipe); 1668 assert(dvs_config->height_y == dvs_config->height_uv); 1669 assert((dvs_config->width_y - 1) == 2 * (dvs_config->width_uv - 1)); 1670 assert(pipe->mode < IA_CSS_PIPE_ID_NUM); 1671 1672 IA_CSS_ENTER_PRIVATE("dvs_config=%p", dvs_config); 1673 1674 copy_dvs_6axis_table(params->pipe_dvs_6axis_config[pipe->mode], dvs_config); 1675 1676 params->pipe_dvs_6axis_config_changed[pipe->mode] = true; 1677 1678 IA_CSS_LEAVE_PRIVATE("void"); 1679} 1680 1681static void 1682sh_css_get_pipe_dvs_6axis_config(const struct ia_css_pipe *pipe, 1683 const struct ia_css_isp_parameters *params, 1684 struct ia_css_dvs_6axis_config *dvs_config) 1685{ 1686 if (!dvs_config) 1687 return; 1688 assert(params); 1689 assert(pipe); 1690 assert(dvs_config->height_y == dvs_config->height_uv); 1691 assert((dvs_config->width_y - 1) == 2 * dvs_config->width_uv - 1); 1692 1693 IA_CSS_ENTER_PRIVATE("dvs_config=%p", dvs_config); 1694 1695 if ((pipe->mode < IA_CSS_PIPE_ID_NUM) && 1696 (dvs_config->width_y == params->pipe_dvs_6axis_config[pipe->mode]->width_y) && 1697 (dvs_config->height_y == params->pipe_dvs_6axis_config[pipe->mode]->height_y) && 1698 (dvs_config->width_uv == params->pipe_dvs_6axis_config[pipe->mode]->width_uv) && 1699 (dvs_config->height_uv == params->pipe_dvs_6axis_config[pipe->mode]->height_uv) 1700 && 1701 dvs_config->xcoords_y && 1702 dvs_config->ycoords_y && 1703 dvs_config->xcoords_uv && 1704 dvs_config->ycoords_uv) { 1705 copy_dvs_6axis_table(dvs_config, params->pipe_dvs_6axis_config[pipe->mode]); 1706 } 1707 1708 IA_CSS_LEAVE_PRIVATE("void"); 1709} 1710 1711static void 1712sh_css_set_baa_config(struct ia_css_isp_parameters *params, 1713 const struct ia_css_aa_config *config) 1714{ 1715 if (!config) 1716 return; 1717 assert(params); 1718 1719 IA_CSS_ENTER_PRIVATE("config=%p", config); 1720 1721 params->bds_config = *config; 1722 params->config_changed[IA_CSS_BDS_ID] = true; 1723 1724 IA_CSS_LEAVE_PRIVATE("void"); 1725} 1726 1727static void 1728sh_css_get_baa_config(const struct ia_css_isp_parameters *params, 1729 struct ia_css_aa_config *config) 1730{ 1731 if (!config) 1732 return; 1733 assert(params); 1734 1735 IA_CSS_ENTER_PRIVATE("config=%p", config); 1736 1737 *config = params->bds_config; 1738 1739 IA_CSS_LEAVE_PRIVATE("void"); 1740} 1741 1742static void 1743sh_css_set_dz_config(struct ia_css_isp_parameters *params, 1744 const struct ia_css_dz_config *config) 1745{ 1746 if (!config) 1747 return; 1748 assert(params); 1749 1750 IA_CSS_ENTER_PRIVATE("dx=%d, dy=%d", config->dx, config->dy); 1751 1752 assert(config->dx <= HRT_GDC_N); 1753 assert(config->dy <= HRT_GDC_N); 1754 1755 params->dz_config = *config; 1756 params->dz_config_changed = true; 1757 /* JK: Why isp params changed?? */ 1758 params->isp_params_changed = true; 1759 1760 IA_CSS_LEAVE_PRIVATE("void"); 1761} 1762 1763static void 1764sh_css_get_dz_config(const struct ia_css_isp_parameters *params, 1765 struct ia_css_dz_config *config) 1766{ 1767 if (!config) 1768 return; 1769 assert(params); 1770 1771 IA_CSS_ENTER_PRIVATE("config=%p", config); 1772 1773 *config = params->dz_config; 1774 1775 IA_CSS_LEAVE_PRIVATE("dx=%d, dy=%d", config->dx, config->dy); 1776} 1777 1778static void 1779sh_css_set_motion_vector(struct ia_css_isp_parameters *params, 1780 const struct ia_css_vector *motion) 1781{ 1782 if (!motion) 1783 return; 1784 assert(params); 1785 1786 IA_CSS_ENTER_PRIVATE("x=%d, y=%d", motion->x, motion->y); 1787 1788 params->motion_config = *motion; 1789 /* JK: Why do isp params change? */ 1790 params->motion_config_changed = true; 1791 params->isp_params_changed = true; 1792 1793 IA_CSS_LEAVE_PRIVATE("void"); 1794} 1795 1796static void 1797sh_css_get_motion_vector(const struct ia_css_isp_parameters *params, 1798 struct ia_css_vector *motion) 1799{ 1800 if (!motion) 1801 return; 1802 assert(params); 1803 1804 IA_CSS_ENTER_PRIVATE("motion=%p", motion); 1805 1806 *motion = params->motion_config; 1807 1808 IA_CSS_LEAVE_PRIVATE("x=%d, y=%d", motion->x, motion->y); 1809} 1810 1811struct ia_css_isp_config * 1812sh_css_pipe_isp_config_get(struct ia_css_pipe *pipe) 1813{ 1814 if (!pipe) { 1815 IA_CSS_ERROR("pipe=%p", NULL); 1816 return NULL; 1817 } 1818 return pipe->config.p_isp_config; 1819} 1820 1821int 1822ia_css_stream_set_isp_config( 1823 struct ia_css_stream *stream, 1824 const struct ia_css_isp_config *config) 1825{ 1826 return ia_css_stream_set_isp_config_on_pipe(stream, config, NULL); 1827} 1828 1829int 1830ia_css_stream_set_isp_config_on_pipe( 1831 struct ia_css_stream *stream, 1832 const struct ia_css_isp_config *config, 1833 struct ia_css_pipe *pipe) 1834{ 1835 int err = 0; 1836 1837 if ((!stream) || (!config)) 1838 return -EINVAL; 1839 1840 IA_CSS_ENTER("stream=%p, config=%p, pipe=%p", stream, config, pipe); 1841 1842 if (config->output_frame) 1843 err = sh_css_set_per_frame_isp_config_on_pipe(stream, config, pipe); 1844 else 1845 err = sh_css_set_global_isp_config_on_pipe(stream->pipes[0], config, pipe); 1846 1847 IA_CSS_LEAVE_ERR(err); 1848 return err; 1849} 1850 1851int 1852ia_css_pipe_set_isp_config(struct ia_css_pipe *pipe, 1853 struct ia_css_isp_config *config) 1854{ 1855 struct ia_css_pipe *pipe_in = pipe; 1856 int err = 0; 1857 1858 IA_CSS_ENTER("pipe=%p", pipe); 1859 1860 if ((!pipe) || (!pipe->stream)) 1861 return -EINVAL; 1862 1863 ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "config=%p\n", config); 1864 1865 if (config->output_frame) 1866 err = sh_css_set_per_frame_isp_config_on_pipe(pipe->stream, config, pipe); 1867 else 1868 err = sh_css_set_global_isp_config_on_pipe(pipe, config, pipe_in); 1869 IA_CSS_LEAVE_ERR(err); 1870 return err; 1871} 1872 1873static int 1874sh_css_set_global_isp_config_on_pipe( 1875 struct ia_css_pipe *curr_pipe, 1876 const struct ia_css_isp_config *config, 1877 struct ia_css_pipe *pipe) 1878{ 1879 int err = 0; 1880 int err1 = 0; 1881 int err2 = 0; 1882 1883 IA_CSS_ENTER_PRIVATE("stream=%p, config=%p, pipe=%p", curr_pipe, config, pipe); 1884 1885 err1 = sh_css_init_isp_params_from_config(curr_pipe, curr_pipe->stream->isp_params_configs, config, pipe); 1886 1887 /* Now commit all changes to the SP */ 1888 err2 = sh_css_param_update_isp_params(curr_pipe, curr_pipe->stream->isp_params_configs, sh_css_sp_is_running(), pipe); 1889 1890 /* The following code is intentional. The sh_css_init_isp_params_from_config interface 1891 * throws an error when both DPC and BDS is enabled. The CSS API must pass this error 1892 * information to the caller, ie. the host. We do not return this error immediately, 1893 * but instead continue with updating the ISP params to enable testing of features 1894 * which are currently in TR phase. */ 1895 1896 err = (err1 != 0) ? err1 : ((err2 != 0) ? err2 : err); 1897 1898 IA_CSS_LEAVE_ERR_PRIVATE(err); 1899 return err; 1900} 1901 1902static int 1903sh_css_set_per_frame_isp_config_on_pipe( 1904 struct ia_css_stream *stream, 1905 const struct ia_css_isp_config *config, 1906 struct ia_css_pipe *pipe) 1907{ 1908 unsigned int i; 1909 bool per_frame_config_created = false; 1910 int err = 0; 1911 int err1 = 0; 1912 int err2 = 0; 1913 int err3 = 0; 1914 1915 struct sh_css_ddr_address_map *ddr_ptrs; 1916 struct sh_css_ddr_address_map_size *ddr_ptrs_size; 1917 struct ia_css_isp_parameters *params; 1918 1919 IA_CSS_ENTER_PRIVATE("stream=%p, config=%p, pipe=%p", stream, config, pipe); 1920 1921 if (!pipe) { 1922 err = -EINVAL; 1923 goto exit; 1924 } 1925 1926 /* create per-frame ISP params object with default values 1927 * from stream->isp_params_configs if one doesn't already exist 1928 */ 1929 if (!stream->per_frame_isp_params_configs) { 1930 err = sh_css_create_isp_params(stream, 1931 &stream->per_frame_isp_params_configs); 1932 if (err) 1933 goto exit; 1934 per_frame_config_created = true; 1935 } 1936 1937 params = stream->per_frame_isp_params_configs; 1938 1939 /* update new ISP params object with the new config */ 1940 if (!sh_css_init_isp_params_from_global(stream, params, false, pipe)) { 1941 err1 = -EINVAL; 1942 } 1943 1944 err2 = sh_css_init_isp_params_from_config(stream->pipes[0], params, config, pipe); 1945 1946 if (per_frame_config_created) { 1947 ddr_ptrs = ¶ms->ddr_ptrs; 1948 ddr_ptrs_size = ¶ms->ddr_ptrs_size; 1949 /* create per pipe reference to general ddr_ptrs */ 1950 for (i = 0; i < IA_CSS_PIPE_ID_NUM; i++) { 1951 ref_sh_css_ddr_address_map(ddr_ptrs, ¶ms->pipe_ddr_ptrs[i]); 1952 params->pipe_ddr_ptrs_size[i] = *ddr_ptrs_size; 1953 } 1954 } 1955 1956 /* now commit to ddr */ 1957 err3 = sh_css_param_update_isp_params(stream->pipes[0], params, sh_css_sp_is_running(), pipe); 1958 1959 /* The following code is intentional. The sh_css_init_sp_params_from_config and 1960 * sh_css_init_isp_params_from_config throws an error when both DPC and BDS is enabled. 1961 * The CSS API must pass this error information to the caller, ie. the host. 1962 * We do not return this error immediately, but instead continue with updating the ISP params 1963 * to enable testing of features which are currently in TR phase. */ 1964 err = (err1 != 0) ? err1 : 1965 (err2 != 0) ? err2 : 1966 (err3 != 0) ? err3 : err; 1967exit: 1968 IA_CSS_LEAVE_ERR_PRIVATE(err); 1969 return err; 1970} 1971 1972static int 1973sh_css_init_isp_params_from_config(struct ia_css_pipe *pipe, 1974 struct ia_css_isp_parameters *params, 1975 const struct ia_css_isp_config *config, 1976 struct ia_css_pipe *pipe_in) 1977{ 1978 int err = 0; 1979 bool is_dp_10bpp = true; 1980 1981 assert(pipe); 1982 1983 IA_CSS_ENTER_PRIVATE("pipe=%p, config=%p, params=%p", pipe, config, params); 1984 1985 ia_css_set_configs(params, config); 1986 1987 sh_css_set_nr_config(params, config->nr_config); 1988 sh_css_set_ee_config(params, config->ee_config); 1989 sh_css_set_baa_config(params, config->baa_config); 1990 if ((pipe->mode < IA_CSS_PIPE_ID_NUM) && 1991 (params->pipe_dvs_6axis_config[pipe->mode])) 1992 sh_css_set_pipe_dvs_6axis_config(pipe, params, config->dvs_6axis_config); 1993 sh_css_set_dz_config(params, config->dz_config); 1994 sh_css_set_motion_vector(params, config->motion_vector); 1995 sh_css_set_shading_table(pipe->stream, params, config->shading_table); 1996 sh_css_set_morph_table(params, config->morph_table); 1997 sh_css_set_macc_table(params, config->macc_table); 1998 sh_css_set_gamma_table(params, config->gamma_table); 1999 sh_css_set_ctc_table(params, config->ctc_table); 2000 /* ------ deprecated(bz675) : from ------ */ 2001 sh_css_set_shading_settings(params, config->shading_settings); 2002 /* ------ deprecated(bz675) : to ------ */ 2003 2004 params->dis_coef_table_changed = (config->dvs_coefs); 2005 params->dvs2_coef_table_changed = (config->dvs2_coefs); 2006 2007 params->output_frame = config->output_frame; 2008 params->isp_parameters_id = config->isp_config_id; 2009 2010 if (0 == 2011 sh_css_select_dp_10bpp_config(pipe, &is_dp_10bpp)) { 2012 /* return an error when both DPC and BDS is enabled by the 2013 * user. */ 2014 /* we do not exit from this point immediately to allow internal 2015 * firmware feature testing. */ 2016 if (is_dp_10bpp) { 2017 err = -EINVAL; 2018 } 2019 } else { 2020 err = -EINVAL; 2021 goto exit; 2022 } 2023 2024 ia_css_set_param_exceptions(pipe, params); 2025 2026exit: 2027 IA_CSS_LEAVE_ERR_PRIVATE(err); 2028 return err; 2029} 2030 2031void 2032ia_css_stream_get_isp_config( 2033 const struct ia_css_stream *stream, 2034 struct ia_css_isp_config *config) 2035{ 2036 IA_CSS_ENTER("void"); 2037 ia_css_pipe_get_isp_config(stream->pipes[0], config); 2038 IA_CSS_LEAVE("void"); 2039} 2040 2041void 2042ia_css_pipe_get_isp_config(struct ia_css_pipe *pipe, 2043 struct ia_css_isp_config *config) 2044{ 2045 struct ia_css_isp_parameters *params = NULL; 2046 2047 assert(config); 2048 2049 IA_CSS_ENTER("config=%p", config); 2050 2051 params = pipe->stream->isp_params_configs; 2052 assert(params); 2053 2054 ia_css_get_configs(params, config); 2055 2056 sh_css_get_ee_config(params, config->ee_config); 2057 sh_css_get_baa_config(params, config->baa_config); 2058 sh_css_get_pipe_dvs_6axis_config(pipe, params, config->dvs_6axis_config); 2059 sh_css_get_macc_table(params, config->macc_table); 2060 sh_css_get_gamma_table(params, config->gamma_table); 2061 sh_css_get_ctc_table(params, config->ctc_table); 2062 sh_css_get_dz_config(params, config->dz_config); 2063 sh_css_get_motion_vector(params, config->motion_vector); 2064 /* ------ deprecated(bz675) : from ------ */ 2065 sh_css_get_shading_settings(params, config->shading_settings); 2066 /* ------ deprecated(bz675) : to ------ */ 2067 2068 config->output_frame = params->output_frame; 2069 config->isp_config_id = params->isp_parameters_id; 2070 2071 IA_CSS_LEAVE("void"); 2072} 2073 2074/* 2075 * coding style says the return of "mmgr_NULL" is the error signal 2076 * 2077 * Deprecated: Implement mmgr_realloc() 2078 */ 2079static bool realloc_isp_css_mm_buf( 2080 ia_css_ptr *curr_buf, 2081 size_t *curr_size, 2082 size_t needed_size, 2083 bool force, 2084 int *err) 2085{ 2086 s32 id; 2087 2088 *err = 0; 2089 /* Possible optimization: add a function sh_css_isp_css_mm_realloc() 2090 * and implement on top of hmm. */ 2091 2092 IA_CSS_ENTER_PRIVATE("void"); 2093 2094 if (!force && *curr_size >= needed_size) { 2095 IA_CSS_LEAVE_PRIVATE("false"); 2096 return false; 2097 } 2098 /* don't reallocate if single ref to buffer and same size */ 2099 if (*curr_size == needed_size && ia_css_refcount_is_single(*curr_buf)) { 2100 IA_CSS_LEAVE_PRIVATE("false"); 2101 return false; 2102 } 2103 2104 id = IA_CSS_REFCOUNT_PARAM_BUFFER; 2105 ia_css_refcount_decrement(id, *curr_buf); 2106 *curr_buf = ia_css_refcount_increment(id, hmm_alloc(needed_size)); 2107 if (!*curr_buf) { 2108 *err = -ENOMEM; 2109 *curr_size = 0; 2110 } else { 2111 *curr_size = needed_size; 2112 } 2113 IA_CSS_LEAVE_PRIVATE("true"); 2114 return true; 2115} 2116 2117static bool reallocate_buffer( 2118 ia_css_ptr *curr_buf, 2119 size_t *curr_size, 2120 size_t needed_size, 2121 bool force, 2122 int *err) 2123{ 2124 bool ret; 2125 2126 IA_CSS_ENTER_PRIVATE("void"); 2127 2128 ret = realloc_isp_css_mm_buf(curr_buf, 2129 curr_size, needed_size, force, err); 2130 2131 IA_CSS_LEAVE_PRIVATE("ret=%d", ret); 2132 return ret; 2133} 2134 2135struct ia_css_isp_3a_statistics * 2136ia_css_isp_3a_statistics_allocate(const struct ia_css_3a_grid_info *grid) 2137{ 2138 struct ia_css_isp_3a_statistics *me; 2139 2140 IA_CSS_ENTER("grid=%p", grid); 2141 2142 assert(grid); 2143 2144 /* MW: Does "grid->enable" also control the histogram output ?? */ 2145 if (!grid->enable) 2146 return NULL; 2147 2148 me = kvcalloc(1, sizeof(*me), GFP_KERNEL); 2149 if (!me) 2150 goto err; 2151 2152 if (grid->use_dmem) { 2153 me->dmem_size = sizeof(struct ia_css_3a_output) * 2154 grid->aligned_width * 2155 grid->aligned_height; 2156 } else { 2157 me->vmem_size = ISP_S3ATBL_HI_LO_STRIDE_BYTES * 2158 grid->aligned_height; 2159 } 2160 me->hmem_size = sizeof_hmem(HMEM0_ID); 2161 2162 /* All subsections need to be aligned to the system bus width */ 2163 me->dmem_size = CEIL_MUL(me->dmem_size, HIVE_ISP_DDR_WORD_BYTES); 2164 me->vmem_size = CEIL_MUL(me->vmem_size, HIVE_ISP_DDR_WORD_BYTES); 2165 me->hmem_size = CEIL_MUL(me->hmem_size, HIVE_ISP_DDR_WORD_BYTES); 2166 2167 me->size = me->dmem_size + me->vmem_size * 2 + me->hmem_size; 2168 me->data_ptr = hmm_alloc(me->size); 2169 if (me->data_ptr == mmgr_NULL) { 2170 kvfree(me); 2171 me = NULL; 2172 goto err; 2173 } 2174 if (me->dmem_size) 2175 me->data.dmem.s3a_tbl = me->data_ptr; 2176 if (me->vmem_size) { 2177 me->data.vmem.s3a_tbl_hi = me->data_ptr + me->dmem_size; 2178 me->data.vmem.s3a_tbl_lo = me->data_ptr + me->dmem_size + me->vmem_size; 2179 } 2180 if (me->hmem_size) 2181 me->data_hmem.rgby_tbl = me->data_ptr + me->dmem_size + 2 * me->vmem_size; 2182 2183err: 2184 IA_CSS_LEAVE("return=%p", me); 2185 return me; 2186} 2187 2188void 2189ia_css_isp_3a_statistics_free(struct ia_css_isp_3a_statistics *me) 2190{ 2191 if (me) { 2192 hmm_free(me->data_ptr); 2193 kvfree(me); 2194 } 2195} 2196 2197struct ia_css_isp_skc_dvs_statistics *ia_css_skc_dvs_statistics_allocate(void) 2198{ 2199 return NULL; 2200} 2201 2202struct ia_css_metadata * 2203ia_css_metadata_allocate(const struct ia_css_metadata_info *metadata_info) 2204{ 2205 struct ia_css_metadata *md = NULL; 2206 2207 IA_CSS_ENTER(""); 2208 2209 if (metadata_info->size == 0) 2210 return NULL; 2211 2212 md = kvmalloc(sizeof(*md), GFP_KERNEL); 2213 if (!md) 2214 goto error; 2215 2216 md->info = *metadata_info; 2217 md->exp_id = 0; 2218 md->address = hmm_alloc(metadata_info->size); 2219 if (md->address == mmgr_NULL) 2220 goto error; 2221 2222 IA_CSS_LEAVE("return=%p", md); 2223 return md; 2224 2225error: 2226 ia_css_metadata_free(md); 2227 IA_CSS_LEAVE("return=%p", NULL); 2228 return NULL; 2229} 2230 2231void 2232ia_css_metadata_free(struct ia_css_metadata *me) 2233{ 2234 if (me) { 2235 /* The enter and leave macros are placed inside 2236 * the condition to avoid false logging of metadata 2237 * free events when metadata is disabled. 2238 * We found this to be confusing during development 2239 * and debugging. */ 2240 IA_CSS_ENTER("me=%p", me); 2241 hmm_free(me->address); 2242 kvfree(me); 2243 IA_CSS_LEAVE("void"); 2244 } 2245} 2246 2247void 2248ia_css_metadata_free_multiple(unsigned int num_bufs, 2249 struct ia_css_metadata **bufs) 2250{ 2251 unsigned int i; 2252 2253 if (bufs) { 2254 for (i = 0; i < num_bufs; i++) 2255 ia_css_metadata_free(bufs[i]); 2256 } 2257} 2258 2259static unsigned int g_param_buffer_dequeue_count; 2260static unsigned int g_param_buffer_enqueue_count; 2261 2262int 2263ia_css_stream_isp_parameters_init(struct ia_css_stream *stream) 2264{ 2265 int err = 0; 2266 unsigned int i; 2267 struct sh_css_ddr_address_map *ddr_ptrs; 2268 struct sh_css_ddr_address_map_size *ddr_ptrs_size; 2269 struct ia_css_isp_parameters *params; 2270 2271 assert(stream); 2272 IA_CSS_ENTER_PRIVATE("void"); 2273 2274 if (!stream) { 2275 IA_CSS_LEAVE_ERR_PRIVATE(-EINVAL); 2276 return -EINVAL; 2277 } 2278 /* TMP: tracking of paramsets */ 2279 g_param_buffer_dequeue_count = 0; 2280 g_param_buffer_enqueue_count = 0; 2281 2282 stream->per_frame_isp_params_configs = NULL; 2283 err = sh_css_create_isp_params(stream, 2284 &stream->isp_params_configs); 2285 if (err) 2286 goto ERR; 2287 2288 params = stream->isp_params_configs; 2289 if (!sh_css_init_isp_params_from_global(stream, params, true, NULL)) { 2290 /* we do not return the error immediately to enable internal 2291 * firmware feature testing */ 2292 err = -EINVAL; 2293 } 2294 2295 ddr_ptrs = ¶ms->ddr_ptrs; 2296 ddr_ptrs_size = ¶ms->ddr_ptrs_size; 2297 2298 /* create per pipe reference to general ddr_ptrs */ 2299 for (i = 0; i < IA_CSS_PIPE_ID_NUM; i++) { 2300 ref_sh_css_ddr_address_map(ddr_ptrs, ¶ms->pipe_ddr_ptrs[i]); 2301 params->pipe_ddr_ptrs_size[i] = *ddr_ptrs_size; 2302 } 2303 2304ERR: 2305 IA_CSS_LEAVE_ERR_PRIVATE(err); 2306 return err; 2307} 2308 2309static void 2310ia_css_set_sdis_config( 2311 struct ia_css_isp_parameters *params, 2312 const struct ia_css_dvs_coefficients *dvs_coefs) 2313{ 2314 ia_css_set_sdis_horicoef_config(params, dvs_coefs); 2315 ia_css_set_sdis_vertcoef_config(params, dvs_coefs); 2316 ia_css_set_sdis_horiproj_config(params, dvs_coefs); 2317 ia_css_set_sdis_vertproj_config(params, dvs_coefs); 2318} 2319 2320static void 2321ia_css_set_sdis2_config( 2322 struct ia_css_isp_parameters *params, 2323 const struct ia_css_dvs2_coefficients *dvs2_coefs) 2324{ 2325 ia_css_set_sdis2_horicoef_config(params, dvs2_coefs); 2326 ia_css_set_sdis2_vertcoef_config(params, dvs2_coefs); 2327 ia_css_set_sdis2_horiproj_config(params, dvs2_coefs); 2328 ia_css_set_sdis2_vertproj_config(params, dvs2_coefs); 2329} 2330 2331static int 2332sh_css_create_isp_params(struct ia_css_stream *stream, 2333 struct ia_css_isp_parameters **isp_params_out) 2334{ 2335 bool succ = true; 2336 unsigned int i; 2337 struct sh_css_ddr_address_map *ddr_ptrs; 2338 struct sh_css_ddr_address_map_size *ddr_ptrs_size; 2339 int err; 2340 size_t params_size; 2341 struct ia_css_isp_parameters *params = 2342 kvmalloc(sizeof(struct ia_css_isp_parameters), GFP_KERNEL); 2343 2344 if (!params) { 2345 *isp_params_out = NULL; 2346 err = -ENOMEM; 2347 IA_CSS_ERROR("%s:%d error: cannot allocate memory", __FILE__, __LINE__); 2348 IA_CSS_LEAVE_ERR_PRIVATE(err); 2349 return err; 2350 } else { 2351 memset(params, 0, sizeof(struct ia_css_isp_parameters)); 2352 } 2353 2354 ddr_ptrs = ¶ms->ddr_ptrs; 2355 ddr_ptrs_size = ¶ms->ddr_ptrs_size; 2356 2357 for (i = 0; i < IA_CSS_PIPE_ID_NUM; i++) { 2358 memset(¶ms->pipe_ddr_ptrs[i], 0, 2359 sizeof(params->pipe_ddr_ptrs[i])); 2360 memset(¶ms->pipe_ddr_ptrs_size[i], 0, 2361 sizeof(params->pipe_ddr_ptrs_size[i])); 2362 } 2363 2364 memset(ddr_ptrs, 0, sizeof(*ddr_ptrs)); 2365 memset(ddr_ptrs_size, 0, sizeof(*ddr_ptrs_size)); 2366 2367 params_size = sizeof(params->uds); 2368 ddr_ptrs_size->isp_param = params_size; 2369 ddr_ptrs->isp_param = 2370 ia_css_refcount_increment(IA_CSS_REFCOUNT_PARAM_BUFFER, 2371 hmm_alloc(params_size)); 2372 succ &= (ddr_ptrs->isp_param != mmgr_NULL); 2373 2374 ddr_ptrs_size->macc_tbl = sizeof(struct ia_css_macc_table); 2375 ddr_ptrs->macc_tbl = 2376 ia_css_refcount_increment(IA_CSS_REFCOUNT_PARAM_BUFFER, 2377 hmm_alloc(sizeof(struct ia_css_macc_table))); 2378 succ &= (ddr_ptrs->macc_tbl != mmgr_NULL); 2379 2380 *isp_params_out = params; 2381 2382 if (!succ) 2383 return -ENOMEM; 2384 2385 return 0; 2386} 2387 2388static bool 2389sh_css_init_isp_params_from_global(struct ia_css_stream *stream, 2390 struct ia_css_isp_parameters *params, 2391 bool use_default_config, 2392 struct ia_css_pipe *pipe_in) 2393{ 2394 bool retval = true; 2395 int i = 0; 2396 bool is_dp_10bpp = true; 2397 unsigned int isp_pipe_version = ia_css_pipe_get_isp_pipe_version( 2398 stream->pipes[0]); 2399 struct ia_css_isp_parameters *stream_params = stream->isp_params_configs; 2400 2401 if (!use_default_config && !stream_params) { 2402 retval = false; 2403 goto exit; 2404 } 2405 2406 params->output_frame = NULL; 2407 params->isp_parameters_id = 0; 2408 2409 if (use_default_config) { 2410 ia_css_set_xnr3_config(params, &default_xnr3_config); 2411 2412 sh_css_set_nr_config(params, &default_nr_config); 2413 sh_css_set_ee_config(params, &default_ee_config); 2414 if (isp_pipe_version == SH_CSS_ISP_PIPE_VERSION_1) 2415 sh_css_set_macc_table(params, &default_macc_table); 2416 else if (isp_pipe_version == SH_CSS_ISP_PIPE_VERSION_2_2) 2417 sh_css_set_macc_table(params, &default_macc2_table); 2418 sh_css_set_gamma_table(params, &default_gamma_table); 2419 sh_css_set_ctc_table(params, &default_ctc_table); 2420 sh_css_set_baa_config(params, &default_baa_config); 2421 sh_css_set_dz_config(params, &default_dz_config); 2422 /* ------ deprecated(bz675) : from ------ */ 2423 sh_css_set_shading_settings(params, &default_shading_settings); 2424 /* ------ deprecated(bz675) : to ------ */ 2425 2426 ia_css_set_s3a_config(params, &default_3a_config); 2427 ia_css_set_wb_config(params, &default_wb_config); 2428 ia_css_set_csc_config(params, &default_cc_config); 2429 ia_css_set_tnr_config(params, &default_tnr_config); 2430 ia_css_set_ob_config(params, &default_ob_config); 2431 ia_css_set_dp_config(params, &default_dp_config); 2432 2433 ia_css_set_param_exceptions(pipe_in, params); 2434 2435 ia_css_set_de_config(params, &default_de_config); 2436 ia_css_set_gc_config(params, &default_gc_config); 2437 ia_css_set_anr_config(params, &default_anr_config); 2438 ia_css_set_anr2_config(params, &default_anr_thres); 2439 ia_css_set_ce_config(params, &default_ce_config); 2440 ia_css_set_xnr_table_config(params, &default_xnr_table); 2441 ia_css_set_ecd_config(params, &default_ecd_config); 2442 ia_css_set_ynr_config(params, &default_ynr_config); 2443 ia_css_set_fc_config(params, &default_fc_config); 2444 ia_css_set_cnr_config(params, &default_cnr_config); 2445 ia_css_set_macc_config(params, &default_macc_config); 2446 ia_css_set_ctc_config(params, &default_ctc_config); 2447 ia_css_set_aa_config(params, &default_aa_config); 2448 ia_css_set_r_gamma_config(params, &default_r_gamma_table); 2449 ia_css_set_g_gamma_config(params, &default_g_gamma_table); 2450 ia_css_set_b_gamma_config(params, &default_b_gamma_table); 2451 ia_css_set_yuv2rgb_config(params, &default_yuv2rgb_cc_config); 2452 ia_css_set_rgb2yuv_config(params, &default_rgb2yuv_cc_config); 2453 ia_css_set_xnr_config(params, &default_xnr_config); 2454 ia_css_set_sdis_config(params, &default_sdis_config); 2455 ia_css_set_sdis2_config(params, &default_sdis2_config); 2456 ia_css_set_formats_config(params, &default_formats_config); 2457 2458 params->fpn_config.data = NULL; 2459 params->config_changed[IA_CSS_FPN_ID] = true; 2460 params->fpn_config.enabled = 0; 2461 2462 params->motion_config = default_motion_config; 2463 params->motion_config_changed = true; 2464 2465 params->morph_table = NULL; 2466 params->morph_table_changed = true; 2467 2468 params->sc_table = NULL; 2469 params->sc_table_changed = true; 2470 2471 ia_css_sdis2_clear_coefficients(¶ms->dvs2_coefs); 2472 params->dvs2_coef_table_changed = true; 2473 2474 ia_css_sdis_clear_coefficients(¶ms->dvs_coefs); 2475 params->dis_coef_table_changed = true; 2476 } else { 2477 ia_css_set_xnr3_config(params, &stream_params->xnr3_config); 2478 2479 sh_css_set_nr_config(params, &stream_params->nr_config); 2480 sh_css_set_ee_config(params, &stream_params->ee_config); 2481 if (isp_pipe_version == SH_CSS_ISP_PIPE_VERSION_1) 2482 sh_css_set_macc_table(params, &stream_params->macc_table); 2483 else if (isp_pipe_version == SH_CSS_ISP_PIPE_VERSION_2_2) 2484 sh_css_set_macc_table(params, &stream_params->macc_table); 2485 sh_css_set_gamma_table(params, &stream_params->gc_table); 2486 sh_css_set_ctc_table(params, &stream_params->ctc_table); 2487 sh_css_set_baa_config(params, &stream_params->bds_config); 2488 sh_css_set_dz_config(params, &stream_params->dz_config); 2489 /* ------ deprecated(bz675) : from ------ */ 2490 sh_css_set_shading_settings(params, &stream_params->shading_settings); 2491 /* ------ deprecated(bz675) : to ------ */ 2492 2493 ia_css_set_s3a_config(params, &stream_params->s3a_config); 2494 ia_css_set_wb_config(params, &stream_params->wb_config); 2495 ia_css_set_csc_config(params, &stream_params->cc_config); 2496 ia_css_set_tnr_config(params, &stream_params->tnr_config); 2497 ia_css_set_ob_config(params, &stream_params->ob_config); 2498 ia_css_set_dp_config(params, &stream_params->dp_config); 2499 ia_css_set_de_config(params, &stream_params->de_config); 2500 ia_css_set_gc_config(params, &stream_params->gc_config); 2501 ia_css_set_anr_config(params, &stream_params->anr_config); 2502 ia_css_set_anr2_config(params, &stream_params->anr_thres); 2503 ia_css_set_ce_config(params, &stream_params->ce_config); 2504 ia_css_set_xnr_table_config(params, &stream_params->xnr_table); 2505 ia_css_set_ecd_config(params, &stream_params->ecd_config); 2506 ia_css_set_ynr_config(params, &stream_params->ynr_config); 2507 ia_css_set_fc_config(params, &stream_params->fc_config); 2508 ia_css_set_cnr_config(params, &stream_params->cnr_config); 2509 ia_css_set_macc_config(params, &stream_params->macc_config); 2510 ia_css_set_ctc_config(params, &stream_params->ctc_config); 2511 ia_css_set_aa_config(params, &stream_params->aa_config); 2512 ia_css_set_r_gamma_config(params, &stream_params->r_gamma_table); 2513 ia_css_set_g_gamma_config(params, &stream_params->g_gamma_table); 2514 ia_css_set_b_gamma_config(params, &stream_params->b_gamma_table); 2515 ia_css_set_yuv2rgb_config(params, &stream_params->yuv2rgb_cc_config); 2516 ia_css_set_rgb2yuv_config(params, &stream_params->rgb2yuv_cc_config); 2517 ia_css_set_xnr_config(params, &stream_params->xnr_config); 2518 ia_css_set_formats_config(params, &stream_params->formats_config); 2519 2520 for (i = 0; i < stream->num_pipes; i++) { 2521 if (0 == 2522 sh_css_select_dp_10bpp_config(stream->pipes[i], &is_dp_10bpp)) { 2523 /* set the return value as false if both DPC and 2524 * BDS is enabled by the user. But we do not return 2525 * the value immediately to enable internal firmware 2526 * feature testing. */ 2527 retval = !is_dp_10bpp; 2528 /* FIXME: should it ignore this error? */ 2529 } else { 2530 retval = false; 2531 goto exit; 2532 } 2533 } 2534 2535 ia_css_set_param_exceptions(pipe_in, params); 2536 2537 params->fpn_config.data = stream_params->fpn_config.data; 2538 params->config_changed[IA_CSS_FPN_ID] = 2539 stream_params->config_changed[IA_CSS_FPN_ID]; 2540 params->fpn_config.enabled = stream_params->fpn_config.enabled; 2541 2542 sh_css_set_motion_vector(params, &stream_params->motion_config); 2543 sh_css_set_morph_table(params, stream_params->morph_table); 2544 2545 if (stream_params->sc_table) { 2546 sh_css_set_shading_table(stream, params, stream_params->sc_table); 2547 } else { 2548 params->sc_table = NULL; 2549 params->sc_table_changed = true; 2550 } 2551 2552 /* Only IA_CSS_PIPE_ID_VIDEO & IA_CSS_PIPE_ID_CAPTURE will support dvs_6axis_config*/ 2553 for (i = 0; i < IA_CSS_PIPE_ID_NUM; i++) { 2554 if (stream_params->pipe_dvs_6axis_config[i]) { 2555 if (params->pipe_dvs_6axis_config[i]) { 2556 copy_dvs_6axis_table(params->pipe_dvs_6axis_config[i], 2557 stream_params->pipe_dvs_6axis_config[i]); 2558 } else { 2559 params->pipe_dvs_6axis_config[i] = 2560 generate_dvs_6axis_table_from_config(stream_params->pipe_dvs_6axis_config[i]); 2561 } 2562 } 2563 } 2564 ia_css_set_sdis_config(params, &stream_params->dvs_coefs); 2565 params->dis_coef_table_changed = stream_params->dis_coef_table_changed; 2566 2567 ia_css_set_sdis2_config(params, &stream_params->dvs2_coefs); 2568 params->dvs2_coef_table_changed = stream_params->dvs2_coef_table_changed; 2569 params->sensor_binning = stream_params->sensor_binning; 2570 } 2571 2572exit: 2573 return retval; 2574} 2575 2576int 2577sh_css_params_init(void) 2578{ 2579 int i, p; 2580 2581 IA_CSS_ENTER_PRIVATE("void"); 2582 2583 /* TMP: tracking of paramsets */ 2584 g_param_buffer_dequeue_count = 0; 2585 g_param_buffer_enqueue_count = 0; 2586 2587 for (p = 0; p < IA_CSS_PIPE_ID_NUM; p++) { 2588 for (i = 0; i < SH_CSS_MAX_STAGES; i++) { 2589 xmem_sp_stage_ptrs[p][i] = 2590 ia_css_refcount_increment(-1, 2591 hmm_alloc(sizeof(struct sh_css_sp_stage))); 2592 xmem_isp_stage_ptrs[p][i] = 2593 ia_css_refcount_increment(-1, 2594 hmm_alloc(sizeof(struct sh_css_sp_stage))); 2595 2596 if ((xmem_sp_stage_ptrs[p][i] == mmgr_NULL) || 2597 (xmem_isp_stage_ptrs[p][i] == mmgr_NULL)) { 2598 sh_css_params_uninit(); 2599 IA_CSS_LEAVE_ERR_PRIVATE(-ENOMEM); 2600 return -ENOMEM; 2601 } 2602 2603 hmm_set(xmem_sp_stage_ptrs[p][i], 0, sizeof(struct sh_css_sp_stage)); 2604 hmm_set(xmem_isp_stage_ptrs[p][i], 0, sizeof(struct sh_css_sp_stage)); 2605 } 2606 } 2607 2608 ia_css_config_gamma_table(); 2609 ia_css_config_ctc_table(); 2610 ia_css_config_rgb_gamma_tables(); 2611 ia_css_config_xnr_table(); 2612 2613 sp_ddr_ptrs = ia_css_refcount_increment(-1, 2614 hmm_alloc(CEIL_MUL(sizeof(struct sh_css_ddr_address_map), 2615 HIVE_ISP_DDR_WORD_BYTES))); 2616 xmem_sp_group_ptrs = ia_css_refcount_increment(-1, 2617 hmm_alloc(sizeof(struct sh_css_sp_group))); 2618 2619 if ((sp_ddr_ptrs == mmgr_NULL) || 2620 (xmem_sp_group_ptrs == mmgr_NULL)) { 2621 ia_css_uninit(); 2622 IA_CSS_LEAVE_ERR_PRIVATE(-ENOMEM); 2623 return -ENOMEM; 2624 } 2625 hmm_set(sp_ddr_ptrs, 0, CEIL_MUL(sizeof(struct sh_css_ddr_address_map), 2626 HIVE_ISP_DDR_WORD_BYTES)); 2627 hmm_set(xmem_sp_group_ptrs, 0, sizeof(struct sh_css_sp_group)); 2628 IA_CSS_LEAVE_ERR_PRIVATE(0); 2629 return 0; 2630} 2631 2632static void host_lut_store(const void *lut) 2633{ 2634 unsigned int i; 2635 2636 for (i = 0; i < N_GDC_ID; i++) 2637 gdc_lut_store((gdc_ID_t)i, (const int (*)[HRT_GDC_N]) lut); 2638} 2639 2640int ia_css_pipe_set_bci_scaler_lut(struct ia_css_pipe *pipe, 2641 const void *lut) 2642{ 2643 int err = 0; 2644 bool stream_started = false; 2645 2646 IA_CSS_ENTER("pipe=%p lut=%p", pipe, lut); 2647 2648 if (!lut || !pipe) { 2649 err = -EINVAL; 2650 IA_CSS_LEAVE("err=%d", err); 2651 return err; 2652 } 2653 2654 /* If the pipe belongs to a stream and the stream has started, it is not 2655 * safe to store lut to gdc HW. If pipe->stream is NULL, then no stream is 2656 * created with this pipe, so it is safe to do this operation as long as 2657 * ia_css_init() has been called. */ 2658 if (pipe->stream && pipe->stream->started) { 2659 ia_css_debug_dtrace(IA_CSS_DEBUG_ERROR, 2660 "unable to set scaler lut since stream has started\n"); 2661 stream_started = true; 2662 err = -ENOTSUPP; 2663 } 2664 2665 /* Free any existing tables. */ 2666 if (pipe->scaler_pp_lut != mmgr_NULL) { 2667 hmm_free(pipe->scaler_pp_lut); 2668 pipe->scaler_pp_lut = mmgr_NULL; 2669 } 2670 2671 if (!stream_started) { 2672 pipe->scaler_pp_lut = hmm_alloc(sizeof(zoom_table)); 2673 2674 if (pipe->scaler_pp_lut == mmgr_NULL) { 2675 ia_css_debug_dtrace(IA_CSS_DEBUG_ERROR, 2676 "unable to allocate scaler_pp_lut\n"); 2677 err = -ENOMEM; 2678 } else { 2679 gdc_lut_convert_to_isp_format((const int(*)[HRT_GDC_N])lut, 2680 interleaved_lut_temp); 2681 hmm_store(pipe->scaler_pp_lut, 2682 (int *)interleaved_lut_temp, 2683 sizeof(zoom_table)); 2684 } 2685 } 2686 2687 IA_CSS_LEAVE("lut(%u) err=%d", pipe->scaler_pp_lut, err); 2688 return err; 2689} 2690 2691/* if pipe is NULL, returns default lut addr. */ 2692ia_css_ptr sh_css_pipe_get_pp_gdc_lut(const struct ia_css_pipe *pipe) 2693{ 2694 assert(pipe); 2695 2696 if (pipe->scaler_pp_lut != mmgr_NULL) 2697 return pipe->scaler_pp_lut; 2698 else 2699 return sh_css_params_get_default_gdc_lut(); 2700} 2701 2702int sh_css_params_map_and_store_default_gdc_lut(void) 2703{ 2704 int err = 0; 2705 2706 IA_CSS_ENTER_PRIVATE("void"); 2707 2708 /* Is table already mapped? Nothing to do if it is mapped. */ 2709 if (default_gdc_lut != mmgr_NULL) 2710 return err; 2711 2712 host_lut_store((void *)zoom_table); 2713 2714 default_gdc_lut = hmm_alloc(sizeof(zoom_table)); 2715 2716 if (default_gdc_lut == mmgr_NULL) 2717 return -ENOMEM; 2718 2719 gdc_lut_convert_to_isp_format((const int(*)[HRT_GDC_N])zoom_table, 2720 interleaved_lut_temp); 2721 hmm_store(default_gdc_lut, (int *)interleaved_lut_temp, 2722 sizeof(zoom_table)); 2723 2724 IA_CSS_LEAVE_PRIVATE("lut(%u) err=%d", default_gdc_lut, err); 2725 return err; 2726} 2727 2728void sh_css_params_free_default_gdc_lut(void) 2729{ 2730 IA_CSS_ENTER_PRIVATE("void"); 2731 2732 if (default_gdc_lut != mmgr_NULL) { 2733 hmm_free(default_gdc_lut); 2734 default_gdc_lut = mmgr_NULL; 2735 } 2736 2737 IA_CSS_LEAVE_PRIVATE("void"); 2738} 2739 2740ia_css_ptr sh_css_params_get_default_gdc_lut(void) 2741{ 2742 return default_gdc_lut; 2743} 2744 2745static void free_param_set_callback( 2746 ia_css_ptr ptr) 2747{ 2748 IA_CSS_ENTER_PRIVATE("void"); 2749 2750 free_ia_css_isp_parameter_set_info(ptr); 2751 2752 IA_CSS_LEAVE_PRIVATE("void"); 2753} 2754 2755static void free_buffer_callback( 2756 ia_css_ptr ptr) 2757{ 2758 IA_CSS_ENTER_PRIVATE("void"); 2759 2760 hmm_free(ptr); 2761 2762 IA_CSS_LEAVE_PRIVATE("void"); 2763} 2764 2765void 2766sh_css_param_clear_param_sets(void) 2767{ 2768 IA_CSS_ENTER_PRIVATE("void"); 2769 2770 ia_css_refcount_clear(IA_CSS_REFCOUNT_PARAM_SET_POOL, &free_param_set_callback); 2771 2772 IA_CSS_LEAVE_PRIVATE("void"); 2773} 2774 2775/* 2776 * MW: we can define hmm_free() to return a NULL 2777 * then you can write ptr = hmm_free(ptr); 2778 */ 2779#define safe_free(id, x) \ 2780 do { \ 2781 ia_css_refcount_decrement(id, x); \ 2782 (x) = mmgr_NULL; \ 2783 } while (0) 2784 2785static void free_map(struct sh_css_ddr_address_map *map) 2786{ 2787 unsigned int i; 2788 2789 ia_css_ptr *addrs = (ia_css_ptr *)map; 2790 2791 IA_CSS_ENTER_PRIVATE("void"); 2792 2793 /* free buffers */ 2794 for (i = 0; i < (sizeof(struct sh_css_ddr_address_map_size) / 2795 sizeof(size_t)); i++) { 2796 if (addrs[i] == mmgr_NULL) 2797 continue; 2798 safe_free(IA_CSS_REFCOUNT_PARAM_BUFFER, addrs[i]); 2799 } 2800 2801 IA_CSS_LEAVE_PRIVATE("void"); 2802} 2803 2804void 2805ia_css_stream_isp_parameters_uninit(struct ia_css_stream *stream) 2806{ 2807 int i; 2808 struct ia_css_isp_parameters *params = stream->isp_params_configs; 2809 struct ia_css_isp_parameters *per_frame_params = 2810 stream->per_frame_isp_params_configs; 2811 2812 IA_CSS_ENTER_PRIVATE("void"); 2813 if (!params) { 2814 IA_CSS_LEAVE_PRIVATE("isp_param_configs is NULL"); 2815 return; 2816 } 2817 2818 /* free existing ddr_ptr maps */ 2819 for (i = 0; i < IA_CSS_PIPE_ID_NUM; i++) { 2820 free_map(¶ms->pipe_ddr_ptrs[i]); 2821 if (per_frame_params) 2822 free_map(&per_frame_params->pipe_ddr_ptrs[i]); 2823 /* Free up theDVS table memory blocks before recomputing new table */ 2824 if (params->pipe_dvs_6axis_config[i]) 2825 free_dvs_6axis_table(¶ms->pipe_dvs_6axis_config[i]); 2826 if (per_frame_params && per_frame_params->pipe_dvs_6axis_config[i]) 2827 free_dvs_6axis_table(&per_frame_params->pipe_dvs_6axis_config[i]); 2828 } 2829 free_map(¶ms->ddr_ptrs); 2830 if (per_frame_params) 2831 free_map(&per_frame_params->ddr_ptrs); 2832 2833 if (params->fpn_config.data) { 2834 kvfree(params->fpn_config.data); 2835 params->fpn_config.data = NULL; 2836 } 2837 2838 /* Free up sc_config (temporal shading table) if it is allocated. */ 2839 if (params->sc_config) { 2840 ia_css_shading_table_free(params->sc_config); 2841 params->sc_config = NULL; 2842 } 2843 if (per_frame_params) { 2844 if (per_frame_params->sc_config) { 2845 ia_css_shading_table_free(per_frame_params->sc_config); 2846 per_frame_params->sc_config = NULL; 2847 } 2848 } 2849 2850 kvfree(params); 2851 kvfree(per_frame_params); 2852 stream->isp_params_configs = NULL; 2853 stream->per_frame_isp_params_configs = NULL; 2854 2855 IA_CSS_LEAVE_PRIVATE("void"); 2856} 2857 2858void 2859sh_css_params_uninit(void) 2860{ 2861 unsigned int p, i; 2862 2863 IA_CSS_ENTER_PRIVATE("void"); 2864 2865 ia_css_refcount_decrement(-1, sp_ddr_ptrs); 2866 sp_ddr_ptrs = mmgr_NULL; 2867 ia_css_refcount_decrement(-1, xmem_sp_group_ptrs); 2868 xmem_sp_group_ptrs = mmgr_NULL; 2869 2870 for (p = 0; p < IA_CSS_PIPE_ID_NUM; p++) 2871 for (i = 0; i < SH_CSS_MAX_STAGES; i++) { 2872 ia_css_refcount_decrement(-1, xmem_sp_stage_ptrs[p][i]); 2873 xmem_sp_stage_ptrs[p][i] = mmgr_NULL; 2874 ia_css_refcount_decrement(-1, xmem_isp_stage_ptrs[p][i]); 2875 xmem_isp_stage_ptrs[p][i] = mmgr_NULL; 2876 } 2877 2878 /* go through the pools to clear references */ 2879 ia_css_refcount_clear(IA_CSS_REFCOUNT_PARAM_SET_POOL, &free_param_set_callback); 2880 ia_css_refcount_clear(IA_CSS_REFCOUNT_PARAM_BUFFER, &free_buffer_callback); 2881 ia_css_refcount_clear(-1, &free_buffer_callback); 2882 2883 IA_CSS_LEAVE_PRIVATE("void"); 2884} 2885 2886static struct ia_css_host_data * 2887convert_allocate_morph_plane( 2888 unsigned short *data, 2889 unsigned int width, 2890 unsigned int height, 2891 unsigned int aligned_width) 2892{ 2893 unsigned int i, j, padding, w; 2894 struct ia_css_host_data *me; 2895 unsigned int isp_data_size; 2896 u16 *isp_data_ptr; 2897 2898 IA_CSS_ENTER_PRIVATE("void"); 2899 2900 /* currently we don't have morph table interpolation yet, 2901 * so we allow a wider table to be used. This will be removed 2902 * in the future. */ 2903 if (width > aligned_width) { 2904 padding = 0; 2905 w = aligned_width; 2906 } else { 2907 padding = aligned_width - width; 2908 w = width; 2909 } 2910 isp_data_size = height * (w + padding) * sizeof(uint16_t); 2911 2912 me = ia_css_host_data_allocate((size_t)isp_data_size); 2913 2914 if (!me) { 2915 IA_CSS_LEAVE_ERR_PRIVATE(-ENOMEM); 2916 return NULL; 2917 } 2918 2919 isp_data_ptr = (uint16_t *)me->address; 2920 2921 memset(isp_data_ptr, 0, (size_t)isp_data_size); 2922 2923 for (i = 0; i < height; i++) { 2924 for (j = 0; j < w; j++) 2925 *isp_data_ptr++ = (uint16_t)data[j]; 2926 isp_data_ptr += padding; 2927 data += width; 2928 } 2929 2930 IA_CSS_LEAVE_PRIVATE("void"); 2931 return me; 2932} 2933 2934static int 2935store_morph_plane( 2936 unsigned short *data, 2937 unsigned int width, 2938 unsigned int height, 2939 ia_css_ptr dest, 2940 unsigned int aligned_width) 2941{ 2942 struct ia_css_host_data *isp_data; 2943 2944 assert(dest != mmgr_NULL); 2945 2946 isp_data = convert_allocate_morph_plane(data, width, height, aligned_width); 2947 if (!isp_data) { 2948 IA_CSS_LEAVE_ERR_PRIVATE(-ENOMEM); 2949 return -ENOMEM; 2950 } 2951 ia_css_params_store_ia_css_host_data(dest, isp_data); 2952 2953 ia_css_host_data_free(isp_data); 2954 return 0; 2955} 2956 2957static void sh_css_update_isp_params_to_ddr( 2958 struct ia_css_isp_parameters *params, 2959 ia_css_ptr ddr_ptr) 2960{ 2961 size_t size = sizeof(params->uds); 2962 2963 IA_CSS_ENTER_PRIVATE("void"); 2964 2965 assert(params); 2966 2967 hmm_store(ddr_ptr, ¶ms->uds, size); 2968 IA_CSS_LEAVE_PRIVATE("void"); 2969} 2970 2971static void sh_css_update_isp_mem_params_to_ddr( 2972 const struct ia_css_binary *binary, 2973 ia_css_ptr ddr_mem_ptr, 2974 size_t size, 2975 enum ia_css_isp_memories mem) 2976{ 2977 const struct ia_css_host_data *params; 2978 2979 IA_CSS_ENTER_PRIVATE("void"); 2980 2981 params = ia_css_isp_param_get_mem_init(&binary->mem_params, 2982 IA_CSS_PARAM_CLASS_PARAM, mem); 2983 hmm_store(ddr_mem_ptr, params->address, size); 2984 2985 IA_CSS_LEAVE_PRIVATE("void"); 2986} 2987 2988void ia_css_dequeue_param_buffers(/*unsigned int pipe_num*/ void) 2989{ 2990 unsigned int i; 2991 ia_css_ptr cpy; 2992 enum sh_css_queue_id param_queue_ids[3] = { IA_CSS_PARAMETER_SET_QUEUE_ID, 2993 IA_CSS_PER_FRAME_PARAMETER_SET_QUEUE_ID, 2994 SH_CSS_INVALID_QUEUE_ID 2995 }; 2996 2997 IA_CSS_ENTER_PRIVATE("void"); 2998 2999 if (!sh_css_sp_is_running()) { 3000 IA_CSS_LEAVE_PRIVATE("sp is not running"); 3001 /* SP is not running. The queues are not valid */ 3002 return; 3003 } 3004 3005 for (i = 0; SH_CSS_INVALID_QUEUE_ID != param_queue_ids[i]; i++) { 3006 cpy = (ia_css_ptr)0; 3007 /* clean-up old copy */ 3008 while (ia_css_bufq_dequeue_buffer(param_queue_ids[i], 3009 (uint32_t *)&cpy) == 0) { 3010 /* TMP: keep track of dequeued param set count 3011 */ 3012 g_param_buffer_dequeue_count++; 3013 ia_css_bufq_enqueue_psys_event( 3014 IA_CSS_PSYS_SW_EVENT_BUFFER_DEQUEUED, 3015 0, 3016 param_queue_ids[i], 3017 0); 3018 3019 IA_CSS_LOG("dequeued param set %x from %d, release ref", cpy, 0); 3020 free_ia_css_isp_parameter_set_info(cpy); 3021 cpy = (ia_css_ptr)0; 3022 } 3023 } 3024 3025 IA_CSS_LEAVE_PRIVATE("void"); 3026} 3027 3028static void 3029process_kernel_parameters(unsigned int pipe_id, 3030 struct ia_css_pipeline_stage *stage, 3031 struct ia_css_isp_parameters *params, 3032 unsigned int isp_pipe_version, 3033 unsigned int raw_bit_depth) 3034{ 3035 unsigned int param_id; 3036 3037 (void)isp_pipe_version; 3038 (void)raw_bit_depth; 3039 3040 sh_css_enable_pipeline(stage->binary); 3041 3042 if (params->config_changed[IA_CSS_OB_ID]) { 3043 ia_css_ob_configure(¶ms->stream_configs.ob, 3044 isp_pipe_version, raw_bit_depth); 3045 } 3046 if (params->config_changed[IA_CSS_S3A_ID]) { 3047 ia_css_s3a_configure(raw_bit_depth); 3048 } 3049 /* Copy stage uds parameters to config, since they can differ per stage. 3050 */ 3051 params->crop_config.crop_pos = params->uds[stage->stage_num].crop_pos; 3052 params->uds_config.crop_pos = params->uds[stage->stage_num].crop_pos; 3053 params->uds_config.uds = params->uds[stage->stage_num].uds; 3054 /* Call parameter process functions for all kernels */ 3055 /* Skip SC, since that is called on a temp sc table */ 3056 for (param_id = 0; param_id < IA_CSS_NUM_PARAMETER_IDS; param_id++) { 3057 if (param_id == IA_CSS_SC_ID) continue; 3058 if (params->config_changed[param_id]) 3059 ia_css_kernel_process_param[param_id](pipe_id, stage, params); 3060 } 3061} 3062 3063int 3064sh_css_param_update_isp_params(struct ia_css_pipe *curr_pipe, 3065 struct ia_css_isp_parameters *params, 3066 bool commit, 3067 struct ia_css_pipe *pipe_in) 3068{ 3069 int err = 0; 3070 ia_css_ptr cpy; 3071 int i; 3072 unsigned int raw_bit_depth = 10; 3073 unsigned int isp_pipe_version = SH_CSS_ISP_PIPE_VERSION_1; 3074 bool acc_cluster_params_changed = false; 3075 unsigned int thread_id, pipe_num; 3076 3077 (void)acc_cluster_params_changed; 3078 3079 assert(curr_pipe); 3080 3081 IA_CSS_ENTER_PRIVATE("pipe=%p, isp_parameters_id=%d", pipe_in, params->isp_parameters_id); 3082 raw_bit_depth = ia_css_stream_input_format_bits_per_pixel(curr_pipe->stream); 3083 3084 /* now make the map available to the sp */ 3085 if (!commit) { 3086 IA_CSS_LEAVE_ERR_PRIVATE(err); 3087 return err; 3088 } 3089 /* enqueue a copies of the mem_map to 3090 the designated pipelines */ 3091 for (i = 0; i < curr_pipe->stream->num_pipes; i++) { 3092 struct ia_css_pipe *pipe; 3093 struct sh_css_ddr_address_map *cur_map; 3094 struct sh_css_ddr_address_map_size *cur_map_size; 3095 struct ia_css_isp_parameter_set_info isp_params_info; 3096 struct ia_css_pipeline *pipeline; 3097 struct ia_css_pipeline_stage *stage; 3098 3099 enum sh_css_queue_id queue_id; 3100 3101 pipe = curr_pipe->stream->pipes[i]; 3102 pipeline = ia_css_pipe_get_pipeline(pipe); 3103 pipe_num = ia_css_pipe_get_pipe_num(pipe); 3104 isp_pipe_version = ia_css_pipe_get_isp_pipe_version(pipe); 3105 ia_css_pipeline_get_sp_thread_id(pipe_num, &thread_id); 3106 3107 ia_css_query_internal_queue_id(params->output_frame 3108 ? IA_CSS_BUFFER_TYPE_PER_FRAME_PARAMETER_SET 3109 : IA_CSS_BUFFER_TYPE_PARAMETER_SET, 3110 thread_id, &queue_id); 3111 if (!sh_css_sp_is_running()) { 3112 /* SP is not running. The queues are not valid */ 3113 err = -EBUSY; 3114 break; 3115 } 3116 cur_map = ¶ms->pipe_ddr_ptrs[pipeline->pipe_id]; 3117 cur_map_size = ¶ms->pipe_ddr_ptrs_size[pipeline->pipe_id]; 3118 3119 /* TODO: Normally, zoom and motion parameters shouldn't 3120 * be part of "isp_params" as it is resolution/pipe dependent 3121 * Therefore, move the zoom config elsewhere (e.g. shading 3122 * table can be taken as an example! @GC 3123 * */ 3124 { 3125 /* we have to do this per pipeline because */ 3126 /* the processing is a.o. resolution dependent */ 3127 err = ia_css_process_zoom_and_motion(params, 3128 pipeline->stages); 3129 if (err) 3130 return err; 3131 } 3132 /* check if to actually update the parameters for this pipe */ 3133 /* When API change is implemented making good distinction between 3134 * stream config and pipe config this skipping code can be moved out of the #ifdef */ 3135 if (pipe_in && (pipe != pipe_in)) { 3136 IA_CSS_LOG("skipping pipe %p", pipe); 3137 continue; 3138 } 3139 3140 /* BZ 125915, should be moved till after "update other buff" */ 3141 /* update the other buffers to the pipe specific copies */ 3142 for (stage = pipeline->stages; stage; stage = stage->next) { 3143 unsigned int mem; 3144 3145 if (!stage || !stage->binary) 3146 continue; 3147 3148 process_kernel_parameters(pipeline->pipe_id, 3149 stage, params, 3150 isp_pipe_version, raw_bit_depth); 3151 3152 err = sh_css_params_write_to_ddr_internal( 3153 pipe, 3154 pipeline->pipe_id, 3155 params, 3156 stage, 3157 cur_map, 3158 cur_map_size); 3159 3160 if (err) 3161 break; 3162 for (mem = 0; mem < IA_CSS_NUM_MEMORIES; mem++) { 3163 params->isp_mem_params_changed 3164 [pipeline->pipe_id][stage->stage_num][mem] = false; 3165 } 3166 } /* for */ 3167 if (err) 3168 break; 3169 /* update isp_params to pipe specific copies */ 3170 if (params->isp_params_changed) { 3171 reallocate_buffer(&cur_map->isp_param, 3172 &cur_map_size->isp_param, 3173 cur_map_size->isp_param, 3174 true, 3175 &err); 3176 if (err) 3177 break; 3178 sh_css_update_isp_params_to_ddr(params, cur_map->isp_param); 3179 } 3180 3181 /* last make referenced copy */ 3182 err = ref_sh_css_ddr_address_map( 3183 cur_map, 3184 &isp_params_info.mem_map); 3185 if (err) 3186 break; 3187 3188 /* Update Parameters ID */ 3189 isp_params_info.isp_parameters_id = params->isp_parameters_id; 3190 3191 /* Update output frame pointer */ 3192 isp_params_info.output_frame_ptr = 3193 (params->output_frame) ? params->output_frame->data : mmgr_NULL; 3194 3195 /* now write the copy to ddr */ 3196 err = write_ia_css_isp_parameter_set_info_to_ddr(&isp_params_info, &cpy); 3197 if (err) 3198 break; 3199 3200 /* enqueue the set to sp */ 3201 IA_CSS_LOG("queue param set %x to %d", cpy, thread_id); 3202 3203 err = ia_css_bufq_enqueue_buffer(thread_id, queue_id, (uint32_t)cpy); 3204 if (err) { 3205 free_ia_css_isp_parameter_set_info(cpy); 3206 IA_CSS_LOG("pfp: FAILED to add config id %d for OF %d to q %d on thread %d", 3207 isp_params_info.isp_parameters_id, 3208 isp_params_info.output_frame_ptr, 3209 queue_id, thread_id); 3210 break; 3211 } else { 3212 /* TMP: check discrepancy between nr of enqueued 3213 * parameter sets and dequeued sets 3214 */ 3215 g_param_buffer_enqueue_count++; 3216 assert(g_param_buffer_enqueue_count < g_param_buffer_dequeue_count + 50); 3217 /* 3218 * Tell the SP which queues are not empty, 3219 * by sending the software event. 3220 */ 3221 if (!sh_css_sp_is_running()) { 3222 /* SP is not running. The queues are not valid */ 3223 IA_CSS_LEAVE_ERR_PRIVATE(-EBUSY); 3224 return -EBUSY; 3225 } 3226 ia_css_bufq_enqueue_psys_event( 3227 IA_CSS_PSYS_SW_EVENT_BUFFER_ENQUEUED, 3228 (uint8_t)thread_id, 3229 (uint8_t)queue_id, 3230 0); 3231 IA_CSS_LOG("pfp: added config id %d for OF %d to q %d on thread %d", 3232 isp_params_info.isp_parameters_id, 3233 isp_params_info.output_frame_ptr, 3234 queue_id, thread_id); 3235 } 3236 /* clean-up old copy */ 3237 ia_css_dequeue_param_buffers(/*pipe_num*/); 3238 params->pipe_dvs_6axis_config_changed[pipeline->pipe_id] = false; 3239 } /* end for each 'active' pipeline */ 3240 /* clear the changed flags after all params 3241 for all pipelines have been updated */ 3242 params->isp_params_changed = false; 3243 params->sc_table_changed = false; 3244 params->dis_coef_table_changed = false; 3245 params->dvs2_coef_table_changed = false; 3246 params->morph_table_changed = false; 3247 params->dz_config_changed = false; 3248 params->motion_config_changed = false; 3249 /* ------ deprecated(bz675) : from ------ */ 3250 params->shading_settings_changed = false; 3251 /* ------ deprecated(bz675) : to ------ */ 3252 3253 memset(¶ms->config_changed[0], 0, sizeof(params->config_changed)); 3254 3255 IA_CSS_LEAVE_ERR_PRIVATE(err); 3256 return err; 3257} 3258 3259static int 3260sh_css_params_write_to_ddr_internal( 3261 struct ia_css_pipe *pipe, 3262 unsigned int pipe_id, 3263 struct ia_css_isp_parameters *params, 3264 const struct ia_css_pipeline_stage *stage, 3265 struct sh_css_ddr_address_map *ddr_map, 3266 struct sh_css_ddr_address_map_size *ddr_map_size) 3267{ 3268 int err; 3269 const struct ia_css_binary *binary; 3270 3271 unsigned int stage_num; 3272 unsigned int mem; 3273 bool buff_realloced; 3274 3275 /* struct is > 128 bytes so it should not be on stack (see checkpatch) */ 3276 static struct ia_css_macc_table converted_macc_table; 3277 3278 IA_CSS_ENTER_PRIVATE("void"); 3279 assert(params); 3280 assert(ddr_map); 3281 assert(ddr_map_size); 3282 assert(stage); 3283 3284 binary = stage->binary; 3285 assert(binary); 3286 3287 stage_num = stage->stage_num; 3288 3289 if (binary->info->sp.enable.fpnr) { 3290 buff_realloced = reallocate_buffer(&ddr_map->fpn_tbl, 3291 &ddr_map_size->fpn_tbl, 3292 fpntbl_bytes(binary), 3293 params->config_changed[IA_CSS_FPN_ID], 3294 &err); 3295 if (err) { 3296 IA_CSS_LEAVE_ERR_PRIVATE(err); 3297 return err; 3298 } 3299 if (params->config_changed[IA_CSS_FPN_ID] || buff_realloced) { 3300 if (params->fpn_config.enabled) { 3301 err = store_fpntbl(params, ddr_map->fpn_tbl); 3302 if (err) { 3303 IA_CSS_LEAVE_ERR_PRIVATE(err); 3304 return err; 3305 } 3306 } 3307 } 3308 } 3309 3310 if (binary->info->sp.enable.sc) { 3311 u32 enable_conv; 3312 3313 enable_conv = params->shading_settings.enable_shading_table_conversion; 3314 3315 buff_realloced = reallocate_buffer(&ddr_map->sc_tbl, 3316 &ddr_map_size->sc_tbl, 3317 sctbl_bytes(binary), 3318 params->sc_table_changed, 3319 &err); 3320 if (err) { 3321 IA_CSS_LEAVE_ERR_PRIVATE(err); 3322 return err; 3323 } 3324 3325 if (params->shading_settings_changed || 3326 params->sc_table_changed || buff_realloced) { 3327 if (enable_conv == 0) { 3328 if (params->sc_table) { 3329 /* store the shading table to ddr */ 3330 err = ia_css_params_store_sctbl(stage, ddr_map->sc_tbl, params->sc_table); 3331 if (err) { 3332 IA_CSS_LEAVE_ERR_PRIVATE(err); 3333 return err; 3334 } 3335 /* set sc_config to isp */ 3336 params->sc_config = (struct ia_css_shading_table *)params->sc_table; 3337 ia_css_kernel_process_param[IA_CSS_SC_ID](pipe_id, stage, params); 3338 params->sc_config = NULL; 3339 } else { 3340 /* generate the identical shading table */ 3341 if (params->sc_config) { 3342 ia_css_shading_table_free(params->sc_config); 3343 params->sc_config = NULL; 3344 } 3345 sh_css_params_shading_id_table_generate(¶ms->sc_config, 3346 binary->sctbl_width_per_color, 3347 binary->sctbl_height); 3348 if (!params->sc_config) { 3349 IA_CSS_LEAVE_ERR_PRIVATE(-ENOMEM); 3350 return -ENOMEM; 3351 } 3352 3353 /* store the shading table to ddr */ 3354 err = ia_css_params_store_sctbl(stage, ddr_map->sc_tbl, params->sc_config); 3355 if (err) { 3356 IA_CSS_LEAVE_ERR_PRIVATE(err); 3357 return err; 3358 } 3359 3360 /* set sc_config to isp */ 3361 ia_css_kernel_process_param[IA_CSS_SC_ID](pipe_id, stage, params); 3362 3363 /* free the shading table */ 3364 ia_css_shading_table_free(params->sc_config); 3365 params->sc_config = NULL; 3366 } 3367 } else { /* legacy */ 3368 /* ------ deprecated(bz675) : from ------ */ 3369 /* shading table is full resolution, reduce */ 3370 if (params->sc_config) { 3371 ia_css_shading_table_free(params->sc_config); 3372 params->sc_config = NULL; 3373 } 3374 prepare_shading_table( 3375 (const struct ia_css_shading_table *)params->sc_table, 3376 params->sensor_binning, 3377 ¶ms->sc_config, 3378 binary, pipe->required_bds_factor); 3379 if (!params->sc_config) { 3380 IA_CSS_LEAVE_ERR_PRIVATE(-ENOMEM); 3381 return -ENOMEM; 3382 } 3383 3384 /* store the shading table to ddr */ 3385 err = ia_css_params_store_sctbl(stage, ddr_map->sc_tbl, params->sc_config); 3386 if (err) { 3387 IA_CSS_LEAVE_ERR_PRIVATE(err); 3388 return err; 3389 } 3390 3391 /* set sc_config to isp */ 3392 ia_css_kernel_process_param[IA_CSS_SC_ID](pipe_id, stage, params); 3393 3394 /* free the shading table */ 3395 ia_css_shading_table_free(params->sc_config); 3396 params->sc_config = NULL; 3397 /* ------ deprecated(bz675) : to ------ */ 3398 } 3399 } 3400 } 3401 3402 if (params->config_changed[IA_CSS_MACC_ID] && binary->info->sp.enable.macc) { 3403 unsigned int i, j, idx; 3404 static const unsigned int idx_map[] = { 3405 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8 3406 }; 3407 3408 for (i = 0; i < IA_CSS_MACC_NUM_AXES; i++) { 3409 idx = 4 * idx_map[i]; 3410 j = 4 * i; 3411 3412 if (binary->info->sp.pipeline.isp_pipe_version == SH_CSS_ISP_PIPE_VERSION_1) { 3413 converted_macc_table.data[idx] = 3414 (int16_t)sDIGIT_FITTING(params->macc_table.data[j], 3415 13, SH_CSS_MACC_COEF_SHIFT); 3416 converted_macc_table.data[idx + 1] = 3417 (int16_t)sDIGIT_FITTING(params->macc_table.data[j + 1], 3418 13, SH_CSS_MACC_COEF_SHIFT); 3419 converted_macc_table.data[idx + 2] = 3420 (int16_t)sDIGIT_FITTING(params->macc_table.data[j + 2], 3421 13, SH_CSS_MACC_COEF_SHIFT); 3422 converted_macc_table.data[idx + 3] = 3423 (int16_t)sDIGIT_FITTING(params->macc_table.data[j + 3], 3424 13, SH_CSS_MACC_COEF_SHIFT); 3425 } else if (binary->info->sp.pipeline.isp_pipe_version == 3426 SH_CSS_ISP_PIPE_VERSION_2_2) { 3427 converted_macc_table.data[idx] = 3428 params->macc_table.data[j]; 3429 converted_macc_table.data[idx + 1] = 3430 params->macc_table.data[j + 1]; 3431 converted_macc_table.data[idx + 2] = 3432 params->macc_table.data[j + 2]; 3433 converted_macc_table.data[idx + 3] = 3434 params->macc_table.data[j + 3]; 3435 } 3436 } 3437 reallocate_buffer(&ddr_map->macc_tbl, 3438 &ddr_map_size->macc_tbl, 3439 ddr_map_size->macc_tbl, 3440 true, 3441 &err); 3442 if (err) { 3443 IA_CSS_LEAVE_ERR_PRIVATE(err); 3444 return err; 3445 } 3446 hmm_store(ddr_map->macc_tbl, 3447 converted_macc_table.data, 3448 sizeof(converted_macc_table.data)); 3449 } 3450 3451 if (binary->info->sp.enable.dvs_6axis) { 3452 /* because UV is packed into the Y plane, calc total 3453 * YYU size = /2 gives size of UV-only, 3454 * total YYU size = UV-only * 3. 3455 */ 3456 buff_realloced = reallocate_buffer( 3457 &ddr_map->dvs_6axis_params_y, 3458 &ddr_map_size->dvs_6axis_params_y, 3459 (size_t)((DVS_6AXIS_BYTES(binary) / 2) * 3), 3460 params->pipe_dvs_6axis_config_changed[pipe_id], 3461 &err); 3462 if (err) { 3463 IA_CSS_LEAVE_ERR_PRIVATE(err); 3464 return err; 3465 } 3466 3467 if (params->pipe_dvs_6axis_config_changed[pipe_id] || buff_realloced) { 3468 const struct ia_css_frame_info *dvs_in_frame_info; 3469 3470 if (stage->args.delay_frames[0]) { 3471 /*When delay frames are present(as in case of video), 3472 they are used for dvs. Configure DVS using those params*/ 3473 dvs_in_frame_info = &stage->args.delay_frames[0]->frame_info; 3474 } else { 3475 /*Otherwise, use input frame to configure DVS*/ 3476 dvs_in_frame_info = &stage->args.in_frame->frame_info; 3477 } 3478 3479 /* Generate default DVS unity table on start up*/ 3480 if (!params->pipe_dvs_6axis_config[pipe_id]) { 3481 struct ia_css_resolution dvs_offset = {0}; 3482 3483 dvs_offset.width = (PIX_SHIFT_FILTER_RUN_IN_X + binary->dvs_envelope.width) / 2; 3484 dvs_offset.height = (PIX_SHIFT_FILTER_RUN_IN_Y + binary->dvs_envelope.height) / 2; 3485 3486 params->pipe_dvs_6axis_config[pipe_id] = 3487 generate_dvs_6axis_table(&binary->out_frame_info[0].res, &dvs_offset); 3488 if (!params->pipe_dvs_6axis_config[pipe_id]) { 3489 IA_CSS_LEAVE_ERR_PRIVATE(-ENOMEM); 3490 return -ENOMEM; 3491 } 3492 params->pipe_dvs_6axis_config_changed[pipe_id] = true; 3493 3494 store_dvs_6axis_config(params->pipe_dvs_6axis_config[pipe_id], 3495 binary, 3496 dvs_in_frame_info, 3497 ddr_map->dvs_6axis_params_y); 3498 params->isp_params_changed = true; 3499 } 3500 } 3501 } 3502 3503 if (binary->info->sp.enable.ca_gdc) { 3504 unsigned int i; 3505 ia_css_ptr *virt_addr_tetra_x[ 3506 3507 IA_CSS_MORPH_TABLE_NUM_PLANES]; 3508 size_t *virt_size_tetra_x[ 3509 3510 IA_CSS_MORPH_TABLE_NUM_PLANES]; 3511 ia_css_ptr *virt_addr_tetra_y[ 3512 3513 IA_CSS_MORPH_TABLE_NUM_PLANES]; 3514 size_t *virt_size_tetra_y[ 3515 3516 IA_CSS_MORPH_TABLE_NUM_PLANES]; 3517 3518 virt_addr_tetra_x[0] = &ddr_map->tetra_r_x; 3519 virt_addr_tetra_x[1] = &ddr_map->tetra_gr_x; 3520 virt_addr_tetra_x[2] = &ddr_map->tetra_gb_x; 3521 virt_addr_tetra_x[3] = &ddr_map->tetra_b_x; 3522 virt_addr_tetra_x[4] = &ddr_map->tetra_ratb_x; 3523 virt_addr_tetra_x[5] = &ddr_map->tetra_batr_x; 3524 3525 virt_size_tetra_x[0] = &ddr_map_size->tetra_r_x; 3526 virt_size_tetra_x[1] = &ddr_map_size->tetra_gr_x; 3527 virt_size_tetra_x[2] = &ddr_map_size->tetra_gb_x; 3528 virt_size_tetra_x[3] = &ddr_map_size->tetra_b_x; 3529 virt_size_tetra_x[4] = &ddr_map_size->tetra_ratb_x; 3530 virt_size_tetra_x[5] = &ddr_map_size->tetra_batr_x; 3531 3532 virt_addr_tetra_y[0] = &ddr_map->tetra_r_y; 3533 virt_addr_tetra_y[1] = &ddr_map->tetra_gr_y; 3534 virt_addr_tetra_y[2] = &ddr_map->tetra_gb_y; 3535 virt_addr_tetra_y[3] = &ddr_map->tetra_b_y; 3536 virt_addr_tetra_y[4] = &ddr_map->tetra_ratb_y; 3537 virt_addr_tetra_y[5] = &ddr_map->tetra_batr_y; 3538 3539 virt_size_tetra_y[0] = &ddr_map_size->tetra_r_y; 3540 virt_size_tetra_y[1] = &ddr_map_size->tetra_gr_y; 3541 virt_size_tetra_y[2] = &ddr_map_size->tetra_gb_y; 3542 virt_size_tetra_y[3] = &ddr_map_size->tetra_b_y; 3543 virt_size_tetra_y[4] = &ddr_map_size->tetra_ratb_y; 3544 virt_size_tetra_y[5] = &ddr_map_size->tetra_batr_y; 3545 3546 buff_realloced = false; 3547 for (i = 0; i < IA_CSS_MORPH_TABLE_NUM_PLANES; i++) { 3548 buff_realloced |= 3549 reallocate_buffer(virt_addr_tetra_x[i], 3550 virt_size_tetra_x[i], 3551 morph_plane_bytes(binary), 3552 params->morph_table_changed, 3553 &err); 3554 if (err) { 3555 IA_CSS_LEAVE_ERR_PRIVATE(err); 3556 return err; 3557 } 3558 buff_realloced |= 3559 reallocate_buffer(virt_addr_tetra_y[i], 3560 virt_size_tetra_y[i], 3561 morph_plane_bytes(binary), 3562 params->morph_table_changed, 3563 &err); 3564 if (err) { 3565 IA_CSS_LEAVE_ERR_PRIVATE(err); 3566 return err; 3567 } 3568 } 3569 if (params->morph_table_changed || buff_realloced) { 3570 const struct ia_css_morph_table *table = params->morph_table; 3571 struct ia_css_morph_table *id_table = NULL; 3572 3573 if ((table) && 3574 (table->width < binary->morph_tbl_width || 3575 table->height < binary->morph_tbl_height)) { 3576 table = NULL; 3577 } 3578 if (!table) { 3579 err = sh_css_params_default_morph_table(&id_table, 3580 binary); 3581 if (err) { 3582 IA_CSS_LEAVE_ERR_PRIVATE(err); 3583 return err; 3584 } 3585 table = id_table; 3586 } 3587 3588 for (i = 0; i < IA_CSS_MORPH_TABLE_NUM_PLANES; i++) { 3589 store_morph_plane(table->coordinates_x[i], 3590 table->width, 3591 table->height, 3592 *virt_addr_tetra_x[i], 3593 binary->morph_tbl_aligned_width); 3594 store_morph_plane(table->coordinates_y[i], 3595 table->width, 3596 table->height, 3597 *virt_addr_tetra_y[i], 3598 binary->morph_tbl_aligned_width); 3599 } 3600 if (id_table) 3601 ia_css_morph_table_free(id_table); 3602 } 3603 } 3604 3605 /* After special cases like SC, FPN since they may change parameters */ 3606 for (mem = 0; mem < N_IA_CSS_MEMORIES; mem++) { 3607 const struct ia_css_isp_data *isp_data = 3608 ia_css_isp_param_get_isp_mem_init(&binary->info->sp.mem_initializers, 3609 IA_CSS_PARAM_CLASS_PARAM, mem); 3610 size_t size = isp_data->size; 3611 3612 if (!size) continue; 3613 buff_realloced = reallocate_buffer(&ddr_map->isp_mem_param[stage_num][mem], 3614 &ddr_map_size->isp_mem_param[stage_num][mem], 3615 size, 3616 params->isp_mem_params_changed[pipe_id][stage_num][mem], 3617 &err); 3618 if (err) { 3619 IA_CSS_LEAVE_ERR_PRIVATE(err); 3620 return err; 3621 } 3622 if (params->isp_mem_params_changed[pipe_id][stage_num][mem] || buff_realloced) { 3623 sh_css_update_isp_mem_params_to_ddr(binary, 3624 ddr_map->isp_mem_param[stage_num][mem], 3625 ddr_map_size->isp_mem_param[stage_num][mem], mem); 3626 } 3627 } 3628 3629 IA_CSS_LEAVE_ERR_PRIVATE(0); 3630 return 0; 3631} 3632 3633const struct ia_css_fpn_table *ia_css_get_fpn_table(struct ia_css_stream 3634 *stream) 3635{ 3636 struct ia_css_isp_parameters *params; 3637 3638 IA_CSS_ENTER_LEAVE("void"); 3639 assert(stream); 3640 3641 params = stream->isp_params_configs; 3642 3643 return ¶ms->fpn_config; 3644} 3645 3646struct ia_css_shading_table *ia_css_get_shading_table(struct ia_css_stream 3647 *stream) 3648{ 3649 struct ia_css_shading_table *table = NULL; 3650 struct ia_css_isp_parameters *params; 3651 3652 IA_CSS_ENTER("void"); 3653 3654 assert(stream); 3655 3656 params = stream->isp_params_configs; 3657 if (!params) 3658 return NULL; 3659 3660 if (params->shading_settings.enable_shading_table_conversion == 0) { 3661 if (params->sc_table) { 3662 table = (struct ia_css_shading_table *)params->sc_table; 3663 } else { 3664 const struct ia_css_binary *binary 3665 = ia_css_stream_get_shading_correction_binary(stream); 3666 if (binary) { 3667 /* generate the identical shading table */ 3668 if (params->sc_config) { 3669 ia_css_shading_table_free(params->sc_config); 3670 params->sc_config = NULL; 3671 } 3672 sh_css_params_shading_id_table_generate(¶ms->sc_config, 3673 binary->sctbl_width_per_color, 3674 binary->sctbl_height); 3675 table = params->sc_config; 3676 /* The sc_config will be freed in the 3677 * ia_css_stream_isp_parameters_uninit function. */ 3678 } 3679 } 3680 } else { 3681 /* ------ deprecated(bz675) : from ------ */ 3682 const struct ia_css_binary *binary 3683 = ia_css_stream_get_shading_correction_binary(stream); 3684 struct ia_css_pipe *pipe; 3685 3686 /**********************************************************************/ 3687 /* following code is copied from function ia_css_stream_get_shading_correction_binary() 3688 * to match with the binary */ 3689 pipe = stream->pipes[0]; 3690 3691 if (stream->num_pipes == 2) { 3692 assert(stream->pipes[1]); 3693 if (stream->pipes[1]->config.mode == IA_CSS_PIPE_MODE_VIDEO || 3694 stream->pipes[1]->config.mode == IA_CSS_PIPE_MODE_PREVIEW) 3695 pipe = stream->pipes[1]; 3696 } 3697 /**********************************************************************/ 3698 if (binary) { 3699 if (params->sc_config) { 3700 ia_css_shading_table_free(params->sc_config); 3701 params->sc_config = NULL; 3702 } 3703 prepare_shading_table( 3704 (const struct ia_css_shading_table *)params->sc_table, 3705 params->sensor_binning, 3706 ¶ms->sc_config, 3707 binary, pipe->required_bds_factor); 3708 3709 table = params->sc_config; 3710 /* The sc_config will be freed in the 3711 * ia_css_stream_isp_parameters_uninit function. */ 3712 } 3713 /* ------ deprecated(bz675) : to ------ */ 3714 } 3715 3716 IA_CSS_LEAVE("table=%p", table); 3717 3718 return table; 3719} 3720 3721ia_css_ptr sh_css_store_sp_group_to_ddr(void) 3722{ 3723 u8 *write_buf; 3724 u8 *buf_ptr; 3725 3726 IA_CSS_ENTER_LEAVE_PRIVATE("void"); 3727 3728 write_buf = kzalloc(sizeof(u8) * 8192, GFP_KERNEL); 3729 if (!write_buf) 3730 return 0; 3731 3732 buf_ptr = write_buf; 3733 if (IS_ISP2401) { 3734 memcpy(buf_ptr, &sh_css_sp_group.config, 3); 3735 buf_ptr += 3; 3736 *buf_ptr++ = sh_css_sp_group.config.enable_isys_event_queue; 3737 *buf_ptr++ = sh_css_sp_group.config.disable_cont_vf; 3738 memset(buf_ptr, 0, 3); 3739 buf_ptr += 3; /* Padding 3 bytes for struct sh_css_sp_config*/ 3740 } else { 3741 memcpy(buf_ptr, &sh_css_sp_group.config, sizeof(sh_css_sp_group.config)); 3742 buf_ptr += sizeof(sh_css_sp_group.config); 3743 } 3744 3745 memcpy(buf_ptr, &sh_css_sp_group.pipe, sizeof(sh_css_sp_group.pipe)); 3746 buf_ptr += sizeof(sh_css_sp_group.pipe); 3747 3748 if (IS_ISP2401) { 3749 memcpy(buf_ptr, &sh_css_sp_group.pipe_io, sizeof(sh_css_sp_group.pipe_io)); 3750 buf_ptr += sizeof(sh_css_sp_group.pipe_io); 3751 memcpy(buf_ptr, &sh_css_sp_group.pipe_io_status, 3752 sizeof(sh_css_sp_group.pipe_io_status)); 3753 buf_ptr += sizeof(sh_css_sp_group.pipe_io_status); 3754 } 3755 3756 memcpy(buf_ptr, &sh_css_sp_group.debug, sizeof(sh_css_sp_group.debug)); 3757 buf_ptr += sizeof(sh_css_sp_group.debug); 3758 3759 hmm_store(xmem_sp_group_ptrs, 3760 write_buf, 3761 buf_ptr - write_buf); 3762 3763 kfree(write_buf); 3764 return xmem_sp_group_ptrs; 3765} 3766 3767ia_css_ptr sh_css_store_sp_stage_to_ddr( 3768 unsigned int pipe, 3769 unsigned int stage) 3770{ 3771 IA_CSS_ENTER_LEAVE_PRIVATE("void"); 3772 hmm_store(xmem_sp_stage_ptrs[pipe][stage], 3773 &sh_css_sp_stage, 3774 sizeof(struct sh_css_sp_stage)); 3775 return xmem_sp_stage_ptrs[pipe][stage]; 3776} 3777 3778ia_css_ptr sh_css_store_isp_stage_to_ddr( 3779 unsigned int pipe, 3780 unsigned int stage) 3781{ 3782 IA_CSS_ENTER_LEAVE_PRIVATE("void"); 3783 hmm_store(xmem_isp_stage_ptrs[pipe][stage], 3784 &sh_css_isp_stage, 3785 sizeof(struct sh_css_isp_stage)); 3786 return xmem_isp_stage_ptrs[pipe][stage]; 3787} 3788 3789static int ref_sh_css_ddr_address_map( 3790 struct sh_css_ddr_address_map *map, 3791 struct sh_css_ddr_address_map *out) 3792{ 3793 int err = 0; 3794 unsigned int i; 3795 3796 /* we will use a union to copy things; overlaying an array 3797 with the struct; that way adding fields in the struct 3798 will keep things working, and we will not get type errors. 3799 */ 3800 union { 3801 struct sh_css_ddr_address_map *map; 3802 ia_css_ptr *addrs; 3803 } in_addrs, to_addrs; 3804 3805 IA_CSS_ENTER_PRIVATE("void"); 3806 assert(map); 3807 assert(out); 3808 3809 in_addrs.map = map; 3810 to_addrs.map = out; 3811 3812 assert(sizeof(struct sh_css_ddr_address_map_size) / sizeof(size_t) == 3813 sizeof(struct sh_css_ddr_address_map) / sizeof(ia_css_ptr)); 3814 3815 /* copy map using size info */ 3816 for (i = 0; i < (sizeof(struct sh_css_ddr_address_map_size) / 3817 sizeof(size_t)); i++) { 3818 if (in_addrs.addrs[i] == mmgr_NULL) 3819 to_addrs.addrs[i] = mmgr_NULL; 3820 else 3821 to_addrs.addrs[i] = ia_css_refcount_increment(IA_CSS_REFCOUNT_PARAM_BUFFER, 3822 in_addrs.addrs[i]); 3823 } 3824 3825 IA_CSS_LEAVE_ERR_PRIVATE(err); 3826 return err; 3827} 3828 3829static int write_ia_css_isp_parameter_set_info_to_ddr( 3830 struct ia_css_isp_parameter_set_info *me, 3831 ia_css_ptr *out) 3832{ 3833 int err = 0; 3834 bool succ; 3835 3836 IA_CSS_ENTER_PRIVATE("void"); 3837 3838 assert(me); 3839 assert(out); 3840 3841 *out = ia_css_refcount_increment(IA_CSS_REFCOUNT_PARAM_SET_POOL, 3842 hmm_alloc(sizeof(struct ia_css_isp_parameter_set_info))); 3843 succ = (*out != mmgr_NULL); 3844 if (succ) 3845 hmm_store(*out, 3846 me, sizeof(struct ia_css_isp_parameter_set_info)); 3847 else 3848 err = -ENOMEM; 3849 3850 IA_CSS_LEAVE_ERR_PRIVATE(err); 3851 return err; 3852} 3853 3854static int 3855free_ia_css_isp_parameter_set_info( 3856 ia_css_ptr ptr) 3857{ 3858 int err = 0; 3859 struct ia_css_isp_parameter_set_info isp_params_info; 3860 unsigned int i; 3861 ia_css_ptr *addrs = (ia_css_ptr *)&isp_params_info.mem_map; 3862 3863 IA_CSS_ENTER_PRIVATE("ptr = %u", ptr); 3864 3865 /* sanity check - ptr must be valid */ 3866 if (!ia_css_refcount_is_valid(ptr)) { 3867 IA_CSS_ERROR("%s: IA_CSS_REFCOUNT_PARAM_SET_POOL(0x%x) invalid arg", __func__, 3868 ptr); 3869 err = -EINVAL; 3870 IA_CSS_LEAVE_ERR_PRIVATE(err); 3871 return err; 3872 } 3873 3874 hmm_load(ptr, &isp_params_info.mem_map, sizeof(struct sh_css_ddr_address_map)); 3875 /* copy map using size info */ 3876 for (i = 0; i < (sizeof(struct sh_css_ddr_address_map_size) / 3877 sizeof(size_t)); i++) { 3878 if (addrs[i] == mmgr_NULL) 3879 continue; 3880 3881 /* sanity check - ptr must be valid */ 3882 if (!ia_css_refcount_is_valid(addrs[i])) { 3883 IA_CSS_ERROR("%s: IA_CSS_REFCOUNT_PARAM_BUFFER(0x%x) invalid arg", __func__, 3884 ptr); 3885 err = -EINVAL; 3886 continue; 3887 } 3888 3889 ia_css_refcount_decrement(IA_CSS_REFCOUNT_PARAM_BUFFER, addrs[i]); 3890 } 3891 ia_css_refcount_decrement(IA_CSS_REFCOUNT_PARAM_SET_POOL, ptr); 3892 3893 IA_CSS_LEAVE_ERR_PRIVATE(err); 3894 return err; 3895} 3896 3897/* Mark all parameters as changed to force recomputing the derived ISP parameters */ 3898void 3899sh_css_invalidate_params(struct ia_css_stream *stream) 3900{ 3901 struct ia_css_isp_parameters *params; 3902 unsigned int i, j, mem; 3903 3904 IA_CSS_ENTER_PRIVATE("void"); 3905 assert(stream); 3906 3907 params = stream->isp_params_configs; 3908 params->isp_params_changed = true; 3909 for (i = 0; i < IA_CSS_PIPE_ID_NUM; i++) { 3910 for (j = 0; j < SH_CSS_MAX_STAGES; j++) { 3911 for (mem = 0; mem < N_IA_CSS_MEMORIES; mem++) { 3912 params->isp_mem_params_changed[i][j][mem] = true; 3913 } 3914 } 3915 } 3916 3917 memset(¶ms->config_changed[0], 1, sizeof(params->config_changed)); 3918 params->dis_coef_table_changed = true; 3919 params->dvs2_coef_table_changed = true; 3920 params->morph_table_changed = true; 3921 params->sc_table_changed = true; 3922 params->dz_config_changed = true; 3923 params->motion_config_changed = true; 3924 3925 /*Free up theDVS table memory blocks before recomputing new table */ 3926 for (i = 0; i < IA_CSS_PIPE_ID_NUM; i++) { 3927 if (params->pipe_dvs_6axis_config[i]) { 3928 free_dvs_6axis_table(¶ms->pipe_dvs_6axis_config[i]); 3929 params->pipe_dvs_6axis_config_changed[i] = true; 3930 } 3931 } 3932 3933 IA_CSS_LEAVE_PRIVATE("void"); 3934} 3935 3936void 3937sh_css_update_uds_and_crop_info( 3938 const struct ia_css_binary_info *info, 3939 const struct ia_css_frame_info *in_frame_info, 3940 const struct ia_css_frame_info *out_frame_info, 3941 const struct ia_css_resolution *dvs_env, 3942 const struct ia_css_dz_config *zoom, 3943 const struct ia_css_vector *motion_vector, 3944 struct sh_css_uds_info *uds, /* out */ 3945 struct sh_css_crop_pos *sp_out_crop_pos, /* out */ 3946 3947 bool enable_zoom) 3948{ 3949 IA_CSS_ENTER_PRIVATE("void"); 3950 3951 assert(info); 3952 assert(in_frame_info); 3953 assert(out_frame_info); 3954 assert(dvs_env); 3955 assert(zoom); 3956 assert(motion_vector); 3957 assert(uds); 3958 assert(sp_out_crop_pos); 3959 3960 uds->curr_dx = enable_zoom ? (uint16_t)zoom->dx : HRT_GDC_N; 3961 uds->curr_dy = enable_zoom ? (uint16_t)zoom->dy : HRT_GDC_N; 3962 3963 if (info->enable.dvs_envelope) { 3964 unsigned int crop_x = 0, 3965 crop_y = 0, 3966 uds_xc = 0, 3967 uds_yc = 0, 3968 env_width, env_height; 3969 int half_env_x, half_env_y; 3970 int motion_x = motion_vector->x; 3971 int motion_y = motion_vector->y; 3972 bool upscale_x = in_frame_info->res.width < out_frame_info->res.width; 3973 bool upscale_y = in_frame_info->res.height < out_frame_info->res.height; 3974 3975 if (info->enable.uds && !info->enable.ds) { 3976 /** 3977 * we calculate with the envelope that we can actually 3978 * use, the min dvs envelope is for the filter 3979 * initialization. 3980 */ 3981 env_width = dvs_env->width - 3982 SH_CSS_MIN_DVS_ENVELOPE; 3983 env_height = dvs_env->height - 3984 SH_CSS_MIN_DVS_ENVELOPE; 3985 half_env_x = env_width / 2; 3986 half_env_y = env_height / 2; 3987 /** 3988 * for digital zoom, we use the dvs envelope and make 3989 * sure that we don't include the 8 leftmost pixels or 3990 * 8 topmost rows. 3991 */ 3992 if (upscale_x) { 3993 uds_xc = (in_frame_info->res.width 3994 + env_width 3995 + SH_CSS_MIN_DVS_ENVELOPE) / 2; 3996 } else { 3997 uds_xc = (out_frame_info->res.width 3998 + env_width) / 2 3999 + SH_CSS_MIN_DVS_ENVELOPE; 4000 } 4001 if (upscale_y) { 4002 uds_yc = (in_frame_info->res.height 4003 + env_height 4004 + SH_CSS_MIN_DVS_ENVELOPE) / 2; 4005 } else { 4006 uds_yc = (out_frame_info->res.height 4007 + env_height) / 2 4008 + SH_CSS_MIN_DVS_ENVELOPE; 4009 } 4010 /* clip the motion vector to +/- half the envelope */ 4011 motion_x = clamp(motion_x, -half_env_x, half_env_x); 4012 motion_y = clamp(motion_y, -half_env_y, half_env_y); 4013 uds_xc += motion_x; 4014 uds_yc += motion_y; 4015 /* uds can be pipelined, remove top lines */ 4016 crop_y = 2; 4017 } else if (info->enable.ds) { 4018 env_width = dvs_env->width; 4019 env_height = dvs_env->height; 4020 half_env_x = env_width / 2; 4021 half_env_y = env_height / 2; 4022 /* clip the motion vector to +/- half the envelope */ 4023 motion_x = clamp(motion_x, -half_env_x, half_env_x); 4024 motion_y = clamp(motion_y, -half_env_y, half_env_y); 4025 /* for video with downscaling, the envelope is included 4026 in the input resolution. */ 4027 uds_xc = in_frame_info->res.width / 2 + motion_x; 4028 uds_yc = in_frame_info->res.height / 2 + motion_y; 4029 crop_x = info->pipeline.left_cropping; 4030 /* ds == 2 (yuv_ds) can be pipelined, remove top 4031 lines */ 4032 if (info->enable.ds & 1) 4033 crop_y = info->pipeline.top_cropping; 4034 else 4035 crop_y = 2; 4036 } else { 4037 /* video nodz: here we can only crop. We make sure we 4038 crop at least the first 8x8 pixels away. */ 4039 env_width = dvs_env->width - 4040 SH_CSS_MIN_DVS_ENVELOPE; 4041 env_height = dvs_env->height - 4042 SH_CSS_MIN_DVS_ENVELOPE; 4043 half_env_x = env_width / 2; 4044 half_env_y = env_height / 2; 4045 motion_x = clamp(motion_x, -half_env_x, half_env_x); 4046 motion_y = clamp(motion_y, -half_env_y, half_env_y); 4047 crop_x = SH_CSS_MIN_DVS_ENVELOPE 4048 + half_env_x + motion_x; 4049 crop_y = SH_CSS_MIN_DVS_ENVELOPE 4050 + half_env_y + motion_y; 4051 } 4052 4053 /* Must enforce that the crop position is even */ 4054 crop_x = EVEN_FLOOR(crop_x); 4055 crop_y = EVEN_FLOOR(crop_y); 4056 uds_xc = EVEN_FLOOR(uds_xc); 4057 uds_yc = EVEN_FLOOR(uds_yc); 4058 4059 uds->xc = (uint16_t)uds_xc; 4060 uds->yc = (uint16_t)uds_yc; 4061 sp_out_crop_pos->x = (uint16_t)crop_x; 4062 sp_out_crop_pos->y = (uint16_t)crop_y; 4063 } else { 4064 /* for down scaling, we always use the center of the image */ 4065 uds->xc = (uint16_t)in_frame_info->res.width / 2; 4066 uds->yc = (uint16_t)in_frame_info->res.height / 2; 4067 sp_out_crop_pos->x = (uint16_t)info->pipeline.left_cropping; 4068 sp_out_crop_pos->y = (uint16_t)info->pipeline.top_cropping; 4069 } 4070 IA_CSS_LEAVE_PRIVATE("void"); 4071} 4072 4073static int 4074sh_css_update_uds_and_crop_info_based_on_zoom_region( 4075 const struct ia_css_binary_info *info, 4076 const struct ia_css_frame_info *in_frame_info, 4077 const struct ia_css_frame_info *out_frame_info, 4078 const struct ia_css_resolution *dvs_env, 4079 const struct ia_css_dz_config *zoom, 4080 const struct ia_css_vector *motion_vector, 4081 struct sh_css_uds_info *uds, /* out */ 4082 struct sh_css_crop_pos *sp_out_crop_pos, /* out */ 4083 struct ia_css_resolution pipe_in_res, 4084 bool enable_zoom) 4085{ 4086 unsigned int x0 = 0, y0 = 0, x1 = 0, y1 = 0; 4087 int err = 0; 4088 /* Note: 4089 * Filter_Envelope = 0 for NND/LUT 4090 * Filter_Envelope = 1 for BCI 4091 * Filter_Envelope = 3 for BLI 4092 * Currently, not considering this filter envelope because, In uds.sp.c is recalculating 4093 * the dx/dy based on filter envelope and other information (ia_css_uds_sp_scale_params) 4094 * Ideally, That should be done on host side not on sp side. 4095 */ 4096 unsigned int filter_envelope = 0; 4097 4098 IA_CSS_ENTER_PRIVATE("void"); 4099 4100 assert(info); 4101 assert(in_frame_info); 4102 assert(out_frame_info); 4103 assert(dvs_env); 4104 assert(zoom); 4105 assert(motion_vector); 4106 assert(uds); 4107 assert(sp_out_crop_pos); 4108 x0 = zoom->zoom_region.origin.x; 4109 y0 = zoom->zoom_region.origin.y; 4110 x1 = zoom->zoom_region.resolution.width + x0; 4111 y1 = zoom->zoom_region.resolution.height + y0; 4112 4113 if ((x0 > x1) || (y0 > y1) || (x1 > pipe_in_res.width) || (y1 > pipe_in_res.height)) 4114 return -EINVAL; 4115 4116 if (!enable_zoom) { 4117 uds->curr_dx = HRT_GDC_N; 4118 uds->curr_dy = HRT_GDC_N; 4119 } 4120 4121 if (info->enable.dvs_envelope) { 4122 /* Zoom region is only supported by the UDS module on ISP 4123 * 2 and higher. It is not supported in video mode on ISP 1 */ 4124 return -EINVAL; 4125 } else { 4126 if (enable_zoom) { 4127 /* A. Calculate dx/dy based on crop region using in_frame_info 4128 * Scale the crop region if in_frame_info to the stage is not same as 4129 * actual effective input of the pipeline 4130 */ 4131 if (in_frame_info->res.width != pipe_in_res.width || 4132 in_frame_info->res.height != pipe_in_res.height) { 4133 x0 = (x0 * in_frame_info->res.width) / (pipe_in_res.width); 4134 y0 = (y0 * in_frame_info->res.height) / (pipe_in_res.height); 4135 x1 = (x1 * in_frame_info->res.width) / (pipe_in_res.width); 4136 y1 = (y1 * in_frame_info->res.height) / (pipe_in_res.height); 4137 } 4138 uds->curr_dx = 4139 ((x1 - x0 - filter_envelope) * HRT_GDC_N) / in_frame_info->res.width; 4140 uds->curr_dy = 4141 ((y1 - y0 - filter_envelope) * HRT_GDC_N) / in_frame_info->res.height; 4142 4143 /* B. Calculate xc/yc based on crop region */ 4144 uds->xc = (uint16_t)x0 + (((x1) - (x0)) / 2); 4145 uds->yc = (uint16_t)y0 + (((y1) - (y0)) / 2); 4146 } else { 4147 uds->xc = (uint16_t)in_frame_info->res.width / 2; 4148 uds->yc = (uint16_t)in_frame_info->res.height / 2; 4149 } 4150 4151 ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, 4152 "uds->curr_dx=%d, uds->xc=%d, uds->yc=%d\n", 4153 uds->curr_dx, uds->xc, uds->yc); 4154 ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "x0=%d, y0=%d, x1=%d, y1=%d\n", 4155 x0, y0, x1, y1); 4156 sp_out_crop_pos->x = (uint16_t)info->pipeline.left_cropping; 4157 sp_out_crop_pos->y = (uint16_t)info->pipeline.top_cropping; 4158 } 4159 IA_CSS_LEAVE_PRIVATE("void"); 4160 return err; 4161} 4162 4163struct ia_css_3a_statistics * 4164ia_css_3a_statistics_allocate(const struct ia_css_3a_grid_info *grid) 4165{ 4166 struct ia_css_3a_statistics *me; 4167 int grid_size; 4168 4169 IA_CSS_ENTER("grid=%p", grid); 4170 4171 assert(grid); 4172 4173 me = kvcalloc(1, sizeof(*me), GFP_KERNEL); 4174 if (!me) 4175 goto err; 4176 4177 me->grid = *grid; 4178 grid_size = grid->width * grid->height; 4179 me->data = kvmalloc(grid_size * sizeof(*me->data), GFP_KERNEL); 4180 if (!me->data) 4181 goto err; 4182 /* No weighted histogram, no structure, treat the histogram data as a byte dump in a byte array */ 4183 me->rgby_data = kvmalloc(sizeof_hmem(HMEM0_ID), GFP_KERNEL); 4184 4185 IA_CSS_LEAVE("return=%p", me); 4186 return me; 4187err: 4188 ia_css_3a_statistics_free(me); 4189 4190 IA_CSS_LEAVE("return=%p", NULL); 4191 return NULL; 4192} 4193 4194void 4195ia_css_3a_statistics_free(struct ia_css_3a_statistics *me) 4196{ 4197 if (me) { 4198 kvfree(me->rgby_data); 4199 kvfree(me->data); 4200 kvfree(me); 4201 } 4202} 4203 4204struct ia_css_dvs_statistics * 4205ia_css_dvs_statistics_allocate(const struct ia_css_dvs_grid_info *grid) 4206{ 4207 struct ia_css_dvs_statistics *me; 4208 4209 assert(grid); 4210 4211 me = kvcalloc(1, sizeof(*me), GFP_KERNEL); 4212 if (!me) 4213 goto err; 4214 4215 me->grid = *grid; 4216 me->hor_proj = kvmalloc(grid->height * IA_CSS_DVS_NUM_COEF_TYPES * 4217 sizeof(*me->hor_proj), GFP_KERNEL); 4218 if (!me->hor_proj) 4219 goto err; 4220 4221 me->ver_proj = kvmalloc(grid->width * IA_CSS_DVS_NUM_COEF_TYPES * 4222 sizeof(*me->ver_proj), GFP_KERNEL); 4223 if (!me->ver_proj) 4224 goto err; 4225 4226 return me; 4227err: 4228 ia_css_dvs_statistics_free(me); 4229 return NULL; 4230} 4231 4232void 4233ia_css_dvs_statistics_free(struct ia_css_dvs_statistics *me) 4234{ 4235 if (me) { 4236 kvfree(me->hor_proj); 4237 kvfree(me->ver_proj); 4238 kvfree(me); 4239 } 4240} 4241 4242struct ia_css_dvs_coefficients * 4243ia_css_dvs_coefficients_allocate(const struct ia_css_dvs_grid_info *grid) 4244{ 4245 struct ia_css_dvs_coefficients *me; 4246 4247 assert(grid); 4248 4249 me = kvcalloc(1, sizeof(*me), GFP_KERNEL); 4250 if (!me) 4251 goto err; 4252 4253 me->grid = *grid; 4254 4255 me->hor_coefs = kvmalloc(grid->num_hor_coefs * 4256 IA_CSS_DVS_NUM_COEF_TYPES * 4257 sizeof(*me->hor_coefs), GFP_KERNEL); 4258 if (!me->hor_coefs) 4259 goto err; 4260 4261 me->ver_coefs = kvmalloc(grid->num_ver_coefs * 4262 IA_CSS_DVS_NUM_COEF_TYPES * 4263 sizeof(*me->ver_coefs), GFP_KERNEL); 4264 if (!me->ver_coefs) 4265 goto err; 4266 4267 return me; 4268err: 4269 ia_css_dvs_coefficients_free(me); 4270 return NULL; 4271} 4272 4273void 4274ia_css_dvs_coefficients_free(struct ia_css_dvs_coefficients *me) 4275{ 4276 if (me) { 4277 kvfree(me->hor_coefs); 4278 kvfree(me->ver_coefs); 4279 kvfree(me); 4280 } 4281} 4282 4283struct ia_css_dvs2_statistics * 4284ia_css_dvs2_statistics_allocate(const struct ia_css_dvs_grid_info *grid) 4285{ 4286 struct ia_css_dvs2_statistics *me; 4287 4288 assert(grid); 4289 4290 me = kvcalloc(1, sizeof(*me), GFP_KERNEL); 4291 if (!me) 4292 goto err; 4293 4294 me->grid = *grid; 4295 4296 me->hor_prod.odd_real = kvmalloc(grid->aligned_width * 4297 grid->aligned_height * 4298 sizeof(*me->hor_prod.odd_real), 4299 GFP_KERNEL); 4300 if (!me->hor_prod.odd_real) 4301 goto err; 4302 4303 me->hor_prod.odd_imag = kvmalloc(grid->aligned_width * 4304 grid->aligned_height * 4305 sizeof(*me->hor_prod.odd_imag), 4306 GFP_KERNEL); 4307 if (!me->hor_prod.odd_imag) 4308 goto err; 4309 4310 me->hor_prod.even_real = kvmalloc(grid->aligned_width * 4311 grid->aligned_height * 4312 sizeof(*me->hor_prod.even_real), 4313 GFP_KERNEL); 4314 if (!me->hor_prod.even_real) 4315 goto err; 4316 4317 me->hor_prod.even_imag = kvmalloc(grid->aligned_width * 4318 grid->aligned_height * 4319 sizeof(*me->hor_prod.even_imag), 4320 GFP_KERNEL); 4321 if (!me->hor_prod.even_imag) 4322 goto err; 4323 4324 me->ver_prod.odd_real = kvmalloc(grid->aligned_width * 4325 grid->aligned_height * 4326 sizeof(*me->ver_prod.odd_real), 4327 GFP_KERNEL); 4328 if (!me->ver_prod.odd_real) 4329 goto err; 4330 4331 me->ver_prod.odd_imag = kvmalloc(grid->aligned_width * 4332 grid->aligned_height * 4333 sizeof(*me->ver_prod.odd_imag), 4334 GFP_KERNEL); 4335 if (!me->ver_prod.odd_imag) 4336 goto err; 4337 4338 me->ver_prod.even_real = kvmalloc(grid->aligned_width * 4339 grid->aligned_height * 4340 sizeof(*me->ver_prod.even_real), 4341 GFP_KERNEL); 4342 if (!me->ver_prod.even_real) 4343 goto err; 4344 4345 me->ver_prod.even_imag = kvmalloc(grid->aligned_width * 4346 grid->aligned_height * 4347 sizeof(*me->ver_prod.even_imag), 4348 GFP_KERNEL); 4349 if (!me->ver_prod.even_imag) 4350 goto err; 4351 4352 return me; 4353err: 4354 ia_css_dvs2_statistics_free(me); 4355 return NULL; 4356} 4357 4358void 4359ia_css_dvs2_statistics_free(struct ia_css_dvs2_statistics *me) 4360{ 4361 if (me) { 4362 kvfree(me->hor_prod.odd_real); 4363 kvfree(me->hor_prod.odd_imag); 4364 kvfree(me->hor_prod.even_real); 4365 kvfree(me->hor_prod.even_imag); 4366 kvfree(me->ver_prod.odd_real); 4367 kvfree(me->ver_prod.odd_imag); 4368 kvfree(me->ver_prod.even_real); 4369 kvfree(me->ver_prod.even_imag); 4370 kvfree(me); 4371 } 4372} 4373 4374struct ia_css_dvs2_coefficients * 4375ia_css_dvs2_coefficients_allocate(const struct ia_css_dvs_grid_info *grid) 4376{ 4377 struct ia_css_dvs2_coefficients *me; 4378 4379 assert(grid); 4380 4381 me = kvcalloc(1, sizeof(*me), GFP_KERNEL); 4382 if (!me) 4383 goto err; 4384 4385 me->grid = *grid; 4386 4387 me->hor_coefs.odd_real = kvmalloc(grid->num_hor_coefs * 4388 sizeof(*me->hor_coefs.odd_real), 4389 GFP_KERNEL); 4390 if (!me->hor_coefs.odd_real) 4391 goto err; 4392 4393 me->hor_coefs.odd_imag = kvmalloc(grid->num_hor_coefs * 4394 sizeof(*me->hor_coefs.odd_imag), 4395 GFP_KERNEL); 4396 if (!me->hor_coefs.odd_imag) 4397 goto err; 4398 4399 me->hor_coefs.even_real = kvmalloc(grid->num_hor_coefs * 4400 sizeof(*me->hor_coefs.even_real), 4401 GFP_KERNEL); 4402 if (!me->hor_coefs.even_real) 4403 goto err; 4404 4405 me->hor_coefs.even_imag = kvmalloc(grid->num_hor_coefs * 4406 sizeof(*me->hor_coefs.even_imag), 4407 GFP_KERNEL); 4408 if (!me->hor_coefs.even_imag) 4409 goto err; 4410 4411 me->ver_coefs.odd_real = kvmalloc(grid->num_ver_coefs * 4412 sizeof(*me->ver_coefs.odd_real), 4413 GFP_KERNEL); 4414 if (!me->ver_coefs.odd_real) 4415 goto err; 4416 4417 me->ver_coefs.odd_imag = kvmalloc(grid->num_ver_coefs * 4418 sizeof(*me->ver_coefs.odd_imag), 4419 GFP_KERNEL); 4420 if (!me->ver_coefs.odd_imag) 4421 goto err; 4422 4423 me->ver_coefs.even_real = kvmalloc(grid->num_ver_coefs * 4424 sizeof(*me->ver_coefs.even_real), 4425 GFP_KERNEL); 4426 if (!me->ver_coefs.even_real) 4427 goto err; 4428 4429 me->ver_coefs.even_imag = kvmalloc(grid->num_ver_coefs * 4430 sizeof(*me->ver_coefs.even_imag), 4431 GFP_KERNEL); 4432 if (!me->ver_coefs.even_imag) 4433 goto err; 4434 4435 return me; 4436err: 4437 ia_css_dvs2_coefficients_free(me); 4438 return NULL; 4439} 4440 4441void 4442ia_css_dvs2_coefficients_free(struct ia_css_dvs2_coefficients *me) 4443{ 4444 if (me) { 4445 kvfree(me->hor_coefs.odd_real); 4446 kvfree(me->hor_coefs.odd_imag); 4447 kvfree(me->hor_coefs.even_real); 4448 kvfree(me->hor_coefs.even_imag); 4449 kvfree(me->ver_coefs.odd_real); 4450 kvfree(me->ver_coefs.odd_imag); 4451 kvfree(me->ver_coefs.even_real); 4452 kvfree(me->ver_coefs.even_imag); 4453 kvfree(me); 4454 } 4455} 4456 4457struct ia_css_dvs_6axis_config * 4458ia_css_dvs2_6axis_config_allocate(const struct ia_css_stream *stream) 4459{ 4460 struct ia_css_dvs_6axis_config *dvs_config = NULL; 4461 struct ia_css_isp_parameters *params = NULL; 4462 unsigned int width_y; 4463 unsigned int height_y; 4464 unsigned int width_uv; 4465 unsigned int height_uv; 4466 4467 assert(stream); 4468 params = stream->isp_params_configs; 4469 4470 /* Backward compatibility by default consider pipe as Video*/ 4471 if (!params || !params->pipe_dvs_6axis_config[IA_CSS_PIPE_ID_VIDEO]) 4472 goto err; 4473 4474 dvs_config = kvcalloc(1, sizeof(struct ia_css_dvs_6axis_config), 4475 GFP_KERNEL); 4476 if (!dvs_config) 4477 goto err; 4478 4479 dvs_config->width_y = width_y = 4480 params->pipe_dvs_6axis_config[IA_CSS_PIPE_ID_VIDEO]->width_y; 4481 dvs_config->height_y = height_y = 4482 params->pipe_dvs_6axis_config[IA_CSS_PIPE_ID_VIDEO]->height_y; 4483 dvs_config->width_uv = width_uv = 4484 params->pipe_dvs_6axis_config[IA_CSS_PIPE_ID_VIDEO]->width_uv; 4485 dvs_config->height_uv = height_uv = 4486 params->pipe_dvs_6axis_config[IA_CSS_PIPE_ID_VIDEO]->height_uv; 4487 IA_CSS_LOG("table Y: W %d H %d", width_y, height_y); 4488 IA_CSS_LOG("table UV: W %d H %d", width_uv, height_uv); 4489 dvs_config->xcoords_y = kvmalloc(width_y * height_y * sizeof(uint32_t), 4490 GFP_KERNEL); 4491 if (!dvs_config->xcoords_y) 4492 goto err; 4493 4494 dvs_config->ycoords_y = kvmalloc(width_y * height_y * sizeof(uint32_t), 4495 GFP_KERNEL); 4496 if (!dvs_config->ycoords_y) 4497 goto err; 4498 4499 dvs_config->xcoords_uv = kvmalloc(width_uv * height_uv * 4500 sizeof(uint32_t), 4501 GFP_KERNEL); 4502 if (!dvs_config->xcoords_uv) 4503 goto err; 4504 4505 dvs_config->ycoords_uv = kvmalloc(width_uv * height_uv * 4506 sizeof(uint32_t), 4507 GFP_KERNEL); 4508 if (!dvs_config->ycoords_uv) 4509 goto err; 4510 4511 return dvs_config; 4512err: 4513 ia_css_dvs2_6axis_config_free(dvs_config); 4514 return NULL; 4515} 4516 4517void 4518ia_css_dvs2_6axis_config_free(struct ia_css_dvs_6axis_config *dvs_6axis_config) 4519{ 4520 if (dvs_6axis_config) { 4521 kvfree(dvs_6axis_config->xcoords_y); 4522 kvfree(dvs_6axis_config->ycoords_y); 4523 kvfree(dvs_6axis_config->xcoords_uv); 4524 kvfree(dvs_6axis_config->ycoords_uv); 4525 kvfree(dvs_6axis_config); 4526 } 4527} 4528 4529void 4530ia_css_en_dz_capt_pipe(struct ia_css_stream *stream, bool enable) 4531{ 4532 struct ia_css_pipe *pipe; 4533 struct ia_css_pipeline *pipeline; 4534 struct ia_css_pipeline_stage *stage; 4535 enum ia_css_pipe_id pipe_id; 4536 int err; 4537 int i; 4538 4539 if (!stream) 4540 return; 4541 4542 for (i = 0; i < stream->num_pipes; i++) { 4543 pipe = stream->pipes[i]; 4544 pipeline = ia_css_pipe_get_pipeline(pipe); 4545 pipe_id = pipeline->pipe_id; 4546 4547 if (pipe_id == IA_CSS_PIPE_ID_CAPTURE) { 4548 err = ia_css_pipeline_get_stage(pipeline, IA_CSS_BINARY_MODE_CAPTURE_PP, 4549 &stage); 4550 if (!err) 4551 stage->enable_zoom = enable; 4552 break; 4553 } 4554 } 4555} 4556