2016-12-22 22:08:08 -08:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2018-01-02 09:16:20 -08:00
|
|
|
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
|
2016-12-22 22:08:08 -08:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
2017-08-25 17:48:06 -07:00
|
|
|
#ifndef CSCORE_USBCAMERAPROPERTY_H_
|
|
|
|
|
#define CSCORE_USBCAMERAPROPERTY_H_
|
2016-12-22 22:08:08 -08:00
|
|
|
|
|
|
|
|
#ifdef __linux__
|
|
|
|
|
#include <linux/videodev2.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-08-25 17:48:06 -07:00
|
|
|
#include <memory>
|
2017-11-13 09:51:26 -08:00
|
|
|
|
|
|
|
|
#include <support/mutex.h>
|
2017-08-25 17:48:06 -07:00
|
|
|
|
2016-12-22 22:08:08 -08:00
|
|
|
#include "PropertyImpl.h"
|
|
|
|
|
|
|
|
|
|
namespace cs {
|
|
|
|
|
|
|
|
|
|
// Property data
|
|
|
|
|
class UsbCameraProperty : public PropertyImpl {
|
|
|
|
|
public:
|
|
|
|
|
UsbCameraProperty() = default;
|
2017-08-25 17:48:06 -07:00
|
|
|
explicit UsbCameraProperty(llvm::StringRef name_) : PropertyImpl{name_} {}
|
2016-12-22 22:08:08 -08:00
|
|
|
|
|
|
|
|
// Normalized property constructor
|
|
|
|
|
UsbCameraProperty(llvm::StringRef name_, int rawIndex_,
|
|
|
|
|
const UsbCameraProperty& rawProp, int defaultValue_,
|
|
|
|
|
int value_)
|
|
|
|
|
: PropertyImpl(name_, rawProp.propKind, 1, defaultValue_, value_),
|
|
|
|
|
percentage{true},
|
|
|
|
|
propPair{rawIndex_},
|
|
|
|
|
id{rawProp.id},
|
|
|
|
|
type{rawProp.type} {
|
|
|
|
|
hasMinimum = true;
|
|
|
|
|
minimum = 0;
|
|
|
|
|
hasMaximum = true;
|
|
|
|
|
maximum = 100;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef __linux__
|
|
|
|
|
#ifdef VIDIOC_QUERY_EXT_CTRL
|
2017-08-25 17:48:06 -07:00
|
|
|
explicit UsbCameraProperty(const struct v4l2_query_ext_ctrl& ctrl);
|
2016-12-22 22:08:08 -08:00
|
|
|
#endif
|
2017-08-25 17:48:06 -07:00
|
|
|
explicit UsbCameraProperty(const struct v4l2_queryctrl& ctrl);
|
2016-12-22 22:08:08 -08:00
|
|
|
|
2016-12-22 22:44:46 -08:00
|
|
|
static std::unique_ptr<UsbCameraProperty> DeviceQuery(int fd, __u32* id);
|
|
|
|
|
|
2017-11-13 09:51:26 -08:00
|
|
|
bool DeviceGet(std::unique_lock<wpi::mutex>& lock, int fd);
|
|
|
|
|
bool DeviceSet(std::unique_lock<wpi::mutex>& lock, int fd) const;
|
|
|
|
|
bool DeviceSet(std::unique_lock<wpi::mutex>& lock, int fd, int newValue,
|
2016-12-22 22:08:08 -08:00
|
|
|
llvm::StringRef newValueStr) const;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// If this is a percentage (rather than raw) property
|
|
|
|
|
bool percentage{false};
|
|
|
|
|
|
|
|
|
|
// If not 0, index of corresponding raw/percentage property
|
|
|
|
|
int propPair{0};
|
|
|
|
|
|
|
|
|
|
unsigned id{0}; // implementation-level id
|
2017-08-25 17:48:06 -07:00
|
|
|
int type{0}; // implementation type, not CS_PropertyKind!
|
2016-12-22 22:08:08 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace cs
|
|
|
|
|
|
2017-08-25 17:48:06 -07:00
|
|
|
#endif // CSCORE_USBCAMERAPROPERTY_H_
|