diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/cameras/dummy.c | 24 | ||||
| -rw-r--r-- | src/cameras/dummy.h | 2 | ||||
| -rw-r--r-- | src/cameras/ipe.c | 18 | ||||
| -rw-r--r-- | src/cameras/ipe.h | 2 | ||||
| -rw-r--r-- | src/cameras/pco.c | 28 | ||||
| -rw-r--r-- | src/cameras/pco.h | 2 | ||||
| -rw-r--r-- | src/cameras/pf.c | 22 | ||||
| -rw-r--r-- | src/cameras/pf.h | 2 | ||||
| -rw-r--r-- | src/grabbers/me4.c | 24 | ||||
| -rw-r--r-- | src/grabbers/me4.h | 2 | ||||
| -rw-r--r-- | src/uca-cam.c | 20 | ||||
| -rw-r--r-- | src/uca-cam.h | 233 | ||||
| -rw-r--r-- | src/uca-grabber.h | 36 | ||||
| -rw-r--r-- | src/uca.c | 97 | ||||
| -rw-r--r-- | src/uca.h | 141 | 
15 files changed, 326 insertions, 327 deletions
| diff --git a/src/cameras/dummy.c b/src/cameras/dummy.c index 2bb0400..0283989 100644 --- a/src/cameras/dummy.c +++ b/src/cameras/dummy.c @@ -106,7 +106,7 @@ static void uca_dummy_print_number(char *buffer, int number, int x, int y, int w      }  } -static void uca_dummy_memcpy(struct uca_camera *cam, char *buffer) +static void uca_dummy_memcpy(struct uca_camera_priv *cam, char *buffer)  {      /* print current frame number */      unsigned int number = cam->current_frame; @@ -127,7 +127,7 @@ static __suseconds_t uca_dummy_time_diff(struct timeval *start, struct timeval *  static void *uca_dummy_grab_thread(void *arg)  { -    struct uca_camera *cam = ((struct uca_camera *) arg); +    struct uca_camera_priv *cam = ((struct uca_camera_priv *) arg);      struct dummy_cam *dc = GET_DUMMY(cam);      assert(dc->frame_rate > 0); @@ -156,7 +156,7 @@ static void *uca_dummy_grab_thread(void *arg)  /*   * --- interface implementations ----------------------------------------------   */ -static uint32_t uca_dummy_set_property(struct uca_camera *cam, enum uca_property_ids property, void *data) +static uint32_t uca_dummy_set_property(struct uca_camera_priv *cam, enum uca_property_ids property, void *data)  {      uint32_t err = UCA_ERR_CAMERA | UCA_ERR_PROP;      if (cam->state == UCA_CAM_RECORDING) @@ -182,7 +182,7 @@ static uint32_t uca_dummy_set_property(struct uca_camera *cam, enum uca_property      return UCA_NO_ERROR;  } -static uint32_t uca_dummy_get_property(struct uca_camera *cam, enum uca_property_ids property, void *data, size_t num) +static uint32_t uca_dummy_get_property(struct uca_camera_priv *cam, enum uca_property_ids property, void *data, size_t num)  {      switch (property) {          case UCA_PROP_NAME: @@ -223,7 +223,7 @@ static uint32_t uca_dummy_get_property(struct uca_camera *cam, enum uca_property      return UCA_NO_ERROR;  } -static uint32_t uca_dummy_start_recording(struct uca_camera *cam) +static uint32_t uca_dummy_start_recording(struct uca_camera_priv *cam)  {      if (cam->callback != NULL) {  #ifdef HAVE_PTHREADS @@ -239,7 +239,7 @@ static uint32_t uca_dummy_start_recording(struct uca_camera *cam)      return UCA_NO_ERROR;  } -static uint32_t uca_dummy_stop_recording(struct uca_camera *cam) +static uint32_t uca_dummy_stop_recording(struct uca_camera_priv *cam)  {      struct dummy_cam *dc = GET_DUMMY(cam);      if (cam->callback != NULL) { @@ -251,7 +251,7 @@ static uint32_t uca_dummy_stop_recording(struct uca_camera *cam)      return UCA_NO_ERROR;  } -static uint32_t uca_dummy_register_callback(struct uca_camera *cam, uca_cam_grab_callback cb, void *user) +static uint32_t uca_dummy_register_callback(struct uca_camera_priv *cam, uca_cam_grab_callback cb, void *user)  {      if (cam->callback == NULL) {          cam->callback = cb; @@ -263,7 +263,7 @@ static uint32_t uca_dummy_register_callback(struct uca_camera *cam, uca_cam_grab      return UCA_NO_ERROR;  } -static uint32_t uca_dummy_grab(struct uca_camera *cam, char *buffer, void *meta_data) +static uint32_t uca_dummy_grab(struct uca_camera_priv *cam, char *buffer, void *meta_data)  {      if (cam->callback != NULL)          return UCA_ERR_CAMERA | UCA_ERR_CALLBACK | UCA_ERR_ALREADY_REGISTERED; @@ -273,7 +273,7 @@ static uint32_t uca_dummy_grab(struct uca_camera *cam, char *buffer, void *meta_      return UCA_NO_ERROR;  } -static uint32_t uca_dummy_destroy(struct uca_camera *cam) +static uint32_t uca_dummy_destroy(struct uca_camera_priv *cam)  {      struct dummy_cam *dc = GET_DUMMY(cam);      free(dc->buffer); @@ -281,14 +281,14 @@ static uint32_t uca_dummy_destroy(struct uca_camera *cam)      return UCA_NO_ERROR;  } -static uint32_t uca_dummy_ignore(struct uca_camera *cam) +static uint32_t uca_dummy_ignore(struct uca_camera_priv *cam)  {      return UCA_NO_ERROR;  } -uint32_t uca_dummy_init(struct uca_camera **cam, struct uca_grabber *grabber) +uint32_t uca_dummy_init(struct uca_camera_priv **cam, struct uca_grabber_priv *grabber)  { -    struct uca_camera *uca = uca_cam_new(); +    struct uca_camera_priv *uca = uca_cam_new();      uca->destroy = &uca_dummy_destroy;      uca->set_property = &uca_dummy_set_property; diff --git a/src/cameras/dummy.h b/src/cameras/dummy.h index ebd2d48..afc6af4 100644 --- a/src/cameras/dummy.h +++ b/src/cameras/dummy.h @@ -1,6 +1,6 @@  #ifndef __UNIFIED_CAMERA_ACCESS_DUMMY_H  #define __UNIFIED_CAMERA_ACCESS_DUMMY_H -uint32_t uca_dummy_init(struct uca_camera **uca, struct uca_grabber *grabber); +uint32_t uca_dummy_init(struct uca_camera_priv **uca, struct uca_grabber_priv *grabber);  #endif diff --git a/src/cameras/ipe.c b/src/cameras/ipe.c index 1032f54..a2fa6f6 100644 --- a/src/cameras/ipe.c +++ b/src/cameras/ipe.c @@ -14,12 +14,12 @@ static void uca_ipe_handle_error(const char *format, ...)      /* Do nothing, we just check errno. */  } -static uint32_t uca_ipe_set_property(struct uca_camera *cam, enum uca_property_ids property, void *data) +static uint32_t uca_ipe_set_property(struct uca_camera_priv *cam, enum uca_property_ids property, void *data)  {      return UCA_NO_ERROR;  } -static uint32_t uca_ipe_get_property(struct uca_camera *cam, enum uca_property_ids property, void *data, size_t num) +static uint32_t uca_ipe_get_property(struct uca_camera_priv *cam, enum uca_property_ids property, void *data, size_t num)  {      pcilib_t *handle = GET_HANDLE(cam);      pcilib_register_value_t value = 0; @@ -78,22 +78,22 @@ static uint32_t uca_ipe_get_property(struct uca_camera *cam, enum uca_property_i      return UCA_NO_ERROR;  } -static uint32_t uca_ipe_start_recording(struct uca_camera *cam) +static uint32_t uca_ipe_start_recording(struct uca_camera_priv *cam)  {      return UCA_NO_ERROR;  } -static uint32_t uca_ipe_stop_recording(struct uca_camera *cam) +static uint32_t uca_ipe_stop_recording(struct uca_camera_priv *cam)  {      return UCA_NO_ERROR;  } -static uint32_t uca_ipe_grab(struct uca_camera *cam, char *buffer, void *meta_data) +static uint32_t uca_ipe_grab(struct uca_camera_priv *cam, char *buffer, void *meta_data)  {      return UCA_NO_ERROR;  } -static uint32_t uca_ipe_register_callback(struct uca_camera *cam, uca_cam_grab_callback cb, void *user) +static uint32_t uca_ipe_register_callback(struct uca_camera_priv *cam, uca_cam_grab_callback cb, void *user)  {      if (cam->callback == NULL) {          cam->callback = cb; @@ -103,13 +103,13 @@ static uint32_t uca_ipe_register_callback(struct uca_camera *cam, uca_cam_grab_c      return UCA_ERR_CAMERA | UCA_ERR_CALLBACK | UCA_ERR_ALREADY_REGISTERED;  } -static uint32_t uca_ipe_destroy(struct uca_camera *cam) +static uint32_t uca_ipe_destroy(struct uca_camera_priv *cam)  {      pcilib_close(GET_HANDLE(cam));      return UCA_NO_ERROR;  } -uint32_t uca_ipe_init(struct uca_camera **cam, struct uca_grabber *grabber) +uint32_t uca_ipe_init(struct uca_camera_priv **cam, struct uca_grabber_priv *grabber)  {      pcilib_model_t model = PCILIB_MODEL_DETECT;      pcilib_t *handle = pcilib_open("/dev/fpga0", model); @@ -119,7 +119,7 @@ uint32_t uca_ipe_init(struct uca_camera **cam, struct uca_grabber *grabber)      pcilib_set_error_handler(&uca_ipe_handle_error, &uca_ipe_handle_error);      model = pcilib_get_model(handle); -    struct uca_camera *uca = uca_cam_new(); +    struct uca_camera_priv *uca = uca_cam_new();      /* Camera found, set function pointers... */      uca->destroy = &uca_ipe_destroy; diff --git a/src/cameras/ipe.h b/src/cameras/ipe.h index 4fc39bd..c911402 100644 --- a/src/cameras/ipe.h +++ b/src/cameras/ipe.h @@ -1,6 +1,6 @@  #ifndef __UNIFIED_CAMERA_ACCESS_IPE_H  #define __UNIFIED_CAMERA_ACCESS_IPE_H -uint32_t uca_ipe_init(struct uca_camera **uca, struct uca_grabber *grabber); +uint32_t uca_ipe_init(struct uca_camera_priv **uca, struct uca_grabber_priv *grabber);  #endif diff --git a/src/cameras/pco.c b/src/cameras/pco.c index f6efd81..9de6467 100644 --- a/src/cameras/pco.c +++ b/src/cameras/pco.c @@ -18,7 +18,7 @@ typedef struct pco_desc {  #define uca_set_void(p, type, value) { *((type *) p) = (type) value; } -static uint32_t uca_pco_set_exposure(struct uca_camera *cam, uint32_t *exposure) +static uint32_t uca_pco_set_exposure(struct uca_camera_priv *cam, uint32_t *exposure)  {      uint32_t err = UCA_ERR_CAMERA | UCA_ERR_PROP;      uint32_t e, d; @@ -29,7 +29,7 @@ static uint32_t uca_pco_set_exposure(struct uca_camera *cam, uint32_t *exposure)      return UCA_NO_ERROR;  } -static uint32_t uca_pco_set_delay(struct uca_camera *cam, uint32_t *delay) +static uint32_t uca_pco_set_delay(struct uca_camera_priv *cam, uint32_t *delay)  {      uint32_t err = UCA_ERR_CAMERA | UCA_ERR_PROP;      uint32_t e, d; @@ -40,7 +40,7 @@ static uint32_t uca_pco_set_delay(struct uca_camera *cam, uint32_t *delay)      return UCA_NO_ERROR;  } -static uint32_t uca_pco_destroy(struct uca_camera *cam) +static uint32_t uca_pco_destroy(struct uca_camera_priv *cam)  {      pco_set_rec_state(GET_PCO(cam), 0);      pco_destroy(GET_PCO(cam)); @@ -48,9 +48,9 @@ static uint32_t uca_pco_destroy(struct uca_camera *cam)      return UCA_NO_ERROR;  } -static uint32_t uca_pco_set_property(struct uca_camera *cam, enum uca_property_ids property, void *data) +static uint32_t uca_pco_set_property(struct uca_camera_priv *cam, enum uca_property_ids property, void *data)  { -    struct uca_grabber *grabber = cam->grabber; +    struct uca_grabber_priv *grabber = cam->grabber;      struct pco_desc *pco_d = GET_PCO_DESC(cam);      uint32_t err = UCA_ERR_CAMERA | UCA_ERR_PROP; @@ -97,10 +97,10 @@ static uint32_t uca_pco_set_property(struct uca_camera *cam, enum uca_property_i  } -static uint32_t uca_pco_get_property(struct uca_camera *cam, enum uca_property_ids property, void *data, size_t num) +static uint32_t uca_pco_get_property(struct uca_camera_priv *cam, enum uca_property_ids property, void *data, size_t num)  {      struct pco_edge *pco = GET_PCO(cam); -    struct uca_grabber *grabber = cam->grabber; +    struct uca_grabber_priv *grabber = cam->grabber;      switch (property) {          case UCA_PROP_NAME:  @@ -225,7 +225,7 @@ static uint32_t uca_pco_get_property(struct uca_camera *cam, enum uca_property_i      return UCA_NO_ERROR;  } -static uint32_t uca_pco_start_recording(struct uca_camera *cam) +static uint32_t uca_pco_start_recording(struct uca_camera_priv *cam)  {      uint32_t err = UCA_ERR_CAMERA | UCA_ERR_INIT;      if (cam->state == UCA_CAM_RECORDING) @@ -241,7 +241,7 @@ static uint32_t uca_pco_start_recording(struct uca_camera *cam)      return cam->grabber->acquire(cam->grabber, -1);  } -static uint32_t uca_pco_stop_recording(struct uca_camera *cam) +static uint32_t uca_pco_stop_recording(struct uca_camera_priv *cam)  {      if ((cam->state == UCA_CAM_RECORDING) && (pco_set_rec_state(GET_PCO(cam), 0) != PCO_NOERROR))          return UCA_ERR_CAMERA | UCA_ERR_INIT | UCA_ERR_UNCLASSIFIED; @@ -250,7 +250,7 @@ static uint32_t uca_pco_stop_recording(struct uca_camera *cam)      return UCA_NO_ERROR;  } -static uint32_t uca_pco_trigger(struct uca_camera *cam) +static uint32_t uca_pco_trigger(struct uca_camera_priv *cam)  {      if (cam->state != UCA_CAM_RECORDING)          return UCA_ERR_CAMERA | UCA_ERR_TRIGGER | UCA_ERR_NOT_RECORDING; @@ -258,7 +258,7 @@ static uint32_t uca_pco_trigger(struct uca_camera *cam)      return cam->grabber->trigger(cam->grabber);  } -static uint32_t uca_pco_grab(struct uca_camera *cam, char *buffer, void *meta_data) +static uint32_t uca_pco_grab(struct uca_camera_priv *cam, char *buffer, void *meta_data)  {      if (cam->state != UCA_CAM_RECORDING)          return UCA_ERR_CAMERA | UCA_ERR_NOT_RECORDING; @@ -272,7 +272,7 @@ static uint32_t uca_pco_grab(struct uca_camera *cam, char *buffer, void *meta_da      return UCA_NO_ERROR;  } -static uint32_t uca_pco_register_callback(struct uca_camera *cam, uca_cam_grab_callback callback, void *user) +static uint32_t uca_pco_register_callback(struct uca_camera_priv *cam, uca_cam_grab_callback callback, void *user)  {      if (cam->callback == NULL) {          cam->callback = callback; @@ -282,7 +282,7 @@ static uint32_t uca_pco_register_callback(struct uca_camera *cam, uca_cam_grab_c      return UCA_ERR_CAMERA | UCA_ERR_CALLBACK | UCA_ERR_ALREADY_REGISTERED;  } -uint32_t uca_pco_init(struct uca_camera **cam, struct uca_grabber *grabber) +uint32_t uca_pco_init(struct uca_camera_priv **cam, struct uca_grabber_priv *grabber)  {      uint32_t err = UCA_ERR_CAMERA | UCA_ERR_INIT;      if (grabber == NULL) @@ -297,7 +297,7 @@ uint32_t uca_pco_init(struct uca_camera **cam, struct uca_grabber *grabber)          return err | UCA_ERR_NOT_FOUND;      } -    struct uca_camera *uca = uca_cam_new(); +    struct uca_camera_priv *uca = uca_cam_new();      uca->grabber = grabber;      uca->grabber->synchronous = false; diff --git a/src/cameras/pco.h b/src/cameras/pco.h index d8c2b07..194ea6c 100644 --- a/src/cameras/pco.h +++ b/src/cameras/pco.h @@ -1,6 +1,6 @@  #ifndef __UNIFIED_CAMERA_ACCESS_PCO_H  #define __UNIFIED_CAMERA_ACCESS_PCO_H -uint32_t uca_pco_init(struct uca_camera **uca, struct uca_grabber *grabber); +uint32_t uca_pco_init(struct uca_camera_priv **uca, struct uca_grabber_priv *grabber);  #endif diff --git a/src/cameras/pf.c b/src/cameras/pf.c index 5a87380..32ca834 100644 --- a/src/cameras/pf.c +++ b/src/cameras/pf.c @@ -47,9 +47,9 @@ static int uca_pf_set_uint32_property(TOKEN token, void *data, uint32_t *update_      return pfDevice_SetProperty(0, token, &value);  } -static uint32_t uca_pf_set_property(struct uca_camera *cam, enum uca_property_ids property, void *data) +static uint32_t uca_pf_set_property(struct uca_camera_priv *cam, enum uca_property_ids property, void *data)  { -    struct uca_grabber *grabber = cam->grabber; +    struct uca_grabber_priv *grabber = cam->grabber;      TOKEN token = INVALID_TOKEN;      int i = 0;      int err = UCA_NO_ERROR; @@ -105,7 +105,7 @@ static uint32_t uca_pf_set_property(struct uca_camera *cam, enum uca_property_id  } -static uint32_t uca_pf_get_property(struct uca_camera *cam, enum uca_property_ids property, void *data, size_t num) +static uint32_t uca_pf_get_property(struct uca_camera_priv *cam, enum uca_property_ids property, void *data, size_t num)  {      TOKEN t;    /* You gotta love developers who name types capitalized... */      PFValue value; @@ -161,22 +161,22 @@ static uint32_t uca_pf_get_property(struct uca_camera *cam, enum uca_property_id      return cam->grabber->get_property(cam->grabber, property, data);  } -static uint32_t uca_pf_start_recording(struct uca_camera *cam) +static uint32_t uca_pf_start_recording(struct uca_camera_priv *cam)  {      return cam->grabber->acquire(cam->grabber, -1);  } -static uint32_t uca_pf_stop_recording(struct uca_camera *cam) +static uint32_t uca_pf_stop_recording(struct uca_camera_priv *cam)  {      return cam->grabber->stop_acquire(cam->grabber);  } -static uint32_t uca_pf_trigger(struct uca_camera *cam) +static uint32_t uca_pf_trigger(struct uca_camera_priv *cam)  {      return cam->grabber->trigger(cam->grabber);  } -static uint32_t uca_pf_grab(struct uca_camera *cam, char *buffer, void *metadata) +static uint32_t uca_pf_grab(struct uca_camera_priv *cam, char *buffer, void *metadata)  {      uint16_t *frame;      uint32_t err = cam->grabber->grab(cam->grabber, (void **) &frame, &cam->current_frame); @@ -187,7 +187,7 @@ static uint32_t uca_pf_grab(struct uca_camera *cam, char *buffer, void *metadata      return UCA_NO_ERROR;  } -static uint32_t uca_pf_register_callback(struct uca_camera *cam, uca_cam_grab_callback callback, void *user) +static uint32_t uca_pf_register_callback(struct uca_camera_priv *cam, uca_cam_grab_callback callback, void *user)  {      if (cam->callback == NULL) {          cam->callback = callback; @@ -197,13 +197,13 @@ static uint32_t uca_pf_register_callback(struct uca_camera *cam, uca_cam_grab_ca      return UCA_ERR_CAMERA | UCA_ERR_CALLBACK | UCA_ERR_ALREADY_REGISTERED;  } -static uint32_t uca_pf_destroy(struct uca_camera *cam) +static uint32_t uca_pf_destroy(struct uca_camera_priv *cam)  {      pfDeviceClose(0);      return UCA_NO_ERROR;  } -uint32_t uca_pf_init(struct uca_camera **cam, struct uca_grabber *grabber) +uint32_t uca_pf_init(struct uca_camera_priv **cam, struct uca_grabber_priv *grabber)  {      int num_ports;      if ((grabber == NULL) || (pfPortInit(&num_ports) < 0) || (pfDeviceOpen(0) < 0)) @@ -212,7 +212,7 @@ uint32_t uca_pf_init(struct uca_camera **cam, struct uca_grabber *grabber)      /* We could check if a higher baud rate is supported, but... forget about       * it. We don't need high speed configuration. */ -    struct uca_camera *uca = uca_cam_new(); +    struct uca_camera_priv *uca = uca_cam_new();      uca->grabber = grabber;      uca->grabber->synchronous = false; diff --git a/src/cameras/pf.h b/src/cameras/pf.h index d7bf85b..c5d4918 100644 --- a/src/cameras/pf.h +++ b/src/cameras/pf.h @@ -1,6 +1,6 @@  #ifndef __UNIFIED_CAMERA_ACCESS_PHOTON_H  #define __UNIFIED_CAMERA_ACCESS_PHOTON_H -uint32_t uca_pf_init(struct uca_camera **uca, struct uca_grabber *grabber); +uint32_t uca_pf_init(struct uca_camera_priv **uca, struct uca_grabber_priv *grabber);  #endif diff --git a/src/grabbers/me4.c b/src/grabbers/me4.c index f0120bb..1117fbf 100644 --- a/src/grabbers/me4.c +++ b/src/grabbers/me4.c @@ -52,7 +52,7 @@ static struct uca_sisofg_map_t uca_to_fg[] = {  #define GET_FG(grabber) (((struct fg_apc_data *) grabber->user)->fg)  #define GET_MEM(grabber) (((struct fg_apc_data *) grabber->user)->mem) -static uint32_t uca_me4_destroy(struct uca_grabber *grabber) +static uint32_t uca_me4_destroy(struct uca_grabber_priv *grabber)  {      if (grabber != NULL) {          Fg_FreeMemEx(GET_FG(grabber), GET_MEM(grabber)); @@ -85,7 +85,7 @@ static struct uca_sisofg_map_t *uca_me4_find_uca_property(int fg_id)      return NULL;  } -static uint32_t uca_me4_set_property(struct uca_grabber *grabber, int32_t property, void *data) +static uint32_t uca_me4_set_property(struct uca_grabber_priv *grabber, int32_t property, void *data)  {      /* Handle all properties not related specifically to the me4 */      union uca_value *v = (union uca_value *) data; @@ -123,7 +123,7 @@ static uint32_t uca_me4_set_property(struct uca_grabber *grabber, int32_t proper              UCA_NO_ERROR : err | UCA_ERR_INVALID;  } -static uint32_t uca_me4_get_property(struct uca_grabber *grabber, int32_t property, void *data) +static uint32_t uca_me4_get_property(struct uca_grabber_priv *grabber, int32_t property, void *data)  {      switch (property) {          case UCA_PROP_GRAB_SYNCHRONOUS: @@ -157,7 +157,7 @@ static uint32_t uca_me4_get_property(struct uca_grabber *grabber, int32_t proper          UCA_NO_ERROR : err | UCA_ERR_INVALID;  } -static uint32_t uca_me4_alloc(struct uca_grabber *grabber, uint32_t pixel_size, uint32_t n_buffers) +static uint32_t uca_me4_alloc(struct uca_grabber_priv *grabber, uint32_t pixel_size, uint32_t n_buffers)  {      dma_mem *mem = GET_MEM(grabber);      /* If buffers are already allocated, we are freeing every buffer and start @@ -177,7 +177,7 @@ static uint32_t uca_me4_alloc(struct uca_grabber *grabber, uint32_t pixel_size,      return UCA_ERR_GRABBER | UCA_ERR_NO_MEMORY;  } -static uint32_t uca_me4_acquire(struct uca_grabber *grabber, int32_t n_frames) +static uint32_t uca_me4_acquire(struct uca_grabber_priv *grabber, int32_t n_frames)  {      if (GET_MEM(grabber) == NULL)          return UCA_ERR_GRABBER | UCA_ERR_NO_MEMORY; @@ -189,7 +189,7 @@ static uint32_t uca_me4_acquire(struct uca_grabber *grabber, int32_t n_frames)      return UCA_ERR_GRABBER | UCA_ERR_ACQUIRE;  } -static uint32_t uca_me4_stop_acquire(struct uca_grabber *grabber) +static uint32_t uca_me4_stop_acquire(struct uca_grabber_priv *grabber)  {      if (GET_MEM(grabber) != NULL)          if (Fg_stopAcquireEx(GET_FG(grabber), 0, GET_MEM(grabber), STOP_SYNC) != FG_OK) @@ -197,14 +197,14 @@ static uint32_t uca_me4_stop_acquire(struct uca_grabber *grabber)      return UCA_NO_ERROR;  } -static uint32_t uca_me4_trigger(struct uca_grabber *grabber) +static uint32_t uca_me4_trigger(struct uca_grabber_priv *grabber)  {      if (Fg_sendSoftwareTrigger(GET_FG(grabber), PORT_A) != FG_OK)          return UCA_ERR_GRABBER | UCA_ERR_TRIGGER;      return UCA_NO_ERROR;  } -static uint32_t uca_me4_grab(struct uca_grabber *grabber, void **buffer, uint64_t *frame_number) +static uint32_t uca_me4_grab(struct uca_grabber_priv *grabber, void **buffer, uint64_t *frame_number)  {      static frameindex_t last_frame = 0;      struct fg_apc_data *me4 = (struct fg_apc_data *) grabber->user; @@ -228,7 +228,7 @@ static int uca_me4_callback(frameindex_t frame, struct fg_apc_data *apc)      return 0;  } -static uint32_t uca_me4_register_callback(struct uca_grabber *grabber, uca_cam_grab_callback callback, void *meta_data, void *user) +static uint32_t uca_me4_register_callback(struct uca_grabber_priv *grabber, uca_cam_grab_callback callback, void *meta_data, void *user)  {      if (GET_MEM(grabber) == NULL)          return UCA_ERR_GRABBER | UCA_ERR_CALLBACK | UCA_ERR_NO_MEMORY; @@ -257,14 +257,14 @@ static uint32_t uca_me4_register_callback(struct uca_grabber *grabber, uca_cam_g      return UCA_NO_ERROR;  } -uint32_t uca_me4_init(struct uca_grabber **grabber) +uint32_t uca_me4_init(struct uca_grabber_priv **grabber)  {      Fg_Struct *fg = Fg_Init("libFullAreaGray8.so", 0);      if (fg == NULL)          return UCA_ERR_GRABBER | UCA_ERR_NOT_FOUND; -    struct uca_grabber *uca = (struct uca_grabber *) malloc(sizeof(struct uca_grabber)); -    memset(uca, 0, sizeof(struct uca_grabber)); +    struct uca_grabber_priv *uca = (struct uca_grabber_priv *) malloc(sizeof(struct uca_grabber_priv)); +    memset(uca, 0, sizeof(struct uca_grabber_priv));      struct fg_apc_data *me4 = (struct fg_apc_data *) malloc(sizeof(struct fg_apc_data));      memset(me4, 0, sizeof(struct fg_apc_data)); diff --git a/src/grabbers/me4.h b/src/grabbers/me4.h index 4021f6a..96a596b 100644 --- a/src/grabbers/me4.h +++ b/src/grabbers/me4.h @@ -1,6 +1,6 @@  #ifndef __UNIFIED_CAMERA_ACCESS_ME4_H  #define __UNIFIED_CAMERA_ACCESS_ME4_H -uint32_t uca_me4_init(struct uca_grabber **grabber); +uint32_t uca_me4_init(struct uca_grabber_priv **grabber);  #endif diff --git a/src/uca-cam.c b/src/uca-cam.c index 7b80f56..0225fa1 100644 --- a/src/uca-cam.c +++ b/src/uca-cam.c @@ -5,28 +5,14 @@  #include "uca-cam.h"  #include "uca-grabber.h" -uint32_t uca_cam_alloc(struct uca_camera *cam, uint32_t n_buffers) -{ -    uint32_t bitdepth; -    cam->get_property(cam, UCA_PROP_BITDEPTH, &bitdepth, 0); -    const int pixel_size = bitdepth == 8 ? 1 : 2; -    if (cam->grabber != NULL) -        return cam->grabber->alloc(cam->grabber, pixel_size, n_buffers); -    return UCA_NO_ERROR; -} - -enum uca_cam_state uca_cam_get_state(struct uca_camera *cam) -{ -    return cam->state; -} -struct uca_camera *uca_cam_new(void) +struct uca_camera_priv *uca_cam_new(void)  { -    struct uca_camera *cam = (struct uca_camera *) malloc(sizeof(struct uca_camera)); +    struct uca_camera_priv *cam = (struct uca_camera_priv *) malloc(sizeof(struct uca_camera_priv));      /* Set all function pointers to NULL so we know early on, if something has       * not been implemented. */ -    memset(cam, 0, sizeof(struct uca_camera)); +    memset(cam, 0, sizeof(struct uca_camera_priv));      cam->state = UCA_CAM_CONFIGURABLE;      cam->current_frame = 0; diff --git a/src/uca-cam.h b/src/uca-cam.h index ba5e101..cd97ea9 100644 --- a/src/uca-cam.h +++ b/src/uca-cam.h @@ -11,7 +11,7 @@ extern "C" {   * \file uca-cam.h   * \brief Abstract camera model   * - * The uca_camera_t structure represents a common interface for cameras regardless of + * The uca_camera_priv_t structure represents a common interface for cameras regardless of   * their connectivity. Each camera that adheres to this model must provide an   * initialization function implementing uca_cam_init() that probes the device   * and sets all function pointers to their respective implementations. @@ -31,234 +31,39 @@ enum uca_cam_state {  /*   * --- non-virtual methods ----------------------------------------------------   */ +typedef uint32_t (*uca_cam_init) (struct uca_camera_priv **cam, struct uca_grabber_priv *grabber);  /** - * Allocates buffer memory for the internal frame grabber. - * - * The allocation is just a hint to the underlying camera driver. It might - * ignore this or pass this information on to a related frame grabber. - * - * \param[in] cam A camera structure. - *  - * \param[in] n_buffers Number of sub-buffers with size frame_width*frame_height. - */ -/* FIXME: put this into vtable?! */ -uint32_t uca_cam_alloc(struct uca_camera *cam, uint32_t n_buffers); - - -/** - * Retrieve current state of the camera. - * - * \param[in] cam A camera structure. - * - * \return A value from the uca_cam_state enum representing the current state of - *   the camera. - */ -enum uca_cam_state uca_cam_get_state(struct uca_camera *cam); - -/** - * Allocates memory for a new uca_camera structure and initializes all fields to + * Allocates memory for a new uca_camera_priv structure and initializes all fields to   * sane values.   * - * \return Pointer to block of memory for a uca_camera structure + * \return Pointer to block of memory for a uca_camera_priv structure   *   * \note This is is a utility function used internally by drivers   */ -struct uca_camera *uca_cam_new(void); - -/* - * --- virtual methods -------------------------------------------------------- - */ - -/** - * Function pointer for camera probing and initialization.  - * - * \param[out] cam On success, *cam holds the newly created uca_camera_t - *   structure. - * - * \param[in] grabber Grabber structure to access the cam. Can be NULL to - *   specify devices without frame grabber access. - * - * \return  - *   UCA_ERR_INIT_NOT_FOUND if camera is not found or could not be initialized - * - * \note This is a private function and should be called exclusively by uca_init(). - */ -typedef uint32_t (*uca_cam_init) (struct uca_camera **cam, struct uca_grabber *grabber); - -/** - * \brief Function pointer to free camera resources. - * - * \param[in] cam The camera to close. - * - * \note This is a private function and should be called exclusively by uca_init(). - */ -typedef uint32_t (*uca_cam_destroy) (struct uca_camera *cam); - -/** - * Function pointer to set a camera property. - * - * \param[in] cam The camera whose properties are to be set. - * - * \param[in] property ID of the property as defined in XXX - * - * \param[out] data Where to read the property's value from - * - * \return UCA_ERR_PROP_INVALID if property is not supported on the camera or - *   UCA_ERR_PROP_VALUE_OUT_OF_RANGE if value cannot be set. - */ -typedef uint32_t (*uca_cam_set_property) (struct uca_camera *cam, enum uca_property_ids property, void *data); - -/** - * Function pointer to get a property. - * - * \param[in] cam The camera whose properties are to be retrieved. - * - * \param[in] property ID of the property as defined in XXX - * - * \param[out] data Where to store the property's value - * - * \param[in] num Number of bytes of string storage. Ignored for uca_uint8t - *   and uca_uint32t properties. - * - * \return UCA_ERR_PROP_INVALID if property is not supported on the camera - */ -typedef uint32_t (*uca_cam_get_property) (struct uca_camera *cam, enum uca_property_ids property, void *data, size_t num); - -/** - * Begin recording. - * - * Usually this also involves the frame acquisition of the frame grabber but is - * hidden by this function. - */ -typedef uint32_t (*uca_cam_start_recording) (struct uca_camera *cam); - -/** - * Stop recording. - */ -typedef uint32_t (*uca_cam_stop_recording) (struct uca_camera *cam); - -/** - * Send a software trigger signal to start a sensor read-out. - * - * This method is only useful when UCA_PROP_TRIGGER_MODE is set to - * UCA_TRIGGER_SOFTWARE. - */ -typedef uint32_t (*uca_cam_trigger) (struct uca_camera *cam); - -/** - * Function pointer to a grab callback. - *  - * Register such a callback function with uca_cam_register_callback() to - * receive data as soon as it is delivered. - * - * \param[in] image_number Current frame number - * - * \param[in] buffer Image data - * - * \param[in] meta_data Meta data provided by the camera specifying per-frame - *   data. - * - * \param[in] user User data registered in uca_cam_register_callback() - * - * \note The meta data parameter is not yet specified but just a place holder. - */ -typedef void (*uca_cam_grab_callback) (uint64_t image_number, void *buffer, void *meta_data, void *user); - -/** - * Register callback for given frame grabber. To actually start receiving - * frames, call uca_grabber_acquire(). - * - * \param[in] grabber The grabber for which the callback should be installed - * - * \param[in] callback Callback function for when a frame arrived - * - * \param[in] user User data that is passed to the callback function - */ -typedef uint32_t (*uca_cam_register_callback) (struct uca_camera *cam, uca_cam_grab_callback callback, void *user); - -/** - * \brief Grab one image from the camera - *  - * The grabbing involves a memory copy because we might have to decode the image - * coming from the camera, which the frame grabber is not able to do. - * - * \param[in] buffer Destination buffer - * - * \param[in] meta_data Meta data provided by the camera specifying per-frame - *   data. - * - * \note The meta data parameter is not yet specified but just a place holder. - * - */ -typedef uint32_t (*uca_cam_grab) (struct uca_camera *cam, char *buffer, void *meta_data); - - +struct uca_camera_priv *uca_cam_new(void);  /**   * Represents a camera abstraction, that concrete cameras must implement.   */ -typedef struct uca_camera { +typedef struct uca_camera_priv {      /**       * Points to the next available camera in a linked-list fashion.       *       * End of list is specified with next == NULL.       */ -    struct uca_camera     *next; - -    /* Function pointers to camera-specific methods */ -    /** -     * Method to set a property. -     * \see uca_cam_set_property -     */ -    uca_cam_set_property    set_property; - -    /** -     * Method to get a property. -     * \see uca_cam_get_property -     */ -    uca_cam_get_property    get_property; - -    /** -     * Method to start recording. -     * \see uca_cam_start_recording -     */ -    uca_cam_start_recording start_recording; - -    /** -     * Method to stop recording. -     * \see uca_cam_stop_recording -     */ -    uca_cam_stop_recording  stop_recording; - -    /** -     * Method to issue a software trigger signal. -     * \see uca_cam_trigger -     */ -    uca_cam_trigger trigger; - -    /** -     * Method to grab a frame. -     * \see uca_cam_grab -     */ -    uca_cam_grab            grab; - -    /** -     * Method to register an frame acquisition callback. -     * -     * \see uca_cam_register_callback -     */ -    uca_cam_register_callback   register_callback; - -    /* Private */ -    /** -     * Method to close the camera. -     * \see uca_cam_destroy -     */ -    uca_cam_destroy         destroy; - -    /* private */ -    struct uca_grabber      *grabber;       /**< grabber associated with this camera */ +    struct uca_camera_priv     *next; + +    uint32_t (*destroy) (struct uca_camera_priv *cam); +    uint32_t (*set_property) (struct uca_camera_priv *cam, enum uca_property_ids property, void *data); +    uint32_t (*get_property) (struct uca_camera_priv *cam, enum uca_property_ids property, void *data, size_t num); +    uint32_t (*start_recording) (struct uca_camera_priv *cam); +    uint32_t (*stop_recording) (struct uca_camera_priv *cam); +    uint32_t (*trigger) (struct uca_camera_priv *cam); +    uint32_t (*register_callback) (struct uca_camera_priv *cam, uca_cam_grab_callback callback, void *user); +    uint32_t (*grab) (struct uca_camera_priv *cam, char *buffer, void *meta_data); + +    struct uca_grabber_priv *grabber;       /**< grabber associated with this camera */      enum uca_cam_state      state;          /**< camera state */      uint32_t                frame_width;    /**< current frame width */      uint32_t                frame_height;   /**< current frame height */ @@ -268,7 +73,7 @@ typedef struct uca_camera {      void                    *callback_user; /**< user data for callback */      void                    *user;          /**< private user data to be used by the camera driver */ -} uca_camera_t; +} uca_camera_priv_t;  #ifdef __cplusplus diff --git a/src/uca-grabber.h b/src/uca-grabber.h index e8b422a..f30233b 100644 --- a/src/uca-grabber.h +++ b/src/uca-grabber.h @@ -36,38 +36,38 @@ enum uca_grabber_constants {   *   * \return UCA_ERR_INIT_NOT_FOUND if grabber is not found or could not be initialized   */ -typedef uint32_t (*uca_grabber_init) (struct uca_grabber **grabber); +typedef uint32_t (*uca_grabber_init) (struct uca_grabber_priv **grabber);  /**   * Free frame grabber resouces.   */ -typedef uint32_t (*uca_grabber_destroy) (struct uca_grabber *grabber); +typedef uint32_t (*uca_grabber_destroy) (struct uca_grabber_priv *grabber);  /**   * Set a frame grabber property.   * - * \param[in] prop Name of the property as defined in uca_grabber_constants + * \param[in] prop Name of the property as defined in uca_grabber_priv_constants   *   * \return UCA_ERR_PROP_INVALID if property is not supported on the frame   *   grabber or UCA_ERR_PROP_VALUE_OUT_OF_RANGE if value cannot be set.   */ -typedef uint32_t (*uca_grabber_set_property) (struct uca_grabber *grabber, enum uca_grabber_constants prop, void *data); +typedef uint32_t (*uca_grabber_set_property) (struct uca_grabber_priv *grabber, enum uca_grabber_constants prop, void *data);  /**   * Get a frame grabber property.   * - * \param[in] prop Name of the property as defined in uca_grabber_constants + * \param[in] prop Name of the property as defined in uca_grabber_priv_constants   *    * \return UCA_ERR_PROP_INVALID if property is not supported on the frame grabber    */ -typedef uint32_t (*uca_grabber_get_property) (struct uca_grabber *grabber, enum uca_grabber_constants prop, void *data); +typedef uint32_t (*uca_grabber_get_property) (struct uca_grabber_priv *grabber, enum uca_grabber_constants prop, void *data);  /**   * Allocate buffers with current width, height and bitdepth.   *   * \warning Subsequent changes of width and height might corrupt memory.   */ -typedef uint32_t (*uca_grabber_alloc) (struct uca_grabber *grabber, uint32_t pixel_size, uint32_t n_buffers); +typedef uint32_t (*uca_grabber_alloc) (struct uca_grabber_priv *grabber, uint32_t pixel_size, uint32_t n_buffers);  /**   * Begin acquiring frames. @@ -76,17 +76,17 @@ typedef uint32_t (*uca_grabber_alloc) (struct uca_grabber *grabber, uint32_t pix   *   * \param[in] async Grab asynchronous if true   */ -typedef uint32_t (*uca_grabber_acquire) (struct uca_grabber *grabber, int32_t n_frames); +typedef uint32_t (*uca_grabber_acquire) (struct uca_grabber_priv *grabber, int32_t n_frames);  /**   * Stop acquiring frames.   */ -typedef uint32_t (*uca_grabber_stop_acquire) (struct uca_grabber *grabber); +typedef uint32_t (*uca_grabber_stop_acquire) (struct uca_grabber_priv *grabber);  /**   * Issue a software trigger signal.   */ -typedef uint32_t (*uca_grabber_trigger) (struct uca_grabber *grabber); +typedef uint32_t (*uca_grabber_trigger) (struct uca_grabber_priv *grabber);  /**   * Grab a frame. @@ -97,30 +97,30 @@ typedef uint32_t (*uca_grabber_trigger) (struct uca_grabber *grabber);   *   * \param[out] frame_number Number of the grabbed frame   */ -typedef uint32_t (*uca_grabber_grab) (struct uca_grabber *grabber, void **buffer, uint64_t *frame_number); +typedef uint32_t (*uca_grabber_grab) (struct uca_grabber_priv *grabber, void **buffer, uint64_t *frame_number);  /**   * Register callback for given frame grabber. To actually start receiving - * frames, call uca_grabber_acquire(). + * frames, call uca_grabber_priv_acquire().   *   * \param[in] grabber The grabber for which the callback should be installed   *   * \param[in] cb Callback function for when a frame arrived   */ -typedef uint32_t (*uca_grabber_register_callback) (struct uca_grabber *grabber, uca_cam_grab_callback cb, void *meta_data, void *user); +typedef uint32_t (*uca_grabber_register_callback) (struct uca_grabber_priv *grabber, uca_cam_grab_callback cb, void *meta_data, void *user);  /**   * Represents a frame grabber abstraction, that concrete frame grabber   * implementations must implement.   * - * A uca_grabber_t structure is never used directly but only via the + * A uca_grabber_priv_t structure is never used directly but only via the   * uca_camera_t interface in order to keep certain duplicated properties in sync   * (e.g. image dimensions can be set on frame grabber and camera).   */ -typedef struct uca_grabber { -    struct uca_grabber    *next; +typedef struct uca_grabber_priv { +    struct uca_grabber_priv    *next;      /* Function pointers to grabber-specific methods */      uca_grabber_destroy      destroy; @@ -135,9 +135,9 @@ typedef struct uca_grabber {      /* Private */      uca_cam_grab_callback   callback; -    bool synchronous;   /**< if true uca_grabber_grab() blocks until image is transferred */ +    bool synchronous;   /**< if true uca_grabber_priv_grab() blocks until image is transferred */      void *user; -} uca_grabber_t; +} uca_grabber_priv_t; @@ -136,10 +136,10 @@ struct uca *uca_init(const char *config_filename)      /* Probe each frame grabber that is configured */      int i = 0; -    struct uca_grabber *grabber = NULL; +    struct uca_grabber_priv *grabber = NULL;      while (grabber_inits[i] != NULL) {          uca_grabber_init init = grabber_inits[i]; -        /* FIXME: we don't only want to take the first one */ +        /* FIXME: we don't want to take the only first one */          if (init(&grabber) == UCA_NO_ERROR)              break;          i++; @@ -150,23 +150,30 @@ struct uca *uca_init(const char *config_filename)       * therefore we also probe each camera against the NULL grabber. However,       * each camera must make sure to check for such a situation. */ -    g_uca->grabbers = grabber; -    if (grabber != NULL) -        grabber->next = NULL; +    if (grabber != NULL) { +        g_uca->grabbers = (struct uca_grabber *) malloc(sizeof(struct uca_grabber)); +        g_uca->grabbers->priv = grabber; +        g_uca->grabbers->next = NULL; +    }      i = 0;      struct uca_camera *current = NULL;      /* Probe each camera that is configured and append a found camera to the       * linked list. */      while (cam_inits[i] != NULL) { -        struct uca_camera *cam = NULL; +        struct uca_camera_priv *cam = NULL;          uca_cam_init init = cam_inits[i];          if (init(&cam, grabber) == UCA_NO_ERROR) { -            if (current == NULL)  -                g_uca->cameras = current = cam; +            if (current == NULL) { +                g_uca->cameras = (struct uca_camera *) malloc(sizeof(struct uca_camera)); +                g_uca->cameras->priv = cam; +                g_uca->cameras->next = NULL; +                current = g_uca->cameras; +            }              else { -                current->next = cam; -                current = cam; +                current->next = (struct uca_camera *) malloc(sizeof(struct uca_camera)); +                current->next->priv = cam; +                current = current->next;              }              current->next = NULL;          } @@ -188,19 +195,23 @@ void uca_destroy(struct uca *u)      uca_lock();      if (u != NULL) {          struct uca_camera *cam = u->cameras, *tmp; +        struct uca_camera_priv *cam_priv;          while (cam != NULL) {              tmp = cam; -            cam->destroy(cam); +            cam_priv = cam->priv; +            cam_priv->destroy(cam_priv);              cam = cam->next;              free(tmp);          }          struct uca_grabber *grabber = u->grabbers, *tmpg; +        struct uca_grabber_priv *grabber_priv;          while (grabber != NULL) {              tmpg = grabber; -            grabber->destroy(grabber); +            grabber_priv = grabber->priv; +            grabber_priv->destroy(grabber_priv);              grabber = grabber->next; -            free(grabber); +            free(tmpg);          }          free(u); @@ -234,3 +245,63 @@ const char* uca_get_property_name(enum uca_property_ids property_id)          return property_map[property_id].name;      return UCA_NO_ERROR;  } + +uint32_t uca_cam_alloc(struct uca_camera *cam, uint32_t n_buffers) +{ +    uint32_t bitdepth; +    struct uca_camera_priv *priv = cam->priv; +    priv->get_property(priv, UCA_PROP_BITDEPTH, &bitdepth, 0); +    const int pixel_size = bitdepth == 8 ? 1 : 2; +    if (priv->grabber != NULL) +        return priv->grabber->alloc(priv->grabber, pixel_size, n_buffers); +    return UCA_NO_ERROR; +} + +enum uca_cam_state uca_cam_get_state(struct uca_camera *cam) +{ +    struct uca_camera_priv *priv = cam->priv; +    return priv->state; +} + +uint32_t uca_cam_set_property(struct uca_camera *cam, enum uca_property_ids property, void *data) +{ +    struct uca_camera_priv *priv = cam->priv; +    return priv->set_property(priv, property, data); +} + +uint32_t uca_cam_get_property(struct uca_camera *cam, enum uca_property_ids property, void *data, size_t num) +{ +    struct uca_camera_priv *priv = cam->priv; +    return priv->get_property(priv, property, data, num); +} + +uint32_t uca_cam_start_recording(struct uca_camera *cam) +{ +    struct uca_camera_priv *priv = cam->priv; +    return priv->start_recording(priv); +} + +uint32_t uca_cam_stop_recording(struct uca_camera *cam) +{ +    struct uca_camera_priv *priv = cam->priv; +    return priv->stop_recording(priv); +} + +uint32_t uca_cam_trigger(struct uca_camera *cam) +{ +    struct uca_camera_priv *priv = cam->priv; +    return priv->trigger(priv); +} + +uint32_t uca_cam_register_callback(struct uca_camera *cam, uca_cam_grab_callback callback, void *user) +{ +    struct uca_camera_priv *priv = cam->priv; +    return priv->register_callback(priv, callback, user); +} + +uint32_t uca_cam_grab(struct uca_camera *cam, char *buffer, void *meta_data) +{ +    struct uca_camera_priv *priv = cam->priv; +    return priv->grab(priv, buffer, meta_data); +} + @@ -212,6 +212,22 @@ union uca_value {      char *string;  }; +/** + * Grab callback. + *  + * Register such a callback function with uca_cam_register_callback() to + * receive data as soon as it is delivered. + * + * \param[in] image_number Current frame number + * \param[in] buffer Image data + * \param[in] meta_data Meta data provided by the camera specifying per-frame + *   data. + * \param[in] user User data registered in uca_cam_register_callback() + * + * \note The meta data parameter is not yet specified but just a place holder. + */ +typedef void (*uca_cam_grab_callback) (uint64_t image_number, void *buffer, void *meta_data, void *user); +  extern const char *uca_unit_map[];      /**< maps unit numbers to corresponding strings */ @@ -264,13 +280,27 @@ extern const char *uca_unit_map[];      /**< maps unit numbers to corresponding  #define UCA_ERR_FRAME_TRANSFER  0x10000009  #define UCA_ERR_ALREADY_REGISTERED 0x1000000A +struct uca_camera_priv; +/** + * uca_camera is an opaque structure that is only accessed with the uca_cam_* + * methods. + */ +struct uca_camera { +    struct uca_camera *next; +    struct uca_camera_priv* priv; +}; + +struct uca_grabber_priv; +struct uca_grabber { +    struct uca_grabber *next; +    struct uca_grabber_priv* priv; +}; +  /**   * Keeps a list of cameras and grabbers.   */  typedef struct uca {      struct uca_camera *cameras; - -    /* private */      struct uca_grabber *grabbers;  } uca_t; @@ -309,6 +339,113 @@ const char* uca_get_property_name(enum uca_property_ids property_id);   */  uca_property_t *uca_get_full_property(enum uca_property_ids property_id); +/** + * Allocates buffer memory for the internal frame grabber. + * + * The allocation is just a hint to the underlying camera driver. It might + * ignore this or pass this information on to a related frame grabber. + * + * \param[in] cam A uca_camera object + * \param[in] n_buffers Number of sub-buffers with size frame_width*frame_height. + * \return Error code + */ +uint32_t uca_cam_alloc(struct uca_camera *cam, uint32_t n_buffers); + +/** + * Retrieve current state of the camera. + * + * \param[in] cam A uca_camera object + * \return A value from the uca_cam_state enum representing the current state of + *   the camera. + */ +enum uca_cam_state uca_cam_get_state(struct uca_camera *cam); + + +/** + * Set a camera property. + * + * \param[in] cam The camera whose properties are to be set. + * \param[in] cam A uca_camera object + * \param[in] property ID of the property as defined in XXX + * \param[out] data Where to read the property's value from + * + * \return UCA_ERR_PROP_INVALID if property is not supported on the camera or + *   UCA_ERR_PROP_VALUE_OUT_OF_RANGE if value cannot be set. + */ +uint32_t uca_cam_set_property(struct uca_camera *cam, enum uca_property_ids property, void *data); + +/** + * Get a property. + * + * \param[in] cam A uca_camera object + * \param[in] property ID of the property as defined in XXX + * \param[out] data Where to store the property's value + * \param[in] num Number of bytes of string storage. Ignored for uca_uint8t + *   and uca_uint32t properties. + * + * \return UCA_ERR_PROP_INVALID if property is not supported on the camera + */ +uint32_t uca_cam_get_property(struct uca_camera *cam, enum uca_property_ids property, void *data, size_t num); + +/** + * Begin recording. + * + * Usually this also involves the frame acquisition of the frame grabber but is + * hidden by this function. + * + * \param[in] cam A uca_camera object + * \return Error code + */ +uint32_t uca_cam_start_recording(struct uca_camera *cam); + +/** + * Stop recording. + * + * \param[in] cam A uca_camera object + * \return Error code + */ +uint32_t uca_cam_stop_recording(struct uca_camera *cam); + +/** + * Send a software trigger signal to start a sensor read-out. + * + * This method is only useful when UCA_PROP_TRIGGER_MODE is set to + * UCA_TRIGGER_SOFTWARE. + * + * \param[in] cam A uca_camera object + * \return Error code + */ +uint32_t uca_cam_trigger(struct uca_camera *cam); + + +/** + * Register callback for given frame grabber. To actually start receiving + * frames, call uca_grabber_acquire(). + * + * \param[in] cam A uca_camera object + * \param[in] callback Callback function for when a frame arrived + * \param[in] user User data that is passed to the callback function + * \return Error code + */ +uint32_t uca_cam_register_callback(struct uca_camera *cam, uca_cam_grab_callback callback, void *user); + +/** + * \brief Grab one image from the camera + *  + * The grabbing involves a memory copy because we might have to decode the image + * coming from the camera, which the frame grabber is not able to do. + * + * \param[in] cam A uca_camera object + * \param[in] buffer Destination buffer + * \param[in] meta_data Meta data provided by the camera specifying per-frame + *   data. + * \return Error code + * + * \note The meta data parameter is not yet specified but just a place holder. + * + */ +uint32_t uca_cam_grab(struct uca_camera *cam, char *buffer, void *meta_data); +  #define uca_set_void(p, type, value) { *((type *) p) = (type) value; }  #ifdef __cplusplus | 
