From c8dcb293921903a2f97a2022ebc77565da792b48 Mon Sep 17 00:00:00 2001 From: matthias Date: Fri, 11 Mar 2011 12:25:05 +0100 Subject: Pack device description into one structure --- src/cameras/ipe.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/cameras/ipe.c') 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; -- cgit v1.2.3