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