1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Support for Intel Camera Imaging ISP subsystem. 4 * Copyright (c) 2015, Intel Corporation. 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms and conditions of the GNU General Public License, 8 * version 2, as published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 * more details. 14 */ 15 16 #include <linux/string.h> /* for memcpy() */ 17 18 #include <type_support.h> 19 #include "system_global.h" 20 #include "vamem.h" 21 #include "ia_css_types.h" 22 #include "ia_css_gc2_table.host.h" 23 24 struct ia_css_rgb_gamma_table default_r_gamma_table; 25 struct ia_css_rgb_gamma_table default_g_gamma_table; 26 struct ia_css_rgb_gamma_table default_b_gamma_table; 27 28 /* Identical default gamma table for R, G, and B. */ 29 30 #if defined(HAS_VAMEM_VERSION_2) 31 32 static const uint16_t 33 default_gamma_table_data[IA_CSS_VAMEM_2_RGB_GAMMA_TABLE_SIZE] = { 34 0, 72, 144, 216, 288, 360, 426, 486, 35 541, 592, 641, 687, 730, 772, 812, 850, 36 887, 923, 958, 991, 1024, 1055, 1086, 1117, 37 1146, 1175, 1203, 1230, 1257, 1284, 1310, 1335, 38 1360, 1385, 1409, 1433, 1457, 1480, 1502, 1525, 39 1547, 1569, 1590, 1612, 1632, 1653, 1674, 1694, 40 1714, 1734, 1753, 1772, 1792, 1811, 1829, 1848, 41 1866, 1884, 1902, 1920, 1938, 1955, 1973, 1990, 42 2007, 2024, 2040, 2057, 2074, 2090, 2106, 2122, 43 2138, 2154, 2170, 2185, 2201, 2216, 2231, 2247, 44 2262, 2277, 2291, 2306, 2321, 2335, 2350, 2364, 45 2378, 2393, 2407, 2421, 2435, 2449, 2462, 2476, 46 2490, 2503, 2517, 2530, 2543, 2557, 2570, 2583, 47 2596, 2609, 2622, 2634, 2647, 2660, 2673, 2685, 48 2698, 2710, 2722, 2735, 2747, 2759, 2771, 2783, 49 2795, 2807, 2819, 2831, 2843, 2855, 2867, 2878, 50 2890, 2901, 2913, 2924, 2936, 2947, 2958, 2970, 51 2981, 2992, 3003, 3014, 3025, 3036, 3047, 3058, 52 3069, 3080, 3091, 3102, 3112, 3123, 3134, 3144, 53 3155, 3165, 3176, 3186, 3197, 3207, 3217, 3228, 54 3238, 3248, 3258, 3268, 3279, 3289, 3299, 3309, 55 3319, 3329, 3339, 3349, 3358, 3368, 3378, 3388, 56 3398, 3407, 3417, 3427, 3436, 3446, 3455, 3465, 57 3474, 3484, 3493, 3503, 3512, 3521, 3531, 3540, 58 3549, 3559, 3568, 3577, 3586, 3595, 3605, 3614, 59 3623, 3632, 3641, 3650, 3659, 3668, 3677, 3686, 60 3694, 3703, 3712, 3721, 3730, 3739, 3747, 3756, 61 3765, 3773, 3782, 3791, 3799, 3808, 3816, 3825, 62 3833, 3842, 3850, 3859, 3867, 3876, 3884, 3893, 63 3901, 3909, 3918, 3926, 3934, 3942, 3951, 3959, 64 3967, 3975, 3984, 3992, 4000, 4008, 4016, 4024, 65 4032, 4040, 4048, 4056, 4064, 4072, 4080, 4088, 66 4095 67 }; 68 #elif defined(HAS_VAMEM_VERSION_1) 69 70 static const uint16_t 71 default_gamma_table_data[IA_CSS_VAMEM_1_RGB_GAMMA_TABLE_SIZE] = { 72 0, 72, 144, 216, 288, 360, 426, 486, 73 541, 592, 641, 687, 730, 772, 812, 850, 74 887, 923, 958, 991, 1024, 1055, 1086, 1117, 75 1146, 1175, 1203, 1230, 1257, 1284, 1310, 1335, 76 1360, 1385, 1409, 1433, 1457, 1480, 1502, 1525, 77 1547, 1569, 1590, 1612, 1632, 1653, 1674, 1694, 78 1714, 1734, 1753, 1772, 1792, 1811, 1829, 1848, 79 1866, 1884, 1902, 1920, 1938, 1955, 1973, 1990, 80 2007, 2024, 2040, 2057, 2074, 2090, 2106, 2122, 81 2138, 2154, 2170, 2185, 2201, 2216, 2231, 2247, 82 2262, 2277, 2291, 2306, 2321, 2335, 2350, 2364, 83 2378, 2393, 2407, 2421, 2435, 2449, 2462, 2476, 84 2490, 2503, 2517, 2530, 2543, 2557, 2570, 2583, 85 2596, 2609, 2622, 2634, 2647, 2660, 2673, 2685, 86 2698, 2710, 2722, 2735, 2747, 2759, 2771, 2783, 87 2795, 2807, 2819, 2831, 2843, 2855, 2867, 2878, 88 2890, 2901, 2913, 2924, 2936, 2947, 2958, 2970, 89 2981, 2992, 3003, 3014, 3025, 3036, 3047, 3058, 90 3069, 3080, 3091, 3102, 3112, 3123, 3134, 3144, 91 3155, 3165, 3176, 3186, 3197, 3207, 3217, 3228, 92 3238, 3248, 3258, 3268, 3279, 3289, 3299, 3309, 93 3319, 3329, 3339, 3349, 3358, 3368, 3378, 3388, 94 3398, 3407, 3417, 3427, 3436, 3446, 3455, 3465, 95 3474, 3484, 3493, 3503, 3512, 3521, 3531, 3540, 96 3549, 3559, 3568, 3577, 3586, 3595, 3605, 3614, 97 3623, 3632, 3641, 3650, 3659, 3668, 3677, 3686, 98 3694, 3703, 3712, 3721, 3730, 3739, 3747, 3756, 99 3765, 3773, 3782, 3791, 3799, 3808, 3816, 3825, 100 3833, 3842, 3850, 3859, 3867, 3876, 3884, 3893, 101 3901, 3909, 3918, 3926, 3934, 3942, 3951, 3959, 102 3967, 3975, 3984, 3992, 4000, 4008, 4016, 4024, 103 4032, 4040, 4048, 4056, 4064, 4072, 4080, 4088 104 }; 105 #else 106 #error "VAMEM version must be one of {VAMEM_VERSION_1, VAMEM_VERSION_2}" 107 #endif 108 109 void 110 ia_css_config_rgb_gamma_tables(void) 111 { 112 #if defined(HAS_VAMEM_VERSION_2) 113 default_r_gamma_table.vamem_type = IA_CSS_VAMEM_TYPE_2; 114 default_g_gamma_table.vamem_type = IA_CSS_VAMEM_TYPE_2; 115 default_b_gamma_table.vamem_type = IA_CSS_VAMEM_TYPE_2; 116 memcpy(default_r_gamma_table.data.vamem_2, default_gamma_table_data, 117 sizeof(default_gamma_table_data)); 118 memcpy(default_g_gamma_table.data.vamem_2, default_gamma_table_data, 119 sizeof(default_gamma_table_data)); 120 memcpy(default_b_gamma_table.data.vamem_2, default_gamma_table_data, 121 sizeof(default_gamma_table_data)); 122 #else 123 memcpy(default_r_gamma_table.data.vamem_1, default_gamma_table_data, 124 sizeof(default_gamma_table_data)); 125 memcpy(default_g_gamma_table.data.vamem_1, default_gamma_table_data, 126 sizeof(default_gamma_table_data)); 127 memcpy(default_b_gamma_table.data.vamem_1, default_gamma_table_data, 128 sizeof(default_gamma_table_data)); 129 default_r_gamma_table.vamem_type = IA_CSS_VAMEM_TYPE_1; 130 default_g_gamma_table.vamem_type = IA_CSS_VAMEM_TYPE_1; 131 default_b_gamma_table.vamem_type = IA_CSS_VAMEM_TYPE_1; 132 #endif 133 } 134