/* This is an AUTO-GENERATED file! Update it with the output of `ctrl-gen.py def`. */
#include "libuvc/libuvc.h"
#include "libuvc/libuvc_internal.h"
static const int REQ_TYPE_SET = 0x21;
static const int REQ_TYPE_GET = 0xa1;
/** @ingroup ctrl
* @brief Reads the SCANNING_MODE control.
* @param devh UVC device handle
* @param[out] mode 0: interlaced, 1: progressive
* @param req_code UVC_GET_* request to execute
*/
uvc_error_t uvc_get_scanning_mode(uvc_device_handle_t *devh, uint8_t* mode, enum uvc_req_code req_code) {
uint8_t data[1];
uvc_error_t ret;
ret = libusb_control_transfer(
devh->usb_devh,
REQ_TYPE_GET, req_code,
UVC_CT_SCANNING_MODE_CONTROL << 8,
uvc_get_camera_terminal(devh)->bTerminalID << 8 | devh->info->ctrl_if.bInterfaceNumber,
data,
sizeof(data),
0);
if (ret == sizeof(data)) {
*mode = data[0];
return UVC_SUCCESS;
} else {
return ret;
}
}
/** @ingroup ctrl
* @brief Sets the SCANNING_MODE control.
* @param devh UVC device handle
* @param mode 0: interlaced, 1: progressive
*/
uvc_error_t uvc_set_scanning_mode(uvc_device_handle_t *devh, uint8_t mode) {
uint8_t data[1];
uvc_error_t ret;
data[0] = mode;
ret = libusb_control_transfer(
devh->usb_devh,
REQ_TYPE_SET, UVC_SET_CUR,
UVC_CT_SCANNING_MODE_CONTROL << 8,
uvc_get_camera_terminal(devh)->bTerminalID << 8 | devh->info->ctrl_if.bInterfaceNumber,
data,
sizeof(data),
0);
if (ret == sizeof(data))
return UVC_SUCCESS;
else
return ret;
}
/** @ingroup ctrl
* @brief Reads camera's auto-exposure mode.
*
* See uvc_set_ae_mode() for a description of the available modes.
* @param devh UVC device handle
* @param[out] mode 1: manual mode; 2: auto mode; 4: shutter priority mode; 8: aperture priority mode
* @param req_code UVC_GET_* request to execute
*/
uvc_error_t uvc_get_ae_mode(uvc_device_handle_t *devh, uint8_t* mode, enum uvc_req_code req_code) {
uint8_t data[1];
uvc_error_t ret;
ret = libusb_control_transfer(
devh->usb_devh,
REQ_TYPE_GET, req_code,
UVC_CT_AE_MODE_CONTROL << 8,
uvc_get_camera_terminal(devh)->bTerminalID << 8 | devh->info->ctrl_if.bInterfaceNumber,
data,
sizeof(data),
0);
if (ret == sizeof(data)) {
*mode = data[0];
return UVC_SUCCESS;
} else {
return ret;
}
}
/** @ingroup ctrl
* @brief Sets camera's auto-exposure mode.
*
* Cameras may support any of the following AE modes:
* * UVC_AUTO_EXPOSURE_MODE_MANUAL (1) - manual exposure time, manual iris
* * UVC_AUTO_EXPOSURE_MODE_AUTO (2) - auto exposure time, auto iris
* * UVC_AUTO_EXPOSURE_MODE_SHUTTER_PRIORITY (4) - manual exposure time, auto iris
* * UVC_AUTO_EXPOSURE_MODE_APERTURE_PRIORITY (8) - auto exposure time, manual iris
*
* Most cameras provide manual mode and aperture priority mode.
* @param devh UVC device handle
* @param mode 1: manual mode; 2: auto mode; 4: shutter priority mode; 8: aperture priority mode
*/
uvc_error_t uvc_set_ae_mode(uvc_device_handle_t *devh, uint8_t mode) {
uint8_t data[1];
uvc_error_t ret;
data[0] = mode;
ret = libusb_control_transfer(
devh->usb_devh,
REQ_TYPE_SET, UVC_SET_CUR,
UVC_CT_AE_MODE_CONTROL << 8,
uvc_get_camera_terminal(devh)->bTerminalID << 8 | devh->info->ctrl_if.bInterfaceNumber,
data,
sizeof(data),
0);
if (ret == sizeof(data))
return UVC_SUCCESS;
else
return ret;
}
/** @ingroup ctrl
* @brief Checks whether the camera may vary the frame rate for exposure control reasons.
* See uvc_set_ae_priority() for a description of the `priority` field.
* @param devh UVC device handle
* @param[out] priority 0: frame rate must remain constant; 1: frame rate may be varied for AE purposes
* @param req_code UVC_GET_* request to execute
*/
uvc_error_t uvc_get_ae_priority(uvc_device_handle_t *devh, uint8_t* priority, enum uvc_req_code req_code) {
uint8_t data[1];
uvc_error_t ret;
ret = libusb_control_transfer(
devh->usb_devh,
REQ_TYPE_GET, req_code,
UVC_CT_AE_PRIORITY_CONTROL << 8,
uvc_get_camera_terminal(devh)->bTerminalID << 8 | devh->info->ctrl_if.bInterfaceNumber,
data,
sizeof(data),
0);
if (ret == sizeof(data)) {
*priority = data[0];
return UVC_SUCCESS;
} else {
return ret;
}
}
/** @ingroup ctrl
* @brief Chooses whether the camera may vary the frame rate for exposure control reasons.
* A `priority` value of zero means the camera may not vary its frame rate. A value of 1
* means the frame rate is variable. This setting has no effect outside of the `auto` and
* `shutter_priority` auto-exposure modes.
* @param devh UVC device handle
* @param priority 0: frame rate must remain constant; 1: frame rate may be varied for AE purposes
*/
uvc_error_t uvc_set_ae_priority(uvc_device_handle_t *devh, uint8_t priority) {
uint8_t data[1];
uvc_error_t ret;
data[0] = priority;
ret = libusb_control_transfer(
devh->usb_devh,
REQ_TYPE_SET, UVC_SET_CUR,
UVC_CT_AE_PRIORITY_CONTROL << 8,
uvc_get_camera_terminal(devh)->bTerminalID << 8 | devh->info->ctrl_if.bInterfaceNumber,
data,
sizeof(data),
0);
if (ret == sizeof(data))
return UVC_SUCCESS;
else
return ret;
}
/** @ingroup ctrl
* @brief Gets the absolute exposure time.
*
* See uvc_set_exposure_abs() for a description of the `time` field.
* @param devh UVC device handle
* @param[out] time
* @param req_code UVC_GET_* request to execute
*/
uvc_error_t uvc_get_exposure_abs(uvc_device_handle_t *devh, uint32_t* time, enum uvc_req_code req_code) {
uint8_t data[4];
uvc_error_t ret;
ret = libusb_control_transfer(
devh->usb_devh,
REQ_TYPE_GET, req_code,
UVC_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL << 8,
uvc_get_camera_terminal(devh)->bTerminalID << 8 | devh->info->ctrl_if.bInterfaceNumber,
data,
sizeof(data),
0);
if (ret == sizeof(data)) {
*time = DW_TO_INT(data + 0);
return UVC_SUCCESS;
} else {
return ret;
}
}
/** @ingroup ctrl
* @brief Sets the absolute exposure time.
*
* The `time` parameter should be provided in units of 0.0001 seconds (e.g., use the value 100
* for a 10ms exposure period). Auto exposure should be set to `manual` or `shutter_priority`
* before attempting to change this setting.
* @param devh UVC device handle
* @param time
*/
uvc_error_t uvc_set_exposure_abs(uvc_device_handle_t *devh, uint32_t time) {
uint8_t data[4];
uvc_error_t ret;
INT_TO_DW(time, data + 0);
ret = libusb_control_transfer(
devh->usb_devh,
REQ_TYPE_SET, UVC_SET_CUR,
UVC_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL << 8,
uvc_get_camera_terminal(devh)->bTerminalID << 8 | devh->info->ctrl_if.bInterfaceNumber,
data,
sizeof(data),
0);
if (ret == sizeof(data))
return UVC_SUCCESS;
else
return ret;
}
/** @ingroup ctrl
* @brief Reads the exposure time relative to the current setting.
* @param devh UVC device handle
* @param[out] step number of steps by which to change the exposure time, or zero to set the default exposure time
* @param req_code UVC_GET_* request to execute
*/
uvc_error_t uvc_get_exposure_rel(uvc_device_handle_t *devh, int8_t* step, enum uvc_req_code req_code) {
uint8_t data[1];
uvc_error_t ret;
ret = libusb_control_transfer(
devh->usb_devh,
REQ_TYPE_GET, req_code,
UVC_CT_EXPOSURE_TIME_RELATIVE_CONTROL << 8,
uvc_get_camera_terminal(devh)->bTerminalID << 8 | devh->info->ctrl_if.bInterfaceNumber,
data,
sizeof(data),
0);
if (ret == sizeof(data)) {
*step = data[0];
return UVC_SUCCESS;
} else {
return ret;
}
}
/** @ingroup ctrl
* @brief Sets the exposure time relative to the current setting.
* @param devh UVC device handle
* @param step number of steps by which to change the exposure time, or zero to set the default exposure time
*/
uvc_error_t uvc_set_exposure_rel(uvc_device_handle_t *devh, int8_t step) {
uint8_t data[1];
uvc_error_t ret;
data[0] = step;