(2/5) Tweak AVT shading control functions This patch tweaks the shading control functions for AVT cameras: - The read arguments to dc1394_avt_get_shading() and dc1394_avt_get_shading_memctrl() are now optional, pass NULL if you aren't interested in certain fields - Added the compute field to dc1394_avt_get_shading(), this was only present in the _set_shading variant. - Added the show field to dc1394_avt_get_shading() and dc1394_avt_set_shading() - dc1394_avt_set_shading_mem_ctrl() was writing to the wrong register - Fixed up prototypes for the above functions in the header file Some of this is based on code from libavt1394 Index: libdc1394-2.0.0-rc3/dc1394/vendor/avt.c =================================================================== --- libdc1394-2.0.0-rc3.orig/dc1394/vendor/avt.c +++ libdc1394-2.0.0-rc3/dc1394/vendor/avt.c @@ -191,7 +191,8 @@ dc1394_avt_print_advanced_feature(dc1394 /************************************************************************/ dc1394error_t dc1394_avt_get_shading(dc1394camera_t *camera, - dc1394bool_t *on_off, uint32_t *frame_nb) + dc1394bool_t *on_off, dc1394bool_t *compute, + dc1394bool_t *show, uint32_t *frame_nb) { dc1394error_t err; uint32_t value; @@ -201,10 +202,20 @@ dc1394_avt_get_shading(dc1394camera_t *c DC1394_ERR_RTN(err,"Could not get AVT shading control reg"); /* Shading ON / OFF : Bit 6 */ - *on_off = (uint32_t)((value & 0x2000000UL) >> 25); - + if (on_off) + *on_off = (uint32_t)((value & 0x2000000UL) >> 25); + + /* Compute : Bit 5 */ + if (compute) + *compute = (uint32_t)((value & 0x4000000UL) >> 26); + + /* Show image : Bit 4 */ + if (show) + *show = (uint32_t)((value & 0x8000000UL) >> 27); + /* Number of images for auto computing of the shading reference: Bits 24..31 */ - *frame_nb =(uint32_t)((value & 0xFFUL)); + if (frame_nb) + *frame_nb =(uint32_t)((value & 0xFFUL)); return DC1394_SUCCESS; @@ -216,7 +227,8 @@ dc1394_avt_get_shading(dc1394camera_t *c /************************************************************************/ dc1394error_t dc1394_avt_set_shading(dc1394camera_t *camera, - dc1394bool_t on_off,dc1394bool_t compute, uint32_t frame_nb) + dc1394bool_t on_off, dc1394bool_t compute, + dc1394bool_t show, uint32_t frame_nb) { dc1394error_t err; uint32_t curval; @@ -230,7 +242,10 @@ dc1394_avt_set_shading(dc1394camera_t *c /* Compute : Bit 5 */ curval = (curval & 0xFBFFFFFFUL) | ((compute ) << 26); - + + /* Show Image : Bit 4 */ + curval = (curval & 0xF7FFFFFFUL) | ((show ) << 27); + /* Number of images : Bits 24..31 */ curval = (curval & 0xFFFFFF00UL) | ((frame_nb & 0xFFUL )); @@ -258,13 +273,16 @@ dc1394_avt_get_shading_mem_ctrl(dc1394ca DC1394_ERR_RTN(err,"Could not get AVT shading memory control"); /* Enable write access : Bit 5 */ - *en_write = (uint32_t)((value & 0x4000000UL) >> 26); + if (en_write) + *en_write = (uint32_t)((value & 0x4000000UL) >> 26); /* Enable read access : Bit 6 */ - *en_read = (uint32_t)((value & 0x2000000UL) >> 25); + if (en_read) + *en_read = (uint32_t)((value & 0x2000000UL) >> 25); /* addroffset in byte : Bits 8..31 */ - *addroffset =(uint32_t)((value & 0xFFFFFFUL)); + if (addroffset) + *addroffset =(uint32_t)((value & 0xFFFFFFUL)); return DC1394_SUCCESS; } @@ -294,7 +312,7 @@ dc1394_avt_set_shading_mem_ctrl(dc1394ca curval = (curval & 0xFF000000UL) | ((addroffset & 0xFFFFFFUL )); /* Set new parameters */ - err=SetCameraAdvControlRegister(camera,REG_CAMERA_AVT_LUT_MEM_CTRL, curval); + err=SetCameraAdvControlRegister(camera,REG_CAMERA_AVT_SHDG_MEM_CTRL, curval); DC1394_ERR_RTN(err,"Could not get AVT LUT memory control"); return DC1394_SUCCESS; Index: libdc1394-2.0.0-rc3/dc1394/vendor/avt.h =================================================================== --- libdc1394-2.0.0-rc3.orig/dc1394/vendor/avt.h +++ libdc1394-2.0.0-rc3/dc1394/vendor/avt.h @@ -90,8 +90,10 @@ dc1394error_t dc1394_avt_print_advanced_ /* Retrieve if shading is on and the number of frames used to compute */ /* The shading reference frame */ /************************************************************************/ -int dc1394_avt_get_shading(dc1394camera_t *camera, - dc1394bool_t *on_off, uint32_t *frame_nb); +dc1394error_t dc1394_avt_get_shading(dc1394camera_t *camera, + dc1394bool_t *on_off, + dc1394bool_t *compute, + dc1394bool_t *show, uint32_t *frame_nb); /************************************************************************/ @@ -100,9 +102,9 @@ int dc1394_avt_get_shading(dc1394camera_ /* Set the shading to on/off and the number of frames used to compute */ /* The shading reference frame */ /************************************************************************/ -int dc1394_avt_set_shading(dc1394camera_t *camera, - dc1394bool_t on_off, dc1394bool_t compute, - uint32_t frame_nb); +dc1394error_t dc1394_avt_set_shading(dc1394camera_t *camera, + dc1394bool_t on_off, dc1394bool_t compute, + dc1394bool_t show, uint32_t frame_nb);