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