change the way to get xu control's range
This commit is contained in:
parent
87470f29a9
commit
5be47846e7
|
@ -838,15 +838,15 @@ bool Channels::PuControlQuery(
|
|||
}
|
||||
|
||||
bool Channels::XuControlRange(
|
||||
channel_t channel, int32_t *min, int32_t *max, int32_t *def) const {
|
||||
return XuControlRange(mynteye_xu, channel, min, max, def);
|
||||
channel_t channel, uint8_t id, int32_t *min, int32_t *max, int32_t *def) const {
|
||||
return XuControlRange(mynteye_xu, channel, id, min, max, def);
|
||||
}
|
||||
|
||||
bool Channels::XuControlRange(
|
||||
const uvc::xu &xu, uint8_t selector, int32_t *min, int32_t *max,
|
||||
const uvc::xu &xu, uint8_t selector, uint8_t id, int32_t *min, int32_t *max,
|
||||
int32_t *def) const {
|
||||
CHECK_NOTNULL(device_);
|
||||
return uvc::xu_control_range(*device_, xu, selector, min, max, def);
|
||||
return uvc::xu_control_range(*device_, xu, selector, id, min, max, def);
|
||||
}
|
||||
|
||||
bool Channels::XuControlQuery(
|
||||
|
@ -983,14 +983,8 @@ Channels::control_info_t Channels::PuControlInfo(Option option) const {
|
|||
Channels::control_info_t Channels::XuControlInfo(Option option) const {
|
||||
int id = XuCamCtrlId(option);
|
||||
|
||||
std::uint8_t data[3] = {static_cast<std::uint8_t>((id | 0x80) & 0xFF), 0, 0};
|
||||
if (!XuCamCtrlQuery(uvc::XU_QUERY_SET, 3, data)) {
|
||||
LOG(WARNING) << "Get XuControlInfo of " << option << " failed";
|
||||
return {0, 0, 0};
|
||||
}
|
||||
|
||||
int32_t min = 0, max = 0, def = 0;
|
||||
if (!XuControlRange(CHANNEL_CAM_CTRL, &min, &max, &def)) {
|
||||
if (!XuControlRange(CHANNEL_CAM_CTRL, static_cast<std::uint8_t>(id), &min, &max, &def)) {
|
||||
LOG(WARNING) << "Get XuControlInfo of " << option << " failed";
|
||||
}
|
||||
return {min, max, def};
|
||||
|
|
|
@ -98,9 +98,9 @@ class MYNTEYE_API Channels {
|
|||
bool PuControlQuery(Option option, uvc::pu_query query, int32_t *value) const;
|
||||
|
||||
bool XuControlRange(
|
||||
channel_t channel, int32_t *min, int32_t *max, int32_t *def) const;
|
||||
channel_t channel, uint8_t id, int32_t *min, int32_t *max, int32_t *def) const;
|
||||
bool XuControlRange(
|
||||
const uvc::xu &xu, uint8_t selector, int32_t *min, int32_t *max,
|
||||
const uvc::xu &xu, uint8_t selector, uint8_t id, int32_t *min, int32_t *max,
|
||||
int32_t *def) const;
|
||||
|
||||
bool XuControlQuery(
|
||||
|
|
|
@ -132,7 +132,7 @@ bool pu_control_query(
|
|||
}
|
||||
|
||||
bool xu_control_range(
|
||||
const device &device, const xu &xu, uint8_t selector, int32_t *min,
|
||||
const device &device, const xu &xu, uint8_t selector, uint8_t id, int32_t *min,
|
||||
int32_t *max, int32_t *def) {
|
||||
// TODO(JohnZhao)
|
||||
UNUSED(device)
|
||||
|
|
|
@ -492,10 +492,17 @@ bool pu_control_query(
|
|||
}
|
||||
|
||||
bool xu_control_range(
|
||||
const device &device, const xu &xu, uint8_t selector, int32_t *min,
|
||||
int32_t *max, int32_t *def) {
|
||||
const device &device, const xu &xu, uint8_t selector, uint8_t id,
|
||||
int32_t *min, int32_t *max, int32_t *def) {
|
||||
bool ret = true;
|
||||
std::uint8_t data[3]{};
|
||||
std::uint8_t query_id[3]{(id | 0x80), 0, 0};
|
||||
|
||||
if(!xu_control_query(device, xu, selcetor, XU_QUERY_SET, 3, query_id)) {
|
||||
LOG(WARNING) << "xu_control_range query failed";
|
||||
ret = false;
|
||||
}
|
||||
|
||||
if (xu_control_query(device, xu, selcetor, XU_QUERY_MIN, 3, data)) {
|
||||
*min = (data[1] << 8) | (data[2]);
|
||||
} else {
|
||||
|
|
|
@ -565,6 +565,7 @@ static std::string to_string(uint16_t size, uint8_t *data) {
|
|||
return ss.str();
|
||||
}
|
||||
|
||||
/*
|
||||
static std::vector<BYTE> xu_control_desc(const device &device, const xu &xu, ULONG id, ULONG flags) {
|
||||
auto ks_control = const_cast<uvc::device &>(device).get_ks_control(xu);
|
||||
|
||||
|
@ -640,6 +641,7 @@ bool xu_control_range(
|
|||
<< ": min=" << *min << ", max=" << *max << ", def=" << *def;
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
static void xu_control_get(const device &device, const xu &xu, uint8_t selector,
|
||||
uint16_t size, uint8_t *data) {
|
||||
|
@ -682,6 +684,28 @@ static void xu_control_set(const device &device, const xu &xu, uint8_t selector,
|
|||
VLOG_INFO << __func__ << " " << static_cast<int>(selector) << " done";
|
||||
}
|
||||
|
||||
static int32_t xu_control_range_basic(const device &device, const xu &xu, uint8_t selector, uint8_t id) {
|
||||
int32_t value = 0;
|
||||
std::uint8_t data[3]{};
|
||||
std::uint8_t query_id[3]{id, 0, 0};
|
||||
|
||||
xu_control_set(device,xu,selector,3,query_id);
|
||||
xu_control_get(device,xu,selector,3,data);
|
||||
value = (data[1] << 8) | (data[2]);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
bool xu_control_range(
|
||||
const device &device, const xu &xu, uint8_t selector, uint8_t id,
|
||||
int32_t *min, int32_t *max, int32_t *def) {
|
||||
VLOG_INFO << __func__ << " " << static_cast<int>(selector);
|
||||
*min = xu_control_range_basic(device,xu,selector,id|0x90);
|
||||
*max = xu_control_range_basic(device,xu,selector,id|0xa0);
|
||||
*def = xu_control_range_basic(device,xu,selector,id|0xc0);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool xu_control_query(
|
||||
const device &device, const xu &xu, uint8_t selector, xu_query query,
|
||||
uint16_t size, uint8_t *data) {
|
||||
|
|
|
@ -73,8 +73,8 @@ MYNTEYE_API bool pu_control_query(
|
|||
|
||||
// Access XU (Extension Unit) controls
|
||||
MYNTEYE_API bool xu_control_range(
|
||||
const device &device, const xu &xu, uint8_t selector, int32_t *min,
|
||||
int32_t *max, int32_t *def);
|
||||
const device &device, const xu &xu, uint8_t selector, uint8_t id,
|
||||
int32_t *min, int32_t *max, int32_t *def);
|
||||
MYNTEYE_API bool xu_control_query( // XU_QUERY_SET, XU_QUERY_GET
|
||||
const device &device, const xu &xu, uint8_t selector, xu_query query,
|
||||
uint16_t size, uint8_t *data);
|
||||
|
|
Loading…
Reference in New Issue
Block a user