@@ -19,6 +19,9 @@ using latch = Latch;
19
19
#include < libcamera/property_ids.h>
20
20
#include < libcamera/control_ids.h>
21
21
22
+ #include < sys/ioctl.h>
23
+ #include < linux/dma-buf.h>
24
+
22
25
using namespace std ::chrono;
23
26
using namespace std ::chrono_literals;
24
27
@@ -84,11 +87,6 @@ void CameraRunner::start() {
84
87
.at (grabber.streamConfiguration ().stream ())
85
88
->planes ();
86
89
87
- for (int i = 0 ; i < 3 ; i++) {
88
- // std::cout << "Plane " << (i + 1) << " has fd " << planes[i].fd.get() << " with offset " << planes[i].offset << std::endl;
89
- // std::cout << "Plane " << (i + 1) << " has fd " << planes[i].fd.get() << " with offset " << planes[i].offset << " and pitch " << static_cast<EGLint>(stride / 2) << std::endl;
90
- }
91
-
92
90
std::array<GlHsvThresholder::DmaBufPlaneData, 3 > yuv_data{{
93
91
{planes[0 ].fd .get (), static_cast <EGLint>(planes[0 ].offset ),
94
92
static_cast <EGLint>(stride)},
@@ -107,7 +105,6 @@ void CameraRunner::start() {
107
105
rangeFromColorspace (colorspace),
108
106
type);
109
107
110
-
111
108
if (out != 0 ) {
112
109
/*
113
110
From libcamera docs:
@@ -177,6 +174,15 @@ void CameraRunner::start() {
177
174
auto input_ptr = mmaped.at (data.fd );
178
175
int bound = m_width * m_height;
179
176
177
+
178
+ {
179
+ struct dma_buf_sync dma_sync {};
180
+ dma_sync.flags = DMA_BUF_SYNC_START | DMA_BUF_SYNC_RW;
181
+ int ret = ::ioctl (data.fd , DMA_BUF_IOCTL_SYNC, &dma_sync);
182
+ if (ret)
183
+ throw std::runtime_error (" failed to start DMA buf sync" );
184
+ }
185
+
180
186
if (m_copyInput) {
181
187
for (int i = 0 ; i < bound; i++) {
182
188
std::memcpy (color_out_buf + i * 3 , input_ptr + i * 4 , 3 );
@@ -188,6 +194,14 @@ void CameraRunner::start() {
188
194
processed_out_buf[i] = input_ptr[i * 4 + 3 ];
189
195
}
190
196
}
197
+
198
+ {
199
+ struct dma_buf_sync dma_sync {};
200
+ dma_sync.flags = DMA_BUF_SYNC_END | DMA_BUF_SYNC_RW;
201
+ int ret = ::ioctl (data.fd , DMA_BUF_IOCTL_SYNC, &dma_sync);
202
+ if (ret)
203
+ throw std::runtime_error (" failed to start DMA buf sync" );
204
+ }
191
205
192
206
m_thresholder.returnBuffer (data.fd );
193
207
outgoing.set (std::move (mat_pair));
0 commit comments