diff options
author | matthias <matthias@ipecaselle1> | 2011-03-11 12:25:05 +0100 |
---|---|---|
committer | matthias <matthias@ipecaselle1> | 2011-03-11 12:25:05 +0100 |
commit | c8dcb293921903a2f97a2022ebc77565da792b48 (patch) | |
tree | 86136a565339d1aac4a7872b13ca1a6ce38dcbeb | |
parent | 84e4d27026c4904fc980dda31783acd6a25606f5 (diff) | |
download | uca-c8dcb293921903a2f97a2022ebc77565da792b48.tar.gz uca-c8dcb293921903a2f97a2022ebc77565da792b48.tar.bz2 uca-c8dcb293921903a2f97a2022ebc77565da792b48.tar.xz uca-c8dcb293921903a2f97a2022ebc77565da792b48.zip |
Pack device description into one structure
-rw-r--r-- | src/cameras/ipe.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/cameras/ipe.c b/src/cameras/ipe.c index 94cd4ed..78aae01 100644 --- a/src/cameras/ipe.c +++ b/src/cameras/ipe.c @@ -6,8 +6,13 @@ #include "uca-cam.h" #include "uca-grabber.h" +struct ipe_desc_t { + pcilib_t *handle; + pcilib_model_t model; +}; + #define set_void(p, type, value) { *((type *) p) = value; } -#define GET_HANDLE(cam) ((pcilib_t *) cam->user) +#define GET_IPE_DESC(cam) ((struct ipe_desc_t *) cam->user) static void uca_ipe_handle_error(const char *format, ...) { @@ -49,7 +54,9 @@ static uint32_t uca_ipe_grab(struct uca_camera_t *cam, char *buffer) static uint32_t uca_ipe_destroy(struct uca_camera_t *cam) { - pcilib_close(GET_HANDLE(cam)); + struct ipe_desc_t *ipe_desc = GET_IPE_DESC(cam); + pcilib_close(ipe_desc->handle); + free(ipe_desc); return UCA_NO_ERROR; } @@ -61,6 +68,10 @@ uint32_t uca_ipe_init(struct uca_camera_t **cam, struct uca_grabber_t *grabber) if (handle < 0) return UCA_ERR_CAM_NOT_FOUND; + struct ipe_desc_t *ipe_desc = (struct ipe_desc_t *) malloc(sizeof(struct ipe_desc_t)); + ipe_desc->handle = handle; + ipe_desc->model = model; + pcilib_set_error_handler(&uca_ipe_handle_error); model = pcilib_get_model(handle); @@ -75,7 +86,7 @@ uint32_t uca_ipe_init(struct uca_camera_t **cam, struct uca_grabber_t *grabber) uca->grab = &uca_ipe_grab; uca->state = UCA_CAM_CONFIGURABLE; - uca->user = handle; + uca->user = ipe_desc; *cam = uca; return UCA_NO_ERROR; |