1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Support for Intel Camera Imaging ISP subsystem. 4 * Copyright (c) 2015, Intel Corporation. 5 */ 6 7 #ifndef __IA_CSS_CTC_TYPES_H 8 #define __IA_CSS_CTC_TYPES_H 9 10 #include <linux/bitops.h> 11 12 /* @file 13 * CSS-API header file for Chroma Tone Control parameters. 14 */ 15 16 /* Fractional bits for CTC gain (used only for ISP1). 17 * 18 * IA_CSS_CTC_COEF_SHIFT(=13) includes not only the fractional bits 19 * of gain(=8), but also the bits(=5) to convert chroma 20 * from 13bit precision to 8bit precision. 21 * 22 * Gain (struct ia_css_ctc_table) : u5.8 23 * Input(Chorma) : s0.12 (13bit precision) 24 * Output(Chorma): s0.7 (8bit precision) 25 * Output = (Input * Gain) >> IA_CSS_CTC_COEF_SHIFT 26 */ 27 #define IA_CSS_CTC_COEF_SHIFT 13 28 29 /* Number of elements in the CTC table. */ 30 #define IA_CSS_VAMEM_1_CTC_TABLE_SIZE_LOG2 10 31 /* Number of elements in the CTC table. */ 32 #define IA_CSS_VAMEM_1_CTC_TABLE_SIZE BIT(IA_CSS_VAMEM_1_CTC_TABLE_SIZE_LOG2) 33 34 /* Number of elements in the CTC table. */ 35 #define IA_CSS_VAMEM_2_CTC_TABLE_SIZE_LOG2 8 36 /* Number of elements in the CTC table. */ 37 #define IA_CSS_VAMEM_2_CTC_TABLE_SIZE ((1U << IA_CSS_VAMEM_2_CTC_TABLE_SIZE_LOG2) + 1) 38 39 enum ia_css_vamem_type { 40 IA_CSS_VAMEM_TYPE_1, 41 IA_CSS_VAMEM_TYPE_2 42 }; 43 44 /* Chroma Tone Control configuration. 45 * 46 * ISP block: CTC2 (CTC by polygonal line approximation) 47 * (ISP1: CTC1 (CTC by look-up table) is used.) 48 * ISP2: CTC2 is used. 49 */ 50 struct ia_css_ctc_config { 51 u16 y0; /** 1st kneepoint gain. 52 u[ce_gain_exp].[13-ce_gain_exp], [0,8191], 53 default/ineffective 4096(0.5) */ 54 u16 y1; /** 2nd kneepoint gain. 55 u[ce_gain_exp].[13-ce_gain_exp], [0,8191], 56 default/ineffective 4096(0.5) */ 57 u16 y2; /** 3rd kneepoint gain. 58 u[ce_gain_exp].[13-ce_gain_exp], [0,8191], 59 default/ineffective 4096(0.5) */ 60 u16 y3; /** 4th kneepoint gain. 61 u[ce_gain_exp].[13-ce_gain_exp], [0,8191], 62 default/ineffective 4096(0.5) */ 63 u16 y4; /** 5th kneepoint gain. 64 u[ce_gain_exp].[13-ce_gain_exp], [0,8191], 65 default/ineffective 4096(0.5) */ 66 u16 y5; /** 6th kneepoint gain. 67 u[ce_gain_exp].[13-ce_gain_exp], [0,8191], 68 default/ineffective 4096(0.5) */ 69 u16 ce_gain_exp; /** Common exponent of y-axis gain. 70 u8.0, [0,13], 71 default/ineffective 1 */ 72 u16 x1; /** 2nd kneepoint luma. 73 u0.13, [0,8191], constraints: 0<x1<x2, 74 default/ineffective 1024 */ 75 u16 x2; /** 3rd kneepoint luma. 76 u0.13, [0,8191], constraints: x1<x2<x3, 77 default/ineffective 2048 */ 78 u16 x3; /** 4th kneepoint luma. 79 u0.13, [0,8191], constraints: x2<x3<x4, 80 default/ineffective 6144 */ 81 u16 x4; /** 5tn kneepoint luma. 82 u0.13, [0,8191], constraints: x3<x4<8191, 83 default/ineffective 7168 */ 84 }; 85 86 union ia_css_ctc_data { 87 u16 vamem_1[IA_CSS_VAMEM_1_CTC_TABLE_SIZE]; 88 u16 vamem_2[IA_CSS_VAMEM_2_CTC_TABLE_SIZE]; 89 }; 90 91 /* CTC table, used for Chroma Tone Control. 92 * 93 * ISP block: CTC1 (CTC by look-up table) 94 * ISP1: CTC1 is used. 95 * (ISP2: CTC2 (CTC by polygonal line approximation) is used.) 96 */ 97 struct ia_css_ctc_table { 98 enum ia_css_vamem_type vamem_type; 99 union ia_css_ctc_data data; 100 }; 101 102 #endif /* __IA_CSS_CTC_TYPES_H */ 103