Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libcamera: fix compilation errors for libcamera v0.3.2+rpt20241119 #160

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions device/libcamera/options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,16 @@ static int libcamera_device_dump_control_option(device_option_fn fn, void *opaqu
case libcamera::ControlTypeString:
opt.type = device_option_type_string;
break;

#if LIBCAMERA_VERSION_MAJOR == 0 && LIBCAMERA_VERSION_MINOR > 3 && LIBCAMERA_VERSION_PATCH >= 2 // Support for older libcamera versions
case libcamera::ControlTypePoint:
opt.type = device_option_type_float;
opt.elems = 2;
break;
#endif

default:
throw std::runtime_error("ControlType unsupported or not implemented");
}

auto named_values = libcamera_find_control_ids(control_id.id());
Expand Down Expand Up @@ -349,6 +359,29 @@ static libcamera::Size libcamera_parse_size(const char *value)
return libcamera::Size();
}

#if LIBCAMERA_VERSION_MAJOR == 0 && LIBCAMERA_VERSION_MINOR > 3 && LIBCAMERA_VERSION_PATCH >= 2 // Support for older libcamera versions
static libcamera::Point libcamera_parse_point(const char *value)
{
static const char *POINT_PATTERNS[] =
{
"(%d,%d)",
"%d,%d",
NULL
};

for (int i = 0; POINT_PATTERNS[i]; i++) {
libcamera::Point point;

if (2 == sscanf(value, POINT_PATTERNS[i],
&point.x, &point.y)) {
return point;
}
}

return libcamera::Point();
}
#endif

template<typename T, typename F>
static bool libcamera_parse_control_value(libcamera::ControlValue &control_value, const char *value, const F &fn)
{
Expand Down Expand Up @@ -436,6 +469,16 @@ int libcamera_device_set_option(device_t *dev, const char *keyp, const char *val

case libcamera::ControlTypeString:
break;

#if LIBCAMERA_VERSION_MAJOR == 0 && LIBCAMERA_VERSION_MINOR > 3 && LIBCAMERA_VERSION_PATCH >= 2 // Support for older libcamera versions
case libcamera::ControlTypePoint:
libcamera_parse_control_value<libcamera::Point>(
control_value, value, libcamera_parse_point);
break;
#endif

default:
throw std::runtime_error("ControlType unsupported or not implemented");
}

if (control_value.isNone()) {
Expand Down
Loading