uvc_error_t uvc_set_pantilt_abs(uvc_device_handle_t *devh, int pan, int tilt) { uint8_t data[8]; uvc_error_t ret; INT_TO_DW(pan, data); INT_TO_DW(tilt, data + 4); ret = libusb_control_transfer(devh->usb_devh, REQ_TYPE_SET, UVC_SET_CUR, UVC_CT_PANTILT_ABSOLUTE_CONTROL << 8, // 1 << 8, /* = fixed ID(00) and wrong VideoControl interface descriptor subtype(UVC_VC_HEADER) on original libuvc */ devh->info->ctrl_if.input_term_descs->request, data, sizeof(data), CTRL_TIMEOUT_MILLIS); if (LIKELY(ret == sizeof(data))) return UVC_SUCCESS; else return ret; }
template<class T> void set_pu(uvc_device_handle_t * devh, int subdevice, uint8_t unit, uint8_t control, int value) { const int REQ_TYPE_SET = 0x21; unsigned char buffer[4]; if(sizeof(T)==1) buffer[0] = value; if(sizeof(T)==2) SHORT_TO_SW(value, buffer); if(sizeof(T)==4) INT_TO_DW(value, buffer); int status = libusb_control_transfer(devh->usb_devh, REQ_TYPE_SET, UVC_SET_CUR, control << 8, unit << 8 | (subdevice*2), buffer, sizeof(T), 0); if(status < 0) throw std::runtime_error(to_string() << "libusb_control_transfer(...) returned " << libusb_error_name(status)); if(status != sizeof(T)) throw std::runtime_error("insufficient data written to usb"); }
uvc_error_t uvc_set_pantilt_abs(uvc_device_handle_t *devh, int pan, int tilt) { uint8_t data[8]; uvc_error_t ret; INT_TO_DW(pan, data); INT_TO_DW(tilt, data + 4); ret = libusb_control_transfer( devh->usb_devh, REQ_TYPE_SET, UVC_SET_CUR, UVC_CT_PANTILT_ABSOLUTE_CONTROL << 8, 1 << 8, data, sizeof(data), 0); if (ret == sizeof(data)) return UVC_SUCCESS; else return ret; }
uvc_error_t uvc_set_wb_compo(uvc_device_handle_t *devh, uint32_t wb_compo) { uint8_t data[4]; uvc_error_t ret; INT_TO_DW(wb_compo, data); ret = libusb_control_transfer(devh->usb_devh, REQ_TYPE_SET, UVC_SET_CUR, UVC_PU_WHITE_BALANCE_COMPONENT_CONTROL << 8, devh->info->ctrl_if.processing_unit_descs->request, data, sizeof(data), CTRL_TIMEOUT_MILLIS); if (LIKELY(ret == sizeof(data))) return UVC_SUCCESS; else return ret; }
uvc_error_t uvc_set_exposure_abs(uvc_device_handle_t *devh, int time) { uint8_t data[4]; uvc_error_t ret; INT_TO_DW(time, data); ret = libusb_control_transfer( devh->usb_devh, REQ_TYPE_SET, UVC_SET_CUR, UVC_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL << 8, 1 << 8, data, sizeof(data), 0); if (ret == sizeof(data)) return UVC_SUCCESS; else return ret; }