2 * Support for Intel Camera Imaging ISP subsystem.
3 * Copyright (c) 2010-2015, Intel Corporation.
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.
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
15 /* The name "gdc.h is already taken" */
16 #include "gdc_device.h"
18 #include "device_access.h"
20 #include "assert_support.h"
23 * Local function declarations
25 STORAGE_CLASS_INLINE void gdc_reg_store(
27 const unsigned int reg,
28 const hrt_data value);
30 STORAGE_CLASS_INLINE hrt_data gdc_reg_load(
32 const unsigned int reg);
35 #ifndef __INLINE_GDC__
36 #include "gdc_private.h"
37 #endif /* __INLINE_GDC__ */
40 * Exported function implementations
44 const int data[4][HRT_GDC_N])
46 unsigned int i, lut_offset = HRT_GDC_LUT_IDX;
48 assert(ID < N_GDC_ID);
49 assert(HRT_GDC_LUT_COEFF_OFFSET <= (4*sizeof(hrt_data)));
51 for (i = 0; i < HRT_GDC_N; i++) {
52 hrt_data entry_0 = data[0][i] & HRT_GDC_BCI_COEF_MASK;
53 hrt_data entry_1 = data[1][i] & HRT_GDC_BCI_COEF_MASK;
54 hrt_data entry_2 = data[2][i] & HRT_GDC_BCI_COEF_MASK;
55 hrt_data entry_3 = data[3][i] & HRT_GDC_BCI_COEF_MASK;
57 hrt_data word_0 = entry_0 |
58 (entry_1 << HRT_GDC_LUT_COEFF_OFFSET);
59 hrt_data word_1 = entry_2 |
60 (entry_3 << HRT_GDC_LUT_COEFF_OFFSET);
62 gdc_reg_store(ID, lut_offset++, word_0);
63 gdc_reg_store(ID, lut_offset++, word_1);
70 * c0[0-1023], c1[0-1023], c2[0-1023] c3[0-1023]
72 * Output LUT format (interleaved):
73 * c0[0], c1[0], c2[0], c3[0], c0[1], c1[1], c2[1], c3[1], ....
74 * c0[1023], c1[1023], c2[1023], c3[1023]
76 * The first format needs c0[0], c1[0] (which are 1024 words apart)
77 * to program gdc LUT registers. This makes it difficult to do piecemeal
78 * reads in SP side gdc_lut_store
80 * Interleaved format allows use of contiguous bytes to store into
83 * See gdc_lut_store() definition in host/gdc.c vs sp/gdc_private.h
86 void gdc_lut_convert_to_isp_format(const int in_lut[4][HRT_GDC_N],
87 int out_lut[4][HRT_GDC_N])
90 int *out = (int *)out_lut;
92 for (i = 0; i < HRT_GDC_N; i++) {
93 out[0] = in_lut[0][i];
94 out[1] = in_lut[1][i];
95 out[2] = in_lut[2][i];
96 out[3] = in_lut[3][i];
104 assert(ID < N_GDC_ID);
106 return (int)(1UL << HRT_GDC_FRAC_BITS);
111 * Local function implementations
113 STORAGE_CLASS_INLINE void gdc_reg_store(
115 const unsigned int reg,
116 const hrt_data value)
118 ia_css_device_store_uint32(GDC_BASE[ID] + reg*sizeof(hrt_data), value);
122 STORAGE_CLASS_INLINE hrt_data gdc_reg_load(
124 const unsigned int reg)
126 return ia_css_device_load_uint32(GDC_BASE[ID] + reg*sizeof(hrt_data));