diff options
author | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2011-10-24 09:22:36 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2011-10-24 09:22:36 +0200 |
commit | 29b0567b035ec45c1d78423a8d96821cdaf85787 (patch) | |
tree | 71c7fc9d2219655b60855eeeed7d28b723e77ec4 /src/cameras | |
parent | ccaf5dfc7727ea32920527a7622509b9724ae42f (diff) | |
download | libuca-29b0567b035ec45c1d78423a8d96821cdaf85787.tar.gz libuca-29b0567b035ec45c1d78423a8d96821cdaf85787.tar.bz2 libuca-29b0567b035ec45c1d78423a8d96821cdaf85787.tar.xz libuca-29b0567b035ec45c1d78423a8d96821cdaf85787.zip |
Fix: pco.dimax record & readout mode
I won't go into detail how retarded a decision from pco is and how much time it
cost...
Diffstat (limited to 'src/cameras')
-rw-r--r-- | src/cameras/pco.c | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/src/cameras/pco.c b/src/cameras/pco.c index cfaa573..00ceee5 100644 --- a/src/cameras/pco.c +++ b/src/cameras/pco.c @@ -12,6 +12,10 @@ typedef struct pco_desc { pco_handle pco; uint16_t type, subtype; uint16_t roi[4]; + + uint16_t active_segment; + uint32_t current_image; + uint32_t num_recorded_images; } pco_desc_t; #define GET_PCO_DESC(cam) ((struct pco_desc *) cam->user) @@ -256,10 +260,14 @@ static uint32_t uca_pco_get_property(struct uca_camera_priv *cam, enum uca_prope static uint32_t uca_pco_start_recording(struct uca_camera_priv *cam) { uint32_t err = UCA_ERR_CAMERA | UCA_ERR_INIT; - pco_handle pco = GET_PCO(cam); + + if (GET_PCO_DESC(cam)->type == CAMERATYPE_PCO_DIMAX_STD) + pco_clear_active_segment(pco); + if (pco_arm_camera(pco) != PCO_NOERROR) return err | UCA_ERR_UNCLASSIFIED; + if (pco_set_rec_state(pco, 1) != PCO_NOERROR) return err | UCA_ERR_UNCLASSIFIED; @@ -284,13 +292,26 @@ static uint32_t uca_pco_trigger(struct uca_camera_priv *cam) static uint32_t uca_pco_grab(struct uca_camera_priv *cam, char *buffer, void *meta_data) { uint16_t *frame; + pco_desc_t *pco_d = GET_PCO_DESC(cam); + pco_handle pco = pco_d->pco; + + if (cam->state == UCA_CAM_READOUT && pco_d->type == CAMERATYPE_PCO_DIMAX_STD) { + if (pco_d->current_image == pco_d->num_recorded_images) + return UCA_ERR_NO_MORE_IMAGES; + + /* Ok, this is pco's way of requesting multiple frames... you have to do + * it one by one :/ */ + pco_read_images(pco, pco_d->active_segment, pco_d->current_image, pco_d->current_image); + pco_d->current_image++; + } pco_request_image(GET_PCO(cam)); uint32_t err = cam->grabber->grab(cam->grabber, (void **) &frame, &cam->current_frame); if (err != UCA_NO_ERROR) return err; - if (GET_PCO_DESC(cam)->type == CAMERATYPE_PCO_EDGE) + /* Copy data into user buffer */ + if (pco_d->type == CAMERATYPE_PCO_EDGE) pco_get_reorder_func(GET_PCO(cam))((uint16_t *) buffer, frame, cam->frame_width, cam->frame_height); else memcpy(buffer, (char *) frame, cam->frame_width * cam->frame_height * 2); @@ -300,14 +321,12 @@ static uint32_t uca_pco_grab(struct uca_camera_priv *cam, char *buffer, void *me static uint32_t uca_pco_readout(struct uca_camera_priv *cam) { - uint16_t active_segment; - uint32_t num_images = 0; - pco_handle pco = GET_PCO(cam); - + pco_desc_t *pco_d = GET_PCO_DESC(cam); /* TODO: error handling */ - pco_get_active_segment(pco, &active_segment); - pco_get_num_images(pco, active_segment, &num_images); - pco_read_images(pco, active_segment, 1, num_images); + pco_handle pco = GET_PCO(cam); + pco_get_active_segment(pco, &pco_d->active_segment); + pco_get_num_images(pco, pco_d->active_segment, &pco_d->num_recorded_images); + pco_d->current_image = 1; return UCA_NO_ERROR; } |