3 * Support for Intel Camera Imaging ISP subsystem.
4 * Copyright (c) 2015, Intel Corporation.
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.
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
17 Support for Intel Camera Imaging ISP subsystem.
18 Copyright (c) 2010 - 2015, Intel Corporation.
20 This program is free software; you can redistribute it and/or modify it
21 under the terms and conditions of the GNU General Public License,
22 version 2, as published by the Free Software Foundation.
24 This program is distributed in the hope it will be useful, but WITHOUT
25 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
26 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
31 #include "type_support.h"
32 #include "queue_access.h"
33 #include "ia_css_circbuf.h"
35 #include "memory_access.h"
36 #include "assert_support.h"
38 int ia_css_queue_load(
39 struct ia_css_queue *rdesc,
40 ia_css_circbuf_desc_t *cb_desc,
41 uint32_t ignore_desc_flags)
43 if (rdesc == NULL || cb_desc == NULL)
46 if (rdesc->location == IA_CSS_QUEUE_LOC_SP) {
47 assert(ignore_desc_flags <= QUEUE_IGNORE_DESC_FLAGS_MAX);
49 if (0 == (ignore_desc_flags & QUEUE_IGNORE_SIZE_FLAG)) {
50 cb_desc->size = sp_dmem_load_uint8(rdesc->proc_id,
51 rdesc->desc.remote.cb_desc_addr
52 + offsetof(ia_css_circbuf_desc_t, size));
54 if (0 == cb_desc->size) {
55 /* Adding back the workaround which was removed
56 while refactoring queues. When reading size
57 through sp_dmem_load_*, sometimes we get back
58 the value as zero. This causes division by 0
59 exception as the size is used in a modular
60 division operation. */
65 if (0 == (ignore_desc_flags & QUEUE_IGNORE_START_FLAG))
66 cb_desc->start = sp_dmem_load_uint8(rdesc->proc_id,
67 rdesc->desc.remote.cb_desc_addr
68 + offsetof(ia_css_circbuf_desc_t, start));
70 if (0 == (ignore_desc_flags & QUEUE_IGNORE_END_FLAG))
71 cb_desc->end = sp_dmem_load_uint8(rdesc->proc_id,
72 rdesc->desc.remote.cb_desc_addr
73 + offsetof(ia_css_circbuf_desc_t, end));
75 if (0 == (ignore_desc_flags & QUEUE_IGNORE_STEP_FLAG))
76 cb_desc->step = sp_dmem_load_uint8(rdesc->proc_id,
77 rdesc->desc.remote.cb_desc_addr
78 + offsetof(ia_css_circbuf_desc_t, step));
80 } else if (rdesc->location == IA_CSS_QUEUE_LOC_HOST) {
81 /* doing DMA transfer of entire structure */
82 mmgr_load(rdesc->desc.remote.cb_desc_addr,
84 sizeof(ia_css_circbuf_desc_t));
85 } else if (rdesc->location == IA_CSS_QUEUE_LOC_ISP) {
86 /* Not supported yet */
93 int ia_css_queue_store(
94 struct ia_css_queue *rdesc,
95 ia_css_circbuf_desc_t *cb_desc,
96 uint32_t ignore_desc_flags)
98 if (rdesc == NULL || cb_desc == NULL)
101 if (rdesc->location == IA_CSS_QUEUE_LOC_SP) {
102 assert(ignore_desc_flags <= QUEUE_IGNORE_DESC_FLAGS_MAX);
104 if (0 == (ignore_desc_flags & QUEUE_IGNORE_SIZE_FLAG))
105 sp_dmem_store_uint8(rdesc->proc_id,
106 rdesc->desc.remote.cb_desc_addr
107 + offsetof(ia_css_circbuf_desc_t, size),
110 if (0 == (ignore_desc_flags & QUEUE_IGNORE_START_FLAG))
111 sp_dmem_store_uint8(rdesc->proc_id,
112 rdesc->desc.remote.cb_desc_addr
113 + offsetof(ia_css_circbuf_desc_t, start),
116 if (0 == (ignore_desc_flags & QUEUE_IGNORE_END_FLAG))
117 sp_dmem_store_uint8(rdesc->proc_id,
118 rdesc->desc.remote.cb_desc_addr
119 + offsetof(ia_css_circbuf_desc_t, end),
122 if (0 == (ignore_desc_flags & QUEUE_IGNORE_STEP_FLAG))
123 sp_dmem_store_uint8(rdesc->proc_id,
124 rdesc->desc.remote.cb_desc_addr
125 + offsetof(ia_css_circbuf_desc_t, step),
127 } else if (rdesc->location == IA_CSS_QUEUE_LOC_HOST) {
128 /* doing DMA transfer of entire structure */
129 mmgr_store(rdesc->desc.remote.cb_desc_addr,
131 sizeof(ia_css_circbuf_desc_t));
132 } else if (rdesc->location == IA_CSS_QUEUE_LOC_ISP) {
133 /* Not supported yet */
140 int ia_css_queue_item_load(
141 struct ia_css_queue *rdesc,
143 ia_css_circbuf_elem_t *item)
145 if (rdesc == NULL || item == NULL)
148 if (rdesc->location == IA_CSS_QUEUE_LOC_SP) {
149 sp_dmem_load(rdesc->proc_id,
150 rdesc->desc.remote.cb_elems_addr
151 + position * sizeof(ia_css_circbuf_elem_t),
153 sizeof(ia_css_circbuf_elem_t));
154 } else if (rdesc->location == IA_CSS_QUEUE_LOC_HOST) {
155 mmgr_load(rdesc->desc.remote.cb_elems_addr
156 + position * sizeof(ia_css_circbuf_elem_t),
158 sizeof(ia_css_circbuf_elem_t));
159 } else if (rdesc->location == IA_CSS_QUEUE_LOC_ISP) {
160 /* Not supported yet */
167 int ia_css_queue_item_store(
168 struct ia_css_queue *rdesc,
170 ia_css_circbuf_elem_t *item)
172 if (rdesc == NULL || item == NULL)
175 if (rdesc->location == IA_CSS_QUEUE_LOC_SP) {
176 sp_dmem_store(rdesc->proc_id,
177 rdesc->desc.remote.cb_elems_addr
178 + position * sizeof(ia_css_circbuf_elem_t),
180 sizeof(ia_css_circbuf_elem_t));
181 } else if (rdesc->location == IA_CSS_QUEUE_LOC_HOST) {
182 mmgr_store(rdesc->desc.remote.cb_elems_addr
183 + position * sizeof(ia_css_circbuf_elem_t),
185 sizeof(ia_css_circbuf_elem_t));
186 } else if (rdesc->location == IA_CSS_QUEUE_LOC_ISP) {
187 /* Not supported yet */