aboutsummaryrefslogtreecommitdiff
path: root/hsm-cam/Hsm/Cam/FFI.hs
blob: 6ee648d52e4fe28b24490a21650d57452135b0b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{-# LANGUAGE CApiFFI #-}

module Hsm.Cam.FFI
  ( frameWidth
  , frameHeight
  , makeLogger
  , registerLogger
  , makeRequestCallback
  , registerRequestCallback
  , startCameraManager
  , stopCameraManager
  , acquireCamera
  , releaseCamera
  , allocateFrameBuffer
  , freeFrameBuffer
  , startCamera
  , stopCamera
  , createRequest
  , getDmaBufferFd
  , requestFrame
  ) where

import Foreign.C.String (CString)
import Foreign.C.Types (CInt(CInt))
import Foreign.Ptr (FunPtr)
import System.Posix.Types (Fd(Fd))

type Logger = Int -> CString -> IO ()

type RequestCallback = IO ()

foreign import capi unsafe "Cam.hpp value FRAME_WIDTH" frameWidth :: Int

foreign import capi unsafe "Cam.hpp value FRAME_HEIGHT" frameHeight :: Int

foreign import ccall unsafe "wrapper" makeLogger :: Logger -> IO (FunPtr Logger)

foreign import ccall safe "Cam.hpp register_logger" registerLogger :: FunPtr Logger -> IO ()

foreign import ccall unsafe "wrapper" makeRequestCallback :: RequestCallback -> IO (FunPtr RequestCallback)

foreign import ccall safe "Cam.hpp register_request_callback" registerRequestCallback :: FunPtr RequestCallback -> IO ()

foreign import ccall safe "Cam.hpp start_camera_manager" startCameraManager :: IO Int

foreign import ccall safe "Cam.hpp stop_camera_manager" stopCameraManager :: IO ()

foreign import ccall safe "Cam.hpp acquire_camera" acquireCamera :: IO Int

foreign import ccall safe "Cam.hpp release_camera" releaseCamera :: IO ()

foreign import ccall safe "Cam.hpp allocate_frame_buffer" allocateFrameBuffer :: IO Int

foreign import ccall safe "Cam.hpp free_frame_buffer" freeFrameBuffer :: IO ()

foreign import ccall safe "Cam.hpp start_camera" startCamera :: IO Int

foreign import ccall safe "Cam.hpp stop_camera" stopCamera :: IO ()

foreign import ccall safe "Cam.hpp create_request" createRequest :: IO Int

foreign import ccall safe "Cam.hpp get_dma_buffer_fd" getDmaBufferFd :: IO Fd

foreign import ccall safe "Cam.hpp request_frame" requestFrame :: IO ()