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
8 #include "ia_css_types.h"
9 #include "sh_css_internal.h"
10 #include "assert_support.h"
11 #include "sh_css_frac.h"
12
13 #include "ia_css_bh.host.h"
14
15 void
ia_css_bh_hmem_decode(struct ia_css_3a_rgby_output * out_ptr,const struct ia_css_bh_table * hmem_buf)16 ia_css_bh_hmem_decode(
17 struct ia_css_3a_rgby_output *out_ptr,
18 const struct ia_css_bh_table *hmem_buf)
19 {
20 int i;
21
22 /*
23 * No weighted histogram, hence no grid definition
24 */
25 if (!hmem_buf)
26 return;
27 assert(sizeof_hmem(HMEM0_ID) == sizeof(*hmem_buf));
28
29 /* Deinterleave */
30 for (i = 0; i < HMEM_UNIT_SIZE; i++) {
31 out_ptr[i].r = hmem_buf->hmem[BH_COLOR_R][i];
32 out_ptr[i].g = hmem_buf->hmem[BH_COLOR_G][i];
33 out_ptr[i].b = hmem_buf->hmem[BH_COLOR_B][i];
34 out_ptr[i].y = hmem_buf->hmem[BH_COLOR_Y][i];
35 /* sh_css_print ("hmem[%d] = %d, %d, %d, %d\n",
36 i, out_ptr[i].r, out_ptr[i].g, out_ptr[i].b, out_ptr[i].y); */
37 }
38 }
39
40 void
ia_css_bh_encode(struct sh_css_isp_bh_params * to,const struct ia_css_3a_config * from,unsigned int size)41 ia_css_bh_encode(
42 struct sh_css_isp_bh_params *to,
43 const struct ia_css_3a_config *from,
44 unsigned int size)
45 {
46 (void)size;
47 /* coefficients to calculate Y */
48 to->y_coef_r =
49 uDIGIT_FITTING(from->ae_y_coef_r, 16, SH_CSS_AE_YCOEF_SHIFT);
50 to->y_coef_g =
51 uDIGIT_FITTING(from->ae_y_coef_g, 16, SH_CSS_AE_YCOEF_SHIFT);
52 to->y_coef_b =
53 uDIGIT_FITTING(from->ae_y_coef_b, 16, SH_CSS_AE_YCOEF_SHIFT);
54 }
55
56