@@ -46,22 +46,6 @@ namespace controls = libcamera::controls;
4646namespace formats = libcamera::formats;
4747namespace properties = libcamera::properties;
4848
49- static const char *heap_positions[] = {
50- " /dev/dma_heap/vidbuf_cached" ,
51- " /dev/dma_heap/linux,cma" ,
52- };
53-
54- // https://github.com/raspberrypi/rpicam-apps/blob/6de1ab6a899df35f929b2a15c0831780bd8e750e/core/dma_heaps.cpp
55- static int create_dma_allocator () {
56- for (unsigned int i = 0 ; i < sizeof (heap_positions) / sizeof (const char *); i++) {
57- int fd = open (heap_positions[i], O_RDWR | O_CLOEXEC, 0 );
58- if (fd >= 0 ) {
59- return fd;
60- }
61- }
62- return -1 ;
63- }
64-
6549static char errbuf[256 ];
6650
6751static void set_error (const char *format, ...) {
@@ -74,6 +58,22 @@ const char *camera_get_error() {
7458 return errbuf;
7559}
7660
61+ // https://github.com/raspberrypi/rpicam-apps/blob/6de1ab6a899df35f929b2a15c0831780bd8e750e/core/dma_heaps.cpp
62+ static int create_dma_allocator () {
63+ static const char *heap_positions[] = {
64+ " /dev/dma_heap/vidbuf_cached" ,
65+ " /dev/dma_heap/linux,cma" ,
66+ };
67+
68+ for (unsigned int i = 0 ; i < sizeof (heap_positions) / sizeof (const char *); i++) {
69+ int fd = open (heap_positions[i], O_RDWR | O_CLOEXEC, 0 );
70+ if (fd >= 0 ) {
71+ return fd;
72+ }
73+ }
74+ return -1 ;
75+ }
76+
7777// https://github.com/raspberrypi/libcamera-apps/blob/dd97618a25523c2c4aa58f87af5f23e49aa6069c/core/libcamera_app.cpp#L42
7878static PixelFormat mode_to_pixel_format (sensor_mode_t *mode) {
7979 static std::vector<std::pair<std::pair<int , bool >, PixelFormat>> table = {
@@ -94,21 +94,6 @@ static PixelFormat mode_to_pixel_format(sensor_mode_t *mode) {
9494 return formats::SBGGR12_CSI2P;
9595}
9696
97- struct CameraPriv {
98- const parameters_t *params;
99- camera_frame_cb frame_cb;
100- camera_error_cb error_cb;
101- std::unique_ptr<CameraManager> camera_manager;
102- std::shared_ptr<Camera> camera;
103- Stream *video_stream;
104- std::vector<std::unique_ptr<Request>> requests;
105- std::mutex ctrls_mutex;
106- std::unique_ptr<ControlList> ctrls;
107- std::vector<std::unique_ptr<FrameBuffer>> frame_buffers;
108- std::map<FrameBuffer *, uint8_t *> mapped_buffers;
109- bool in_error;
110- };
111-
11297static int get_v4l2_colorspace (std::optional<ColorSpace> const &cs) {
11398 if (cs == ColorSpace::Rec709) {
11499 return V4L2_COLORSPACE_REC709;
@@ -133,6 +118,21 @@ static void set_hdr(bool hdr) {
133118 }
134119}
135120
121+ struct CameraPriv {
122+ const parameters_t *params;
123+ camera_frame_cb frame_cb;
124+ camera_error_cb error_cb;
125+ std::unique_ptr<CameraManager> camera_manager;
126+ std::shared_ptr<Camera> camera;
127+ Stream *video_stream;
128+ std::vector<std::unique_ptr<Request>> requests;
129+ std::mutex ctrls_mutex;
130+ std::unique_ptr<ControlList> ctrls;
131+ std::vector<std::unique_ptr<FrameBuffer>> frame_buffers;
132+ std::map<FrameBuffer *, uint8_t *> mapped_buffers;
133+ bool in_error;
134+ };
135+
136136bool camera_create (
137137 const parameters_t *params,
138138 camera_frame_cb frame_cb,
0 commit comments