162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2013 Texas Instruments Inc. 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * David Griego, <dagriego@biglakesoftware.com> 662306a36Sopenharmony_ci * Dale Farnsworth, <dale@farnsworth.org> 762306a36Sopenharmony_ci * Archit Taneja, <archit@ti.com> 862306a36Sopenharmony_ci */ 962306a36Sopenharmony_ci#ifndef TI_SC_H 1062306a36Sopenharmony_ci#define TI_SC_H 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci/* Scaler regs */ 1362306a36Sopenharmony_ci#define CFG_SC0 0x0 1462306a36Sopenharmony_ci#define CFG_INTERLACE_O (1 << 0) 1562306a36Sopenharmony_ci#define CFG_LINEAR (1 << 1) 1662306a36Sopenharmony_ci#define CFG_SC_BYPASS (1 << 2) 1762306a36Sopenharmony_ci#define CFG_INVT_FID (1 << 3) 1862306a36Sopenharmony_ci#define CFG_USE_RAV (1 << 4) 1962306a36Sopenharmony_ci#define CFG_ENABLE_EV (1 << 5) 2062306a36Sopenharmony_ci#define CFG_AUTO_HS (1 << 6) 2162306a36Sopenharmony_ci#define CFG_DCM_2X (1 << 7) 2262306a36Sopenharmony_ci#define CFG_DCM_4X (1 << 8) 2362306a36Sopenharmony_ci#define CFG_HP_BYPASS (1 << 9) 2462306a36Sopenharmony_ci#define CFG_INTERLACE_I (1 << 10) 2562306a36Sopenharmony_ci#define CFG_ENABLE_SIN2_VER_INTP (1 << 11) 2662306a36Sopenharmony_ci#define CFG_Y_PK_EN (1 << 14) 2762306a36Sopenharmony_ci#define CFG_TRIM (1 << 15) 2862306a36Sopenharmony_ci#define CFG_SELFGEN_FID (1 << 16) 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci#define CFG_SC1 0x4 3162306a36Sopenharmony_ci#define CFG_ROW_ACC_INC_MASK 0x07ffffff 3262306a36Sopenharmony_ci#define CFG_ROW_ACC_INC_SHIFT 0 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci#define CFG_SC2 0x08 3562306a36Sopenharmony_ci#define CFG_ROW_ACC_OFFSET_MASK 0x0fffffff 3662306a36Sopenharmony_ci#define CFG_ROW_ACC_OFFSET_SHIFT 0 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci#define CFG_SC3 0x0c 3962306a36Sopenharmony_ci#define CFG_ROW_ACC_OFFSET_B_MASK 0x0fffffff 4062306a36Sopenharmony_ci#define CFG_ROW_ACC_OFFSET_B_SHIFT 0 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci#define CFG_SC4 0x10 4362306a36Sopenharmony_ci#define CFG_TAR_H_MASK 0x07ff 4462306a36Sopenharmony_ci#define CFG_TAR_H_SHIFT 0 4562306a36Sopenharmony_ci#define CFG_TAR_W_MASK 0x07ff 4662306a36Sopenharmony_ci#define CFG_TAR_W_SHIFT 12 4762306a36Sopenharmony_ci#define CFG_LIN_ACC_INC_U_MASK 0x07 4862306a36Sopenharmony_ci#define CFG_LIN_ACC_INC_U_SHIFT 24 4962306a36Sopenharmony_ci#define CFG_NLIN_ACC_INIT_U_MASK 0x07 5062306a36Sopenharmony_ci#define CFG_NLIN_ACC_INIT_U_SHIFT 28 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ci#define CFG_SC5 0x14 5362306a36Sopenharmony_ci#define CFG_SRC_H_MASK 0x07ff 5462306a36Sopenharmony_ci#define CFG_SRC_H_SHIFT 0 5562306a36Sopenharmony_ci#define CFG_SRC_W_MASK 0x07ff 5662306a36Sopenharmony_ci#define CFG_SRC_W_SHIFT 12 5762306a36Sopenharmony_ci#define CFG_NLIN_ACC_INC_U_MASK 0x07 5862306a36Sopenharmony_ci#define CFG_NLIN_ACC_INC_U_SHIFT 24 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ci#define CFG_SC6 0x18 6162306a36Sopenharmony_ci#define CFG_ROW_ACC_INIT_RAV_MASK 0x03ff 6262306a36Sopenharmony_ci#define CFG_ROW_ACC_INIT_RAV_SHIFT 0 6362306a36Sopenharmony_ci#define CFG_ROW_ACC_INIT_RAV_B_MASK 0x03ff 6462306a36Sopenharmony_ci#define CFG_ROW_ACC_INIT_RAV_B_SHIFT 10 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci#define CFG_SC8 0x20 6762306a36Sopenharmony_ci#define CFG_NLIN_LEFT_MASK 0x07ff 6862306a36Sopenharmony_ci#define CFG_NLIN_LEFT_SHIFT 0 6962306a36Sopenharmony_ci#define CFG_NLIN_RIGHT_MASK 0x07ff 7062306a36Sopenharmony_ci#define CFG_NLIN_RIGHT_SHIFT 12 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci#define CFG_SC9 0x24 7362306a36Sopenharmony_ci#define CFG_LIN_ACC_INC CFG_SC9 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci#define CFG_SC10 0x28 7662306a36Sopenharmony_ci#define CFG_NLIN_ACC_INIT CFG_SC10 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ci#define CFG_SC11 0x2c 7962306a36Sopenharmony_ci#define CFG_NLIN_ACC_INC CFG_SC11 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ci#define CFG_SC12 0x30 8262306a36Sopenharmony_ci#define CFG_COL_ACC_OFFSET_MASK 0x01ffffff 8362306a36Sopenharmony_ci#define CFG_COL_ACC_OFFSET_SHIFT 0 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_ci#define CFG_SC13 0x34 8662306a36Sopenharmony_ci#define CFG_SC_FACTOR_RAV_MASK 0xff 8762306a36Sopenharmony_ci#define CFG_SC_FACTOR_RAV_SHIFT 0 8862306a36Sopenharmony_ci#define CFG_CHROMA_INTP_THR_MASK 0x03ff 8962306a36Sopenharmony_ci#define CFG_CHROMA_INTP_THR_SHIFT 12 9062306a36Sopenharmony_ci#define CFG_DELTA_CHROMA_THR_MASK 0x0f 9162306a36Sopenharmony_ci#define CFG_DELTA_CHROMA_THR_SHIFT 24 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_ci#define CFG_SC17 0x44 9462306a36Sopenharmony_ci#define CFG_EV_THR_MASK 0x03ff 9562306a36Sopenharmony_ci#define CFG_EV_THR_SHIFT 12 9662306a36Sopenharmony_ci#define CFG_DELTA_LUMA_THR_MASK 0x0f 9762306a36Sopenharmony_ci#define CFG_DELTA_LUMA_THR_SHIFT 24 9862306a36Sopenharmony_ci#define CFG_DELTA_EV_THR_MASK 0x0f 9962306a36Sopenharmony_ci#define CFG_DELTA_EV_THR_SHIFT 28 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_ci#define CFG_SC18 0x48 10262306a36Sopenharmony_ci#define CFG_HS_FACTOR_MASK 0x03ff 10362306a36Sopenharmony_ci#define CFG_HS_FACTOR_SHIFT 0 10462306a36Sopenharmony_ci#define CFG_CONF_DEFAULT_MASK 0x01ff 10562306a36Sopenharmony_ci#define CFG_CONF_DEFAULT_SHIFT 16 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_ci#define CFG_SC19 0x4c 10862306a36Sopenharmony_ci#define CFG_HPF_COEFF0_MASK 0xff 10962306a36Sopenharmony_ci#define CFG_HPF_COEFF0_SHIFT 0 11062306a36Sopenharmony_ci#define CFG_HPF_COEFF1_MASK 0xff 11162306a36Sopenharmony_ci#define CFG_HPF_COEFF1_SHIFT 8 11262306a36Sopenharmony_ci#define CFG_HPF_COEFF2_MASK 0xff 11362306a36Sopenharmony_ci#define CFG_HPF_COEFF2_SHIFT 16 11462306a36Sopenharmony_ci#define CFG_HPF_COEFF3_MASK 0xff 11562306a36Sopenharmony_ci#define CFG_HPF_COEFF3_SHIFT 23 11662306a36Sopenharmony_ci 11762306a36Sopenharmony_ci#define CFG_SC20 0x50 11862306a36Sopenharmony_ci#define CFG_HPF_COEFF4_MASK 0xff 11962306a36Sopenharmony_ci#define CFG_HPF_COEFF4_SHIFT 0 12062306a36Sopenharmony_ci#define CFG_HPF_COEFF5_MASK 0xff 12162306a36Sopenharmony_ci#define CFG_HPF_COEFF5_SHIFT 8 12262306a36Sopenharmony_ci#define CFG_HPF_NORM_SHIFT_MASK 0x07 12362306a36Sopenharmony_ci#define CFG_HPF_NORM_SHIFT_SHIFT 16 12462306a36Sopenharmony_ci#define CFG_NL_LIMIT_MASK 0x1ff 12562306a36Sopenharmony_ci#define CFG_NL_LIMIT_SHIFT 20 12662306a36Sopenharmony_ci 12762306a36Sopenharmony_ci#define CFG_SC21 0x54 12862306a36Sopenharmony_ci#define CFG_NL_LO_THR_MASK 0x01ff 12962306a36Sopenharmony_ci#define CFG_NL_LO_THR_SHIFT 0 13062306a36Sopenharmony_ci#define CFG_NL_LO_SLOPE_MASK 0xff 13162306a36Sopenharmony_ci#define CFG_NL_LO_SLOPE_SHIFT 16 13262306a36Sopenharmony_ci 13362306a36Sopenharmony_ci#define CFG_SC22 0x58 13462306a36Sopenharmony_ci#define CFG_NL_HI_THR_MASK 0x01ff 13562306a36Sopenharmony_ci#define CFG_NL_HI_THR_SHIFT 0 13662306a36Sopenharmony_ci#define CFG_NL_HI_SLOPE_SH_MASK 0x07 13762306a36Sopenharmony_ci#define CFG_NL_HI_SLOPE_SH_SHIFT 16 13862306a36Sopenharmony_ci 13962306a36Sopenharmony_ci#define CFG_SC23 0x5c 14062306a36Sopenharmony_ci#define CFG_GRADIENT_THR_MASK 0x07ff 14162306a36Sopenharmony_ci#define CFG_GRADIENT_THR_SHIFT 0 14262306a36Sopenharmony_ci#define CFG_GRADIENT_THR_RANGE_MASK 0x0f 14362306a36Sopenharmony_ci#define CFG_GRADIENT_THR_RANGE_SHIFT 12 14462306a36Sopenharmony_ci#define CFG_MIN_GY_THR_MASK 0xff 14562306a36Sopenharmony_ci#define CFG_MIN_GY_THR_SHIFT 16 14662306a36Sopenharmony_ci#define CFG_MIN_GY_THR_RANGE_MASK 0x0f 14762306a36Sopenharmony_ci#define CFG_MIN_GY_THR_RANGE_SHIFT 28 14862306a36Sopenharmony_ci 14962306a36Sopenharmony_ci#define CFG_SC24 0x60 15062306a36Sopenharmony_ci#define CFG_ORG_H_MASK 0x07ff 15162306a36Sopenharmony_ci#define CFG_ORG_H_SHIFT 0 15262306a36Sopenharmony_ci#define CFG_ORG_W_MASK 0x07ff 15362306a36Sopenharmony_ci#define CFG_ORG_W_SHIFT 16 15462306a36Sopenharmony_ci 15562306a36Sopenharmony_ci#define CFG_SC25 0x64 15662306a36Sopenharmony_ci#define CFG_OFF_H_MASK 0x07ff 15762306a36Sopenharmony_ci#define CFG_OFF_H_SHIFT 0 15862306a36Sopenharmony_ci#define CFG_OFF_W_MASK 0x07ff 15962306a36Sopenharmony_ci#define CFG_OFF_W_SHIFT 16 16062306a36Sopenharmony_ci 16162306a36Sopenharmony_ci/* number of phases supported by the polyphase scalers */ 16262306a36Sopenharmony_ci#define SC_NUM_PHASES 32 16362306a36Sopenharmony_ci 16462306a36Sopenharmony_ci/* number of taps used by horizontal polyphase scaler */ 16562306a36Sopenharmony_ci#define SC_H_NUM_TAPS 7 16662306a36Sopenharmony_ci 16762306a36Sopenharmony_ci/* number of taps used by vertical polyphase scaler */ 16862306a36Sopenharmony_ci#define SC_V_NUM_TAPS 5 16962306a36Sopenharmony_ci 17062306a36Sopenharmony_ci/* number of taps expected by the scaler in it's coefficient memory */ 17162306a36Sopenharmony_ci#define SC_NUM_TAPS_MEM_ALIGN 8 17262306a36Sopenharmony_ci 17362306a36Sopenharmony_ci/* Maximum frame width the scaler can handle (in pixels) */ 17462306a36Sopenharmony_ci#define SC_MAX_PIXEL_WIDTH 2047 17562306a36Sopenharmony_ci 17662306a36Sopenharmony_ci/* Maximum frame height the scaler can handle (in lines) */ 17762306a36Sopenharmony_ci#define SC_MAX_PIXEL_HEIGHT 2047 17862306a36Sopenharmony_ci 17962306a36Sopenharmony_ci/* 18062306a36Sopenharmony_ci * coefficient memory size in bytes: 18162306a36Sopenharmony_ci * num phases x num sets(luma and chroma) x num taps(aligned) x coeff size 18262306a36Sopenharmony_ci */ 18362306a36Sopenharmony_ci#define SC_COEF_SRAM_SIZE (SC_NUM_PHASES * 2 * SC_NUM_TAPS_MEM_ALIGN * 2) 18462306a36Sopenharmony_ci 18562306a36Sopenharmony_cistruct sc_data { 18662306a36Sopenharmony_ci void __iomem *base; 18762306a36Sopenharmony_ci struct resource *res; 18862306a36Sopenharmony_ci 18962306a36Sopenharmony_ci dma_addr_t loaded_coeff_h; /* loaded h coeffs in SC */ 19062306a36Sopenharmony_ci dma_addr_t loaded_coeff_v; /* loaded v coeffs in SC */ 19162306a36Sopenharmony_ci 19262306a36Sopenharmony_ci bool load_coeff_h; /* have new h SC coeffs */ 19362306a36Sopenharmony_ci bool load_coeff_v; /* have new v SC coeffs */ 19462306a36Sopenharmony_ci 19562306a36Sopenharmony_ci struct platform_device *pdev; 19662306a36Sopenharmony_ci}; 19762306a36Sopenharmony_ci 19862306a36Sopenharmony_civoid sc_dump_regs(struct sc_data *sc); 19962306a36Sopenharmony_civoid sc_set_hs_coeffs(struct sc_data *sc, void *addr, unsigned int src_w, 20062306a36Sopenharmony_ci unsigned int dst_w); 20162306a36Sopenharmony_civoid sc_set_vs_coeffs(struct sc_data *sc, void *addr, unsigned int src_h, 20262306a36Sopenharmony_ci unsigned int dst_h); 20362306a36Sopenharmony_civoid sc_config_scaler(struct sc_data *sc, u32 *sc_reg0, u32 *sc_reg8, 20462306a36Sopenharmony_ci u32 *sc_reg17, unsigned int src_w, unsigned int src_h, 20562306a36Sopenharmony_ci unsigned int dst_w, unsigned int dst_h); 20662306a36Sopenharmony_cistruct sc_data *sc_create(struct platform_device *pdev, const char *res_name); 20762306a36Sopenharmony_ci 20862306a36Sopenharmony_ci#endif 209