]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blob - drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_common/host/isp_private.h
staging/atomisp: Add support for the Intel IPU v2
[mirror_ubuntu-hirsute-kernel.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / hive_isp_css_common / host / isp_private.h
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 #ifndef __ISP_PRIVATE_H_INCLUDED__
16 #define __ISP_PRIVATE_H_INCLUDED__
17
18 #ifdef HRT_MEMORY_ACCESS
19 #include <hrt/api.h>
20 #endif
21
22 #include "isp_public.h"
23
24 #ifdef C_RUN
25 #include <string.h> /* memcpy() */
26 #endif
27
28 #include "device_access.h"
29
30 #include "assert_support.h"
31 #include "type_support.h"
32
33 STORAGE_CLASS_ISP_C void isp_ctrl_store(
34 const isp_ID_t ID,
35 const unsigned int reg,
36 const hrt_data value)
37 {
38 assert(ID < N_ISP_ID);
39 assert(ISP_CTRL_BASE[ID] != (hrt_address)-1);
40 #if !defined(HRT_MEMORY_ACCESS)
41 ia_css_device_store_uint32(ISP_CTRL_BASE[ID] + reg*sizeof(hrt_data), value);
42 #else
43 hrt_master_port_store_32(ISP_CTRL_BASE[ID] + reg*sizeof(hrt_data), value);
44 #endif
45 return;
46 }
47
48 STORAGE_CLASS_ISP_C hrt_data isp_ctrl_load(
49 const isp_ID_t ID,
50 const unsigned int reg)
51 {
52 assert(ID < N_ISP_ID);
53 assert(ISP_CTRL_BASE[ID] != (hrt_address)-1);
54 #if !defined(HRT_MEMORY_ACCESS)
55 return ia_css_device_load_uint32(ISP_CTRL_BASE[ID] + reg*sizeof(hrt_data));
56 #else
57 return hrt_master_port_uload_32(ISP_CTRL_BASE[ID] + reg*sizeof(hrt_data));
58 #endif
59 }
60
61 STORAGE_CLASS_ISP_C bool isp_ctrl_getbit(
62 const isp_ID_t ID,
63 const unsigned int reg,
64 const unsigned int bit)
65 {
66 hrt_data val = isp_ctrl_load(ID, reg);
67 return (val & (1UL << bit)) != 0;
68 }
69
70 STORAGE_CLASS_ISP_C void isp_ctrl_setbit(
71 const isp_ID_t ID,
72 const unsigned int reg,
73 const unsigned int bit)
74 {
75 hrt_data data = isp_ctrl_load(ID, reg);
76 isp_ctrl_store(ID, reg, (data | (1UL << bit)));
77 return;
78 }
79
80 STORAGE_CLASS_ISP_C void isp_ctrl_clearbit(
81 const isp_ID_t ID,
82 const unsigned int reg,
83 const unsigned int bit)
84 {
85 hrt_data data = isp_ctrl_load(ID, reg);
86 isp_ctrl_store(ID, reg, (data & ~(1UL << bit)));
87 return;
88 }
89
90 STORAGE_CLASS_ISP_C void isp_dmem_store(
91 const isp_ID_t ID,
92 unsigned int addr,
93 const void *data,
94 const size_t size)
95 {
96 assert(ID < N_ISP_ID);
97 assert(ISP_DMEM_BASE[ID] != (hrt_address)-1);
98 #ifdef C_RUN
99 memcpy((void *)addr, data, size);
100 #elif !defined(HRT_MEMORY_ACCESS)
101 ia_css_device_store(ISP_DMEM_BASE[ID] + addr, data, size);
102 #else
103 hrt_master_port_store(ISP_DMEM_BASE[ID] + addr, data, size);
104 #endif
105 return;
106 }
107
108 STORAGE_CLASS_ISP_C void isp_dmem_load(
109 const isp_ID_t ID,
110 const unsigned int addr,
111 void *data,
112 const size_t size)
113 {
114 assert(ID < N_ISP_ID);
115 assert(ISP_DMEM_BASE[ID] != (hrt_address)-1);
116 #ifdef C_RUN
117 memcpy(data, (void *)addr, size);
118 #elif !defined(HRT_MEMORY_ACCESS)
119 ia_css_device_load(ISP_DMEM_BASE[ID] + addr, data, size);
120 #else
121 hrt_master_port_load(ISP_DMEM_BASE[ID] + addr, data, size);
122 #endif
123 return;
124 }
125
126 STORAGE_CLASS_ISP_C void isp_dmem_store_uint32(
127 const isp_ID_t ID,
128 unsigned int addr,
129 const uint32_t data)
130 {
131 assert(ID < N_ISP_ID);
132 assert(ISP_DMEM_BASE[ID] != (hrt_address)-1);
133 (void)ID;
134 #ifdef C_RUN
135 *(uint32_t *)addr = data;
136 #elif !defined(HRT_MEMORY_ACCESS)
137 ia_css_device_store_uint32(ISP_DMEM_BASE[ID] + addr, data);
138 #else
139 hrt_master_port_store_32(ISP_DMEM_BASE[ID] + addr, data);
140 #endif
141 return;
142 }
143
144 STORAGE_CLASS_ISP_C uint32_t isp_dmem_load_uint32(
145 const isp_ID_t ID,
146 const unsigned int addr)
147 {
148 assert(ID < N_ISP_ID);
149 assert(ISP_DMEM_BASE[ID] != (hrt_address)-1);
150 (void)ID;
151 #ifdef C_RUN
152 return *(uint32_t *)addr;
153 #elif !defined(HRT_MEMORY_ACCESS)
154 return ia_css_device_load_uint32(ISP_DMEM_BASE[ID] + addr);
155 #else
156 return hrt_master_port_uload_32(ISP_DMEM_BASE[ID] + addr);
157 #endif
158 }
159
160 STORAGE_CLASS_ISP_C uint32_t isp_2w_cat_1w(
161 const uint16_t x0,
162 const uint16_t x1)
163 {
164 uint32_t out = ((uint32_t)(x1 & HIVE_ISP_VMEM_MASK) << ISP_VMEM_ELEMBITS)
165 | (x0 & HIVE_ISP_VMEM_MASK);
166 return out;
167 }
168
169 #endif /* __ISP_PRIVATE_H_INCLUDED__ */