GNU Linux-libre 4.14.295-gnu1
[releases.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / isp / kernels / ref / ref_1.0 / ia_css_ref.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 <assert_support.h>
16 #include <ia_css_frame_public.h>
17 #include <ia_css_frame.h>
18 #include <ia_css_binary.h>
19 #define IA_CSS_INCLUDE_CONFIGURATIONS
20 #include "ia_css_isp_configs.h"
21 #include "isp.h"
22 #include "ia_css_ref.host.h"
23
24 void
25 ia_css_ref_config(
26         struct sh_css_isp_ref_isp_config *to,
27         const struct ia_css_ref_configuration  *from,
28         unsigned size)
29 {
30         unsigned elems_a = ISP_VEC_NELEMS, i;
31
32         (void)size;
33         ia_css_dma_configure_from_info(&to->port_b, &(from->ref_frames[0]->info));
34         to->width_a_over_b = elems_a / to->port_b.elems;
35         to->dvs_frame_delay = from->dvs_frame_delay;
36         for (i = 0; i < MAX_NUM_VIDEO_DELAY_FRAMES; i++) {
37                 if (from->ref_frames[i]) {
38                         to->ref_frame_addr_y[i] = from->ref_frames[i]->data + from->ref_frames[i]->planes.yuv.y.offset;
39                         to->ref_frame_addr_c[i] = from->ref_frames[i]->data + from->ref_frames[i]->planes.yuv.u.offset;
40                 } else {
41                         to->ref_frame_addr_y[i] = 0;
42                         to->ref_frame_addr_c[i] = 0;
43                 }
44         }
45
46         /* Assume divisiblity here, may need to generalize to fixed point. */
47         assert (elems_a % to->port_b.elems == 0);
48 }
49
50 void
51 ia_css_ref_configure(
52         const struct ia_css_binary     *binary,
53         const struct ia_css_frame **ref_frames,
54         const uint32_t dvs_frame_delay)
55 {
56         struct ia_css_ref_configuration config;
57         unsigned i;
58
59         for (i = 0; i < MAX_NUM_VIDEO_DELAY_FRAMES; i++)
60                 config.ref_frames[i] = ref_frames[i];
61         config.dvs_frame_delay = dvs_frame_delay;
62         ia_css_configure_ref(binary, &config);
63 }
64
65 void
66 ia_css_init_ref_state(
67         struct sh_css_isp_ref_dmem_state *state,
68         unsigned size)
69 {
70         (void)size;
71         assert(MAX_NUM_VIDEO_DELAY_FRAMES >= 2);
72         state->ref_in_buf_idx = 0;
73         state->ref_out_buf_idx = 1;
74 }