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