GNU Linux-libre 4.14.324-gnu1
[releases.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / isp / kernels / xnr / xnr_1.0 / ia_css_xnr_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_xnr_table.host.h"
21
22 struct ia_css_xnr_table default_xnr_table;
23
24 #if defined(HAS_VAMEM_VERSION_2)
25
26 static const uint16_t
27 default_xnr_table_data[IA_CSS_VAMEM_2_XNR_TABLE_SIZE] = {
28   /* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 */
29   8191>>1, 4096>>1, 2730>>1, 2048>>1, 1638>>1, 1365>>1, 1170>>1, 1024>>1, 910>>1, 819>>1, 744>>1, 682>>1, 630>>1, 585>>1,
30     546>>1, 512>>1,
31
32   /* 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 */
33   481>>1, 455>>1, 431>>1, 409>>1, 390>>1, 372>>1, 356>>1, 341>>1, 327>>1, 315>>1, 303>>1, 292>>1, 282>>1, 273>>1, 264>>1,
34     256>>1,
35
36   /* 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 */
37   248>>1, 240>>1, 234>>1, 227>>1, 221>>1, 215>>1, 210>>1, 204>>1, 199>>1, 195>>1, 190>>1, 186>>1, 182>>1, 178>>1, 174>>1,
38     170>>1,
39
40   /* 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 */
41   167>>1, 163>>1, 160>>1, 157>>1, 154>>1, 151>>1, 148>>1, 146>>1, 143>>1, 141>>1, 138>>1, 136>>1, 134>>1, 132>>1, 130>>1, 128>>1
42 };
43
44 #elif defined(HAS_VAMEM_VERSION_1)
45
46 static const uint16_t
47 default_xnr_table_data[IA_CSS_VAMEM_1_XNR_TABLE_SIZE] = {
48   /* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 */
49   8191>>1, 4096>>1, 2730>>1, 2048>>1, 1638>>1, 1365>>1, 1170>>1, 1024>>1, 910>>1, 819>>1, 744>>1, 682>>1, 630>>1, 585>>1,
50     546>>1, 512>>1,
51
52   /* 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 */
53   481>>1, 455>>1, 431>>1, 409>>1, 390>>1, 372>>1, 356>>1, 341>>1, 327>>1, 315>>1, 303>>1, 292>>1, 282>>1, 273>>1, 264>>1,
54     256>>1,
55
56   /* 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 */
57   248>>1, 240>>1, 234>>1, 227>>1, 221>>1, 215>>1, 210>>1, 204>>1, 199>>1, 195>>1, 190>>1, 186>>1, 182>>1, 178>>1, 174>>1,
58     170>>1,
59
60   /* 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 */
61   167>>1, 163>>1, 160>>1, 157>>1, 154>>1, 151>>1, 148>>1, 146>>1, 143>>1, 141>>1, 138>>1, 136>>1, 134>>1, 132>>1, 130>>1, 128>>1
62 };
63
64 #else
65 #error "sh_css_params.c: VAMEM version must \
66         be one of {VAMEM_VERSION_1, VAMEM_VERSION_2}"
67 #endif
68
69 void
70 ia_css_config_xnr_table(void)
71 {
72 #if defined(HAS_VAMEM_VERSION_2)
73         memcpy(default_xnr_table.data.vamem_2, default_xnr_table_data,
74                sizeof(default_xnr_table_data));
75         default_xnr_table.vamem_type     = IA_CSS_VAMEM_TYPE_2;
76 #else
77         memcpy(default_xnr_table.data.vamem_1, default_xnr_table_data,
78                sizeof(default_xnr_table_data));
79         default_xnr_table.vamem_type     = IA_CSS_VAMEM_TYPE_1;
80 #endif
81 }