summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/android/system/core/include/system/graphics-base-v1.0.h1
-rw-r--r--include/android/system/core/include/system/graphics-base-v1.1.h1
-rw-r--r--include/android/system/core/include/system/graphics-base.h1
-rw-r--r--include/android/system/core/include/system/graphics-sw.h1
-rw-r--r--include/libcamera/base/backtrace.h36
-rw-r--r--include/libcamera/base/bound_method.h97
-rw-r--r--include/libcamera/base/class.h8
-rw-r--r--include/libcamera/base/event_dispatcher.h8
-rw-r--r--include/libcamera/base/event_dispatcher_poll.h11
-rw-r--r--include/libcamera/base/event_notifier.h10
-rw-r--r--include/libcamera/base/file.h15
-rw-r--r--include/libcamera/base/flags.h16
-rw-r--r--include/libcamera/base/log.h25
-rw-r--r--include/libcamera/base/memfd.h32
-rw-r--r--include/libcamera/base/meson.build28
-rw-r--r--include/libcamera/base/message.h10
-rw-r--r--include/libcamera/base/mutex.h134
-rw-r--r--include/libcamera/base/object.h14
-rw-r--r--include/libcamera/base/private.h2
-rw-r--r--include/libcamera/base/semaphore.h23
-rw-r--r--include/libcamera/base/shared_fd.h59
-rw-r--r--include/libcamera/base/signal.h43
-rw-r--r--include/libcamera/base/span.h8
-rw-r--r--include/libcamera/base/thread.h19
-rw-r--r--include/libcamera/base/thread_annotations.h82
-rw-r--r--include/libcamera/base/timer.h12
-rw-r--r--include/libcamera/base/unique_fd.h68
-rw-r--r--include/libcamera/base/utils.h104
-rw-r--r--include/libcamera/camera.h63
-rw-r--r--include/libcamera/camera_manager.h15
-rw-r--r--include/libcamera/color_space.h76
-rw-r--r--include/libcamera/compiler.h16
-rw-r--r--include/libcamera/control_ids.h.in51
-rw-r--r--include/libcamera/controls.h161
-rw-r--r--include/libcamera/fence.h31
-rw-r--r--include/libcamera/file_descriptor.h48
-rw-r--r--include/libcamera/formats.h.in8
-rw-r--r--include/libcamera/framebuffer.h55
-rw-r--r--include/libcamera/framebuffer_allocator.h8
-rw-r--r--include/libcamera/geometry.h88
-rw-r--r--include/libcamera/internal/bayer_format.h25
-rw-r--r--include/libcamera/internal/byte_stream_buffer.h8
-rw-r--r--include/libcamera/internal/camera.h16
-rw-r--r--include/libcamera/internal/camera_controls.h8
-rw-r--r--include/libcamera/internal/camera_lens.h50
-rw-r--r--include/libcamera/internal/camera_manager.h71
-rw-r--r--include/libcamera/internal/camera_sensor.h149
-rw-r--r--include/libcamera/internal/camera_sensor_properties.h20
-rw-r--r--include/libcamera/internal/control_serializer.h20
-rw-r--r--include/libcamera/internal/control_validator.h8
-rw-r--r--include/libcamera/internal/converter.h143
-rw-r--r--include/libcamera/internal/converter/converter_v4l2_m2m.h125
-rw-r--r--include/libcamera/internal/converter/meson.build5
-rw-r--r--include/libcamera/internal/debug_controls.h46
-rw-r--r--include/libcamera/internal/delayed_controls.h15
-rw-r--r--include/libcamera/internal/device_enumerator.h8
-rw-r--r--include/libcamera/internal/device_enumerator_sysfs.h9
-rw-r--r--include/libcamera/internal/device_enumerator_udev.h10
-rw-r--r--include/libcamera/internal/dma_buf_allocator.h80
-rw-r--r--include/libcamera/internal/formats.h27
-rw-r--r--include/libcamera/internal/framebuffer.h30
-rw-r--r--include/libcamera/internal/ipa_data_serializer.h120
-rw-r--r--include/libcamera/internal/ipa_manager.h24
-rw-r--r--include/libcamera/internal/ipa_module.h8
-rw-r--r--include/libcamera/internal/ipa_proxy.h13
-rw-r--r--include/libcamera/internal/ipc_pipe.h18
-rw-r--r--include/libcamera/internal/ipc_pipe_unixsocket.h12
-rw-r--r--include/libcamera/internal/ipc_unixsocket.h18
-rw-r--r--include/libcamera/internal/mapped_framebuffer.h11
-rw-r--r--include/libcamera/internal/matrix.h199
-rw-r--r--include/libcamera/internal/media_device.h21
-rw-r--r--include/libcamera/internal/media_object.h31
-rw-r--r--include/libcamera/internal/meson.build30
-rw-r--r--include/libcamera/internal/pipeline_handler.h91
-rw-r--r--include/libcamera/internal/process.h16
-rw-r--r--include/libcamera/internal/pub_key.h16
-rw-r--r--include/libcamera/internal/request.h66
-rw-r--r--include/libcamera/internal/shared_mem_object.h126
-rw-r--r--include/libcamera/internal/software_isp/debayer_params.h28
-rw-r--r--include/libcamera/internal/software_isp/meson.build7
-rw-r--r--include/libcamera/internal/software_isp/software_isp.h104
-rw-r--r--include/libcamera/internal/software_isp/swisp_stats.h49
-rw-r--r--include/libcamera/internal/source_paths.h8
-rw-r--r--include/libcamera/internal/sysfs.h8
-rw-r--r--include/libcamera/internal/tracepoints.h.in4
-rw-r--r--include/libcamera/internal/tracepoints/request.tp24
-rw-r--r--include/libcamera/internal/v4l2_device.h35
-rw-r--r--include/libcamera/internal/v4l2_pixelformat.h39
-rw-r--r--include/libcamera/internal/v4l2_subdevice.h152
-rw-r--r--include/libcamera/internal/v4l2_videodevice.h59
-rw-r--r--include/libcamera/internal/yaml_parser.h245
-rw-r--r--include/libcamera/ipa/core.mojom55
-rw-r--r--include/libcamera/ipa/ipa_controls.h15
-rw-r--r--include/libcamera/ipa/ipa_interface.h24
-rw-r--r--include/libcamera/ipa/ipa_module_info.h8
-rw-r--r--include/libcamera/ipa/ipu3.mojom38
-rw-r--r--include/libcamera/ipa/mali-c55.mojom34
-rw-r--r--include/libcamera/ipa/meson.build89
-rw-r--r--include/libcamera/ipa/raspberrypi.h57
-rw-r--r--include/libcamera/ipa/raspberrypi.mojom265
-rw-r--r--include/libcamera/ipa/rkisp1.mojom44
-rw-r--r--include/libcamera/ipa/soft.mojom36
-rw-r--r--include/libcamera/ipa/vimc.mojom18
-rw-r--r--include/libcamera/logging.h14
-rw-r--r--include/libcamera/meson.build108
-rw-r--r--include/libcamera/orientation.h30
-rw-r--r--include/libcamera/pixel_format.h12
-rw-r--r--include/libcamera/property_ids.h.in39
-rw-r--r--include/libcamera/request.h36
-rw-r--r--include/libcamera/stream.h19
-rw-r--r--include/libcamera/transform.h16
-rw-r--r--include/libcamera/version.h.in8
-rw-r--r--include/linux/README2
-rw-r--r--include/linux/bcm2835-isp.h2
-rw-r--r--include/linux/dma-buf.h138
-rw-r--r--include/linux/dma-heap.h2
-rw-r--r--include/linux/drm_fourcc.h370
-rw-r--r--include/linux/intel-ipu3.h74
-rw-r--r--include/linux/mali-c55-config.h909
-rw-r--r--include/linux/media-bus-format.h33
-rw-r--r--include/linux/media.h29
-rw-r--r--include/linux/rkisp1-config.h721
-rw-r--r--include/linux/udmabuf.h33
-rw-r--r--include/linux/v4l2-common.h39
-rw-r--r--include/linux/v4l2-controls.h1940
-rw-r--r--include/linux/v4l2-mediabus.h22
-rw-r--r--include/linux/v4l2-subdev.h144
-rw-r--r--include/linux/videodev2.h248
-rw-r--r--include/meson.build2
129 files changed, 8224 insertions, 1392 deletions
diff --git a/include/android/system/core/include/system/graphics-base-v1.0.h b/include/android/system/core/include/system/graphics-base-v1.0.h
index 44913cc6..7548d879 100644
--- a/include/android/system/core/include/system/graphics-base-v1.0.h
+++ b/include/android/system/core/include/system/graphics-base-v1.0.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: Apache-2.0 */
// This file is autogenerated by hidl-gen. Do not edit manually.
// Source: android.hardware.graphics.common@1.0
// Location: hardware/interfaces/graphics/common/1.0/
diff --git a/include/android/system/core/include/system/graphics-base-v1.1.h b/include/android/system/core/include/system/graphics-base-v1.1.h
index f95b9ba2..35130724 100644
--- a/include/android/system/core/include/system/graphics-base-v1.1.h
+++ b/include/android/system/core/include/system/graphics-base-v1.1.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: Apache-2.0 */
// This file is autogenerated by hidl-gen. Do not edit manually.
// Source: android.hardware.graphics.common@1.1
// Location: hardware/interfaces/graphics/common/1.1/
diff --git a/include/android/system/core/include/system/graphics-base.h b/include/android/system/core/include/system/graphics-base.h
index ea920071..d01e9874 100644
--- a/include/android/system/core/include/system/graphics-base.h
+++ b/include/android/system/core/include/system/graphics-base.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: Apache-2.0 */
#ifndef SYSTEM_CORE_GRAPHICS_BASE_H_
#define SYSTEM_CORE_GRAPHICS_BASE_H_
diff --git a/include/android/system/core/include/system/graphics-sw.h b/include/android/system/core/include/system/graphics-sw.h
index 9e1a88e9..4a1cf829 100644
--- a/include/android/system/core/include/system/graphics-sw.h
+++ b/include/android/system/core/include/system/graphics-sw.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: Apache-2.0 */
#ifndef SYSTEM_CORE_GRAPHICS_SW_H_
#define SYSTEM_CORE_GRAPHICS_SW_H_
diff --git a/include/libcamera/base/backtrace.h b/include/libcamera/base/backtrace.h
new file mode 100644
index 00000000..699ddd9e
--- /dev/null
+++ b/include/libcamera/base/backtrace.h
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2021, Ideas on Board Oy
+ *
+ * Call stack backtraces
+ */
+
+#pragma once
+
+#include <string>
+#include <vector>
+
+#include <libcamera/base/private.h>
+
+#include <libcamera/base/class.h>
+
+namespace libcamera {
+
+class Backtrace
+{
+public:
+ Backtrace();
+
+ std::string toString(unsigned int skipLevels = 0) const;
+
+private:
+ LIBCAMERA_DISABLE_COPY(Backtrace)
+
+ bool backtraceTrace();
+ bool unwindTrace();
+
+ std::vector<void *> backtrace_;
+ std::vector<std::string> backtraceText_;
+};
+
+} /* namespace libcamera */
diff --git a/include/libcamera/base/bound_method.h b/include/libcamera/base/bound_method.h
index 282f9b58..dd3488ee 100644
--- a/include/libcamera/base/bound_method.h
+++ b/include/libcamera/base/bound_method.h
@@ -2,10 +2,10 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * bound_method.h - Method bind and invocation
+ * Method bind and invocation
*/
-#ifndef __LIBCAMERA_BASE_BOUND_METHOD_H__
-#define __LIBCAMERA_BASE_BOUND_METHOD_H__
+
+#pragma once
#include <memory>
#include <tuple>
@@ -38,6 +38,11 @@ public:
{
}
+ R returnValue()
+ {
+ return ret_;
+ }
+
std::tuple<typename std::remove_reference_t<Args>...> args_;
R ret_;
};
@@ -51,6 +56,10 @@ public:
{
}
+ void returnValue()
+ {
+ }
+
std::tuple<typename std::remove_reference_t<Args>...> args_;
};
@@ -63,7 +72,7 @@ public:
}
virtual ~BoundMethodBase() = default;
- template<typename T, typename std::enable_if_t<!std::is_same<Object, T>::value> * = nullptr>
+ template<typename T, std::enable_if_t<!std::is_same<Object, T>::value> * = nullptr>
bool match(T *obj) { return obj == obj_; }
bool match(Object *object) { return object == object_; }
@@ -89,35 +98,17 @@ public:
using PackType = BoundMethodPack<R, Args...>;
private:
- template<std::size_t... I>
- void invokePack(BoundMethodPackBase *pack, std::index_sequence<I...>)
+ template<std::size_t... I, typename T = R>
+ std::enable_if_t<!std::is_void<T>::value, void>
+ invokePack(BoundMethodPackBase *pack, std::index_sequence<I...>)
{
PackType *args = static_cast<PackType *>(pack);
args->ret_ = invoke(std::get<I>(args->args_)...);
}
-public:
- BoundMethodArgs(void *obj, Object *object, ConnectionType type)
- : BoundMethodBase(obj, object, type) {}
-
- void invokePack(BoundMethodPackBase *pack) override
- {
- invokePack(pack, std::make_index_sequence<sizeof...(Args)>{});
- }
-
- virtual R activate(Args... args, bool deleteMethod = false) = 0;
- virtual R invoke(Args... args) = 0;
-};
-
-template<typename... Args>
-class BoundMethodArgs<void, Args...> : public BoundMethodBase
-{
-public:
- using PackType = BoundMethodPack<void, Args...>;
-
-private:
- template<std::size_t... I>
- void invokePack(BoundMethodPackBase *pack, std::index_sequence<I...>)
+ template<std::size_t... I, typename T = R>
+ std::enable_if_t<std::is_void<T>::value, void>
+ invokePack(BoundMethodPackBase *pack, std::index_sequence<I...>)
{
/* args is effectively unused when the sequence I is empty. */
PackType *args [[gnu::unused]] = static_cast<PackType *>(pack);
@@ -133,61 +124,56 @@ public:
invokePack(pack, std::make_index_sequence<sizeof...(Args)>{});
}
- virtual void activate(Args... args, bool deleteMethod = false) = 0;
- virtual void invoke(Args... args) = 0;
+ virtual R activate(Args... args, bool deleteMethod = false) = 0;
+ virtual R invoke(Args... args) = 0;
};
-template<typename T, typename R, typename... Args>
-class BoundMethodMember : public BoundMethodArgs<R, Args...>
+template<typename T, typename R, typename Func, typename... Args>
+class BoundMethodFunctor : public BoundMethodArgs<R, Args...>
{
public:
using PackType = typename BoundMethodArgs<R, Args...>::PackType;
- BoundMethodMember(T *obj, Object *object, R (T::*func)(Args...),
- ConnectionType type = ConnectionTypeAuto)
+ BoundMethodFunctor(T *obj, Object *object, Func func,
+ ConnectionType type = ConnectionTypeAuto)
: BoundMethodArgs<R, Args...>(obj, object, type), func_(func)
{
}
- bool match(R (T::*func)(Args...)) const { return func == func_; }
-
R activate(Args... args, bool deleteMethod = false) override
{
- if (!this->object_) {
- T *obj = static_cast<T *>(this->obj_);
- return (obj->*func_)(args...);
- }
+ if (!this->object_)
+ return func_(args...);
auto pack = std::make_shared<PackType>(args...);
bool sync = BoundMethodBase::activatePack(pack, deleteMethod);
- return sync ? pack->ret_ : R();
+ return sync ? pack->returnValue() : R();
}
R invoke(Args... args) override
{
- T *obj = static_cast<T *>(this->obj_);
- return (obj->*func_)(args...);
+ return func_(args...);
}
private:
- R (T::*func_)(Args...);
+ Func func_;
};
-template<typename T, typename... Args>
-class BoundMethodMember<T, void, Args...> : public BoundMethodArgs<void, Args...>
+template<typename T, typename R, typename... Args>
+class BoundMethodMember : public BoundMethodArgs<R, Args...>
{
public:
- using PackType = typename BoundMethodArgs<void, Args...>::PackType;
+ using PackType = typename BoundMethodArgs<R, Args...>::PackType;
- BoundMethodMember(T *obj, Object *object, void (T::*func)(Args...),
+ BoundMethodMember(T *obj, Object *object, R (T::*func)(Args...),
ConnectionType type = ConnectionTypeAuto)
- : BoundMethodArgs<void, Args...>(obj, object, type), func_(func)
+ : BoundMethodArgs<R, Args...>(obj, object, type), func_(func)
{
}
- bool match(void (T::*func)(Args...)) const { return func == func_; }
+ bool match(R (T::*func)(Args...)) const { return func == func_; }
- void activate(Args... args, bool deleteMethod = false) override
+ R activate(Args... args, bool deleteMethod = false) override
{
if (!this->object_) {
T *obj = static_cast<T *>(this->obj_);
@@ -195,17 +181,18 @@ public:
}
auto pack = std::make_shared<PackType>(args...);
- BoundMethodBase::activatePack(pack, deleteMethod);
+ bool sync = BoundMethodBase::activatePack(pack, deleteMethod);
+ return sync ? pack->returnValue() : R();
}
- void invoke(Args... args) override
+ R invoke(Args... args) override
{
T *obj = static_cast<T *>(this->obj_);
return (obj->*func_)(args...);
}
private:
- void (T::*func_)(Args...);
+ R (T::*func_)(Args...);
};
template<typename R, typename... Args>
@@ -235,5 +222,3 @@ private:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_BASE_BOUND_METHOD_H__ */
diff --git a/include/libcamera/base/class.h b/include/libcamera/base/class.h
index 09806cd7..a808422e 100644
--- a/include/libcamera/base/class.h
+++ b/include/libcamera/base/class.h
@@ -2,10 +2,10 @@
/*
* Copyright (C) 2020, Google Inc.
*
- * class.h - Utilities and helpers for classes
+ * Utilities and helpers for classes
*/
-#ifndef __LIBCAMERA_BASE_CLASS_H__
-#define __LIBCAMERA_BASE_CLASS_H__
+
+#pragma once
#include <memory>
@@ -107,5 +107,3 @@ private:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_BASE_CLASS_H__ */
diff --git a/include/libcamera/base/event_dispatcher.h b/include/libcamera/base/event_dispatcher.h
index 825af7a3..408f8da6 100644
--- a/include/libcamera/base/event_dispatcher.h
+++ b/include/libcamera/base/event_dispatcher.h
@@ -2,12 +2,10 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * event_dispatcher.h - Event dispatcher
+ * Event dispatcher
*/
-#ifndef __LIBCAMERA_BASE_EVENT_DISPATCHER_H__
-#define __LIBCAMERA_BASE_EVENT_DISPATCHER_H__
-#include <vector>
+#pragma once
#include <libcamera/base/private.h>
@@ -33,5 +31,3 @@ public:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_BASE_EVENT_DISPATCHER_H__ */
diff --git a/include/libcamera/base/event_dispatcher_poll.h b/include/libcamera/base/event_dispatcher_poll.h
index 683934bf..1f7e05cf 100644
--- a/include/libcamera/base/event_dispatcher_poll.h
+++ b/include/libcamera/base/event_dispatcher_poll.h
@@ -2,10 +2,10 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * event_dispatcher_poll.h - Poll-based event dispatcher
+ * Poll-based event dispatcher
*/
-#ifndef __LIBCAMERA_BASE_EVENT_DISPATCHER_POLL_H__
-#define __LIBCAMERA_BASE_EVENT_DISPATCHER_POLL_H__
+
+#pragma once
#include <list>
#include <map>
@@ -14,6 +14,7 @@
#include <libcamera/base/private.h>
#include <libcamera/base/event_dispatcher.h>
+#include <libcamera/base/unique_fd.h>
struct pollfd;
@@ -50,11 +51,9 @@ private:
std::map<int, EventNotifierSetPoll> notifiers_;
std::list<Timer *> timers_;
- int eventfd_;
+ UniqueFD eventfd_;
bool processingEvents_;
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_BASE_EVENT_DISPATCHER_POLL_H__ */
diff --git a/include/libcamera/base/event_notifier.h b/include/libcamera/base/event_notifier.h
index 5055ccbf..158f2d44 100644
--- a/include/libcamera/base/event_notifier.h
+++ b/include/libcamera/base/event_notifier.h
@@ -2,10 +2,10 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * event_notifier.h - File descriptor event notifier
+ * File descriptor event notifier
*/
-#ifndef __LIBCAMERA_BASE_EVENT_NOTIFIER_H__
-#define __LIBCAMERA_BASE_EVENT_NOTIFIER_H__
+
+#pragma once
#include <libcamera/base/private.h>
@@ -34,7 +34,7 @@ public:
bool enabled() const { return enabled_; }
void setEnabled(bool enable);
- Signal<EventNotifier *> activated;
+ Signal<> activated;
protected:
void message(Message *msg) override;
@@ -46,5 +46,3 @@ private:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_BASE_EVENT_NOTIFIER_H__ */
diff --git a/include/libcamera/base/file.h b/include/libcamera/base/file.h
index 60851d38..6d3f106d 100644
--- a/include/libcamera/base/file.h
+++ b/include/libcamera/base/file.h
@@ -2,21 +2,22 @@
/*
* Copyright (C) 2020, Google Inc.
*
- * file.h - File I/O operations
+ * File I/O operations
*/
-#ifndef __LIBCAMERA_BASE_FILE_H__
-#define __LIBCAMERA_BASE_FILE_H__
-#include <sys/types.h>
+#pragma once
#include <map>
+#include <stdint.h>
#include <string>
+#include <sys/types.h>
#include <libcamera/base/private.h>
#include <libcamera/base/class.h>
#include <libcamera/base/flags.h>
#include <libcamera/base/span.h>
+#include <libcamera/base/unique_fd.h>
namespace libcamera {
@@ -48,7 +49,7 @@ public:
bool exists() const;
bool open(OpenMode mode);
- bool isOpen() const { return fd_ != -1; }
+ bool isOpen() const { return fd_.isValid(); }
OpenMode openMode() const { return mode_; }
void close();
@@ -73,7 +74,7 @@ private:
void unmapAll();
std::string name_;
- int fd_;
+ UniqueFD fd_;
OpenMode mode_;
int error_;
@@ -84,5 +85,3 @@ LIBCAMERA_FLAGS_ENABLE_OPERATORS(File::MapFlag)
LIBCAMERA_FLAGS_ENABLE_OPERATORS(File::OpenModeFlag)
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_BASE_FILE_H__ */
diff --git a/include/libcamera/base/flags.h b/include/libcamera/base/flags.h
index adec549d..af4f6e35 100644
--- a/include/libcamera/base/flags.h
+++ b/include/libcamera/base/flags.h
@@ -2,10 +2,10 @@
/*
* Copyright (C) 2020, Google Inc.
*
- * flags.h - Type-safe enum-based bitfields
+ * Type-safe enum-based bitfields
*/
-#ifndef __LIBCAMERA_BASE_FLAGS_H__
-#define __LIBCAMERA_BASE_FLAGS_H__
+
+#pragma once
#include <type_traits>
@@ -147,7 +147,7 @@ struct flags_enable_operators {
};
template<typename E>
-typename std::enable_if_t<flags_enable_operators<E>::enable, Flags<E>>
+std::enable_if_t<flags_enable_operators<E>::enable, Flags<E>>
operator|(E lhs, E rhs)
{
using type = std::underlying_type_t<E>;
@@ -155,7 +155,7 @@ operator|(E lhs, E rhs)
}
template<typename E>
-typename std::enable_if_t<flags_enable_operators<E>::enable, Flags<E>>
+std::enable_if_t<flags_enable_operators<E>::enable, Flags<E>>
operator&(E lhs, E rhs)
{
using type = std::underlying_type_t<E>;
@@ -163,7 +163,7 @@ operator&(E lhs, E rhs)
}
template<typename E>
-typename std::enable_if_t<flags_enable_operators<E>::enable, Flags<E>>
+std::enable_if_t<flags_enable_operators<E>::enable, Flags<E>>
operator^(E lhs, E rhs)
{
using type = std::underlying_type_t<E>;
@@ -171,7 +171,7 @@ operator^(E lhs, E rhs)
}
template<typename E>
-typename std::enable_if_t<flags_enable_operators<E>::enable, Flags<E>>
+std::enable_if_t<flags_enable_operators<E>::enable, Flags<E>>
operator~(E rhs)
{
using type = std::underlying_type_t<E>;
@@ -191,5 +191,3 @@ struct flags_enable_operators<_enum> { \
#endif /* __DOXYGEN__ */
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_BASE_FLAGS_H__ */
diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h
index 866a2133..62093012 100644
--- a/include/libcamera/base/log.h
+++ b/include/libcamera/base/log.h
@@ -2,12 +2,11 @@
/*
* Copyright (C) 2018, Google Inc.
*
- * log.h - Logging infrastructure
+ * Logging infrastructure
*/
-#ifndef __LIBCAMERA_BASE_LOG_H__
-#define __LIBCAMERA_BASE_LOG_H__
-#include <chrono>
+#pragma once
+
#include <sstream>
#include <libcamera/base/private.h>
@@ -29,16 +28,18 @@ enum LogSeverity {
class LogCategory
{
public:
- explicit LogCategory(const char *name);
+ static LogCategory *create(const char *name);
- const char *name() const { return name_; }
+ const std::string &name() const { return name_; }
LogSeverity severity() const { return severity_; }
void setSeverity(LogSeverity severity);
static const LogCategory &defaultCategory();
private:
- const char *name_;
+ explicit LogCategory(const char *name);
+
+ const std::string name_;
LogSeverity severity_;
};
@@ -46,10 +47,11 @@ private:
extern const LogCategory &_LOG_CATEGORY(name)();
#define LOG_DEFINE_CATEGORY(name) \
+LOG_DECLARE_CATEGORY(name) \
const LogCategory &_LOG_CATEGORY(name)() \
{ \
/* The instance will be deleted by the Logger destructor. */ \
- static LogCategory *category = new LogCategory(#name); \
+ static LogCategory *category = LogCategory::create(#name); \
return *category; \
}
@@ -57,7 +59,8 @@ class LogMessage
{
public:
LogMessage(const char *fileName, unsigned int line,
- const LogCategory &category, LogSeverity severity);
+ const LogCategory &category, LogSeverity severity,
+ const std::string &prefix = std::string());
LogMessage(LogMessage &&);
~LogMessage();
@@ -68,6 +71,7 @@ public:
LogSeverity severity() const { return severity_; }
const LogCategory &category() const { return category_; }
const std::string &fileInfo() const { return fileInfo_; }
+ const std::string &prefix() const { return prefix_; }
const std::string msg() const { return msgStream_.str(); }
private:
@@ -80,6 +84,7 @@ private:
LogSeverity severity_;
utils::time_point timestamp_;
std::string fileInfo_;
+ std::string prefix_;
};
class Loggable
@@ -128,5 +133,3 @@ LogMessage _log(const LogCategory *category, LogSeverity severity,
#endif
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_BASE_LOG_H__ */
diff --git a/include/libcamera/base/memfd.h b/include/libcamera/base/memfd.h
new file mode 100644
index 00000000..705d9929
--- /dev/null
+++ b/include/libcamera/base/memfd.h
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2024, Ideas on Board Oy
+ *
+ * Anonymous file creation
+ */
+
+#pragma once
+
+#include <libcamera/base/flags.h>
+#include <libcamera/base/unique_fd.h>
+
+namespace libcamera {
+
+class MemFd
+{
+public:
+ enum class Seal {
+ None = 0,
+ Shrink = (1 << 0),
+ Grow = (1 << 1),
+ };
+
+ using Seals = Flags<Seal>;
+
+ static UniqueFD create(const char *name, std::size_t size,
+ Seals seals = Seal::None);
+};
+
+LIBCAMERA_FLAGS_ENABLE_OPERATORS(MemFd::Seal)
+
+} /* namespace libcamera */
diff --git a/include/libcamera/base/meson.build b/include/libcamera/base/meson.build
index 9feb4b93..f28ae4d4 100644
--- a/include/libcamera/base/meson.build
+++ b/include/libcamera/base/meson.build
@@ -2,25 +2,39 @@
libcamera_base_include_dir = libcamera_include_dir / 'base'
-libcamera_base_headers = files([
+libcamera_base_public_headers = files([
'bound_method.h',
'class.h',
+ 'flags.h',
+ 'object.h',
+ 'shared_fd.h',
+ 'signal.h',
+ 'span.h',
+ 'unique_fd.h',
+])
+
+libcamera_base_private_headers = files([
+ 'backtrace.h',
'event_dispatcher.h',
'event_dispatcher_poll.h',
'event_notifier.h',
'file.h',
- 'flags.h',
'log.h',
+ 'memfd.h',
'message.h',
- 'object.h',
+ 'mutex.h',
'private.h',
'semaphore.h',
- 'signal.h',
- 'span.h',
'thread.h',
+ 'thread_annotations.h',
'timer.h',
'utils.h',
])
-install_headers(libcamera_base_headers,
- subdir: libcamera_base_include_dir)
+libcamera_base_headers = [
+ libcamera_base_public_headers,
+ libcamera_base_private_headers,
+]
+
+install_headers(libcamera_base_public_headers,
+ subdir : libcamera_base_include_dir)
diff --git a/include/libcamera/base/message.h b/include/libcamera/base/message.h
index 5d2a9f04..4b232031 100644
--- a/include/libcamera/base/message.h
+++ b/include/libcamera/base/message.h
@@ -2,13 +2,15 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * message.h - Message queue support
+ * Message queue support
*/
-#ifndef __LIBCAMERA_BASE_MESSAGE_H__
-#define __LIBCAMERA_BASE_MESSAGE_H__
+
+#pragma once
#include <atomic>
+#include <libcamera/base/private.h>
+
#include <libcamera/base/bound_method.h>
namespace libcamera {
@@ -67,5 +69,3 @@ private:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_BASE_MESSAGE_H__ */
diff --git a/include/libcamera/base/mutex.h b/include/libcamera/base/mutex.h
new file mode 100644
index 00000000..fa9a8d0d
--- /dev/null
+++ b/include/libcamera/base/mutex.h
@@ -0,0 +1,134 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2021, Google Inc.
+ *
+ * Mutex classes with clang thread safety annotation
+ */
+
+#pragma once
+
+#include <condition_variable>
+#include <mutex>
+
+#include <libcamera/base/private.h>
+
+#include <libcamera/base/thread_annotations.h>
+
+namespace libcamera {
+
+/* \todo using Mutex = std::mutex if libc++ is used. */
+
+#ifndef __DOXYGEN__
+
+class LIBCAMERA_TSA_CAPABILITY("mutex") Mutex final
+{
+public:
+ constexpr Mutex()
+ {
+ }
+
+ void lock() LIBCAMERA_TSA_ACQUIRE()
+ {
+ mutex_.lock();
+ }
+
+ void unlock() LIBCAMERA_TSA_RELEASE()
+ {
+ mutex_.unlock();
+ }
+
+private:
+ friend class MutexLocker;
+
+ std::mutex mutex_;
+};
+
+class LIBCAMERA_TSA_SCOPED_CAPABILITY MutexLocker final
+{
+public:
+ explicit MutexLocker(Mutex &mutex) LIBCAMERA_TSA_ACQUIRE(mutex)
+ : lock_(mutex.mutex_)
+ {
+ }
+
+ MutexLocker(Mutex &mutex, std::defer_lock_t t) noexcept LIBCAMERA_TSA_EXCLUDES(mutex)
+ : lock_(mutex.mutex_, t)
+ {
+ }
+
+ ~MutexLocker() LIBCAMERA_TSA_RELEASE()
+ {
+ }
+
+ void lock() LIBCAMERA_TSA_ACQUIRE()
+ {
+ lock_.lock();
+ }
+
+ bool try_lock() LIBCAMERA_TSA_TRY_ACQUIRE(true)
+ {
+ return lock_.try_lock();
+ }
+
+ void unlock() LIBCAMERA_TSA_RELEASE()
+ {
+ lock_.unlock();
+ }
+
+private:
+ friend class ConditionVariable;
+
+ std::unique_lock<std::mutex> lock_;
+};
+
+class ConditionVariable final
+{
+public:
+ ConditionVariable()
+ {
+ }
+
+ void notify_one() noexcept
+ {
+ cv_.notify_one();
+ }
+
+ void notify_all() noexcept
+ {
+ cv_.notify_all();
+ }
+
+ template<class Predicate>
+ void wait(MutexLocker &locker, Predicate stopWaiting)
+ {
+ cv_.wait(locker.lock_, stopWaiting);
+ }
+
+ template<class Rep, class Period, class Predicate>
+ bool wait_for(MutexLocker &locker,
+ const std::chrono::duration<Rep, Period> &relTime,
+ Predicate stopWaiting)
+ {
+ return cv_.wait_for(locker.lock_, relTime, stopWaiting);
+ }
+
+private:
+ std::condition_variable cv_;
+};
+
+#else /* __DOXYGEN__ */
+
+class Mutex final
+{
+};
+
+class MutexLocker final
+{
+};
+
+class ConditionVariable final
+{
+};
+
+#endif /* __DOXYGEN__ */
+} /* namespace libcamera */
diff --git a/include/libcamera/base/object.h b/include/libcamera/base/object.h
index 5c385ab4..508773cd 100644
--- a/include/libcamera/base/object.h
+++ b/include/libcamera/base/object.h
@@ -2,10 +2,10 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * object.h - Base object
+ * Base object
*/
-#ifndef __LIBCAMERA_BASE_OBJECT_H__
-#define __LIBCAMERA_BASE_OBJECT_H__
+
+#pragma once
#include <list>
#include <memory>
@@ -32,9 +32,9 @@ public:
void postMessage(std::unique_ptr<Message> msg);
template<typename T, typename R, typename... FuncArgs, typename... Args,
- typename std::enable_if_t<std::is_base_of<Object, T>::value> * = nullptr>
+ std::enable_if_t<std::is_base_of<Object, T>::value> * = nullptr>
R invokeMethod(R (T::*func)(FuncArgs...), ConnectionType type,
- Args... args)
+ Args&&... args)
{
T *obj = static_cast<T *>(this);
auto *method = new BoundMethodMember<T, R, FuncArgs...>(obj, this, func, type);
@@ -49,6 +49,8 @@ public:
protected:
virtual void message(Message *msg);
+ bool assertThreadBound(const char *message);
+
private:
friend class SignalBase;
friend class Thread;
@@ -67,5 +69,3 @@ private:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_BASE_OBJECT_H__ */
diff --git a/include/libcamera/base/private.h b/include/libcamera/base/private.h
index 163012bf..8670c40b 100644
--- a/include/libcamera/base/private.h
+++ b/include/libcamera/base/private.h
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2021, Google Inc.
*
- * private.h - Private Header Validation
+ * Private Header Validation
*
* A selection of internal libcamera headers are installed as part
* of the libcamera package to allow sharing of a select subset of
diff --git a/include/libcamera/base/semaphore.h b/include/libcamera/base/semaphore.h
index d8146eb8..59d4aa44 100644
--- a/include/libcamera/base/semaphore.h
+++ b/include/libcamera/base/semaphore.h
@@ -2,15 +2,14 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * semaphore.h - General-purpose counting semaphore
+ * General-purpose counting semaphore
*/
-#ifndef __LIBCAMERA_BASE_SEMAPHORE_H__
-#define __LIBCAMERA_BASE_SEMAPHORE_H__
-#include <condition_variable>
+#pragma once
#include <libcamera/base/private.h>
-#include <libcamera/base/thread.h>
+
+#include <libcamera/base/mutex.h>
namespace libcamera {
@@ -19,17 +18,15 @@ class Semaphore
public:
Semaphore(unsigned int n = 0);
- unsigned int available();
- void acquire(unsigned int n = 1);
- bool tryAcquire(unsigned int n = 1);
- void release(unsigned int n = 1);
+ unsigned int available() LIBCAMERA_TSA_EXCLUDES(mutex_);
+ void acquire(unsigned int n = 1) LIBCAMERA_TSA_EXCLUDES(mutex_);
+ bool tryAcquire(unsigned int n = 1) LIBCAMERA_TSA_EXCLUDES(mutex_);
+ void release(unsigned int n = 1) LIBCAMERA_TSA_EXCLUDES(mutex_);
private:
Mutex mutex_;
- std::condition_variable cv_;
- unsigned int available_;
+ ConditionVariable cv_;
+ unsigned int available_ LIBCAMERA_TSA_GUARDED_BY(mutex_);
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_BASE_SEMAPHORE_H__ */
diff --git a/include/libcamera/base/shared_fd.h b/include/libcamera/base/shared_fd.h
new file mode 100644
index 00000000..61fe11c1
--- /dev/null
+++ b/include/libcamera/base/shared_fd.h
@@ -0,0 +1,59 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2019, Google Inc.
+ *
+ * File descriptor wrapper with shared ownership
+ */
+
+#pragma once
+
+#include <memory>
+
+namespace libcamera {
+
+class UniqueFD;
+
+class SharedFD final
+{
+public:
+ explicit SharedFD(const int &fd = -1);
+ explicit SharedFD(int &&fd);
+ explicit SharedFD(UniqueFD fd);
+ SharedFD(const SharedFD &other);
+ SharedFD(SharedFD &&other);
+ ~SharedFD();
+
+ SharedFD &operator=(const SharedFD &other);
+ SharedFD &operator=(SharedFD &&other);
+
+ bool isValid() const { return fd_ != nullptr; }
+ int get() const { return fd_ ? fd_->fd() : -1; }
+ UniqueFD dup() const;
+
+private:
+ class Descriptor
+ {
+ public:
+ Descriptor(int fd, bool duplicate);
+ ~Descriptor();
+
+ int fd() const { return fd_; }
+
+ private:
+ int fd_;
+ };
+
+ std::shared_ptr<Descriptor> fd_;
+};
+
+static inline bool operator==(const SharedFD &lhs, const SharedFD &rhs)
+{
+ return lhs.get() == rhs.get();
+}
+
+static inline bool operator!=(const SharedFD &lhs, const SharedFD &rhs)
+{
+ return !(lhs == rhs);
+}
+
+} /* namespace libcamera */
diff --git a/include/libcamera/base/signal.h b/include/libcamera/base/signal.h
index c2521769..bbff1495 100644
--- a/include/libcamera/base/signal.h
+++ b/include/libcamera/base/signal.h
@@ -2,21 +2,21 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * signal.h - Signal & slot implementation
+ * Signal & slot implementation
*/
-#ifndef __LIBCAMERA_BASE_SIGNAL_H__
-#define __LIBCAMERA_BASE_SIGNAL_H__
+
+#pragma once
#include <functional>
#include <list>
#include <type_traits>
-#include <vector>
#include <libcamera/base/bound_method.h>
-#include <libcamera/base/object.h>
namespace libcamera {
+class Object;
+
class SignalBase
{
public:
@@ -44,7 +44,7 @@ public:
}
#ifndef __DOXYGEN__
- template<typename T, typename R, typename std::enable_if_t<std::is_base_of<Object, T>::value> * = nullptr>
+ template<typename T, typename R, std::enable_if_t<std::is_base_of<Object, T>::value> * = nullptr>
void connect(T *obj, R (T::*func)(Args...),
ConnectionType type = ConnectionTypeAuto)
{
@@ -52,7 +52,7 @@ public:
SignalBase::connect(new BoundMethodMember<T, R, Args...>(obj, object, func, type));
}
- template<typename T, typename R, typename std::enable_if_t<!std::is_base_of<Object, T>::value> * = nullptr>
+ template<typename T, typename R, std::enable_if_t<!std::is_base_of<Object, T>::value> * = nullptr>
#else
template<typename T, typename R>
#endif
@@ -61,6 +61,33 @@ public:
SignalBase::connect(new BoundMethodMember<T, R, Args...>(obj, nullptr, func));
}
+#ifndef __DOXYGEN__
+ template<typename T, typename Func,
+ std::enable_if_t<std::is_base_of<Object, T>::value
+#if __cplusplus >= 201703L
+ && std::is_invocable_v<Func, Args...>
+#endif
+ > * = nullptr>
+ void connect(T *obj, Func func, ConnectionType type = ConnectionTypeAuto)
+ {
+ Object *object = static_cast<Object *>(obj);
+ SignalBase::connect(new BoundMethodFunctor<T, void, Func, Args...>(obj, object, func, type));
+ }
+
+ template<typename T, typename Func,
+ std::enable_if_t<!std::is_base_of<Object, T>::value
+#if __cplusplus >= 201703L
+ && std::is_invocable_v<Func, Args...>
+#endif
+ > * = nullptr>
+#else
+ template<typename T, typename Func>
+#endif
+ void connect(T *obj, Func func)
+ {
+ SignalBase::connect(new BoundMethodFunctor<T, void, Func, Args...>(obj, nullptr, func));
+ }
+
template<typename R>
void connect(R (*func)(Args...))
{
@@ -128,5 +155,3 @@ public:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_BASE_SIGNAL_H__ */
diff --git a/include/libcamera/base/span.h b/include/libcamera/base/span.h
index 21099d56..92cce4f0 100644
--- a/include/libcamera/base/span.h
+++ b/include/libcamera/base/span.h
@@ -2,16 +2,14 @@
/*
* Copyright (C) 2020, Google Inc.
*
- * span.h - C++20 std::span<> implementation for C++11
+ * C++20 std::span<> implementation for C++11
*/
-#ifndef __LIBCAMERA_BASE_SPAN_H__
-#define __LIBCAMERA_BASE_SPAN_H__
+#pragma once
#include <array>
#include <iterator>
#include <limits>
-#include <stddef.h>
#include <type_traits>
namespace libcamera {
@@ -420,5 +418,3 @@ private:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_BASE_SPAN_H__ */
diff --git a/include/libcamera/base/thread.h b/include/libcamera/base/thread.h
index 762beab2..3209d4f7 100644
--- a/include/libcamera/base/thread.h
+++ b/include/libcamera/base/thread.h
@@ -2,13 +2,12 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * thread.h - Thread support
+ * Thread support
*/
-#ifndef __LIBCAMERA_BASE_THREAD_H__
-#define __LIBCAMERA_BASE_THREAD_H__
+
+#pragma once
#include <memory>
-#include <mutex>
#include <sys/types.h>
#include <thread>
@@ -16,6 +15,7 @@
#include <libcamera/base/message.h>
#include <libcamera/base/signal.h>
+#include <libcamera/base/span.h>
#include <libcamera/base/utils.h>
namespace libcamera {
@@ -26,9 +26,6 @@ class Object;
class ThreadData;
class ThreadMain;
-using Mutex = std::mutex;
-using MutexLocker = std::unique_lock<std::mutex>;
-
class Thread
{
public:
@@ -39,9 +36,11 @@ public:
void exit(int code = 0);
bool wait(utils::duration duration = utils::duration::max());
+ int setThreadAffinity(const Span<const unsigned int> &cpus);
+
bool isRunning();
- Signal<Thread *> finished;
+ Signal<> finished;
static Thread *current();
static pid_t currentId();
@@ -58,6 +57,8 @@ private:
void startThread();
void finishThread();
+ void setThreadAffinityInternal();
+
void postMessage(std::unique_ptr<Message> msg, Object *receiver);
void removeMessages(Object *receiver);
@@ -74,5 +75,3 @@ private:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_BASE_THREAD_H__ */
diff --git a/include/libcamera/base/thread_annotations.h b/include/libcamera/base/thread_annotations.h
new file mode 100644
index 00000000..81930f08
--- /dev/null
+++ b/include/libcamera/base/thread_annotations.h
@@ -0,0 +1,82 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2021, Google Inc.
+ *
+ * Macro of Clang thread safety analysis
+ */
+
+#pragma once
+
+#include <libcamera/base/private.h>
+
+/*
+ * Enable thread safety attributes only with clang.
+ * The attributes can be safely erased when compiling with other compilers.
+ */
+#if defined(__clang__) && !defined(SWIG)
+#define LIBCAMERA_TSA_ATTRIBUTE__(x) __attribute__((x))
+#else
+#define LIBCAMERA_TSA_ATTRIBUTE__(x) /* no-op */
+#endif
+
+/* See https://clang.llvm.org/docs/ThreadSafetyAnalysis.html for these usages. */
+
+#define LIBCAMERA_TSA_CAPABILITY(x) \
+ LIBCAMERA_TSA_ATTRIBUTE__(capability(x))
+
+#define LIBCAMERA_TSA_SCOPED_CAPABILITY \
+ LIBCAMERA_TSA_ATTRIBUTE__(scoped_lockable)
+
+#define LIBCAMERA_TSA_GUARDED_BY(x) \
+ LIBCAMERA_TSA_ATTRIBUTE__(guarded_by(x))
+
+#define LIBCAMERA_TSA_PT_GUARDED_BY(x) \
+ LIBCAMERA_TSA_ATTRIBUTE__(pt_guarded_by(x))
+
+#define LIBCAMERA_TSA_ACQUIRED_BEFORE(...) \
+ LIBCAMERA_TSA_ATTRIBUTE__(acquired_before(__VA_ARGS__))
+
+#define LIBCAMERA_TSA_ACQUIRED_AFTER(...) \
+ LIBCAMERA_TSA_ATTRIBUTE__(acquired_after(__VA_ARGS__))
+
+#define LIBCAMERA_TSA_REQUIRES(...) \
+ LIBCAMERA_TSA_ATTRIBUTE__(requires_capability(__VA_ARGS__))
+
+#define LIBCAMERA_TSA_REQUIRES_SHARED(...) \
+ LIBCAMERA_TSA_ATTRIBUTE__(requires_shared_capability(__VA_ARGS__))
+
+#define LIBCAMERA_TSA_ACQUIRE(...) \
+ LIBCAMERA_TSA_ATTRIBUTE__(acquire_capability(__VA_ARGS__))
+
+#define LIBCAMERA_TSA_ACQUIRE_SHARED(...) \
+ LIBCAMERA_TSA_ATTRIBUTE__(acquire_shared_capability(__VA_ARGS__))
+
+#define LIBCAMERA_TSA_RELEASE(...) \
+ LIBCAMERA_TSA_ATTRIBUTE__(release_capability(__VA_ARGS__))
+
+#define LIBCAMERA_TSA_RELEASE_SHARED(...) \
+ LIBCAMERA_TSA_ATTRIBUTE__(release_shared_capability(__VA_ARGS__))
+
+#define LIBCAMERA_TSA_RELEASE_GENERIC(...) \
+ LIBCAMERA_TSA_ATTRIBUTE__(release_generic_capability(__VA_ARGS__))
+
+#define LIBCAMERA_TSA_TRY_ACQUIRE(...) \
+ LIBCAMERA_TSA_ATTRIBUTE__(try_acquire_capability(__VA_ARGS__))
+
+#define LIBCAMERA_TSA_TRY_ACQUIRE_SHARED(...) \
+ LIBCAMERA_TSA_ATTRIBUTE__(try_acquire_shared_capability(__VA_ARGS__))
+
+#define LIBCAMERA_TSA_EXCLUDES(...) \
+ LIBCAMERA_TSA_ATTRIBUTE__(locks_excluded(__VA_ARGS__))
+
+#define LIBCAMERA_TSA_ASSERT_CAPABILITY(x) \
+ LIBCAMERA_TSA_ATTRIBUTE__(assert_capability(x))
+
+#define LIBCAMERA_TSA_ASSERT_SHARED_CAPABILITY(x) \
+ LIBCAMERA_TSA_ATTRIBUTE__(assert_shared_capability(x))
+
+#define LIBCAMERA_TSA_RETURN_CAPABILITY(x) \
+ LIBCAMERA_TSA_ATTRIBUTE__(lock_returned(x))
+
+#define LIBCAMERA_TSA_NO_THREAD_SAFETY_ANALYSIS \
+ LIBCAMERA_TSA_ATTRIBUTE__(no_thread_safety_analysis)
diff --git a/include/libcamera/base/timer.h b/include/libcamera/base/timer.h
index 79882161..9646a0fe 100644
--- a/include/libcamera/base/timer.h
+++ b/include/libcamera/base/timer.h
@@ -2,13 +2,12 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * timer.h - Generic timer
+ * Generic timer
*/
-#ifndef __LIBCAMERA_BASE_TIMER_H__
-#define __LIBCAMERA_BASE_TIMER_H__
+
+#pragma once
#include <chrono>
-#include <stdint.h>
#include <libcamera/base/private.h>
@@ -25,7 +24,6 @@ public:
Timer(Object *parent = nullptr);
~Timer();
- void start(unsigned int msec) { start(std::chrono::milliseconds(msec)); }
void start(std::chrono::milliseconds duration);
void start(std::chrono::steady_clock::time_point deadline);
void stop();
@@ -33,7 +31,7 @@ public:
std::chrono::steady_clock::time_point deadline() const { return deadline_; }
- Signal<Timer *> timeout;
+ Signal<> timeout;
protected:
void message(Message *msg) override;
@@ -47,5 +45,3 @@ private:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_BASE_TIMER_H__ */
diff --git a/include/libcamera/base/unique_fd.h b/include/libcamera/base/unique_fd.h
new file mode 100644
index 00000000..3066bf28
--- /dev/null
+++ b/include/libcamera/base/unique_fd.h
@@ -0,0 +1,68 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2021, Google Inc.
+ *
+ * File descriptor wrapper that owns a file descriptor.
+ */
+
+#pragma once
+
+#include <utility>
+
+#include <libcamera/base/class.h>
+
+namespace libcamera {
+
+class UniqueFD final
+{
+public:
+ UniqueFD()
+ : fd_(-1)
+ {
+ }
+
+ explicit UniqueFD(int fd)
+ : fd_(fd)
+ {
+ }
+
+ UniqueFD(UniqueFD &&other)
+ : fd_(other.release())
+ {
+ }
+
+ ~UniqueFD()
+ {
+ reset();
+ }
+
+ UniqueFD &operator=(UniqueFD &&other)
+ {
+ reset(other.release());
+ return *this;
+ }
+
+ [[nodiscard]] int release()
+ {
+ int fd = fd_;
+ fd_ = -1;
+ return fd;
+ }
+
+ void reset(int fd = -1);
+
+ void swap(UniqueFD &other)
+ {
+ std::swap(fd_, other.fd_);
+ }
+
+ int get() const { return fd_; }
+ bool isValid() const { return fd_ >= 0; }
+
+private:
+ LIBCAMERA_DISABLE_COPY(UniqueFD)
+
+ int fd_;
+};
+
+} /* namespace libcamera */
diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h
index 52301254..8d5c3578 100644
--- a/include/libcamera/base/utils.h
+++ b/include/libcamera/base/utils.h
@@ -2,19 +2,20 @@
/*
* Copyright (C) 2018, Google Inc.
*
- * utils.h - Miscellaneous utility functions
+ * Miscellaneous utility functions
*/
-#ifndef __LIBCAMERA_BASE_UTILS_H__
-#define __LIBCAMERA_BASE_UTILS_H__
+
+#pragma once
#include <algorithm>
#include <chrono>
+#include <functional>
#include <iterator>
-#include <memory>
#include <ostream>
#include <sstream>
-#include <string>
+#include <stdint.h>
#include <string.h>
+#include <string>
#include <sys/time.h>
#include <type_traits>
#include <utility>
@@ -91,6 +92,30 @@ _hex hex(T value, unsigned int width = 0);
#ifndef __DOXYGEN__
template<>
+inline _hex hex<int8_t>(int8_t value, unsigned int width)
+{
+ return { static_cast<uint64_t>(value), width ? width : 2 };
+}
+
+template<>
+inline _hex hex<uint8_t>(uint8_t value, unsigned int width)
+{
+ return { static_cast<uint64_t>(value), width ? width : 2 };
+}
+
+template<>
+inline _hex hex<int16_t>(int16_t value, unsigned int width)
+{
+ return { static_cast<uint64_t>(value), width ? width : 4 };
+}
+
+template<>
+inline _hex hex<uint16_t>(uint16_t value, unsigned int width)
+{
+ return { static_cast<uint64_t>(value), width ? width : 4 };
+}
+
+template<>
inline _hex hex<int32_t>(int32_t value, unsigned int width)
{
return { static_cast<uint64_t>(value), width ? width : 8 };
@@ -170,11 +195,26 @@ public:
class iterator
{
public:
+ using difference_type = std::size_t;
+ using value_type = std::string;
+ using pointer = value_type *;
+ using reference = value_type &;
+ using iterator_category = std::input_iterator_tag;
+
iterator(const StringSplitter *ss, std::string::size_type pos);
iterator &operator++();
std::string operator*() const;
- bool operator!=(const iterator &other) const;
+
+ bool operator==(const iterator &other) const
+ {
+ return pos_ == other.pos_;
+ }
+
+ bool operator!=(const iterator &other) const
+ {
+ return !(*this == other);
+ }
private:
const StringSplitter *ss_;
@@ -182,8 +222,15 @@ public:
std::string::size_type next_;
};
- iterator begin() const;
- iterator end() const;
+ iterator begin() const
+ {
+ return { this, 0 };
+ }
+
+ iterator end() const
+ {
+ return { this, std::string::npos };
+ }
private:
std::string str_;
@@ -246,7 +293,7 @@ private:
public:
using difference_type = typename std::iterator_traits<Base>::difference_type;
- using value_type = std::pair<const difference_type, base_reference>;
+ using value_type = std::pair<const std::size_t, base_reference>;
using pointer = value_type *;
using reference = value_type &;
using iterator_category = std::input_iterator_tag;
@@ -275,7 +322,7 @@ public:
private:
Base current_;
- difference_type pos_;
+ std::size_t pos_;
};
template<typename Base>
@@ -327,6 +374,12 @@ class Duration : public std::chrono::duration<double, std::nano>
public:
Duration() = default;
+ template<typename Rep>
+ constexpr explicit Duration(const Rep &r)
+ : BaseDuration(r)
+ {
+ }
+
template<typename Rep, typename Period>
constexpr Duration(const std::chrono::duration<Rep, Period> &d)
: BaseDuration(d)
@@ -346,6 +399,35 @@ public:
}
};
+template<typename T>
+decltype(auto) abs_diff(const T &a, const T &b)
+{
+ if (a < b)
+ return b - a;
+ else
+ return a - b;
+}
+
+double strtod(const char *__restrict nptr, char **__restrict endptr);
+
+template<class Enum>
+constexpr std::underlying_type_t<Enum> to_underlying(Enum e) noexcept
+{
+ return static_cast<std::underlying_type_t<Enum>>(e);
+}
+
+class ScopeExitActions
+{
+public:
+ ~ScopeExitActions();
+
+ void operator+=(std::function<void()> &&action);
+ void release();
+
+private:
+ std::vector<std::function<void()>> actions_;
+};
+
} /* namespace utils */
#ifndef __DOXYGEN__
@@ -355,5 +437,3 @@ std::basic_ostream<CharT, Traits> &operator<<(std::basic_ostream<CharT, Traits>
#endif
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_BASE_UTILS_H__ */
diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h
index 05cdab72..94cee7bd 100644
--- a/include/libcamera/camera.h
+++ b/include/libcamera/camera.h
@@ -2,24 +2,28 @@
/*
* Copyright (C) 2018, Google Inc.
*
- * camera.h - Camera object interface
+ * Camera object interface
*/
-#ifndef __LIBCAMERA_CAMERA_H__
-#define __LIBCAMERA_CAMERA_H__
+#pragma once
+
+#include <initializer_list>
#include <memory>
+#include <optional>
#include <set>
#include <stdint.h>
#include <string>
#include <libcamera/base/class.h>
+#include <libcamera/base/flags.h>
#include <libcamera/base/object.h>
#include <libcamera/base/signal.h>
#include <libcamera/controls.h>
+#include <libcamera/geometry.h>
+#include <libcamera/orientation.h>
#include <libcamera/request.h>
#include <libcamera/stream.h>
-#include <libcamera/transform.h>
namespace libcamera {
@@ -28,6 +32,30 @@ class FrameBufferAllocator;
class PipelineHandler;
class Request;
+class SensorConfiguration
+{
+public:
+ unsigned int bitDepth = 0;
+
+ Rectangle analogCrop;
+
+ struct {
+ unsigned int binX = 1;
+ unsigned int binY = 1;
+ } binning;
+
+ struct {
+ unsigned int xOddInc = 1;
+ unsigned int xEvenInc = 1;
+ unsigned int yOddInc = 1;
+ unsigned int yEvenInc = 1;
+ } skipping;
+
+ Size outputSize;
+
+ bool isValid() const;
+};
+
class CameraConfiguration
{
public:
@@ -64,11 +92,21 @@ public:
bool empty() const;
std::size_t size() const;
- Transform transform;
+ std::optional<SensorConfiguration> sensorConfig;
+ Orientation orientation;
protected:
CameraConfiguration();
+ enum class ColorSpaceFlag {
+ None,
+ StreamsShareColorSpace,
+ };
+
+ using ColorSpaceFlags = Flags<ColorSpaceFlag>;
+
+ Status validateColorSpaces(ColorSpaceFlags flags = ColorSpaceFlag::None);
+
std::vector<StreamConfiguration> config_;
};
@@ -86,7 +124,7 @@ public:
Signal<Request *, FrameBuffer *> bufferCompleted;
Signal<Request *> requestCompleted;
- Signal<Camera *> disconnected;
+ Signal<> disconnected;
int acquire();
int release();
@@ -95,7 +133,16 @@ public:
const ControlList &properties() const;
const std::set<Stream *> &streams() const;
- std::unique_ptr<CameraConfiguration> generateConfiguration(const StreamRoles &roles = {});
+
+ std::unique_ptr<CameraConfiguration>
+ generateConfiguration(Span<const StreamRole> roles = {});
+
+ std::unique_ptr<CameraConfiguration>
+ generateConfiguration(std::initializer_list<StreamRole> roles)
+ {
+ return generateConfiguration(Span(roles.begin(), roles.end()));
+ }
+
int configure(CameraConfiguration *config);
std::unique_ptr<Request> createRequest(uint64_t cookie = 0);
@@ -121,5 +168,3 @@ private:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_CAMERA_H__ */
diff --git a/include/libcamera/camera_manager.h b/include/libcamera/camera_manager.h
index 744e5a06..b50df782 100644
--- a/include/libcamera/camera_manager.h
+++ b/include/libcamera/camera_manager.h
@@ -2,10 +2,10 @@
/*
* Copyright (C) 2018, Google Inc.
*
- * camera_manager.h - Camera management
+ * Camera management
*/
-#ifndef __LIBCAMERA_CAMERA_MANAGER_H__
-#define __LIBCAMERA_CAMERA_MANAGER_H__
+
+#pragma once
#include <memory>
#include <string>
@@ -31,12 +31,7 @@ public:
void stop();
std::vector<std::shared_ptr<Camera>> cameras() const;
- std::shared_ptr<Camera> get(const std::string &name);
- std::shared_ptr<Camera> get(dev_t devnum);
-
- void addCamera(std::shared_ptr<Camera> camera,
- const std::vector<dev_t> &devnums);
- void removeCamera(std::shared_ptr<Camera> camera);
+ std::shared_ptr<Camera> get(const std::string &id);
static const std::string &version() { return version_; }
@@ -51,5 +46,3 @@ private:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_CAMERA_MANAGER_H__ */
diff --git a/include/libcamera/color_space.h b/include/libcamera/color_space.h
new file mode 100644
index 00000000..7b483cd1
--- /dev/null
+++ b/include/libcamera/color_space.h
@@ -0,0 +1,76 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2021, Raspberry Pi Ltd
+ *
+ * color space definitions
+ */
+
+#pragma once
+
+#include <optional>
+#include <string>
+
+namespace libcamera {
+
+class PixelFormat;
+
+class ColorSpace
+{
+public:
+ enum class Primaries {
+ Raw,
+ Smpte170m,
+ Rec709,
+ Rec2020,
+ };
+
+ enum class TransferFunction {
+ Linear,
+ Srgb,
+ Rec709,
+ };
+
+ enum class YcbcrEncoding {
+ None,
+ Rec601,
+ Rec709,
+ Rec2020,
+ };
+
+ enum class Range {
+ Full,
+ Limited,
+ };
+
+ constexpr ColorSpace(Primaries p, TransferFunction t, YcbcrEncoding e, Range r)
+ : primaries(p), transferFunction(t), ycbcrEncoding(e), range(r)
+ {
+ }
+
+ static const ColorSpace Raw;
+ static const ColorSpace Srgb;
+ static const ColorSpace Sycc;
+ static const ColorSpace Smpte170m;
+ static const ColorSpace Rec709;
+ static const ColorSpace Rec2020;
+
+ Primaries primaries;
+ TransferFunction transferFunction;
+ YcbcrEncoding ycbcrEncoding;
+ Range range;
+
+ std::string toString() const;
+ static std::string toString(const std::optional<ColorSpace> &colorSpace);
+
+ static std::optional<ColorSpace> fromString(const std::string &str);
+
+ bool adjust(PixelFormat format);
+};
+
+bool operator==(const ColorSpace &lhs, const ColorSpace &rhs);
+static inline bool operator!=(const ColorSpace &lhs, const ColorSpace &rhs)
+{
+ return !(lhs == rhs);
+}
+
+} /* namespace libcamera */
diff --git a/include/libcamera/compiler.h b/include/libcamera/compiler.h
deleted file mode 100644
index dc56dbb8..00000000
--- a/include/libcamera/compiler.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1-or-later */
-/*
- * Copyright (C) 2021, Google Inc.
- *
- * compiler.h - Compiler support
- */
-#ifndef __LIBCAMERA_COMPILER_H__
-#define __LIBCAMERA_COMPILER_H__
-
-#if __cplusplus >= 201703L
-#define __nodiscard [[nodiscard]]
-#else
-#define __nodiscard
-#endif
-
-#endif /* __LIBCAMERA_COMPILER_H__ */
diff --git a/include/libcamera/control_ids.h.in b/include/libcamera/control_ids.h.in
index 7edeb6b6..5d0594c6 100644
--- a/include/libcamera/control_ids.h.in
+++ b/include/libcamera/control_ids.h.in
@@ -2,39 +2,60 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * control_ids.h - Control ID list
+ * {{mode|capitalize}} ID list
*
* This file is auto-generated. Do not edit.
*/
-#ifndef __LIBCAMERA_CONTROL_IDS_H__
-#define __LIBCAMERA_CONTROL_IDS_H__
+#pragma once
#include <array>
+#include <map>
#include <stdint.h>
+#include <string>
#include <libcamera/controls.h>
namespace libcamera {
-namespace controls {
+namespace {{mode}} {
-enum {
-${ids}
-};
+extern const ControlIdMap {{mode}};
-${controls}
+{%- for vendor, ctrls in controls -%}
-extern const ControlIdMap controls;
+{% if vendor != 'libcamera' %}
+namespace {{vendor}} {
-namespace draft {
+#define LIBCAMERA_HAS_{{vendor|upper}}_VENDOR_{{mode|upper}}
+{%- endif %}
-${draft_controls}
+{% if ctrls %}
+enum {
+{%- for ctrl in ctrls %}
+ {{ctrl.name|snake_case|upper}} = {{ctrl.id}},
+{%- endfor %}
+};
+{% endif %}
+
+{% for ctrl in ctrls -%}
+{% if ctrl.is_enum -%}
+enum {{ctrl.name}}Enum {
+{%- for enum in ctrl.enum_values %}
+ {{enum.name}} = {{enum.value}},
+{%- endfor %}
+};
+extern const std::array<const ControlValue, {{ctrl.enum_values_count}}> {{ctrl.name}}Values;
+extern const std::map<std::string, {{ctrl.type}}> {{ctrl.name}}NameValueMap;
+{% endif -%}
+extern const Control<{{ctrl.type}}> {{ctrl.name}};
+{% endfor -%}
-} /* namespace draft */
+{% if vendor != 'libcamera' %}
+} /* namespace {{vendor}} */
+{% endif -%}
-} /* namespace controls */
+{% endfor %}
+} /* namespace {{mode}} */
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_CONTROL_IDS_H__ */
diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
index 6668e4bb..7c7828ae 100644
--- a/include/libcamera/controls.h
+++ b/include/libcamera/controls.h
@@ -2,13 +2,14 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * controls.h - Control handling
+ * Control handling
*/
-#ifndef __LIBCAMERA_CONTROLS_H__
-#define __LIBCAMERA_CONTROLS_H__
+#pragma once
#include <assert.h>
+#include <map>
+#include <optional>
#include <set>
#include <stdint.h>
#include <string>
@@ -16,6 +17,7 @@
#include <vector>
#include <libcamera/base/class.h>
+#include <libcamera/base/flags.h>
#include <libcamera/base/span.h>
#include <libcamera/geometry.h>
@@ -28,67 +30,102 @@ enum ControlType {
ControlTypeNone,
ControlTypeBool,
ControlTypeByte,
+ ControlTypeUnsigned16,
+ ControlTypeUnsigned32,
ControlTypeInteger32,
ControlTypeInteger64,
ControlTypeFloat,
ControlTypeString,
ControlTypeRectangle,
ControlTypeSize,
+ ControlTypePoint,
};
namespace details {
-template<typename T>
+template<typename T, typename = std::void_t<>>
struct control_type {
};
template<>
struct control_type<void> {
static constexpr ControlType value = ControlTypeNone;
+ static constexpr std::size_t size = 0;
};
template<>
struct control_type<bool> {
static constexpr ControlType value = ControlTypeBool;
+ static constexpr std::size_t size = 0;
};
template<>
struct control_type<uint8_t> {
static constexpr ControlType value = ControlTypeByte;
+ static constexpr std::size_t size = 0;
+};
+
+template<>
+struct control_type<uint16_t> {
+ static constexpr ControlType value = ControlTypeUnsigned16;
+ static constexpr std::size_t size = 0;
+};
+
+template<>
+struct control_type<uint32_t> {
+ static constexpr ControlType value = ControlTypeUnsigned32;
+ static constexpr std::size_t size = 0;
};
template<>
struct control_type<int32_t> {
static constexpr ControlType value = ControlTypeInteger32;
+ static constexpr std::size_t size = 0;
};
template<>
struct control_type<int64_t> {
static constexpr ControlType value = ControlTypeInteger64;
+ static constexpr std::size_t size = 0;
};
template<>
struct control_type<float> {
static constexpr ControlType value = ControlTypeFloat;
+ static constexpr std::size_t size = 0;
};
template<>
struct control_type<std::string> {
static constexpr ControlType value = ControlTypeString;
+ static constexpr std::size_t size = 0;
};
template<>
struct control_type<Rectangle> {
static constexpr ControlType value = ControlTypeRectangle;
+ static constexpr std::size_t size = 0;
};
template<>
struct control_type<Size> {
static constexpr ControlType value = ControlTypeSize;
+ static constexpr std::size_t size = 0;
+};
+
+template<>
+struct control_type<Point> {
+ static constexpr ControlType value = ControlTypePoint;
+ static constexpr std::size_t size = 0;
};
template<typename T, std::size_t N>
struct control_type<Span<T, N>> : public control_type<std::remove_cv_t<T>> {
+ static constexpr std::size_t size = N;
+};
+
+template<typename T>
+struct control_type<T, std::enable_if_t<std::is_enum_v<T>>> : public control_type<int32_t> {
};
} /* namespace details */
@@ -99,10 +136,10 @@ public:
ControlValue();
#ifndef __DOXYGEN__
- template<typename T, typename std::enable_if_t<!details::is_span<T>::value &&
- details::control_type<T>::value &&
- !std::is_same<std::string, std::remove_cv_t<T>>::value,
- std::nullptr_t> = nullptr>
+ template<typename T, std::enable_if_t<!details::is_span<T>::value &&
+ details::control_type<T>::value &&
+ !std::is_same<std::string, std::remove_cv_t<T>>::value,
+ std::nullptr_t> = nullptr>
ControlValue(const T &value)
: type_(ControlTypeNone), numElements_(0)
{
@@ -110,9 +147,9 @@ public:
&value, 1, sizeof(T));
}
- template<typename T, typename std::enable_if_t<details::is_span<T>::value ||
- std::is_same<std::string, std::remove_cv_t<T>>::value,
- std::nullptr_t> = nullptr>
+ template<typename T, std::enable_if_t<details::is_span<T>::value ||
+ std::is_same<std::string, std::remove_cv_t<T>>::value,
+ std::nullptr_t> = nullptr>
#else
template<typename T>
#endif
@@ -144,9 +181,9 @@ public:
}
#ifndef __DOXYGEN__
- template<typename T, typename std::enable_if_t<!details::is_span<T>::value &&
- !std::is_same<std::string, std::remove_cv_t<T>>::value,
- std::nullptr_t> = nullptr>
+ template<typename T, std::enable_if_t<!details::is_span<T>::value &&
+ !std::is_same<std::string, std::remove_cv_t<T>>::value,
+ std::nullptr_t> = nullptr>
T get() const
{
assert(type_ == details::control_type<std::remove_cv_t<T>>::value);
@@ -155,9 +192,9 @@ public:
return *reinterpret_cast<const T *>(data().data());
}
- template<typename T, typename std::enable_if_t<details::is_span<T>::value ||
- std::is_same<std::string, std::remove_cv_t<T>>::value,
- std::nullptr_t> = nullptr>
+ template<typename T, std::enable_if_t<details::is_span<T>::value ||
+ std::is_same<std::string, std::remove_cv_t<T>>::value,
+ std::nullptr_t> = nullptr>
#else
template<typename T>
#endif
@@ -168,22 +205,22 @@ public:
using V = typename T::value_type;
const V *value = reinterpret_cast<const V *>(data().data());
- return { value, numElements_ };
+ return T{ value, numElements_ };
}
#ifndef __DOXYGEN__
- template<typename T, typename std::enable_if_t<!details::is_span<T>::value &&
- !std::is_same<std::string, std::remove_cv_t<T>>::value,
- std::nullptr_t> = nullptr>
+ template<typename T, std::enable_if_t<!details::is_span<T>::value &&
+ !std::is_same<std::string, std::remove_cv_t<T>>::value,
+ std::nullptr_t> = nullptr>
void set(const T &value)
{
set(details::control_type<std::remove_cv_t<T>>::value, false,
reinterpret_cast<const void *>(&value), 1, sizeof(T));
}
- template<typename T, typename std::enable_if_t<details::is_span<T>::value ||
- std::is_same<std::string, std::remove_cv_t<T>>::value,
- std::nullptr_t> = nullptr>
+ template<typename T, std::enable_if_t<details::is_span<T>::value ||
+ std::is_same<std::string, std::remove_cv_t<T>>::value,
+ std::nullptr_t> = nullptr>
#else
template<typename T>
#endif
@@ -213,23 +250,44 @@ private:
class ControlId
{
public:
- ControlId(unsigned int id, const std::string &name, ControlType type)
- : id_(id), name_(name), type_(type)
- {
- }
+ enum class Direction {
+ In = (1 << 0),
+ Out = (1 << 1),
+ };
+
+ using DirectionFlags = Flags<Direction>;
+
+ ControlId(unsigned int id, const std::string &name, const std::string &vendor,
+ ControlType type, DirectionFlags direction,
+ std::size_t size = 0,
+ const std::map<std::string, int32_t> &enumStrMap = {});
unsigned int id() const { return id_; }
const std::string &name() const { return name_; }
+ const std::string &vendor() const { return vendor_; }
ControlType type() const { return type_; }
+ DirectionFlags direction() const { return direction_; }
+ bool isInput() const { return !!(direction_ & Direction::In); }
+ bool isOutput() const { return !!(direction_ & Direction::Out); }
+ bool isArray() const { return size_ > 0; }
+ std::size_t size() const { return size_; }
+ const std::map<int32_t, std::string> &enumerators() const { return reverseMap_; }
private:
LIBCAMERA_DISABLE_COPY_AND_MOVE(ControlId)
unsigned int id_;
std::string name_;
+ std::string vendor_;
ControlType type_;
+ DirectionFlags direction_;
+ std::size_t size_;
+ std::map<std::string, int32_t> enumStrMap_;
+ std::map<int32_t, std::string> reverseMap_;
};
+LIBCAMERA_FLAGS_ENABLE_OPERATORS(ControlId::Direction)
+
static inline bool operator==(unsigned int lhs, const ControlId &rhs)
{
return lhs == rhs.id();
@@ -256,8 +314,11 @@ class Control : public ControlId
public:
using type = T;
- Control(unsigned int id, const char *name)
- : ControlId(id, name, details::control_type<std::remove_cv_t<T>>::value)
+ Control(unsigned int id, const char *name, const char *vendor,
+ ControlId::DirectionFlags direction,
+ const std::map<std::string, int32_t> &enumStrMap = {})
+ : ControlId(id, name, vendor, details::control_type<std::remove_cv_t<T>>::value,
+ direction, details::control_type<std::remove_cv_t<T>>::size, enumStrMap)
{
}
@@ -268,9 +329,9 @@ private:
class ControlInfo
{
public:
- explicit ControlInfo(const ControlValue &min = 0,
- const ControlValue &max = 0,
- const ControlValue &def = 0);
+ explicit ControlInfo(const ControlValue &min = {},
+ const ControlValue &max = {},
+ const ControlValue &def = {});
explicit ControlInfo(Span<const ControlValue> values,
const ControlValue &def = {});
explicit ControlInfo(std::set<bool> values, bool def);
@@ -352,9 +413,14 @@ private:
using ControlListMap = std::unordered_map<unsigned int, ControlValue>;
public:
+ enum class MergePolicy {
+ KeepExisting = 0,
+ OverwriteExisting,
+ };
+
ControlList();
- ControlList(const ControlIdMap &idmap, ControlValidator *validator = nullptr);
- ControlList(const ControlInfoMap &infoMap, ControlValidator *validator = nullptr);
+ ControlList(const ControlIdMap &idmap, const ControlValidator *validator = nullptr);
+ ControlList(const ControlInfoMap &infoMap, const ControlValidator *validator = nullptr);
using iterator = ControlListMap::iterator;
using const_iterator = ControlListMap::const_iterator;
@@ -368,19 +434,19 @@ public:
std::size_t size() const { return controls_.size(); }
void clear() { controls_.clear(); }
- void merge(const ControlList &source);
+ void merge(const ControlList &source, MergePolicy policy = MergePolicy::KeepExisting);
- bool contains(const ControlId &id) const;
bool contains(unsigned int id) const;
template<typename T>
- T get(const Control<T> &ctrl) const
+ std::optional<T> get(const Control<T> &ctrl) const
{
- const ControlValue *val = find(ctrl.id());
- if (!val)
- return T{};
+ const auto entry = controls_.find(ctrl.id());
+ if (entry == controls_.end())
+ return std::nullopt;
- return val->get<T>();
+ const ControlValue &val = entry->second;
+ return val.get<T>();
}
template<typename T, typename V>
@@ -393,26 +459,27 @@ public:
val->set<T>(value);
}
- template<typename T, typename V>
- void set(const Control<T> &ctrl, const std::initializer_list<V> &value)
+ template<typename T, typename V, size_t Size>
+ void set(const Control<Span<T, Size>> &ctrl, const std::initializer_list<V> &value)
{
ControlValue *val = find(ctrl.id());
if (!val)
return;
- val->set<T>(Span<const typename std::remove_cv_t<V>>{ value.begin(), value.size() });
+ val->set(Span<const typename std::remove_cv_t<V>, Size>{ value.begin(), value.size() });
}
const ControlValue &get(unsigned int id) const;
void set(unsigned int id, const ControlValue &value);
const ControlInfoMap *infoMap() const { return infoMap_; }
+ const ControlIdMap *idMap() const { return idmap_; }
private:
const ControlValue *find(unsigned int id) const;
ControlValue *find(unsigned int id);
- ControlValidator *validator_;
+ const ControlValidator *validator_;
const ControlIdMap *idmap_;
const ControlInfoMap *infoMap_;
@@ -420,5 +487,3 @@ private:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_CONTROLS_H__ */
diff --git a/include/libcamera/fence.h b/include/libcamera/fence.h
new file mode 100644
index 00000000..598336cb
--- /dev/null
+++ b/include/libcamera/fence.h
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2021, Google Inc.
+ *
+ * Synchronization fence
+ */
+
+#pragma once
+
+#include <libcamera/base/class.h>
+#include <libcamera/base/unique_fd.h>
+
+namespace libcamera {
+
+class Fence
+{
+public:
+ Fence(UniqueFD fd);
+
+ bool isValid() const { return fd_.isValid(); }
+ const UniqueFD &fd() const { return fd_; }
+
+ UniqueFD release() { return std::move(fd_); }
+
+private:
+ LIBCAMERA_DISABLE_COPY_AND_MOVE(Fence)
+
+ UniqueFD fd_;
+};
+
+} /* namespace libcamera */
diff --git a/include/libcamera/file_descriptor.h b/include/libcamera/file_descriptor.h
deleted file mode 100644
index d514aac7..00000000
--- a/include/libcamera/file_descriptor.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1-or-later */
-/*
- * Copyright (C) 2019, Google Inc.
- *
- * file_descriptor.h - File descriptor wrapper
- */
-#ifndef __LIBCAMERA_FILE_DESCRIPTOR_H__
-#define __LIBCAMERA_FILE_DESCRIPTOR_H__
-
-#include <memory>
-
-namespace libcamera {
-
-class FileDescriptor final
-{
-public:
- explicit FileDescriptor(const int &fd = -1);
- explicit FileDescriptor(int &&fd);
- FileDescriptor(const FileDescriptor &other);
- FileDescriptor(FileDescriptor &&other);
- ~FileDescriptor();
-
- FileDescriptor &operator=(const FileDescriptor &other);
- FileDescriptor &operator=(FileDescriptor &&other);
-
- bool isValid() const { return fd_ != nullptr; }
- int fd() const { return fd_ ? fd_->fd() : -1; }
- FileDescriptor dup() const;
-
-private:
- class Descriptor
- {
- public:
- Descriptor(int fd, bool duplicate);
- ~Descriptor();
-
- int fd() const { return fd_; }
-
- private:
- int fd_;
- };
-
- std::shared_ptr<Descriptor> fd_;
-};
-
-} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_FILE_DESCRIPTOR_H__ */
diff --git a/include/libcamera/formats.h.in b/include/libcamera/formats.h.in
index 8e7b9581..6ae7634f 100644
--- a/include/libcamera/formats.h.in
+++ b/include/libcamera/formats.h.in
@@ -2,12 +2,12 @@
/*
* Copyright (C) 2020, Google Inc.
*
- * formats.h - Formats
+ * Formats
*
* This file is auto-generated. Do not edit.
*/
-#ifndef __LIBCAMERA_FORMATS_H__
-#define __LIBCAMERA_FORMATS_H__
+
+#pragma once
#include <stdint.h>
@@ -40,5 +40,3 @@ ${formats}
} /* namespace formats */
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_FORMATS_H__ */
diff --git a/include/libcamera/framebuffer.h b/include/libcamera/framebuffer.h
index d5aeff00..ff839243 100644
--- a/include/libcamera/framebuffer.h
+++ b/include/libcamera/framebuffer.h
@@ -2,22 +2,23 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * framebuffer.h - Frame buffer handling
+ * Frame buffer handling
*/
-#ifndef __LIBCAMERA_FRAMEBUFFER_H__
-#define __LIBCAMERA_FRAMEBUFFER_H__
-#include <assert.h>
+#pragma once
+
#include <limits>
+#include <memory>
#include <stdint.h>
#include <vector>
#include <libcamera/base/class.h>
-
-#include <libcamera/file_descriptor.h>
+#include <libcamera/base/shared_fd.h>
+#include <libcamera/base/span.h>
namespace libcamera {
+class Fence;
class Request;
struct FrameMetadata {
@@ -34,51 +35,43 @@ struct FrameMetadata {
Status status;
unsigned int sequence;
uint64_t timestamp;
- std::vector<Plane> planes;
+
+ Span<Plane> planes() { return planes_; }
+ Span<const Plane> planes() const { return planes_; }
+
+private:
+ friend class FrameBuffer;
+
+ std::vector<Plane> planes_;
};
-class FrameBuffer final : public Extensible
+class FrameBuffer : public Extensible
{
LIBCAMERA_DECLARE_PRIVATE()
public:
struct Plane {
static constexpr unsigned int kInvalidOffset = std::numeric_limits<unsigned int>::max();
- FileDescriptor fd;
+ SharedFD fd;
unsigned int offset = kInvalidOffset;
unsigned int length;
};
FrameBuffer(const std::vector<Plane> &planes, unsigned int cookie = 0);
+ FrameBuffer(std::unique_ptr<Private> d);
+ virtual ~FrameBuffer() {}
- const std::vector<Plane> &planes() const
- {
- /* \todo Remove the assertions after sufficient testing */
- for (const auto &plane : planes_)
- assert(plane.offset != Plane::kInvalidOffset);
- return planes_;
- }
-
+ const std::vector<Plane> &planes() const;
Request *request() const;
- const FrameMetadata &metadata() const { return metadata_; }
+ const FrameMetadata &metadata() const;
- unsigned int cookie() const { return cookie_; }
- void setCookie(unsigned int cookie) { cookie_ = cookie; }
+ uint64_t cookie() const;
+ void setCookie(uint64_t cookie);
- void cancel() { metadata_.status = FrameMetadata::FrameCancelled; }
+ std::unique_ptr<Fence> releaseFence();
private:
LIBCAMERA_DISABLE_COPY_AND_MOVE(FrameBuffer)
-
- friend class V4L2VideoDevice; /* Needed to update metadata_. */
-
- std::vector<Plane> planes_;
-
- FrameMetadata metadata_;
-
- unsigned int cookie_;
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_FRAMEBUFFER_H__ */
diff --git a/include/libcamera/framebuffer_allocator.h b/include/libcamera/framebuffer_allocator.h
index cbc9ce10..f3896bf2 100644
--- a/include/libcamera/framebuffer_allocator.h
+++ b/include/libcamera/framebuffer_allocator.h
@@ -2,10 +2,10 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * framebuffer_allocator.h - FrameBuffer allocator
+ * FrameBuffer allocator
*/
-#ifndef __LIBCAMERA_FRAMEBUFFER_ALLOCATOR_H__
-#define __LIBCAMERA_FRAMEBUFFER_ALLOCATOR_H__
+
+#pragma once
#include <map>
#include <memory>
@@ -39,5 +39,3 @@ private:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_FRAMEBUFFER_ALLOCATOR_H__ */
diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h
index fdd1b467..f322e3d5 100644
--- a/include/libcamera/geometry.h
+++ b/include/libcamera/geometry.h
@@ -2,17 +2,15 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * geometry.h - Geometry-related classes
+ * Geometry-related classes
*/
-#ifndef __LIBCAMERA_GEOMETRY_H__
-#define __LIBCAMERA_GEOMETRY_H__
+#pragma once
#include <algorithm>
+#include <ostream>
#include <string>
-#include <libcamera/compiler.h>
-
namespace libcamera {
class Rectangle;
@@ -47,6 +45,8 @@ static inline bool operator!=(const Point &lhs, const Point &rhs)
return !(lhs == rhs);
}
+std::ostream &operator<<(std::ostream &out, const Point &p);
+
class Size
{
public:
@@ -94,8 +94,22 @@ public:
return *this;
}
- __nodiscard constexpr Size alignedDownTo(unsigned int hAlignment,
- unsigned int vAlignment) const
+ Size &growBy(const Size &margins)
+ {
+ width += margins.width;
+ height += margins.height;
+ return *this;
+ }
+
+ Size &shrinkBy(const Size &margins)
+ {
+ width = width > margins.width ? width - margins.width : 0;
+ height = height > margins.height ? height - margins.height : 0;
+ return *this;
+ }
+
+ [[nodiscard]] constexpr Size alignedDownTo(unsigned int hAlignment,
+ unsigned int vAlignment) const
{
return {
width / hAlignment * hAlignment,
@@ -103,8 +117,8 @@ public:
};
}
- __nodiscard constexpr Size alignedUpTo(unsigned int hAlignment,
- unsigned int vAlignment) const
+ [[nodiscard]] constexpr Size alignedUpTo(unsigned int hAlignment,
+ unsigned int vAlignment) const
{
return {
(width + hAlignment - 1) / hAlignment * hAlignment,
@@ -112,7 +126,7 @@ public:
};
}
- __nodiscard constexpr Size boundedTo(const Size &bound) const
+ [[nodiscard]] constexpr Size boundedTo(const Size &bound) const
{
return {
std::min(width, bound.width),
@@ -120,7 +134,7 @@ public:
};
}
- __nodiscard constexpr Size expandedTo(const Size &expand) const
+ [[nodiscard]] constexpr Size expandedTo(const Size &expand) const
{
return {
std::max(width, expand.width),
@@ -128,10 +142,26 @@ public:
};
}
- __nodiscard Size boundedToAspectRatio(const Size &ratio) const;
- __nodiscard Size expandedToAspectRatio(const Size &ratio) const;
+ [[nodiscard]] constexpr Size grownBy(const Size &margins) const
+ {
+ return {
+ width + margins.width,
+ height + margins.height
+ };
+ }
+
+ [[nodiscard]] constexpr Size shrunkBy(const Size &margins) const
+ {
+ return {
+ width > margins.width ? width - margins.width : 0,
+ height > margins.height ? height - margins.height : 0
+ };
+ }
+
+ [[nodiscard]] Size boundedToAspectRatio(const Size &ratio) const;
+ [[nodiscard]] Size expandedToAspectRatio(const Size &ratio) const;
- __nodiscard Rectangle centeredTo(const Point &center) const;
+ [[nodiscard]] Rectangle centeredTo(const Point &center) const;
Size operator*(float factor) const;
Size operator/(float factor) const;
@@ -163,6 +193,8 @@ static inline bool operator>=(const Size &lhs, const Size &rhs)
return !(lhs < rhs);
}
+std::ostream &operator<<(std::ostream &out, const Size &s);
+
class SizeRange
{
public:
@@ -203,6 +235,8 @@ static inline bool operator!=(const SizeRange &lhs, const SizeRange &rhs)
return !(lhs == rhs);
}
+std::ostream &operator<<(std::ostream &out, const SizeRange &sr);
+
class Rectangle
{
public:
@@ -226,6 +260,15 @@ public:
{
}
+ constexpr Rectangle(const Point &point1, const Point &point2)
+ : Rectangle(std::min(point1.x, point2.x), std::min(point1.y, point2.y),
+ static_cast<unsigned int>(std::max(point1.x, point2.x)) -
+ static_cast<unsigned int>(std::min(point1.x, point2.x)),
+ static_cast<unsigned int>(std::max(point1.y, point2.y)) -
+ static_cast<unsigned int>(std::min(point1.y, point2.y)))
+ {
+ }
+
int x;
int y;
unsigned int width;
@@ -249,11 +292,14 @@ public:
Rectangle &scaleBy(const Size &numerator, const Size &denominator);
Rectangle &translateBy(const Point &point);
- __nodiscard Rectangle boundedTo(const Rectangle &bound) const;
- __nodiscard Rectangle enclosedIn(const Rectangle &boundary) const;
- __nodiscard Rectangle scaledBy(const Size &numerator,
- const Size &denominator) const;
- __nodiscard Rectangle translatedBy(const Point &point) const;
+ [[nodiscard]] Rectangle boundedTo(const Rectangle &bound) const;
+ [[nodiscard]] Rectangle enclosedIn(const Rectangle &boundary) const;
+ [[nodiscard]] Rectangle scaledBy(const Size &numerator,
+ const Size &denominator) const;
+ [[nodiscard]] Rectangle translatedBy(const Point &point) const;
+
+ Rectangle transformedBetween(const Rectangle &source,
+ const Rectangle &target) const;
};
bool operator==(const Rectangle &lhs, const Rectangle &rhs);
@@ -262,6 +308,6 @@ static inline bool operator!=(const Rectangle &lhs, const Rectangle &rhs)
return !(lhs == rhs);
}
-} /* namespace libcamera */
+std::ostream &operator<<(std::ostream &out, const Rectangle &r);
-#endif /* __LIBCAMERA_GEOMETRY_H__ */
+} /* namespace libcamera */
diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h
index 723382d4..5c14bb5f 100644
--- a/include/libcamera/internal/bayer_format.h
+++ b/include/libcamera/internal/bayer_format.h
@@ -1,15 +1,18 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
- * Copyright (C) 2020, Raspberry Pi (Trading) Ltd.
+ * Copyright (C) 2020, Raspberry Pi Ltd
*
- * bayer_format.h - Bayer Pixel Format
+ * Bayer Pixel Format
*/
-#ifndef __LIBCAMERA_INTERNAL_BAYER_FORMAT_H__
-#define __LIBCAMERA_INTERNAL_BAYER_FORMAT_H__
+#pragma once
+
+#include <ostream>
#include <stdint.h>
#include <string>
+#include <libcamera/pixel_format.h>
+
#include "libcamera/internal/v4l2_pixelformat.h"
namespace libcamera {
@@ -27,10 +30,12 @@ public:
MONO = 4
};
- enum Packing : uint16_t {
+ enum class Packing : uint16_t {
None = 0,
- CSI2Packed = 1,
- IPU3Packed = 2,
+ CSI2 = 1,
+ IPU3 = 2,
+ PISP1 = 3,
+ PISP2 = 4,
};
constexpr BayerFormat()
@@ -50,6 +55,8 @@ public:
V4L2PixelFormat toV4L2PixelFormat() const;
static BayerFormat fromV4L2PixelFormat(V4L2PixelFormat v4l2Format);
+ PixelFormat toPixelFormat() const;
+ static BayerFormat fromPixelFormat(PixelFormat format);
BayerFormat transform(Transform t) const;
Order order;
@@ -64,6 +71,6 @@ static inline bool operator!=(const BayerFormat &lhs, const BayerFormat &rhs)
return !(lhs == rhs);
}
-} /* namespace libcamera */
+std::ostream &operator<<(std::ostream &out, const BayerFormat &f);
-#endif /* __LIBCAMERA_INTERNAL_BAYER_FORMAT_H__ */
+} /* namespace libcamera */
diff --git a/include/libcamera/internal/byte_stream_buffer.h b/include/libcamera/internal/byte_stream_buffer.h
index d0f0df5e..5b1c10ab 100644
--- a/include/libcamera/internal/byte_stream_buffer.h
+++ b/include/libcamera/internal/byte_stream_buffer.h
@@ -2,10 +2,10 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * byte_stream_buffer.h - Byte stream buffer
+ * Byte stream buffer
*/
-#ifndef __LIBCAMERA_INTERNAL_BYTE_STREAM_BUFFER_H__
-#define __LIBCAMERA_INTERNAL_BYTE_STREAM_BUFFER_H__
+
+#pragma once
#include <stddef.h>
#include <stdint.h>
@@ -85,5 +85,3 @@ private:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_INTERNAL_BYTE_STREAM_BUFFER_H__ */
diff --git a/include/libcamera/internal/camera.h b/include/libcamera/internal/camera.h
index 1a08da0c..18f5c32a 100644
--- a/include/libcamera/internal/camera.h
+++ b/include/libcamera/internal/camera.h
@@ -2,15 +2,16 @@
/*
* Copyright (C) 2021, Google Inc.
*
- * camera.h - Camera private data
+ * Camera private data
*/
-#ifndef __LIBCAMERA_INTERNAL_CAMERA_H__
-#define __LIBCAMERA_INTERNAL_CAMERA_H__
+
+#pragma once
#include <atomic>
#include <list>
#include <memory>
#include <set>
+#include <stdint.h>
#include <string>
#include <libcamera/base/class.h>
@@ -19,6 +20,7 @@
namespace libcamera {
+class CameraControlValidator;
class PipelineHandler;
class Stream;
@@ -31,6 +33,7 @@ public:
~Private();
PipelineHandler *pipe() { return pipe_.get(); }
+ const PipelineHandler *pipe() const { return pipe_.get(); }
std::list<Request *> queuedRequests_;
ControlInfoMap controlInfo_;
@@ -38,6 +41,8 @@ public:
uint32_t requestSequence_;
+ const CameraControlValidator *validator() const { return validator_.get(); }
+
private:
enum State {
CameraAvailable,
@@ -47,6 +52,7 @@ private:
CameraRunning,
};
+ bool isAcquired() const;
bool isRunning() const;
int isAccessAllowed(State state, bool allowDisconnected = false,
const char *from = __builtin_FUNCTION()) const;
@@ -64,8 +70,8 @@ private:
bool disconnected_;
std::atomic<State> state_;
+
+ std::unique_ptr<CameraControlValidator> validator_;
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_INTERNAL_CAMERA_H__ */
diff --git a/include/libcamera/internal/camera_controls.h b/include/libcamera/internal/camera_controls.h
index 6e40f443..4a5a3ebc 100644
--- a/include/libcamera/internal/camera_controls.h
+++ b/include/libcamera/internal/camera_controls.h
@@ -2,10 +2,10 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * camera_controls.h - Camera controls
+ * Camera controls
*/
-#ifndef __LIBCAMERA_INTERNAL_CAMERA_CONTROLS_H__
-#define __LIBCAMERA_INTERNAL_CAMERA_CONTROLS_H__
+
+#pragma once
#include "libcamera/internal/control_validator.h"
@@ -26,5 +26,3 @@ private:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_INTERNAL_CAMERA_CONTROLS_H__ */
diff --git a/include/libcamera/internal/camera_lens.h b/include/libcamera/internal/camera_lens.h
new file mode 100644
index 00000000..f347c5e0
--- /dev/null
+++ b/include/libcamera/internal/camera_lens.h
@@ -0,0 +1,50 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2021, Google Inc.
+ *
+ * A camera lens controller
+ */
+#pragma once
+
+#include <memory>
+#include <stdint.h>
+#include <string>
+
+#include <libcamera/base/class.h>
+#include <libcamera/base/log.h>
+
+#include <libcamera/controls.h>
+
+namespace libcamera {
+
+class MediaEntity;
+class V4L2Subdevice;
+
+class CameraLens : protected Loggable
+{
+public:
+ explicit CameraLens(const MediaEntity *entity);
+ ~CameraLens();
+
+ int init();
+ int setFocusPosition(int32_t position);
+
+ const std::string &model() const { return model_; }
+
+ const ControlInfoMap &controls() const;
+
+protected:
+ std::string logPrefix() const override;
+
+private:
+ LIBCAMERA_DISABLE_COPY_AND_MOVE(CameraLens)
+
+ int validateLensDriver();
+
+ const MediaEntity *entity_;
+ std::unique_ptr<V4L2Subdevice> subdev_;
+
+ std::string model_;
+};
+
+} /* namespace libcamera */
diff --git a/include/libcamera/internal/camera_manager.h b/include/libcamera/internal/camera_manager.h
new file mode 100644
index 00000000..0150ca61
--- /dev/null
+++ b/include/libcamera/internal/camera_manager.h
@@ -0,0 +1,71 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2023, Ideas on Board Oy.
+ *
+ * Camera manager private data
+ */
+
+#pragma once
+
+#include <libcamera/camera_manager.h>
+
+#include <memory>
+#include <sys/types.h>
+#include <vector>
+
+#include <libcamera/base/class.h>
+#include <libcamera/base/mutex.h>
+#include <libcamera/base/thread.h>
+#include <libcamera/base/thread_annotations.h>
+
+#include "libcamera/internal/process.h"
+
+namespace libcamera {
+
+class Camera;
+class DeviceEnumerator;
+class IPAManager;
+class PipelineHandlerFactoryBase;
+
+class CameraManager::Private : public Extensible::Private, public Thread
+{
+ LIBCAMERA_DECLARE_PUBLIC(CameraManager)
+
+public:
+ Private();
+
+ int start();
+ void addCamera(std::shared_ptr<Camera> camera) LIBCAMERA_TSA_EXCLUDES(mutex_);
+ void removeCamera(std::shared_ptr<Camera> camera) LIBCAMERA_TSA_EXCLUDES(mutex_);
+
+ IPAManager *ipaManager() const { return ipaManager_.get(); }
+
+protected:
+ void run() override;
+
+private:
+ int init();
+ void createPipelineHandlers();
+ void pipelineFactoryMatch(const PipelineHandlerFactoryBase *factory);
+ void cleanup() LIBCAMERA_TSA_EXCLUDES(mutex_);
+
+ /*
+ * This mutex protects
+ *
+ * - initialized_ and status_ during initialization
+ * - cameras_ after initialization
+ */
+ mutable Mutex mutex_;
+ std::vector<std::shared_ptr<Camera>> cameras_ LIBCAMERA_TSA_GUARDED_BY(mutex_);
+
+ ConditionVariable cv_;
+ bool initialized_ LIBCAMERA_TSA_GUARDED_BY(mutex_);
+ int status_ LIBCAMERA_TSA_GUARDED_BY(mutex_);
+
+ std::unique_ptr<DeviceEnumerator> enumerator_;
+
+ std::unique_ptr<IPAManager> ipaManager_;
+ ProcessManager processManager_;
+};
+
+} /* namespace libcamera */
diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h
index d25a1165..13048f32 100644
--- a/include/libcamera/internal/camera_sensor.h
+++ b/include/libcamera/internal/camera_sensor.h
@@ -2,97 +2,130 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * camera_sensor.h - A camera sensor
+ * A camera sensor
*/
-#ifndef __LIBCAMERA_INTERNAL_CAMERA_SENSOR_H__
-#define __LIBCAMERA_INTERNAL_CAMERA_SENSOR_H__
+
+#pragma once
#include <memory>
+#include <stdint.h>
#include <string>
+#include <variant>
#include <vector>
#include <libcamera/base/class.h>
-#include <libcamera/base/log.h>
+#include <libcamera/control_ids.h>
#include <libcamera/controls.h>
#include <libcamera/geometry.h>
-#include <libcamera/ipa/core_ipa_interface.h>
+#include <libcamera/orientation.h>
+#include <libcamera/transform.h>
-#include "libcamera/internal/formats.h"
+#include "libcamera/internal/bayer_format.h"
+#include "libcamera/internal/camera_sensor_properties.h"
#include "libcamera/internal/v4l2_subdevice.h"
namespace libcamera {
-class BayerFormat;
+class CameraLens;
class MediaEntity;
+class SensorConfiguration;
+
+enum class Orientation;
-class CameraSensor : protected Loggable
+struct IPACameraSensorInfo;
+
+class CameraSensor
{
public:
- explicit CameraSensor(const MediaEntity *entity);
- ~CameraSensor();
-
- int init();
-
- const std::string &model() const { return model_; }
- const std::string &id() const { return id_; }
- const MediaEntity *entity() const { return entity_; }
- const std::vector<unsigned int> &mbusCodes() const { return mbusCodes_; }
- const std::vector<Size> sizes(unsigned int mbusCode) const;
- Size resolution() const;
- const std::vector<int32_t> &testPatternModes() const
- {
- return testPatternModes_;
- }
+ virtual ~CameraSensor();
+
+ virtual const std::string &model() const = 0;
+ virtual const std::string &id() const = 0;
+
+ virtual const MediaEntity *entity() const = 0;
+ virtual V4L2Subdevice *device() = 0;
- V4L2SubdeviceFormat getFormat(const std::vector<unsigned int> &mbusCodes,
- const Size &size) const;
- int setFormat(V4L2SubdeviceFormat *format);
+ virtual CameraLens *focusLens() = 0;
- const ControlInfoMap &controls() const;
- ControlList getControls(const std::vector<uint32_t> &ids);
- int setControls(ControlList *ctrls);
+ virtual const std::vector<unsigned int> &mbusCodes() const = 0;
+ virtual std::vector<Size> sizes(unsigned int mbusCode) const = 0;
+ virtual Size resolution() const = 0;
- V4L2Subdevice *device() { return subdev_.get(); }
+ virtual V4L2SubdeviceFormat
+ getFormat(const std::vector<unsigned int> &mbusCodes,
+ const Size &size, const Size maxSize = Size()) const = 0;
+ virtual int setFormat(V4L2SubdeviceFormat *format,
+ Transform transform = Transform::Identity) = 0;
+ virtual int tryFormat(V4L2SubdeviceFormat *format) const = 0;
- const ControlList &properties() const { return properties_; }
- int sensorInfo(IPACameraSensorInfo *info) const;
+ virtual int applyConfiguration(const SensorConfiguration &config,
+ Transform transform = Transform::Identity,
+ V4L2SubdeviceFormat *sensorFormat = nullptr) = 0;
- void updateControlInfo();
+ virtual V4L2Subdevice::Stream imageStream() const;
+ virtual std::optional<V4L2Subdevice::Stream> embeddedDataStream() const;
+ virtual V4L2SubdeviceFormat embeddedDataFormat() const;
+ virtual int setEmbeddedDataEnabled(bool enable);
-protected:
- std::string logPrefix() const override;
+ virtual const ControlList &properties() const = 0;
+ virtual int sensorInfo(IPACameraSensorInfo *info) const = 0;
+ virtual Transform computeTransform(Orientation *orientation) const = 0;
+ virtual BayerFormat::Order bayerOrder(Transform t) const = 0;
+
+ virtual const ControlInfoMap &controls() const = 0;
+ virtual ControlList getControls(const std::vector<uint32_t> &ids) = 0;
+ virtual int setControls(ControlList *ctrls) = 0;
+
+ virtual const std::vector<controls::draft::TestPatternModeEnum> &
+ testPatternModes() const = 0;
+ virtual int setTestPatternMode(controls::draft::TestPatternModeEnum mode) = 0;
+ virtual const CameraSensorProperties::SensorDelays &sensorDelays() = 0;
+};
+
+class CameraSensorFactoryBase
+{
+public:
+ CameraSensorFactoryBase(const char *name, int priority);
+ virtual ~CameraSensorFactoryBase() = default;
+
+ static std::unique_ptr<CameraSensor> create(MediaEntity *entity);
+
+ const std::string &name() const { return name_; }
+ int priority() const { return priority_; }
private:
- LIBCAMERA_DISABLE_COPY(CameraSensor)
+ LIBCAMERA_DISABLE_COPY_AND_MOVE(CameraSensorFactoryBase)
- int generateId();
- int validateSensorDriver();
- void initVimcDefaultProperties();
- void initStaticProperties();
- void initTestPatternModes(
- const std::map<int32_t, int32_t> &testPatternModeMap);
- int initProperties();
+ static std::vector<CameraSensorFactoryBase *> &factories();
- const MediaEntity *entity_;
- std::unique_ptr<V4L2Subdevice> subdev_;
- unsigned int pad_;
+ static void registerFactory(CameraSensorFactoryBase *factory);
- std::string model_;
- std::string id_;
+ virtual std::variant<std::unique_ptr<CameraSensor>, int>
+ match(MediaEntity *entity) const = 0;
- V4L2Subdevice::Formats formats_;
- std::vector<unsigned int> mbusCodes_;
- std::vector<Size> sizes_;
- std::vector<int32_t> testPatternModes_;
+ std::string name_;
+ int priority_;
+};
- Size pixelArraySize_;
- Rectangle activeArea_;
- const BayerFormat *bayerFormat_;
+template<typename _CameraSensor>
+class CameraSensorFactory final : public CameraSensorFactoryBase
+{
+public:
+ CameraSensorFactory(const char *name, int priority)
+ : CameraSensorFactoryBase(name, priority)
+ {
+ }
- ControlList properties_;
+private:
+ std::variant<std::unique_ptr<CameraSensor>, int>
+ match(MediaEntity *entity) const override
+ {
+ return _CameraSensor::match(entity);
+ }
};
-} /* namespace libcamera */
+#define REGISTER_CAMERA_SENSOR(sensor, priority) \
+static CameraSensorFactory<sensor> global_##sensor##Factory{ #sensor, priority };
-#endif /* __LIBCAMERA_INTERNAL_CAMERA_SENSOR_H__ */
+} /* namespace libcamera */
diff --git a/include/libcamera/internal/camera_sensor_properties.h b/include/libcamera/internal/camera_sensor_properties.h
index 67c77920..d7d4dab6 100644
--- a/include/libcamera/internal/camera_sensor_properties.h
+++ b/include/libcamera/internal/camera_sensor_properties.h
@@ -2,25 +2,33 @@
/*
* Copyright (C) 2021, Google Inc.
*
- * camera_sensor_properties.h - Database of camera sensor properties
+ * Database of camera sensor properties
*/
-#ifndef __LIBCAMERA_SENSOR_CAMERA_SENSOR_PROPERTIES_H__
-#define __LIBCAMERA_SENSOR_CAMERA_SENSOR_PROPERTIES_H__
+
+#pragma once
#include <map>
+#include <stdint.h>
#include <string>
+#include <libcamera/control_ids.h>
#include <libcamera/geometry.h>
namespace libcamera {
struct CameraSensorProperties {
+ struct SensorDelays {
+ uint8_t exposureDelay;
+ uint8_t gainDelay;
+ uint8_t vblankDelay;
+ uint8_t hblankDelay;
+ };
+
static const CameraSensorProperties *get(const std::string &sensor);
Size unitCellSize;
- std::map<int32_t, int32_t> testPatternModes;
+ std::map<controls::draft::TestPatternModeEnum, int32_t> testPatternModes;
+ SensorDelays sensorDelays;
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_SENSOR_CAMERA_SENSOR_PROPERTIES_H__ */
diff --git a/include/libcamera/internal/control_serializer.h b/include/libcamera/internal/control_serializer.h
index 8a66be32..8a63ae44 100644
--- a/include/libcamera/internal/control_serializer.h
+++ b/include/libcamera/internal/control_serializer.h
@@ -2,10 +2,10 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * control_serializer.h - Control (de)serializer
+ * Control (de)serializer
*/
-#ifndef __LIBCAMERA_INTERNAL_CONTROL_SERIALIZER_H__
-#define __LIBCAMERA_INTERNAL_CONTROL_SERIALIZER_H__
+
+#pragma once
#include <map>
#include <memory>
@@ -20,7 +20,12 @@ class ByteStreamBuffer;
class ControlSerializer
{
public:
- ControlSerializer();
+ enum class Role {
+ Proxy,
+ Worker
+ };
+
+ ControlSerializer(Role role);
void reset();
@@ -42,11 +47,12 @@ private:
static void store(const ControlValue &value, ByteStreamBuffer &buffer);
static void store(const ControlInfo &info, ByteStreamBuffer &buffer);
- ControlValue loadControlValue(ControlType type, ByteStreamBuffer &buffer,
+ ControlValue loadControlValue(ByteStreamBuffer &buffer,
bool isArray = false, unsigned int count = 1);
- ControlInfo loadControlInfo(ControlType type, ByteStreamBuffer &buffer);
+ ControlInfo loadControlInfo(ByteStreamBuffer &buffer);
unsigned int serial_;
+ unsigned int serialSeed_;
std::vector<std::unique_ptr<ControlId>> controlIds_;
std::vector<std::unique_ptr<ControlIdMap>> controlIdMaps_;
std::map<unsigned int, ControlInfoMap> infoMaps_;
@@ -54,5 +60,3 @@ private:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_INTERNAL_CONTROL_SERIALIZER_H__ */
diff --git a/include/libcamera/internal/control_validator.h b/include/libcamera/internal/control_validator.h
index 20600695..260602f2 100644
--- a/include/libcamera/internal/control_validator.h
+++ b/include/libcamera/internal/control_validator.h
@@ -2,10 +2,10 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * control_validator.h - Control validator
+ * Control validator
*/
-#ifndef __LIBCAMERA_INTERNAL_CONTROL_VALIDATOR_H__
-#define __LIBCAMERA_INTERNAL_CONTROL_VALIDATOR_H__
+
+#pragma once
#include <string>
@@ -23,5 +23,3 @@ public:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_INTERNAL_CONTROL_VALIDATOR_H__ */
diff --git a/include/libcamera/internal/converter.h b/include/libcamera/internal/converter.h
new file mode 100644
index 00000000..644ec429
--- /dev/null
+++ b/include/libcamera/internal/converter.h
@@ -0,0 +1,143 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2020, Laurent Pinchart
+ * Copyright 2022 NXP
+ *
+ * Generic format converter interface
+ */
+
+#pragma once
+
+#include <functional>
+#include <initializer_list>
+#include <map>
+#include <memory>
+#include <string>
+#include <tuple>
+#include <utility>
+#include <vector>
+
+#include <libcamera/base/class.h>
+#include <libcamera/base/flags.h>
+#include <libcamera/base/signal.h>
+
+#include <libcamera/geometry.h>
+
+namespace libcamera {
+
+class FrameBuffer;
+class MediaDevice;
+class PixelFormat;
+class Stream;
+struct StreamConfiguration;
+
+class Converter
+{
+public:
+ enum class Feature {
+ None = 0,
+ InputCrop = (1 << 0),
+ };
+
+ using Features = Flags<Feature>;
+
+ enum class Alignment {
+ Down = 0,
+ Up,
+ };
+
+ Converter(MediaDevice *media, Features features = Feature::None);
+ virtual ~Converter();
+
+ virtual int loadConfiguration(const std::string &filename) = 0;
+
+ virtual bool isValid() const = 0;
+
+ virtual std::vector<PixelFormat> formats(PixelFormat input) = 0;
+ virtual SizeRange sizes(const Size &input) = 0;
+
+ virtual Size adjustInputSize(const PixelFormat &pixFmt,
+ const Size &size,
+ Alignment align = Alignment::Down) = 0;
+ virtual Size adjustOutputSize(const PixelFormat &pixFmt,
+ const Size &size,
+ Alignment align = Alignment::Down) = 0;
+
+ virtual std::tuple<unsigned int, unsigned int>
+ strideAndFrameSize(const PixelFormat &pixelFormat, const Size &size) = 0;
+
+ virtual int validateOutput(StreamConfiguration *cfg, bool *adjusted,
+ Alignment align = Alignment::Down) = 0;
+
+ virtual int configure(const StreamConfiguration &inputCfg,
+ const std::vector<std::reference_wrapper<StreamConfiguration>> &outputCfgs) = 0;
+ virtual bool isConfigured(const Stream *stream) const = 0;
+ virtual int exportBuffers(const Stream *stream, unsigned int count,
+ std::vector<std::unique_ptr<FrameBuffer>> *buffers) = 0;
+
+ virtual int start() = 0;
+ virtual void stop() = 0;
+
+ virtual int queueBuffers(FrameBuffer *input,
+ const std::map<const Stream *, FrameBuffer *> &outputs) = 0;
+
+ virtual int setInputCrop(const Stream *stream, Rectangle *rect) = 0;
+ virtual std::pair<Rectangle, Rectangle> inputCropBounds() = 0;
+ virtual std::pair<Rectangle, Rectangle> inputCropBounds(const Stream *stream) = 0;
+
+ Signal<FrameBuffer *> inputBufferReady;
+ Signal<FrameBuffer *> outputBufferReady;
+
+ const std::string &deviceNode() const { return deviceNode_; }
+
+ Features features() const { return features_; }
+
+protected:
+ Features features_;
+
+private:
+ std::string deviceNode_;
+};
+
+class ConverterFactoryBase
+{
+public:
+ ConverterFactoryBase(const std::string name, std::initializer_list<std::string> compatibles);
+ virtual ~ConverterFactoryBase() = default;
+
+ const std::vector<std::string> &compatibles() const { return compatibles_; }
+
+ static std::unique_ptr<Converter> create(MediaDevice *media);
+ static std::vector<ConverterFactoryBase *> &factories();
+ static std::vector<std::string> names();
+
+private:
+ LIBCAMERA_DISABLE_COPY_AND_MOVE(ConverterFactoryBase)
+
+ static void registerType(ConverterFactoryBase *factory);
+
+ virtual std::unique_ptr<Converter> createInstance(MediaDevice *media) const = 0;
+
+ std::string name_;
+ std::vector<std::string> compatibles_;
+};
+
+template<typename _Converter>
+class ConverterFactory : public ConverterFactoryBase
+{
+public:
+ ConverterFactory(const char *name, std::initializer_list<std::string> compatibles)
+ : ConverterFactoryBase(name, compatibles)
+ {
+ }
+
+ std::unique_ptr<Converter> createInstance(MediaDevice *media) const override
+ {
+ return std::make_unique<_Converter>(media);
+ }
+};
+
+#define REGISTER_CONVERTER(name, converter, compatibles) \
+ static ConverterFactory<converter> global_##converter##Factory(name, compatibles);
+
+} /* namespace libcamera */
diff --git a/include/libcamera/internal/converter/converter_v4l2_m2m.h b/include/libcamera/internal/converter/converter_v4l2_m2m.h
new file mode 100644
index 00000000..0ad7bf7f
--- /dev/null
+++ b/include/libcamera/internal/converter/converter_v4l2_m2m.h
@@ -0,0 +1,125 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2020, Laurent Pinchart
+ * Copyright 2022 NXP
+ *
+ * V4l2 M2M Format converter interface
+ */
+
+#pragma once
+
+#include <functional>
+#include <map>
+#include <memory>
+#include <string>
+#include <tuple>
+#include <vector>
+
+#include <libcamera/base/log.h>
+#include <libcamera/base/signal.h>
+
+#include <libcamera/pixel_format.h>
+
+#include "libcamera/internal/converter.h"
+
+namespace libcamera {
+
+class FrameBuffer;
+class MediaDevice;
+class Size;
+class SizeRange;
+class Stream;
+struct StreamConfiguration;
+class Rectangle;
+class V4L2M2MDevice;
+
+class V4L2M2MConverter : public Converter
+{
+public:
+ V4L2M2MConverter(MediaDevice *media);
+
+ int loadConfiguration([[maybe_unused]] const std::string &filename) override { return 0; }
+ bool isValid() const override { return m2m_ != nullptr; }
+
+ std::vector<PixelFormat> formats(PixelFormat input) override;
+ SizeRange sizes(const Size &input) override;
+
+ std::tuple<unsigned int, unsigned int>
+ strideAndFrameSize(const PixelFormat &pixelFormat, const Size &size) override;
+
+ Size adjustInputSize(const PixelFormat &pixFmt,
+ const Size &size, Alignment align = Alignment::Down) override;
+ Size adjustOutputSize(const PixelFormat &pixFmt,
+ const Size &size, Alignment align = Alignment::Down) override;
+
+ int configure(const StreamConfiguration &inputCfg,
+ const std::vector<std::reference_wrapper<StreamConfiguration>>
+ &outputCfg) override;
+ bool isConfigured(const Stream *stream) const override;
+ int exportBuffers(const Stream *stream, unsigned int count,
+ std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;
+
+ int start() override;
+ void stop() override;
+
+ int validateOutput(StreamConfiguration *cfg, bool *adjusted,
+ Alignment align = Alignment::Down) override;
+
+ int queueBuffers(FrameBuffer *input,
+ const std::map<const Stream *, FrameBuffer *> &outputs) override;
+
+ int setInputCrop(const Stream *stream, Rectangle *rect) override;
+ std::pair<Rectangle, Rectangle> inputCropBounds() override { return inputCropBounds_; }
+ std::pair<Rectangle, Rectangle> inputCropBounds(const Stream *stream) override;
+
+private:
+ class V4L2M2MStream : protected Loggable
+ {
+ public:
+ V4L2M2MStream(V4L2M2MConverter *converter, const Stream *stream);
+
+ bool isValid() const { return m2m_ != nullptr; }
+
+ int configure(const StreamConfiguration &inputCfg,
+ const StreamConfiguration &outputCfg);
+ int exportBuffers(unsigned int count,
+ std::vector<std::unique_ptr<FrameBuffer>> *buffers);
+
+ int start();
+ void stop();
+
+ int queueBuffers(FrameBuffer *input, FrameBuffer *output);
+
+ int setInputSelection(unsigned int target, Rectangle *rect);
+ int getInputSelection(unsigned int target, Rectangle *rect);
+
+ std::pair<Rectangle, Rectangle> inputCropBounds();
+
+ protected:
+ std::string logPrefix() const override;
+
+ private:
+ void captureBufferReady(FrameBuffer *buffer);
+ void outputBufferReady(FrameBuffer *buffer);
+
+ V4L2M2MConverter *converter_;
+ const Stream *stream_;
+ std::unique_ptr<V4L2M2MDevice> m2m_;
+
+ unsigned int inputBufferCount_;
+ unsigned int outputBufferCount_;
+
+ std::pair<Rectangle, Rectangle> inputCropBounds_;
+ };
+
+ Size adjustSizes(const Size &size, const std::vector<SizeRange> &ranges,
+ Alignment align);
+
+ std::unique_ptr<V4L2M2MDevice> m2m_;
+
+ std::map<const Stream *, std::unique_ptr<V4L2M2MStream>> streams_;
+ std::map<FrameBuffer *, unsigned int> queue_;
+ std::pair<Rectangle, Rectangle> inputCropBounds_;
+};
+
+} /* namespace libcamera */
diff --git a/include/libcamera/internal/converter/meson.build b/include/libcamera/internal/converter/meson.build
new file mode 100644
index 00000000..891e79e7
--- /dev/null
+++ b/include/libcamera/internal/converter/meson.build
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: CC0-1.0
+
+libcamera_internal_headers += files([
+ 'converter_v4l2_m2m.h',
+])
diff --git a/include/libcamera/internal/debug_controls.h b/include/libcamera/internal/debug_controls.h
new file mode 100644
index 00000000..0b049f48
--- /dev/null
+++ b/include/libcamera/internal/debug_controls.h
@@ -0,0 +1,46 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2024, Google Inc.
+ *
+ * Debug metadata helpers
+ */
+
+#pragma once
+
+#include <libcamera/control_ids.h>
+
+namespace libcamera {
+
+class DebugMetadata
+{
+public:
+ DebugMetadata() = default;
+
+ void enableByControl(const ControlList &controls);
+ void enable(bool enable = true);
+ void setParent(DebugMetadata *parent);
+ void moveEntries(ControlList &list);
+
+ template<typename T, typename V>
+ void set(const Control<T> &ctrl, const V &value)
+ {
+ if (parent_) {
+ parent_->set(ctrl, value);
+ return;
+ }
+
+ if (!enabled_)
+ return;
+
+ cache_.set(ctrl, value);
+ }
+
+ void set(unsigned int id, const ControlValue &value);
+
+private:
+ bool enabled_ = false;
+ DebugMetadata *parent_ = nullptr;
+ ControlList cache_;
+};
+
+} /* namespace libcamera */
diff --git a/include/libcamera/internal/delayed_controls.h b/include/libcamera/internal/delayed_controls.h
index 2a6a912b..e8d3014d 100644
--- a/include/libcamera/internal/delayed_controls.h
+++ b/include/libcamera/internal/delayed_controls.h
@@ -1,11 +1,11 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
- * Copyright (C) 2020, Raspberry Pi (Trading) Ltd.
+ * Copyright (C) 2020, Raspberry Pi Ltd
*
- * delayed_controls.h - Helper to deal with controls that take effect with a delay
+ * Helper to deal with controls that take effect with a delay
*/
-#ifndef __LIBCAMERA_INTERNAL_DELAYED_CONTROLS_H__
-#define __LIBCAMERA_INTERNAL_DELAYED_CONTROLS_H__
+
+#pragma once
#include <stdint.h>
#include <unordered_map>
@@ -51,7 +51,7 @@ private:
bool updated;
};
- /* \todo: Make the listSize configurable at instance creation time. */
+ /* \todo Make the listSize configurable at instance creation time. */
static constexpr int listSize = 16;
class ControlRingBuffer : public std::array<Info, listSize>
{
@@ -72,9 +72,6 @@ private:
std::unordered_map<const ControlId *, ControlParams> controlParams_;
unsigned int maxDelay_;
- bool running_;
- uint32_t firstSequence_;
-
uint32_t queueCount_;
uint32_t writeCount_;
/* \todo Evaluate if we should index on ControlId * or unsigned int */
@@ -82,5 +79,3 @@ private:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_INTERNAL_DELAYED_CONTROLS_H__ */
diff --git a/include/libcamera/internal/device_enumerator.h b/include/libcamera/internal/device_enumerator.h
index baccfc00..db3532a9 100644
--- a/include/libcamera/internal/device_enumerator.h
+++ b/include/libcamera/internal/device_enumerator.h
@@ -2,10 +2,10 @@
/*
* Copyright (C) 2018, Google Inc.
*
- * device_enumerator.h - API to enumerate and find media devices
+ * API to enumerate and find media devices
*/
-#ifndef __LIBCAMERA_INTERNAL_DEVICE_ENUMERATOR_H__
-#define __LIBCAMERA_INTERNAL_DEVICE_ENUMERATOR_H__
+
+#pragma once
#include <memory>
#include <string>
@@ -55,5 +55,3 @@ private:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_INTERNAL_DEVICE_ENUMERATOR_H__ */
diff --git a/include/libcamera/internal/device_enumerator_sysfs.h b/include/libcamera/internal/device_enumerator_sysfs.h
index 2112bc54..4ccc9845 100644
--- a/include/libcamera/internal/device_enumerator_sysfs.h
+++ b/include/libcamera/internal/device_enumerator_sysfs.h
@@ -2,12 +2,11 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * device_enumerator_sysfs.h - sysfs-based device enumerator
+ * sysfs-based device enumerator
*/
-#ifndef __LIBCAMERA_INTERNAL_DEVICE_ENUMERATOR_SYSFS_H__
-#define __LIBCAMERA_INTERNAL_DEVICE_ENUMERATOR_SYSFS_H__
-#include <memory>
+#pragma once
+
#include <string>
#include "libcamera/internal/device_enumerator.h"
@@ -28,5 +27,3 @@ private:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_INTERNAL_DEVICE_ENUMERATOR_SYSFS_H__ */
diff --git a/include/libcamera/internal/device_enumerator_udev.h b/include/libcamera/internal/device_enumerator_udev.h
index 58e64a29..1378c190 100644
--- a/include/libcamera/internal/device_enumerator_udev.h
+++ b/include/libcamera/internal/device_enumerator_udev.h
@@ -2,10 +2,10 @@
/*
* Copyright (C) 2018-2019, Google Inc.
*
- * device_enumerator_udev.h - udev-based device enumerator
+ * udev-based device enumerator
*/
-#ifndef __LIBCAMERA_INTERNAL_DEVICE_ENUMERATOR_UDEV_H__
-#define __LIBCAMERA_INTERNAL_DEVICE_ENUMERATOR_UDEV_H__
+
+#pragma once
#include <list>
#include <map>
@@ -59,7 +59,7 @@ private:
std::string lookupDeviceNode(dev_t devnum);
int addV4L2Device(dev_t devnum);
- void udevNotify(EventNotifier *notifier);
+ void udevNotify();
struct udev *udev_;
struct udev_monitor *monitor_;
@@ -71,5 +71,3 @@ private:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_INTERNAL_DEVICE_ENUMERATOR_UDEV_H__ */
diff --git a/include/libcamera/internal/dma_buf_allocator.h b/include/libcamera/internal/dma_buf_allocator.h
new file mode 100644
index 00000000..13600915
--- /dev/null
+++ b/include/libcamera/internal/dma_buf_allocator.h
@@ -0,0 +1,80 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2020, Raspberry Pi Ltd
+ *
+ * Helper class for dma-buf allocations.
+ */
+
+#pragma once
+
+#include <memory>
+#include <stdint.h>
+#include <string>
+#include <vector>
+
+#include <libcamera/base/flags.h>
+#include <libcamera/base/shared_fd.h>
+#include <libcamera/base/unique_fd.h>
+
+namespace libcamera {
+
+class FrameBuffer;
+
+class DmaBufAllocator
+{
+public:
+ enum class DmaBufAllocatorFlag {
+ CmaHeap = 1 << 0,
+ SystemHeap = 1 << 1,
+ UDmaBuf = 1 << 2,
+ };
+
+ using DmaBufAllocatorFlags = Flags<DmaBufAllocatorFlag>;
+
+ DmaBufAllocator(DmaBufAllocatorFlags flags = DmaBufAllocatorFlag::CmaHeap);
+ ~DmaBufAllocator();
+ bool isValid() const { return providerHandle_.isValid(); }
+ UniqueFD alloc(const char *name, std::size_t size);
+
+ int exportBuffers(unsigned int count,
+ const std::vector<unsigned int> &planeSizes,
+ std::vector<std::unique_ptr<FrameBuffer>> *buffers);
+
+private:
+ std::unique_ptr<FrameBuffer> createBuffer(
+ std::string name, const std::vector<unsigned int> &planeSizes);
+
+ UniqueFD allocFromHeap(const char *name, std::size_t size);
+ UniqueFD allocFromUDmaBuf(const char *name, std::size_t size);
+ UniqueFD providerHandle_;
+ DmaBufAllocatorFlag type_;
+};
+
+class DmaSyncer final
+{
+public:
+ enum class SyncType {
+ Read = 0,
+ Write,
+ ReadWrite,
+ };
+
+ explicit DmaSyncer(SharedFD fd, SyncType type = SyncType::ReadWrite);
+
+ DmaSyncer(DmaSyncer &&other) = default;
+ DmaSyncer &operator=(DmaSyncer &&other) = default;
+
+ ~DmaSyncer();
+
+private:
+ LIBCAMERA_DISABLE_COPY(DmaSyncer)
+
+ void sync(uint64_t step);
+
+ SharedFD fd_;
+ uint64_t flags_ = 0;
+};
+
+LIBCAMERA_FLAGS_ENABLE_OPERATORS(DmaBufAllocator::DmaBufAllocatorFlag)
+
+} /* namespace libcamera */
diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h
index 51a8a6b8..6a3e9c16 100644
--- a/include/libcamera/internal/formats.h
+++ b/include/libcamera/internal/formats.h
@@ -2,14 +2,12 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * formats.h - libcamera image formats
+ * libcamera image formats
*/
-#ifndef __LIBCAMERA_INTERNAL_FORMATS_H__
-#define __LIBCAMERA_INTERNAL_FORMATS_H__
+#pragma once
#include <array>
-#include <map>
#include <vector>
#include <libcamera/geometry.h>
@@ -19,12 +17,6 @@
namespace libcamera {
-struct PixelFormatPlaneInfo
-{
- unsigned int bytesPerGroup;
- unsigned int verticalSubSampling;
-};
-
class PixelFormatInfo
{
public:
@@ -34,6 +26,11 @@ public:
ColourEncodingRAW,
};
+ struct Plane {
+ unsigned int bytesPerGroup;
+ unsigned int verticalSubSampling;
+ };
+
bool isValid() const { return format.isValid(); }
static const PixelFormatInfo &info(const PixelFormat &format);
@@ -42,6 +39,10 @@ public:
unsigned int stride(unsigned int width, unsigned int plane,
unsigned int align = 1) const;
+ unsigned int planeSize(const Size &size, unsigned int plane,
+ unsigned int align = 1) const;
+ unsigned int planeSize(unsigned int height, unsigned int plane,
+ unsigned int stride) const;
unsigned int frameSize(const Size &size, unsigned int align = 1) const;
unsigned int frameSize(const Size &size,
const std::array<unsigned int, 3> &strides) const;
@@ -51,16 +52,14 @@ public:
/* \todo Add support for non-contiguous memory planes */
const char *name;
PixelFormat format;
- V4L2PixelFormat v4l2Format;
+ std::vector<V4L2PixelFormat> v4l2Formats;
unsigned int bitsPerPixel;
enum ColourEncoding colourEncoding;
bool packed;
unsigned int pixelsPerGroup;
- std::array<PixelFormatPlaneInfo, 3> planes;
+ std::array<Plane, 3> planes;
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_INTERNAL_FORMATS_H__ */
diff --git a/include/libcamera/internal/framebuffer.h b/include/libcamera/internal/framebuffer.h
index 606aed2b..97b49d42 100644
--- a/include/libcamera/internal/framebuffer.h
+++ b/include/libcamera/internal/framebuffer.h
@@ -2,13 +2,18 @@
/*
* Copyright (C) 2020, Google Inc.
*
- * framebuffer.h - Internal frame buffer handling
+ * Internal frame buffer handling
*/
-#ifndef __LIBCAMERA_INTERNAL_FRAMEBUFFER_H__
-#define __LIBCAMERA_INTERNAL_FRAMEBUFFER_H__
+
+#pragma once
+
+#include <memory>
+#include <stdint.h>
+#include <utility>
#include <libcamera/base/class.h>
+#include <libcamera/fence.h>
#include <libcamera/framebuffer.h>
namespace libcamera {
@@ -18,14 +23,27 @@ class FrameBuffer::Private : public Extensible::Private
LIBCAMERA_DECLARE_PUBLIC(FrameBuffer)
public:
- Private();
+ Private(const std::vector<Plane> &planes, uint64_t cookie = 0);
+ virtual ~Private();
void setRequest(Request *request) { request_ = request; }
+ bool isContiguous() const { return isContiguous_; }
+
+ Fence *fence() const { return fence_.get(); }
+ void setFence(std::unique_ptr<Fence> fence) { fence_ = std::move(fence); }
+
+ void cancel() { metadata_.status = FrameMetadata::FrameCancelled; }
+
+ FrameMetadata &metadata() { return metadata_; }
private:
+ std::vector<Plane> planes_;
+ FrameMetadata metadata_;
+ uint64_t cookie_;
+
+ std::unique_ptr<Fence> fence_;
Request *request_;
+ bool isContiguous_;
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_INTERNAL_FRAMEBUFFER_H__ */
diff --git a/include/libcamera/internal/ipa_data_serializer.h b/include/libcamera/internal/ipa_data_serializer.h
index 4353e07b..b4614f21 100644
--- a/include/libcamera/internal/ipa_data_serializer.h
+++ b/include/libcamera/internal/ipa_data_serializer.h
@@ -2,27 +2,26 @@
/*
* Copyright (C) 2020, Google Inc.
*
- * ipa_data_serializer.h - Image Processing Algorithm data serializer
+ * Image Processing Algorithm data serializer
*/
-#ifndef __LIBCAMERA_INTERNAL_IPA_DATA_SERIALIZER_H__
-#define __LIBCAMERA_INTERNAL_IPA_DATA_SERIALIZER_H__
-#include <deque>
-#include <iostream>
+#pragma once
+
+#include <stdint.h>
#include <string.h>
#include <tuple>
#include <type_traits>
#include <vector>
+#include <libcamera/base/flags.h>
#include <libcamera/base/log.h>
#include <libcamera/control_ids.h>
#include <libcamera/framebuffer.h>
#include <libcamera/geometry.h>
+
#include <libcamera/ipa/ipa_interface.h>
-#include "libcamera/internal/byte_stream_buffer.h"
-#include "libcamera/internal/camera_sensor.h"
#include "libcamera/internal/control_serializer.h"
namespace libcamera {
@@ -32,7 +31,7 @@ LOG_DECLARE_CATEGORY(IPADataSerializer)
namespace {
template<typename T,
- typename std::enable_if_t<std::is_arithmetic_v<T>> * = nullptr>
+ std::enable_if_t<std::is_arithmetic_v<T>> * = nullptr>
void appendPOD(std::vector<uint8_t> &vec, T val)
{
constexpr size_t byteWidth = sizeof(val);
@@ -66,7 +65,7 @@ template<typename T>
class IPADataSerializer
{
public:
- static std::tuple<std::vector<uint8_t>, std::vector<FileDescriptor>>
+ static std::tuple<std::vector<uint8_t>, std::vector<SharedFD>>
serialize(const T &data, ControlSerializer *cs = nullptr);
static T deserialize(const std::vector<uint8_t> &data,
@@ -76,12 +75,12 @@ public:
ControlSerializer *cs = nullptr);
static T deserialize(const std::vector<uint8_t> &data,
- const std::vector<FileDescriptor> &fds,
+ const std::vector<SharedFD> &fds,
ControlSerializer *cs = nullptr);
static T deserialize(std::vector<uint8_t>::const_iterator dataBegin,
std::vector<uint8_t>::const_iterator dataEnd,
- std::vector<FileDescriptor>::const_iterator fdsBegin,
- std::vector<FileDescriptor>::const_iterator fdsEnd,
+ std::vector<SharedFD>::const_iterator fdsBegin,
+ std::vector<SharedFD>::const_iterator fdsEnd,
ControlSerializer *cs = nullptr);
};
@@ -104,11 +103,11 @@ template<typename V>
class IPADataSerializer<std::vector<V>>
{
public:
- static std::tuple<std::vector<uint8_t>, std::vector<FileDescriptor>>
+ static std::tuple<std::vector<uint8_t>, std::vector<SharedFD>>
serialize(const std::vector<V> &data, ControlSerializer *cs = nullptr)
{
std::vector<uint8_t> dataVec;
- std::vector<FileDescriptor> fdsVec;
+ std::vector<SharedFD> fdsVec;
/* Serialize the length. */
uint32_t vecLen = data.size();
@@ -117,7 +116,7 @@ public:
/* Serialize the members. */
for (auto const &it : data) {
std::vector<uint8_t> dvec;
- std::vector<FileDescriptor> fvec;
+ std::vector<SharedFD> fvec;
std::tie(dvec, fvec) =
IPADataSerializer<V>::serialize(it, cs);
@@ -134,37 +133,37 @@ public:
static std::vector<V> deserialize(std::vector<uint8_t> &data, ControlSerializer *cs = nullptr)
{
- return deserialize(data.cbegin(), data.end(), cs);
+ return deserialize(data.cbegin(), data.cend(), cs);
}
static std::vector<V> deserialize(std::vector<uint8_t>::const_iterator dataBegin,
std::vector<uint8_t>::const_iterator dataEnd,
ControlSerializer *cs = nullptr)
{
- std::vector<FileDescriptor> fds;
- return deserialize(dataBegin, dataEnd, fds.cbegin(), fds.end(), cs);
+ std::vector<SharedFD> fds;
+ return deserialize(dataBegin, dataEnd, fds.cbegin(), fds.cend(), cs);
}
- static std::vector<V> deserialize(std::vector<uint8_t> &data, std::vector<FileDescriptor> &fds,
+ static std::vector<V> deserialize(std::vector<uint8_t> &data, std::vector<SharedFD> &fds,
ControlSerializer *cs = nullptr)
{
- return deserialize(data.cbegin(), data.end(), fds.cbegin(), fds.end(), cs);
+ return deserialize(data.cbegin(), data.cend(), fds.cbegin(), fds.cend(), cs);
}
static std::vector<V> deserialize(std::vector<uint8_t>::const_iterator dataBegin,
std::vector<uint8_t>::const_iterator dataEnd,
- std::vector<FileDescriptor>::const_iterator fdsBegin,
- [[maybe_unused]] std::vector<FileDescriptor>::const_iterator fdsEnd,
+ std::vector<SharedFD>::const_iterator fdsBegin,
+ [[maybe_unused]] std::vector<SharedFD>::const_iterator fdsEnd,
ControlSerializer *cs = nullptr)
{
uint32_t vecLen = readPOD<uint32_t>(dataBegin, 0, dataEnd);
std::vector<V> ret(vecLen);
std::vector<uint8_t>::const_iterator dataIter = dataBegin + 4;
- std::vector<FileDescriptor>::const_iterator fdIter = fdsBegin;
+ std::vector<SharedFD>::const_iterator fdIter = fdsBegin;
for (uint32_t i = 0; i < vecLen; i++) {
uint32_t sizeofData = readPOD<uint32_t>(dataIter, 0, dataEnd);
- uint32_t sizeofFds = readPOD<uint32_t>(dataIter, 4, dataEnd);
+ uint32_t sizeofFds = readPOD<uint32_t>(dataIter, 4, dataEnd);
dataIter += 8;
ret[i] = IPADataSerializer<V>::deserialize(dataIter,
@@ -201,11 +200,11 @@ template<typename K, typename V>
class IPADataSerializer<std::map<K, V>>
{
public:
- static std::tuple<std::vector<uint8_t>, std::vector<FileDescriptor>>
+ static std::tuple<std::vector<uint8_t>, std::vector<SharedFD>>
serialize(const std::map<K, V> &data, ControlSerializer *cs = nullptr)
{
std::vector<uint8_t> dataVec;
- std::vector<FileDescriptor> fdsVec;
+ std::vector<SharedFD> fdsVec;
/* Serialize the length. */
uint32_t mapLen = data.size();
@@ -214,7 +213,7 @@ public:
/* Serialize the members. */
for (auto const &it : data) {
std::vector<uint8_t> dvec;
- std::vector<FileDescriptor> fvec;
+ std::vector<SharedFD> fvec;
std::tie(dvec, fvec) =
IPADataSerializer<K>::serialize(it.first, cs);
@@ -240,27 +239,27 @@ public:
static std::map<K, V> deserialize(std::vector<uint8_t> &data, ControlSerializer *cs = nullptr)
{
- return deserialize(data.cbegin(), data.end(), cs);
+ return deserialize(data.cbegin(), data.cend(), cs);
}
static std::map<K, V> deserialize(std::vector<uint8_t>::const_iterator dataBegin,
std::vector<uint8_t>::const_iterator dataEnd,
ControlSerializer *cs = nullptr)
{
- std::vector<FileDescriptor> fds;
- return deserialize(dataBegin, dataEnd, fds.cbegin(), fds.end(), cs);
+ std::vector<SharedFD> fds;
+ return deserialize(dataBegin, dataEnd, fds.cbegin(), fds.cend(), cs);
}
- static std::map<K, V> deserialize(std::vector<uint8_t> &data, std::vector<FileDescriptor> &fds,
+ static std::map<K, V> deserialize(std::vector<uint8_t> &data, std::vector<SharedFD> &fds,
ControlSerializer *cs = nullptr)
{
- return deserialize(data.cbegin(), data.end(), fds.cbegin(), fds.end(), cs);
+ return deserialize(data.cbegin(), data.cend(), fds.cbegin(), fds.cend(), cs);
}
static std::map<K, V> deserialize(std::vector<uint8_t>::const_iterator dataBegin,
std::vector<uint8_t>::const_iterator dataEnd,
- std::vector<FileDescriptor>::const_iterator fdsBegin,
- [[maybe_unused]] std::vector<FileDescriptor>::const_iterator fdsEnd,
+ std::vector<SharedFD>::const_iterator fdsBegin,
+ [[maybe_unused]] std::vector<SharedFD>::const_iterator fdsEnd,
ControlSerializer *cs = nullptr)
{
std::map<K, V> ret;
@@ -268,10 +267,10 @@ public:
uint32_t mapLen = readPOD<uint32_t>(dataBegin, 0, dataEnd);
std::vector<uint8_t>::const_iterator dataIter = dataBegin + 4;
- std::vector<FileDescriptor>::const_iterator fdIter = fdsBegin;
+ std::vector<SharedFD>::const_iterator fdIter = fdsBegin;
for (uint32_t i = 0; i < mapLen; i++) {
uint32_t sizeofData = readPOD<uint32_t>(dataIter, 0, dataEnd);
- uint32_t sizeofFds = readPOD<uint32_t>(dataIter, 4, dataEnd);
+ uint32_t sizeofFds = readPOD<uint32_t>(dataIter, 4, dataEnd);
dataIter += 8;
K key = IPADataSerializer<K>::deserialize(dataIter,
@@ -283,7 +282,7 @@ public:
dataIter += sizeofData;
fdIter += sizeofFds;
sizeofData = readPOD<uint32_t>(dataIter, 0, dataEnd);
- sizeofFds = readPOD<uint32_t>(dataIter, 4, dataEnd);
+ sizeofFds = readPOD<uint32_t>(dataIter, 4, dataEnd);
dataIter += 8;
const V value = IPADataSerializer<V>::deserialize(dataIter,
@@ -301,8 +300,51 @@ public:
}
};
+/* Serialization format for Flags is same as for PODs */
+template<typename E>
+class IPADataSerializer<Flags<E>>
+{
+public:
+ static std::tuple<std::vector<uint8_t>, std::vector<SharedFD>>
+ serialize(const Flags<E> &data, [[maybe_unused]] ControlSerializer *cs = nullptr)
+ {
+ std::vector<uint8_t> dataVec;
+ dataVec.reserve(sizeof(Flags<E>));
+ appendPOD<uint32_t>(dataVec, static_cast<typename Flags<E>::Type>(data));
+
+ return { dataVec, {} };
+ }
+
+ static Flags<E> deserialize(std::vector<uint8_t> &data,
+ [[maybe_unused]] ControlSerializer *cs = nullptr)
+ {
+ return deserialize(data.cbegin(), data.cend());
+ }
+
+ static Flags<E> deserialize(std::vector<uint8_t>::const_iterator dataBegin,
+ std::vector<uint8_t>::const_iterator dataEnd,
+ [[maybe_unused]] ControlSerializer *cs = nullptr)
+ {
+ return Flags<E>{ static_cast<E>(readPOD<uint32_t>(dataBegin, 0, dataEnd)) };
+ }
+
+ static Flags<E> deserialize(std::vector<uint8_t> &data,
+ [[maybe_unused]] std::vector<SharedFD> &fds,
+ [[maybe_unused]] ControlSerializer *cs = nullptr)
+ {
+ return deserialize(data.cbegin(), data.cend());
+ }
+
+ static Flags<E> deserialize(std::vector<uint8_t>::const_iterator dataBegin,
+ std::vector<uint8_t>::const_iterator dataEnd,
+ [[maybe_unused]] std::vector<SharedFD>::const_iterator fdsBegin,
+ [[maybe_unused]] std::vector<SharedFD>::const_iterator fdsEnd,
+ [[maybe_unused]] ControlSerializer *cs = nullptr)
+ {
+ return deserialize(dataBegin, dataEnd);
+ }
+};
+
#endif /* __DOXYGEN__ */
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_INTERNAL_IPA_DATA_SERIALIZER_H__ */
diff --git a/include/libcamera/internal/ipa_manager.h b/include/libcamera/internal/ipa_manager.h
index 0687842e..16dede0c 100644
--- a/include/libcamera/internal/ipa_manager.h
+++ b/include/libcamera/internal/ipa_manager.h
@@ -2,10 +2,10 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * ipa_manager.h - Image Processing Algorithm module manager
+ * Image Processing Algorithm module manager
*/
-#ifndef __LIBCAMERA_INTERNAL_IPA_MANAGER_H__
-#define __LIBCAMERA_INTERNAL_IPA_MANAGER_H__
+
+#pragma once
#include <stdint.h>
#include <vector>
@@ -15,6 +15,7 @@
#include <libcamera/ipa/ipa_interface.h>
#include <libcamera/ipa/ipa_module_info.h>
+#include "libcamera/internal/camera_manager.h"
#include "libcamera/internal/ipa_module.h"
#include "libcamera/internal/pipeline_handler.h"
#include "libcamera/internal/pub_key.h"
@@ -34,11 +35,13 @@ public:
uint32_t minVersion,
uint32_t maxVersion)
{
- IPAModule *m = self_->module(pipe, minVersion, maxVersion);
+ CameraManager *cm = pipe->cameraManager();
+ IPAManager *self = cm->_d()->ipaManager();
+ IPAModule *m = self->module(pipe, minVersion, maxVersion);
if (!m)
return nullptr;
- std::unique_ptr<T> proxy = std::make_unique<T>(m, !self_->isSignatureValid(m));
+ std::unique_ptr<T> proxy = std::make_unique<T>(m, !self->isSignatureValid(m));
if (!proxy->isValid()) {
LOG(IPAManager, Error) << "Failed to load proxy";
return nullptr;
@@ -47,9 +50,14 @@ public:
return proxy;
}
-private:
- static IPAManager *self_;
+#if HAVE_IPA_PUBKEY
+ static const PubKey &pubKey()
+ {
+ return pubKey_;
+ }
+#endif
+private:
void parseDir(const char *libDir, unsigned int maxDepth,
std::vector<std::string> &files);
unsigned int addDir(const char *libDir, unsigned int maxDepth = 0);
@@ -68,5 +76,3 @@ private:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_INTERNAL_IPA_MANAGER_H__ */
diff --git a/include/libcamera/internal/ipa_module.h b/include/libcamera/internal/ipa_module.h
index a87f5650..7c49d3f3 100644
--- a/include/libcamera/internal/ipa_module.h
+++ b/include/libcamera/internal/ipa_module.h
@@ -2,10 +2,10 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * ipa_module.h - Image Processing Algorithm module
+ * Image Processing Algorithm module
*/
-#ifndef __LIBCAMERA_INTERNAL_IPA_MODULE_H__
-#define __LIBCAMERA_INTERNAL_IPA_MODULE_H__
+
+#pragma once
#include <stdint.h>
#include <string>
@@ -58,5 +58,3 @@ private:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_INTERNAL_IPA_MODULE_H__ */
diff --git a/include/libcamera/internal/ipa_proxy.h b/include/libcamera/internal/ipa_proxy.h
index ea9f0760..983bcc5f 100644
--- a/include/libcamera/internal/ipa_proxy.h
+++ b/include/libcamera/internal/ipa_proxy.h
@@ -2,14 +2,12 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * ipa_proxy.h - Image Processing Algorithm proxy
+ * Image Processing Algorithm proxy
*/
-#ifndef __LIBCAMERA_INTERNAL_IPA_PROXY_H__
-#define __LIBCAMERA_INTERNAL_IPA_PROXY_H__
-#include <memory>
+#pragma once
+
#include <string>
-#include <vector>
#include <libcamera/ipa/ipa_interface.h>
@@ -31,7 +29,8 @@ public:
bool isValid() const { return valid_; }
- std::string configurationFile(const std::string &file) const;
+ std::string configurationFile(const std::string &name,
+ const std::string &fallbackName = std::string()) const;
protected:
std::string resolvePath(const std::string &file) const;
@@ -44,5 +43,3 @@ private:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_INTERNAL_IPA_PROXY_H__ */
diff --git a/include/libcamera/internal/ipc_pipe.h b/include/libcamera/internal/ipc_pipe.h
index 52cc8fa3..418c4622 100644
--- a/include/libcamera/internal/ipc_pipe.h
+++ b/include/libcamera/internal/ipc_pipe.h
@@ -2,17 +2,17 @@
/*
* Copyright (C) 2020, Google Inc.
*
- * ipc_pipe.h - Image Processing Algorithm IPC module for IPA proxies
+ * Image Processing Algorithm IPC module for IPA proxies
*/
-#ifndef __LIBCAMERA_INTERNAL_IPA_IPC_H__
-#define __LIBCAMERA_INTERNAL_IPA_IPC_H__
+#pragma once
+
+#include <stdint.h>
#include <vector>
+#include <libcamera/base/shared_fd.h>
#include <libcamera/base/signal.h>
-#include <libcamera/file_descriptor.h>
-
#include "libcamera/internal/ipc_unixsocket.h"
namespace libcamera {
@@ -34,17 +34,17 @@ public:
Header &header() { return header_; }
std::vector<uint8_t> &data() { return data_; }
- std::vector<FileDescriptor> &fds() { return fds_; }
+ std::vector<SharedFD> &fds() { return fds_; }
const Header &header() const { return header_; }
const std::vector<uint8_t> &data() const { return data_; }
- const std::vector<FileDescriptor> &fds() const { return fds_; }
+ const std::vector<SharedFD> &fds() const { return fds_; }
private:
Header header_;
std::vector<uint8_t> data_;
- std::vector<FileDescriptor> fds_;
+ std::vector<SharedFD> fds_;
};
class IPCPipe
@@ -67,5 +67,3 @@ protected:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_INTERNAL_IPA_IPC_H__ */
diff --git a/include/libcamera/internal/ipc_pipe_unixsocket.h b/include/libcamera/internal/ipc_pipe_unixsocket.h
index 4ffdddcc..84512809 100644
--- a/include/libcamera/internal/ipc_pipe_unixsocket.h
+++ b/include/libcamera/internal/ipc_pipe_unixsocket.h
@@ -2,14 +2,14 @@
/*
* Copyright (C) 2020, Google Inc.
*
- * ipc_pipe_unixsocket.h - Image Processing Algorithm IPC module using unix socket
+ * Image Processing Algorithm IPC module using unix socket
*/
-#ifndef __LIBCAMERA_INTERNAL_IPA_IPC_UNIXSOCKET_H__
-#define __LIBCAMERA_INTERNAL_IPA_IPC_UNIXSOCKET_H__
+
+#pragma once
#include <map>
#include <memory>
-#include <vector>
+#include <stdint.h>
#include "libcamera/internal/ipc_pipe.h"
#include "libcamera/internal/ipc_unixsocket.h"
@@ -35,7 +35,7 @@ private:
bool done;
};
- void readyRead(IPCUnixSocket *socket);
+ void readyRead();
int call(const IPCUnixSocket::Payload &message,
IPCUnixSocket::Payload *response, uint32_t seq);
@@ -45,5 +45,3 @@ private:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_INTERNAL_IPA_IPC_UNIXSOCKET_H__ */
diff --git a/include/libcamera/internal/ipc_unixsocket.h b/include/libcamera/internal/ipc_unixsocket.h
index 9f5b0677..48bb7a94 100644
--- a/include/libcamera/internal/ipc_unixsocket.h
+++ b/include/libcamera/internal/ipc_unixsocket.h
@@ -2,17 +2,17 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * ipc_unixsocket.h - IPC mechanism based on Unix sockets
+ * IPC mechanism based on Unix sockets
*/
-#ifndef __LIBCAMERA_INTERNAL_IPC_UNIXSOCKET_H__
-#define __LIBCAMERA_INTERNAL_IPC_UNIXSOCKET_H__
+#pragma once
#include <stdint.h>
#include <sys/types.h>
#include <vector>
#include <libcamera/base/signal.h>
+#include <libcamera/base/unique_fd.h>
namespace libcamera {
@@ -29,15 +29,15 @@ public:
IPCUnixSocket();
~IPCUnixSocket();
- int create();
- int bind(int fd);
+ UniqueFD create();
+ int bind(UniqueFD fd);
void close();
bool isBound() const;
int send(const Payload &payload);
int receive(Payload *payload);
- Signal<IPCUnixSocket *> readyRead;
+ Signal<> readyRead;
private:
struct Header {
@@ -48,14 +48,12 @@ private:
int sendData(const void *buffer, size_t length, const int32_t *fds, unsigned int num);
int recvData(void *buffer, size_t length, int32_t *fds, unsigned int num);
- void dataNotifier(EventNotifier *notifier);
+ void dataNotifier();
- int fd_;
+ UniqueFD fd_;
bool headerReceived_;
struct Header header_;
EventNotifier *notifier_;
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_INTERNAL_IPC_UNIXSOCKET_H__ */
diff --git a/include/libcamera/internal/mapped_framebuffer.h b/include/libcamera/internal/mapped_framebuffer.h
index 42479541..6aaabf50 100644
--- a/include/libcamera/internal/mapped_framebuffer.h
+++ b/include/libcamera/internal/mapped_framebuffer.h
@@ -2,10 +2,10 @@
/*
* Copyright (C) 2021, Google Inc.
*
- * mapped_framebuffer.h - Frame buffer memory mapping support
+ * Frame buffer memory mapping support
*/
-#ifndef __LIBCAMERA_INTERNAL_MAPPED_FRAMEBUFFER_H__
-#define __LIBCAMERA_INTERNAL_MAPPED_FRAMEBUFFER_H__
+
+#pragma once
#include <stdint.h>
#include <vector>
@@ -30,8 +30,7 @@ public:
bool isValid() const { return error_ == 0; }
int error() const { return error_; }
- /* \todo rename to planes(). */
- const std::vector<Plane> &maps() const { return planes_; }
+ const std::vector<Plane> &planes() const { return planes_; }
protected:
MappedBuffer();
@@ -61,5 +60,3 @@ public:
LIBCAMERA_FLAGS_ENABLE_OPERATORS(MappedFrameBuffer::MapFlag)
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_INTERNAL_MAPPED_FRAMEBUFFER_H__ */
diff --git a/include/libcamera/internal/matrix.h b/include/libcamera/internal/matrix.h
new file mode 100644
index 00000000..7a71028c
--- /dev/null
+++ b/include/libcamera/internal/matrix.h
@@ -0,0 +1,199 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2024, Paul Elder <paul.elder@ideasonboard.com>
+ *
+ * Matrix and related operations
+ */
+#pragma once
+
+#include <algorithm>
+#include <sstream>
+#include <vector>
+
+#include <libcamera/base/log.h>
+#include <libcamera/base/span.h>
+
+#include "libcamera/internal/yaml_parser.h"
+
+namespace libcamera {
+
+LOG_DECLARE_CATEGORY(Matrix)
+
+#ifndef __DOXYGEN__
+template<typename T, unsigned int Rows, unsigned int Cols,
+ std::enable_if_t<std::is_arithmetic_v<T>> * = nullptr>
+#else
+template<typename T, unsigned int Rows, unsigned int Cols>
+#endif /* __DOXYGEN__ */
+class Matrix
+{
+public:
+ Matrix()
+ {
+ data_.fill(static_cast<T>(0));
+ }
+
+ Matrix(const std::array<T, Rows * Cols> &data)
+ {
+ std::copy(data.begin(), data.end(), data_.begin());
+ }
+
+ static Matrix identity()
+ {
+ Matrix ret;
+ for (size_t i = 0; i < std::min(Rows, Cols); i++)
+ ret[i][i] = static_cast<T>(1);
+ return ret;
+ }
+
+ ~Matrix() = default;
+
+ const std::string toString() const
+ {
+ std::stringstream out;
+
+ out << "Matrix { ";
+ for (unsigned int i = 0; i < Rows; i++) {
+ out << "[ ";
+ for (unsigned int j = 0; j < Cols; j++) {
+ out << (*this)[i][j];
+ out << ((j + 1 < Cols) ? ", " : " ");
+ }
+ out << ((i + 1 < Rows) ? "], " : "]");
+ }
+ out << " }";
+
+ return out.str();
+ }
+
+ Span<const T, Cols> operator[](size_t i) const
+ {
+ return Span<const T, Cols>{ &data_.data()[i * Cols], Cols };
+ }
+
+ Span<T, Cols> operator[](size_t i)
+ {
+ return Span<T, Cols>{ &data_.data()[i * Cols], Cols };
+ }
+
+#ifndef __DOXYGEN__
+ template<typename U, std::enable_if_t<std::is_arithmetic_v<U>>>
+#else
+ template<typename U>
+#endif /* __DOXYGEN__ */
+ Matrix<T, Rows, Cols> &operator*=(U d)
+ {
+ for (unsigned int i = 0; i < Rows * Cols; i++)
+ data_[i] *= d;
+ return *this;
+ }
+
+private:
+ std::array<T, Rows * Cols> data_;
+};
+
+#ifndef __DOXYGEN__
+template<typename T, typename U, unsigned int Rows, unsigned int Cols,
+ std::enable_if_t<std::is_arithmetic_v<T>> * = nullptr>
+#else
+template<typename T, typename U, unsigned int Rows, unsigned int Cols>
+#endif /* __DOXYGEN__ */
+Matrix<U, Rows, Cols> operator*(T d, const Matrix<U, Rows, Cols> &m)
+{
+ Matrix<U, Rows, Cols> result;
+
+ for (unsigned int i = 0; i < Rows; i++) {
+ for (unsigned int j = 0; j < Cols; j++)
+ result[i][j] = d * m[i][j];
+ }
+
+ return result;
+}
+
+#ifndef __DOXYGEN__
+template<typename T, typename U, unsigned int Rows, unsigned int Cols,
+ std::enable_if_t<std::is_arithmetic_v<T>> * = nullptr>
+#else
+template<typename T, typename U, unsigned int Rows, unsigned int Cols>
+#endif /* __DOXYGEN__ */
+Matrix<U, Rows, Cols> operator*(const Matrix<U, Rows, Cols> &m, T d)
+{
+ return d * m;
+}
+
+#ifndef __DOXYGEN__
+template<typename T,
+ unsigned int R1, unsigned int C1,
+ unsigned int R2, unsigned int C2,
+ std::enable_if_t<C1 == R2> * = nullptr>
+#else
+template<typename T, unsigned int R1, unsigned int C1, unsigned int R2, unsigned in C2>
+#endif /* __DOXYGEN__ */
+Matrix<T, R1, C2> operator*(const Matrix<T, R1, C1> &m1, const Matrix<T, R2, C2> &m2)
+{
+ Matrix<T, R1, C2> result;
+
+ for (unsigned int i = 0; i < R1; i++) {
+ for (unsigned int j = 0; j < C2; j++) {
+ T sum = 0;
+
+ for (unsigned int k = 0; k < C1; k++)
+ sum += m1[i][k] * m2[k][j];
+
+ result[i][j] = sum;
+ }
+ }
+
+ return result;
+}
+
+template<typename T, unsigned int Rows, unsigned int Cols>
+Matrix<T, Rows, Cols> operator+(const Matrix<T, Rows, Cols> &m1, const Matrix<T, Rows, Cols> &m2)
+{
+ Matrix<T, Rows, Cols> result;
+
+ for (unsigned int i = 0; i < Rows; i++) {
+ for (unsigned int j = 0; j < Cols; j++)
+ result[i][j] = m1[i][j] + m2[i][j];
+ }
+
+ return result;
+}
+
+#ifndef __DOXYGEN__
+bool matrixValidateYaml(const YamlObject &obj, unsigned int size);
+#endif /* __DOXYGEN__ */
+
+#ifndef __DOXYGEN__
+template<typename T, unsigned int Rows, unsigned int Cols>
+std::ostream &operator<<(std::ostream &out, const Matrix<T, Rows, Cols> &m)
+{
+ out << m.toString();
+ return out;
+}
+
+template<typename T, unsigned int Rows, unsigned int Cols>
+struct YamlObject::Getter<Matrix<T, Rows, Cols>> {
+ std::optional<Matrix<T, Rows, Cols>> get(const YamlObject &obj) const
+ {
+ if (!matrixValidateYaml(obj, Rows * Cols))
+ return std::nullopt;
+
+ Matrix<T, Rows, Cols> matrix;
+ T *data = &matrix[0][0];
+
+ unsigned int i = 0;
+ for (const YamlObject &entry : obj.asList()) {
+ const auto value = entry.get<T>();
+ if (!value)
+ return std::nullopt;
+
+ data[i++] = *value;
+ }
+
+ return matrix;
+ }
+};
+#endif /* __DOXYGEN__ */
+
+} /* namespace libcamera */
diff --git a/include/libcamera/internal/media_device.h b/include/libcamera/internal/media_device.h
index 3a7722c2..e412d3a0 100644
--- a/include/libcamera/internal/media_device.h
+++ b/include/libcamera/internal/media_device.h
@@ -2,13 +2,12 @@
/*
* Copyright (C) 2018, Google Inc.
*
- * media_device.h - Media device handler
+ * Media device handler
*/
-#ifndef __LIBCAMERA_INTERNAL_MEDIA_DEVICE_H__
-#define __LIBCAMERA_INTERNAL_MEDIA_DEVICE_H__
+
+#pragma once
#include <map>
-#include <sstream>
#include <string>
#include <vector>
@@ -16,6 +15,7 @@
#include <libcamera/base/log.h>
#include <libcamera/base/signal.h>
+#include <libcamera/base/unique_fd.h>
#include "libcamera/internal/media_object.h"
@@ -37,9 +37,9 @@ public:
int populate();
bool isValid() const { return valid_; }
- const std::string driver() const { return driver_; }
- const std::string deviceNode() const { return deviceNode_; }
- const std::string model() const { return model_; }
+ const std::string &driver() const { return driver_; }
+ const std::string &deviceNode() const { return deviceNode_; }
+ const std::string &model() const { return model_; }
unsigned int version() const { return version_; }
unsigned int hwRevision() const { return hwRevision_; }
@@ -53,7 +53,7 @@ public:
MediaLink *link(const MediaPad *source, const MediaPad *sink);
int disableLinks();
- Signal<MediaDevice *> disconnected;
+ Signal<> disconnected;
protected:
std::string logPrefix() const override;
@@ -82,15 +82,12 @@ private:
unsigned int version_;
unsigned int hwRevision_;
- int fd_;
+ UniqueFD fd_;
bool valid_;
bool acquired_;
- bool lockOwner_;
std::map<unsigned int, MediaObject *> objects_;
std::vector<MediaEntity *> entities_;
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_INTERNAL_MEDIA_DEVICE_H__ */
diff --git a/include/libcamera/internal/media_object.h b/include/libcamera/internal/media_object.h
index 2f5d33e1..9356d204 100644
--- a/include/libcamera/internal/media_object.h
+++ b/include/libcamera/internal/media_object.h
@@ -2,10 +2,10 @@
/*
* Copyright (C) 2018, Google Inc.
*
- * media_object.h - Media Device objects: entities, pads and links.
+ * Media Device objects: entities, pads and links.
*/
-#ifndef __LIBCAMERA_INTERNAL_MEDIA_OBJECT_H__
-#define __LIBCAMERA_INTERNAL_MEDIA_OBJECT_H__
+
+#pragma once
#include <string>
#include <vector>
@@ -48,6 +48,8 @@ public:
unsigned int flags() const { return flags_; }
int setEnabled(bool enable);
+ std::string toString() const;
+
private:
LIBCAMERA_DISABLE_COPY_AND_MOVE(MediaLink)
@@ -61,6 +63,8 @@ private:
unsigned int flags_;
};
+std::ostream &operator<<(std::ostream &out, const MediaLink &link);
+
class MediaPad : public MediaObject
{
public:
@@ -71,6 +75,8 @@ public:
void addLink(MediaLink *link);
+ std::string toString() const;
+
private:
LIBCAMERA_DISABLE_COPY_AND_MOVE(MediaPad)
@@ -85,17 +91,28 @@ private:
std::vector<MediaLink *> links_;
};
+std::ostream &operator<<(std::ostream &out, const MediaPad &pad);
+
class MediaEntity : public MediaObject
{
public:
+ enum class Type {
+ Invalid,
+ MediaEntity,
+ V4L2Subdevice,
+ V4L2VideoDevice,
+ };
+
const std::string &name() const { return name_; }
unsigned int function() const { return function_; }
unsigned int flags() const { return flags_; }
+ Type type() const { return type_; }
const std::string &deviceNode() const { return deviceNode_; }
unsigned int deviceMajor() const { return major_; }
unsigned int deviceMinor() const { return minor_; }
const std::vector<MediaPad *> &pads() const { return pads_; }
+ const std::vector<MediaEntity *> ancillaryEntities() const { return ancillaryEntities_; }
const MediaPad *getPadByIndex(unsigned int index) const;
const MediaPad *getPadById(unsigned int id) const;
@@ -108,20 +125,22 @@ private:
friend class MediaDevice;
MediaEntity(MediaDevice *dev, const struct media_v2_entity *entity,
- unsigned int major = 0, unsigned int minor = 0);
+ const struct media_v2_interface *iface);
void addPad(MediaPad *pad);
+ void addAncillaryEntity(MediaEntity *ancillaryEntity);
+
std::string name_;
unsigned int function_;
unsigned int flags_;
+ Type type_;
std::string deviceNode_;
unsigned int major_;
unsigned int minor_;
std::vector<MediaPad *> pads_;
+ std::vector<MediaEntity *> ancillaryEntities_;
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_INTERNAL_MEDIA_OBJECT_H__ */
diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build
index 665fd6de..7d6aa8b7 100644
--- a/include/libcamera/internal/meson.build
+++ b/include/libcamera/internal/meson.build
@@ -2,42 +2,58 @@
subdir('tracepoints')
-libcamera_tracepoint_header = custom_target(
- 'tp_header',
- input: ['tracepoints.h.in', tracepoint_files],
- output: 'tracepoints.h',
- command: [gen_tracepoints_header, '@OUTPUT@', '@INPUT@'],
-)
-
libcamera_internal_headers = files([
'bayer_format.h',
'byte_stream_buffer.h',
'camera.h',
'camera_controls.h',
+ 'camera_lens.h',
+ 'camera_manager.h',
'camera_sensor.h',
'camera_sensor_properties.h',
'control_serializer.h',
'control_validator.h',
+ 'converter.h',
+ 'debug_controls.h',
'delayed_controls.h',
'device_enumerator.h',
'device_enumerator_sysfs.h',
'device_enumerator_udev.h',
+ 'dma_buf_allocator.h',
'formats.h',
'framebuffer.h',
+ 'ipa_data_serializer.h',
'ipa_manager.h',
'ipa_module.h',
'ipa_proxy.h',
+ 'ipc_pipe.h',
'ipc_unixsocket.h',
'mapped_framebuffer.h',
+ 'matrix.h',
'media_device.h',
'media_object.h',
'pipeline_handler.h',
'process.h',
'pub_key.h',
+ 'request.h',
+ 'shared_mem_object.h',
'source_paths.h',
'sysfs.h',
'v4l2_device.h',
'v4l2_pixelformat.h',
'v4l2_subdevice.h',
'v4l2_videodevice.h',
+ 'yaml_parser.h',
])
+
+tracepoints_h = custom_target(
+ 'tp_header',
+ input : ['tracepoints.h.in', tracepoint_files],
+ output : 'tracepoints.h',
+ command : [gen_tracepoints, include_build_dir, '@OUTPUT@', '@INPUT@'],
+)
+
+libcamera_internal_headers += tracepoints_h
+
+subdir('converter')
+subdir('software_isp')
diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h
index 41cba44d..fb28a18d 100644
--- a/include/libcamera/internal/pipeline_handler.h
+++ b/include/libcamera/internal/pipeline_handler.h
@@ -2,13 +2,13 @@
/*
* Copyright (C) 2018, Google Inc.
*
- * pipeline_handler.h - Pipeline handler infrastructure
+ * Pipeline handler infrastructure
*/
-#ifndef __LIBCAMERA_INTERNAL_PIPELINE_HANDLER_H__
-#define __LIBCAMERA_INTERNAL_PIPELINE_HANDLER_H__
+
+#pragma once
#include <memory>
-#include <set>
+#include <queue>
#include <string>
#include <sys/types.h>
#include <vector>
@@ -18,8 +18,6 @@
#include <libcamera/controls.h>
#include <libcamera/stream.h>
-#include "libcamera/internal/ipa_proxy.h"
-
namespace libcamera {
class Camera;
@@ -43,80 +41,105 @@ public:
MediaDevice *acquireMediaDevice(DeviceEnumerator *enumerator,
const DeviceMatch &dm);
- bool lock();
- void unlock();
+ bool acquire(Camera *camera);
+ void release(Camera *camera);
- virtual CameraConfiguration *generateConfiguration(Camera *camera,
- const StreamRoles &roles) = 0;
+ virtual std::unique_ptr<CameraConfiguration> generateConfiguration(Camera *camera,
+ Span<const StreamRole> roles) = 0;
virtual int configure(Camera *camera, CameraConfiguration *config) = 0;
virtual int exportFrameBuffers(Camera *camera, Stream *stream,
std::vector<std::unique_ptr<FrameBuffer>> *buffers) = 0;
virtual int start(Camera *camera, const ControlList *controls) = 0;
- virtual void stop(Camera *camera) = 0;
+ void stop(Camera *camera);
bool hasPendingRequests(const Camera *camera) const;
+ void registerRequest(Request *request);
void queueRequest(Request *request);
bool completeBuffer(Request *request, FrameBuffer *buffer);
void completeRequest(Request *request);
+ void cancelRequest(Request *request);
+
+ std::string configurationFile(const std::string &subdir,
+ const std::string &name) const;
const char *name() const { return name_; }
+ CameraManager *cameraManager() const { return manager_; }
+
protected:
void registerCamera(std::shared_ptr<Camera> camera);
void hotplugMediaDevice(MediaDevice *media);
virtual int queueRequestDevice(Camera *camera, Request *request) = 0;
+ virtual void stopDevice(Camera *camera) = 0;
+
+ virtual bool acquireDevice(Camera *camera);
+ virtual void releaseDevice(Camera *camera);
CameraManager *manager_;
private:
+ void unlockMediaDevices();
+
void mediaDeviceDisconnected(MediaDevice *media);
virtual void disconnect();
+ void doQueueRequest(Request *request);
+ void doQueueRequests();
+
std::vector<std::shared_ptr<MediaDevice>> mediaDevices_;
std::vector<std::weak_ptr<Camera>> cameras_;
+ std::queue<Request *> waitingRequests_;
+
const char *name_;
+ unsigned int useCount_;
- friend class PipelineHandlerFactory;
+ friend class PipelineHandlerFactoryBase;
};
-class PipelineHandlerFactory
+class PipelineHandlerFactoryBase
{
public:
- PipelineHandlerFactory(const char *name);
- virtual ~PipelineHandlerFactory() = default;
+ PipelineHandlerFactoryBase(const char *name);
+ virtual ~PipelineHandlerFactoryBase() = default;
- std::shared_ptr<PipelineHandler> create(CameraManager *manager);
+ std::shared_ptr<PipelineHandler> create(CameraManager *manager) const;
const std::string &name() const { return name_; }
- static void registerType(PipelineHandlerFactory *factory);
- static std::vector<PipelineHandlerFactory *> &factories();
+ static std::vector<PipelineHandlerFactoryBase *> &factories();
+ static const PipelineHandlerFactoryBase *getFactoryByName(const std::string &name);
private:
- virtual PipelineHandler *createInstance(CameraManager *manager) = 0;
+ static void registerType(PipelineHandlerFactoryBase *factory);
+
+ virtual std::unique_ptr<PipelineHandler>
+ createInstance(CameraManager *manager) const = 0;
std::string name_;
};
-#define REGISTER_PIPELINE_HANDLER(handler) \
-class handler##Factory final : public PipelineHandlerFactory \
-{ \
-public: \
- handler##Factory() : PipelineHandlerFactory(#handler) {} \
- \
-private: \
- PipelineHandler *createInstance(CameraManager *manager) \
- { \
- return new handler(manager); \
- } \
-}; \
-static handler##Factory global_##handler##Factory;
+template<typename _PipelineHandler>
+class PipelineHandlerFactory final : public PipelineHandlerFactoryBase
+{
+public:
+ PipelineHandlerFactory(const char *name)
+ : PipelineHandlerFactoryBase(name)
+ {
+ }
+
+ std::unique_ptr<PipelineHandler>
+ createInstance(CameraManager *manager) const override
+ {
+ return std::make_unique<_PipelineHandler>(manager);
+ }
+};
-} /* namespace libcamera */
+#define REGISTER_PIPELINE_HANDLER(handler, name) \
+ static PipelineHandlerFactory<handler> global_##handler##Factory(name);
-#endif /* __LIBCAMERA_INTERNAL_PIPELINE_HANDLER_H__ */
+} /* namespace libcamera */
diff --git a/include/libcamera/internal/process.h b/include/libcamera/internal/process.h
index c4d5d9c1..b1d07a5a 100644
--- a/include/libcamera/internal/process.h
+++ b/include/libcamera/internal/process.h
@@ -2,16 +2,17 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * process.h - Process object
+ * Process object
*/
-#ifndef __LIBCAMERA_INTERNAL_PROCESS_H__
-#define __LIBCAMERA_INTERNAL_PROCESS_H__
+
+#pragma once
#include <signal.h>
#include <string>
#include <vector>
#include <libcamera/base/signal.h>
+#include <libcamera/base/unique_fd.h>
namespace libcamera {
@@ -38,7 +39,7 @@ public:
void kill();
- Signal<Process *, enum ExitStatus, int> finished;
+ Signal<enum ExitStatus, int> finished;
private:
void closeAllFdsExcept(const std::vector<int> &fds);
@@ -70,15 +71,14 @@ public:
private:
static ProcessManager *self_;
- void sighandler(EventNotifier *notifier);
+ void sighandler();
std::list<Process *> processes_;
struct sigaction oldsa_;
+
EventNotifier *sigEvent_;
- int pipe_[2];
+ UniqueFD pipe_[2];
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_INTERNAL_PROCESS_H__ */
diff --git a/include/libcamera/internal/pub_key.h b/include/libcamera/internal/pub_key.h
index 9261c9c2..c8cc04cb 100644
--- a/include/libcamera/internal/pub_key.h
+++ b/include/libcamera/internal/pub_key.h
@@ -2,16 +2,18 @@
/*
* Copyright (C) 2020, Google Inc.
*
- * pub_key.h - Public key signature verification
+ * Public key signature verification
*/
-#ifndef __LIBCAMERA_INTERNAL_PUB_KEY_H__
-#define __LIBCAMERA_INTERNAL_PUB_KEY_H__
+
+#pragma once
#include <stdint.h>
#include <libcamera/base/span.h>
-#if HAVE_GNUTLS
+#if HAVE_CRYPTO
+struct evp_pkey_st;
+#elif HAVE_GNUTLS
struct gnutls_pubkey_st;
#endif
@@ -28,11 +30,11 @@ public:
private:
bool valid_;
-#if HAVE_GNUTLS
+#if HAVE_CRYPTO
+ struct evp_pkey_st *pubkey_;
+#elif HAVE_GNUTLS
struct gnutls_pubkey_st *pubkey_;
#endif
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_INTERNAL_PUB_KEY_H__ */
diff --git a/include/libcamera/internal/request.h b/include/libcamera/internal/request.h
new file mode 100644
index 00000000..73e9bb5c
--- /dev/null
+++ b/include/libcamera/internal/request.h
@@ -0,0 +1,66 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2019, Google Inc.
+ *
+ * Request class private data
+ */
+
+#pragma once
+
+#include <chrono>
+#include <map>
+#include <memory>
+#include <stdint.h>
+#include <unordered_set>
+
+#include <libcamera/base/event_notifier.h>
+#include <libcamera/base/timer.h>
+
+#include <libcamera/request.h>
+
+using namespace std::chrono_literals;
+
+namespace libcamera {
+
+class Camera;
+class FrameBuffer;
+
+class Request::Private : public Extensible::Private
+{
+ LIBCAMERA_DECLARE_PUBLIC(Request)
+
+public:
+ Private(Camera *camera);
+ ~Private();
+
+ Camera *camera() const { return camera_; }
+ bool hasPendingBuffers() const;
+
+ bool completeBuffer(FrameBuffer *buffer);
+ void complete();
+ void cancel();
+ void reset();
+
+ void prepare(std::chrono::milliseconds timeout = 0ms);
+ Signal<> prepared;
+
+private:
+ friend class PipelineHandler;
+ friend std::ostream &operator<<(std::ostream &out, const Request &r);
+
+ void doCancelRequest();
+ void emitPrepareCompleted();
+ void notifierActivated(FrameBuffer *buffer);
+ void timeout();
+
+ Camera *camera_;
+ bool cancelled_;
+ uint32_t sequence_ = 0;
+ bool prepared_ = false;
+
+ std::unordered_set<FrameBuffer *> pending_;
+ std::map<FrameBuffer *, std::unique_ptr<EventNotifier>> notifiers_;
+ std::unique_ptr<Timer> timer_;
+};
+
+} /* namespace libcamera */
diff --git a/include/libcamera/internal/shared_mem_object.h b/include/libcamera/internal/shared_mem_object.h
new file mode 100644
index 00000000..e9f1dacd
--- /dev/null
+++ b/include/libcamera/internal/shared_mem_object.h
@@ -0,0 +1,126 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2023 Raspberry Pi Ltd
+ * Copyright (C) 2024 Andrei Konovalov
+ * Copyright (C) 2024 Dennis Bonke
+ *
+ * Helpers for shared memory allocations
+ */
+#pragma once
+
+#include <stdint.h>
+#include <string>
+#include <sys/mman.h>
+#include <type_traits>
+#include <utility>
+
+#include <libcamera/base/class.h>
+#include <libcamera/base/shared_fd.h>
+#include <libcamera/base/span.h>
+
+namespace libcamera {
+
+class SharedMem
+{
+public:
+ SharedMem();
+
+ SharedMem(const std::string &name, std::size_t size);
+ SharedMem(SharedMem &&rhs);
+
+ virtual ~SharedMem();
+
+ SharedMem &operator=(SharedMem &&rhs);
+
+ const SharedFD &fd() const
+ {
+ return fd_;
+ }
+
+ Span<uint8_t> mem() const
+ {
+ return mem_;
+ }
+
+ explicit operator bool() const
+ {
+ return !mem_.empty();
+ }
+
+private:
+ LIBCAMERA_DISABLE_COPY(SharedMem)
+
+ SharedFD fd_;
+
+ Span<uint8_t> mem_;
+};
+
+template<class T, typename = std::enable_if_t<std::is_standard_layout<T>::value>>
+class SharedMemObject : public SharedMem
+{
+public:
+ static constexpr std::size_t kSize = sizeof(T);
+
+ SharedMemObject()
+ : SharedMem(), obj_(nullptr)
+ {
+ }
+
+ template<class... Args>
+ SharedMemObject(const std::string &name, Args &&...args)
+ : SharedMem(name, kSize), obj_(nullptr)
+ {
+ if (mem().empty())
+ return;
+
+ obj_ = new (mem().data()) T(std::forward<Args>(args)...);
+ }
+
+ SharedMemObject(SharedMemObject<T> &&rhs)
+ : SharedMem(std::move(rhs))
+ {
+ this->obj_ = rhs.obj_;
+ rhs.obj_ = nullptr;
+ }
+
+ ~SharedMemObject()
+ {
+ if (obj_)
+ obj_->~T();
+ }
+
+ SharedMemObject<T> &operator=(SharedMemObject<T> &&rhs)
+ {
+ SharedMem::operator=(std::move(rhs));
+ this->obj_ = rhs.obj_;
+ rhs.obj_ = nullptr;
+ return *this;
+ }
+
+ T *operator->()
+ {
+ return obj_;
+ }
+
+ const T *operator->() const
+ {
+ return obj_;
+ }
+
+ T &operator*()
+ {
+ return *obj_;
+ }
+
+ const T &operator*() const
+ {
+ return *obj_;
+ }
+
+private:
+ LIBCAMERA_DISABLE_COPY(SharedMemObject)
+
+ T *obj_;
+};
+
+} /* namespace libcamera */
diff --git a/include/libcamera/internal/software_isp/debayer_params.h b/include/libcamera/internal/software_isp/debayer_params.h
new file mode 100644
index 00000000..7d8fdd48
--- /dev/null
+++ b/include/libcamera/internal/software_isp/debayer_params.h
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2023, 2024 Red Hat Inc.
+ *
+ * Authors:
+ * Hans de Goede <hdegoede@redhat.com>
+ *
+ * DebayerParams header
+ */
+
+#pragma once
+
+#include <array>
+#include <stdint.h>
+
+namespace libcamera {
+
+struct DebayerParams {
+ static constexpr unsigned int kRGBLookupSize = 256;
+
+ using ColorLookupTable = std::array<uint8_t, kRGBLookupSize>;
+
+ ColorLookupTable red;
+ ColorLookupTable green;
+ ColorLookupTable blue;
+};
+
+} /* namespace libcamera */
diff --git a/include/libcamera/internal/software_isp/meson.build b/include/libcamera/internal/software_isp/meson.build
new file mode 100644
index 00000000..508ddddc
--- /dev/null
+++ b/include/libcamera/internal/software_isp/meson.build
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: CC0-1.0
+
+libcamera_internal_headers += files([
+ 'debayer_params.h',
+ 'software_isp.h',
+ 'swisp_stats.h',
+])
diff --git a/include/libcamera/internal/software_isp/software_isp.h b/include/libcamera/internal/software_isp/software_isp.h
new file mode 100644
index 00000000..d51b03fd
--- /dev/null
+++ b/include/libcamera/internal/software_isp/software_isp.h
@@ -0,0 +1,104 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2023, Linaro Ltd
+ *
+ * Simple software ISP implementation
+ */
+
+#pragma once
+
+#include <functional>
+#include <initializer_list>
+#include <map>
+#include <memory>
+#include <stdint.h>
+#include <string>
+#include <tuple>
+#include <vector>
+
+#include <libcamera/base/class.h>
+#include <libcamera/base/log.h>
+#include <libcamera/base/signal.h>
+#include <libcamera/base/thread.h>
+
+#include <libcamera/geometry.h>
+#include <libcamera/pixel_format.h>
+
+#include <libcamera/ipa/soft_ipa_interface.h>
+#include <libcamera/ipa/soft_ipa_proxy.h>
+
+#include "libcamera/internal/camera_sensor.h"
+#include "libcamera/internal/dma_buf_allocator.h"
+#include "libcamera/internal/pipeline_handler.h"
+#include "libcamera/internal/shared_mem_object.h"
+#include "libcamera/internal/software_isp/debayer_params.h"
+
+namespace libcamera {
+
+class DebayerCpu;
+class FrameBuffer;
+class PixelFormat;
+class Stream;
+struct StreamConfiguration;
+
+LOG_DECLARE_CATEGORY(SoftwareIsp)
+
+class SoftwareIsp
+{
+public:
+ SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor,
+ ControlInfoMap *ipaControls);
+ ~SoftwareIsp();
+
+ int loadConfiguration([[maybe_unused]] const std::string &filename) { return 0; }
+
+ bool isValid() const;
+
+ std::vector<PixelFormat> formats(PixelFormat input);
+
+ SizeRange sizes(PixelFormat inputFormat, const Size &inputSize);
+
+ std::tuple<unsigned int, unsigned int>
+ strideAndFrameSize(const PixelFormat &outputFormat, const Size &size);
+
+ int configure(const StreamConfiguration &inputCfg,
+ const std::vector<std::reference_wrapper<StreamConfiguration>> &outputCfgs,
+ const ipa::soft::IPAConfigInfo &configInfo);
+
+ int exportBuffers(const Stream *stream, unsigned int count,
+ std::vector<std::unique_ptr<FrameBuffer>> *buffers);
+
+ void processStats(const uint32_t frame, const uint32_t bufferId,
+ const ControlList &sensorControls);
+
+ int start();
+ void stop();
+
+ void queueRequest(const uint32_t frame, const ControlList &controls);
+ int queueBuffers(uint32_t frame, FrameBuffer *input,
+ const std::map<const Stream *, FrameBuffer *> &outputs);
+
+ void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output);
+
+ Signal<FrameBuffer *> inputBufferReady;
+ Signal<FrameBuffer *> outputBufferReady;
+ Signal<uint32_t, uint32_t> ispStatsReady;
+ Signal<const ControlList &> setSensorControls;
+
+private:
+ void saveIspParams();
+ void setSensorCtrls(const ControlList &sensorControls);
+ void statsReady(uint32_t frame, uint32_t bufferId);
+ void inputReady(FrameBuffer *input);
+ void outputReady(FrameBuffer *output);
+
+ std::unique_ptr<DebayerCpu> debayer_;
+ Thread ispWorkerThread_;
+ SharedMemObject<DebayerParams> sharedParams_;
+ DebayerParams debayerParams_;
+ DmaBufAllocator dmaHeap_;
+
+ std::unique_ptr<ipa::soft::IPAProxySoft> ipa_;
+};
+
+} /* namespace libcamera */
diff --git a/include/libcamera/internal/software_isp/swisp_stats.h b/include/libcamera/internal/software_isp/swisp_stats.h
new file mode 100644
index 00000000..ae11f112
--- /dev/null
+++ b/include/libcamera/internal/software_isp/swisp_stats.h
@@ -0,0 +1,49 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2023, Linaro Ltd
+ *
+ * Statistics data format used by the software ISP and software IPA
+ */
+
+#pragma once
+
+#include <array>
+#include <stdint.h>
+
+namespace libcamera {
+
+/**
+ * \brief Struct that holds the statistics for the Software ISP
+ *
+ * The struct value types are large enough to not overflow.
+ * Should they still overflow for some reason, no check is performed and they
+ * wrap around.
+ */
+struct SwIspStats {
+ /**
+ * \brief Holds the sum of all sampled red pixels
+ */
+ uint64_t sumR_;
+ /**
+ * \brief Holds the sum of all sampled green pixels
+ */
+ uint64_t sumG_;
+ /**
+ * \brief Holds the sum of all sampled blue pixels
+ */
+ uint64_t sumB_;
+ /**
+ * \brief Number of bins in the yHistogram
+ */
+ static constexpr unsigned int kYHistogramSize = 64;
+ /**
+ * \brief Type of the histogram.
+ */
+ using Histogram = std::array<uint32_t, kYHistogramSize>;
+ /**
+ * \brief A histogram of luminance values
+ */
+ Histogram yHistogram;
+};
+
+} /* namespace libcamera */
diff --git a/include/libcamera/internal/source_paths.h b/include/libcamera/internal/source_paths.h
index 111c25b0..14e64717 100644
--- a/include/libcamera/internal/source_paths.h
+++ b/include/libcamera/internal/source_paths.h
@@ -2,10 +2,10 @@
/*
* Copyright (C) 2021, Google Inc.
*
- * source_paths.h - Identify libcamera source and build paths
+ * Identify libcamera source and build paths
*/
-#ifndef __LIBCAMERA_INTERNAL_SOURCE_PATHS_H__
-#define __LIBCAMERA_INTERNAL_SOURCE_PATHS_H__
+
+#pragma once
#include <string>
@@ -15,5 +15,3 @@ std::string libcameraBuildPath();
std::string libcameraSourcePath();
} /* namespace libcamera::utils */
-
-#endif /* __LIBCAMERA_INTERNAL_SOURCE_PATHS_H__ */
diff --git a/include/libcamera/internal/sysfs.h b/include/libcamera/internal/sysfs.h
index bc6c1620..aca60fb6 100644
--- a/include/libcamera/internal/sysfs.h
+++ b/include/libcamera/internal/sysfs.h
@@ -2,10 +2,10 @@
/*
* Copyright (C) 2020, Google Inc.
*
- * sysfs.h - Miscellaneous utility functions to access sysfs
+ * Miscellaneous utility functions to access sysfs
*/
-#ifndef __LIBCAMERA_INTERNAL_SYSFS_H__
-#define __LIBCAMERA_INTERNAL_SYSFS_H__
+
+#pragma once
#include <string>
@@ -20,5 +20,3 @@ std::string firmwareNodePath(const std::string &device);
} /* namespace sysfs */
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_INTERNAL_SYSFS_H__ */
diff --git a/include/libcamera/internal/tracepoints.h.in b/include/libcamera/internal/tracepoints.h.in
index d0fc1365..385f9f54 100644
--- a/include/libcamera/internal/tracepoints.h.in
+++ b/include/libcamera/internal/tracepoints.h.in
@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
- * Copyright (C) {{year}}, Google Inc.
+ * Copyright (C) 2020, Google Inc.
*
- * tracepoints.h - Tracepoints with lttng
+ * Tracepoints with lttng
*
* This file is auto-generated. Do not edit.
*/
diff --git a/include/libcamera/internal/tracepoints/request.tp b/include/libcamera/internal/tracepoints/request.tp
index 37d8c46f..42c59685 100644
--- a/include/libcamera/internal/tracepoints/request.tp
+++ b/include/libcamera/internal/tracepoints/request.tp
@@ -5,8 +5,11 @@
* request.tp - Tracepoints for the request object
*/
+#include <stdint.h>
+
#include <libcamera/framebuffer.h>
-#include <libcamera/request.h>
+
+#include "libcamera/internal/request.h"
TRACEPOINT_EVENT_CLASS(
libcamera,
@@ -60,7 +63,7 @@ TRACEPOINT_EVENT_INSTANCE(
TRACEPOINT_EVENT_INSTANCE(
libcamera,
request,
- request_complete,
+ request_device_queue,
TP_ARGS(
libcamera::Request *, req
)
@@ -69,9 +72,18 @@ TRACEPOINT_EVENT_INSTANCE(
TRACEPOINT_EVENT_INSTANCE(
libcamera,
request,
+ request_complete,
+ TP_ARGS(
+ libcamera::Request::Private *, req
+ )
+)
+
+TRACEPOINT_EVENT_INSTANCE(
+ libcamera,
+ request,
request_cancel,
TP_ARGS(
- libcamera::Request *, req
+ libcamera::Request::Private *, req
)
)
@@ -79,13 +91,13 @@ TRACEPOINT_EVENT(
libcamera,
request_complete_buffer,
TP_ARGS(
- libcamera::Request *, req,
+ libcamera::Request::Private *, req,
libcamera::FrameBuffer *, buf
),
TP_FIELDS(
ctf_integer_hex(uintptr_t, request, reinterpret_cast<uintptr_t>(req))
- ctf_integer(uint64_t, cookie, req->cookie())
- ctf_integer(int, status, req->status())
+ ctf_integer(uint64_t, cookie, req->_o<libcamera::Request>()->cookie())
+ ctf_integer(int, status, req->_o<libcamera::Request>()->status())
ctf_integer_hex(uintptr_t, buffer, reinterpret_cast<uintptr_t>(buf))
ctf_enum(libcamera, buffer_status, uint32_t, buf_status, buf->metadata().status)
)
diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h
index 423c8fb1..affe52c2 100644
--- a/include/libcamera/internal/v4l2_device.h
+++ b/include/libcamera/internal/v4l2_device.h
@@ -2,13 +2,15 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * v4l2_device.h - Common base for V4L2 video devices and subdevices
+ * Common base for V4L2 video devices and subdevices
*/
-#ifndef __LIBCAMERA_INTERNAL_V4L2_DEVICE_H__
-#define __LIBCAMERA_INTERNAL_V4L2_DEVICE_H__
+
+#pragma once
#include <map>
#include <memory>
+#include <optional>
+#include <stdint.h>
#include <vector>
#include <linux/videodev2.h>
@@ -16,9 +18,13 @@
#include <libcamera/base/log.h>
#include <libcamera/base/signal.h>
#include <libcamera/base/span.h>
+#include <libcamera/base/unique_fd.h>
+#include <libcamera/color_space.h>
#include <libcamera/controls.h>
+#include "libcamera/internal/formats.h"
+
namespace libcamera {
class EventNotifier;
@@ -27,7 +33,7 @@ class V4L2Device : protected Loggable
{
public:
void close();
- bool isOpen() const { return fd_ != -1; }
+ bool isOpen() const { return fd_.isValid(); }
const ControlInfoMap &controls() const { return controls_; }
@@ -49,35 +55,40 @@ protected:
~V4L2Device();
int open(unsigned int flags);
- int setFd(int fd);
+ int setFd(UniqueFD fd);
int ioctl(unsigned long request, void *argp);
- int fd() const { return fd_; }
+ int fd() const { return fd_.get(); }
+
+ template<typename T>
+ static std::optional<ColorSpace> toColorSpace(const T &v4l2Format,
+ PixelFormatInfo::ColourEncoding colourEncoding);
+
+ template<typename T>
+ static int fromColorSpace(const std::optional<ColorSpace> &colorSpace, T &v4l2Format);
private:
static ControlType v4l2CtrlType(uint32_t ctrlType);
static std::unique_ptr<ControlId> v4l2ControlId(const v4l2_query_ext_ctrl &ctrl);
- ControlInfo v4l2ControlInfo(const v4l2_query_ext_ctrl &ctrl);
- ControlInfo v4l2MenuControlInfo(const v4l2_query_ext_ctrl &ctrl);
+ std::optional<ControlInfo> v4l2ControlInfo(const v4l2_query_ext_ctrl &ctrl);
+ std::optional<ControlInfo> v4l2MenuControlInfo(const v4l2_query_ext_ctrl &ctrl);
void listControls();
void updateControls(ControlList *ctrls,
Span<const v4l2_ext_control> v4l2Ctrls);
- void eventAvailable(EventNotifier *notifier);
+ void eventAvailable();
std::map<unsigned int, struct v4l2_query_ext_ctrl> controlInfo_;
std::vector<std::unique_ptr<ControlId>> controlIds_;
ControlIdMap controlIdMap_;
ControlInfoMap controls_;
std::string deviceNode_;
- int fd_;
+ UniqueFD fd_;
EventNotifier *fdEventNotifier_;
bool frameStartEnabled_;
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_INTERNAL_V4L2_DEVICE_H__ */
diff --git a/include/libcamera/internal/v4l2_pixelformat.h b/include/libcamera/internal/v4l2_pixelformat.h
index 9bfd81ad..543eb21b 100644
--- a/include/libcamera/internal/v4l2_pixelformat.h
+++ b/include/libcamera/internal/v4l2_pixelformat.h
@@ -1,15 +1,18 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
- * Copyright (C) 2020, Raspberry Pi (Trading) Ltd.
+ * Copyright (C) 2020, Raspberry Pi Ltd
*
- * v4l2_pixelformat.h - V4L2 Pixel Format
+ * V4L2 Pixel Format
*/
-#ifndef __LIBCAMERA_INTERNAL_V4L2_PIXELFORMAT_H__
-#define __LIBCAMERA_INTERNAL_V4L2_PIXELFORMAT_H__
+#pragma once
+
+#include <functional>
+#include <ostream>
#include <stdint.h>
#include <string>
+#include <vector>
#include <linux/videodev2.h>
@@ -20,6 +23,11 @@ namespace libcamera {
class V4L2PixelFormat
{
public:
+ struct Info {
+ PixelFormat format;
+ const char *description;
+ };
+
V4L2PixelFormat()
: fourcc_(0)
{
@@ -35,15 +43,30 @@ public:
operator uint32_t() const { return fourcc_; }
std::string toString() const;
+ const char *description() const;
+
+ PixelFormat toPixelFormat(bool warn = true) const;
+ static const std::vector<V4L2PixelFormat> &
+ fromPixelFormat(const PixelFormat &pixelFormat);
- PixelFormat toPixelFormat() const;
- static V4L2PixelFormat fromPixelFormat(const PixelFormat &pixelFormat,
- bool multiplanar);
+ bool isGenericLineBasedMetadata() const;
private:
uint32_t fourcc_;
};
+std::ostream &operator<<(std::ostream &out, const V4L2PixelFormat &f);
+
} /* namespace libcamera */
-#endif /* __LIBCAMERA_INTERNAL_V4L2_PIXELFORMAT_H__ */
+namespace std {
+
+template<>
+struct hash<libcamera::V4L2PixelFormat> {
+ size_t operator()(libcamera::V4L2PixelFormat const &format) const noexcept
+ {
+ return format.fourcc();
+ }
+};
+
+} /* namespace std */
diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h
index 97b89fb9..fa2a4a21 100644
--- a/include/libcamera/internal/v4l2_subdevice.h
+++ b/include/libcamera/internal/v4l2_subdevice.h
@@ -2,18 +2,24 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * v4l2_subdevice.h - V4L2 Subdevice
+ * V4L2 Subdevice
*/
-#ifndef __LIBCAMERA_INTERNAL_V4L2_SUBDEVICE_H__
-#define __LIBCAMERA_INTERNAL_V4L2_SUBDEVICE_H__
+
+#pragma once
#include <memory>
+#include <optional>
+#include <ostream>
+#include <stdint.h>
#include <string>
#include <vector>
+#include <linux/v4l2-subdev.h>
+
#include <libcamera/base/class.h>
#include <libcamera/base/log.h>
+#include <libcamera/color_space.h>
#include <libcamera/geometry.h>
#include "libcamera/internal/formats.h"
@@ -24,24 +30,90 @@ namespace libcamera {
class MediaDevice;
+class MediaBusFormatInfo
+{
+public:
+ enum class Type {
+ Image,
+ Metadata,
+ EmbeddedData,
+ };
+
+ bool isValid() const { return code != 0; }
+
+ static const MediaBusFormatInfo &info(uint32_t code);
+
+ const char *name;
+ uint32_t code;
+ Type type;
+ unsigned int bitsPerPixel;
+ PixelFormatInfo::ColourEncoding colourEncoding;
+};
+
+struct V4L2SubdeviceCapability final : v4l2_subdev_capability {
+ bool isReadOnly() const
+ {
+ return capabilities & V4L2_SUBDEV_CAP_RO_SUBDEV;
+ }
+ bool hasStreams() const
+ {
+ return capabilities & V4L2_SUBDEV_CAP_STREAMS;
+ }
+};
+
struct V4L2SubdeviceFormat {
- uint32_t mbus_code;
+ uint32_t code;
Size size;
+ std::optional<ColorSpace> colorSpace;
const std::string toString() const;
- uint8_t bitsPerPixel() const;
};
+std::ostream &operator<<(std::ostream &out, const V4L2SubdeviceFormat &f);
+
class V4L2Subdevice : public V4L2Device
{
public:
using Formats = std::map<unsigned int, std::vector<SizeRange>>;
enum Whence {
- ActiveFormat,
- TryFormat,
+ TryFormat = V4L2_SUBDEV_FORMAT_TRY,
+ ActiveFormat = V4L2_SUBDEV_FORMAT_ACTIVE,
};
+ struct Stream {
+ Stream()
+ : pad(0), stream(0)
+ {
+ }
+
+ Stream(unsigned int p, unsigned int s)
+ : pad(p), stream(s)
+ {
+ }
+
+ unsigned int pad;
+ unsigned int stream;
+ };
+
+ struct Route {
+ Route()
+ : flags(0)
+ {
+ }
+
+ Route(const Stream &snk, const Stream &src, uint32_t f)
+ : sink(snk), source(src), flags(f)
+ {
+ }
+
+ Stream sink;
+ Stream source;
+ uint32_t flags;
+ };
+
+ using Routing = std::vector<Route>;
+
explicit V4L2Subdevice(const MediaEntity *entity);
~V4L2Subdevice();
@@ -49,17 +121,45 @@ public:
const MediaEntity *entity() const { return entity_; }
- int getSelection(unsigned int pad, unsigned int target,
+ int getSelection(const Stream &stream, unsigned int target,
Rectangle *rect);
- int setSelection(unsigned int pad, unsigned int target,
+ int getSelection(unsigned int pad, unsigned int target, Rectangle *rect)
+ {
+ return getSelection({ pad, 0 }, target, rect);
+ }
+ int setSelection(const Stream &stream, unsigned int target,
Rectangle *rect);
-
- Formats formats(unsigned int pad);
-
+ int setSelection(unsigned int pad, unsigned int target, Rectangle *rect)
+ {
+ return setSelection({ pad, 0 }, target, rect);
+ }
+
+ Formats formats(const Stream &stream);
+ Formats formats(unsigned int pad)
+ {
+ return formats({ pad, 0 });
+ }
+
+ int getFormat(const Stream &stream, V4L2SubdeviceFormat *format,
+ Whence whence = ActiveFormat);
int getFormat(unsigned int pad, V4L2SubdeviceFormat *format,
+ Whence whence = ActiveFormat)
+ {
+ return getFormat({ pad, 0 }, format, whence);
+ }
+ int setFormat(const Stream &stream, V4L2SubdeviceFormat *format,
Whence whence = ActiveFormat);
int setFormat(unsigned int pad, V4L2SubdeviceFormat *format,
- Whence whence = ActiveFormat);
+ Whence whence = ActiveFormat)
+ {
+ return setFormat({ pad, 0 }, format, whence);
+ }
+
+ int getRouting(Routing *routing, Whence whence = ActiveFormat);
+ int setRouting(Routing *routing, Whence whence = ActiveFormat);
+
+ const std::string &model();
+ const V4L2SubdeviceCapability &caps() const { return caps_; }
static std::unique_ptr<V4L2Subdevice>
fromEntityName(const MediaDevice *media, const std::string &entity);
@@ -70,13 +170,31 @@ protected:
private:
LIBCAMERA_DISABLE_COPY(V4L2Subdevice)
- std::vector<unsigned int> enumPadCodes(unsigned int pad);
- std::vector<SizeRange> enumPadSizes(unsigned int pad,
+ std::optional<ColorSpace>
+ toColorSpace(const v4l2_mbus_framefmt &format) const;
+
+ std::vector<unsigned int> enumPadCodes(const Stream &stream);
+ std::vector<SizeRange> enumPadSizes(const Stream &stream,
unsigned int code);
+ int getRoutingLegacy(Routing *routing, Whence whence);
+ int setRoutingLegacy(Routing *routing, Whence whence);
+
const MediaEntity *entity_;
+
+ std::string model_;
+ struct V4L2SubdeviceCapability caps_;
};
-} /* namespace libcamera */
+bool operator==(const V4L2Subdevice::Stream &lhs, const V4L2Subdevice::Stream &rhs);
+static inline bool operator!=(const V4L2Subdevice::Stream &lhs,
+ const V4L2Subdevice::Stream &rhs)
+{
+ return !(lhs == rhs);
+}
-#endif /* __LIBCAMERA_INTERNAL_V4L2_SUBDEVICE_H__ */
+std::ostream &operator<<(std::ostream &out, const V4L2Subdevice::Stream &stream);
+std::ostream &operator<<(std::ostream &out, const V4L2Subdevice::Route &route);
+std::ostream &operator<<(std::ostream &out, const V4L2Subdevice::Routing &routing);
+
+} /* namespace libcamera */
diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h
index 4a5d2cad..f021c2a0 100644
--- a/include/libcamera/internal/v4l2_videodevice.h
+++ b/include/libcamera/internal/v4l2_videodevice.h
@@ -2,16 +2,19 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * v4l2_videodevice.h - V4L2 Video Device
+ * V4L2 Video Device
*/
-#ifndef __LIBCAMERA_INTERNAL_V4L2_VIDEODEVICE_H__
-#define __LIBCAMERA_INTERNAL_V4L2_VIDEODEVICE_H__
+
+#pragma once
#include <array>
#include <atomic>
#include <memory>
+#include <optional>
+#include <ostream>
#include <stdint.h>
#include <string>
+#include <unordered_set>
#include <vector>
#include <linux/videodev2.h>
@@ -19,7 +22,11 @@
#include <libcamera/base/class.h>
#include <libcamera/base/log.h>
#include <libcamera/base/signal.h>
+#include <libcamera/base/timer.h>
+#include <libcamera/base/unique_fd.h>
+#include <libcamera/base/utils.h>
+#include <libcamera/color_space.h>
#include <libcamera/framebuffer.h>
#include <libcamera/geometry.h>
#include <libcamera/pixel_format.h>
@@ -31,7 +38,6 @@
namespace libcamera {
class EventNotifier;
-class FileDescriptor;
class MediaDevice;
class MediaEntity;
@@ -109,6 +115,10 @@ struct V4L2Capability final : v4l2_capability {
{
return device_caps() & V4L2_CAP_STREAMING;
}
+ bool hasMediaController() const
+ {
+ return device_caps() & V4L2_CAP_IO_MC;
+ }
};
class V4L2BufferCache
@@ -118,6 +128,7 @@ public:
V4L2BufferCache(const std::vector<std::unique_ptr<FrameBuffer>> &buffers);
~V4L2BufferCache();
+ bool isEmpty() const;
int get(const FrameBuffer &buffer);
void put(unsigned int index);
@@ -136,7 +147,7 @@ private:
private:
struct Plane {
Plane(const FrameBuffer::Plane &plane)
- : fd(plane.fd.fd()), length(plane.length)
+ : fd(plane.fd.get()), length(plane.length)
{
}
@@ -163,6 +174,7 @@ public:
V4L2PixelFormat fourcc;
Size size;
+ std::optional<ColorSpace> colorSpace;
std::array<Plane, 3> planes;
unsigned int planesCount = 0;
@@ -170,6 +182,8 @@ public:
const std::string toString() const;
};
+std::ostream &operator<<(std::ostream &out, const V4L2DeviceFormat &f);
+
class V4L2VideoDevice : public V4L2Device
{
public:
@@ -180,7 +194,7 @@ public:
~V4L2VideoDevice();
int open();
- int open(int handle, enum v4l2_buf_type type);
+ int open(SharedFD handle, enum v4l2_buf_type type);
void close();
const char *driverName() const { return caps_.driver(); }
@@ -194,6 +208,7 @@ public:
int setFormat(V4L2DeviceFormat *format);
Formats formats(uint32_t code = 0);
+ int getSelection(unsigned int target, Rectangle *rect);
int setSelection(unsigned int target, Rectangle *rect);
int allocateBuffers(unsigned int count,
@@ -209,10 +224,13 @@ public:
int streamOn();
int streamOff();
+ void setDequeueTimeout(utils::Duration timeout);
+ Signal<> dequeueTimeout;
+
static std::unique_ptr<V4L2VideoDevice>
fromEntityName(const MediaDevice *media, const std::string &entity);
- V4L2PixelFormat toV4L2PixelFormat(const PixelFormat &pixelFormat);
+ V4L2PixelFormat toV4L2PixelFormat(const PixelFormat &pixelFormat) const;
protected:
std::string logPrefix() const override;
@@ -220,6 +238,14 @@ protected:
private:
LIBCAMERA_DISABLE_COPY(V4L2VideoDevice)
+ enum class State {
+ Streaming,
+ Stopping,
+ Stopped,
+ };
+
+ int initFormats();
+
int getFormatMeta(V4L2DeviceFormat *format);
int trySetFormatMeta(V4L2DeviceFormat *format, bool set);
@@ -236,13 +262,20 @@ private:
int createBuffers(unsigned int count,
std::vector<std::unique_ptr<FrameBuffer>> *buffers);
std::unique_ptr<FrameBuffer> createBuffer(unsigned int index);
- FileDescriptor exportDmabufFd(unsigned int index, unsigned int plane);
+ UniqueFD exportDmabufFd(unsigned int index, unsigned int plane);
- void bufferAvailable(EventNotifier *notifier);
+ void bufferAvailable();
FrameBuffer *dequeueBuffer();
+ void watchdogExpired();
+
+ template<typename T>
+ static std::optional<ColorSpace> toColorSpace(const T &v4l2Format);
+
V4L2Capability caps_;
V4L2DeviceFormat format_;
+ const PixelFormatInfo *formatInfo_;
+ std::unordered_set<V4L2PixelFormat> pixelFormats_;
enum v4l2_buf_type bufferType_;
enum v4l2_memory memoryType_;
@@ -252,7 +285,11 @@ private:
EventNotifier *fdBufferNotifier_;
- bool streaming_;
+ State state_;
+ std::optional<unsigned int> firstFrame_;
+
+ Timer watchdog_;
+ utils::Duration watchdogDuration_;
};
class V4L2M2MDevice
@@ -275,5 +312,3 @@ private:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_INTERNAL_V4L2_VIDEODEVICE_H__ */
diff --git a/include/libcamera/internal/yaml_parser.h b/include/libcamera/internal/yaml_parser.h
new file mode 100644
index 00000000..8c791656
--- /dev/null
+++ b/include/libcamera/internal/yaml_parser.h
@@ -0,0 +1,245 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2022, Google Inc.
+ *
+ * libcamera YAML parsing helper
+ */
+
+#pragma once
+
+#include <iterator>
+#include <map>
+#include <optional>
+#include <stdint.h>
+#include <string>
+#include <string_view>
+#include <vector>
+
+#include <libcamera/base/class.h>
+
+#include <libcamera/geometry.h>
+
+namespace libcamera {
+
+class File;
+class YamlParserContext;
+
+class YamlObject
+{
+private:
+ struct Value {
+ Value(std::string &&k, std::unique_ptr<YamlObject> &&v)
+ : key(std::move(k)), value(std::move(v))
+ {
+ }
+ std::string key;
+ std::unique_ptr<YamlObject> value;
+ };
+
+ using Container = std::vector<Value>;
+ using ListContainer = std::vector<std::unique_ptr<YamlObject>>;
+
+public:
+#ifndef __DOXYGEN__
+ template<typename Derived>
+ class Iterator
+ {
+ public:
+ using difference_type = std::ptrdiff_t;
+ using iterator_category = std::forward_iterator_tag;
+
+ Iterator(typename Container::const_iterator it)
+ : it_(it)
+ {
+ }
+
+ Derived &operator++()
+ {
+ ++it_;
+ return *static_cast<Derived *>(this);
+ }
+
+ Derived operator++(int)
+ {
+ Derived it = *static_cast<Derived *>(this);
+ it_++;
+ return it;
+ }
+
+ friend bool operator==(const Iterator &a, const Iterator &b)
+ {
+ return a.it_ == b.it_;
+ }
+
+ friend bool operator!=(const Iterator &a, const Iterator &b)
+ {
+ return a.it_ != b.it_;
+ }
+
+ protected:
+ Container::const_iterator it_;
+ };
+
+ template<typename Iterator>
+ class Adapter
+ {
+ public:
+ Adapter(const Container &container)
+ : container_(container)
+ {
+ }
+
+ Iterator begin() const
+ {
+ return Iterator{ container_.begin() };
+ }
+
+ Iterator end() const
+ {
+ return Iterator{ container_.end() };
+ }
+
+ protected:
+ const Container &container_;
+ };
+
+ class ListIterator : public Iterator<ListIterator>
+ {
+ public:
+ using value_type = const YamlObject &;
+ using pointer = const YamlObject *;
+ using reference = value_type;
+
+ value_type operator*() const
+ {
+ return *it_->value.get();
+ }
+
+ pointer operator->() const
+ {
+ return it_->value.get();
+ }
+ };
+
+ class DictIterator : public Iterator<DictIterator>
+ {
+ public:
+ using value_type = std::pair<const std::string &, const YamlObject &>;
+ using pointer = value_type *;
+ using reference = value_type &;
+
+ value_type operator*() const
+ {
+ return { it_->key, *it_->value.get() };
+ }
+ };
+
+ class DictAdapter : public Adapter<DictIterator>
+ {
+ public:
+ using key_type = std::string;
+ };
+
+ class ListAdapter : public Adapter<ListIterator>
+ {
+ };
+#endif /* __DOXYGEN__ */
+
+ YamlObject();
+ ~YamlObject();
+
+ bool isValue() const
+ {
+ return type_ == Type::Value;
+ }
+ bool isList() const
+ {
+ return type_ == Type::List;
+ }
+ bool isDictionary() const
+ {
+ return type_ == Type::Dictionary;
+ }
+ bool isEmpty() const
+ {
+ return type_ == Type::Empty;
+ }
+ explicit operator bool() const
+ {
+ return type_ != Type::Empty;
+ }
+
+ std::size_t size() const;
+
+ template<typename T>
+ std::optional<T> get() const
+ {
+ return Getter<T>{}.get(*this);
+ }
+
+ template<typename T, typename U>
+ T get(U &&defaultValue) const
+ {
+ return get<T>().value_or(std::forward<U>(defaultValue));
+ }
+
+#ifndef __DOXYGEN__
+ template<typename T,
+ std::enable_if_t<
+ std::is_same_v<bool, T> ||
+ std::is_same_v<float, T> ||
+ std::is_same_v<double, T> ||
+ std::is_same_v<int8_t, T> ||
+ std::is_same_v<uint8_t, T> ||
+ std::is_same_v<int16_t, T> ||
+ std::is_same_v<uint16_t, T> ||
+ std::is_same_v<int32_t, T> ||
+ std::is_same_v<uint32_t, T> ||
+ std::is_same_v<std::string, T> ||
+ std::is_same_v<Size, T>> * = nullptr>
+#else
+ template<typename T>
+#endif
+ std::optional<std::vector<T>> getList() const;
+
+ DictAdapter asDict() const { return DictAdapter{ list_ }; }
+ ListAdapter asList() const { return ListAdapter{ list_ }; }
+
+ const YamlObject &operator[](std::size_t index) const;
+
+ bool contains(std::string_view key) const;
+ const YamlObject &operator[](std::string_view key) const;
+
+private:
+ LIBCAMERA_DISABLE_COPY_AND_MOVE(YamlObject)
+
+ template<typename T>
+ friend struct Getter;
+ friend class YamlParserContext;
+
+ enum class Type {
+ Dictionary,
+ List,
+ Value,
+ Empty,
+ };
+
+ template<typename T, typename Enable = void>
+ struct Getter {
+ std::optional<T> get(const YamlObject &obj) const;
+ };
+
+ Type type_;
+
+ std::string value_;
+ Container list_;
+ std::map<std::string, YamlObject *, std::less<>> dictionary_;
+};
+
+class YamlParser final
+{
+public:
+ static std::unique_ptr<YamlObject> parse(File &file);
+};
+
+} /* namespace libcamera */
diff --git a/include/libcamera/ipa/core.mojom b/include/libcamera/ipa/core.mojom
index f7eff0c7..bce79724 100644
--- a/include/libcamera/ipa/core.mojom
+++ b/include/libcamera/ipa/core.mojom
@@ -14,8 +14,8 @@ module libcamera;
* - structs
*
* Attributes:
- * - skipHeader - structs only, and only in core.mojom
- * - Do not generate a C++ definition for the structure
+ * - skipHeader - allowed only for structs and enums in core.mojom
+ * - Do not generate a C++ definition for the structure or enum
* - Any type used in a mojom interface definition must have a corresponding
* definition in a mojom file for the code generator to accept it, except
* for types solely used as map/array members for which a definition is not
@@ -32,7 +32,16 @@ module libcamera;
* - This attribute instructs the build system that a (de)serializer is
* available for the type and there's no need to generate one
* - hasFd - struct fields or empty structs only
- * - Designate that this field or empty struct contains a FileDescriptor
+ * - Designate that this field or empty struct contains a SharedFD
+ * - scopedEnum - enum definitions
+ * - Designate that this enum should be an enum class, as opposed to a pure
+ * enum
+ * - flags - struct fields or function parameters that are enums
+ * - Designate that this enum type E should be Flags<E> in the generated C++
+ * code
+ * - For example, if a struct field is defined as `[flags] ErrorFlag f;`
+ * (where ErrorFlag is defined as an enum elsewhere in mojom), then the
+ * generated code for this field will be `Flags<ErrorFlag> f`
*
* Rules:
* - If the type is defined in a libcamera C++ header *and* a (de)serializer is
@@ -43,6 +52,8 @@ module libcamera;
* then the type definition in the core.mojom file should have the
* [skipHeader] attribute only
* - A (de)serializer will be generated for the type
+ * - enums that are defined in a libcamera C++ header also fall in this
+ * category
* - If a type definition has [skipHeader], then the header where the type is
* defined must be included in ipa_interface.h
* - Types that are solely used as array/map members do not require a mojom
@@ -60,7 +71,7 @@ module libcamera;
* - In mojom, reference the type as FrameBuffer.Plane and only as map/array
* member
* - [skipHeader] and [skipSerdes] only work here in core.mojom
- * - If a field in a struct has a FileDescriptor, but is not explicitly
+ * - If a field in a struct has a SharedFD, but is not explicitly
* defined so in mojom, then the field must be marked with the [hasFd]
* attribute
*
@@ -71,7 +82,7 @@ module libcamera;
*/
[skipSerdes, skipHeader] struct ControlInfoMap {};
[skipSerdes, skipHeader] struct ControlList {};
-[skipSerdes, skipHeader] struct FileDescriptor {};
+[skipSerdes, skipHeader] struct SharedFD {};
[skipHeader] struct Point {
int32 x;
@@ -130,6 +141,18 @@ module libcamera;
*/
/**
+ * \var IPACameraSensorInfo::cfaPattern
+ * \brief The arrangement of colour filters on the image sensor
+ *
+ * This takes a value defined by properties::draft::ColorFilterArrangementEnum.
+ * For non-Bayer colour sensors, the cfaPattern will be set to
+ * properties::draft::ColorFilterArrangementEnum::RGB.
+ *
+ * \todo Make this variable optional once mojom supports it, instead of using
+ * RGB for sensors that don't have a CFA.
+ */
+
+/**
* \var IPACameraSensorInfo::activeAreaSize
* \brief The size of the pixel array active area of the sensor
*/
@@ -172,10 +195,17 @@ module libcamera;
*/
/**
- * \var IPACameraSensorInfo::lineLength
- * \brief Total line length in pixels
+ * \var IPACameraSensorInfo::minLineLength
+ * \brief The minimum line length in pixels
*
- * The total line length in pixel clock periods, including blanking.
+ * The minimum allowable line length in pixel clock periods, including blanking.
+ */
+
+/**
+ * \var IPACameraSensorInfo::maxLineLength
+ * \brief The maximum line length in pixels
+ *
+ * The maximum allowable line length in pixel clock periods, including blanking.
*/
/**
@@ -189,7 +219,7 @@ module libcamera;
* To obtain the minimum frame duration:
*
* \verbatim
- frameDuration(s) = minFrameLength(lines) * lineLength(pixels) / pixelRate(pixels per second)
+ frameDuration(s) = minFrameLength(lines) * minLineLength(pixels) / pixelRate(pixels per second)
\endverbatim
*/
@@ -204,20 +234,23 @@ module libcamera;
* To obtain the maximum frame duration:
*
* \verbatim
- frameDuration(s) = maxFrameLength(lines) * lineLength(pixels) / pixelRate(pixels per second)
+ frameDuration(s) = maxFrameLength(lines) * maxLineLength(pixels) / pixelRate(pixels per second)
\endverbatim
*/
struct IPACameraSensorInfo {
string model;
uint32 bitsPerPixel;
+ uint32 cfaPattern;
Size activeAreaSize;
Rectangle analogCrop;
Size outputSize;
uint64 pixelRate;
- uint32 lineLength;
+
+ uint32 minLineLength;
+ uint32 maxLineLength;
uint32 minFrameLength;
uint32 maxFrameLength;
diff --git a/include/libcamera/ipa/ipa_controls.h b/include/libcamera/ipa/ipa_controls.h
index eec34d92..980668c8 100644
--- a/include/libcamera/ipa/ipa_controls.h
+++ b/include/libcamera/ipa/ipa_controls.h
@@ -2,14 +2,16 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * ipa_controls.h - IPA Control handling
+ * IPA Control handling
*/
-#ifndef __LIBCAMERA_IPA_CONTROLS_H__
-#define __LIBCAMERA_IPA_CONTROLS_H__
+
+#pragma once
#include <stdint.h>
#ifdef __cplusplus
+namespace libcamera {
+
extern "C" {
#endif
@@ -44,11 +46,12 @@ struct ipa_control_info_entry {
uint32_t id;
uint32_t type;
uint32_t offset;
- uint32_t padding[1];
+ uint8_t direction;
+ uint8_t padding[3];
};
#ifdef __cplusplus
+} /* namespace libcamera */
+
}
#endif
-
-#endif /* __LIBCAMERA_IPA_CONTROLS_H__ */
diff --git a/include/libcamera/ipa/ipa_interface.h b/include/libcamera/ipa/ipa_interface.h
index 1590584c..dce9637a 100644
--- a/include/libcamera/ipa/ipa_interface.h
+++ b/include/libcamera/ipa/ipa_interface.h
@@ -2,28 +2,16 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * ipa_interface.h - Image Processing Algorithm interface
+ * Image Processing Algorithm interface
*/
-#ifndef __LIBCAMERA_IPA_INTERFACE_H__
-#define __LIBCAMERA_IPA_INTERFACE_H__
-#include <stddef.h>
-#include <stdint.h>
-
-#include <map>
-#include <vector>
-
-#include <libcamera/base/signal.h>
-
-#include <libcamera/controls.h>
-#include <libcamera/framebuffer.h>
-#include <libcamera/geometry.h>
+#pragma once
namespace libcamera {
/*
- * Structs that are defined in core.mojom and have the skipHeader tag must be
- * #included here.
+ * Structs and enums that are defined in core.mojom that have the skipHeader
+ * tag must be #included here.
*/
class IPAInterface
@@ -32,10 +20,8 @@ public:
virtual ~IPAInterface() = default;
};
-} /* namespace libcamera */
-
extern "C" {
libcamera::IPAInterface *ipaCreate();
}
-#endif /* __LIBCAMERA_IPA_INTERFACE_H__ */
+} /* namespace libcamera */
diff --git a/include/libcamera/ipa/ipa_module_info.h b/include/libcamera/ipa/ipa_module_info.h
index 3b1c37d2..3507a6d7 100644
--- a/include/libcamera/ipa/ipa_module_info.h
+++ b/include/libcamera/ipa/ipa_module_info.h
@@ -2,10 +2,10 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * ipa_module_info.h - Image Processing Algorithm module information
+ * Image Processing Algorithm module information
*/
-#ifndef __LIBCAMERA_IPA_MODULE_INFO_H__
-#define __LIBCAMERA_IPA_MODULE_INFO_H__
+
+#pragma once
#include <stdint.h>
@@ -25,5 +25,3 @@ extern const struct IPAModuleInfo ipaModuleInfo;
}
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_IPA_MODULE_INFO_H__ */
diff --git a/include/libcamera/ipa/ipu3.mojom b/include/libcamera/ipa/ipu3.mojom
index d561c224..d9a50b01 100644
--- a/include/libcamera/ipa/ipu3.mojom
+++ b/include/libcamera/ipa/ipu3.mojom
@@ -8,31 +8,10 @@ module ipa.ipu3;
import "include/libcamera/ipa/core.mojom";
-enum IPU3Operations {
- ActionSetSensorControls = 1,
- ActionParamFilled = 2,
- ActionMetadataReady = 3,
- EventProcessControls = 4,
- EventStatReady = 5,
- EventFillParams = 6,
-};
-
-struct IPU3Event {
- IPU3Operations op;
- uint32 frame;
- int64 frameTimestamp;
- uint32 bufferId;
- libcamera.ControlList controls;
-};
-
-struct IPU3Action {
- IPU3Operations op;
- libcamera.ControlList controls;
-};
-
struct IPAConfigInfo {
libcamera.IPACameraSensorInfo sensorInfo;
- map<uint32, libcamera.ControlInfoMap> entityControls;
+ libcamera.ControlInfoMap sensorControls;
+ libcamera.ControlInfoMap lensControls;
libcamera.Size bdsOutputSize;
libcamera.Size iif;
};
@@ -45,14 +24,21 @@ interface IPAIPU3Interface {
start() => (int32 ret);
stop();
- configure(IPAConfigInfo configInfo) => (int32 ret);
+ configure(IPAConfigInfo configInfo)
+ => (int32 ret, libcamera.ControlInfoMap ipaControls);
mapBuffers(array<libcamera.IPABuffer> buffers);
unmapBuffers(array<uint32> ids);
- [async] processEvent(IPU3Event ev);
+ [async] queueRequest(uint32 frame, libcamera.ControlList controls);
+ [async] computeParams(uint32 frame, uint32 bufferId);
+ [async] processStats(uint32 frame, int64 frameTimestamp,
+ uint32 bufferId, libcamera.ControlList sensorControls);
};
interface IPAIPU3EventInterface {
- queueFrameAction(uint32 frame, IPU3Action action);
+ setSensorControls(uint32 frame, libcamera.ControlList sensorControls,
+ libcamera.ControlList lensControls);
+ paramsComputed(uint32 frame);
+ metadataReady(uint32 frame, libcamera.ControlList metadata);
};
diff --git a/include/libcamera/ipa/mali-c55.mojom b/include/libcamera/ipa/mali-c55.mojom
new file mode 100644
index 00000000..5d7eb4ee
--- /dev/null
+++ b/include/libcamera/ipa/mali-c55.mojom
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+module ipa.mali_c55;
+
+import "include/libcamera/ipa/core.mojom";
+
+struct IPAConfigInfo {
+ libcamera.IPACameraSensorInfo sensorInfo;
+ libcamera.ControlInfoMap sensorControls;
+};
+
+interface IPAMaliC55Interface {
+ init(libcamera.IPASettings settings, IPAConfigInfo configInfo)
+ => (int32 ret, libcamera.ControlInfoMap ipaControls);
+ start() => (int32 ret);
+ stop();
+
+ configure(IPAConfigInfo configInfo, uint8 bayerOrder)
+ => (int32 ret, libcamera.ControlInfoMap ipaControls);
+
+ mapBuffers(array<libcamera.IPABuffer> buffers, bool readOnly);
+ unmapBuffers(array<libcamera.IPABuffer> buffers);
+
+ [async] queueRequest(uint32 request, libcamera.ControlList reqControls);
+ [async] fillParams(uint32 request, uint32 bufferId);
+ [async] processStats(uint32 request, uint32 bufferId,
+ libcamera.ControlList sensorControls);
+};
+
+interface IPAMaliC55EventInterface {
+ paramsComputed(uint32 request);
+ statsProcessed(uint32 request, libcamera.ControlList metadata);
+ setSensorControls(libcamera.ControlList sensorControls);
+};
diff --git a/include/libcamera/ipa/meson.build b/include/libcamera/ipa/meson.build
index 81fb69f0..3129f119 100644
--- a/include/libcamera/ipa/meson.build
+++ b/include/libcamera/ipa/meson.build
@@ -9,9 +9,9 @@ libcamera_ipa_headers = files([
])
install_headers(libcamera_ipa_headers,
- subdir: libcamera_ipa_include_dir)
+ subdir : libcamera_ipa_include_dir)
-libcamera_generated_ipa_headers = []
+ipa_headers_install_dir = get_option('includedir') / libcamera_ipa_include_dir
#
# Prepare IPA/IPC generation components
@@ -23,18 +23,19 @@ ipa_mojom_core = custom_target(core_mojom_file.split('.')[0] + '_mojom_module',
output : core_mojom_file + '-module',
command : [
mojom_parser,
- '--output-root', meson.build_root(),
- '--input-root', meson.source_root(),
+ '--output-root', meson.project_build_root(),
+ '--input-root', meson.project_source_root(),
'--mojoms', '@INPUT@'
- ])
+ ],
+ env : py_build_env)
# core_ipa_interface.h
-libcamera_generated_ipa_headers += custom_target('core_ipa_interface_h',
+libcamera_ipa_headers += custom_target('core_ipa_interface_h',
input : ipa_mojom_core,
output : 'core_ipa_interface.h',
depends : mojom_templates,
install : true,
- install_dir : get_option('includedir') / libcamera_ipa_include_dir,
+ install_dir : ipa_headers_install_dir,
command : [
mojom_generator, 'generate',
'-g', 'libcamera',
@@ -42,10 +43,11 @@ libcamera_generated_ipa_headers += custom_target('core_ipa_interface_h',
'--libcamera_generate_core_header',
'--libcamera_output_path=@OUTPUT@',
'./' +'@INPUT@'
- ])
+ ],
+ env : py_build_env)
# core_ipa_serializer.h
-libcamera_generated_ipa_headers += custom_target('core_ipa_serializer_h',
+libcamera_ipa_headers += custom_target('core_ipa_serializer_h',
input : ipa_mojom_core,
output : 'core_ipa_serializer.h',
depends : mojom_templates,
@@ -56,16 +58,18 @@ libcamera_generated_ipa_headers += custom_target('core_ipa_serializer_h',
'--libcamera_generate_core_serializer',
'--libcamera_output_path=@OUTPUT@',
'./' +'@INPUT@'
- ])
-
-ipa_mojom_files = [
- 'ipu3.mojom',
- 'raspberrypi.mojom',
- 'rkisp1.mojom',
- 'vimc.mojom',
-]
-
-ipa_mojoms = []
+ ],
+ env : py_build_env)
+
+# Mapping from pipeline handler name to mojom file
+pipeline_ipa_mojom_mapping = {
+ 'ipu3': 'ipu3.mojom',
+ 'mali-c55': 'mali-c55.mojom',
+ 'rkisp1': 'rkisp1.mojom',
+ 'rpi/vc4': 'raspberrypi.mojom',
+ 'simple': 'soft.mojom',
+ 'vimc': 'vimc.mojom',
+}
#
# Generate headers from templates.
@@ -73,32 +77,42 @@ ipa_mojoms = []
# TODO Define per-pipeline ControlInfoMap with yaml?
-foreach file : ipa_mojom_files
+ipa_mojoms = []
+mojoms_built = []
+foreach pipeline, file : pipeline_ipa_mojom_mapping
name = file.split('.')[0]
- if name not in pipelines
+ # Avoid building duplicate mojom interfaces with the same interface file
+ if name in mojoms_built
+ continue
+ endif
+
+ if pipeline not in pipelines
continue
endif
- # {pipeline}.mojom-module
+ mojoms_built += name
+
+ # {interface}.mojom-module
mojom = custom_target(name + '_mojom_module',
input : file,
output : file + '-module',
depends : ipa_mojom_core,
command : [
mojom_parser,
- '--output-root', meson.build_root(),
- '--input-root', meson.source_root(),
+ '--output-root', meson.project_build_root(),
+ '--input-root', meson.project_source_root(),
'--mojoms', '@INPUT@'
- ])
+ ],
+ env : py_build_env)
- # {pipeline}_ipa_interface.h
+ # {interface}_ipa_interface.h
header = custom_target(name + '_ipa_interface_h',
input : mojom,
output : name + '_ipa_interface.h',
depends : mojom_templates,
install : true,
- install_dir : get_option('includedir') / libcamera_ipa_include_dir,
+ install_dir : ipa_headers_install_dir,
command : [
mojom_generator, 'generate',
'-g', 'libcamera',
@@ -106,9 +120,10 @@ foreach file : ipa_mojom_files
'--libcamera_generate_header',
'--libcamera_output_path=@OUTPUT@',
'./' +'@INPUT@'
- ])
+ ],
+ env : py_build_env)
- # {pipeline}_ipa_serializer.h
+ # {interface}_ipa_serializer.h
serializer = custom_target(name + '_ipa_serializer_h',
input : mojom,
output : name + '_ipa_serializer.h',
@@ -120,9 +135,10 @@ foreach file : ipa_mojom_files
'--libcamera_generate_serializer',
'--libcamera_output_path=@OUTPUT@',
'./' +'@INPUT@'
- ])
+ ],
+ env : py_build_env)
- # {pipeline}_ipa_proxy.h
+ # {interface}_ipa_proxy.h
proxy_header = custom_target(name + '_proxy_h',
input : mojom,
output : name + '_ipa_proxy.h',
@@ -134,16 +150,23 @@ foreach file : ipa_mojom_files
'--libcamera_generate_proxy_h',
'--libcamera_output_path=@OUTPUT@',
'./' +'@INPUT@'
- ])
+ ],
+ env : py_build_env)
ipa_mojoms += {
'name': name,
'mojom': mojom,
}
- libcamera_generated_ipa_headers += [header, serializer, proxy_header]
+ libcamera_ipa_headers += [header, serializer, proxy_header]
endforeach
+ipa_mojom_files = []
+foreach pipeline, file : pipeline_ipa_mojom_mapping
+ if file not in ipa_mojom_files
+ ipa_mojom_files += file
+ endif
+endforeach
ipa_mojom_files = files(ipa_mojom_files)
# Pass this to the documentation generator in src/libcamera/ipa
diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h
deleted file mode 100644
index 521eaecd..00000000
--- a/include/libcamera/ipa/raspberrypi.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1-or-later */
-/*
- * Copyright (C) 2019-2020, Raspberry Pi Ltd.
- *
- * raspberrypi.h - Image Processing Algorithm interface for Raspberry Pi
- */
-#ifndef __LIBCAMERA_IPA_INTERFACE_RASPBERRYPI_H__
-#define __LIBCAMERA_IPA_INTERFACE_RASPBERRYPI_H__
-
-#include <stdint.h>
-
-#include <libcamera/control_ids.h>
-#include <libcamera/controls.h>
-
-#ifndef __DOXYGEN__
-
-namespace libcamera {
-
-namespace RPi {
-
-/*
- * List of controls handled by the Raspberry Pi IPA
- *
- * \todo This list will need to be built dynamically from the control
- * algorithms loaded by the json file, once this is supported. At that
- * point applications should check first whether a control is supported,
- * and the pipeline handler may be reverted so that it aborts when an
- * unsupported control is encountered.
- */
-static const ControlInfoMap Controls({
- { &controls::AeEnable, ControlInfo(false, true) },
- { &controls::ExposureTime, ControlInfo(0, 999999) },
- { &controls::AnalogueGain, ControlInfo(1.0f, 32.0f) },
- { &controls::AeMeteringMode, ControlInfo(controls::AeMeteringModeValues) },
- { &controls::AeConstraintMode, ControlInfo(controls::AeConstraintModeValues) },
- { &controls::AeExposureMode, ControlInfo(controls::AeExposureModeValues) },
- { &controls::ExposureValue, ControlInfo(0.0f, 16.0f) },
- { &controls::AwbEnable, ControlInfo(false, true) },
- { &controls::ColourGains, ControlInfo(0.0f, 32.0f) },
- { &controls::AwbMode, ControlInfo(controls::AwbModeValues) },
- { &controls::Brightness, ControlInfo(-1.0f, 1.0f) },
- { &controls::Contrast, ControlInfo(0.0f, 32.0f) },
- { &controls::Saturation, ControlInfo(0.0f, 32.0f) },
- { &controls::Sharpness, ControlInfo(0.0f, 16.0f, 1.0f) },
- { &controls::ColourCorrectionMatrix, ControlInfo(-16.0f, 16.0f) },
- { &controls::ScalerCrop, ControlInfo(Rectangle{}, Rectangle(65535, 65535, 65535, 65535), Rectangle{}) },
- { &controls::FrameDurationLimits, ControlInfo(INT64_C(1000), INT64_C(1000000000)) },
- { &controls::draft::NoiseReductionMode, ControlInfo(controls::draft::NoiseReductionModeValues) }
- }, controls::controls);
-
-} /* namespace RPi */
-
-} /* namespace libcamera */
-
-#endif /* __DOXYGEN__ */
-
-#endif /* __LIBCAMERA_IPA_INTERFACE_RASPBERRYPI_H__ */
diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom
index e453d46c..e30c70bd 100644
--- a/include/libcamera/ipa/raspberrypi.mojom
+++ b/include/libcamera/ipa/raspberrypi.mojom
@@ -8,70 +8,135 @@ module ipa.RPi;
import "include/libcamera/ipa/core.mojom";
-enum BufferMask {
- MaskID = 0x00ffff,
- MaskStats = 0x010000,
- MaskEmbeddedData = 0x020000,
- MaskBayerData = 0x040000,
- MaskExternalBuffer = 0x100000,
-};
-
-/* Size of the LS grid allocation. */
+/* Size of the LS grid allocation on VC4. */
const uint32 MaxLsGridSize = 0x8000;
struct SensorConfig {
- uint32 gainDelay;
- uint32 exposureDelay;
- uint32 vblankDelay;
uint32 sensorMetadata;
};
-struct ISPConfig {
- uint32 embeddedBufferId;
- uint32 bayerBufferId;
- bool embeddedBufferPresent;
- libcamera.ControlList controls;
+struct InitParams {
+ bool lensPresent;
+ libcamera.IPACameraSensorInfo sensorInfo;
+ /* PISP specific */
+ libcamera.SharedFD fe;
+ libcamera.SharedFD be;
+};
+
+struct InitResult {
+ SensorConfig sensorConfig;
+ libcamera.ControlInfoMap controlInfo;
};
-struct IPAConfig {
+struct BufferIds {
+ uint32 bayer;
+ uint32 embedded;
+ uint32 stats;
+};
+
+struct ConfigParams {
uint32 transform;
- libcamera.FileDescriptor lsTableHandle;
+ libcamera.ControlInfoMap sensorControls;
+ libcamera.ControlInfoMap ispControls;
+ libcamera.ControlInfoMap lensControls;
+ /* VC4 specific */
+ libcamera.SharedFD lsTableHandle;
+};
+
+struct ConfigResult {
+ float modeSensitivity;
+ libcamera.ControlInfoMap controlInfo;
+ libcamera.ControlList sensorControls;
+ libcamera.ControlList lensControls;
};
-struct StartConfig {
+struct StartResult {
libcamera.ControlList controls;
int32 dropFrameCount;
};
+struct PrepareParams {
+ BufferIds buffers;
+ libcamera.ControlList sensorControls;
+ libcamera.ControlList requestControls;
+ uint32 ipaContext;
+ uint32 delayContext;
+};
+
+struct ProcessParams {
+ BufferIds buffers;
+ uint32 ipaContext;
+};
+
interface IPARPiInterface {
- init(libcamera.IPASettings settings)
- => (int32 ret, SensorConfig sensorConfig);
- start(libcamera.ControlList controls) => (StartConfig startConfig);
+ /**
+ * \fn init()
+ * \brief Initialise the IPA
+ * \param[in] settings Camera sensor information and configuration file
+ * \param[in] params Platform specific initialisation parameters
+ * \param[out] ret 0 on success or a negative error code otherwise
+ * \param[out] result Static sensor configuration and controls available
+ *
+ * This function initialises the IPA for a particular sensor from the
+ * pipeline handler.
+ *
+ * The \a settings conveys information about the camera sensor and
+ * configuration file requested by the pipeline handler.
+ *
+ * The \a result parameter returns the sensor delay for the given camera
+ * as well as a ControlInfoMap of available controls that can be handled
+ * by the IPA.
+ */
+ init(libcamera.IPASettings settings, InitParams params)
+ => (int32 ret, InitResult result);
+
+ /**
+ * \fn start()
+ * \brief Start the IPA
+ * \param[in] controls List of control to handle
+ * \param[out] result Controls to apply and number of dropped frames
+ *
+ * This function sets the IPA to a started state.
+ *
+ * The \a controls provide a list of controls to handle immediately. The
+ * actual controls to apply on the sensor and ISP in the pipeline
+ * handler are returned in \a result.
+ *
+ * The number of convergence frames to be dropped is also returned in
+ * \a result.
+ */
+ start(libcamera.ControlList controls) => (StartResult result);
+
+ /**
+ * \fn start()
+ * \brief Stop the IPA
+ *
+ * This function sets the IPA to a stopped state.
+ */
stop();
/**
* \fn configure()
- * \brief Configure the IPA stream and sensor settings
- * \param[in] sensorInfo Camera sensor information
- * \param[in] streamConfig Configuration of all active streams
- * \param[in] entityControls Controls provided by the pipeline entities
- * \param[in] ipaConfig Pipeline-handler-specific configuration data
- * \param[out] controls Controls to apply by the pipeline entity
+ * \brief Configure the IPA
+ * \param[in] sensorInfo Sensor mode configuration
+ * \param[in] params Platform configuration parameters
+ * \param[out] ret 0 on success or a negative error code otherwise
+ * \param[out] result Results of the configuration operation
*
- * This function shall be called when the camera is configured to inform
- * the IPA of the camera's streams and the sensor settings.
+ * This function configures the IPA for a particular camera
+ * configuration
*
- * The \a sensorInfo conveys information about the camera sensor settings that
- * the pipeline handler has selected for the configuration.
+ * The \a params parameter provides a list of available controls for the
+ * ISP, sensor and lens devices, and the user requested transform
+ * operation. It can also provide platform specific configuration
+ * parameters, e.g. the lens shading table memory handle for VC4.
*
- * The \a ipaConfig and \a controls parameters carry data passed by the
- * pipeline handler to the IPA and back.
+ * The \a result parameter returns the available controls for the given
+ * camera mode, a list of controls to apply to the sensor device, and
+ * the requested mode's sensitivity characteristics.
*/
- configure(libcamera.IPACameraSensorInfo sensorInfo,
- map<uint32, libcamera.IPAStream> streamConfig,
- map<uint32, libcamera.ControlInfoMap> entityControls,
- IPAConfig ipaConfig)
- => (int32 ret, libcamera.ControlList controls);
+ configure(libcamera.IPACameraSensorInfo sensorInfo, ConfigParams params)
+ => (int32 ret, ConfigResult result);
/**
* \fn mapBuffers()
@@ -94,7 +159,7 @@ interface IPARPiInterface {
* depending on the IPA protocol. Regardless of the protocol, all
* buffers mapped at a given time shall have unique numerical IDs.
*
- * The numerical IDs have no meaning defined by the IPA interface, and
+ * The numerical IDs have no meaning defined by the IPA interface, and
* should be treated as opaque handles by IPAs, with the only exception
* that ID zero is invalid.
*
@@ -114,15 +179,119 @@ interface IPARPiInterface {
*/
unmapBuffers(array<uint32> ids);
- [async] signalStatReady(uint32 bufferId);
- [async] signalQueueRequest(libcamera.ControlList controls);
- [async] signalIspPrepare(ISPConfig data);
+ /**
+ * \fn prepareIsp()
+ * \brief Prepare the ISP configuration for a frame
+ * \param[in] params Parameter set for the frame to process
+ *
+ * This function call into all the algorithms in preparation for the
+ * frame to be processed by the ISP.
+ *
+ * The \a params parameter lists the buffer IDs for the Bayer and
+ * embedded data buffers, a ControlList of sensor frame params, and
+ * a ControlList of request controls for the current frame.
+ *
+ * Additionally, \a params also contains the IPA context (ipaContext) to
+ * use as an index location to store control algorithm results, and a
+ * historical IPA context (delayContext) that was active when the sensor
+ * settings were requested by the IPA.
+ */
+ [async] prepareIsp(PrepareParams params);
+
+ /**
+ * \fn processStats()
+ * \brief Process the statistics provided by the ISP
+ * \param[in] params Parameter set for the statistics to process
+ *
+ * This function call into all the algorithms to provide the statistics
+ * generated by the ISP for the processed frame.
+ *
+ * The \a params parameter lists the buffer ID for the statistics buffer
+ * and an IPA context (ipaContext) to use as an index location to store
+ * algorithm results.
+ */
+ [async] processStats(ProcessParams params);
};
interface IPARPiEventInterface {
- statsMetadataComplete(uint32 bufferId, libcamera.ControlList controls);
- runIsp(uint32 bufferId);
- embeddedComplete(uint32 bufferId);
+ /**
+ * \fn prepareIspComplete()
+ * \brief Signal completion of \a prepareIsp
+ * \param[in] buffers Bayer and embedded buffers actioned.
+ * \param[in] stitchSwapBuffers Whether the stitch block buffers need to be swapped.
+ *
+ * This asynchronous event is signalled to the pipeline handler once
+ * the \a prepareIsp signal has completed, and the ISP is ready to start
+ * processing the frame. The embedded data buffer may be recycled after
+ * this event.
+ */
+ prepareIspComplete(BufferIds buffers, bool stitchSwapBuffers);
+
+ /**
+ * \fn processStatsComplete()
+ * \brief Signal completion of \a processStats
+ * \param[in] buffers Statistics buffers actioned.
+ *
+ * This asynchronous event is signalled to the pipeline handler once
+ * the \a processStats signal has completed. The statistics buffer may
+ * be recycled after this event.
+ */
+ processStatsComplete(BufferIds buffers);
+
+ /**
+ * \fn metadataReady()
+ * \brief Signal request metadata is to be merged
+ * \param[in] metadata Control list of metadata to be merged
+ *
+ * This asynchronous event is signalled to the pipeline handler once
+ * all the frame metadata has been gathered. The pipeline handler will
+ * copy or merge this metadata into the \a Request returned back to the
+ * application.
+ */
+ metadataReady(libcamera.ControlList metadata);
+
+ /**
+ * \fn setIspControls()
+ * \brief Signal ISP controls to be applied.
+ * \param[in] controls List of controls to be applied.
+ *
+ * This asynchronous event is signalled to the pipeline handler during
+ * the \a prepareISP signal after all algorithms have been run and the
+ * IPA requires ISP controls to be applied for the frame.
+ */
setIspControls(libcamera.ControlList controls);
- setDelayedControls(libcamera.ControlList controls);
+
+ /**
+ * \fn setDelayedControls()
+ * \brief Signal Sensor controls to be applied.
+ * \param[in] controls List of controls to be applied.
+ * \param[in] delayContext IPA context index used for this request
+ *
+ * This asynchronous event is signalled to the pipeline handler when
+ * the IPA requires sensor specific controls (e.g. exposure time, gain,
+ * blanking) to be applied.
+ */
+ setDelayedControls(libcamera.ControlList controls, uint32 delayContext);
+
+ /**
+ * \fn setLensControls()
+ * \brief Signal lens controls to be applied.
+ * \param[in] controls List of controls to be applied.
+ *
+ * This asynchronous event is signalled to the pipeline handler when
+ * the IPA requires a lens movement control to be applied.
+ */
+ setLensControls(libcamera.ControlList controls);
+
+ /**
+ * \fn setCameraTimeout()
+ * \brief Request a watchdog timeout value to use
+ * \param[in] maxFrameLengthMs Timeout value in ms
+ *
+ * This asynchronous event is used by the IPA to inform the pipeline
+ * handler of an acceptable watchdog timer value to use for the sensor
+ * stream. This value is based on the history of frame lengths requested
+ * by the IPA.
+ */
+ setCameraTimeout(uint32 maxFrameLengthMs);
};
diff --git a/include/libcamera/ipa/rkisp1.mojom b/include/libcamera/ipa/rkisp1.mojom
index cae757ea..043ad27e 100644
--- a/include/libcamera/ipa/rkisp1.mojom
+++ b/include/libcamera/ipa/rkisp1.mojom
@@ -8,42 +8,36 @@ module ipa.rkisp1;
import "include/libcamera/ipa/core.mojom";
-enum RkISP1Operations {
- ActionV4L2Set = 1,
- ActionParamFilled = 2,
- ActionMetadata = 3,
- EventSignalStatBuffer = 4,
- EventQueueRequest = 5,
-};
-
-struct RkISP1Event {
- RkISP1Operations op;
- uint32 frame;
- uint32 bufferId;
- libcamera.ControlList controls;
-};
-
-struct RkISP1Action {
- RkISP1Operations op;
- libcamera.ControlList controls;
+struct IPAConfigInfo {
+ libcamera.IPACameraSensorInfo sensorInfo;
+ libcamera.ControlInfoMap sensorControls;
+ uint32 paramFormat;
};
interface IPARkISP1Interface {
- init(uint32 hwRevision) => (int32 ret);
+ init(libcamera.IPASettings settings,
+ uint32 hwRevision,
+ libcamera.IPACameraSensorInfo sensorInfo,
+ libcamera.ControlInfoMap sensorControls)
+ => (int32 ret, libcamera.ControlInfoMap ipaControls);
start() => (int32 ret);
stop();
- configure(libcamera.IPACameraSensorInfo sensorInfo,
- map<uint32, libcamera.IPAStream> streamConfig,
- map<uint32, libcamera.ControlInfoMap> entityControls)
- => (int32 ret);
+ configure(IPAConfigInfo configInfo,
+ map<uint32, libcamera.IPAStream> streamConfig)
+ => (int32 ret, libcamera.ControlInfoMap ipaControls);
mapBuffers(array<libcamera.IPABuffer> buffers);
unmapBuffers(array<uint32> ids);
- [async] processEvent(RkISP1Event ev);
+ [async] queueRequest(uint32 frame, libcamera.ControlList reqControls);
+ [async] computeParams(uint32 frame, uint32 bufferId);
+ [async] processStats(uint32 frame, uint32 bufferId,
+ libcamera.ControlList sensorControls);
};
interface IPARkISP1EventInterface {
- queueFrameAction(uint32 frame, RkISP1Action action);
+ paramsComputed(uint32 frame, uint32 bytesused);
+ setSensorControls(uint32 frame, libcamera.ControlList sensorControls);
+ metadataReady(uint32 frame, libcamera.ControlList metadata);
};
diff --git a/include/libcamera/ipa/soft.mojom b/include/libcamera/ipa/soft.mojom
new file mode 100644
index 00000000..d52e6f1a
--- /dev/null
+++ b/include/libcamera/ipa/soft.mojom
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+/*
+ * \todo Document the interface and remove the related EXCLUDE_PATTERNS entry.
+ */
+
+module ipa.soft;
+
+import "include/libcamera/ipa/core.mojom";
+
+struct IPAConfigInfo {
+ libcamera.ControlInfoMap sensorControls;
+};
+
+interface IPASoftInterface {
+ init(libcamera.IPASettings settings,
+ libcamera.SharedFD fdStats,
+ libcamera.SharedFD fdParams,
+ libcamera.ControlInfoMap sensorCtrlInfoMap)
+ => (int32 ret, libcamera.ControlInfoMap ipaControls);
+ start() => (int32 ret);
+ stop();
+ configure(IPAConfigInfo configInfo)
+ => (int32 ret);
+
+ [async] queueRequest(uint32 frame, libcamera.ControlList sensorControls);
+ [async] computeParams(uint32 frame);
+ [async] processStats(uint32 frame,
+ uint32 bufferId,
+ libcamera.ControlList sensorControls);
+};
+
+interface IPASoftEventInterface {
+ setSensorControls(libcamera.ControlList sensorControls);
+ setIspParams();
+};
diff --git a/include/libcamera/ipa/vimc.mojom b/include/libcamera/ipa/vimc.mojom
index e3b14e38..c5c5fe83 100644
--- a/include/libcamera/ipa/vimc.mojom
+++ b/include/libcamera/ipa/vimc.mojom
@@ -17,8 +17,18 @@ enum IPAOperationCode {
IPAOperationStop,
};
+[scopedEnum] enum TestFlag {
+ Flag1 = 0x1,
+ Flag2 = 0x2,
+ Flag3 = 0x4,
+ Flag4 = 0x8,
+};
+
interface IPAVimcInterface {
- init(libcamera.IPASettings settings) => (int32 ret);
+ init(libcamera.IPASettings settings,
+ IPAOperationCode code,
+ [flags] TestFlag inFlags)
+ => (int32 ret, [flags] TestFlag outFlags);
configure(libcamera.IPACameraSensorInfo sensorInfo,
map<uint32, libcamera.IPAStream> streamConfig,
@@ -30,16 +40,16 @@ interface IPAVimcInterface {
mapBuffers(array<libcamera.IPABuffer> buffers);
unmapBuffers(array<uint32> ids);
+ [async] queueRequest(uint32 frame, libcamera.ControlList controls);
/*
* The vimc driver doesn't use parameters buffers. To maximize coverage
* of unit tests that rely on the VIMC pipeline handler, we still define
* interface functions that mimick how other pipeline handlers typically
* handle parameters at runtime.
*/
- [async] fillParams(uint32 frame, uint32 bufferId);
- [async] processControls(uint32 frame, libcamera.ControlList controls);
+ [async] computeParams(uint32 frame, uint32 bufferId);
};
interface IPAVimcEventInterface {
- paramsFilled(uint32 bufferId);
+ paramsComputed(uint32 bufferId, [flags] TestFlag flags);
};
diff --git a/include/libcamera/logging.h b/include/libcamera/logging.h
index 2b6dd3f4..e1c6341c 100644
--- a/include/libcamera/logging.h
+++ b/include/libcamera/logging.h
@@ -2,10 +2,12 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * logging.h - Logging infrastructure
+ * Logging infrastructure
*/
-#ifndef __LIBCAMERA_LOGGING_H__
-#define __LIBCAMERA_LOGGING_H__
+
+#pragma once
+
+#include <ostream>
namespace libcamera {
@@ -16,11 +18,9 @@ enum LoggingTarget {
LoggingTargetStream,
};
-int logSetFile(const char *path);
-int logSetStream(std::ostream *stream);
+int logSetFile(const char *path, bool color = false);
+int logSetStream(std::ostream *stream, bool color = false);
int logSetTarget(LoggingTarget target);
void logSetLevel(const char *category, const char *level);
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_LOGGING_H__ */
diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build
index 5b25ef84..fd69a517 100644
--- a/include/libcamera/meson.build
+++ b/include/libcamera/meson.build
@@ -1,50 +1,97 @@
# SPDX-License-Identifier: CC0-1.0
+libcamera_include_dir = 'libcamera' / 'libcamera'
+
libcamera_public_headers = files([
'camera.h',
'camera_manager.h',
- 'compiler.h',
+ 'color_space.h',
'controls.h',
- 'file_descriptor.h',
+ 'fence.h',
'framebuffer.h',
'framebuffer_allocator.h',
'geometry.h',
'logging.h',
+ 'orientation.h',
'pixel_format.h',
'request.h',
'stream.h',
'transform.h',
])
-include_dir = libcamera_include_dir / 'libcamera'
-
subdir('base')
subdir('internal')
subdir('ipa')
install_headers(libcamera_public_headers,
- subdir : include_dir)
+ subdir : libcamera_include_dir)
#
# Generate headers from templates.
#
-# control_ids.h and property_ids.h
-control_source_files = [
- 'control_ids',
- 'property_ids',
-]
+libcamera_headers_install_dir = get_option('includedir') / libcamera_include_dir
+
+controls_map = {
+ 'controls': {
+ 'core': 'control_ids_core.yaml',
+ 'debug': 'control_ids_debug.yaml',
+ 'draft': 'control_ids_draft.yaml',
+ 'rpi/vc4': 'control_ids_rpi.yaml',
+ },
+
+ 'properties': {
+ 'draft': 'property_ids_draft.yaml',
+ 'core': 'property_ids_core.yaml',
+ }
+}
control_headers = []
+controls_files = []
+controls_files_names = []
+properties_files = []
+properties_files_names = []
+
+foreach mode, entry : controls_map
+ files_list = []
+ input_files = []
+ foreach vendor, header : entry
+ if vendor not in ['core', 'debug', 'draft']
+ if vendor not in pipelines
+ continue
+ endif
+ endif
+
+ if header in files_list
+ continue
+ endif
-foreach header : control_source_files
- input_files = files('../../src/libcamera/' + header +'.yaml', header + '.h.in')
+ files_list += header
+ input_files += files('../../src/libcamera/' + header)
+ endforeach
+
+ outfile = ''
+ if mode == 'controls'
+ outfile = 'control_ids.h'
+ controls_files += input_files
+ controls_files_names += files_list
+ else
+ outfile = 'property_ids.h'
+ properties_files += input_files
+ properties_files_names += files_list
+ endif
+
+ template_file = files('control_ids.h.in')
+ ranges_file = files('../../src/libcamera/control_ranges.yaml')
control_headers += custom_target(header + '_h',
input : input_files,
- output : header + '.h',
- command : [gen_controls, '-o', '@OUTPUT@', '@INPUT@'],
+ output : outfile,
+ command : [gen_controls, '-o', '@OUTPUT@',
+ '--mode', mode, '-t', template_file,
+ '-r', ranges_file, '@INPUT@'],
+ env : py_build_env,
install : true,
- install_dir : get_option('includedir') / include_dir)
+ install_dir : libcamera_headers_install_dir)
endforeach
libcamera_public_headers += control_headers
@@ -59,19 +106,9 @@ formats_h = custom_target('formats_h',
output : 'formats.h',
command : [gen_formats, '-o', '@OUTPUT@', '@INPUT@'],
install : true,
- install_dir : get_option('includedir') / include_dir)
+ install_dir : libcamera_headers_install_dir)
libcamera_public_headers += formats_h
-# libcamera.h
-libcamera_h = custom_target('gen-header',
- input : 'meson.build',
- output : 'libcamera.h',
- command : [gen_header, meson.current_source_dir(), '@OUTPUT@'],
- install : true,
- install_dir : get_option('includedir') / include_dir)
-
-libcamera_public_headers += libcamera_h
-
# version.h
version = libcamera_version.split('.')
libcamera_version_config = configuration_data()
@@ -79,7 +116,18 @@ libcamera_version_config.set('LIBCAMERA_VERSION_MAJOR', version[0])
libcamera_version_config.set('LIBCAMERA_VERSION_MINOR', version[1])
libcamera_version_config.set('LIBCAMERA_VERSION_PATCH', version[2])
-configure_file(input : 'version.h.in',
- output : 'version.h',
- configuration : libcamera_version_config,
- install_dir : get_option('includedir') / include_dir)
+version_h = configure_file(input : 'version.h.in',
+ output : 'version.h',
+ configuration : libcamera_version_config,
+ install_dir : libcamera_headers_install_dir)
+libcamera_public_headers += version_h
+
+# libcamera.h
+libcamera_h = custom_target('gen-header',
+ input : 'meson.build',
+ output : 'libcamera.h',
+ command : [gen_header, '@OUTPUT@', libcamera_public_headers],
+ install : true,
+ install_dir : libcamera_headers_install_dir)
+
+libcamera_public_headers += libcamera_h
diff --git a/include/libcamera/orientation.h b/include/libcamera/orientation.h
new file mode 100644
index 00000000..a3b40e63
--- /dev/null
+++ b/include/libcamera/orientation.h
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2023, Ideas On Board Oy
+ *
+ * Image orientation
+ */
+
+#pragma once
+
+#include <iostream>
+
+namespace libcamera {
+
+enum class Orientation {
+ /* EXIF tag 274 starts from '1' */
+ Rotate0 = 1,
+ Rotate0Mirror,
+ Rotate180,
+ Rotate180Mirror,
+ Rotate90Mirror,
+ Rotate270,
+ Rotate270Mirror,
+ Rotate90,
+};
+
+Orientation orientationFromRotation(int angle, bool *success = nullptr);
+
+std::ostream &operator<<(std::ostream &out, const Orientation &orientation);
+
+} /* namespace libcamera */
diff --git a/include/libcamera/pixel_format.h b/include/libcamera/pixel_format.h
index c4ae0883..1b4d8c7c 100644
--- a/include/libcamera/pixel_format.h
+++ b/include/libcamera/pixel_format.h
@@ -2,12 +2,12 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * pixel_format.h - libcamera Pixel Format
+ * libcamera Pixel Format
*/
-#ifndef __LIBCAMERA_PIXEL_FORMAT_H__
-#define __LIBCAMERA_PIXEL_FORMAT_H__
-#include <set>
+#pragma once
+
+#include <ostream>
#include <stdint.h>
#include <string>
@@ -45,6 +45,6 @@ private:
uint64_t modifier_;
};
-} /* namespace libcamera */
+std::ostream &operator<<(std::ostream &out, const PixelFormat &f);
-#endif /* __LIBCAMERA_PIXEL_FORMAT_H__ */
+} /* namespace libcamera */
diff --git a/include/libcamera/property_ids.h.in b/include/libcamera/property_ids.h.in
deleted file mode 100644
index 52646c1f..00000000
--- a/include/libcamera/property_ids.h.in
+++ /dev/null
@@ -1,39 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1-or-later */
-/*
- * Copyright (C) 2019, Google Inc.
- *
- * property_ids.h - Property ID list
- *
- * This file is auto-generated. Do not edit.
- */
-
-#ifndef __LIBCAMERA_PROPERTY_IDS_H__
-#define __LIBCAMERA_PROPERTY_IDS_H__
-
-#include <stdint.h>
-
-#include <libcamera/controls.h>
-
-namespace libcamera {
-
-namespace properties {
-
-enum {
-${ids}
-};
-
-${controls}
-
-namespace draft {
-
-${draft_controls}
-
-} /* namespace draft */
-
-extern const ControlIdMap properties;
-
-} /* namespace properties */
-
-} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_PROPERTY_IDS_H__ */
diff --git a/include/libcamera/request.h b/include/libcamera/request.h
index 2d361c9d..e214a9d1 100644
--- a/include/libcamera/request.h
+++ b/include/libcamera/request.h
@@ -2,21 +2,22 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * request.h - Capture request handling
+ * Capture request handling
*/
-#ifndef __LIBCAMERA_REQUEST_H__
-#define __LIBCAMERA_REQUEST_H__
+
+#pragma once
#include <map>
#include <memory>
+#include <ostream>
#include <stdint.h>
#include <string>
-#include <unordered_set>
#include <libcamera/base/class.h>
#include <libcamera/base/signal.h>
#include <libcamera/controls.h>
+#include <libcamera/fence.h>
namespace libcamera {
@@ -25,8 +26,10 @@ class CameraControlValidator;
class FrameBuffer;
class Stream;
-class Request
+class Request : public Extensible
{
+ LIBCAMERA_DECLARE_PRIVATE()
+
public:
enum Status {
RequestPending,
@@ -49,40 +52,29 @@ public:
ControlList &controls() { return *controls_; }
ControlList &metadata() { return *metadata_; }
const BufferMap &buffers() const { return bufferMap_; }
- int addBuffer(const Stream *stream, FrameBuffer *buffer);
+ int addBuffer(const Stream *stream, FrameBuffer *buffer,
+ std::unique_ptr<Fence> fence = nullptr);
FrameBuffer *findBuffer(const Stream *stream) const;
- uint32_t sequence() const { return sequence_; }
+ uint32_t sequence() const;
uint64_t cookie() const { return cookie_; }
Status status() const { return status_; }
- bool hasPendingBuffers() const { return !pending_.empty(); }
+ bool hasPendingBuffers() const;
std::string toString() const;
private:
LIBCAMERA_DISABLE_COPY(Request)
- friend class PipelineHandler;
-
- void complete();
- void cancel();
-
- bool completeBuffer(FrameBuffer *buffer);
-
- Camera *camera_;
- CameraControlValidator *validator_;
ControlList *controls_;
ControlList *metadata_;
BufferMap bufferMap_;
- std::unordered_set<FrameBuffer *> pending_;
- uint32_t sequence_;
const uint64_t cookie_;
Status status_;
- bool cancelled_;
};
-} /* namespace libcamera */
+std::ostream &operator<<(std::ostream &out, const Request &r);
-#endif /* __LIBCAMERA_REQUEST_H__ */
+} /* namespace libcamera */
diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h
index 0c55e716..b5e8f0a9 100644
--- a/include/libcamera/stream.h
+++ b/include/libcamera/stream.h
@@ -2,16 +2,17 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * stream.h - Video stream for a Camera
+ * Video stream for a Camera
*/
-#ifndef __LIBCAMERA_STREAM_H__
-#define __LIBCAMERA_STREAM_H__
+
+#pragma once
#include <map>
-#include <memory>
+#include <ostream>
#include <string>
#include <vector>
+#include <libcamera/color_space.h>
#include <libcamera/framebuffer.h>
#include <libcamera/geometry.h>
#include <libcamera/pixel_format.h>
@@ -47,6 +48,8 @@ struct StreamConfiguration {
unsigned int bufferCount;
+ std::optional<ColorSpace> colorSpace;
+
Stream *stream() const { return stream_; }
void setStream(Stream *stream) { stream_ = stream; }
const StreamFormats &formats() const { return formats_; }
@@ -58,14 +61,16 @@ private:
StreamFormats formats_;
};
-enum StreamRole {
+std::ostream &operator<<(std::ostream &out, const StreamConfiguration &cfg);
+
+enum class StreamRole {
Raw,
StillCapture,
VideoRecording,
Viewfinder,
};
-using StreamRoles = std::vector<StreamRole>;
+std::ostream &operator<<(std::ostream &out, StreamRole role);
class Stream
{
@@ -81,5 +86,3 @@ protected:
};
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_STREAM_H__ */
diff --git a/include/libcamera/transform.h b/include/libcamera/transform.h
index 71b43da7..4517412a 100644
--- a/include/libcamera/transform.h
+++ b/include/libcamera/transform.h
@@ -1,17 +1,16 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
- * Copyright (C) 2020, Raspberry Pi (Trading) Limited
+ * Copyright (C) 2020, Raspberry Pi Ltd
*
- * transform.h - 2D plane transforms
+ * 2D plane transforms
*/
-#ifndef __LIBCAMERA_TRANSFORM_H__
-#define __LIBCAMERA_TRANSFORM_H__
-
-#include <string>
+#pragma once
namespace libcamera {
+enum class Orientation;
+
enum class Transform : int {
Identity = 0,
Rot0 = Identity,
@@ -71,8 +70,9 @@ constexpr Transform operator~(Transform t)
Transform transformFromRotation(int angle, bool *success = nullptr);
+Transform operator/(const Orientation &o1, const Orientation &o2);
+Orientation operator*(const Orientation &o, const Transform &t);
+
const char *transformToString(Transform t);
} /* namespace libcamera */
-
-#endif /* __LIBCAMERA_TRANSFORM_H__ */
diff --git a/include/libcamera/version.h.in b/include/libcamera/version.h.in
index 5e9a3091..50bf1001 100644
--- a/include/libcamera/version.h.in
+++ b/include/libcamera/version.h.in
@@ -2,15 +2,13 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * version.h - Library version information
+ * Library version information
*
* This file is auto-generated. Do not edit.
*/
-#ifndef __LIBCAMERA_VERSION_H__
-#define __LIBCAMERA_VERSION_H__
+
+#pragma once
#define LIBCAMERA_VERSION_MAJOR @LIBCAMERA_VERSION_MAJOR@
#define LIBCAMERA_VERSION_MINOR @LIBCAMERA_VERSION_MINOR@
#define LIBCAMERA_VERSION_PATCH @LIBCAMERA_VERSION_PATCH@
-
-#endif /* __LIBCAMERA_VERSION_H__ */
diff --git a/include/linux/README b/include/linux/README
index 17df9f7b..f9f68641 100644
--- a/include/linux/README
+++ b/include/linux/README
@@ -1,4 +1,4 @@
# SPDX-License-Identifier: CC0-1.0
-Files in this directory are imported from v5.12-rc1 of the Linux kernel. Do not
+Files in this directory are imported from v6.13-rc1-68-gf9bbbd9a696d of the Linux kernel. Do not
modify them manually.
diff --git a/include/linux/bcm2835-isp.h b/include/linux/bcm2835-isp.h
index 94c3af94..5f0f78e3 100644
--- a/include/linux/bcm2835-isp.h
+++ b/include/linux/bcm2835-isp.h
@@ -4,7 +4,7 @@
*
* BCM2835 ISP driver - user space header file.
*
- * Copyright © 2019-2020 Raspberry Pi (Trading) Ltd.
+ * Copyright © 2019-2020 Raspberry Pi Ltd
*
* Author: Naushir Patuck (naush@raspberrypi.com)
*
diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
index 7f30393b..5a6fda66 100644
--- a/include/linux/dma-buf.h
+++ b/include/linux/dma-buf.h
@@ -22,8 +22,56 @@
#include <linux/types.h>
-/* begin/end dma-buf functions used for userspace mmap. */
+/**
+ * struct dma_buf_sync - Synchronize with CPU access.
+ *
+ * When a DMA buffer is accessed from the CPU via mmap, it is not always
+ * possible to guarantee coherency between the CPU-visible map and underlying
+ * memory. To manage coherency, DMA_BUF_IOCTL_SYNC must be used to bracket
+ * any CPU access to give the kernel the chance to shuffle memory around if
+ * needed.
+ *
+ * Prior to accessing the map, the client must call DMA_BUF_IOCTL_SYNC
+ * with DMA_BUF_SYNC_START and the appropriate read/write flags. Once the
+ * access is complete, the client should call DMA_BUF_IOCTL_SYNC with
+ * DMA_BUF_SYNC_END and the same read/write flags.
+ *
+ * The synchronization provided via DMA_BUF_IOCTL_SYNC only provides cache
+ * coherency. It does not prevent other processes or devices from
+ * accessing the memory at the same time. If synchronization with a GPU or
+ * other device driver is required, it is the client's responsibility to
+ * wait for buffer to be ready for reading or writing before calling this
+ * ioctl with DMA_BUF_SYNC_START. Likewise, the client must ensure that
+ * follow-up work is not submitted to GPU or other device driver until
+ * after this ioctl has been called with DMA_BUF_SYNC_END?
+ *
+ * If the driver or API with which the client is interacting uses implicit
+ * synchronization, waiting for prior work to complete can be done via
+ * poll() on the DMA buffer file descriptor. If the driver or API requires
+ * explicit synchronization, the client may have to wait on a sync_file or
+ * other synchronization primitive outside the scope of the DMA buffer API.
+ */
struct dma_buf_sync {
+ /**
+ * @flags: Set of access flags
+ *
+ * DMA_BUF_SYNC_START:
+ * Indicates the start of a map access session.
+ *
+ * DMA_BUF_SYNC_END:
+ * Indicates the end of a map access session.
+ *
+ * DMA_BUF_SYNC_READ:
+ * Indicates that the mapped DMA buffer will be read by the
+ * client via the CPU map.
+ *
+ * DMA_BUF_SYNC_WRITE:
+ * Indicates that the mapped DMA buffer will be written by the
+ * client via the CPU map.
+ *
+ * DMA_BUF_SYNC_RW:
+ * An alias for DMA_BUF_SYNC_READ | DMA_BUF_SYNC_WRITE.
+ */
__u64 flags;
};
@@ -37,6 +85,88 @@ struct dma_buf_sync {
#define DMA_BUF_NAME_LEN 32
+/**
+ * struct dma_buf_export_sync_file - Get a sync_file from a dma-buf
+ *
+ * Userspace can perform a DMA_BUF_IOCTL_EXPORT_SYNC_FILE to retrieve the
+ * current set of fences on a dma-buf file descriptor as a sync_file. CPU
+ * waits via poll() or other driver-specific mechanisms typically wait on
+ * whatever fences are on the dma-buf at the time the wait begins. This
+ * is similar except that it takes a snapshot of the current fences on the
+ * dma-buf for waiting later instead of waiting immediately. This is
+ * useful for modern graphics APIs such as Vulkan which assume an explicit
+ * synchronization model but still need to inter-operate with dma-buf.
+ *
+ * The intended usage pattern is the following:
+ *
+ * 1. Export a sync_file with flags corresponding to the expected GPU usage
+ * via DMA_BUF_IOCTL_EXPORT_SYNC_FILE.
+ *
+ * 2. Submit rendering work which uses the dma-buf. The work should wait on
+ * the exported sync file before rendering and produce another sync_file
+ * when complete.
+ *
+ * 3. Import the rendering-complete sync_file into the dma-buf with flags
+ * corresponding to the GPU usage via DMA_BUF_IOCTL_IMPORT_SYNC_FILE.
+ *
+ * Unlike doing implicit synchronization via a GPU kernel driver's exec ioctl,
+ * the above is not a single atomic operation. If userspace wants to ensure
+ * ordering via these fences, it is the respnosibility of userspace to use
+ * locks or other mechanisms to ensure that no other context adds fences or
+ * submits work between steps 1 and 3 above.
+ */
+struct dma_buf_export_sync_file {
+ /**
+ * @flags: Read/write flags
+ *
+ * Must be DMA_BUF_SYNC_READ, DMA_BUF_SYNC_WRITE, or both.
+ *
+ * If DMA_BUF_SYNC_READ is set and DMA_BUF_SYNC_WRITE is not set,
+ * the returned sync file waits on any writers of the dma-buf to
+ * complete. Waiting on the returned sync file is equivalent to
+ * poll() with POLLIN.
+ *
+ * If DMA_BUF_SYNC_WRITE is set, the returned sync file waits on
+ * any users of the dma-buf (read or write) to complete. Waiting
+ * on the returned sync file is equivalent to poll() with POLLOUT.
+ * If both DMA_BUF_SYNC_WRITE and DMA_BUF_SYNC_READ are set, this
+ * is equivalent to just DMA_BUF_SYNC_WRITE.
+ */
+ __u32 flags;
+ /** @fd: Returned sync file descriptor */
+ __s32 fd;
+};
+
+/**
+ * struct dma_buf_import_sync_file - Insert a sync_file into a dma-buf
+ *
+ * Userspace can perform a DMA_BUF_IOCTL_IMPORT_SYNC_FILE to insert a
+ * sync_file into a dma-buf for the purposes of implicit synchronization
+ * with other dma-buf consumers. This allows clients using explicitly
+ * synchronized APIs such as Vulkan to inter-op with dma-buf consumers
+ * which expect implicit synchronization such as OpenGL or most media
+ * drivers/video.
+ */
+struct dma_buf_import_sync_file {
+ /**
+ * @flags: Read/write flags
+ *
+ * Must be DMA_BUF_SYNC_READ, DMA_BUF_SYNC_WRITE, or both.
+ *
+ * If DMA_BUF_SYNC_READ is set and DMA_BUF_SYNC_WRITE is not set,
+ * this inserts the sync_file as a read-only fence. Any subsequent
+ * implicitly synchronized writes to this dma-buf will wait on this
+ * fence but reads will not.
+ *
+ * If DMA_BUF_SYNC_WRITE is set, this inserts the sync_file as a
+ * write fence. All subsequent implicitly synchronized access to
+ * this dma-buf will wait on this fence.
+ */
+ __u32 flags;
+ /** @fd: Sync file descriptor */
+ __s32 fd;
+};
+
#define DMA_BUF_BASE 'b'
#define DMA_BUF_IOCTL_SYNC _IOW(DMA_BUF_BASE, 0, struct dma_buf_sync)
@@ -44,7 +174,9 @@ struct dma_buf_sync {
* between them in actual uapi, they're just different numbers.
*/
#define DMA_BUF_SET_NAME _IOW(DMA_BUF_BASE, 1, const char *)
-#define DMA_BUF_SET_NAME_A _IOW(DMA_BUF_BASE, 1, u32)
-#define DMA_BUF_SET_NAME_B _IOW(DMA_BUF_BASE, 1, u64)
+#define DMA_BUF_SET_NAME_A _IOW(DMA_BUF_BASE, 1, __u32)
+#define DMA_BUF_SET_NAME_B _IOW(DMA_BUF_BASE, 1, __u64)
+#define DMA_BUF_IOCTL_EXPORT_SYNC_FILE _IOWR(DMA_BUF_BASE, 2, struct dma_buf_export_sync_file)
+#define DMA_BUF_IOCTL_IMPORT_SYNC_FILE _IOW(DMA_BUF_BASE, 3, struct dma_buf_import_sync_file)
#endif
diff --git a/include/linux/dma-heap.h b/include/linux/dma-heap.h
index 96b90cf0..63b1e9ed 100644
--- a/include/linux/dma-heap.h
+++ b/include/linux/dma-heap.h
@@ -19,7 +19,7 @@
#define DMA_HEAP_VALID_FD_FLAGS (O_CLOEXEC | O_ACCMODE)
/* Currently no heap flags */
-#define DMA_HEAP_VALID_HEAP_FLAGS (0)
+#define DMA_HEAP_VALID_HEAP_FLAGS (0ULL)
/**
* struct dma_heap_allocation_data - metadata passed from userspace for
diff --git a/include/linux/drm_fourcc.h b/include/linux/drm_fourcc.h
index 05d697ff..db679877 100644
--- a/include/linux/drm_fourcc.h
+++ b/include/linux/drm_fourcc.h
@@ -54,7 +54,7 @@ extern "C" {
* Format modifiers may change any property of the buffer, including the number
* of planes and/or the required allocation size. Format modifiers are
* vendor-namespaced, and as such the relationship between a fourcc code and a
- * modifier is specific to the modifer being used. For example, some modifiers
+ * modifier is specific to the modifier being used. For example, some modifiers
* may preserve meaning - such as number of planes - from the fourcc code,
* whereas others may not.
*
@@ -79,7 +79,7 @@ extern "C" {
* format.
* - Higher-level programs interfacing with KMS/GBM/EGL/Vulkan/etc: these users
* see modifiers as opaque tokens they can check for equality and intersect.
- * These users musn't need to know to reason about the modifier value
+ * These users mustn't need to know to reason about the modifier value
* (i.e. they are not expected to extract information out of the modifier).
*
* Vendors should document their modifier usage in as much detail as
@@ -88,6 +88,18 @@ extern "C" {
*
* The authoritative list of format modifier codes is found in
* `include/uapi/drm/drm_fourcc.h`
+ *
+ * Open Source User Waiver
+ * -----------------------
+ *
+ * Because this is the authoritative source for pixel formats and modifiers
+ * referenced by GL, Vulkan extensions and other standards and hence used both
+ * by open source and closed source driver stacks, the usual requirement for an
+ * upstream in-kernel or open source userspace user does not apply.
+ *
+ * To ensure, as much as feasible, compatibility across stacks and avoid
+ * confusion with incompatible enumerations stakeholders for all relevant driver
+ * stacks should approve additions.
*/
#define fourcc_code(a, b, c, d) ((__u32)(a) | ((__u32)(b) << 8) | \
@@ -99,12 +111,42 @@ extern "C" {
#define DRM_FORMAT_INVALID 0
/* color index */
+#define DRM_FORMAT_C1 fourcc_code('C', '1', ' ', ' ') /* [7:0] C0:C1:C2:C3:C4:C5:C6:C7 1:1:1:1:1:1:1:1 eight pixels/byte */
+#define DRM_FORMAT_C2 fourcc_code('C', '2', ' ', ' ') /* [7:0] C0:C1:C2:C3 2:2:2:2 four pixels/byte */
+#define DRM_FORMAT_C4 fourcc_code('C', '4', ' ', ' ') /* [7:0] C0:C1 4:4 two pixels/byte */
#define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ') /* [7:0] C */
-/* 8 bpp Red */
+/* 1 bpp Darkness (inverse relationship between channel value and brightness) */
+#define DRM_FORMAT_D1 fourcc_code('D', '1', ' ', ' ') /* [7:0] D0:D1:D2:D3:D4:D5:D6:D7 1:1:1:1:1:1:1:1 eight pixels/byte */
+
+/* 2 bpp Darkness (inverse relationship between channel value and brightness) */
+#define DRM_FORMAT_D2 fourcc_code('D', '2', ' ', ' ') /* [7:0] D0:D1:D2:D3 2:2:2:2 four pixels/byte */
+
+/* 4 bpp Darkness (inverse relationship between channel value and brightness) */
+#define DRM_FORMAT_D4 fourcc_code('D', '4', ' ', ' ') /* [7:0] D0:D1 4:4 two pixels/byte */
+
+/* 8 bpp Darkness (inverse relationship between channel value and brightness) */
+#define DRM_FORMAT_D8 fourcc_code('D', '8', ' ', ' ') /* [7:0] D */
+
+/* 1 bpp Red (direct relationship between channel value and brightness) */
+#define DRM_FORMAT_R1 fourcc_code('R', '1', ' ', ' ') /* [7:0] R0:R1:R2:R3:R4:R5:R6:R7 1:1:1:1:1:1:1:1 eight pixels/byte */
+
+/* 2 bpp Red (direct relationship between channel value and brightness) */
+#define DRM_FORMAT_R2 fourcc_code('R', '2', ' ', ' ') /* [7:0] R0:R1:R2:R3 2:2:2:2 four pixels/byte */
+
+/* 4 bpp Red (direct relationship between channel value and brightness) */
+#define DRM_FORMAT_R4 fourcc_code('R', '4', ' ', ' ') /* [7:0] R0:R1 4:4 two pixels/byte */
+
+/* 8 bpp Red (direct relationship between channel value and brightness) */
#define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ') /* [7:0] R */
-/* 16 bpp Red */
+/* 10 bpp Red (direct relationship between channel value and brightness) */
+#define DRM_FORMAT_R10 fourcc_code('R', '1', '0', ' ') /* [15:0] x:R 6:10 little endian */
+
+/* 12 bpp Red (direct relationship between channel value and brightness) */
+#define DRM_FORMAT_R12 fourcc_code('R', '1', '2', ' ') /* [15:0] x:R 4:12 little endian */
+
+/* 16 bpp Red (direct relationship between channel value and brightness) */
#define DRM_FORMAT_R16 fourcc_code('R', '1', '6', ' ') /* [15:0] R little endian */
/* 16 bpp RG */
@@ -168,6 +210,17 @@ extern "C" {
#define DRM_FORMAT_RGBA1010102 fourcc_code('R', 'A', '3', '0') /* [31:0] R:G:B:A 10:10:10:2 little endian */
#define DRM_FORMAT_BGRA1010102 fourcc_code('B', 'A', '3', '0') /* [31:0] B:G:R:A 10:10:10:2 little endian */
+/* 48 bpp RGB */
+#define DRM_FORMAT_RGB161616 fourcc_code('R', 'G', '4', '8') /* [47:0] R:G:B 16:16:16 little endian */
+#define DRM_FORMAT_BGR161616 fourcc_code('B', 'G', '4', '8') /* [47:0] B:G:R 16:16:16 little endian */
+
+/* 64 bpp RGB */
+#define DRM_FORMAT_XRGB16161616 fourcc_code('X', 'R', '4', '8') /* [63:0] x:R:G:B 16:16:16:16 little endian */
+#define DRM_FORMAT_XBGR16161616 fourcc_code('X', 'B', '4', '8') /* [63:0] x:B:G:R 16:16:16:16 little endian */
+
+#define DRM_FORMAT_ARGB16161616 fourcc_code('A', 'R', '4', '8') /* [63:0] A:R:G:B 16:16:16:16 little endian */
+#define DRM_FORMAT_ABGR16161616 fourcc_code('A', 'B', '4', '8') /* [63:0] A:B:G:R 16:16:16:16 little endian */
+
/*
* Floating point 64bpp RGB
* IEEE 754-2008 binary16 half-precision float
@@ -192,7 +245,9 @@ extern "C" {
#define DRM_FORMAT_VYUY fourcc_code('V', 'Y', 'U', 'Y') /* [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian */
#define DRM_FORMAT_AYUV fourcc_code('A', 'Y', 'U', 'V') /* [31:0] A:Y:Cb:Cr 8:8:8:8 little endian */
+#define DRM_FORMAT_AVUY8888 fourcc_code('A', 'V', 'U', 'Y') /* [31:0] A:Cr:Cb:Y 8:8:8:8 little endian */
#define DRM_FORMAT_XYUV8888 fourcc_code('X', 'Y', 'U', 'V') /* [31:0] X:Y:Cb:Cr 8:8:8:8 little endian */
+#define DRM_FORMAT_XVUY8888 fourcc_code('X', 'V', 'U', 'Y') /* [31:0] X:Cr:Cb:Y 8:8:8:8 little endian */
#define DRM_FORMAT_VUY888 fourcc_code('V', 'U', '2', '4') /* [23:0] Cr:Cb:Y 8:8:8 little endian */
#define DRM_FORMAT_VUY101010 fourcc_code('V', 'U', '3', '0') /* Y followed by U then V, 10:10:10. Non-linear modifier only */
@@ -272,6 +327,8 @@ extern "C" {
* index 1 = Cr:Cb plane, [39:0] Cr1:Cb1:Cr0:Cb0 little endian
*/
#define DRM_FORMAT_NV15 fourcc_code('N', 'V', '1', '5') /* 2x2 subsampled Cr:Cb plane */
+#define DRM_FORMAT_NV20 fourcc_code('N', 'V', '2', '0') /* 2x1 subsampled Cr:Cb plane */
+#define DRM_FORMAT_NV30 fourcc_code('N', 'V', '3', '0') /* non-subsampled Cr:Cb plane */
/*
* 2 plane YCbCr MSB aligned
@@ -301,6 +358,13 @@ extern "C" {
*/
#define DRM_FORMAT_P016 fourcc_code('P', '0', '1', '6') /* 2x2 subsampled Cr:Cb plane 16 bits per channel */
+/* 2 plane YCbCr420.
+ * 3 10 bit components and 2 padding bits packed into 4 bytes.
+ * index 0 = Y plane, [31:0] x:Y2:Y1:Y0 2:10:10:10 little endian
+ * index 1 = Cr:Cb plane, [63:0] x:Cr2:Cb2:Cr1:x:Cb1:Cr0:Cb0 [2:10:10:10:2:10:10:10] little endian
+ */
+#define DRM_FORMAT_P030 fourcc_code('P', '0', '3', '0') /* 2x2 subsampled Cr:Cb plane 10 bits per channel packed */
+
/* 3 plane non-subsampled (444) YCbCr
* 16 bits per component, but only 10 bits are used and 6 bits are padded
* index 0: Y plane, [15:0] Y:x [10:6] little endian
@@ -426,11 +490,18 @@ extern "C" {
#define DRM_FORMAT_MOD_VENDOR_ALLWINNER 0x09
#define DRM_FORMAT_MOD_VENDOR_AMLOGIC 0x0a
#define DRM_FORMAT_MOD_VENDOR_MIPI 0x0b
+#define DRM_FORMAT_MOD_VENDOR_RPI 0x0c
/* add more to the end as needed */
#define DRM_FORMAT_RESERVED ((1ULL << 56) - 1)
+#define fourcc_mod_get_vendor(modifier) \
+ (((modifier) >> 56) & 0xff)
+
+#define fourcc_mod_is_vendor(modifier, vendor) \
+ (fourcc_mod_get_vendor(modifier) == DRM_FORMAT_MOD_VENDOR_## vendor)
+
#define fourcc_mod_code(vendor, val) \
((((__u64)DRM_FORMAT_MOD_VENDOR_## vendor) << 56) | ((val) & 0x00ffffffffffffffULL))
@@ -539,7 +610,7 @@ extern "C" {
* This is a tiled layout using 4Kb tiles in row-major layout.
* Within the tile pixels are laid out in 16 256 byte units / sub-tiles which
* are arranged in four groups (two wide, two high) with column-major layout.
- * Each group therefore consits out of four 256 byte units, which are also laid
+ * Each group therefore consists out of four 256 byte units, which are also laid
* out as 2x2 column-major.
* 256 byte units are made out of four 64 byte blocks of pixels, producing
* either a square block or a 2:1 unit.
@@ -598,7 +669,7 @@ extern "C" {
*
* The main surface is Y-tiled and is at plane index 0 whereas CCS is linear
* and at index 1. The clear color is stored at index 2, and the pitch should
- * be ignored. The clear color structure is 256 bits. The first 128 bits
+ * be 64 bytes aligned. The clear color structure is 256 bits. The first 128 bits
* represents Raw Clear Color Red, Green, Blue and Alpha color each represented
* by 32 bits. The raw clear color is consumed by the 3d engine and generates
* the converted clear color of size 64 bits. The first 32 bits store the Lower
@@ -612,6 +683,96 @@ extern "C" {
#define I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC fourcc_mod_code(INTEL, 8)
/*
+ * Intel Tile 4 layout
+ *
+ * This is a tiled layout using 4KB tiles in a row-major layout. It has the same
+ * shape as Tile Y at two granularities: 4KB (128B x 32) and 64B (16B x 4). It
+ * only differs from Tile Y at the 256B granularity in between. At this
+ * granularity, Tile Y has a shape of 16B x 32 rows, but this tiling has a shape
+ * of 64B x 8 rows.
+ */
+#define I915_FORMAT_MOD_4_TILED fourcc_mod_code(INTEL, 9)
+
+/*
+ * Intel color control surfaces (CCS) for DG2 render compression.
+ *
+ * The main surface is Tile 4 and at plane index 0. The CCS data is stored
+ * outside of the GEM object in a reserved memory area dedicated for the
+ * storage of the CCS data for all RC/RC_CC/MC compressible GEM objects. The
+ * main surface pitch is required to be a multiple of four Tile 4 widths.
+ */
+#define I915_FORMAT_MOD_4_TILED_DG2_RC_CCS fourcc_mod_code(INTEL, 10)
+
+/*
+ * Intel color control surfaces (CCS) for DG2 media compression.
+ *
+ * The main surface is Tile 4 and at plane index 0. For semi-planar formats
+ * like NV12, the Y and UV planes are Tile 4 and are located at plane indices
+ * 0 and 1, respectively. The CCS for all planes are stored outside of the
+ * GEM object in a reserved memory area dedicated for the storage of the
+ * CCS data for all RC/RC_CC/MC compressible GEM objects. The main surface
+ * pitch is required to be a multiple of four Tile 4 widths.
+ */
+#define I915_FORMAT_MOD_4_TILED_DG2_MC_CCS fourcc_mod_code(INTEL, 11)
+
+/*
+ * Intel Color Control Surface with Clear Color (CCS) for DG2 render compression.
+ *
+ * The main surface is Tile 4 and at plane index 0. The CCS data is stored
+ * outside of the GEM object in a reserved memory area dedicated for the
+ * storage of the CCS data for all RC/RC_CC/MC compressible GEM objects. The
+ * main surface pitch is required to be a multiple of four Tile 4 widths. The
+ * clear color is stored at plane index 1 and the pitch should be 64 bytes
+ * aligned. The format of the 256 bits of clear color data matches the one used
+ * for the I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC modifier, see its description
+ * for details.
+ */
+#define I915_FORMAT_MOD_4_TILED_DG2_RC_CCS_CC fourcc_mod_code(INTEL, 12)
+
+/*
+ * Intel Color Control Surfaces (CCS) for display ver. 14 render compression.
+ *
+ * The main surface is tile4 and at plane index 0, the CCS is linear and
+ * at index 1. A 64B CCS cache line corresponds to an area of 4x1 tiles in
+ * main surface. In other words, 4 bits in CCS map to a main surface cache
+ * line pair. The main surface pitch is required to be a multiple of four
+ * tile4 widths.
+ */
+#define I915_FORMAT_MOD_4_TILED_MTL_RC_CCS fourcc_mod_code(INTEL, 13)
+
+/*
+ * Intel Color Control Surfaces (CCS) for display ver. 14 media compression
+ *
+ * The main surface is tile4 and at plane index 0, the CCS is linear and
+ * at index 1. A 64B CCS cache line corresponds to an area of 4x1 tiles in
+ * main surface. In other words, 4 bits in CCS map to a main surface cache
+ * line pair. The main surface pitch is required to be a multiple of four
+ * tile4 widths. For semi-planar formats like NV12, CCS planes follow the
+ * Y and UV planes i.e., planes 0 and 1 are used for Y and UV surfaces,
+ * planes 2 and 3 for the respective CCS.
+ */
+#define I915_FORMAT_MOD_4_TILED_MTL_MC_CCS fourcc_mod_code(INTEL, 14)
+
+/*
+ * Intel Color Control Surface with Clear Color (CCS) for display ver. 14 render
+ * compression.
+ *
+ * The main surface is tile4 and is at plane index 0 whereas CCS is linear
+ * and at index 1. The clear color is stored at index 2, and the pitch should
+ * be ignored. The clear color structure is 256 bits. The first 128 bits
+ * represents Raw Clear Color Red, Green, Blue and Alpha color each represented
+ * by 32 bits. The raw clear color is consumed by the 3d engine and generates
+ * the converted clear color of size 64 bits. The first 32 bits store the Lower
+ * Converted Clear Color value and the next 32 bits store the Higher Converted
+ * Clear Color value when applicable. The Converted Clear Color values are
+ * consumed by the DE. The last 64 bits are used to store Color Discard Enable
+ * and Depth Clear Value Valid which are ignored by the DE. A CCS cache line
+ * corresponds to an area of 4x1 tiles in the main surface. The main surface
+ * pitch is required to be a multiple of 4 tile widths.
+ */
+#define I915_FORMAT_MOD_4_TILED_MTL_RC_CCS_CC fourcc_mod_code(INTEL, 15)
+
+/*
* IPU3 Bayer packing layout
*
* The IPU3 raw Bayer formats use a custom packing layout where there are no
@@ -619,7 +780,7 @@ extern "C" {
* the 6 most significant bits in the last byte unused. The format is little
* endian.
*/
-#define IPU3_FORMAT_MOD_PACKED fourcc_mod_code(INTEL, 9)
+#define IPU3_FORMAT_MOD_PACKED fourcc_mod_code(INTEL, 13)
/*
* Tiled, NV12MT, grouped in 64 (pixels) x 32 (lines) -sized macroblocks
@@ -658,6 +819,28 @@ extern "C" {
*/
#define DRM_FORMAT_MOD_QCOM_COMPRESSED fourcc_mod_code(QCOM, 1)
+/*
+ * Qualcomm Tiled Format
+ *
+ * Similar to DRM_FORMAT_MOD_QCOM_COMPRESSED but not compressed.
+ * Implementation may be platform and base-format specific.
+ *
+ * Each macrotile consists of m x n (mostly 4 x 4) tiles.
+ * Pixel data pitch/stride is aligned with macrotile width.
+ * Pixel data height is aligned with macrotile height.
+ * Entire pixel data buffer is aligned with 4k(bytes).
+ */
+#define DRM_FORMAT_MOD_QCOM_TILED3 fourcc_mod_code(QCOM, 3)
+
+/*
+ * Qualcomm Alternate Tiled Format
+ *
+ * Alternate tiled format typically only used within GMEM.
+ * Implementation may be platform and base-format specific.
+ */
+#define DRM_FORMAT_MOD_QCOM_TILED2 fourcc_mod_code(QCOM, 2)
+
+
/* Vivante framebuffer modifiers */
/*
@@ -698,6 +881,35 @@ extern "C" {
*/
#define DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED fourcc_mod_code(VIVANTE, 4)
+/*
+ * Vivante TS (tile-status) buffer modifiers. They can be combined with all of
+ * the color buffer tiling modifiers defined above. When TS is present it's a
+ * separate buffer containing the clear/compression status of each tile. The
+ * modifiers are defined as VIVANTE_MOD_TS_c_s, where c is the color buffer
+ * tile size in bytes covered by one entry in the status buffer and s is the
+ * number of status bits per entry.
+ * We reserve the top 8 bits of the Vivante modifier space for tile status
+ * clear/compression modifiers, as future cores might add some more TS layout
+ * variations.
+ */
+#define VIVANTE_MOD_TS_64_4 (1ULL << 48)
+#define VIVANTE_MOD_TS_64_2 (2ULL << 48)
+#define VIVANTE_MOD_TS_128_4 (3ULL << 48)
+#define VIVANTE_MOD_TS_256_4 (4ULL << 48)
+#define VIVANTE_MOD_TS_MASK (0xfULL << 48)
+
+/*
+ * Vivante compression modifiers. Those depend on a TS modifier being present
+ * as the TS bits get reinterpreted as compression tags instead of simple
+ * clear markers when compression is enabled.
+ */
+#define VIVANTE_MOD_COMP_DEC400 (1ULL << 52)
+#define VIVANTE_MOD_COMP_MASK (0xfULL << 52)
+
+/* Masking out the extension bits will yield the base modifier. */
+#define VIVANTE_MOD_EXT_MASK (VIVANTE_MOD_TS_MASK | \
+ VIVANTE_MOD_COMP_MASK)
+
/* NVIDIA frame buffer modifiers */
/*
@@ -910,6 +1122,10 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
* and UV. Some SAND-using hardware stores UV in a separate tiled
* image from Y to reduce the column height, which is not supported
* with these modifiers.
+ *
+ * The DRM_FORMAT_MOD_BROADCOM_SAND128_COL_HEIGHT modifier is also
+ * supported for DRM_FORMAT_P030 where the columns remain as 128 bytes
+ * wide, but as this is a 10 bpp format that translates to 96 pixels.
*/
#define DRM_FORMAT_MOD_BROADCOM_SAND32_COL_HEIGHT(v) \
@@ -967,10 +1183,10 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
*/
/*
- * The top 4 bits (out of the 56 bits alloted for specifying vendor specific
- * modifiers) denote the category for modifiers. Currently we have only two
- * categories of modifiers ie AFBC and MISC. We can have a maximum of sixteen
- * different categories.
+ * The top 4 bits (out of the 56 bits allotted for specifying vendor specific
+ * modifiers) denote the category for modifiers. Currently we have three
+ * categories of modifiers ie AFBC, MISC and AFRC. We can have a maximum of
+ * sixteen different categories.
*/
#define DRM_FORMAT_MOD_ARM_CODE(__type, __val) \
fourcc_mod_code(ARM, ((__u64)(__type) << 52) | ((__val) & 0x000fffffffffffffULL))
@@ -1086,6 +1302,109 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
#define AFBC_FORMAT_MOD_USM (1ULL << 12)
/*
+ * Arm Fixed-Rate Compression (AFRC) modifiers
+ *
+ * AFRC is a proprietary fixed rate image compression protocol and format,
+ * designed to provide guaranteed bandwidth and memory footprint
+ * reductions in graphics and media use-cases.
+ *
+ * AFRC buffers consist of one or more planes, with the same components
+ * and meaning as an uncompressed buffer using the same pixel format.
+ *
+ * Within each plane, the pixel/luma/chroma values are grouped into
+ * "coding unit" blocks which are individually compressed to a
+ * fixed size (in bytes). All coding units within a given plane of a buffer
+ * store the same number of values, and have the same compressed size.
+ *
+ * The coding unit size is configurable, allowing different rates of compression.
+ *
+ * The start of each AFRC buffer plane must be aligned to an alignment granule which
+ * depends on the coding unit size.
+ *
+ * Coding Unit Size Plane Alignment
+ * ---------------- ---------------
+ * 16 bytes 1024 bytes
+ * 24 bytes 512 bytes
+ * 32 bytes 2048 bytes
+ *
+ * Coding units are grouped into paging tiles. AFRC buffer dimensions must be aligned
+ * to a multiple of the paging tile dimensions.
+ * The dimensions of each paging tile depend on whether the buffer is optimised for
+ * scanline (SCAN layout) or rotated (ROT layout) access.
+ *
+ * Layout Paging Tile Width Paging Tile Height
+ * ------ ----------------- ------------------
+ * SCAN 16 coding units 4 coding units
+ * ROT 8 coding units 8 coding units
+ *
+ * The dimensions of each coding unit depend on the number of components
+ * in the compressed plane and whether the buffer is optimised for
+ * scanline (SCAN layout) or rotated (ROT layout) access.
+ *
+ * Number of Components in Plane Layout Coding Unit Width Coding Unit Height
+ * ----------------------------- --------- ----------------- ------------------
+ * 1 SCAN 16 samples 4 samples
+ * Example: 16x4 luma samples in a 'Y' plane
+ * 16x4 chroma 'V' values, in the 'V' plane of a fully-planar YUV buffer
+ * ----------------------------- --------- ----------------- ------------------
+ * 1 ROT 8 samples 8 samples
+ * Example: 8x8 luma samples in a 'Y' plane
+ * 8x8 chroma 'V' values, in the 'V' plane of a fully-planar YUV buffer
+ * ----------------------------- --------- ----------------- ------------------
+ * 2 DONT CARE 8 samples 4 samples
+ * Example: 8x4 chroma pairs in the 'UV' plane of a semi-planar YUV buffer
+ * ----------------------------- --------- ----------------- ------------------
+ * 3 DONT CARE 4 samples 4 samples
+ * Example: 4x4 pixels in an RGB buffer without alpha
+ * ----------------------------- --------- ----------------- ------------------
+ * 4 DONT CARE 4 samples 4 samples
+ * Example: 4x4 pixels in an RGB buffer with alpha
+ */
+
+#define DRM_FORMAT_MOD_ARM_TYPE_AFRC 0x02
+
+#define DRM_FORMAT_MOD_ARM_AFRC(__afrc_mode) \
+ DRM_FORMAT_MOD_ARM_CODE(DRM_FORMAT_MOD_ARM_TYPE_AFRC, __afrc_mode)
+
+/*
+ * AFRC coding unit size modifier.
+ *
+ * Indicates the number of bytes used to store each compressed coding unit for
+ * one or more planes in an AFRC encoded buffer. The coding unit size for chrominance
+ * is the same for both Cb and Cr, which may be stored in separate planes.
+ *
+ * AFRC_FORMAT_MOD_CU_SIZE_P0 indicates the number of bytes used to store
+ * each compressed coding unit in the first plane of the buffer. For RGBA buffers
+ * this is the only plane, while for semi-planar and fully-planar YUV buffers,
+ * this corresponds to the luma plane.
+ *
+ * AFRC_FORMAT_MOD_CU_SIZE_P12 indicates the number of bytes used to store
+ * each compressed coding unit in the second and third planes in the buffer.
+ * For semi-planar and fully-planar YUV buffers, this corresponds to the chroma plane(s).
+ *
+ * For single-plane buffers, AFRC_FORMAT_MOD_CU_SIZE_P0 must be specified
+ * and AFRC_FORMAT_MOD_CU_SIZE_P12 must be zero.
+ * For semi-planar and fully-planar buffers, both AFRC_FORMAT_MOD_CU_SIZE_P0 and
+ * AFRC_FORMAT_MOD_CU_SIZE_P12 must be specified.
+ */
+#define AFRC_FORMAT_MOD_CU_SIZE_MASK 0xf
+#define AFRC_FORMAT_MOD_CU_SIZE_16 (1ULL)
+#define AFRC_FORMAT_MOD_CU_SIZE_24 (2ULL)
+#define AFRC_FORMAT_MOD_CU_SIZE_32 (3ULL)
+
+#define AFRC_FORMAT_MOD_CU_SIZE_P0(__afrc_cu_size) (__afrc_cu_size)
+#define AFRC_FORMAT_MOD_CU_SIZE_P12(__afrc_cu_size) ((__afrc_cu_size) << 4)
+
+/*
+ * AFRC scanline memory layout.
+ *
+ * Indicates if the buffer uses the scanline-optimised layout
+ * for an AFRC encoded buffer, otherwise, it uses the rotation-optimised layout.
+ * The memory layout is the same for all planes.
+ */
+#define AFRC_FORMAT_MOD_LAYOUT_SCAN (1ULL << 8)
+
+/*
* Arm 16x16 Block U-Interleaved modifier
*
* This is used by Arm Mali Utgard and Midgard GPUs. It divides the image
@@ -1180,7 +1499,7 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
* Amlogic FBC Memory Saving mode
*
* Indicates the storage is packed when pixel size is multiple of word
- * boudaries, i.e. 8bit should be stored in this mode to save allocation
+ * boundaries, i.e. 8bit should be stored in this mode to save allocation
* memory.
*
* This mode reduces body layout to 3072 bytes per 64x32 superblock with
@@ -1236,6 +1555,8 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
#define AMD_FMT_MOD_TILE_VER_GFX9 1
#define AMD_FMT_MOD_TILE_VER_GFX10 2
#define AMD_FMT_MOD_TILE_VER_GFX10_RBPLUS 3
+#define AMD_FMT_MOD_TILE_VER_GFX11 4
+#define AMD_FMT_MOD_TILE_VER_GFX12 5
/*
* 64K_S is the same for GFX9/GFX10/GFX10_RBPLUS and hence has GFX9 as canonical
@@ -1246,11 +1567,29 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
/*
* 64K_D for non-32 bpp is the same for GFX9/GFX10/GFX10_RBPLUS and hence has
* GFX9 as canonical version.
+ *
+ * 64K_D_2D on GFX12 is identical to 64K_D on GFX11.
*/
#define AMD_FMT_MOD_TILE_GFX9_64K_D 10
#define AMD_FMT_MOD_TILE_GFX9_64K_S_X 25
#define AMD_FMT_MOD_TILE_GFX9_64K_D_X 26
#define AMD_FMT_MOD_TILE_GFX9_64K_R_X 27
+#define AMD_FMT_MOD_TILE_GFX11_256K_R_X 31
+
+/* Gfx12 swizzle modes:
+ * 0 - LINEAR
+ * 1 - 256B_2D - 2D block dimensions
+ * 2 - 4KB_2D
+ * 3 - 64KB_2D
+ * 4 - 256KB_2D
+ * 5 - 4KB_3D - 3D block dimensions
+ * 6 - 64KB_3D
+ * 7 - 256KB_3D
+ */
+#define AMD_FMT_MOD_TILE_GFX12_256B_2D 1
+#define AMD_FMT_MOD_TILE_GFX12_4K_2D 2
+#define AMD_FMT_MOD_TILE_GFX12_64K_2D 3
+#define AMD_FMT_MOD_TILE_GFX12_256K_2D 4
#define AMD_FMT_MOD_DCC_BLOCK_64B 0
#define AMD_FMT_MOD_DCC_BLOCK_128B 1
@@ -1317,11 +1656,11 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
#define AMD_FMT_MOD_PIPE_MASK 0x7
#define AMD_FMT_MOD_SET(field, value) \
- ((uint64_t)(value) << AMD_FMT_MOD_##field##_SHIFT)
+ ((__u64)(value) << AMD_FMT_MOD_##field##_SHIFT)
#define AMD_FMT_MOD_GET(field, value) \
(((value) >> AMD_FMT_MOD_##field##_SHIFT) & AMD_FMT_MOD_##field##_MASK)
#define AMD_FMT_MOD_CLEAR(field) \
- (~((uint64_t)AMD_FMT_MOD_##field##_MASK << AMD_FMT_MOD_##field##_SHIFT))
+ (~((__u64)AMD_FMT_MOD_##field##_MASK << AMD_FMT_MOD_##field##_SHIFT))
/* Mobile Industry Processor Interface (MIPI) modifiers */
@@ -1350,6 +1689,9 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
*/
#define MIPI_FORMAT_MOD_CSI2_PACKED fourcc_mod_code(MIPI, 1)
+#define PISP_FORMAT_MOD_COMPRESS_MODE1 fourcc_mod_code(RPI, 1)
+#define PISP_FORMAT_MOD_COMPRESS_MODE2 fourcc_mod_code(RPI, 2)
+
#if defined(__cplusplus)
}
#endif
diff --git a/include/linux/intel-ipu3.h b/include/linux/intel-ipu3.h
index ee0e6d0e..8c192f35 100644
--- a/include/linux/intel-ipu3.h
+++ b/include/linux/intel-ipu3.h
@@ -1,4 +1,4 @@
-/* SPDX-License-Identifier: GPL-2.0 */
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/* Copyright (C) 2017 - 2018 Intel Corporation */
#ifndef __IPU3_UAPI_H
@@ -9,8 +9,10 @@
/* from /drivers/staging/media/ipu3/include/videodev2.h */
/* Vendor specific - used for IPU3 camera sub-system */
-#define V4L2_META_FMT_IPU3_PARAMS v4l2_fourcc('i', 'p', '3', 'p') /* IPU3 processing parameters */
-#define V4L2_META_FMT_IPU3_STAT_3A v4l2_fourcc('i', 'p', '3', 's') /* IPU3 3A statistics */
+/* IPU3 processing parameters */
+#define V4L2_META_FMT_IPU3_PARAMS v4l2_fourcc('i', 'p', '3', 'p')
+/* IPU3 3A statistics */
+#define V4L2_META_FMT_IPU3_STAT_3A v4l2_fourcc('i', 'p', '3', 's')
/* from include/uapi/linux/v4l2-controls.h */
#define V4L2_CID_INTEL_IPU3_BASE (V4L2_CID_USER_BASE + 0x10c0)
@@ -32,11 +34,17 @@
* struct ipu3_uapi_grid_config - Grid plane config
*
* @width: Grid horizontal dimensions, in number of grid blocks(cells).
+ * For AWB, the range is (16, 80).
+ * For AF/AE, the range is (16, 32).
* @height: Grid vertical dimensions, in number of grid cells.
+ * For AWB, the range is (16, 60).
+ * For AF/AE, the range is (16, 24).
* @block_width_log2: Log2 of the width of each cell in pixels.
- * for (2^3, 2^4, 2^5, 2^6, 2^7), values [3, 7].
+ * For AWB, the range is [3, 6].
+ * For AF/AE, the range is [3, 7].
* @block_height_log2: Log2 of the height of each cell in pixels.
- * for (2^3, 2^4, 2^5, 2^6, 2^7), values [3, 7].
+ * For AWB, the range is [3, 6].
+ * For AF/AE, the range is [3, 7].
* @height_per_slice: The number of blocks in vertical axis per slice.
* Default 2.
* @x_start: X value of top left corner of Region of Interest(ROI).
@@ -59,22 +67,43 @@ struct ipu3_uapi_grid_config {
__u16 y_end;
} __attribute__((packed));
+/**
+ * struct ipu3_uapi_awb_set_item - Memory layout for each cell in AWB
+ *
+ * @Gr_avg: Green average for red lines in the cell.
+ * @R_avg: Red average in the cell.
+ * @B_avg: Blue average in the cell.
+ * @Gb_avg: Green average for blue lines in the cell.
+ * @sat_ratio: Percentage of pixels over the thresholds specified in
+ * ipu3_uapi_awb_config_s, coded from 0 to 255.
+ * @padding0: Unused byte for padding.
+ * @padding1: Unused byte for padding.
+ * @padding2: Unused byte for padding.
+ */
+struct ipu3_uapi_awb_set_item {
+ __u8 Gr_avg;
+ __u8 R_avg;
+ __u8 B_avg;
+ __u8 Gb_avg;
+ __u8 sat_ratio;
+ __u8 padding0;
+ __u8 padding1;
+ __u8 padding2;
+} __attribute__((packed));
+
/*
* The grid based data is divided into "slices" called set, each slice of setX
* refers to ipu3_uapi_grid_config width * height_per_slice.
*/
#define IPU3_UAPI_AWB_MAX_SETS 60
/* Based on grid size 80 * 60 and cell size 16 x 16 */
-#define IPU3_UAPI_AWB_SET_SIZE 1280
-#define IPU3_UAPI_AWB_MD_ITEM_SIZE 8
+#define IPU3_UAPI_AWB_SET_SIZE 160
#define IPU3_UAPI_AWB_SPARE_FOR_BUBBLES \
- (IPU3_UAPI_MAX_BUBBLE_SIZE * IPU3_UAPI_MAX_STRIPES * \
- IPU3_UAPI_AWB_MD_ITEM_SIZE)
+ (IPU3_UAPI_MAX_BUBBLE_SIZE * IPU3_UAPI_MAX_STRIPES)
#define IPU3_UAPI_AWB_MAX_BUFFER_SIZE \
(IPU3_UAPI_AWB_MAX_SETS * \
(IPU3_UAPI_AWB_SET_SIZE + IPU3_UAPI_AWB_SPARE_FOR_BUBBLES))
-
/**
* struct ipu3_uapi_awb_raw_buffer - AWB raw buffer
*
@@ -82,7 +111,7 @@ struct ipu3_uapi_grid_config {
* the average values for each color channel.
*/
struct ipu3_uapi_awb_raw_buffer {
- __u8 meta_data[IPU3_UAPI_AWB_MAX_BUFFER_SIZE]
+ struct ipu3_uapi_awb_set_item meta_data[IPU3_UAPI_AWB_MAX_BUFFER_SIZE]
__attribute__((aligned(32)));
} __attribute__((packed));
@@ -233,7 +262,9 @@ struct ipu3_uapi_ae_ccm {
* struct ipu3_uapi_ae_config - AE config
*
* @grid_cfg: config for auto exposure statistics grid. See struct
- * &ipu3_uapi_ae_grid_config
+ * &ipu3_uapi_ae_grid_config, as Imgu did not support output
+ * auto exposure statistics, so user can ignore this configuration
+ * and use the RGB table in auto-whitebalance statistics instead.
* @weights: &IPU3_UAPI_AE_WEIGHTS is based on 32x24 blocks in the grid.
* Each grid cell has a corresponding value in weights LUT called
* grid value, global histogram is updated based on grid value and
@@ -244,8 +275,8 @@ struct ipu3_uapi_ae_ccm {
*/
struct ipu3_uapi_ae_config {
struct ipu3_uapi_ae_grid_config grid_cfg __attribute__((aligned(32)));
- struct ipu3_uapi_ae_weight_elem weights[
- IPU3_UAPI_AE_WEIGHTS] __attribute__((aligned(32)));
+ struct ipu3_uapi_ae_weight_elem weights[IPU3_UAPI_AE_WEIGHTS]
+ __attribute__((aligned(32)));
struct ipu3_uapi_ae_ccm ae_ccm __attribute__((aligned(32)));
} __attribute__((packed));
@@ -533,6 +564,9 @@ struct ipu3_uapi_ff_status {
*
* @awb_raw_buffer: auto white balance meta data &ipu3_uapi_awb_raw_buffer
* @ae_raw_buffer: auto exposure raw data &ipu3_uapi_ae_raw_buffer_aligned
+ * current Imgu does not output the auto exposure statistics
+ * to ae_raw_buffer, the user such as 3A algorithm can use the
+ * RGB table in &ipu3_uapi_awb_raw_buffer to do auto-exposure.
* @af_raw_buffer: &ipu3_uapi_af_raw_buffer for auto focus meta data
* @awb_fr_raw_buffer: value as specified by &ipu3_uapi_awb_fr_raw_buffer
* @stats_4a_config: 4a statistics config as defined by &ipu3_uapi_4a_config.
@@ -592,8 +626,11 @@ struct ipu3_uapi_stats_3a {
* @b: white balance gain for B channel.
* @gb: white balance gain for Gb channel.
*
- * Precision u3.13, range [0, 8). White balance correction is done by applying
- * a multiplicative gain to each color channels prior to BNR.
+ * For BNR parameters WB gain factor for the three channels [Ggr, Ggb, Gb, Gr].
+ * Their precision is U3.13 and the range is (0, 8) and the actual gain is
+ * Gx + 1, it is typically Gx = 1.
+ *
+ * Pout = {Pin * (1 + Gx)}.
*/
struct ipu3_uapi_bnr_static_config_wb_gains_config {
__u16 gr;
@@ -630,7 +667,7 @@ struct ipu3_uapi_bnr_static_config_wb_gains_thr_config {
* @cg: Gain coefficient for threshold calculation, [0, 31], default 8.
* @ci: Intensity coefficient for threshold calculation. range [0, 0x1f]
* default 6.
- * format: u3.2 (3 most significant bits represent whole number,
+ * format: u3.2 (3 most significant bits represent whole number,
* 2 least significant bits represent the fractional part
* with each count representing 0.25)
* e.g. 6 in binary format is 00110, that translates to 1.5
@@ -2448,11 +2485,9 @@ struct ipu3_uapi_anr_config {
* &ipu3_uapi_yuvp1_y_ee_nr_config
* @yds: y down scaler config. See &ipu3_uapi_yuvp1_yds_config
* @chnr: chroma noise reduction config. See &ipu3_uapi_yuvp1_chnr_config
- * @reserved1: reserved
* @yds2: y channel down scaler config. See &ipu3_uapi_yuvp1_yds_config
* @tcc: total color correction config as defined in struct
* &ipu3_uapi_yuvp2_tcc_static_config
- * @reserved2: reserved
* @anr: advanced noise reduction config.See &ipu3_uapi_anr_config
* @awb_fr: AWB filter response config. See ipu3_uapi_awb_fr_config
* @ae: auto exposure config As specified by &ipu3_uapi_ae_config
@@ -2687,7 +2722,6 @@ struct ipu3_uapi_obgrid_param {
* @acc_ae: 0 = no update, 1 = update.
* @acc_af: 0 = no update, 1 = update.
* @acc_awb: 0 = no update, 1 = update.
- * @__acc_osys: 0 = no update, 1 = update.
* @reserved3: Not used.
* @lin_vmem_params: 0 = no update, 1 = update.
* @tnr3_vmem_params: 0 = no update, 1 = update.
diff --git a/include/linux/mali-c55-config.h b/include/linux/mali-c55-config.h
new file mode 100644
index 00000000..b3141559
--- /dev/null
+++ b/include/linux/mali-c55-config.h
@@ -0,0 +1,909 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * ARM Mali-C55 ISP Driver - Userspace API
+ *
+ * Copyright (C) 2023 Ideas on Board Oy
+ */
+
+#ifndef __UAPI_MALI_C55_CONFIG_H
+#define __UAPI_MALI_C55_CONFIG_H
+
+#include <linux/types.h>
+
+/*
+ * Frames are split into zones of almost equal width and height - a zone is a
+ * rectangular tile of a frame. The metering blocks within the ISP collect
+ * aggregated statistics per zone. A maximum of 15x15 zones can be configured,
+ * and so the statistics buffer within the hardware is sized to accommodate
+ * that.
+ *
+ * The utilised number of zones is runtime configurable.
+ */
+#define MALI_C55_MAX_ZONES (15 * 15)
+
+/**
+ * struct mali_c55_ae_1024bin_hist - Auto Exposure 1024-bin histogram statistics
+ *
+ * @bins: 1024 element array of 16-bit pixel counts.
+ *
+ * The 1024-bin histogram module collects image-global but zone-weighted
+ * intensity distributions of pixels in fixed-width bins. The modules can be
+ * configured into different "plane modes" which affect the contents of the
+ * collected statistics. In plane mode 0, pixel intensities are taken regardless
+ * of colour plane into a single 1024-bin histogram with a bin width of 4. In
+ * plane mode 1, four 256-bin histograms with a bin width of 16 are collected -
+ * one for each CFA colour plane. In plane modes 4, 5, 6 and 7 two 512-bin
+ * histograms with a bin width of 8 are collected - in each mode one of the
+ * colour planes is collected into the first histogram and all the others are
+ * combined into the second. The histograms are stored consecutively in the bins
+ * array.
+ *
+ * The 16-bit pixel counts are stored as a 4-bit exponent in the most
+ * significant bits followed by a 12-bit mantissa. Conversion to a usable
+ * format can be done according to the following pseudo-code::
+ *
+ * if (e == 0) {
+ * bin = m * 2;
+ * } else {
+ * bin = (m + 4096) * 2^e
+ * }
+ *
+ * where
+ * e is the exponent value in range 0..15
+ * m is the mantissa value in range 0..4095
+ *
+ * The pixels used in calculating the statistics can be masked using three
+ * methods:
+ *
+ * 1. Pixels can be skipped in X and Y directions independently.
+ * 2. Minimum/Maximum intensities can be configured
+ * 3. Zones can be differentially weighted, including 0 weighted to mask them
+ *
+ * The data for this histogram can be collected from different tap points in the
+ * ISP depending on configuration - after the white balance or digital gain
+ * blocks, or immediately after the input crossbar.
+ */
+struct mali_c55_ae_1024bin_hist {
+ __u16 bins[1024];
+} __attribute__((packed));
+
+/**
+ * struct mali_c55_ae_5bin_hist - Auto Exposure 5-bin histogram statistics
+ *
+ * @hist0: 16-bit normalised pixel count for the 0th intensity bin
+ * @hist1: 16-bit normalised pixel count for the 1st intensity bin
+ * @hist3: 16-bit normalised pixel count for the 3rd intensity bin
+ * @hist4: 16-bit normalised pixel count for the 4th intensity bin
+ *
+ * The ISP generates a 5-bin histogram of normalised pixel counts within bins of
+ * pixel intensity for each of 225 possible zones within a frame. The centre bin
+ * of the histogram for each zone is not available from the hardware and must be
+ * calculated by subtracting the values of hist0, hist1, hist3 and hist4 from
+ * 0xffff as in the following equation:
+ *
+ * hist2 = 0xffff - (hist0 + hist1 + hist3 + hist4)
+ */
+struct mali_c55_ae_5bin_hist {
+ __u16 hist0;
+ __u16 hist1;
+ __u16 hist3;
+ __u16 hist4;
+} __attribute__((packed));
+
+/**
+ * struct mali_c55_awb_average_ratios - Auto White Balance colour ratios
+ *
+ * @avg_rg_gr: Average R/G or G/R ratio in Q4.8 format.
+ * @avg_bg_br: Average B/G or B/R ratio in Q4.8 format.
+ * @num_pixels: The number of pixels used in the AWB calculation
+ *
+ * The ISP calculates and collects average colour ratios for each zone in an
+ * image and stores them in Q4.8 format (the lowest 8 bits are fractional, with
+ * bits [11:8] representing the integer). The exact ratios collected (either
+ * R/G, B/G or G/R, B/R) are configurable through the parameters buffer. The
+ * value of the 4 high bits is undefined.
+ */
+struct mali_c55_awb_average_ratios {
+ __u16 avg_rg_gr;
+ __u16 avg_bg_br;
+ __u32 num_pixels;
+} __attribute__((packed));
+
+/**
+ * struct mali_c55_af_statistics - Auto Focus edge and intensity statistics
+ *
+ * @intensity_stats: Packed mantissa and exponent value for pixel intensity
+ * @edge_stats: Packed mantissa and exponent values for edge intensity
+ *
+ * The ISP collects the squared sum of pixel intensities for each zone within a
+ * configurable Region of Interest on the frame. Additionally, the same data are
+ * collected after being passed through a bandpass filter which removes high and
+ * low frequency components - these are referred to as the edge statistics.
+ *
+ * The intensity and edge statistics for a zone can be used to calculate the
+ * contrast information for a zone
+ *
+ * C = E2 / I2
+ *
+ * Where I2 is the intensity statistic for a zone and E2 is the edge statistic
+ * for that zone. Optimum focus is reached when C is at its maximum.
+ *
+ * The intensity and edge statistics are stored packed into a non-standard 16
+ * bit floating point format, where the 7 most significant bits represent the
+ * exponent and the 9 least significant bits the mantissa. This format can be
+ * unpacked with the following pseudocode::
+ *
+ * if (e == 0) {
+ * x = m;
+ * } else {
+ * x = 2^e-1 * (m + 2^9)
+ * }
+ *
+ * where
+ * e is the exponent value in range 0..127
+ * m is the mantissa value in range 0..511
+ */
+struct mali_c55_af_statistics {
+ __u16 intensity_stats;
+ __u16 edge_stats;
+} __attribute__((packed));
+
+/**
+ * struct mali_c55_stats_buffer - 3A statistics for the mali-c55 ISP
+ *
+ * @ae_1024bin_hist: 1024-bin frame-global pixel intensity histogram
+ * @iridix_1024bin_hist: Post-Iridix block 1024-bin histogram
+ * @ae_5bin_hists: 5-bin pixel intensity histograms for AEC
+ * @reserved1: Undefined buffer space
+ * @awb_ratios: Color balance ratios for Auto White Balance
+ * @reserved2: Undefined buffer space
+ * @af_statistics: Pixel intensity statistics for Auto Focus
+ * @reserved3: Undefined buffer space
+ *
+ * This struct describes the metering statistics space in the Mali-C55 ISP's
+ * hardware in its entirety. The space between each defined area is marked as
+ * "unknown" and may not be 0, but should not be used. The @ae_5bin_hists,
+ * @awb_ratios and @af_statistics members are arrays of statistics per-zone.
+ * The zones are arranged in the array in raster order starting from the top
+ * left corner of the image.
+ */
+
+struct mali_c55_stats_buffer {
+ struct mali_c55_ae_1024bin_hist ae_1024bin_hist;
+ struct mali_c55_ae_1024bin_hist iridix_1024bin_hist;
+ struct mali_c55_ae_5bin_hist ae_5bin_hists[MALI_C55_MAX_ZONES];
+ __u32 reserved1[14];
+ struct mali_c55_awb_average_ratios awb_ratios[MALI_C55_MAX_ZONES];
+ __u32 reserved2[14];
+ struct mali_c55_af_statistics af_statistics[MALI_C55_MAX_ZONES];
+ __u32 reserved3[15];
+} __attribute__((packed));
+
+/**
+ * enum mali_c55_param_buffer_version - Mali-C55 parameters block versioning
+ *
+ * @MALI_C55_PARAM_BUFFER_V1: First version of Mali-C55 parameters block
+ */
+enum mali_c55_param_buffer_version {
+ MALI_C55_PARAM_BUFFER_V1,
+};
+
+/**
+ * enum mali_c55_param_block_type - Enumeration of Mali-C55 parameter blocks
+ *
+ * This enumeration defines the types of Mali-C55 parameters block. Each block
+ * configures a specific processing block of the Mali-C55 ISP. The block
+ * type allows the driver to correctly interpret the parameters block data.
+ *
+ * It is the responsibility of userspace to correctly set the type of each
+ * parameters block.
+ *
+ * @MALI_C55_PARAM_BLOCK_SENSOR_OFFS: Sensor pre-shading black level offset
+ * @MALI_C55_PARAM_BLOCK_AEXP_HIST: Auto-exposure 1024-bin histogram
+ * configuration
+ * @MALI_C55_PARAM_BLOCK_AEXP_IHIST: Post-Iridix auto-exposure 1024-bin
+ * histogram configuration
+ * @MALI_C55_PARAM_BLOCK_AEXP_HIST_WEIGHTS: Auto-exposure 1024-bin histogram
+ * weighting
+ * @MALI_C55_PARAM_BLOCK_AEXP_IHIST_WEIGHTS: Post-Iridix auto-exposure 1024-bin
+ * histogram weighting
+ * @MALI_C55_PARAM_BLOCK_DIGITAL_GAIN: Digital gain
+ * @MALI_C55_PARAM_BLOCK_AWB_GAINS: Auto-white balance gains
+ * @MALI_C55_PARAM_BLOCK_AWB_CONFIG: Auto-white balance statistics config
+ * @MALI_C55_PARAM_BLOCK_AWB_GAINS_AEXP: Auto-white balance gains for AEXP-0 tap
+ * @MALI_C55_PARAM_MESH_SHADING_CONFIG : Mesh shading tables configuration
+ * @MALI_C55_PARAM_MESH_SHADING_SELECTION: Mesh shading table selection
+ */
+enum mali_c55_param_block_type {
+ MALI_C55_PARAM_BLOCK_SENSOR_OFFS,
+ MALI_C55_PARAM_BLOCK_AEXP_HIST,
+ MALI_C55_PARAM_BLOCK_AEXP_IHIST,
+ MALI_C55_PARAM_BLOCK_AEXP_HIST_WEIGHTS,
+ MALI_C55_PARAM_BLOCK_AEXP_IHIST_WEIGHTS,
+ MALI_C55_PARAM_BLOCK_DIGITAL_GAIN,
+ MALI_C55_PARAM_BLOCK_AWB_GAINS,
+ MALI_C55_PARAM_BLOCK_AWB_CONFIG,
+ MALI_C55_PARAM_BLOCK_AWB_GAINS_AEXP,
+ MALI_C55_PARAM_MESH_SHADING_CONFIG,
+ MALI_C55_PARAM_MESH_SHADING_SELECTION,
+};
+
+#define MALI_C55_PARAM_BLOCK_FL_NONE 0
+#define MALI_C55_PARAM_BLOCK_FL_DISABLED BIT(0)
+
+/**
+ * struct mali_c55_params_block_header - Mali-C55 parameter block header
+ *
+ * This structure represents the common part of all the ISP configuration
+ * blocks. Each parameters block embeds an instance of this structure type
+ * as its first member, followed by the block-specific configuration data. The
+ * driver inspects this common header to discern the block type and its size and
+ * properly handle the block content by casting it to the correct block-specific
+ * type.
+ *
+ * The @type field is one of the values enumerated by
+ * :c:type:`mali_c55_param_block_type` and specifies how the data should be
+ * interpreted by the driver. The @size field specifies the size of the
+ * parameters block and is used by the driver for validation purposes. The
+ * @flags field holds a bitmask of per-block flags MALI_C55_PARAM_BLOCK_FL_*.
+ *
+ * If userspace wants to disable an ISP block the
+ * MALI_C55_PARAM_BLOCK_FL_DISABLED bit should be set in the @flags field. In
+ * that case userspace may optionally omit the remainder of the configuration
+ * block, which will in any case be ignored by the driver. If a new
+ * configuration of an ISP block has to be applied userspace shall fully
+ * populate the ISP block and omit setting the MALI_C55_PARAM_BLOCK_FL_DISABLED
+ * bit in the @flags field.
+ *
+ * Userspace is responsible for correctly populating the parameters block header
+ * fields (@type, @flags and @size) and correctly populate the block-specific
+ * parameters.
+ *
+ * For example:
+ *
+ * .. code-block:: c
+ *
+ * void populate_sensor_offs(struct mali_c55_params_block_header *block) {
+ * block->type = MALI_C55_PARAM_BLOCK_SENSOR_OFFS;
+ * block->enabled = MALI_C55_PARAM_BLOCK_FL_NONE;
+ * block->size = sizeof(struct mali_c55_params_sensor_off_preshading);
+ *
+ * struct mali_c55_params_sensor_off_preshading *sensor_offs =
+ * (struct mali_c55_params_sensor_off_preshading *)block;
+ *
+ * sensor_offs->chan00 = offset00;
+ * sensor_offs->chan01 = offset01;
+ * sensor_offs->chan10 = offset10;
+ * sensor_offs->chan11 = offset11;
+ * }
+ *
+ * @type: The parameters block type from :c:type:`mali_c55_param_block_type`
+ * @flags: Bitmask of block flags
+ * @size: Size (in bytes) of the parameters block
+ */
+struct mali_c55_params_block_header {
+ __u16 type;
+ __u16 flags;
+ __u32 size;
+} __attribute__((aligned(8)));
+
+/**
+ * struct mali_c55_params_sensor_off_preshading - offset subtraction for each
+ * color channel
+ *
+ * Provides removal of the sensor black level from the sensor data. Separate
+ * offsets are provided for each of the four Bayer component color channels
+ * which are defaulted to R, Gr, Gb, B.
+ *
+ * header.type should be set to MALI_C55_PARAM_BLOCK_SENSOR_OFFS from
+ * :c:type:`mali_c55_param_block_type` for this block.
+ *
+ * @header: The Mali-C55 parameters block header
+ * @chan00: Offset for color channel 00 (default: R)
+ * @chan01: Offset for color channel 01 (default: Gr)
+ * @chan10: Offset for color channel 10 (default: Gb)
+ * @chan11: Offset for color channel 11 (default: B)
+ */
+struct mali_c55_params_sensor_off_preshading {
+ struct mali_c55_params_block_header header;
+ __u32 chan00;
+ __u32 chan01;
+ __u32 chan10;
+ __u32 chan11;
+};
+
+/**
+ * enum mali_c55_aexp_hist_tap_points - Tap points for the AEXP histogram
+ * @MALI_C55_AEXP_HIST_TAP_WB: After static white balance
+ * @MALI_C55_AEXP_HIST_TAP_FS: After WDR Frame Stitch
+ * @MALI_C55_AEXP_HIST_TAP_TPG: After the test pattern generator
+ */
+enum mali_c55_aexp_hist_tap_points {
+ MALI_C55_AEXP_HIST_TAP_WB = 0,
+ MALI_C55_AEXP_HIST_TAP_FS,
+ MALI_C55_AEXP_HIST_TAP_TPG,
+};
+
+/**
+ * enum mali_c55_aexp_skip_x - Horizontal pixel skipping
+ * @MALI_C55_AEXP_SKIP_X_EVERY_2ND: Collect every 2nd pixel horizontally
+ * @MALI_C55_AEXP_SKIP_X_EVERY_3RD: Collect every 3rd pixel horizontally
+ * @MALI_C55_AEXP_SKIP_X_EVERY_4TH: Collect every 4th pixel horizontally
+ * @MALI_C55_AEXP_SKIP_X_EVERY_5TH: Collect every 5th pixel horizontally
+ * @MALI_C55_AEXP_SKIP_X_EVERY_8TH: Collect every 8th pixel horizontally
+ * @MALI_C55_AEXP_SKIP_X_EVERY_9TH: Collect every 9th pixel horizontally
+ */
+enum mali_c55_aexp_skip_x {
+ MALI_C55_AEXP_SKIP_X_EVERY_2ND,
+ MALI_C55_AEXP_SKIP_X_EVERY_3RD,
+ MALI_C55_AEXP_SKIP_X_EVERY_4TH,
+ MALI_C55_AEXP_SKIP_X_EVERY_5TH,
+ MALI_C55_AEXP_SKIP_X_EVERY_8TH,
+ MALI_C55_AEXP_SKIP_X_EVERY_9TH
+};
+
+/**
+ * enum mali_c55_aexp_skip_y - Vertical pixel skipping
+ * @MALI_C55_AEXP_SKIP_Y_ALL: Collect every single pixel vertically
+ * @MALI_C55_AEXP_SKIP_Y_EVERY_2ND: Collect every 2nd pixel vertically
+ * @MALI_C55_AEXP_SKIP_Y_EVERY_3RD: Collect every 3rd pixel vertically
+ * @MALI_C55_AEXP_SKIP_Y_EVERY_4TH: Collect every 4th pixel vertically
+ * @MALI_C55_AEXP_SKIP_Y_EVERY_5TH: Collect every 5th pixel vertically
+ * @MALI_C55_AEXP_SKIP_Y_EVERY_8TH: Collect every 8th pixel vertically
+ * @MALI_C55_AEXP_SKIP_Y_EVERY_9TH: Collect every 9th pixel vertically
+ */
+enum mali_c55_aexp_skip_y {
+ MALI_C55_AEXP_SKIP_Y_ALL,
+ MALI_C55_AEXP_SKIP_Y_EVERY_2ND,
+ MALI_C55_AEXP_SKIP_Y_EVERY_3RD,
+ MALI_C55_AEXP_SKIP_Y_EVERY_4TH,
+ MALI_C55_AEXP_SKIP_Y_EVERY_5TH,
+ MALI_C55_AEXP_SKIP_Y_EVERY_8TH,
+ MALI_C55_AEXP_SKIP_Y_EVERY_9TH
+};
+
+/**
+ * enum mali_c55_aexp_row_column_offset - Start from the first or second row or
+ * column
+ * @MALI_C55_AEXP_FIRST_ROW_OR_COL: Start from the first row / column
+ * @MALI_C55_AEXP_SECOND_ROW_OR_COL: Start from the second row / column
+ */
+enum mali_c55_aexp_row_column_offset {
+ MALI_C55_AEXP_FIRST_ROW_OR_COL = 1,
+ MALI_C55_AEXP_SECOND_ROW_OR_COL = 2,
+};
+
+/**
+ * enum mali_c55_aexp_hist_plane_mode - Mode for the AEXP Histograms
+ * @MALI_C55_AEXP_HIST_COMBINED: All color planes in one 1024-bin histogram
+ * @MALI_C55_AEXP_HIST_SEPARATE: Each color plane in one 256-bin histogram with a bin width of 16
+ * @MALI_C55_AEXP_HIST_FOCUS_00: Top left plane in the first bank, rest in second bank
+ * @MALI_C55_AEXP_HIST_FOCUS_01: Top right plane in the first bank, rest in second bank
+ * @MALI_C55_AEXP_HIST_FOCUS_10: Bottom left plane in the first bank, rest in second bank
+ * @MALI_C55_AEXP_HIST_FOCUS_11: Bottom right plane in the first bank, rest in second bank
+ *
+ * In the "focus" modes statistics are collected into two 512-bin histograms
+ * with a bin width of 8. One colour plane is in the first histogram with the
+ * remainder combined into the second. The four options represent which of the
+ * four positions in a bayer pattern are the focused plane.
+ */
+enum mali_c55_aexp_hist_plane_mode {
+ MALI_C55_AEXP_HIST_COMBINED = 0,
+ MALI_C55_AEXP_HIST_SEPARATE = 1,
+ MALI_C55_AEXP_HIST_FOCUS_00 = 4,
+ MALI_C55_AEXP_HIST_FOCUS_01 = 5,
+ MALI_C55_AEXP_HIST_FOCUS_10 = 6,
+ MALI_C55_AEXP_HIST_FOCUS_11 = 7,
+};
+
+/**
+ * struct mali_c55_params_aexp_hist - configuration for AEXP metering hists
+ *
+ * This struct allows users to configure the 1024-bin AEXP histograms. Broadly
+ * speaking the parameters allow you to mask particular regions of the image and
+ * to select different kinds of histogram.
+ *
+ * The skip_x, offset_x, skip_y and offset_y fields allow users to ignore or
+ * mask pixels in the frame by their position relative to the top left pixel.
+ * First, the skip_y, offset_x and offset_y fields define which of the pixels
+ * within each 2x2 region will be counted in the statistics.
+ *
+ * If skip_y == 0 then two pixels from each covered region will be counted. If
+ * both offset_x and offset_y are zero, then the two left-most pixels in each
+ * 2x2 pixel region will be counted. Setting offset_x = 1 will discount the top
+ * left pixel and count the top right pixel. Setting offset_y = 1 will discount
+ * the bottom left pixel and count the bottom right pixel.
+ *
+ * If skip_y != 0 then only a single pixel from each region covered by the
+ * pattern will be counted. In this case offset_x controls whether the pixel
+ * that's counted is in the left (if offset_x == 0) or right (if offset_x == 1)
+ * column and offset_y controls whether the pixel that's counted is in the top
+ * (if offset_y == 0) or bottom (if offset_y == 1) row.
+ *
+ * The skip_x and skip_y fields control how the 2x2 pixel region is repeated
+ * across the image data. The first instance of the region is always in the top
+ * left of the image data. The skip_x field controls how many pixels are ignored
+ * in the x direction before the pixel masking region is repeated. The skip_y
+ * field controls how many pixels are ignored in the y direction before the
+ * pixel masking region is repeated.
+ *
+ * These fields can be used to reduce the number of pixels counted for the
+ * statistics, but it's important to be careful to configure them correctly.
+ * Some combinations of values will result in colour components from the input
+ * data being ignored entirely, for example in the following configuration:
+ *
+ * skip_x = 0
+ * offset_x = 0
+ * skip_y = 0
+ * offset_y = 0
+ *
+ * Only the R and Gb components of RGGB data that was input would be collected.
+ * Similarly in the following configuration:
+ *
+ * skip_x = 0
+ * offset_x = 0
+ * skip_y = 1
+ * offset_y = 1
+ *
+ * Only the Gb component of RGGB data that was input would be collected. To
+ * correct things such that all 4 colour components were included it would be
+ * necessary to set the skip_x and skip_y fields in a way that resulted in all
+ * four colour components being collected:
+ *
+ * skip_x = 1
+ * offset_x = 0
+ * skip_y = 1
+ * offset_y = 1
+ *
+ * header.type should be set to one of either MALI_C55_PARAM_BLOCK_AEXP_HIST or
+ * MALI_C55_PARAM_BLOCK_AEXP_IHIST from :c:type:`mali_c55_param_block_type`.
+ *
+ * @header: The Mali-C55 parameters block header
+ * @skip_x: Horizontal decimation. See enum mali_c55_aexp_skip_x
+ * @offset_x: Skip the first column, or not. See enum mali_c55_aexp_row_column_offset
+ * @skip_y: Vertical decimation. See enum mali_c55_aexp_skip_y
+ * @offset_y: Skip the first row, or not. See enum mali_c55_aexp_row_column_offset
+ * @scale_bottom: Scale pixels in bottom half of intensity range: 0=1x ,1=2x, 2=4x, 4=8x, 4=16x
+ * @scale_top: scale pixels in top half of intensity range: 0=1x ,1=2x, 2=4x, 4=8x, 4=16x
+ * @plane_mode: Plane separation mode. See enum mali_c55_aexp_hist_plane_mode
+ * @tap_point: Tap point for histogram from enum mali_c55_aexp_hist_tap_points.
+ * This parameter is unused for the post-Iridix Histogram
+ */
+struct mali_c55_params_aexp_hist {
+ struct mali_c55_params_block_header header;
+ __u8 skip_x;
+ __u8 offset_x;
+ __u8 skip_y;
+ __u8 offset_y;
+ __u8 scale_bottom;
+ __u8 scale_top;
+ __u8 plane_mode;
+ __u8 tap_point;
+};
+
+/**
+ * struct mali_c55_params_aexp_weights - Array of weights for AEXP metering
+ *
+ * This struct allows users to configure the weighting for both of the 1024-bin
+ * AEXP histograms. The pixel data collected for each zone is multiplied by the
+ * corresponding weight from this array, which may be zero if the intention is
+ * to mask off the zone entirely.
+ *
+ * header.type should be set to one of either MALI_C55_PARAM_BLOCK_AEXP_HIST_WEIGHTS
+ * or MALI_C55_PARAM_BLOCK_AEXP_IHIST_WEIGHTS from :c:type:`mali_c55_param_block_type`.
+ *
+ * @header: The Mali-C55 parameters block header
+ * @nodes_used_horiz: Number of active zones horizontally [0..15]
+ * @nodes_used_vert: Number of active zones vertically [0..15]
+ * @zone_weights: Zone weighting. Index is row*col where 0,0 is the top
+ * left zone continuing in raster order. Each zone can be
+ * weighted in the range [0..15]. The number of rows and
+ * columns is defined by @nodes_used_vert and
+ * @nodes_used_horiz
+ */
+struct mali_c55_params_aexp_weights {
+ struct mali_c55_params_block_header header;
+ __u8 nodes_used_horiz;
+ __u8 nodes_used_vert;
+ __u8 zone_weights[MALI_C55_MAX_ZONES];
+};
+
+/**
+ * struct mali_c55_params_digital_gain - Digital gain value
+ *
+ * This struct carries a digital gain value to set in the ISP.
+ *
+ * header.type should be set to MALI_C55_PARAM_BLOCK_DIGITAL_GAIN from
+ * :c:type:`mali_c55_param_block_type` for this block.
+ *
+ * @header: The Mali-C55 parameters block header
+ * @gain: The digital gain value to apply, in Q5.8 format.
+ */
+struct mali_c55_params_digital_gain {
+ struct mali_c55_params_block_header header;
+ __u16 gain;
+};
+
+/**
+ * enum mali_c55_awb_stats_mode - Statistics mode for AWB
+ * @MALI_C55_AWB_MODE_GRBR: Statistics collected as Green/Red and Blue/Red ratios
+ * @MALI_C55_AWB_MODE_RGBG: Statistics collected as Red/Green and Blue/Green ratios
+ */
+enum mali_c55_awb_stats_mode {
+ MALI_C55_AWB_MODE_GRBR = 0,
+ MALI_C55_AWB_MODE_RGBG,
+};
+
+/**
+ * struct mali_c55_params_awb_gains - Gain settings for auto white balance
+ *
+ * This struct allows users to configure the gains for auto-white balance. There
+ * are four gain settings corresponding to each colour channel in the bayer
+ * domain. Although named generically, the association between the gain applied
+ * and the colour channel is done automatically within the ISP depending on the
+ * input format, and so the following mapping always holds true::
+ *
+ * gain00 = R
+ * gain01 = Gr
+ * gain10 = Gb
+ * gain11 = B
+ *
+ * All of the gains are stored in Q4.8 format.
+ *
+ * header.type should be set to one of either MALI_C55_PARAM_BLOCK_AWB_GAINS or
+ * MALI_C55_PARAM_BLOCK_AWB_GAINS_AEXP from :c:type:`mali_c55_param_block_type`.
+ *
+ * @header: The Mali-C55 parameters block header
+ * @gain00: Multiplier for colour channel 00
+ * @gain01: Multiplier for colour channel 01
+ * @gain10: Multiplier for colour channel 10
+ * @gain11: Multiplier for colour channel 11
+ */
+struct mali_c55_params_awb_gains {
+ struct mali_c55_params_block_header header;
+ __u16 gain00;
+ __u16 gain01;
+ __u16 gain10;
+ __u16 gain11;
+};
+
+/**
+ * enum mali_c55_params_awb_tap_points - Tap points for the AWB statistics
+ * @MALI_C55_AWB_STATS_TAP_PF: Immediately after the Purple Fringe block
+ * @MALI_C55_AWB_STATS_TAP_CNR: Immediately after the CNR block
+ */
+enum mali_c55_params_awb_tap_points {
+ MALI_C55_AWB_STATS_TAP_PF = 0,
+ MALI_C55_AWB_STATS_TAP_CNR,
+};
+
+/**
+ * struct mali_c55_params_awb_config - Stats settings for auto-white balance
+ *
+ * This struct allows the configuration of the statistics generated for auto
+ * white balance. Pixel intensity limits can be set to exclude overly bright or
+ * dark regions of an image from the statistics entirely. Colour ratio minima
+ * and maxima can be set to discount pixels who's ratios fall outside the
+ * defined boundaries; there are two sets of registers to do this - the
+ * "min/max" ratios which bound a region and the "high/low" ratios which further
+ * trim the upper and lower ratios. For example with the boundaries configured
+ * as follows, only pixels whos colour ratios falls into the region marked "A"
+ * would be counted::
+ *
+ * cr_high
+ * 2.0 | |
+ * | cb_max --> _________________________v_____
+ * 1.8 | | \ |
+ * | | \ |
+ * 1.6 | | \ |
+ * | | \ |
+ * c 1.4 | cb_low -->|\ A \|<-- cb_high
+ * b | | \ |
+ * 1.2 | | \ |
+ * r | | \ |
+ * a 1.0 | cb_min --> |____\_________________________|
+ * t | ^ ^ ^
+ * i 0.8 | | | |
+ * o | cr_min | cr_max
+ * s 0.6 | |
+ * | cr_low
+ * 0.4 |
+ * |
+ * 0.2 |
+ * |
+ * 0.0 |_______________________________________________________________
+ * 0.0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0
+ * cr ratios
+ *
+ * header.type should be set to MALI_C55_PARAM_BLOCK_AWB_CONFIG from
+ * :c:type:`mali_c55_param_block_type` for this block.
+ *
+ * @header: The Mali-C55 parameters block header
+ * @tap_point: The tap point from enum mali_c55_params_awb_tap_points
+ * @stats_mode: AWB statistics collection mode, see :c:type:`mali_c55_awb_stats_mode`
+ * @white_level: Upper pixel intensity (I.E. raw pixel values) limit
+ * @black_level: Lower pixel intensity (I.E. raw pixel values) limit
+ * @cr_max: Maximum R/G ratio (Q4.8 format)
+ * @cr_min: Minimum R/G ratio (Q4.8 format)
+ * @cb_max: Maximum B/G ratio (Q4.8 format)
+ * @cb_min: Minimum B/G ratio (Q4.8 format)
+ * @nodes_used_horiz: Number of active zones horizontally [0..15]
+ * @nodes_used_vert: Number of active zones vertically [0..15]
+ * @cr_high: R/G ratio trim high (Q4.8 format)
+ * @cr_low: R/G ratio trim low (Q4.8 format)
+ * @cb_high: B/G ratio trim high (Q4.8 format)
+ * @cb_low: B/G ratio trim low (Q4.8 format)
+ */
+struct mali_c55_params_awb_config {
+ struct mali_c55_params_block_header header;
+ __u8 tap_point;
+ __u8 stats_mode;
+ __u16 white_level;
+ __u16 black_level;
+ __u16 cr_max;
+ __u16 cr_min;
+ __u16 cb_max;
+ __u16 cb_min;
+ __u8 nodes_used_horiz;
+ __u8 nodes_used_vert;
+ __u16 cr_high;
+ __u16 cr_low;
+ __u16 cb_high;
+ __u16 cb_low;
+};
+
+#define MALI_C55_NUM_MESH_SHADING_ELEMENTS 3072
+
+/**
+ * struct mali_c55_params_mesh_shading_config - Mesh shading configuration
+ *
+ * The mesh shading correction module allows programming a separate table of
+ * either 16x16 or 32x32 node coefficients for 3 different light sources. The
+ * final correction coefficients applied are computed by blending the
+ * coefficients from two tables together.
+ *
+ * A page of 1024 32-bit integers is associated to each colour channel, with
+ * pages stored consecutively in memory. Each 32-bit integer packs 3 8-bit
+ * correction coefficients for a single node, one for each of the three light
+ * sources. The 8 most significant bits are unused. The following table
+ * describes the layout::
+ *
+ * +----------- Page (Colour Plane) 0 -------------+
+ * | @mesh[i] | Mesh Point | Bits | Light Source |
+ * +-----------+------------+-------+--------------+
+ * | 0 | 0,0 | 16,23 | LS2 |
+ * | | | 08-15 | LS1 |
+ * | | | 00-07 | LS0 |
+ * +-----------+------------+-------+--------------+
+ * | 1 | 0,1 | 16,23 | LS2 |
+ * | | | 08-15 | LS1 |
+ * | | | 00-07 | LS0 |
+ * +-----------+------------+-------+--------------+
+ * | ... | ... | ... | ... |
+ * +-----------+------------+-------+--------------+
+ * | 1023 | 31,31 | 16,23 | LS2 |
+ * | | | 08-15 | LS1 |
+ * | | | 00-07 | LS0 |
+ * +----------- Page (Colour Plane) 1 -------------+
+ * | @mesh[i] | Mesh Point | Bits | Light Source |
+ * +-----------+------------+-------+--------------+
+ * | 1024 | 0,0 | 16,23 | LS2 |
+ * | | | 08-15 | LS1 |
+ * | | | 00-07 | LS0 |
+ * +-----------+------------+-------+--------------+
+ * | 1025 | 0,1 | 16,23 | LS2 |
+ * | | | 08-15 | LS1 |
+ * | | | 00-07 | LS0 |
+ * +-----------+------------+-------+--------------+
+ * | ... | ... | ... | ... |
+ * +-----------+------------+-------+--------------+
+ * | 2047 | 31,31 | 16,23 | LS2 |
+ * | | | 08-15 | LS1 |
+ * | | | 00-07 | LS0 |
+ * +----------- Page (Colour Plane) 2 -------------+
+ * | @mesh[i] | Mesh Point | Bits | Light Source |
+ * +-----------+------------+-------+--------------+
+ * | 2048 | 0,0 | 16,23 | LS2 |
+ * | | | 08-15 | LS1 |
+ * | | | 00-07 | LS0 |
+ * +-----------+------------+-------+--------------+
+ * | 2049 | 0,1 | 16,23 | LS2 |
+ * | | | 08-15 | LS1 |
+ * | | | 00-07 | LS0 |
+ * +-----------+------------+-------+--------------+
+ * | ... | ... | ... | ... |
+ * +-----------+------------+-------+--------------+
+ * | 3071 | 31,31 | 16,23 | LS2 |
+ * | | | 08-15 | LS1 |
+ * | | | 00-07 | LS0 |
+ * +-----------+------------+-------+--------------+
+ *
+ * The @mesh_scale member determines the precision and minimum and maximum gain.
+ * For example if @mesh_scale is 0 and therefore selects 0 - 2x gain, a value of
+ * 0 in a coefficient means 0.0 gain, a value of 128 means 1.0 gain and 255
+ * means 2.0 gain.
+ *
+ * header.type should be set to MALI_C55_PARAM_MESH_SHADING_CONFIG from
+ * :c:type:`mali_c55_param_block_type` for this block.
+ *
+ * @header: The Mali-C55 parameters block header
+ * @mesh_show: Output the mesh data rather than image data
+ * @mesh_scale: Set the precision and maximum gain range of mesh shading
+ * - 0 = 0-2x gain
+ * - 1 = 0-4x gain
+ * - 2 = 0-8x gain
+ * - 3 = 0-16x gain
+ * - 4 = 1-2x gain
+ * - 5 = 1-3x gain
+ * - 6 = 1-5x gain
+ * - 7 = 1-9x gain
+ * @mesh_page_r: Mesh page select for red colour plane [0..2]
+ * @mesh_page_g: Mesh page select for green colour plane [0..2]
+ * @mesh_page_b: Mesh page select for blue colour plane [0..2]
+ * @mesh_width: Number of horizontal nodes minus 1 [15,31]
+ * @mesh_height: Number of vertical nodes minus 1 [15,31]
+ * @mesh: Mesh shading correction tables
+ */
+struct mali_c55_params_mesh_shading_config {
+ struct mali_c55_params_block_header header;
+ __u8 mesh_show;
+ __u8 mesh_scale;
+ __u8 mesh_page_r;
+ __u8 mesh_page_g;
+ __u8 mesh_page_b;
+ __u8 mesh_width;
+ __u8 mesh_height;
+ __u32 mesh[MALI_C55_NUM_MESH_SHADING_ELEMENTS];
+};
+
+/** enum mali_c55_params_mesh_alpha_bank - Mesh shading table bank selection
+ * @MALI_C55_MESH_ALPHA_BANK_LS0_AND_LS1 - Select Light Sources 0 and 1
+ * @MALI_C55_MESH_ALPHA_BANK_LS1_AND_LS2 - Select Light Sources 1 and 2
+ * @MALI_C55_MESH_ALPHA_BANK_LS0_AND_LS2 - Select Light Sources 0 and 2
+ */
+enum mali_c55_params_mesh_alpha_bank {
+ MALI_C55_MESH_ALPHA_BANK_LS0_AND_LS1 = 0,
+ MALI_C55_MESH_ALPHA_BANK_LS1_AND_LS2 = 1,
+ MALI_C55_MESH_ALPHA_BANK_LS0_AND_LS2 = 4
+};
+
+/**
+ * struct mali_c55_params_mesh_shading_selection - Mesh table selection
+ *
+ * The module computes the final correction coefficients by blending the ones
+ * from two light source tables, which are selected (independently for each
+ * colour channel) by the @mesh_alpha_bank_r/g/b fields.
+ *
+ * The final blended coefficients for each node are calculated using the
+ * following equation:
+ *
+ * Final coefficient = (a * LS\ :sub:`b`\ + (256 - a) * LS\ :sub:`a`\) / 256
+ *
+ * Where a is the @mesh_alpha_r/g/b value, and LS\ :sub:`a`\ and LS\ :sub:`b`\
+ * are the node cofficients for the two tables selected by the
+ * @mesh_alpha_bank_r/g/b value.
+ *
+ * The scale of the applied correction may also be controlled by tuning the
+ * @mesh_strength member. This is a modifier to the final coefficients which can
+ * be used to globally reduce the gains applied.
+ *
+ * header.type should be set to MALI_C55_PARAM_MESH_SHADING_SELECTION from
+ * :c:type:`mali_c55_param_block_type` for this block.
+ *
+ * @header: The Mali-C55 parameters block header
+ * @mesh_alpha_bank_r: Red mesh table select (c:type:`enum mali_c55_params_mesh_alpha_bank`)
+ * @mesh_alpha_bank_g: Green mesh table select (c:type:`enum mali_c55_params_mesh_alpha_bank`)
+ * @mesh_alpha_bank_b: Blue mesh table select (c:type:`enum mali_c55_params_mesh_alpha_bank`)
+ * @mesh_alpha_r: Blend coefficient for R [0..255]
+ * @mesh_alpha_g: Blend coefficient for G [0..255]
+ * @mesh_alpha_b: Blend coefficient for B [0..255]
+ * @mesh_strength: Mesh strength in Q4.12 format [0..4096]
+ */
+struct mali_c55_params_mesh_shading_selection {
+ struct mali_c55_params_block_header header;
+ __u8 mesh_alpha_bank_r;
+ __u8 mesh_alpha_bank_g;
+ __u8 mesh_alpha_bank_b;
+ __u8 mesh_alpha_r;
+ __u8 mesh_alpha_g;
+ __u8 mesh_alpha_b;
+ __u16 mesh_strength;
+};
+
+/**
+ * define MALI_C55_PARAMS_MAX_SIZE - Maximum size of all Mali C55 Parameters
+ *
+ * Though the parameters for the Mali-C55 are passed as optional blocks, the
+ * driver still needs to know the absolute maximum size so that it can allocate
+ * a buffer sized appropriately to accommodate userspace attempting to set all
+ * possible parameters in a single frame.
+ *
+ * Some structs are in this list multiple times. Where that's the case, it just
+ * reflects the fact that the same struct can be used with multiple different
+ * header types from :c:type:`mali_c55_param_block_type`.
+ */
+#define MALI_C55_PARAMS_MAX_SIZE \
+ (sizeof(struct mali_c55_params_sensor_off_preshading) + \
+ sizeof(struct mali_c55_params_aexp_hist) + \
+ sizeof(struct mali_c55_params_aexp_weights) + \
+ sizeof(struct mali_c55_params_aexp_hist) + \
+ sizeof(struct mali_c55_params_aexp_weights) + \
+ sizeof(struct mali_c55_params_digital_gain) + \
+ sizeof(struct mali_c55_params_awb_gains) + \
+ sizeof(struct mali_c55_params_awb_config) + \
+ sizeof(struct mali_c55_params_awb_gains) + \
+ sizeof(struct mali_c55_params_mesh_shading_config) + \
+ sizeof(struct mali_c55_params_mesh_shading_selection))
+
+/**
+ * struct mali_c55_params_buffer - 3A configuration parameters
+ *
+ * This struct contains the configuration parameters of the Mali-C55 ISP
+ * algorithms, serialized by userspace into a data buffer. Each configuration
+ * parameter block is represented by a block-specific structure which contains a
+ * :c:type:`mali_c55_params_block_header` entry as first member. Userspace
+ * populates the @data buffer with configuration parameters for the blocks that
+ * it intends to configure. As a consequence, the data buffer effective size
+ * changes according to the number of ISP blocks that userspace intends to
+ * configure.
+ *
+ * The parameters buffer is versioned by the @version field to allow modifying
+ * and extending its definition. Userspace shall populate the @version field to
+ * inform the driver about the version it intends to use. The driver will parse
+ * and handle the @data buffer according to the data layout specific to the
+ * indicated version and return an error if the desired version is not
+ * supported.
+ *
+ * For each ISP block that userspace wants to configure, a block-specific
+ * structure is appended to the @data buffer, one after the other without gaps
+ * in between nor overlaps. Userspace shall populate the @total_size field with
+ * the effective size, in bytes, of the @data buffer.
+ *
+ * The expected memory layout of the parameters buffer is::
+ *
+ * +-------------------- struct mali_c55_params_buffer ------------------+
+ * | version = MALI_C55_PARAM_BUFFER_V1; |
+ * | total_size = sizeof(struct mali_c55_params_sensor_off_preshading) |
+ * | sizeof(struct mali_c55_params_aexp_hist); |
+ * | +------------------------- data ---------------------------------+ |
+ * | | +--------- struct mali_c55_params_sensor_off_preshading ------+ | |
+ * | | | +-------- struct mali_c55_params_block_header header -----+ | | |
+ * | | | | type = MALI_C55_PARAM_BLOCK_SENSOR_OFFS; | | | |
+ * | | | | flags = MALI_C55_PARAM_BLOCK_FL_NONE; | | | |
+ * | | | | size = | | | |
+ * | | | | sizeof(struct mali_c55_params_sensor_off_preshading);| | | |
+ * | | | +---------------------------------------------------------+ | | |
+ * | | | chan00 = ...; | | |
+ * | | | chan01 = ...; | | |
+ * | | | chan10 = ...; | | |
+ * | | | chan11 = ...; | | |
+ * | | +------------ struct mali_c55_params_aexp_hist ---------------+ | |
+ * | | | +-------- struct mali_c55_params_block_header header -----+ | | |
+ * | | | | type = MALI_C55_PARAM_BLOCK_AEXP_HIST; | | | |
+ * | | | | flags = MALI_C55_PARAM_BLOCK_FL_NONE; | | | |
+ * | | | | size = sizeof(struct mali_c55_params_aexp_hist); | | | |
+ * | | | +---------------------------------------------------------+ | | |
+ * | | | skip_x = ...; | | |
+ * | | | offset_x = ...; | | |
+ * | | | skip_y = ...; | | |
+ * | | | offset_y = ...; | | |
+ * | | | scale_bottom = ...; | | |
+ * | | | scale_top = ...; | | |
+ * | | | plane_mode = ...; | | |
+ * | | | tap_point = ...; | | |
+ * | | +-------------------------------------------------------------+ | |
+ * | +-----------------------------------------------------------------+ |
+ * +---------------------------------------------------------------------+
+ *
+ * @version: The version from :c:type:`mali_c55_param_buffer_version`
+ * @total_size: The Mali-C55 configuration data effective size, excluding this
+ * header
+ * @data: The Mali-C55 configuration blocks data
+ */
+struct mali_c55_params_buffer {
+ __u8 version;
+ __u32 total_size;
+ __u8 data[MALI_C55_PARAMS_MAX_SIZE];
+};
+
+#endif /* __UAPI_MALI_C55_CONFIG_H */
diff --git a/include/linux/media-bus-format.h b/include/linux/media-bus-format.h
index 0dfc11ee..bf467168 100644
--- a/include/linux/media-bus-format.h
+++ b/include/linux/media-bus-format.h
@@ -34,7 +34,7 @@
#define MEDIA_BUS_FMT_FIXED 0x0001
-/* RGB - next is 0x101e */
+/* RGB - next is 0x1027 */
#define MEDIA_BUS_FMT_RGB444_1X12 0x1016
#define MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE 0x1001
#define MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE 0x1002
@@ -46,8 +46,12 @@
#define MEDIA_BUS_FMT_RGB565_2X8_BE 0x1007
#define MEDIA_BUS_FMT_RGB565_2X8_LE 0x1008
#define MEDIA_BUS_FMT_RGB666_1X18 0x1009
+#define MEDIA_BUS_FMT_RGB666_2X9_BE 0x1025
+#define MEDIA_BUS_FMT_BGR666_1X18 0x1023
#define MEDIA_BUS_FMT_RBG888_1X24 0x100e
#define MEDIA_BUS_FMT_RGB666_1X24_CPADHI 0x1015
+#define MEDIA_BUS_FMT_BGR666_1X24_CPADHI 0x1024
+#define MEDIA_BUS_FMT_RGB565_1X24_CPADHI 0x1022
#define MEDIA_BUS_FMT_RGB666_1X7X3_SPWG 0x1010
#define MEDIA_BUS_FMT_BGR888_1X24 0x1013
#define MEDIA_BUS_FMT_BGR888_3X8 0x101b
@@ -59,13 +63,18 @@
#define MEDIA_BUS_FMT_RGB888_3X8_DELTA 0x101d
#define MEDIA_BUS_FMT_RGB888_1X7X4_SPWG 0x1011
#define MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA 0x1012
+#define MEDIA_BUS_FMT_RGB666_1X30_CPADLO 0x101e
+#define MEDIA_BUS_FMT_RGB888_1X30_CPADLO 0x101f
#define MEDIA_BUS_FMT_ARGB8888_1X32 0x100d
#define MEDIA_BUS_FMT_RGB888_1X32_PADHI 0x100f
#define MEDIA_BUS_FMT_RGB101010_1X30 0x1018
+#define MEDIA_BUS_FMT_RGB666_1X36_CPADLO 0x1020
+#define MEDIA_BUS_FMT_RGB888_1X36_CPADLO 0x1021
#define MEDIA_BUS_FMT_RGB121212_1X36 0x1019
#define MEDIA_BUS_FMT_RGB161616_1X48 0x101a
+#define MEDIA_BUS_FMT_RGB202020_1X60 0x1026
-/* YUV (including grey) - next is 0x202e */
+/* YUV (including grey) - next is 0x202f */
#define MEDIA_BUS_FMT_Y8_1X8 0x2001
#define MEDIA_BUS_FMT_UV8_1X8 0x2015
#define MEDIA_BUS_FMT_UYVY8_1_5X8 0x2002
@@ -88,6 +97,7 @@
#define MEDIA_BUS_FMT_YUYV12_2X12 0x201e
#define MEDIA_BUS_FMT_YVYU12_2X12 0x201f
#define MEDIA_BUS_FMT_Y14_1X14 0x202d
+#define MEDIA_BUS_FMT_Y16_1X16 0x202e
#define MEDIA_BUS_FMT_UYVY8_1X16 0x200f
#define MEDIA_BUS_FMT_VYUY8_1X16 0x2010
#define MEDIA_BUS_FMT_YUYV8_1X16 0x2011
@@ -112,7 +122,7 @@
#define MEDIA_BUS_FMT_YUV16_1X48 0x202a
#define MEDIA_BUS_FMT_UYYVYY16_0_5X48 0x202b
-/* Bayer - next is 0x3021 */
+/* Bayer - next is 0x3025 */
#define MEDIA_BUS_FMT_SBGGR8_1X8 0x3001
#define MEDIA_BUS_FMT_SGBRG8_1X8 0x3013
#define MEDIA_BUS_FMT_SGRBG8_1X8 0x3002
@@ -145,6 +155,10 @@
#define MEDIA_BUS_FMT_SGBRG16_1X16 0x301e
#define MEDIA_BUS_FMT_SGRBG16_1X16 0x301f
#define MEDIA_BUS_FMT_SRGGB16_1X16 0x3020
+#define MEDIA_BUS_FMT_SBGGR20_1X20 0x3021
+#define MEDIA_BUS_FMT_SGBRG20_1X20 0x3022
+#define MEDIA_BUS_FMT_SGRBG20_1X20 0x3023
+#define MEDIA_BUS_FMT_SRGGB20_1X20 0x3024
/* JPEG compressed formats - next is 0x4002 */
#define MEDIA_BUS_FMT_JPEG_1X8 0x4001
@@ -165,4 +179,17 @@
*/
#define MEDIA_BUS_FMT_METADATA_FIXED 0x7001
+/* Generic line based metadata formats for serial buses. Next is 0x8008. */
+#define MEDIA_BUS_FMT_META_8 0x8001
+#define MEDIA_BUS_FMT_META_10 0x8002
+#define MEDIA_BUS_FMT_META_12 0x8003
+#define MEDIA_BUS_FMT_META_14 0x8004
+#define MEDIA_BUS_FMT_META_16 0x8005
+#define MEDIA_BUS_FMT_META_20 0x8006
+#define MEDIA_BUS_FMT_META_24 0x8007
+
+/* Specific metadata formats. Next is 0x9003. */
+#define MEDIA_BUS_FMT_CCS_EMBEDDED 0x9001
+#define MEDIA_BUS_FMT_OV2740_EMBEDDED 0x9002
+
#endif /* __LINUX_MEDIA_BUS_FORMAT_H */
diff --git a/include/linux/media.h b/include/linux/media.h
index 17432318..4a733b9b 100644
--- a/include/linux/media.h
+++ b/include/linux/media.h
@@ -20,7 +20,6 @@
#ifndef __LINUX_MEDIA_H
#define __LINUX_MEDIA_H
-#include <stdint.h>
#include <linux/ioctl.h>
#include <linux/types.h>
@@ -141,8 +140,8 @@ struct media_device_info {
#define MEDIA_ENT_F_DV_ENCODER (MEDIA_ENT_F_BASE + 0x6002)
/* Entity flags */
-#define MEDIA_ENT_FL_DEFAULT (1 << 0)
-#define MEDIA_ENT_FL_CONNECTOR (1 << 1)
+#define MEDIA_ENT_FL_DEFAULT (1U << 0)
+#define MEDIA_ENT_FL_CONNECTOR (1U << 1)
/* OR with the entity id value to find the next entity */
#define MEDIA_ENT_ID_FLAG_NEXT (1U << 31)
@@ -204,9 +203,10 @@ struct media_entity_desc {
};
};
-#define MEDIA_PAD_FL_SINK (1 << 0)
-#define MEDIA_PAD_FL_SOURCE (1 << 1)
-#define MEDIA_PAD_FL_MUST_CONNECT (1 << 2)
+#define MEDIA_PAD_FL_SINK (1U << 0)
+#define MEDIA_PAD_FL_SOURCE (1U << 1)
+#define MEDIA_PAD_FL_MUST_CONNECT (1U << 2)
+#define MEDIA_PAD_FL_INTERNAL (1U << 3)
struct media_pad_desc {
__u32 entity; /* entity ID */
@@ -215,13 +215,14 @@ struct media_pad_desc {
__u32 reserved[2];
};
-#define MEDIA_LNK_FL_ENABLED (1 << 0)
-#define MEDIA_LNK_FL_IMMUTABLE (1 << 1)
-#define MEDIA_LNK_FL_DYNAMIC (1 << 2)
+#define MEDIA_LNK_FL_ENABLED (1U << 0)
+#define MEDIA_LNK_FL_IMMUTABLE (1U << 1)
+#define MEDIA_LNK_FL_DYNAMIC (1U << 2)
#define MEDIA_LNK_FL_LINK_TYPE (0xf << 28)
-# define MEDIA_LNK_FL_DATA_LINK (0 << 28)
-# define MEDIA_LNK_FL_INTERFACE_LINK (1 << 28)
+# define MEDIA_LNK_FL_DATA_LINK (0U << 28)
+# define MEDIA_LNK_FL_INTERFACE_LINK (1U << 28)
+# define MEDIA_LNK_FL_ANCILLARY_LINK (2U << 28)
struct media_link_desc {
struct media_pad_desc source;
@@ -276,7 +277,7 @@ struct media_links_enum {
* struct media_device_info.
*/
#define MEDIA_V2_ENTITY_HAS_FLAGS(media_version) \
- ((media_version) >= ((4 << 16) | (19 << 8) | 0))
+ ((media_version) >= ((4U << 16) | (19U << 8) | 0U))
struct media_v2_entity {
__u32 id;
@@ -311,7 +312,7 @@ struct media_v2_interface {
* struct media_device_info.
*/
#define MEDIA_V2_PAD_HAS_INDEX(media_version) \
- ((media_version) >= ((4 << 16) | (19 << 8) | 0))
+ ((media_version) >= ((4U << 16) | (19U << 8) | 0U))
struct media_v2_pad {
__u32 id;
@@ -414,7 +415,7 @@ struct media_v2_topology {
#define MEDIA_INTF_T_ALSA_TIMER (MEDIA_INTF_T_ALSA_BASE + 7)
/* Obsolete symbol for media_version, no longer used in the kernel */
-#define MEDIA_API_VERSION ((0 << 16) | (1 << 8) | 0)
+#define MEDIA_API_VERSION ((0U << 16) | (1U << 8) | 0U)
#endif /* __LINUX_MEDIA_H */
diff --git a/include/linux/rkisp1-config.h b/include/linux/rkisp1-config.h
index 1b14c230..edbc6cb6 100644
--- a/include/linux/rkisp1-config.h
+++ b/include/linux/rkisp1-config.h
@@ -15,7 +15,7 @@
#define RKISP1_CIF_ISP_MODULE_BLS (1U << 1)
/* Sensor De-gamma */
#define RKISP1_CIF_ISP_MODULE_SDG (1U << 2)
-/* Histogram */
+/* Histogram statistics configuration */
#define RKISP1_CIF_ISP_MODULE_HST (1U << 3)
/* Lens Shade Control */
#define RKISP1_CIF_ISP_MODULE_LSC (1U << 4)
@@ -31,13 +31,13 @@
#define RKISP1_CIF_ISP_MODULE_GOC (1U << 9)
/* Color Processing */
#define RKISP1_CIF_ISP_MODULE_CPROC (1U << 10)
-/* Auto Focus Control */
+/* Auto Focus Control statistics configuration */
#define RKISP1_CIF_ISP_MODULE_AFC (1U << 11)
-/* Auto White Balancing */
+/* Auto White Balancing statistics configuration */
#define RKISP1_CIF_ISP_MODULE_AWB (1U << 12)
/* Image Effect */
#define RKISP1_CIF_ISP_MODULE_IE (1U << 13)
-/* Auto Exposure Control */
+/* Auto Exposure Control statistics configuration */
#define RKISP1_CIF_ISP_MODULE_AEC (1U << 14)
/* Wide Dynamic Range */
#define RKISP1_CIF_ISP_MODULE_WDR (1U << 15)
@@ -117,7 +117,46 @@
/*
* Defect Pixel Cluster Correction
*/
-#define RKISP1_CIF_ISP_DPCC_METHODS_MAX 3
+#define RKISP1_CIF_ISP_DPCC_METHODS_MAX 3
+
+#define RKISP1_CIF_ISP_DPCC_MODE_STAGE1_ENABLE (1U << 2)
+
+#define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_INCL_G_CENTER (1U << 0)
+#define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_INCL_RB_CENTER (1U << 1)
+#define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_G_3X3 (1U << 2)
+#define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_RB_3X3 (1U << 3)
+
+/* 0-2 for sets 1-3 */
+#define RKISP1_CIF_ISP_DPCC_SET_USE_STAGE1_USE_SET(n) ((n) << 0)
+#define RKISP1_CIF_ISP_DPCC_SET_USE_STAGE1_USE_FIX_SET (1U << 3)
+
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_PG_GREEN_ENABLE (1U << 0)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_LC_GREEN_ENABLE (1U << 1)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RO_GREEN_ENABLE (1U << 2)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RND_GREEN_ENABLE (1U << 3)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RG_GREEN_ENABLE (1U << 4)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_PG_RED_BLUE_ENABLE (1U << 8)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_LC_RED_BLUE_ENABLE (1U << 9)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RO_RED_BLUE_ENABLE (1U << 10)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RND_RED_BLUE_ENABLE (1U << 11)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RG_RED_BLUE_ENABLE (1U << 12)
+
+#define RKISP1_CIF_ISP_DPCC_LINE_THRESH_G(v) ((v) << 0)
+#define RKISP1_CIF_ISP_DPCC_LINE_THRESH_RB(v) ((v) << 8)
+#define RKISP1_CIF_ISP_DPCC_LINE_MAD_FAC_G(v) ((v) << 0)
+#define RKISP1_CIF_ISP_DPCC_LINE_MAD_FAC_RB(v) ((v) << 8)
+#define RKISP1_CIF_ISP_DPCC_PG_FAC_G(v) ((v) << 0)
+#define RKISP1_CIF_ISP_DPCC_PG_FAC_RB(v) ((v) << 8)
+#define RKISP1_CIF_ISP_DPCC_RND_THRESH_G(v) ((v) << 0)
+#define RKISP1_CIF_ISP_DPCC_RND_THRESH_RB(v) ((v) << 8)
+#define RKISP1_CIF_ISP_DPCC_RG_FAC_G(v) ((v) << 0)
+#define RKISP1_CIF_ISP_DPCC_RG_FAC_RB(v) ((v) << 8)
+
+#define RKISP1_CIF_ISP_DPCC_RO_LIMITS_n_G(n, v) ((v) << ((n) * 4))
+#define RKISP1_CIF_ISP_DPCC_RO_LIMITS_n_RB(n, v) ((v) << ((n) * 4 + 2))
+
+#define RKISP1_CIF_ISP_DPCC_RND_OFFS_n_G(n, v) ((v) << ((n) * 4))
+#define RKISP1_CIF_ISP_DPCC_RND_OFFS_n_RB(n, v) ((v) << ((n) * 4 + 2))
/*
* Denoising pre filter
@@ -126,6 +165,11 @@
#define RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS 6
/*
+ * Compand
+ */
+#define RKISP1_CIF_ISP_COMPAND_NUM_POINTS 64
+
+/*
* Measurement types
*/
#define RKISP1_CIF_ISP_STAT_AWB (1U << 0)
@@ -136,16 +180,21 @@
/**
* enum rkisp1_cif_isp_version - ISP variants
*
- * @RKISP1_V10: used at least in rk3288 and rk3399
- * @RKISP1_V11: declared in the original vendor code, but not used
- * @RKISP1_V12: used at least in rk3326 and px30
- * @RKISP1_V13: used at least in rk1808
+ * @RKISP1_V10: Used at least in RK3288 and RK3399.
+ * @RKISP1_V11: Declared in the original vendor code, but not used. Same number
+ * of entries in grids and histogram as v10.
+ * @RKISP1_V12: Used at least in RK3326 and PX30.
+ * @RKISP1_V13: Used at least in RK1808. Same number of entries in grids and
+ * histogram as v12.
+ * @RKISP1_V_IMX8MP: Used in at least i.MX8MP. Same number of entries in grids
+ * and histogram as v10.
*/
enum rkisp1_cif_isp_version {
RKISP1_V10 = 10,
RKISP1_V11,
RKISP1_V12,
RKISP1_V13,
+ RKISP1_V_IMX8MP,
};
enum rkisp1_cif_isp_histogram_mode {
@@ -249,16 +298,20 @@ struct rkisp1_cif_isp_bls_config {
};
/**
- * struct rkisp1_cif_isp_dpcc_methods_config - Methods Configuration used by DPCC
+ * struct rkisp1_cif_isp_dpcc_methods_config - DPCC methods set configuration
*
- * Methods Configuration used by Defect Pixel Cluster Correction
+ * This structure stores the configuration of one set of methods for the DPCC
+ * algorithm. Multiple methods can be selected in each set (independently for
+ * the Green and Red/Blue components) through the @method field, the result is
+ * the logical AND of all enabled methods. The remaining fields set thresholds
+ * and factors for each method.
*
- * @method: Method enable bits
- * @line_thresh: Line threshold
- * @line_mad_fac: Line MAD factor
- * @pg_fac: Peak gradient factor
- * @rnd_thresh: Rank Neighbor Difference threshold
- * @rg_fac: Rank gradient factor
+ * @method: Method enable bits (RKISP1_CIF_ISP_DPCC_METHODS_SET_*)
+ * @line_thresh: Line threshold (RKISP1_CIF_ISP_DPCC_LINE_THRESH_*)
+ * @line_mad_fac: Line Mean Absolute Difference factor (RKISP1_CIF_ISP_DPCC_LINE_MAD_FAC_*)
+ * @pg_fac: Peak gradient factor (RKISP1_CIF_ISP_DPCC_PG_FAC_*)
+ * @rnd_thresh: Rank Neighbor Difference threshold (RKISP1_CIF_ISP_DPCC_RND_THRESH_*)
+ * @rg_fac: Rank gradient factor (RKISP1_CIF_ISP_DPCC_RG_FAC_*)
*/
struct rkisp1_cif_isp_dpcc_methods_config {
__u32 method;
@@ -272,14 +325,16 @@ struct rkisp1_cif_isp_dpcc_methods_config {
/**
* struct rkisp1_cif_isp_dpcc_config - Configuration used by DPCC
*
- * Configuration used by Defect Pixel Cluster Correction
+ * Configuration used by Defect Pixel Cluster Correction. Three sets of methods
+ * can be configured and selected through the @set_use field. The result is the
+ * logical OR of all enabled sets.
*
- * @mode: dpcc output mode
- * @output_mode: whether use hard coded methods
- * @set_use: stage1 methods set
- * @methods: methods config
- * @ro_limits: rank order limits
- * @rnd_offs: differential rank offsets for rank neighbor difference
+ * @mode: DPCC mode (RKISP1_CIF_ISP_DPCC_MODE_*)
+ * @output_mode: Interpolation output mode (RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_*)
+ * @set_use: Methods sets selection (RKISP1_CIF_ISP_DPCC_SET_USE_*)
+ * @methods: Methods sets configuration
+ * @ro_limits: Rank order limits (RKISP1_CIF_ISP_DPCC_RO_LIMITS_*)
+ * @rnd_offs: Differential rank offsets for rank neighbor difference (RKISP1_CIF_ISP_DPCC_RND_OFFS_*)
*/
struct rkisp1_cif_isp_dpcc_config {
__u32 mode;
@@ -411,7 +466,7 @@ struct rkisp1_cif_isp_cproc_config {
};
/**
- * struct rkisp1_cif_isp_awb_meas_config - Configuration used by auto white balance
+ * struct rkisp1_cif_isp_awb_meas_config - Configuration for the AWB statistics
*
* @awb_mode: the awb meas mode. From enum rkisp1_cif_isp_awb_mode_type.
* @awb_wnd: white balance measurement window (in pixels)
@@ -539,10 +594,9 @@ enum rkisp1_cif_isp_goc_mode {
* as is reported by the hw_revision field of the struct media_device_info
* that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
*
- * Versions <= V11 have RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10
- * entries, versions >= V12 have RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12
- * entries. RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES is equal to the maximum
- * of the two.
+ * V10 has RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10 entries, V12 has
+ * RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12 entries.
+ * RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES is equal to the maximum of the two.
*/
struct rkisp1_cif_isp_goc_config {
__u32 mode;
@@ -550,7 +604,7 @@ struct rkisp1_cif_isp_goc_config {
};
/**
- * struct rkisp1_cif_isp_hst_config - Configuration used by Histogram
+ * struct rkisp1_cif_isp_hst_config - Configuration for Histogram statistics
*
* @mode: histogram mode (from enum rkisp1_cif_isp_histogram_mode)
* @histogram_predivider: process every stepsize pixel, all other pixels are
@@ -562,10 +616,10 @@ struct rkisp1_cif_isp_goc_config {
* as is reported by the hw_revision field of the struct media_device_info
* that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
*
- * Versions <= V11 have RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10
- * entries, versions >= V12 have RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12
- * entries. RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE is equal to the maximum
- * of the two.
+ * V10 has RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10 entries, V12 has
+ * RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12 entries.
+ * RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE is equal to the maximum of the
+ * two.
*/
struct rkisp1_cif_isp_hst_config {
__u32 mode;
@@ -575,7 +629,7 @@ struct rkisp1_cif_isp_hst_config {
};
/**
- * struct rkisp1_cif_isp_aec_config - Configuration used by Auto Exposure Control
+ * struct rkisp1_cif_isp_aec_config - Configuration for Auto Exposure statistics
*
* @mode: Exposure measure mode (from enum rkisp1_cif_isp_exp_meas_mode)
* @autostop: stop mode (from enum rkisp1_cif_isp_exp_ctrl_autostop)
@@ -588,7 +642,7 @@ struct rkisp1_cif_isp_aec_config {
};
/**
- * struct rkisp1_cif_isp_afc_config - Configuration used by Auto Focus Control
+ * struct rkisp1_cif_isp_afc_config - Configuration for the Auto Focus statistics
*
* @num_afm_win: max RKISP1_CIF_ISP_AFM_MAX_WINDOWS
* @afm_win: coordinates of the meas window
@@ -802,6 +856,39 @@ struct rkisp1_params_cfg {
struct rkisp1_cif_isp_isp_other_cfg others;
};
+/**
+ * struct rkisp1_cif_isp_compand_bls_config - Rockchip ISP1 Companding parameters (BLS)
+ * @r: Fixed subtraction value for Bayer pattern R
+ * @gr: Fixed subtraction value for Bayer pattern Gr
+ * @gb: Fixed subtraction value for Bayer pattern Gb
+ * @b: Fixed subtraction value for Bayer pattern B
+ *
+ * The values will be subtracted from the sensor values. Note that unlike the
+ * dedicated BLS block, the BLS values in the compander are 20-bit unsigned.
+ */
+struct rkisp1_cif_isp_compand_bls_config {
+ __u32 r;
+ __u32 gr;
+ __u32 gb;
+ __u32 b;
+};
+
+/**
+ * struct rkisp1_cif_isp_compand_curve_config - Rockchip ISP1 Companding
+ * parameters (expand and compression curves)
+ * @px: Compand curve x-values. Each value stores the distance from the
+ * previous x-value, expressed as log2 of the distance on 5 bits.
+ * @x: Compand curve x-values. The functionality of these parameters are
+ * unknown due to do a lack of hardware documentation, but these are left
+ * here for future compatibility purposes.
+ * @y: Compand curve y-values
+ */
+struct rkisp1_cif_isp_compand_curve_config {
+ __u8 px[RKISP1_CIF_ISP_COMPAND_NUM_POINTS];
+ __u32 x[RKISP1_CIF_ISP_COMPAND_NUM_POINTS];
+ __u32 y[RKISP1_CIF_ISP_COMPAND_NUM_POINTS];
+};
+
/*---------- PART2: Measurement Statistics ------------*/
/**
@@ -857,9 +944,9 @@ struct rkisp1_cif_isp_bls_meas_val {
* as is reported by the hw_revision field of the struct media_device_info
* that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
*
- * Versions <= V11 have RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries,
- * versions >= V12 have RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries.
- * RKISP1_CIF_ISP_AE_MEAN_MAX is equal to the maximum of the two.
+ * V10 has RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries, V12 has
+ * RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries. RKISP1_CIF_ISP_AE_MEAN_MAX is equal
+ * to the maximum of the two.
*
* Image is divided into 5x5 blocks on V10 and 9x9 blocks on V12.
*/
@@ -899,21 +986,21 @@ struct rkisp1_cif_isp_af_stat {
* integer part.
*
* The window of the measurements area is divided to 5x5 sub-windows for
- * V10/V11 and to 9x9 sub-windows for V12. The histogram is then computed for
- * each sub-window independently and the final result is a weighted average of
- * the histogram measurements on all sub-windows. The window of the
- * measurements area and the weight of each sub-window are configurable using
+ * V10 and to 9x9 sub-windows for V12. The histogram is then computed for each
+ * sub-window independently and the final result is a weighted average of the
+ * histogram measurements on all sub-windows. The window of the measurements
+ * area and the weight of each sub-window are configurable using
* struct @rkisp1_cif_isp_hst_config.
*
- * The histogram contains 16 bins in V10/V11 and 32 bins in V12/V13.
+ * The histogram contains 16 bins in V10 and 32 bins in V12.
*
* The number of entries of @hist_bins depends on the hardware revision
* as is reported by the hw_revision field of the struct media_device_info
* that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
*
- * Versions <= V11 have RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 entries,
- * versions >= V12 have RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 entries.
- * RKISP1_CIF_ISP_HIST_BIN_N_MAX is equal to the maximum of the two.
+ * V10 has RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 entries, V12 has
+ * RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 entries. RKISP1_CIF_ISP_HIST_BIN_N_MAX is
+ * equal to the maximum of the two.
*/
struct rkisp1_cif_isp_hist_stat {
__u32 hist_bins[RKISP1_CIF_ISP_HIST_BIN_N_MAX];
@@ -947,4 +1034,544 @@ struct rkisp1_stat_buffer {
struct rkisp1_cif_isp_stat params;
};
+/*---------- PART3: Extensible Configuration Parameters ------------*/
+
+/**
+ * enum rkisp1_ext_params_block_type - RkISP1 extensible params block type
+ *
+ * @RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS: Black level subtraction
+ * @RKISP1_EXT_PARAMS_BLOCK_TYPE_DPCC: Defect pixel cluster correction
+ * @RKISP1_EXT_PARAMS_BLOCK_TYPE_SDG: Sensor de-gamma
+ * @RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_GAIN: Auto white balance gains
+ * @RKISP1_EXT_PARAMS_BLOCK_TYPE_FLT: ISP filtering
+ * @RKISP1_EXT_PARAMS_BLOCK_TYPE_BDM: Bayer de-mosaic
+ * @RKISP1_EXT_PARAMS_BLOCK_TYPE_CTK: Cross-talk correction
+ * @RKISP1_EXT_PARAMS_BLOCK_TYPE_GOC: Gamma out correction
+ * @RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF: De-noise pre-filter
+ * @RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF_STRENGTH: De-noise pre-filter strength
+ * @RKISP1_EXT_PARAMS_BLOCK_TYPE_CPROC: Color processing
+ * @RKISP1_EXT_PARAMS_BLOCK_TYPE_IE: Image effects
+ * @RKISP1_EXT_PARAMS_BLOCK_TYPE_LSC: Lens shading correction
+ * @RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_MEAS: Auto white balance statistics
+ * @RKISP1_EXT_PARAMS_BLOCK_TYPE_HST_MEAS: Histogram statistics
+ * @RKISP1_EXT_PARAMS_BLOCK_TYPE_AEC_MEAS: Auto exposure statistics
+ * @RKISP1_EXT_PARAMS_BLOCK_TYPE_AFC_MEAS: Auto-focus statistics
+ * @RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_BLS: BLS in the compand block
+ * @RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_EXPAND: Companding expand curve
+ * @RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_COMPRESS: Companding compress curve
+ */
+enum rkisp1_ext_params_block_type {
+ RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS,
+ RKISP1_EXT_PARAMS_BLOCK_TYPE_DPCC,
+ RKISP1_EXT_PARAMS_BLOCK_TYPE_SDG,
+ RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_GAIN,
+ RKISP1_EXT_PARAMS_BLOCK_TYPE_FLT,
+ RKISP1_EXT_PARAMS_BLOCK_TYPE_BDM,
+ RKISP1_EXT_PARAMS_BLOCK_TYPE_CTK,
+ RKISP1_EXT_PARAMS_BLOCK_TYPE_GOC,
+ RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF,
+ RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF_STRENGTH,
+ RKISP1_EXT_PARAMS_BLOCK_TYPE_CPROC,
+ RKISP1_EXT_PARAMS_BLOCK_TYPE_IE,
+ RKISP1_EXT_PARAMS_BLOCK_TYPE_LSC,
+ RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_MEAS,
+ RKISP1_EXT_PARAMS_BLOCK_TYPE_HST_MEAS,
+ RKISP1_EXT_PARAMS_BLOCK_TYPE_AEC_MEAS,
+ RKISP1_EXT_PARAMS_BLOCK_TYPE_AFC_MEAS,
+ RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_BLS,
+ RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_EXPAND,
+ RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_COMPRESS,
+};
+
+#define RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE (1U << 0)
+#define RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE (1U << 1)
+
+/**
+ * struct rkisp1_ext_params_block_header - RkISP1 extensible parameters block
+ * header
+ *
+ * This structure represents the common part of all the ISP configuration
+ * blocks. Each parameters block shall embed an instance of this structure type
+ * as its first member, followed by the block-specific configuration data. The
+ * driver inspects this common header to discern the block type and its size and
+ * properly handle the block content by casting it to the correct block-specific
+ * type.
+ *
+ * The @type field is one of the values enumerated by
+ * :c:type:`rkisp1_ext_params_block_type` and specifies how the data should be
+ * interpreted by the driver. The @size field specifies the size of the
+ * parameters block and is used by the driver for validation purposes.
+ *
+ * The @flags field is a bitmask of per-block flags RKISP1_EXT_PARAMS_FL_*.
+ *
+ * When userspace wants to configure and enable an ISP block it shall fully
+ * populate the block configuration and set the
+ * RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE bit in the @flags field.
+ *
+ * When userspace simply wants to disable an ISP block the
+ * RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE bit should be set in @flags field. The
+ * driver ignores the rest of the block configuration structure in this case.
+ *
+ * If a new configuration of an ISP block has to be applied userspace shall
+ * fully populate the ISP block configuration and omit setting the
+ * RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE and RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE bits
+ * in the @flags field.
+ *
+ * Setting both the RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE and
+ * RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE bits in the @flags field is not allowed
+ * and not accepted by the driver.
+ *
+ * Userspace is responsible for correctly populating the parameters block header
+ * fields (@type, @flags and @size) and the block-specific parameters.
+ *
+ * For example:
+ *
+ * .. code-block:: c
+ *
+ * void populate_bls(struct rkisp1_ext_params_block_header *block) {
+ * struct rkisp1_ext_params_bls_config *bls =
+ * (struct rkisp1_ext_params_bls_config *)block;
+ *
+ * bls->header.type = RKISP1_EXT_PARAMS_BLOCK_ID_BLS;
+ * bls->header.flags = RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE;
+ * bls->header.size = sizeof(*bls);
+ *
+ * bls->config.enable_auto = 0;
+ * bls->config.fixed_val.r = blackLevelRed_;
+ * bls->config.fixed_val.gr = blackLevelGreenR_;
+ * bls->config.fixed_val.gb = blackLevelGreenB_;
+ * bls->config.fixed_val.b = blackLevelBlue_;
+ * }
+ *
+ * @type: The parameters block type, see
+ * :c:type:`rkisp1_ext_params_block_type`
+ * @flags: A bitmask of block flags
+ * @size: Size (in bytes) of the parameters block, including this header
+ */
+struct rkisp1_ext_params_block_header {
+ __u16 type;
+ __u16 flags;
+ __u32 size;
+};
+
+/**
+ * struct rkisp1_ext_params_bls_config - RkISP1 extensible params BLS config
+ *
+ * RkISP1 extensible parameters Black Level Subtraction configuration block.
+ * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS`.
+ *
+ * @header: The RkISP1 extensible parameters header, see
+ * :c:type:`rkisp1_ext_params_block_header`
+ * @config: Black Level Subtraction configuration, see
+ * :c:type:`rkisp1_cif_isp_bls_config`
+ */
+struct rkisp1_ext_params_bls_config {
+ struct rkisp1_ext_params_block_header header;
+ struct rkisp1_cif_isp_bls_config config;
+} __attribute__((aligned(8)));
+
+/**
+ * struct rkisp1_ext_params_dpcc_config - RkISP1 extensible params DPCC config
+ *
+ * RkISP1 extensible parameters Defective Pixel Cluster Correction configuration
+ * block. Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_DPCC`.
+ *
+ * @header: The RkISP1 extensible parameters header, see
+ * :c:type:`rkisp1_ext_params_block_header`
+ * @config: Defective Pixel Cluster Correction configuration, see
+ * :c:type:`rkisp1_cif_isp_dpcc_config`
+ */
+struct rkisp1_ext_params_dpcc_config {
+ struct rkisp1_ext_params_block_header header;
+ struct rkisp1_cif_isp_dpcc_config config;
+} __attribute__((aligned(8)));
+
+/**
+ * struct rkisp1_ext_params_sdg_config - RkISP1 extensible params SDG config
+ *
+ * RkISP1 extensible parameters Sensor Degamma configuration block. Identified
+ * by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_SDG`.
+ *
+ * @header: The RkISP1 extensible parameters header, see
+ * :c:type:`rkisp1_ext_params_block_header`
+ * @config: Sensor Degamma configuration, see
+ * :c:type:`rkisp1_cif_isp_sdg_config`
+ */
+struct rkisp1_ext_params_sdg_config {
+ struct rkisp1_ext_params_block_header header;
+ struct rkisp1_cif_isp_sdg_config config;
+} __attribute__((aligned(8)));
+
+/**
+ * struct rkisp1_ext_params_lsc_config - RkISP1 extensible params LSC config
+ *
+ * RkISP1 extensible parameters Lens Shading Correction configuration block.
+ * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_LSC`.
+ *
+ * @header: The RkISP1 extensible parameters header, see
+ * :c:type:`rkisp1_ext_params_block_header`
+ * @config: Lens Shading Correction configuration, see
+ * :c:type:`rkisp1_cif_isp_lsc_config`
+ */
+struct rkisp1_ext_params_lsc_config {
+ struct rkisp1_ext_params_block_header header;
+ struct rkisp1_cif_isp_lsc_config config;
+} __attribute__((aligned(8)));
+
+/**
+ * struct rkisp1_ext_params_awb_gain_config - RkISP1 extensible params AWB
+ * gain config
+ *
+ * RkISP1 extensible parameters Auto-White Balance Gains configuration block.
+ * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_GAIN`.
+ *
+ * @header: The RkISP1 extensible parameters header, see
+ * :c:type:`rkisp1_ext_params_block_header`
+ * @config: Auto-White Balance Gains configuration, see
+ * :c:type:`rkisp1_cif_isp_awb_gain_config`
+ */
+struct rkisp1_ext_params_awb_gain_config {
+ struct rkisp1_ext_params_block_header header;
+ struct rkisp1_cif_isp_awb_gain_config config;
+} __attribute__((aligned(8)));
+
+/**
+ * struct rkisp1_ext_params_flt_config - RkISP1 extensible params FLT config
+ *
+ * RkISP1 extensible parameters Filter configuration block. Identified by
+ * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_FLT`.
+ *
+ * @header: The RkISP1 extensible parameters header, see
+ * :c:type:`rkisp1_ext_params_block_header`
+ * @config: Filter configuration, see :c:type:`rkisp1_cif_isp_flt_config`
+ */
+struct rkisp1_ext_params_flt_config {
+ struct rkisp1_ext_params_block_header header;
+ struct rkisp1_cif_isp_flt_config config;
+} __attribute__((aligned(8)));
+
+/**
+ * struct rkisp1_ext_params_bdm_config - RkISP1 extensible params BDM config
+ *
+ * RkISP1 extensible parameters Demosaicing configuration block. Identified by
+ * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_BDM`.
+ *
+ * @header: The RkISP1 extensible parameters header, see
+ * :c:type:`rkisp1_ext_params_block_header`
+ * @config: Demosaicing configuration, see :c:type:`rkisp1_cif_isp_bdm_config`
+ */
+struct rkisp1_ext_params_bdm_config {
+ struct rkisp1_ext_params_block_header header;
+ struct rkisp1_cif_isp_bdm_config config;
+} __attribute__((aligned(8)));
+
+/**
+ * struct rkisp1_ext_params_ctk_config - RkISP1 extensible params CTK config
+ *
+ * RkISP1 extensible parameters Cross-Talk configuration block. Identified by
+ * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_CTK`.
+ *
+ * @header: The RkISP1 extensible parameters header, see
+ * :c:type:`rkisp1_ext_params_block_header`
+ * @config: Cross-Talk configuration, see :c:type:`rkisp1_cif_isp_ctk_config`
+ */
+struct rkisp1_ext_params_ctk_config {
+ struct rkisp1_ext_params_block_header header;
+ struct rkisp1_cif_isp_ctk_config config;
+} __attribute__((aligned(8)));
+
+/**
+ * struct rkisp1_ext_params_goc_config - RkISP1 extensible params GOC config
+ *
+ * RkISP1 extensible parameters Gamma-Out configuration block. Identified by
+ * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_GOC`.
+ *
+ * @header: The RkISP1 extensible parameters header, see
+ * :c:type:`rkisp1_ext_params_block_header`
+ * @config: Gamma-Out configuration, see :c:type:`rkisp1_cif_isp_goc_config`
+ */
+struct rkisp1_ext_params_goc_config {
+ struct rkisp1_ext_params_block_header header;
+ struct rkisp1_cif_isp_goc_config config;
+} __attribute__((aligned(8)));
+
+/**
+ * struct rkisp1_ext_params_dpf_config - RkISP1 extensible params DPF config
+ *
+ * RkISP1 extensible parameters De-noise Pre-Filter configuration block.
+ * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF`.
+ *
+ * @header: The RkISP1 extensible parameters header, see
+ * :c:type:`rkisp1_ext_params_block_header`
+ * @config: De-noise Pre-Filter configuration, see
+ * :c:type:`rkisp1_cif_isp_dpf_config`
+ */
+struct rkisp1_ext_params_dpf_config {
+ struct rkisp1_ext_params_block_header header;
+ struct rkisp1_cif_isp_dpf_config config;
+} __attribute__((aligned(8)));
+
+/**
+ * struct rkisp1_ext_params_dpf_strength_config - RkISP1 extensible params DPF
+ * strength config
+ *
+ * RkISP1 extensible parameters De-noise Pre-Filter strength configuration
+ * block. Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF_STRENGTH`.
+ *
+ * @header: The RkISP1 extensible parameters header, see
+ * :c:type:`rkisp1_ext_params_block_header`
+ * @config: De-noise Pre-Filter strength configuration, see
+ * :c:type:`rkisp1_cif_isp_dpf_strength_config`
+ */
+struct rkisp1_ext_params_dpf_strength_config {
+ struct rkisp1_ext_params_block_header header;
+ struct rkisp1_cif_isp_dpf_strength_config config;
+} __attribute__((aligned(8)));
+
+/**
+ * struct rkisp1_ext_params_cproc_config - RkISP1 extensible params CPROC config
+ *
+ * RkISP1 extensible parameters Color Processing configuration block.
+ * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_CPROC`.
+ *
+ * @header: The RkISP1 extensible parameters header, see
+ * :c:type:`rkisp1_ext_params_block_header`
+ * @config: Color processing configuration, see
+ * :c:type:`rkisp1_cif_isp_cproc_config`
+ */
+struct rkisp1_ext_params_cproc_config {
+ struct rkisp1_ext_params_block_header header;
+ struct rkisp1_cif_isp_cproc_config config;
+} __attribute__((aligned(8)));
+
+/**
+ * struct rkisp1_ext_params_ie_config - RkISP1 extensible params IE config
+ *
+ * RkISP1 extensible parameters Image Effect configuration block. Identified by
+ * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_IE`.
+ *
+ * @header: The RkISP1 extensible parameters header, see
+ * :c:type:`rkisp1_ext_params_block_header`
+ * @config: Image Effect configuration, see :c:type:`rkisp1_cif_isp_ie_config`
+ */
+struct rkisp1_ext_params_ie_config {
+ struct rkisp1_ext_params_block_header header;
+ struct rkisp1_cif_isp_ie_config config;
+} __attribute__((aligned(8)));
+
+/**
+ * struct rkisp1_ext_params_awb_meas_config - RkISP1 extensible params AWB
+ * Meas config
+ *
+ * RkISP1 extensible parameters Auto-White Balance Measurement configuration
+ * block. Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_MEAS`.
+ *
+ * @header: The RkISP1 extensible parameters header, see
+ * :c:type:`rkisp1_ext_params_block_header`
+ * @config: Auto-White Balance measure configuration, see
+ * :c:type:`rkisp1_cif_isp_awb_meas_config`
+ */
+struct rkisp1_ext_params_awb_meas_config {
+ struct rkisp1_ext_params_block_header header;
+ struct rkisp1_cif_isp_awb_meas_config config;
+} __attribute__((aligned(8)));
+
+/**
+ * struct rkisp1_ext_params_hst_config - RkISP1 extensible params Histogram config
+ *
+ * RkISP1 extensible parameters Histogram statistics configuration block.
+ * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_HST_MEAS`.
+ *
+ * @header: The RkISP1 extensible parameters header, see
+ * :c:type:`rkisp1_ext_params_block_header`
+ * @config: Histogram statistics configuration, see
+ * :c:type:`rkisp1_cif_isp_hst_config`
+ */
+struct rkisp1_ext_params_hst_config {
+ struct rkisp1_ext_params_block_header header;
+ struct rkisp1_cif_isp_hst_config config;
+} __attribute__((aligned(8)));
+
+/**
+ * struct rkisp1_ext_params_aec_config - RkISP1 extensible params AEC config
+ *
+ * RkISP1 extensible parameters Auto-Exposure statistics configuration block.
+ * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_AEC_MEAS`.
+ *
+ * @header: The RkISP1 extensible parameters header, see
+ * :c:type:`rkisp1_ext_params_block_header`
+ * @config: Auto-Exposure statistics configuration, see
+ * :c:type:`rkisp1_cif_isp_aec_config`
+ */
+struct rkisp1_ext_params_aec_config {
+ struct rkisp1_ext_params_block_header header;
+ struct rkisp1_cif_isp_aec_config config;
+} __attribute__((aligned(8)));
+
+/**
+ * struct rkisp1_ext_params_afc_config - RkISP1 extensible params AFC config
+ *
+ * RkISP1 extensible parameters Auto-Focus statistics configuration block.
+ * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_AFC_MEAS`.
+ *
+ * @header: The RkISP1 extensible parameters header, see
+ * :c:type:`rkisp1_ext_params_block_header`
+ * @config: Auto-Focus statistics configuration, see
+ * :c:type:`rkisp1_cif_isp_afc_config`
+ */
+struct rkisp1_ext_params_afc_config {
+ struct rkisp1_ext_params_block_header header;
+ struct rkisp1_cif_isp_afc_config config;
+} __attribute__((aligned(8)));
+
+/**
+ * struct rkisp1_ext_params_compand_bls_config - RkISP1 extensible params
+ * Compand BLS config
+ *
+ * RkISP1 extensible parameters Companding configuration block (black level
+ * subtraction). Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_BLS`.
+ *
+ * @header: The RkISP1 extensible parameters header, see
+ * :c:type:`rkisp1_ext_params_block_header`
+ * @config: Companding BLS configuration, see
+ * :c:type:`rkisp1_cif_isp_compand_bls_config`
+ */
+struct rkisp1_ext_params_compand_bls_config {
+ struct rkisp1_ext_params_block_header header;
+ struct rkisp1_cif_isp_compand_bls_config config;
+} __attribute__((aligned(8)));
+
+/**
+ * struct rkisp1_ext_params_compand_curve_config - RkISP1 extensible params
+ * Compand curve config
+ *
+ * RkISP1 extensible parameters Companding configuration block (expand and
+ * compression curves). Identified by
+ * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_EXPAND` or
+ * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_COMPRESS`.
+ *
+ * @header: The RkISP1 extensible parameters header, see
+ * :c:type:`rkisp1_ext_params_block_header`
+ * @config: Companding curve configuration, see
+ * :c:type:`rkisp1_cif_isp_compand_curve_config`
+ */
+struct rkisp1_ext_params_compand_curve_config {
+ struct rkisp1_ext_params_block_header header;
+ struct rkisp1_cif_isp_compand_curve_config config;
+} __attribute__((aligned(8)));
+
+/*
+ * The rkisp1_ext_params_compand_curve_config structure is counted twice as it
+ * is used for both the COMPAND_EXPAND and COMPAND_COMPRESS block types.
+ */
+#define RKISP1_EXT_PARAMS_MAX_SIZE \
+ (sizeof(struct rkisp1_ext_params_bls_config) +\
+ sizeof(struct rkisp1_ext_params_dpcc_config) +\
+ sizeof(struct rkisp1_ext_params_sdg_config) +\
+ sizeof(struct rkisp1_ext_params_lsc_config) +\
+ sizeof(struct rkisp1_ext_params_awb_gain_config) +\
+ sizeof(struct rkisp1_ext_params_flt_config) +\
+ sizeof(struct rkisp1_ext_params_bdm_config) +\
+ sizeof(struct rkisp1_ext_params_ctk_config) +\
+ sizeof(struct rkisp1_ext_params_goc_config) +\
+ sizeof(struct rkisp1_ext_params_dpf_config) +\
+ sizeof(struct rkisp1_ext_params_dpf_strength_config) +\
+ sizeof(struct rkisp1_ext_params_cproc_config) +\
+ sizeof(struct rkisp1_ext_params_ie_config) +\
+ sizeof(struct rkisp1_ext_params_awb_meas_config) +\
+ sizeof(struct rkisp1_ext_params_hst_config) +\
+ sizeof(struct rkisp1_ext_params_aec_config) +\
+ sizeof(struct rkisp1_ext_params_afc_config) +\
+ sizeof(struct rkisp1_ext_params_compand_bls_config) +\
+ sizeof(struct rkisp1_ext_params_compand_curve_config) +\
+ sizeof(struct rkisp1_ext_params_compand_curve_config))
+
+/**
+ * enum rksip1_ext_param_buffer_version - RkISP1 extensible parameters version
+ *
+ * @RKISP1_EXT_PARAM_BUFFER_V1: First version of RkISP1 extensible parameters
+ */
+enum rksip1_ext_param_buffer_version {
+ RKISP1_EXT_PARAM_BUFFER_V1 = 1,
+};
+
+/**
+ * struct rkisp1_ext_params_cfg - RkISP1 extensible parameters configuration
+ *
+ * This struct contains the configuration parameters of the RkISP1 ISP
+ * algorithms, serialized by userspace into a data buffer. Each configuration
+ * parameter block is represented by a block-specific structure which contains a
+ * :c:type:`rkisp1_ext_params_block_header` entry as first member. Userspace
+ * populates the @data buffer with configuration parameters for the blocks that
+ * it intends to configure. As a consequence, the data buffer effective size
+ * changes according to the number of ISP blocks that userspace intends to
+ * configure and is set by userspace in the @data_size field.
+ *
+ * The parameters buffer is versioned by the @version field to allow modifying
+ * and extending its definition. Userspace shall populate the @version field to
+ * inform the driver about the version it intends to use. The driver will parse
+ * and handle the @data buffer according to the data layout specific to the
+ * indicated version and return an error if the desired version is not
+ * supported.
+ *
+ * Currently the single RKISP1_EXT_PARAM_BUFFER_V1 version is supported.
+ * When a new format version will be added, a mechanism for userspace to query
+ * the supported format versions will be implemented in the form of a read-only
+ * V4L2 control. If such control is not available, userspace should assume only
+ * RKISP1_EXT_PARAM_BUFFER_V1 is supported by the driver.
+ *
+ * For each ISP block that userspace wants to configure, a block-specific
+ * structure is appended to the @data buffer, one after the other without gaps
+ * in between nor overlaps. Userspace shall populate the @data_size field with
+ * the effective size, in bytes, of the @data buffer.
+ *
+ * The expected memory layout of the parameters buffer is::
+ *
+ * +-------------------- struct rkisp1_ext_params_cfg -------------------+
+ * | version = RKISP_EXT_PARAMS_BUFFER_V1; |
+ * | data_size = sizeof(struct rkisp1_ext_params_bls_config) |
+ * | + sizeof(struct rkisp1_ext_params_dpcc_config); |
+ * | +------------------------- data ---------------------------------+ |
+ * | | +------------- struct rkisp1_ext_params_bls_config -----------+ | |
+ * | | | +-------- struct rkisp1_ext_params_block_header ---------+ | | |
+ * | | | | type = RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS; | | | |
+ * | | | | flags = RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE; | | | |
+ * | | | | size = sizeof(struct rkisp1_ext_params_bls_config); | | | |
+ * | | | +---------------------------------------------------------+ | | |
+ * | | | +---------- struct rkisp1_cif_isp_bls_config -------------+ | | |
+ * | | | | enable_auto = 0; | | | |
+ * | | | | fixed_val.r = 256; | | | |
+ * | | | | fixed_val.gr = 256; | | | |
+ * | | | | fixed_val.gb = 256; | | | |
+ * | | | | fixed_val.b = 256; | | | |
+ * | | | +---------------------------------------------------------+ | | |
+ * | | +------------ struct rkisp1_ext_params_dpcc_config -----------+ | |
+ * | | | +-------- struct rkisp1_ext_params_block_header ---------+ | | |
+ * | | | | type = RKISP1_EXT_PARAMS_BLOCK_TYPE_DPCC; | | | |
+ * | | | | flags = RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE; | | | |
+ * | | | | size = sizeof(struct rkisp1_ext_params_dpcc_config); | | | |
+ * | | | +---------------------------------------------------------+ | | |
+ * | | | +---------- struct rkisp1_cif_isp_dpcc_config ------------+ | | |
+ * | | | | mode = RKISP1_CIF_ISP_DPCC_MODE_STAGE1_ENABLE; | | | |
+ * | | | | output_mode = | | | |
+ * | | | | RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_INCL_G_CENTER; | | | |
+ * | | | | set_use = ... ; | | | |
+ * | | | | ... = ... ; | | | |
+ * | | | +---------------------------------------------------------+ | | |
+ * | | +-------------------------------------------------------------+ | |
+ * | +-----------------------------------------------------------------+ |
+ * +---------------------------------------------------------------------+
+ *
+ * @version: The RkISP1 extensible parameters buffer version, see
+ * :c:type:`rksip1_ext_param_buffer_version`
+ * @data_size: The RkISP1 configuration data effective size, excluding this
+ * header
+ * @data: The RkISP1 extensible configuration data blocks
+ */
+struct rkisp1_ext_params_cfg {
+ __u32 version;
+ __u32 data_size;
+ __u8 data[RKISP1_EXT_PARAMS_MAX_SIZE];
+};
+
#endif /* _RKISP1_CONFIG_H */
diff --git a/include/linux/udmabuf.h b/include/linux/udmabuf.h
new file mode 100644
index 00000000..76cc7de9
--- /dev/null
+++ b/include/linux/udmabuf.h
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _LINUX_UDMABUF_H
+#define _LINUX_UDMABUF_H
+
+#include <linux/types.h>
+#include <linux/ioctl.h>
+
+#define UDMABUF_FLAGS_CLOEXEC 0x01
+
+struct udmabuf_create {
+ __u32 memfd;
+ __u32 flags;
+ __u64 offset;
+ __u64 size;
+};
+
+struct udmabuf_create_item {
+ __u32 memfd;
+ __u32 __pad;
+ __u64 offset;
+ __u64 size;
+};
+
+struct udmabuf_create_list {
+ __u32 flags;
+ __u32 count;
+ struct udmabuf_create_item list[];
+};
+
+#define UDMABUF_CREATE _IOW('u', 0x42, struct udmabuf_create)
+#define UDMABUF_CREATE_LIST _IOW('u', 0x43, struct udmabuf_create_list)
+
+#endif /* _LINUX_UDMABUF_H */
diff --git a/include/linux/v4l2-common.h b/include/linux/v4l2-common.h
index 14de1731..c3ca11e3 100644
--- a/include/linux/v4l2-common.h
+++ b/include/linux/v4l2-common.h
@@ -10,45 +10,6 @@
*
* Copyright (C) 2012 Nokia Corporation
* Contact: Sakari Ailus <sakari.ailus@iki.fi>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * Alternatively you can redistribute this file under the terms of the
- * BSD license as stated below:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. The names of its contributors may not be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
*/
#ifndef __V4L2_COMMON__
diff --git a/include/linux/v4l2-controls.h b/include/linux/v4l2-controls.h
index 59a57418..882a8180 100644
--- a/include/linux/v4l2-controls.h
+++ b/include/linux/v4l2-controls.h
@@ -4,44 +4,6 @@
*
* Copyright (C) 1999-2012 the contributors
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * Alternatively you can redistribute this file under the terms of the
- * BSD license as stated below:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. The names of its contributors may not be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
* The contents of this header was split off from videodev2.h. All control
* definitions should be added to this header, which is included by
* videodev2.h.
@@ -50,6 +12,7 @@
#ifndef __LINUX_V4L2_CONTROLS_H
#define __LINUX_V4L2_CONTROLS_H
+#include <linux/const.h>
#include <linux/types.h>
/* Control classes */
@@ -66,6 +29,7 @@
#define V4L2_CTRL_CLASS_RF_TUNER 0x00a20000 /* RF tuner controls */
#define V4L2_CTRL_CLASS_DETECT 0x00a30000 /* Detection controls */
#define V4L2_CTRL_CLASS_CODEC_STATELESS 0x00a40000 /* Stateless codecs controls */
+#define V4L2_CTRL_CLASS_COLORIMETRY 0x00a50000 /* Colorimetry controls */
/* User-class control IDs */
@@ -126,6 +90,7 @@ enum v4l2_colorfx {
V4L2_COLORFX_SOLARIZATION = 13,
V4L2_COLORFX_ANTIQUE = 14,
V4L2_COLORFX_SET_CBCR = 15,
+ V4L2_COLORFX_SET_RGB = 16,
};
#define V4L2_CID_AUTOBRIGHTNESS (V4L2_CID_BASE+32)
#define V4L2_CID_BAND_STOP_FILTER (V4L2_CID_BASE+33)
@@ -143,14 +108,17 @@ enum v4l2_colorfx {
#define V4L2_CID_ALPHA_COMPONENT (V4L2_CID_BASE+41)
#define V4L2_CID_COLORFX_CBCR (V4L2_CID_BASE+42)
+#define V4L2_CID_COLORFX_RGB (V4L2_CID_BASE+43)
/* last CID + 1 */
-#define V4L2_CID_LASTP1 (V4L2_CID_BASE+43)
+#define V4L2_CID_LASTP1 (V4L2_CID_BASE+44)
/* USER-class private control IDs */
-/* The base for the meye driver controls. See linux/meye.h for the list
- * of controls. We reserve 16 controls for this driver. */
+/*
+ * The base for the meye driver controls. This driver was removed, but
+ * we keep this define in case any software still uses it.
+ */
#define V4L2_CID_USER_MEYE_BASE (V4L2_CID_USER_BASE + 0x1000)
/* The base for the bttv driver controls.
@@ -213,6 +181,41 @@ enum v4l2_colorfx {
/* The base for the bcm2835-isp driver controls.
* We reserve 16 controls for this driver. */
#define V4L2_CID_USER_BCM2835_ISP_BASE (V4L2_CID_USER_BASE + 0x10e0)
+/*
+ * The base for Allegro driver controls.
+ * We reserve 16 controls for this driver.
+ */
+#define V4L2_CID_USER_ALLEGRO_BASE (V4L2_CID_USER_BASE + 0x1170)
+
+/*
+ * The base for the isl7998x driver controls.
+ * We reserve 16 controls for this driver.
+ */
+#define V4L2_CID_USER_ISL7998X_BASE (V4L2_CID_USER_BASE + 0x1180)
+
+/*
+ * The base for DW100 driver controls.
+ * We reserve 16 controls for this driver.
+ */
+#define V4L2_CID_USER_DW100_BASE (V4L2_CID_USER_BASE + 0x1190)
+
+/*
+ * The base for Aspeed driver controls.
+ * We reserve 16 controls for this driver.
+ */
+#define V4L2_CID_USER_ASPEED_BASE (V4L2_CID_USER_BASE + 0x11a0)
+
+/*
+ * The base for Nuvoton NPCM driver controls.
+ * We reserve 16 controls for this driver.
+ */
+#define V4L2_CID_USER_NPCM_BASE (V4L2_CID_USER_BASE + 0x11b0)
+
+/*
+ * The base for THine THP7312 driver controls.
+ * We reserve 32 controls for this driver.
+ */
+#define V4L2_CID_USER_THP7312_BASE (V4L2_CID_USER_BASE + 0x11c0)
/* MPEG-class control IDs */
/* The MPEG controls are applicable to all codec controls
@@ -430,6 +433,17 @@ enum v4l2_mpeg_video_multi_slice_mode {
#define V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE (V4L2_CID_CODEC_BASE+228)
#define V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME (V4L2_CID_CODEC_BASE+229)
#define V4L2_CID_MPEG_VIDEO_BASELAYER_PRIORITY_ID (V4L2_CID_CODEC_BASE+230)
+#define V4L2_CID_MPEG_VIDEO_AU_DELIMITER (V4L2_CID_CODEC_BASE+231)
+#define V4L2_CID_MPEG_VIDEO_LTR_COUNT (V4L2_CID_CODEC_BASE+232)
+#define V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX (V4L2_CID_CODEC_BASE+233)
+#define V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES (V4L2_CID_CODEC_BASE+234)
+#define V4L2_CID_MPEG_VIDEO_DEC_CONCEAL_COLOR (V4L2_CID_CODEC_BASE+235)
+#define V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD (V4L2_CID_CODEC_BASE+236)
+#define V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE (V4L2_CID_CODEC_BASE+237)
+enum v4l2_mpeg_video_intra_refresh_period_type {
+ V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE_RANDOM = 0,
+ V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE_CYCLIC = 1,
+};
/* CIDs for the MPEG-2 Part 2 (H.262) codec */
#define V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL (V4L2_CID_CODEC_BASE+270)
@@ -799,6 +813,93 @@ enum v4l2_mpeg_video_frame_skip_mode {
#define V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_MIN_QP (V4L2_CID_CODEC_BASE + 651)
#define V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_MAX_QP (V4L2_CID_CODEC_BASE + 652)
+#define V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY (V4L2_CID_CODEC_BASE + 653)
+#define V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY_ENABLE (V4L2_CID_CODEC_BASE + 654)
+
+#define V4L2_CID_MPEG_VIDEO_AV1_PROFILE (V4L2_CID_CODEC_BASE + 655)
+/**
+ * enum v4l2_mpeg_video_av1_profile - AV1 profiles
+ *
+ * @V4L2_MPEG_VIDEO_AV1_PROFILE_MAIN: compliant decoders must be able to decode
+ * streams with seq_profile equal to 0.
+ * @V4L2_MPEG_VIDEO_AV1_PROFILE_HIGH: compliant decoders must be able to decode
+ * streams with seq_profile equal less than or equal to 1.
+ * @V4L2_MPEG_VIDEO_AV1_PROFILE_PROFESSIONAL: compliant decoders must be able to
+ * decode streams with seq_profile less than or equal to 2.
+ *
+ * Conveys the highest profile a decoder can work with.
+ */
+enum v4l2_mpeg_video_av1_profile {
+ V4L2_MPEG_VIDEO_AV1_PROFILE_MAIN = 0,
+ V4L2_MPEG_VIDEO_AV1_PROFILE_HIGH = 1,
+ V4L2_MPEG_VIDEO_AV1_PROFILE_PROFESSIONAL = 2,
+};
+
+#define V4L2_CID_MPEG_VIDEO_AV1_LEVEL (V4L2_CID_CODEC_BASE + 656)
+/**
+ * enum v4l2_mpeg_video_av1_level - AV1 levels
+ *
+ * @V4L2_MPEG_VIDEO_AV1_LEVEL_2_0: Level 2.0.
+ * @V4L2_MPEG_VIDEO_AV1_LEVEL_2_1: Level 2.1.
+ * @V4L2_MPEG_VIDEO_AV1_LEVEL_2_2: Level 2.2.
+ * @V4L2_MPEG_VIDEO_AV1_LEVEL_2_3: Level 2.3.
+ * @V4L2_MPEG_VIDEO_AV1_LEVEL_3_0: Level 3.0.
+ * @V4L2_MPEG_VIDEO_AV1_LEVEL_3_1: Level 3.1.
+ * @V4L2_MPEG_VIDEO_AV1_LEVEL_3_2: Level 3.2.
+ * @V4L2_MPEG_VIDEO_AV1_LEVEL_3_3: Level 3.3.
+ * @V4L2_MPEG_VIDEO_AV1_LEVEL_4_0: Level 4.0.
+ * @V4L2_MPEG_VIDEO_AV1_LEVEL_4_1: Level 4.1.
+ * @V4L2_MPEG_VIDEO_AV1_LEVEL_4_2: Level 4.2.
+ * @V4L2_MPEG_VIDEO_AV1_LEVEL_4_3: Level 4.3.
+ * @V4L2_MPEG_VIDEO_AV1_LEVEL_5_0: Level 5.0.
+ * @V4L2_MPEG_VIDEO_AV1_LEVEL_5_1: Level 5.1.
+ * @V4L2_MPEG_VIDEO_AV1_LEVEL_5_2: Level 5.2.
+ * @V4L2_MPEG_VIDEO_AV1_LEVEL_5_3: Level 5.3.
+ * @V4L2_MPEG_VIDEO_AV1_LEVEL_6_0: Level 6.0.
+ * @V4L2_MPEG_VIDEO_AV1_LEVEL_6_1: Level 6.1.
+ * @V4L2_MPEG_VIDEO_AV1_LEVEL_6_2: Level 6.2.
+ * @V4L2_MPEG_VIDEO_AV1_LEVEL_6_3: Level 6.3.
+ * @V4L2_MPEG_VIDEO_AV1_LEVEL_7_0: Level 7.0.
+ * @V4L2_MPEG_VIDEO_AV1_LEVEL_7_1: Level 7.1.
+ * @V4L2_MPEG_VIDEO_AV1_LEVEL_7_2: Level 7.2.
+ * @V4L2_MPEG_VIDEO_AV1_LEVEL_7_3: Level 7.3.
+ *
+ * Conveys the highest level a decoder can work with.
+ */
+enum v4l2_mpeg_video_av1_level {
+ V4L2_MPEG_VIDEO_AV1_LEVEL_2_0 = 0,
+ V4L2_MPEG_VIDEO_AV1_LEVEL_2_1 = 1,
+ V4L2_MPEG_VIDEO_AV1_LEVEL_2_2 = 2,
+ V4L2_MPEG_VIDEO_AV1_LEVEL_2_3 = 3,
+
+ V4L2_MPEG_VIDEO_AV1_LEVEL_3_0 = 4,
+ V4L2_MPEG_VIDEO_AV1_LEVEL_3_1 = 5,
+ V4L2_MPEG_VIDEO_AV1_LEVEL_3_2 = 6,
+ V4L2_MPEG_VIDEO_AV1_LEVEL_3_3 = 7,
+
+ V4L2_MPEG_VIDEO_AV1_LEVEL_4_0 = 8,
+ V4L2_MPEG_VIDEO_AV1_LEVEL_4_1 = 9,
+ V4L2_MPEG_VIDEO_AV1_LEVEL_4_2 = 10,
+ V4L2_MPEG_VIDEO_AV1_LEVEL_4_3 = 11,
+
+ V4L2_MPEG_VIDEO_AV1_LEVEL_5_0 = 12,
+ V4L2_MPEG_VIDEO_AV1_LEVEL_5_1 = 13,
+ V4L2_MPEG_VIDEO_AV1_LEVEL_5_2 = 14,
+ V4L2_MPEG_VIDEO_AV1_LEVEL_5_3 = 15,
+
+ V4L2_MPEG_VIDEO_AV1_LEVEL_6_0 = 16,
+ V4L2_MPEG_VIDEO_AV1_LEVEL_6_1 = 17,
+ V4L2_MPEG_VIDEO_AV1_LEVEL_6_2 = 18,
+ V4L2_MPEG_VIDEO_AV1_LEVEL_6_3 = 19,
+
+ V4L2_MPEG_VIDEO_AV1_LEVEL_7_0 = 20,
+ V4L2_MPEG_VIDEO_AV1_LEVEL_7_1 = 21,
+ V4L2_MPEG_VIDEO_AV1_LEVEL_7_2 = 22,
+ V4L2_MPEG_VIDEO_AV1_LEVEL_7_3 = 23
+};
+
+#define V4L2_CID_MPEG_VIDEO_AVERAGE_QP (V4L2_CID_CODEC_BASE + 657)
+
/* MPEG-class control IDs specific to the CX2341x driver as defined by V4L2 */
#define V4L2_CID_CODEC_CX2341X_BASE (V4L2_CTRL_CLASS_CODEC | 0x1000)
#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE (V4L2_CID_CODEC_CX2341X_BASE+0)
@@ -986,6 +1087,8 @@ enum v4l2_auto_focus_range {
#define V4L2_CID_CAMERA_SENSOR_ROTATION (V4L2_CID_CAMERA_CLASS_BASE+35)
+#define V4L2_CID_HDR_SENSOR_MODE (V4L2_CID_CAMERA_CLASS_BASE+36)
+
/* FM Modulator class control IDs */
#define V4L2_CID_FM_TX_CLASS_BASE (V4L2_CTRL_CLASS_FM_TX | 0x900)
@@ -1109,6 +1212,7 @@ enum v4l2_jpeg_chroma_subsampling {
#define V4L2_CID_TEST_PATTERN_BLUE (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 6)
#define V4L2_CID_TEST_PATTERN_GREENB (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 7)
#define V4L2_CID_UNIT_CELL_SIZE (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 8)
+#define V4L2_CID_NOTIFY_GAINS (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 9)
/* Image processing controls */
@@ -1331,7 +1435,7 @@ struct v4l2_ctrl_h264_sps {
* struct v4l2_ctrl_h264_pps - H264 picture parameter set
*
* Except where noted, all the members on this picture parameter set
- * structure match the sequence parameter set syntax as specified
+ * structure match the picture parameter set syntax as specified
* by the H264 specification.
*
* In particular, V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT flag
@@ -1546,6 +1650,8 @@ struct v4l2_h264_dpb_entry {
#define V4L2_H264_DECODE_PARAM_FLAG_IDR_PIC 0x01
#define V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC 0x02
#define V4L2_H264_DECODE_PARAM_FLAG_BOTTOM_FIELD 0x04
+#define V4L2_H264_DECODE_PARAM_FLAG_PFRAME 0x08
+#define V4L2_H264_DECODE_PARAM_FLAG_BFRAME 0x10
#define V4L2_CID_STATELESS_H264_DECODE_PARAMS (V4L2_CID_CODEC_STATELESS_BASE + 7)
/**
@@ -1595,30 +1701,30 @@ struct v4l2_ctrl_h264_decode_params {
#define V4L2_FWHT_VERSION 3
/* Set if this is an interlaced format */
-#define V4L2_FWHT_FL_IS_INTERLACED BIT(0)
+#define V4L2_FWHT_FL_IS_INTERLACED _BITUL(0)
/* Set if this is a bottom-first (NTSC) interlaced format */
-#define V4L2_FWHT_FL_IS_BOTTOM_FIRST BIT(1)
+#define V4L2_FWHT_FL_IS_BOTTOM_FIRST _BITUL(1)
/* Set if each 'frame' contains just one field */
-#define V4L2_FWHT_FL_IS_ALTERNATE BIT(2)
+#define V4L2_FWHT_FL_IS_ALTERNATE _BITUL(2)
/*
* If V4L2_FWHT_FL_IS_ALTERNATE was set, then this is set if this
* 'frame' is the bottom field, else it is the top field.
*/
-#define V4L2_FWHT_FL_IS_BOTTOM_FIELD BIT(3)
+#define V4L2_FWHT_FL_IS_BOTTOM_FIELD _BITUL(3)
/* Set if the Y' plane is uncompressed */
-#define V4L2_FWHT_FL_LUMA_IS_UNCOMPRESSED BIT(4)
+#define V4L2_FWHT_FL_LUMA_IS_UNCOMPRESSED _BITUL(4)
/* Set if the Cb plane is uncompressed */
-#define V4L2_FWHT_FL_CB_IS_UNCOMPRESSED BIT(5)
+#define V4L2_FWHT_FL_CB_IS_UNCOMPRESSED _BITUL(5)
/* Set if the Cr plane is uncompressed */
-#define V4L2_FWHT_FL_CR_IS_UNCOMPRESSED BIT(6)
+#define V4L2_FWHT_FL_CR_IS_UNCOMPRESSED _BITUL(6)
/* Set if the chroma plane is full height, if cleared it is half height */
-#define V4L2_FWHT_FL_CHROMA_FULL_HEIGHT BIT(7)
+#define V4L2_FWHT_FL_CHROMA_FULL_HEIGHT _BITUL(7)
/* Set if the chroma plane is full width, if cleared it is half width */
-#define V4L2_FWHT_FL_CHROMA_FULL_WIDTH BIT(8)
+#define V4L2_FWHT_FL_CHROMA_FULL_WIDTH _BITUL(8)
/* Set if the alpha plane is uncompressed */
-#define V4L2_FWHT_FL_ALPHA_IS_UNCOMPRESSED BIT(9)
+#define V4L2_FWHT_FL_ALPHA_IS_UNCOMPRESSED _BITUL(9)
/* Set if this is an I Frame */
-#define V4L2_FWHT_FL_I_FRAME BIT(10)
+#define V4L2_FWHT_FL_I_FRAME _BITUL(10)
/* A 4-values flag - the number of components - 1 */
#define V4L2_FWHT_FL_COMPONENTS_NUM_MSK GENMASK(18, 16)
@@ -1659,6 +1765,1734 @@ struct v4l2_ctrl_fwht_params {
__u32 quantization;
};
+/* Stateless VP8 control */
+
+#define V4L2_VP8_SEGMENT_FLAG_ENABLED 0x01
+#define V4L2_VP8_SEGMENT_FLAG_UPDATE_MAP 0x02
+#define V4L2_VP8_SEGMENT_FLAG_UPDATE_FEATURE_DATA 0x04
+#define V4L2_VP8_SEGMENT_FLAG_DELTA_VALUE_MODE 0x08
+
+/**
+ * struct v4l2_vp8_segment - VP8 segment-based adjustments parameters
+ *
+ * @quant_update: update values for the segment quantizer.
+ * @lf_update: update values for the loop filter level.
+ * @segment_probs: branch probabilities of the segment_id decoding tree.
+ * @padding: padding field. Should be zeroed by applications.
+ * @flags: see V4L2_VP8_SEGMENT_FLAG_{}.
+ *
+ * This structure contains segment-based adjustments related parameters.
+ * See the 'update_segmentation()' part of the frame header syntax,
+ * and section '9.3. Segment-Based Adjustments' of the VP8 specification
+ * for more details.
+ */
+struct v4l2_vp8_segment {
+ __s8 quant_update[4];
+ __s8 lf_update[4];
+ __u8 segment_probs[3];
+ __u8 padding;
+ __u32 flags;
+};
+
+#define V4L2_VP8_LF_ADJ_ENABLE 0x01
+#define V4L2_VP8_LF_DELTA_UPDATE 0x02
+#define V4L2_VP8_LF_FILTER_TYPE_SIMPLE 0x04
+
+/**
+ * struct v4l2_vp8_loop_filter - VP8 loop filter parameters
+ *
+ * @ref_frm_delta: Reference frame signed delta values.
+ * @mb_mode_delta: MB prediction mode signed delta values.
+ * @sharpness_level: matches sharpness_level syntax element.
+ * @level: matches loop_filter_level syntax element.
+ * @padding: padding field. Should be zeroed by applications.
+ * @flags: see V4L2_VP8_LF_{}.
+ *
+ * This structure contains loop filter related parameters.
+ * See the 'mb_lf_adjustments()' part of the frame header syntax,
+ * and section '9.4. Loop Filter Type and Levels' of the VP8 specification
+ * for more details.
+ */
+struct v4l2_vp8_loop_filter {
+ __s8 ref_frm_delta[4];
+ __s8 mb_mode_delta[4];
+ __u8 sharpness_level;
+ __u8 level;
+ __u16 padding;
+ __u32 flags;
+};
+
+/**
+ * struct v4l2_vp8_quantization - VP8 quantizattion indices
+ *
+ * @y_ac_qi: luma AC coefficient table index.
+ * @y_dc_delta: luma DC delta vaue.
+ * @y2_dc_delta: y2 block DC delta value.
+ * @y2_ac_delta: y2 block AC delta value.
+ * @uv_dc_delta: chroma DC delta value.
+ * @uv_ac_delta: chroma AC delta value.
+ * @padding: padding field. Should be zeroed by applications.
+ *
+ * This structure contains the quantization indices present
+ * in 'quant_indices()' part of the frame header syntax.
+ * See section '9.6. Dequantization Indices' of the VP8 specification
+ * for more details.
+ */
+struct v4l2_vp8_quantization {
+ __u8 y_ac_qi;
+ __s8 y_dc_delta;
+ __s8 y2_dc_delta;
+ __s8 y2_ac_delta;
+ __s8 uv_dc_delta;
+ __s8 uv_ac_delta;
+ __u16 padding;
+};
+
+#define V4L2_VP8_COEFF_PROB_CNT 11
+#define V4L2_VP8_MV_PROB_CNT 19
+
+/**
+ * struct v4l2_vp8_entropy - VP8 update probabilities
+ *
+ * @coeff_probs: coefficient probability update values.
+ * @y_mode_probs: luma intra-prediction probabilities.
+ * @uv_mode_probs: chroma intra-prediction probabilities.
+ * @mv_probs: mv decoding probability.
+ * @padding: padding field. Should be zeroed by applications.
+ *
+ * This structure contains the update probabilities present in
+ * 'token_prob_update()' and 'mv_prob_update()' part of the frame header.
+ * See section '17.2. Probability Updates' of the VP8 specification
+ * for more details.
+ */
+struct v4l2_vp8_entropy {
+ __u8 coeff_probs[4][8][3][V4L2_VP8_COEFF_PROB_CNT];
+ __u8 y_mode_probs[4];
+ __u8 uv_mode_probs[3];
+ __u8 mv_probs[2][V4L2_VP8_MV_PROB_CNT];
+ __u8 padding[3];
+};
+
+/**
+ * struct v4l2_vp8_entropy_coder_state - VP8 boolean coder state
+ *
+ * @range: coder state value for "Range"
+ * @value: coder state value for "Value"
+ * @bit_count: number of bits left in range "Value".
+ * @padding: padding field. Should be zeroed by applications.
+ *
+ * This structure contains the state for the boolean coder, as
+ * explained in section '7. Boolean Entropy Decoder' of the VP8 specification.
+ */
+struct v4l2_vp8_entropy_coder_state {
+ __u8 range;
+ __u8 value;
+ __u8 bit_count;
+ __u8 padding;
+};
+
+#define V4L2_VP8_FRAME_FLAG_KEY_FRAME 0x01
+#define V4L2_VP8_FRAME_FLAG_EXPERIMENTAL 0x02
+#define V4L2_VP8_FRAME_FLAG_SHOW_FRAME 0x04
+#define V4L2_VP8_FRAME_FLAG_MB_NO_SKIP_COEFF 0x08
+#define V4L2_VP8_FRAME_FLAG_SIGN_BIAS_GOLDEN 0x10
+#define V4L2_VP8_FRAME_FLAG_SIGN_BIAS_ALT 0x20
+
+#define V4L2_VP8_FRAME_IS_KEY_FRAME(hdr) \
+ (!!((hdr)->flags & V4L2_VP8_FRAME_FLAG_KEY_FRAME))
+
+#define V4L2_CID_STATELESS_VP8_FRAME (V4L2_CID_CODEC_STATELESS_BASE + 200)
+/**
+ * struct v4l2_ctrl_vp8_frame - VP8 frame parameters
+ *
+ * @segment: segmentation parameters. See &v4l2_vp8_segment for more details
+ * @lf: loop filter parameters. See &v4l2_vp8_loop_filter for more details
+ * @quant: quantization parameters. See &v4l2_vp8_quantization for more details
+ * @entropy: update probabilities. See &v4l2_vp8_entropy for more details
+ * @coder_state: boolean coder state. See &v4l2_vp8_entropy_coder_state for more details
+ * @width: frame width.
+ * @height: frame height.
+ * @horizontal_scale: horizontal scaling factor.
+ * @vertical_scale: vertical scaling factor.
+ * @version: bitstream version.
+ * @prob_skip_false: frame header syntax element.
+ * @prob_intra: frame header syntax element.
+ * @prob_last: frame header syntax element.
+ * @prob_gf: frame header syntax element.
+ * @num_dct_parts: number of DCT coefficients partitions.
+ * @first_part_size: size of the first partition, i.e. the control partition.
+ * @first_part_header_bits: size in bits of the first partition header portion.
+ * @dct_part_sizes: DCT coefficients sizes.
+ * @last_frame_ts: "last" reference buffer timestamp.
+ * The timestamp refers to the timestamp field in struct v4l2_buffer.
+ * Use v4l2_timeval_to_ns() to convert the struct timeval to a __u64.
+ * @golden_frame_ts: "golden" reference buffer timestamp.
+ * @alt_frame_ts: "alt" reference buffer timestamp.
+ * @flags: see V4L2_VP8_FRAME_FLAG_{}.
+ */
+struct v4l2_ctrl_vp8_frame {
+ struct v4l2_vp8_segment segment;
+ struct v4l2_vp8_loop_filter lf;
+ struct v4l2_vp8_quantization quant;
+ struct v4l2_vp8_entropy entropy;
+ struct v4l2_vp8_entropy_coder_state coder_state;
+
+ __u16 width;
+ __u16 height;
+
+ __u8 horizontal_scale;
+ __u8 vertical_scale;
+
+ __u8 version;
+ __u8 prob_skip_false;
+ __u8 prob_intra;
+ __u8 prob_last;
+ __u8 prob_gf;
+ __u8 num_dct_parts;
+
+ __u32 first_part_size;
+ __u32 first_part_header_bits;
+ __u32 dct_part_sizes[8];
+
+ __u64 last_frame_ts;
+ __u64 golden_frame_ts;
+ __u64 alt_frame_ts;
+
+ __u64 flags;
+};
+
+/* Stateless MPEG-2 controls */
+
+#define V4L2_MPEG2_SEQ_FLAG_PROGRESSIVE 0x01
+
+#define V4L2_CID_STATELESS_MPEG2_SEQUENCE (V4L2_CID_CODEC_STATELESS_BASE+220)
+/**
+ * struct v4l2_ctrl_mpeg2_sequence - MPEG-2 sequence header
+ *
+ * All the members on this structure match the sequence header and sequence
+ * extension syntaxes as specified by the MPEG-2 specification.
+ *
+ * Fields horizontal_size, vertical_size and vbv_buffer_size are a
+ * combination of respective _value and extension syntax elements,
+ * as described in section 6.3.3 "Sequence header".
+ *
+ * @horizontal_size: combination of elements horizontal_size_value and
+ * horizontal_size_extension.
+ * @vertical_size: combination of elements vertical_size_value and
+ * vertical_size_extension.
+ * @vbv_buffer_size: combination of elements vbv_buffer_size_value and
+ * vbv_buffer_size_extension.
+ * @profile_and_level_indication: see MPEG-2 specification.
+ * @chroma_format: see MPEG-2 specification.
+ * @flags: see V4L2_MPEG2_SEQ_FLAG_{}.
+ */
+struct v4l2_ctrl_mpeg2_sequence {
+ __u16 horizontal_size;
+ __u16 vertical_size;
+ __u32 vbv_buffer_size;
+ __u16 profile_and_level_indication;
+ __u8 chroma_format;
+ __u8 flags;
+};
+
+#define V4L2_MPEG2_PIC_CODING_TYPE_I 1
+#define V4L2_MPEG2_PIC_CODING_TYPE_P 2
+#define V4L2_MPEG2_PIC_CODING_TYPE_B 3
+#define V4L2_MPEG2_PIC_CODING_TYPE_D 4
+
+#define V4L2_MPEG2_PIC_TOP_FIELD 0x1
+#define V4L2_MPEG2_PIC_BOTTOM_FIELD 0x2
+#define V4L2_MPEG2_PIC_FRAME 0x3
+
+#define V4L2_MPEG2_PIC_FLAG_TOP_FIELD_FIRST 0x0001
+#define V4L2_MPEG2_PIC_FLAG_FRAME_PRED_DCT 0x0002
+#define V4L2_MPEG2_PIC_FLAG_CONCEALMENT_MV 0x0004
+#define V4L2_MPEG2_PIC_FLAG_Q_SCALE_TYPE 0x0008
+#define V4L2_MPEG2_PIC_FLAG_INTRA_VLC 0x0010
+#define V4L2_MPEG2_PIC_FLAG_ALT_SCAN 0x0020
+#define V4L2_MPEG2_PIC_FLAG_REPEAT_FIRST 0x0040
+#define V4L2_MPEG2_PIC_FLAG_PROGRESSIVE 0x0080
+
+#define V4L2_CID_STATELESS_MPEG2_PICTURE (V4L2_CID_CODEC_STATELESS_BASE+221)
+/**
+ * struct v4l2_ctrl_mpeg2_picture - MPEG-2 picture header
+ *
+ * All the members on this structure match the picture header and picture
+ * coding extension syntaxes as specified by the MPEG-2 specification.
+ *
+ * @backward_ref_ts: timestamp of the V4L2 capture buffer to use as
+ * reference for backward prediction.
+ * @forward_ref_ts: timestamp of the V4L2 capture buffer to use as
+ * reference for forward prediction. These timestamp refers to the
+ * timestamp field in struct v4l2_buffer. Use v4l2_timeval_to_ns()
+ * to convert the struct timeval to a __u64.
+ * @flags: see V4L2_MPEG2_PIC_FLAG_{}.
+ * @f_code: see MPEG-2 specification.
+ * @picture_coding_type: see MPEG-2 specification.
+ * @picture_structure: see V4L2_MPEG2_PIC_{}_FIELD.
+ * @intra_dc_precision: see MPEG-2 specification.
+ * @reserved: padding field. Should be zeroed by applications.
+ */
+struct v4l2_ctrl_mpeg2_picture {
+ __u64 backward_ref_ts;
+ __u64 forward_ref_ts;
+ __u32 flags;
+ __u8 f_code[2][2];
+ __u8 picture_coding_type;
+ __u8 picture_structure;
+ __u8 intra_dc_precision;
+ __u8 reserved[5];
+};
+
+#define V4L2_CID_STATELESS_MPEG2_QUANTISATION (V4L2_CID_CODEC_STATELESS_BASE+222)
+/**
+ * struct v4l2_ctrl_mpeg2_quantisation - MPEG-2 quantisation
+ *
+ * Quantisation matrices as specified by section 6.3.7
+ * "Quant matrix extension".
+ *
+ * @intra_quantiser_matrix: The quantisation matrix coefficients
+ * for intra-coded frames, in zigzag scanning order. It is relevant
+ * for both luma and chroma components, although it can be superseded
+ * by the chroma-specific matrix for non-4:2:0 YUV formats.
+ * @non_intra_quantiser_matrix: The quantisation matrix coefficients
+ * for non-intra-coded frames, in zigzag scanning order. It is relevant
+ * for both luma and chroma components, although it can be superseded
+ * by the chroma-specific matrix for non-4:2:0 YUV formats.
+ * @chroma_intra_quantiser_matrix: The quantisation matrix coefficients
+ * for the chominance component of intra-coded frames, in zigzag scanning
+ * order. Only relevant for 4:2:2 and 4:4:4 YUV formats.
+ * @chroma_non_intra_quantiser_matrix: The quantisation matrix coefficients
+ * for the chrominance component of non-intra-coded frames, in zigzag scanning
+ * order. Only relevant for 4:2:2 and 4:4:4 YUV formats.
+ */
+struct v4l2_ctrl_mpeg2_quantisation {
+ __u8 intra_quantiser_matrix[64];
+ __u8 non_intra_quantiser_matrix[64];
+ __u8 chroma_intra_quantiser_matrix[64];
+ __u8 chroma_non_intra_quantiser_matrix[64];
+};
+
+#define V4L2_CID_STATELESS_HEVC_SPS (V4L2_CID_CODEC_STATELESS_BASE + 400)
+#define V4L2_CID_STATELESS_HEVC_PPS (V4L2_CID_CODEC_STATELESS_BASE + 401)
+#define V4L2_CID_STATELESS_HEVC_SLICE_PARAMS (V4L2_CID_CODEC_STATELESS_BASE + 402)
+#define V4L2_CID_STATELESS_HEVC_SCALING_MATRIX (V4L2_CID_CODEC_STATELESS_BASE + 403)
+#define V4L2_CID_STATELESS_HEVC_DECODE_PARAMS (V4L2_CID_CODEC_STATELESS_BASE + 404)
+#define V4L2_CID_STATELESS_HEVC_DECODE_MODE (V4L2_CID_CODEC_STATELESS_BASE + 405)
+#define V4L2_CID_STATELESS_HEVC_START_CODE (V4L2_CID_CODEC_STATELESS_BASE + 406)
+#define V4L2_CID_STATELESS_HEVC_ENTRY_POINT_OFFSETS (V4L2_CID_CODEC_STATELESS_BASE + 407)
+
+enum v4l2_stateless_hevc_decode_mode {
+ V4L2_STATELESS_HEVC_DECODE_MODE_SLICE_BASED,
+ V4L2_STATELESS_HEVC_DECODE_MODE_FRAME_BASED,
+};
+
+enum v4l2_stateless_hevc_start_code {
+ V4L2_STATELESS_HEVC_START_CODE_NONE,
+ V4L2_STATELESS_HEVC_START_CODE_ANNEX_B,
+};
+
+#define V4L2_HEVC_SLICE_TYPE_B 0
+#define V4L2_HEVC_SLICE_TYPE_P 1
+#define V4L2_HEVC_SLICE_TYPE_I 2
+
+#define V4L2_HEVC_SPS_FLAG_SEPARATE_COLOUR_PLANE (1ULL << 0)
+#define V4L2_HEVC_SPS_FLAG_SCALING_LIST_ENABLED (1ULL << 1)
+#define V4L2_HEVC_SPS_FLAG_AMP_ENABLED (1ULL << 2)
+#define V4L2_HEVC_SPS_FLAG_SAMPLE_ADAPTIVE_OFFSET (1ULL << 3)
+#define V4L2_HEVC_SPS_FLAG_PCM_ENABLED (1ULL << 4)
+#define V4L2_HEVC_SPS_FLAG_PCM_LOOP_FILTER_DISABLED (1ULL << 5)
+#define V4L2_HEVC_SPS_FLAG_LONG_TERM_REF_PICS_PRESENT (1ULL << 6)
+#define V4L2_HEVC_SPS_FLAG_SPS_TEMPORAL_MVP_ENABLED (1ULL << 7)
+#define V4L2_HEVC_SPS_FLAG_STRONG_INTRA_SMOOTHING_ENABLED (1ULL << 8)
+
+/**
+ * struct v4l2_ctrl_hevc_sps - ITU-T Rec. H.265: Sequence parameter set
+ *
+ * @video_parameter_set_id: specifies the value of the
+ * vps_video_parameter_set_id of the active VPS
+ * @seq_parameter_set_id: provides an identifier for the SPS for
+ * reference by other syntax elements
+ * @pic_width_in_luma_samples: specifies the width of each decoded picture
+ * in units of luma samples
+ * @pic_height_in_luma_samples: specifies the height of each decoded picture
+ * in units of luma samples
+ * @bit_depth_luma_minus8: this value plus 8specifies the bit depth of the
+ * samples of the luma array
+ * @bit_depth_chroma_minus8: this value plus 8 specifies the bit depth of the
+ * samples of the chroma arrays
+ * @log2_max_pic_order_cnt_lsb_minus4: this value plus 4 specifies the value of
+ * the variable MaxPicOrderCntLsb
+ * @sps_max_dec_pic_buffering_minus1: this value plus 1 specifies the maximum
+ * required size of the decoded picture
+ * buffer for the codec video sequence
+ * @sps_max_num_reorder_pics: indicates the maximum allowed number of pictures
+ * @sps_max_latency_increase_plus1: not equal to 0 is used to compute the
+ * value of SpsMaxLatencyPictures array
+ * @log2_min_luma_coding_block_size_minus3: plus 3 specifies the minimum
+ * luma coding block size
+ * @log2_diff_max_min_luma_coding_block_size: specifies the difference between
+ * the maximum and minimum luma
+ * coding block size
+ * @log2_min_luma_transform_block_size_minus2: plus 2 specifies the minimum luma
+ * transform block size
+ * @log2_diff_max_min_luma_transform_block_size: specifies the difference between
+ * the maximum and minimum luma
+ * transform block size
+ * @max_transform_hierarchy_depth_inter: specifies the maximum hierarchy
+ * depth for transform units of
+ * coding units coded in inter
+ * prediction mode
+ * @max_transform_hierarchy_depth_intra: specifies the maximum hierarchy
+ * depth for transform units of
+ * coding units coded in intra
+ * prediction mode
+ * @pcm_sample_bit_depth_luma_minus1: this value plus 1 specifies the number of
+ * bits used to represent each of PCM sample
+ * values of the luma component
+ * @pcm_sample_bit_depth_chroma_minus1: this value plus 1 specifies the number
+ * of bits used to represent each of PCM
+ * sample values of the chroma components
+ * @log2_min_pcm_luma_coding_block_size_minus3: this value plus 3 specifies the
+ * minimum size of coding blocks
+ * @log2_diff_max_min_pcm_luma_coding_block_size: specifies the difference between
+ * the maximum and minimum size of
+ * coding blocks
+ * @num_short_term_ref_pic_sets: specifies the number of st_ref_pic_set()
+ * syntax structures included in the SPS
+ * @num_long_term_ref_pics_sps: specifies the number of candidate long-term
+ * reference pictures that are specified in the SPS
+ * @chroma_format_idc: specifies the chroma sampling
+ * @sps_max_sub_layers_minus1: this value plus 1 specifies the maximum number
+ * of temporal sub-layers
+ * @reserved: padding field. Should be zeroed by applications.
+ * @flags: see V4L2_HEVC_SPS_FLAG_{}
+ */
+struct v4l2_ctrl_hevc_sps {
+ __u8 video_parameter_set_id;
+ __u8 seq_parameter_set_id;
+ __u16 pic_width_in_luma_samples;
+ __u16 pic_height_in_luma_samples;
+ __u8 bit_depth_luma_minus8;
+ __u8 bit_depth_chroma_minus8;
+ __u8 log2_max_pic_order_cnt_lsb_minus4;
+ __u8 sps_max_dec_pic_buffering_minus1;
+ __u8 sps_max_num_reorder_pics;
+ __u8 sps_max_latency_increase_plus1;
+ __u8 log2_min_luma_coding_block_size_minus3;
+ __u8 log2_diff_max_min_luma_coding_block_size;
+ __u8 log2_min_luma_transform_block_size_minus2;
+ __u8 log2_diff_max_min_luma_transform_block_size;
+ __u8 max_transform_hierarchy_depth_inter;
+ __u8 max_transform_hierarchy_depth_intra;
+ __u8 pcm_sample_bit_depth_luma_minus1;
+ __u8 pcm_sample_bit_depth_chroma_minus1;
+ __u8 log2_min_pcm_luma_coding_block_size_minus3;
+ __u8 log2_diff_max_min_pcm_luma_coding_block_size;
+ __u8 num_short_term_ref_pic_sets;
+ __u8 num_long_term_ref_pics_sps;
+ __u8 chroma_format_idc;
+ __u8 sps_max_sub_layers_minus1;
+
+ __u8 reserved[6];
+ __u64 flags;
+};
+
+#define V4L2_HEVC_PPS_FLAG_DEPENDENT_SLICE_SEGMENT_ENABLED (1ULL << 0)
+#define V4L2_HEVC_PPS_FLAG_OUTPUT_FLAG_PRESENT (1ULL << 1)
+#define V4L2_HEVC_PPS_FLAG_SIGN_DATA_HIDING_ENABLED (1ULL << 2)
+#define V4L2_HEVC_PPS_FLAG_CABAC_INIT_PRESENT (1ULL << 3)
+#define V4L2_HEVC_PPS_FLAG_CONSTRAINED_INTRA_PRED (1ULL << 4)
+#define V4L2_HEVC_PPS_FLAG_TRANSFORM_SKIP_ENABLED (1ULL << 5)
+#define V4L2_HEVC_PPS_FLAG_CU_QP_DELTA_ENABLED (1ULL << 6)
+#define V4L2_HEVC_PPS_FLAG_PPS_SLICE_CHROMA_QP_OFFSETS_PRESENT (1ULL << 7)
+#define V4L2_HEVC_PPS_FLAG_WEIGHTED_PRED (1ULL << 8)
+#define V4L2_HEVC_PPS_FLAG_WEIGHTED_BIPRED (1ULL << 9)
+#define V4L2_HEVC_PPS_FLAG_TRANSQUANT_BYPASS_ENABLED (1ULL << 10)
+#define V4L2_HEVC_PPS_FLAG_TILES_ENABLED (1ULL << 11)
+#define V4L2_HEVC_PPS_FLAG_ENTROPY_CODING_SYNC_ENABLED (1ULL << 12)
+#define V4L2_HEVC_PPS_FLAG_LOOP_FILTER_ACROSS_TILES_ENABLED (1ULL << 13)
+#define V4L2_HEVC_PPS_FLAG_PPS_LOOP_FILTER_ACROSS_SLICES_ENABLED (1ULL << 14)
+#define V4L2_HEVC_PPS_FLAG_DEBLOCKING_FILTER_OVERRIDE_ENABLED (1ULL << 15)
+#define V4L2_HEVC_PPS_FLAG_PPS_DISABLE_DEBLOCKING_FILTER (1ULL << 16)
+#define V4L2_HEVC_PPS_FLAG_LISTS_MODIFICATION_PRESENT (1ULL << 17)
+#define V4L2_HEVC_PPS_FLAG_SLICE_SEGMENT_HEADER_EXTENSION_PRESENT (1ULL << 18)
+#define V4L2_HEVC_PPS_FLAG_DEBLOCKING_FILTER_CONTROL_PRESENT (1ULL << 19)
+#define V4L2_HEVC_PPS_FLAG_UNIFORM_SPACING (1ULL << 20)
+
+/**
+ * struct v4l2_ctrl_hevc_pps - ITU-T Rec. H.265: Picture parameter set
+ *
+ * @pic_parameter_set_id: identifies the PPS for reference by other
+ * syntax elements
+ * @num_extra_slice_header_bits: specifies the number of extra slice header
+ * bits that are present in the slice header RBSP
+ * for coded pictures referring to the PPS.
+ * @num_ref_idx_l0_default_active_minus1: this value plus 1 specifies the
+ * inferred value of num_ref_idx_l0_active_minus1
+ * @num_ref_idx_l1_default_active_minus1: this value plus 1 specifies the
+ * inferred value of num_ref_idx_l1_active_minus1
+ * @init_qp_minus26: this value plus 26 specifies the initial value of SliceQp Y for
+ * each slice referring to the PPS
+ * @diff_cu_qp_delta_depth: specifies the difference between the luma coding
+ * tree block size and the minimum luma coding block
+ * size of coding units that convey cu_qp_delta_abs
+ * and cu_qp_delta_sign_flag
+ * @pps_cb_qp_offset: specify the offsets to the luma quantization parameter Cb
+ * @pps_cr_qp_offset: specify the offsets to the luma quantization parameter Cr
+ * @num_tile_columns_minus1: this value plus 1 specifies the number of tile columns
+ * partitioning the picture
+ * @num_tile_rows_minus1: this value plus 1 specifies the number of tile rows partitioning
+ * the picture
+ * @column_width_minus1: this value plus 1 specifies the width of the each tile column in
+ * units of coding tree blocks
+ * @row_height_minus1: this value plus 1 specifies the height of the each tile row in
+ * units of coding tree blocks
+ * @pps_beta_offset_div2: specify the default deblocking parameter offsets for
+ * beta divided by 2
+ * @pps_tc_offset_div2: specify the default deblocking parameter offsets for tC
+ * divided by 2
+ * @log2_parallel_merge_level_minus2: this value plus 2 specifies the value of
+ * the variable Log2ParMrgLevel
+ * @reserved: padding field. Should be zeroed by applications.
+ * @flags: see V4L2_HEVC_PPS_FLAG_{}
+ */
+struct v4l2_ctrl_hevc_pps {
+ __u8 pic_parameter_set_id;
+ __u8 num_extra_slice_header_bits;
+ __u8 num_ref_idx_l0_default_active_minus1;
+ __u8 num_ref_idx_l1_default_active_minus1;
+ __s8 init_qp_minus26;
+ __u8 diff_cu_qp_delta_depth;
+ __s8 pps_cb_qp_offset;
+ __s8 pps_cr_qp_offset;
+ __u8 num_tile_columns_minus1;
+ __u8 num_tile_rows_minus1;
+ __u8 column_width_minus1[20];
+ __u8 row_height_minus1[22];
+ __s8 pps_beta_offset_div2;
+ __s8 pps_tc_offset_div2;
+ __u8 log2_parallel_merge_level_minus2;
+ __u8 reserved;
+ __u64 flags;
+};
+
+#define V4L2_HEVC_DPB_ENTRY_LONG_TERM_REFERENCE 0x01
+
+#define V4L2_HEVC_SEI_PIC_STRUCT_FRAME 0
+#define V4L2_HEVC_SEI_PIC_STRUCT_TOP_FIELD 1
+#define V4L2_HEVC_SEI_PIC_STRUCT_BOTTOM_FIELD 2
+#define V4L2_HEVC_SEI_PIC_STRUCT_TOP_BOTTOM 3
+#define V4L2_HEVC_SEI_PIC_STRUCT_BOTTOM_TOP 4
+#define V4L2_HEVC_SEI_PIC_STRUCT_TOP_BOTTOM_TOP 5
+#define V4L2_HEVC_SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM 6
+#define V4L2_HEVC_SEI_PIC_STRUCT_FRAME_DOUBLING 7
+#define V4L2_HEVC_SEI_PIC_STRUCT_FRAME_TRIPLING 8
+#define V4L2_HEVC_SEI_PIC_STRUCT_TOP_PAIRED_PREVIOUS_BOTTOM 9
+#define V4L2_HEVC_SEI_PIC_STRUCT_BOTTOM_PAIRED_PREVIOUS_TOP 10
+#define V4L2_HEVC_SEI_PIC_STRUCT_TOP_PAIRED_NEXT_BOTTOM 11
+#define V4L2_HEVC_SEI_PIC_STRUCT_BOTTOM_PAIRED_NEXT_TOP 12
+
+#define V4L2_HEVC_DPB_ENTRIES_NUM_MAX 16
+
+/**
+ * struct v4l2_hevc_dpb_entry - HEVC decoded picture buffer entry
+ *
+ * @timestamp: timestamp of the V4L2 capture buffer to use as reference.
+ * @flags: long term flag for the reference frame
+ * @field_pic: whether the reference is a field picture or a frame.
+ * @reserved: padding field. Should be zeroed by applications.
+ * @pic_order_cnt_val: the picture order count of the current picture.
+ */
+struct v4l2_hevc_dpb_entry {
+ __u64 timestamp;
+ __u8 flags;
+ __u8 field_pic;
+ __u16 reserved;
+ __s32 pic_order_cnt_val;
+};
+
+/**
+ * struct v4l2_hevc_pred_weight_table - HEVC weighted prediction parameters
+ *
+ * @delta_luma_weight_l0: the difference of the weighting factor applied
+ * to the luma prediction value for list 0
+ * @luma_offset_l0: the additive offset applied to the luma prediction value
+ * for list 0
+ * @delta_chroma_weight_l0: the difference of the weighting factor applied
+ * to the chroma prediction values for list 0
+ * @chroma_offset_l0: the difference of the additive offset applied to
+ * the chroma prediction values for list 0
+ * @delta_luma_weight_l1: the difference of the weighting factor applied
+ * to the luma prediction value for list 1
+ * @luma_offset_l1: the additive offset applied to the luma prediction value
+ * for list 1
+ * @delta_chroma_weight_l1: the difference of the weighting factor applied
+ * to the chroma prediction values for list 1
+ * @chroma_offset_l1: the difference of the additive offset applied to
+ * the chroma prediction values for list 1
+ * @luma_log2_weight_denom: the base 2 logarithm of the denominator for
+ * all luma weighting factors
+ * @delta_chroma_log2_weight_denom: the difference of the base 2 logarithm
+ * of the denominator for all chroma
+ * weighting factors
+ */
+struct v4l2_hevc_pred_weight_table {
+ __s8 delta_luma_weight_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+ __s8 luma_offset_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+ __s8 delta_chroma_weight_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX][2];
+ __s8 chroma_offset_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX][2];
+
+ __s8 delta_luma_weight_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+ __s8 luma_offset_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+ __s8 delta_chroma_weight_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX][2];
+ __s8 chroma_offset_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX][2];
+
+ __u8 luma_log2_weight_denom;
+ __s8 delta_chroma_log2_weight_denom;
+};
+
+#define V4L2_HEVC_SLICE_PARAMS_FLAG_SLICE_SAO_LUMA (1ULL << 0)
+#define V4L2_HEVC_SLICE_PARAMS_FLAG_SLICE_SAO_CHROMA (1ULL << 1)
+#define V4L2_HEVC_SLICE_PARAMS_FLAG_SLICE_TEMPORAL_MVP_ENABLED (1ULL << 2)
+#define V4L2_HEVC_SLICE_PARAMS_FLAG_MVD_L1_ZERO (1ULL << 3)
+#define V4L2_HEVC_SLICE_PARAMS_FLAG_CABAC_INIT (1ULL << 4)
+#define V4L2_HEVC_SLICE_PARAMS_FLAG_COLLOCATED_FROM_L0 (1ULL << 5)
+#define V4L2_HEVC_SLICE_PARAMS_FLAG_USE_INTEGER_MV (1ULL << 6)
+#define V4L2_HEVC_SLICE_PARAMS_FLAG_SLICE_DEBLOCKING_FILTER_DISABLED (1ULL << 7)
+#define V4L2_HEVC_SLICE_PARAMS_FLAG_SLICE_LOOP_FILTER_ACROSS_SLICES_ENABLED (1ULL << 8)
+#define V4L2_HEVC_SLICE_PARAMS_FLAG_DEPENDENT_SLICE_SEGMENT (1ULL << 9)
+
+/**
+ * struct v4l2_ctrl_hevc_slice_params - HEVC slice parameters
+ *
+ * This control is a dynamically sized 1-dimensional array,
+ * V4L2_CTRL_FLAG_DYNAMIC_ARRAY flag must be set when using it.
+ *
+ * @bit_size: size (in bits) of the current slice data
+ * @data_byte_offset: offset (in bytes) to the video data in the current slice data
+ * @num_entry_point_offsets: specifies the number of entry point offset syntax
+ * elements in the slice header.
+ * @nal_unit_type: specifies the coding type of the slice (B, P or I)
+ * @nuh_temporal_id_plus1: minus 1 specifies a temporal identifier for the NAL unit
+ * @slice_type: see V4L2_HEVC_SLICE_TYPE_{}
+ * @colour_plane_id: specifies the colour plane associated with the current slice
+ * @slice_pic_order_cnt: specifies the picture order count
+ * @num_ref_idx_l0_active_minus1: this value plus 1 specifies the maximum
+ * reference index for reference picture list 0
+ * that may be used to decode the slice
+ * @num_ref_idx_l1_active_minus1: this value plus 1 specifies the maximum
+ * reference index for reference picture list 1
+ * that may be used to decode the slice
+ * @collocated_ref_idx: specifies the reference index of the collocated picture used
+ * for temporal motion vector prediction
+ * @five_minus_max_num_merge_cand: specifies the maximum number of merging
+ * motion vector prediction candidates supported in
+ * the slice subtracted from 5
+ * @slice_qp_delta: specifies the initial value of QpY to be used for the coding
+ * blocks in the slice
+ * @slice_cb_qp_offset: specifies a difference to be added to the value of pps_cb_qp_offset
+ * @slice_cr_qp_offset: specifies a difference to be added to the value of pps_cr_qp_offset
+ * @slice_act_y_qp_offset: screen content extension parameters
+ * @slice_act_cb_qp_offset: screen content extension parameters
+ * @slice_act_cr_qp_offset: screen content extension parameters
+ * @slice_beta_offset_div2: specify the deblocking parameter offsets for beta divided by 2
+ * @slice_tc_offset_div2: specify the deblocking parameter offsets for tC divided by 2
+ * @pic_struct: indicates whether a picture should be displayed as a frame or as one or
+ * more fields
+ * @reserved0: padding field. Should be zeroed by applications.
+ * @slice_segment_addr: specifies the address of the first coding tree block in
+ * the slice segment
+ * @ref_idx_l0: the list of L0 reference elements as indices in the DPB
+ * @ref_idx_l1: the list of L1 reference elements as indices in the DPB
+ * @short_term_ref_pic_set_size: specifies the size of short-term reference
+ * pictures set included in the SPS
+ * @long_term_ref_pic_set_size: specifies the size of long-term reference
+ * pictures set include in the SPS
+ * @pred_weight_table: the prediction weight coefficients for inter-picture
+ * prediction
+ * @reserved1: padding field. Should be zeroed by applications.
+ * @flags: see V4L2_HEVC_SLICE_PARAMS_FLAG_{}
+ */
+struct v4l2_ctrl_hevc_slice_params {
+ __u32 bit_size;
+ __u32 data_byte_offset;
+ __u32 num_entry_point_offsets;
+
+ /* ISO/IEC 23008-2, ITU-T Rec. H.265: NAL unit header */
+ __u8 nal_unit_type;
+ __u8 nuh_temporal_id_plus1;
+
+ /* ISO/IEC 23008-2, ITU-T Rec. H.265: General slice segment header */
+ __u8 slice_type;
+ __u8 colour_plane_id;
+ __s32 slice_pic_order_cnt;
+ __u8 num_ref_idx_l0_active_minus1;
+ __u8 num_ref_idx_l1_active_minus1;
+ __u8 collocated_ref_idx;
+ __u8 five_minus_max_num_merge_cand;
+ __s8 slice_qp_delta;
+ __s8 slice_cb_qp_offset;
+ __s8 slice_cr_qp_offset;
+ __s8 slice_act_y_qp_offset;
+ __s8 slice_act_cb_qp_offset;
+ __s8 slice_act_cr_qp_offset;
+ __s8 slice_beta_offset_div2;
+ __s8 slice_tc_offset_div2;
+
+ /* ISO/IEC 23008-2, ITU-T Rec. H.265: Picture timing SEI message */
+ __u8 pic_struct;
+
+ __u8 reserved0[3];
+ /* ISO/IEC 23008-2, ITU-T Rec. H.265: General slice segment header */
+ __u32 slice_segment_addr;
+ __u8 ref_idx_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+ __u8 ref_idx_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+ __u16 short_term_ref_pic_set_size;
+ __u16 long_term_ref_pic_set_size;
+
+ /* ISO/IEC 23008-2, ITU-T Rec. H.265: Weighted prediction parameter */
+ struct v4l2_hevc_pred_weight_table pred_weight_table;
+
+ __u8 reserved1[2];
+ __u64 flags;
+};
+
+#define V4L2_HEVC_DECODE_PARAM_FLAG_IRAP_PIC 0x1
+#define V4L2_HEVC_DECODE_PARAM_FLAG_IDR_PIC 0x2
+#define V4L2_HEVC_DECODE_PARAM_FLAG_NO_OUTPUT_OF_PRIOR 0x4
+
+/**
+ * struct v4l2_ctrl_hevc_decode_params - HEVC decode parameters
+ *
+ * @pic_order_cnt_val: picture order count
+ * @short_term_ref_pic_set_size: specifies the size of short-term reference
+ * pictures set included in the SPS of the first slice
+ * @long_term_ref_pic_set_size: specifies the size of long-term reference
+ * pictures set include in the SPS of the first slice
+ * @num_active_dpb_entries: the number of entries in dpb
+ * @num_poc_st_curr_before: the number of reference pictures in the short-term
+ * set that come before the current frame
+ * @num_poc_st_curr_after: the number of reference pictures in the short-term
+ * set that come after the current frame
+ * @num_poc_lt_curr: the number of reference pictures in the long-term set
+ * @poc_st_curr_before: provides the index of the short term before references
+ * in DPB array
+ * @poc_st_curr_after: provides the index of the short term after references
+ * in DPB array
+ * @poc_lt_curr: provides the index of the long term references in DPB array
+ * @num_delta_pocs_of_ref_rps_idx: same as the derived value NumDeltaPocs[RefRpsIdx],
+ * can be used to parse the RPS data in slice headers
+ * instead of skipping it with @short_term_ref_pic_set_size.
+ * @reserved: padding field. Should be zeroed by applications.
+ * @dpb: the decoded picture buffer, for meta-data about reference frames
+ * @flags: see V4L2_HEVC_DECODE_PARAM_FLAG_{}
+ */
+struct v4l2_ctrl_hevc_decode_params {
+ __s32 pic_order_cnt_val;
+ __u16 short_term_ref_pic_set_size;
+ __u16 long_term_ref_pic_set_size;
+ __u8 num_active_dpb_entries;
+ __u8 num_poc_st_curr_before;
+ __u8 num_poc_st_curr_after;
+ __u8 num_poc_lt_curr;
+ __u8 poc_st_curr_before[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+ __u8 poc_st_curr_after[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+ __u8 poc_lt_curr[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+ __u8 num_delta_pocs_of_ref_rps_idx;
+ __u8 reserved[3];
+ struct v4l2_hevc_dpb_entry dpb[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+ __u64 flags;
+};
+
+/**
+ * struct v4l2_ctrl_hevc_scaling_matrix - HEVC scaling lists parameters
+ *
+ * @scaling_list_4x4: scaling list is used for the scaling process for
+ * transform coefficients. The values on each scaling
+ * list are expected in raster scan order
+ * @scaling_list_8x8: scaling list is used for the scaling process for
+ * transform coefficients. The values on each scaling
+ * list are expected in raster scan order
+ * @scaling_list_16x16: scaling list is used for the scaling process for
+ * transform coefficients. The values on each scaling
+ * list are expected in raster scan order
+ * @scaling_list_32x32: scaling list is used for the scaling process for
+ * transform coefficients. The values on each scaling
+ * list are expected in raster scan order
+ * @scaling_list_dc_coef_16x16: scaling list is used for the scaling process
+ * for transform coefficients. The values on each
+ * scaling list are expected in raster scan order.
+ * @scaling_list_dc_coef_32x32: scaling list is used for the scaling process
+ * for transform coefficients. The values on each
+ * scaling list are expected in raster scan order.
+ */
+struct v4l2_ctrl_hevc_scaling_matrix {
+ __u8 scaling_list_4x4[6][16];
+ __u8 scaling_list_8x8[6][64];
+ __u8 scaling_list_16x16[6][64];
+ __u8 scaling_list_32x32[2][64];
+ __u8 scaling_list_dc_coef_16x16[6];
+ __u8 scaling_list_dc_coef_32x32[2];
+};
+
+#define V4L2_CID_COLORIMETRY_CLASS_BASE (V4L2_CTRL_CLASS_COLORIMETRY | 0x900)
+#define V4L2_CID_COLORIMETRY_CLASS (V4L2_CTRL_CLASS_COLORIMETRY | 1)
+
+#define V4L2_CID_COLORIMETRY_HDR10_CLL_INFO (V4L2_CID_COLORIMETRY_CLASS_BASE + 0)
+
+struct v4l2_ctrl_hdr10_cll_info {
+ __u16 max_content_light_level;
+ __u16 max_pic_average_light_level;
+};
+
+#define V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY (V4L2_CID_COLORIMETRY_CLASS_BASE + 1)
+
+#define V4L2_HDR10_MASTERING_PRIMARIES_X_LOW 5
+#define V4L2_HDR10_MASTERING_PRIMARIES_X_HIGH 37000
+#define V4L2_HDR10_MASTERING_PRIMARIES_Y_LOW 5
+#define V4L2_HDR10_MASTERING_PRIMARIES_Y_HIGH 42000
+#define V4L2_HDR10_MASTERING_WHITE_POINT_X_LOW 5
+#define V4L2_HDR10_MASTERING_WHITE_POINT_X_HIGH 37000
+#define V4L2_HDR10_MASTERING_WHITE_POINT_Y_LOW 5
+#define V4L2_HDR10_MASTERING_WHITE_POINT_Y_HIGH 42000
+#define V4L2_HDR10_MASTERING_MAX_LUMA_LOW 50000
+#define V4L2_HDR10_MASTERING_MAX_LUMA_HIGH 100000000
+#define V4L2_HDR10_MASTERING_MIN_LUMA_LOW 1
+#define V4L2_HDR10_MASTERING_MIN_LUMA_HIGH 50000
+
+struct v4l2_ctrl_hdr10_mastering_display {
+ __u16 display_primaries_x[3];
+ __u16 display_primaries_y[3];
+ __u16 white_point_x;
+ __u16 white_point_y;
+ __u32 max_display_mastering_luminance;
+ __u32 min_display_mastering_luminance;
+};
+
+/* Stateless VP9 controls */
+
+#define V4L2_VP9_LOOP_FILTER_FLAG_DELTA_ENABLED 0x1
+#define V4L2_VP9_LOOP_FILTER_FLAG_DELTA_UPDATE 0x2
+
+/**
+ * struct v4l2_vp9_loop_filter - VP9 loop filter parameters
+ *
+ * @ref_deltas: contains the adjustment needed for the filter level based on the
+ * chosen reference frame. If this syntax element is not present in the bitstream,
+ * users should pass its last value.
+ * @mode_deltas: contains the adjustment needed for the filter level based on the
+ * chosen mode. If this syntax element is not present in the bitstream, users should
+ * pass its last value.
+ * @level: indicates the loop filter strength.
+ * @sharpness: indicates the sharpness level.
+ * @flags: combination of V4L2_VP9_LOOP_FILTER_FLAG_{} flags.
+ * @reserved: padding field. Should be zeroed by applications.
+ *
+ * This structure contains all loop filter related parameters. See sections
+ * '7.2.8 Loop filter semantics' of the VP9 specification for more details.
+ */
+struct v4l2_vp9_loop_filter {
+ __s8 ref_deltas[4];
+ __s8 mode_deltas[2];
+ __u8 level;
+ __u8 sharpness;
+ __u8 flags;
+ __u8 reserved[7];
+};
+
+/**
+ * struct v4l2_vp9_quantization - VP9 quantization parameters
+ *
+ * @base_q_idx: indicates the base frame qindex.
+ * @delta_q_y_dc: indicates the Y DC quantizer relative to base_q_idx.
+ * @delta_q_uv_dc: indicates the UV DC quantizer relative to base_q_idx.
+ * @delta_q_uv_ac: indicates the UV AC quantizer relative to base_q_idx.
+ * @reserved: padding field. Should be zeroed by applications.
+ *
+ * Encodes the quantization parameters. See section '7.2.9 Quantization params
+ * syntax' of the VP9 specification for more details.
+ */
+struct v4l2_vp9_quantization {
+ __u8 base_q_idx;
+ __s8 delta_q_y_dc;
+ __s8 delta_q_uv_dc;
+ __s8 delta_q_uv_ac;
+ __u8 reserved[4];
+};
+
+#define V4L2_VP9_SEGMENTATION_FLAG_ENABLED 0x01
+#define V4L2_VP9_SEGMENTATION_FLAG_UPDATE_MAP 0x02
+#define V4L2_VP9_SEGMENTATION_FLAG_TEMPORAL_UPDATE 0x04
+#define V4L2_VP9_SEGMENTATION_FLAG_UPDATE_DATA 0x08
+#define V4L2_VP9_SEGMENTATION_FLAG_ABS_OR_DELTA_UPDATE 0x10
+
+#define V4L2_VP9_SEG_LVL_ALT_Q 0
+#define V4L2_VP9_SEG_LVL_ALT_L 1
+#define V4L2_VP9_SEG_LVL_REF_FRAME 2
+#define V4L2_VP9_SEG_LVL_SKIP 3
+#define V4L2_VP9_SEG_LVL_MAX 4
+
+#define V4L2_VP9_SEGMENT_FEATURE_ENABLED(id) (1 << (id))
+#define V4L2_VP9_SEGMENT_FEATURE_ENABLED_MASK 0xf
+
+/**
+ * struct v4l2_vp9_segmentation - VP9 segmentation parameters
+ *
+ * @feature_data: data attached to each feature. Data entry is only valid if
+ * the feature is enabled. The array shall be indexed with segment number as
+ * the first dimension (0..7) and one of V4L2_VP9_SEG_{} as the second dimension.
+ * @feature_enabled: bitmask defining which features are enabled in each segment.
+ * The value for each segment is a combination of V4L2_VP9_SEGMENT_FEATURE_ENABLED(id)
+ * values where id is one of V4L2_VP9_SEG_LVL_{}.
+ * @tree_probs: specifies the probability values to be used when decoding a
+ * Segment-ID. See '5.15. Segmentation map' section of the VP9 specification
+ * for more details.
+ * @pred_probs: specifies the probability values to be used when decoding a
+ * Predicted-Segment-ID. See '6.4.14. Get segment id syntax' section of :ref:`vp9`
+ * for more details.
+ * @flags: combination of V4L2_VP9_SEGMENTATION_FLAG_{} flags.
+ * @reserved: padding field. Should be zeroed by applications.
+ *
+ * Encodes the quantization parameters. See section '7.2.10 Segmentation params syntax' of
+ * the VP9 specification for more details.
+ */
+struct v4l2_vp9_segmentation {
+ __s16 feature_data[8][4];
+ __u8 feature_enabled[8];
+ __u8 tree_probs[7];
+ __u8 pred_probs[3];
+ __u8 flags;
+ __u8 reserved[5];
+};
+
+#define V4L2_VP9_FRAME_FLAG_KEY_FRAME 0x001
+#define V4L2_VP9_FRAME_FLAG_SHOW_FRAME 0x002
+#define V4L2_VP9_FRAME_FLAG_ERROR_RESILIENT 0x004
+#define V4L2_VP9_FRAME_FLAG_INTRA_ONLY 0x008
+#define V4L2_VP9_FRAME_FLAG_ALLOW_HIGH_PREC_MV 0x010
+#define V4L2_VP9_FRAME_FLAG_REFRESH_FRAME_CTX 0x020
+#define V4L2_VP9_FRAME_FLAG_PARALLEL_DEC_MODE 0x040
+#define V4L2_VP9_FRAME_FLAG_X_SUBSAMPLING 0x080
+#define V4L2_VP9_FRAME_FLAG_Y_SUBSAMPLING 0x100
+#define V4L2_VP9_FRAME_FLAG_COLOR_RANGE_FULL_SWING 0x200
+
+#define V4L2_VP9_SIGN_BIAS_LAST 0x1
+#define V4L2_VP9_SIGN_BIAS_GOLDEN 0x2
+#define V4L2_VP9_SIGN_BIAS_ALT 0x4
+
+#define V4L2_VP9_RESET_FRAME_CTX_NONE 0
+#define V4L2_VP9_RESET_FRAME_CTX_SPEC 1
+#define V4L2_VP9_RESET_FRAME_CTX_ALL 2
+
+#define V4L2_VP9_INTERP_FILTER_EIGHTTAP 0
+#define V4L2_VP9_INTERP_FILTER_EIGHTTAP_SMOOTH 1
+#define V4L2_VP9_INTERP_FILTER_EIGHTTAP_SHARP 2
+#define V4L2_VP9_INTERP_FILTER_BILINEAR 3
+#define V4L2_VP9_INTERP_FILTER_SWITCHABLE 4
+
+#define V4L2_VP9_REFERENCE_MODE_SINGLE_REFERENCE 0
+#define V4L2_VP9_REFERENCE_MODE_COMPOUND_REFERENCE 1
+#define V4L2_VP9_REFERENCE_MODE_SELECT 2
+
+#define V4L2_VP9_PROFILE_MAX 3
+
+#define V4L2_CID_STATELESS_VP9_FRAME (V4L2_CID_CODEC_STATELESS_BASE + 300)
+/**
+ * struct v4l2_ctrl_vp9_frame - VP9 frame decoding control
+ *
+ * @lf: loop filter parameters. See &v4l2_vp9_loop_filter for more details.
+ * @quant: quantization parameters. See &v4l2_vp9_quantization for more details.
+ * @seg: segmentation parameters. See &v4l2_vp9_segmentation for more details.
+ * @flags: combination of V4L2_VP9_FRAME_FLAG_{} flags.
+ * @compressed_header_size: compressed header size in bytes.
+ * @uncompressed_header_size: uncompressed header size in bytes.
+ * @frame_width_minus_1: add 1 to it and you'll get the frame width expressed in pixels.
+ * @frame_height_minus_1: add 1 to it and you'll get the frame height expressed in pixels.
+ * @render_width_minus_1: add 1 to it and you'll get the expected render width expressed in
+ * pixels. This is not used during the decoding process but might be used by HW scalers
+ * to prepare a frame that's ready for scanout.
+ * @render_height_minus_1: add 1 to it and you'll get the expected render height expressed in
+ * pixels. This is not used during the decoding process but might be used by HW scalers
+ * to prepare a frame that's ready for scanout.
+ * @last_frame_ts: "last" reference buffer timestamp.
+ * The timestamp refers to the timestamp field in struct v4l2_buffer.
+ * Use v4l2_timeval_to_ns() to convert the struct timeval to a __u64.
+ * @golden_frame_ts: "golden" reference buffer timestamp.
+ * The timestamp refers to the timestamp field in struct v4l2_buffer.
+ * Use v4l2_timeval_to_ns() to convert the struct timeval to a __u64.
+ * @alt_frame_ts: "alt" reference buffer timestamp.
+ * The timestamp refers to the timestamp field in struct v4l2_buffer.
+ * Use v4l2_timeval_to_ns() to convert the struct timeval to a __u64.
+ * @ref_frame_sign_bias: a bitfield specifying whether the sign bias is set for a given
+ * reference frame. Either of V4L2_VP9_SIGN_BIAS_{}.
+ * @reset_frame_context: specifies whether the frame context should be reset to default values.
+ * Either of V4L2_VP9_RESET_FRAME_CTX_{}.
+ * @frame_context_idx: frame context that should be used/updated.
+ * @profile: VP9 profile. Can be 0, 1, 2 or 3.
+ * @bit_depth: bits per components. Can be 8, 10 or 12. Note that not all profiles support
+ * 10 and/or 12 bits depths.
+ * @interpolation_filter: specifies the filter selection used for performing inter prediction.
+ * Set to one of V4L2_VP9_INTERP_FILTER_{}.
+ * @tile_cols_log2: specifies the base 2 logarithm of the width of each tile (where the width
+ * is measured in units of 8x8 blocks). Shall be less than or equal to 6.
+ * @tile_rows_log2: specifies the base 2 logarithm of the height of each tile (where the height
+ * is measured in units of 8x8 blocks).
+ * @reference_mode: specifies the type of inter prediction to be used.
+ * Set to one of V4L2_VP9_REFERENCE_MODE_{}.
+ * @reserved: padding field. Should be zeroed by applications.
+ */
+struct v4l2_ctrl_vp9_frame {
+ struct v4l2_vp9_loop_filter lf;
+ struct v4l2_vp9_quantization quant;
+ struct v4l2_vp9_segmentation seg;
+ __u32 flags;
+ __u16 compressed_header_size;
+ __u16 uncompressed_header_size;
+ __u16 frame_width_minus_1;
+ __u16 frame_height_minus_1;
+ __u16 render_width_minus_1;
+ __u16 render_height_minus_1;
+ __u64 last_frame_ts;
+ __u64 golden_frame_ts;
+ __u64 alt_frame_ts;
+ __u8 ref_frame_sign_bias;
+ __u8 reset_frame_context;
+ __u8 frame_context_idx;
+ __u8 profile;
+ __u8 bit_depth;
+ __u8 interpolation_filter;
+ __u8 tile_cols_log2;
+ __u8 tile_rows_log2;
+ __u8 reference_mode;
+ __u8 reserved[7];
+};
+
+#define V4L2_VP9_NUM_FRAME_CTX 4
+
+/**
+ * struct v4l2_vp9_mv_probs - VP9 Motion vector probability updates
+ * @joint: motion vector joint probability updates.
+ * @sign: motion vector sign probability updates.
+ * @classes: motion vector class probability updates.
+ * @class0_bit: motion vector class0 bit probability updates.
+ * @bits: motion vector bits probability updates.
+ * @class0_fr: motion vector class0 fractional bit probability updates.
+ * @fr: motion vector fractional bit probability updates.
+ * @class0_hp: motion vector class0 high precision fractional bit probability updates.
+ * @hp: motion vector high precision fractional bit probability updates.
+ *
+ * This structure contains new values of motion vector probabilities.
+ * A value of zero in an array element means there is no update of the relevant probability.
+ * See `struct v4l2_vp9_prob_updates` for details.
+ */
+struct v4l2_vp9_mv_probs {
+ __u8 joint[3];
+ __u8 sign[2];
+ __u8 classes[2][10];
+ __u8 class0_bit[2];
+ __u8 bits[2][10];
+ __u8 class0_fr[2][2][3];
+ __u8 fr[2][3];
+ __u8 class0_hp[2];
+ __u8 hp[2];
+};
+
+#define V4L2_CID_STATELESS_VP9_COMPRESSED_HDR (V4L2_CID_CODEC_STATELESS_BASE + 301)
+
+#define V4L2_VP9_TX_MODE_ONLY_4X4 0
+#define V4L2_VP9_TX_MODE_ALLOW_8X8 1
+#define V4L2_VP9_TX_MODE_ALLOW_16X16 2
+#define V4L2_VP9_TX_MODE_ALLOW_32X32 3
+#define V4L2_VP9_TX_MODE_SELECT 4
+
+/**
+ * struct v4l2_ctrl_vp9_compressed_hdr - VP9 probability updates control
+ * @tx_mode: specifies the TX mode. Set to one of V4L2_VP9_TX_MODE_{}.
+ * @tx8: TX 8x8 probability updates.
+ * @tx16: TX 16x16 probability updates.
+ * @tx32: TX 32x32 probability updates.
+ * @coef: coefficient probability updates.
+ * @skip: skip probability updates.
+ * @inter_mode: inter mode probability updates.
+ * @interp_filter: interpolation filter probability updates.
+ * @is_inter: is inter-block probability updates.
+ * @comp_mode: compound prediction mode probability updates.
+ * @single_ref: single ref probability updates.
+ * @comp_ref: compound ref probability updates.
+ * @y_mode: Y prediction mode probability updates.
+ * @uv_mode: UV prediction mode probability updates.
+ * @partition: partition probability updates.
+ * @mv: motion vector probability updates.
+ *
+ * This structure holds the probabilities update as parsed in the compressed
+ * header (Spec 6.3). These values represent the value of probability update after
+ * being translated with inv_map_table[] (see 6.3.5). A value of zero in an array element
+ * means that there is no update of the relevant probability.
+ *
+ * This control is optional and needs to be used when dealing with the hardware which is
+ * not capable of parsing the compressed header itself. Only drivers which need it will
+ * implement it.
+ */
+struct v4l2_ctrl_vp9_compressed_hdr {
+ __u8 tx_mode;
+ __u8 tx8[2][1];
+ __u8 tx16[2][2];
+ __u8 tx32[2][3];
+ __u8 coef[4][2][2][6][6][3];
+ __u8 skip[3];
+ __u8 inter_mode[7][3];
+ __u8 interp_filter[4][2];
+ __u8 is_inter[4];
+ __u8 comp_mode[5];
+ __u8 single_ref[5][2];
+ __u8 comp_ref[5];
+ __u8 y_mode[4][9];
+ __u8 uv_mode[10][9];
+ __u8 partition[16][3];
+
+ struct v4l2_vp9_mv_probs mv;
+};
+
+/* Stateless AV1 controls */
+
+#define V4L2_AV1_TOTAL_REFS_PER_FRAME 8
+#define V4L2_AV1_CDEF_MAX 8
+#define V4L2_AV1_NUM_PLANES_MAX 3 /* 1 if monochrome, 3 otherwise */
+#define V4L2_AV1_MAX_SEGMENTS 8
+#define V4L2_AV1_MAX_OPERATING_POINTS (1 << 5) /* 5 bits to encode */
+#define V4L2_AV1_REFS_PER_FRAME 7
+#define V4L2_AV1_MAX_NUM_Y_POINTS (1 << 4) /* 4 bits to encode */
+#define V4L2_AV1_MAX_NUM_CB_POINTS (1 << 4) /* 4 bits to encode */
+#define V4L2_AV1_MAX_NUM_CR_POINTS (1 << 4) /* 4 bits to encode */
+#define V4L2_AV1_AR_COEFFS_SIZE 25 /* (2 * 3 * (3 + 1)) + 1 */
+#define V4L2_AV1_MAX_NUM_PLANES 3
+#define V4L2_AV1_MAX_TILE_COLS 64
+#define V4L2_AV1_MAX_TILE_ROWS 64
+#define V4L2_AV1_MAX_TILE_COUNT 512
+
+#define V4L2_AV1_SEQUENCE_FLAG_STILL_PICTURE 0x00000001
+#define V4L2_AV1_SEQUENCE_FLAG_USE_128X128_SUPERBLOCK 0x00000002
+#define V4L2_AV1_SEQUENCE_FLAG_ENABLE_FILTER_INTRA 0x00000004
+#define V4L2_AV1_SEQUENCE_FLAG_ENABLE_INTRA_EDGE_FILTER 0x00000008
+#define V4L2_AV1_SEQUENCE_FLAG_ENABLE_INTERINTRA_COMPOUND 0x00000010
+#define V4L2_AV1_SEQUENCE_FLAG_ENABLE_MASKED_COMPOUND 0x00000020
+#define V4L2_AV1_SEQUENCE_FLAG_ENABLE_WARPED_MOTION 0x00000040
+#define V4L2_AV1_SEQUENCE_FLAG_ENABLE_DUAL_FILTER 0x00000080
+#define V4L2_AV1_SEQUENCE_FLAG_ENABLE_ORDER_HINT 0x00000100
+#define V4L2_AV1_SEQUENCE_FLAG_ENABLE_JNT_COMP 0x00000200
+#define V4L2_AV1_SEQUENCE_FLAG_ENABLE_REF_FRAME_MVS 0x00000400
+#define V4L2_AV1_SEQUENCE_FLAG_ENABLE_SUPERRES 0x00000800
+#define V4L2_AV1_SEQUENCE_FLAG_ENABLE_CDEF 0x00001000
+#define V4L2_AV1_SEQUENCE_FLAG_ENABLE_RESTORATION 0x00002000
+#define V4L2_AV1_SEQUENCE_FLAG_MONO_CHROME 0x00004000
+#define V4L2_AV1_SEQUENCE_FLAG_COLOR_RANGE 0x00008000
+#define V4L2_AV1_SEQUENCE_FLAG_SUBSAMPLING_X 0x00010000
+#define V4L2_AV1_SEQUENCE_FLAG_SUBSAMPLING_Y 0x00020000
+#define V4L2_AV1_SEQUENCE_FLAG_FILM_GRAIN_PARAMS_PRESENT 0x00040000
+#define V4L2_AV1_SEQUENCE_FLAG_SEPARATE_UV_DELTA_Q 0x00080000
+
+#define V4L2_CID_STATELESS_AV1_SEQUENCE (V4L2_CID_CODEC_STATELESS_BASE + 500)
+/**
+ * struct v4l2_ctrl_av1_sequence - AV1 Sequence
+ *
+ * Represents an AV1 Sequence OBU. See section 5.5 "Sequence header OBU syntax"
+ * for more details.
+ *
+ * @flags: See V4L2_AV1_SEQUENCE_FLAG_{}.
+ * @seq_profile: specifies the features that can be used in the coded video
+ * sequence.
+ * @order_hint_bits: specifies the number of bits used for the order_hint field
+ * at each frame.
+ * @bit_depth: the bitdepth to use for the sequence as described in section
+ * 5.5.2 "Color config syntax".
+ * @reserved: padding field. Should be zeroed by applications.
+ * @max_frame_width_minus_1: specifies the maximum frame width minus 1 for the
+ * frames represented by this sequence header.
+ * @max_frame_height_minus_1: specifies the maximum frame height minus 1 for the
+ * frames represented by this sequence header.
+ */
+struct v4l2_ctrl_av1_sequence {
+ __u32 flags;
+ __u8 seq_profile;
+ __u8 order_hint_bits;
+ __u8 bit_depth;
+ __u8 reserved;
+ __u16 max_frame_width_minus_1;
+ __u16 max_frame_height_minus_1;
+};
+
+#define V4L2_CID_STATELESS_AV1_TILE_GROUP_ENTRY (V4L2_CID_CODEC_STATELESS_BASE + 501)
+/**
+ * struct v4l2_ctrl_av1_tile_group_entry - AV1 Tile Group entry
+ *
+ * Represents a single AV1 tile inside an AV1 Tile Group. Note that MiRowStart,
+ * MiRowEnd, MiColStart and MiColEnd can be retrieved from struct
+ * v4l2_av1_tile_info in struct v4l2_ctrl_av1_frame using tile_row and
+ * tile_col. See section 6.10.1 "General tile group OBU semantics" for more
+ * details.
+ *
+ * @tile_offset: offset from the OBU data, i.e. where the coded tile data
+ * actually starts.
+ * @tile_size: specifies the size in bytes of the coded tile. Equivalent to
+ * "TileSize" in the AV1 Specification.
+ * @tile_row: specifies the row of the current tile. Equivalent to "TileRow" in
+ * the AV1 Specification.
+ * @tile_col: specifies the col of the current tile. Equivalent to "TileCol" in
+ * the AV1 Specification.
+ */
+struct v4l2_ctrl_av1_tile_group_entry {
+ __u32 tile_offset;
+ __u32 tile_size;
+ __u32 tile_row;
+ __u32 tile_col;
+};
+
+/**
+ * enum v4l2_av1_warp_model - AV1 Warp Model as described in section 3
+ * "Symbols and abbreviated terms" of the AV1 Specification.
+ *
+ * @V4L2_AV1_WARP_MODEL_IDENTITY: Warp model is just an identity transform.
+ * @V4L2_AV1_WARP_MODEL_TRANSLATION: Warp model is a pure translation.
+ * @V4L2_AV1_WARP_MODEL_ROTZOOM: Warp model is a rotation + symmetric zoom +
+ * translation.
+ * @V4L2_AV1_WARP_MODEL_AFFINE: Warp model is a general affine transform.
+ */
+enum v4l2_av1_warp_model {
+ V4L2_AV1_WARP_MODEL_IDENTITY = 0,
+ V4L2_AV1_WARP_MODEL_TRANSLATION = 1,
+ V4L2_AV1_WARP_MODEL_ROTZOOM = 2,
+ V4L2_AV1_WARP_MODEL_AFFINE = 3,
+};
+
+/**
+ * enum v4l2_av1_reference_frame - AV1 reference frames
+ *
+ * @V4L2_AV1_REF_INTRA_FRAME: Intra Frame Reference
+ * @V4L2_AV1_REF_LAST_FRAME: Last Reference Frame
+ * @V4L2_AV1_REF_LAST2_FRAME: Last2 Reference Frame
+ * @V4L2_AV1_REF_LAST3_FRAME: Last3 Reference Frame
+ * @V4L2_AV1_REF_GOLDEN_FRAME: Golden Reference Frame
+ * @V4L2_AV1_REF_BWDREF_FRAME: BWD Reference Frame
+ * @V4L2_AV1_REF_ALTREF2_FRAME: Alternative2 Reference Frame
+ * @V4L2_AV1_REF_ALTREF_FRAME: Alternative Reference Frame
+ */
+enum v4l2_av1_reference_frame {
+ V4L2_AV1_REF_INTRA_FRAME = 0,
+ V4L2_AV1_REF_LAST_FRAME = 1,
+ V4L2_AV1_REF_LAST2_FRAME = 2,
+ V4L2_AV1_REF_LAST3_FRAME = 3,
+ V4L2_AV1_REF_GOLDEN_FRAME = 4,
+ V4L2_AV1_REF_BWDREF_FRAME = 5,
+ V4L2_AV1_REF_ALTREF2_FRAME = 6,
+ V4L2_AV1_REF_ALTREF_FRAME = 7,
+};
+
+#define V4L2_AV1_GLOBAL_MOTION_IS_INVALID(ref) (1 << (ref))
+
+#define V4L2_AV1_GLOBAL_MOTION_FLAG_IS_GLOBAL 0x1
+#define V4L2_AV1_GLOBAL_MOTION_FLAG_IS_ROT_ZOOM 0x2
+#define V4L2_AV1_GLOBAL_MOTION_FLAG_IS_TRANSLATION 0x4
+/**
+ * struct v4l2_av1_global_motion - AV1 Global Motion parameters as described in
+ * section 6.8.17 "Global motion params semantics" of the AV1 specification.
+ *
+ * @flags: A bitfield containing the flags per reference frame. See
+ * V4L2_AV1_GLOBAL_MOTION_FLAG_{}
+ * @type: The type of global motion transform used.
+ * @params: this field has the same meaning as "gm_params" in the AV1
+ * specification.
+ * @invalid: bitfield indicating whether the global motion params are invalid
+ * for a given reference frame. See section 7.11.3.6 Setup shear process and
+ * the variable "warpValid". Use V4L2_AV1_GLOBAL_MOTION_IS_INVALID(ref) to
+ * create a suitable mask.
+ * @reserved: padding field. Should be zeroed by applications.
+ */
+
+struct v4l2_av1_global_motion {
+ __u8 flags[V4L2_AV1_TOTAL_REFS_PER_FRAME];
+ enum v4l2_av1_warp_model type[V4L2_AV1_TOTAL_REFS_PER_FRAME];
+ __s32 params[V4L2_AV1_TOTAL_REFS_PER_FRAME][6];
+ __u8 invalid;
+ __u8 reserved[3];
+};
+
+/**
+ * enum v4l2_av1_frame_restoration_type - AV1 Frame Restoration Type
+ * @V4L2_AV1_FRAME_RESTORE_NONE: no filtering is applied.
+ * @V4L2_AV1_FRAME_RESTORE_WIENER: Wiener filter process is invoked.
+ * @V4L2_AV1_FRAME_RESTORE_SGRPROJ: self guided filter process is invoked.
+ * @V4L2_AV1_FRAME_RESTORE_SWITCHABLE: restoration filter is swichtable.
+ */
+enum v4l2_av1_frame_restoration_type {
+ V4L2_AV1_FRAME_RESTORE_NONE = 0,
+ V4L2_AV1_FRAME_RESTORE_WIENER = 1,
+ V4L2_AV1_FRAME_RESTORE_SGRPROJ = 2,
+ V4L2_AV1_FRAME_RESTORE_SWITCHABLE = 3,
+};
+
+#define V4L2_AV1_LOOP_RESTORATION_FLAG_USES_LR 0x1
+#define V4L2_AV1_LOOP_RESTORATION_FLAG_USES_CHROMA_LR 0x2
+
+/**
+ * struct v4l2_av1_loop_restoration - AV1 Loop Restauration as described in
+ * section 6.10.15 "Loop restoration params semantics" of the AV1 specification.
+ *
+ * @flags: See V4L2_AV1_LOOP_RESTORATION_FLAG_{}.
+ * @lr_unit_shift: specifies if the luma restoration size should be halved.
+ * @lr_uv_shift: specifies if the chroma size should be half the luma size.
+ * @reserved: padding field. Should be zeroed by applications.
+ * @frame_restoration_type: specifies the type of restoration used for each
+ * plane. See enum v4l2_av1_frame_restoration_type.
+ * @loop_restoration_size: specifies the size of loop restoration units in units
+ * of samples in the current plane.
+ */
+struct v4l2_av1_loop_restoration {
+ __u8 flags;
+ __u8 lr_unit_shift;
+ __u8 lr_uv_shift;
+ __u8 reserved;
+ enum v4l2_av1_frame_restoration_type frame_restoration_type[V4L2_AV1_NUM_PLANES_MAX];
+ __u32 loop_restoration_size[V4L2_AV1_MAX_NUM_PLANES];
+};
+
+/**
+ * struct v4l2_av1_cdef - AV1 CDEF params semantics as described in section
+ * 6.10.14 "CDEF params semantics" of the AV1 specification
+ *
+ * @damping_minus_3: controls the amount of damping in the deringing filter.
+ * @bits: specifies the number of bits needed to specify which CDEF filter to
+ * apply.
+ * @y_pri_strength: specifies the strength of the primary filter.
+ * @y_sec_strength: specifies the strength of the secondary filter.
+ * @uv_pri_strength: specifies the strength of the primary filter.
+ * @uv_sec_strength: specifies the strength of the secondary filter.
+ */
+struct v4l2_av1_cdef {
+ __u8 damping_minus_3;
+ __u8 bits;
+ __u8 y_pri_strength[V4L2_AV1_CDEF_MAX];
+ __u8 y_sec_strength[V4L2_AV1_CDEF_MAX];
+ __u8 uv_pri_strength[V4L2_AV1_CDEF_MAX];
+ __u8 uv_sec_strength[V4L2_AV1_CDEF_MAX];
+};
+
+#define V4L2_AV1_SEGMENTATION_FLAG_ENABLED 0x1
+#define V4L2_AV1_SEGMENTATION_FLAG_UPDATE_MAP 0x2
+#define V4L2_AV1_SEGMENTATION_FLAG_TEMPORAL_UPDATE 0x4
+#define V4L2_AV1_SEGMENTATION_FLAG_UPDATE_DATA 0x8
+#define V4L2_AV1_SEGMENTATION_FLAG_SEG_ID_PRE_SKIP 0x10
+
+/**
+ * enum v4l2_av1_segment_feature - AV1 segment features as described in section
+ * 3 "Symbols and abbreviated terms" of the AV1 specification.
+ *
+ * @V4L2_AV1_SEG_LVL_ALT_Q: Index for quantizer segment feature.
+ * @V4L2_AV1_SEG_LVL_ALT_LF_Y_V: Index for vertical luma loop filter segment
+ * feature.
+ * @V4L2_AV1_SEG_LVL_REF_FRAME: Index for reference frame segment feature.
+ * @V4L2_AV1_SEG_LVL_REF_SKIP: Index for skip segment feature.
+ * @V4L2_AV1_SEG_LVL_REF_GLOBALMV: Index for global mv feature.
+ * @V4L2_AV1_SEG_LVL_MAX: Number of segment features.
+ */
+enum v4l2_av1_segment_feature {
+ V4L2_AV1_SEG_LVL_ALT_Q = 0,
+ V4L2_AV1_SEG_LVL_ALT_LF_Y_V = 1,
+ V4L2_AV1_SEG_LVL_REF_FRAME = 5,
+ V4L2_AV1_SEG_LVL_REF_SKIP = 6,
+ V4L2_AV1_SEG_LVL_REF_GLOBALMV = 7,
+ V4L2_AV1_SEG_LVL_MAX = 8
+};
+
+#define V4L2_AV1_SEGMENT_FEATURE_ENABLED(id) (1 << (id))
+
+/**
+ * struct v4l2_av1_segmentation - AV1 Segmentation params as defined in section
+ * 6.8.13 "Segmentation params semantics" of the AV1 specification.
+ *
+ * @flags: see V4L2_AV1_SEGMENTATION_FLAG_{}.
+ * @last_active_seg_id: indicates the highest numbered segment id that has some
+ * enabled feature. This is used when decoding the segment id to only decode
+ * choices corresponding to used segments.
+ * @feature_enabled: bitmask defining which features are enabled in each
+ * segment. Use V4L2_AV1_SEGMENT_FEATURE_ENABLED to build a suitable mask.
+ * @feature_data: data attached to each feature. Data entry is only valid if the
+ * feature is enabled
+ */
+struct v4l2_av1_segmentation {
+ __u8 flags;
+ __u8 last_active_seg_id;
+ __u8 feature_enabled[V4L2_AV1_MAX_SEGMENTS];
+ __s16 feature_data[V4L2_AV1_MAX_SEGMENTS][V4L2_AV1_SEG_LVL_MAX];
+};
+
+#define V4L2_AV1_LOOP_FILTER_FLAG_DELTA_ENABLED 0x1
+#define V4L2_AV1_LOOP_FILTER_FLAG_DELTA_UPDATE 0x2
+#define V4L2_AV1_LOOP_FILTER_FLAG_DELTA_LF_PRESENT 0x4
+#define V4L2_AV1_LOOP_FILTER_FLAG_DELTA_LF_MULTI 0x8
+
+/**
+ * struct v4l2_av1_loop_filter - AV1 Loop filter params as defined in section
+ * 6.8.10 "Loop filter semantics" and 6.8.16 "Loop filter delta parameters
+ * semantics" of the AV1 specification.
+ *
+ * @flags: see V4L2_AV1_LOOP_FILTER_FLAG_{}
+ * @level: an array containing loop filter strength values. Different loop
+ * filter strength values from the array are used depending on the image plane
+ * being filtered, and the edge direction (vertical or horizontal) being
+ * filtered.
+ * @sharpness: indicates the sharpness level. The loop_filter_level and
+ * loop_filter_sharpness together determine when a block edge is filtered, and
+ * by how much the filtering can change the sample values. The loop filter
+ * process is described in section 7.14 of the AV1 specification.
+ * @ref_deltas: contains the adjustment needed for the filter level based on the
+ * chosen reference frame. If this syntax element is not present, it maintains
+ * its previous value.
+ * @mode_deltas: contains the adjustment needed for the filter level based on
+ * the chosen mode. If this syntax element is not present, it maintains its
+ * previous value.
+ * @delta_lf_res: specifies the left shift which should be applied to decoded
+ * loop filter delta values.
+ */
+struct v4l2_av1_loop_filter {
+ __u8 flags;
+ __u8 level[4];
+ __u8 sharpness;
+ __s8 ref_deltas[V4L2_AV1_TOTAL_REFS_PER_FRAME];
+ __s8 mode_deltas[2];
+ __u8 delta_lf_res;
+};
+
+#define V4L2_AV1_QUANTIZATION_FLAG_DIFF_UV_DELTA 0x1
+#define V4L2_AV1_QUANTIZATION_FLAG_USING_QMATRIX 0x2
+#define V4L2_AV1_QUANTIZATION_FLAG_DELTA_Q_PRESENT 0x4
+
+/**
+ * struct v4l2_av1_quantization - AV1 Quantization params as defined in section
+ * 6.8.11 "Quantization params semantics" of the AV1 specification.
+ *
+ * @flags: see V4L2_AV1_QUANTIZATION_FLAG_{}
+ * @base_q_idx: indicates the base frame qindex. This is used for Y AC
+ * coefficients and as the base value for the other quantizers.
+ * @delta_q_y_dc: indicates the Y DC quantizer relative to base_q_idx.
+ * @delta_q_u_dc: indicates the U DC quantizer relative to base_q_idx.
+ * @delta_q_u_ac: indicates the U AC quantizer relative to base_q_idx.
+ * @delta_q_v_dc: indicates the V DC quantizer relative to base_q_idx.
+ * @delta_q_v_ac: indicates the V AC quantizer relative to base_q_idx.
+ * @qm_y: specifies the level in the quantizer matrix that should be used for
+ * luma plane decoding.
+ * @qm_u: specifies the level in the quantizer matrix that should be used for
+ * chroma U plane decoding.
+ * @qm_v: specifies the level in the quantizer matrix that should be used for
+ * chroma V plane decoding.
+ * @delta_q_res: specifies the left shift which should be applied to decoded
+ * quantizer index delta values.
+ */
+struct v4l2_av1_quantization {
+ __u8 flags;
+ __u8 base_q_idx;
+ __s8 delta_q_y_dc;
+ __s8 delta_q_u_dc;
+ __s8 delta_q_u_ac;
+ __s8 delta_q_v_dc;
+ __s8 delta_q_v_ac;
+ __u8 qm_y;
+ __u8 qm_u;
+ __u8 qm_v;
+ __u8 delta_q_res;
+};
+
+#define V4L2_AV1_TILE_INFO_FLAG_UNIFORM_TILE_SPACING 0x1
+
+/**
+ * struct v4l2_av1_tile_info - AV1 Tile info as defined in section 6.8.14 "Tile
+ * info semantics" of the AV1 specification.
+ *
+ * @flags: see V4L2_AV1_TILE_INFO_FLAG_{}
+ * @context_update_tile_id: specifies which tile to use for the CDF update.
+ * @tile_rows: specifies the number of tiles down the frame.
+ * @tile_cols: specifies the number of tiles across the frame.
+ * @mi_col_starts: an array specifying the start column (in units of 4x4 luma
+ * samples) for each tile across the image.
+ * @mi_row_starts: an array specifying the start row (in units of 4x4 luma
+ * samples) for each tile down the image.
+ * @width_in_sbs_minus_1: specifies the width of a tile minus 1 in units of
+ * superblocks.
+ * @height_in_sbs_minus_1: specifies the height of a tile minus 1 in units of
+ * superblocks.
+ * @tile_size_bytes: specifies the number of bytes needed to code each tile
+ * size.
+ * @reserved: padding field. Should be zeroed by applications.
+ */
+struct v4l2_av1_tile_info {
+ __u8 flags;
+ __u8 context_update_tile_id;
+ __u8 tile_cols;
+ __u8 tile_rows;
+ __u32 mi_col_starts[V4L2_AV1_MAX_TILE_COLS + 1];
+ __u32 mi_row_starts[V4L2_AV1_MAX_TILE_ROWS + 1];
+ __u32 width_in_sbs_minus_1[V4L2_AV1_MAX_TILE_COLS];
+ __u32 height_in_sbs_minus_1[V4L2_AV1_MAX_TILE_ROWS];
+ __u8 tile_size_bytes;
+ __u8 reserved[3];
+};
+
+/**
+ * enum v4l2_av1_frame_type - AV1 Frame Type
+ *
+ * @V4L2_AV1_KEY_FRAME: Key frame
+ * @V4L2_AV1_INTER_FRAME: Inter frame
+ * @V4L2_AV1_INTRA_ONLY_FRAME: Intra-only frame
+ * @V4L2_AV1_SWITCH_FRAME: Switch frame
+ */
+enum v4l2_av1_frame_type {
+ V4L2_AV1_KEY_FRAME = 0,
+ V4L2_AV1_INTER_FRAME = 1,
+ V4L2_AV1_INTRA_ONLY_FRAME = 2,
+ V4L2_AV1_SWITCH_FRAME = 3
+};
+
+/**
+ * enum v4l2_av1_interpolation_filter - AV1 interpolation filter types
+ *
+ * @V4L2_AV1_INTERPOLATION_FILTER_EIGHTTAP: eight tap filter
+ * @V4L2_AV1_INTERPOLATION_FILTER_EIGHTTAP_SMOOTH: eight tap smooth filter
+ * @V4L2_AV1_INTERPOLATION_FILTER_EIGHTTAP_SHARP: eight tap sharp filter
+ * @V4L2_AV1_INTERPOLATION_FILTER_BILINEAR: bilinear filter
+ * @V4L2_AV1_INTERPOLATION_FILTER_SWITCHABLE: filter selection is signaled at
+ * the block level
+ *
+ * See section 6.8.9 "Interpolation filter semantics" of the AV1 specification
+ * for more details.
+ */
+enum v4l2_av1_interpolation_filter {
+ V4L2_AV1_INTERPOLATION_FILTER_EIGHTTAP = 0,
+ V4L2_AV1_INTERPOLATION_FILTER_EIGHTTAP_SMOOTH = 1,
+ V4L2_AV1_INTERPOLATION_FILTER_EIGHTTAP_SHARP = 2,
+ V4L2_AV1_INTERPOLATION_FILTER_BILINEAR = 3,
+ V4L2_AV1_INTERPOLATION_FILTER_SWITCHABLE = 4,
+};
+
+/**
+ * enum v4l2_av1_tx_mode - AV1 Tx mode as described in section 6.8.21 "TX mode
+ * semantics" of the AV1 specification.
+ * @V4L2_AV1_TX_MODE_ONLY_4X4: the inverse transform will use only 4x4
+ * transforms
+ * @V4L2_AV1_TX_MODE_LARGEST: the inverse transform will use the largest
+ * transform size that fits inside the block
+ * @V4L2_AV1_TX_MODE_SELECT: the choice of transform size is specified
+ * explicitly for each block.
+ */
+enum v4l2_av1_tx_mode {
+ V4L2_AV1_TX_MODE_ONLY_4X4 = 0,
+ V4L2_AV1_TX_MODE_LARGEST = 1,
+ V4L2_AV1_TX_MODE_SELECT = 2
+};
+
+#define V4L2_AV1_FRAME_FLAG_SHOW_FRAME 0x00000001
+#define V4L2_AV1_FRAME_FLAG_SHOWABLE_FRAME 0x00000002
+#define V4L2_AV1_FRAME_FLAG_ERROR_RESILIENT_MODE 0x00000004
+#define V4L2_AV1_FRAME_FLAG_DISABLE_CDF_UPDATE 0x00000008
+#define V4L2_AV1_FRAME_FLAG_ALLOW_SCREEN_CONTENT_TOOLS 0x00000010
+#define V4L2_AV1_FRAME_FLAG_FORCE_INTEGER_MV 0x00000020
+#define V4L2_AV1_FRAME_FLAG_ALLOW_INTRABC 0x00000040
+#define V4L2_AV1_FRAME_FLAG_USE_SUPERRES 0x00000080
+#define V4L2_AV1_FRAME_FLAG_ALLOW_HIGH_PRECISION_MV 0x00000100
+#define V4L2_AV1_FRAME_FLAG_IS_MOTION_MODE_SWITCHABLE 0x00000200
+#define V4L2_AV1_FRAME_FLAG_USE_REF_FRAME_MVS 0x00000400
+#define V4L2_AV1_FRAME_FLAG_DISABLE_FRAME_END_UPDATE_CDF 0x00000800
+#define V4L2_AV1_FRAME_FLAG_ALLOW_WARPED_MOTION 0x00001000
+#define V4L2_AV1_FRAME_FLAG_REFERENCE_SELECT 0x00002000
+#define V4L2_AV1_FRAME_FLAG_REDUCED_TX_SET 0x00004000
+#define V4L2_AV1_FRAME_FLAG_SKIP_MODE_ALLOWED 0x00008000
+#define V4L2_AV1_FRAME_FLAG_SKIP_MODE_PRESENT 0x00010000
+#define V4L2_AV1_FRAME_FLAG_FRAME_SIZE_OVERRIDE 0x00020000
+#define V4L2_AV1_FRAME_FLAG_BUFFER_REMOVAL_TIME_PRESENT 0x00040000
+#define V4L2_AV1_FRAME_FLAG_FRAME_REFS_SHORT_SIGNALING 0x00080000
+
+#define V4L2_CID_STATELESS_AV1_FRAME (V4L2_CID_CODEC_STATELESS_BASE + 502)
+/**
+ * struct v4l2_ctrl_av1_frame - Represents an AV1 Frame Header OBU.
+ *
+ * @tile_info: tile info
+ * @quantization: quantization params
+ * @segmentation: segmentation params
+ * @superres_denom: the denominator for the upscaling ratio.
+ * @loop_filter: loop filter params
+ * @cdef: cdef params
+ * @skip_mode_frame: specifies the frames to use for compound prediction when
+ * skip_mode is equal to 1.
+ * @primary_ref_frame: specifies which reference frame contains the CDF values
+ * and other state that should be loaded at the start of the frame.
+ * @loop_restoration: loop restoration params
+ * @global_motion: global motion params
+ * @flags: see V4L2_AV1_FRAME_FLAG_{}
+ * @frame_type: specifies the AV1 frame type
+ * @order_hint: specifies OrderHintBits least significant bits of the expected
+ * output order for this frame.
+ * @upscaled_width: the upscaled width.
+ * @interpolation_filter: specifies the filter selection used for performing
+ * inter prediction.
+ * @tx_mode: specifies how the transform size is determined.
+ * @frame_width_minus_1: add 1 to get the frame's width.
+ * @frame_height_minus_1: add 1 to get the frame's height
+ * @render_width_minus_1: add 1 to get the render width of the frame in luma
+ * samples.
+ * @render_height_minus_1: add 1 to get the render height of the frame in luma
+ * samples.
+ * @current_frame_id: specifies the frame id number for the current frame. Frame
+ * id numbers are additional information that do not affect the decoding
+ * process, but provide decoders with a way of detecting missing reference
+ * frames so that appropriate action can be taken.
+ * @buffer_removal_time: specifies the frame removal time in units of DecCT clock
+ * ticks counted from the removal time of the last random access point for
+ * operating point opNum.
+ * @reserved: padding field. Should be zeroed by applications.
+ * @order_hints: specifies the expected output order hint for each reference
+ * frame. This field corresponds to the OrderHints variable from the
+ * specification (section 5.9.2 "Uncompressed header syntax"). As such, this is
+ * only used for non-intra frames and ignored otherwise. order_hints[0] is
+ * always ignored.
+ * @reference_frame_ts: the V4L2 timestamp of the reference frame slots.
+ * @ref_frame_idx: used to index into @reference_frame_ts when decoding
+ * inter-frames. The meaning of this array is the same as in the specification.
+ * The timestamp refers to the timestamp field in struct v4l2_buffer. Use
+ * v4l2_timeval_to_ns() to convert the struct timeval to a __u64.
+ * @refresh_frame_flags: contains a bitmask that specifies which reference frame
+ * slots will be updated with the current frame after it is decoded.
+ */
+struct v4l2_ctrl_av1_frame {
+ struct v4l2_av1_tile_info tile_info;
+ struct v4l2_av1_quantization quantization;
+ __u8 superres_denom;
+ struct v4l2_av1_segmentation segmentation;
+ struct v4l2_av1_loop_filter loop_filter;
+ struct v4l2_av1_cdef cdef;
+ __u8 skip_mode_frame[2];
+ __u8 primary_ref_frame;
+ struct v4l2_av1_loop_restoration loop_restoration;
+ struct v4l2_av1_global_motion global_motion;
+ __u32 flags;
+ enum v4l2_av1_frame_type frame_type;
+ __u32 order_hint;
+ __u32 upscaled_width;
+ enum v4l2_av1_interpolation_filter interpolation_filter;
+ enum v4l2_av1_tx_mode tx_mode;
+ __u32 frame_width_minus_1;
+ __u32 frame_height_minus_1;
+ __u16 render_width_minus_1;
+ __u16 render_height_minus_1;
+
+ __u32 current_frame_id;
+ __u32 buffer_removal_time[V4L2_AV1_MAX_OPERATING_POINTS];
+ __u8 reserved[4];
+ __u32 order_hints[V4L2_AV1_TOTAL_REFS_PER_FRAME];
+ __u64 reference_frame_ts[V4L2_AV1_TOTAL_REFS_PER_FRAME];
+ __s8 ref_frame_idx[V4L2_AV1_REFS_PER_FRAME];
+ __u8 refresh_frame_flags;
+};
+
+#define V4L2_AV1_FILM_GRAIN_FLAG_APPLY_GRAIN 0x1
+#define V4L2_AV1_FILM_GRAIN_FLAG_UPDATE_GRAIN 0x2
+#define V4L2_AV1_FILM_GRAIN_FLAG_CHROMA_SCALING_FROM_LUMA 0x4
+#define V4L2_AV1_FILM_GRAIN_FLAG_OVERLAP 0x8
+#define V4L2_AV1_FILM_GRAIN_FLAG_CLIP_TO_RESTRICTED_RANGE 0x10
+
+#define V4L2_CID_STATELESS_AV1_FILM_GRAIN (V4L2_CID_CODEC_STATELESS_BASE + 505)
+/**
+ * struct v4l2_ctrl_av1_film_grain - AV1 Film Grain parameters.
+ *
+ * Film grain parameters as specified by section 6.8.20 of the AV1 Specification.
+ *
+ * @flags: see V4L2_AV1_FILM_GRAIN_{}.
+ * @cr_mult: represents a multiplier for the cr component used in derivation of
+ * the input index to the cr component scaling function.
+ * @grain_seed: specifies the starting value for the pseudo-random numbers used
+ * during film grain synthesis.
+ * @film_grain_params_ref_idx: indicates which reference frame contains the
+ * film grain parameters to be used for this frame.
+ * @num_y_points: specifies the number of points for the piece-wise linear
+ * scaling function of the luma component.
+ * @point_y_value: represents the x (luma value) coordinate for the i-th point
+ * of the piecewise linear scaling function for luma component. The values are
+ * signaled on the scale of 0..255. In case of 10 bit video, these values
+ * correspond to luma values divided by 4. In case of 12 bit video, these values
+ * correspond to luma values divided by 16.
+ * @point_y_scaling: represents the scaling (output) value for the i-th point
+ * of the piecewise linear scaling function for luma component.
+ * @num_cb_points: specifies the number of points for the piece-wise linear
+ * scaling function of the cb component.
+ * @point_cb_value: represents the x coordinate for the i-th point of the
+ * piece-wise linear scaling function for cb component. The values are signaled
+ * on the scale of 0..255.
+ * @point_cb_scaling: represents the scaling (output) value for the i-th point
+ * of the piecewise linear scaling function for cb component.
+ * @num_cr_points: specifies represents the number of points for the piece-wise
+ * linear scaling function of the cr component.
+ * @point_cr_value: represents the x coordinate for the i-th point of the
+ * piece-wise linear scaling function for cr component. The values are signaled
+ * on the scale of 0..255.
+ * @point_cr_scaling: represents the scaling (output) value for the i-th point
+ * of the piecewise linear scaling function for cr component.
+ * @grain_scaling_minus_8: represents the shift – 8 applied to the values of the
+ * chroma component. The grain_scaling_minus_8 can take values of 0..3 and
+ * determines the range and quantization step of the standard deviation of film
+ * grain.
+ * @ar_coeff_lag: specifies the number of auto-regressive coefficients for luma
+ * and chroma.
+ * @ar_coeffs_y_plus_128: specifies auto-regressive coefficients used for the Y
+ * plane.
+ * @ar_coeffs_cb_plus_128: specifies auto-regressive coefficients used for the U
+ * plane.
+ * @ar_coeffs_cr_plus_128: specifies auto-regressive coefficients used for the V
+ * plane.
+ * @ar_coeff_shift_minus_6: specifies the range of the auto-regressive
+ * coefficients. Values of 0, 1, 2, and 3 correspond to the ranges for
+ * auto-regressive coefficients of [-2, 2), [-1, 1), [-0.5, 0.5) and [-0.25,
+ * 0.25) respectively.
+ * @grain_scale_shift: specifies how much the Gaussian random numbers should be
+ * scaled down during the grain synthesis process.
+ * @cb_mult: represents a multiplier for the cb component used in derivation of
+ * the input index to the cb component scaling function.
+ * @cb_luma_mult: represents a multiplier for the average luma component used in
+ * derivation of the input index to the cb component scaling function.
+ * @cr_luma_mult: represents a multiplier for the average luma component used in
+ * derivation of the input index to the cr component scaling function.
+ * @cb_offset: represents an offset used in derivation of the input index to the
+ * cb component scaling function.
+ * @cr_offset: represents an offset used in derivation of the input index to the
+ * cr component scaling function.
+ * @reserved: padding field. Should be zeroed by applications.
+ */
+struct v4l2_ctrl_av1_film_grain {
+ __u8 flags;
+ __u8 cr_mult;
+ __u16 grain_seed;
+ __u8 film_grain_params_ref_idx;
+ __u8 num_y_points;
+ __u8 point_y_value[V4L2_AV1_MAX_NUM_Y_POINTS];
+ __u8 point_y_scaling[V4L2_AV1_MAX_NUM_Y_POINTS];
+ __u8 num_cb_points;
+ __u8 point_cb_value[V4L2_AV1_MAX_NUM_CB_POINTS];
+ __u8 point_cb_scaling[V4L2_AV1_MAX_NUM_CB_POINTS];
+ __u8 num_cr_points;
+ __u8 point_cr_value[V4L2_AV1_MAX_NUM_CR_POINTS];
+ __u8 point_cr_scaling[V4L2_AV1_MAX_NUM_CR_POINTS];
+ __u8 grain_scaling_minus_8;
+ __u8 ar_coeff_lag;
+ __u8 ar_coeffs_y_plus_128[V4L2_AV1_AR_COEFFS_SIZE];
+ __u8 ar_coeffs_cb_plus_128[V4L2_AV1_AR_COEFFS_SIZE];
+ __u8 ar_coeffs_cr_plus_128[V4L2_AV1_AR_COEFFS_SIZE];
+ __u8 ar_coeff_shift_minus_6;
+ __u8 grain_scale_shift;
+ __u8 cb_mult;
+ __u8 cb_luma_mult;
+ __u8 cr_luma_mult;
+ __u16 cb_offset;
+ __u16 cr_offset;
+ __u8 reserved[4];
+};
+
/* MPEG-compression definitions kept for backwards compatibility */
#define V4L2_CTRL_CLASS_MPEG V4L2_CTRL_CLASS_CODEC
#define V4L2_CID_MPEG_CLASS V4L2_CID_CODEC_CLASS
diff --git a/include/linux/v4l2-mediabus.h b/include/linux/v4l2-mediabus.h
index 846dadfb..097ef739 100644
--- a/include/linux/v4l2-mediabus.h
+++ b/include/linux/v4l2-mediabus.h
@@ -3,10 +3,6 @@
* Media Bus API header
*
* Copyright (C) 2009, Guennadi Liakhovetski <g.liakhovetski@gmx.de>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
*/
#ifndef __LINUX_V4L2_MEDIABUS_H
@@ -23,12 +19,18 @@
* @width: image width
* @height: image height
* @code: data format code (from enum v4l2_mbus_pixelcode)
- * @field: used interlacing type (from enum v4l2_field)
- * @colorspace: colorspace of the data (from enum v4l2_colorspace)
- * @ycbcr_enc: YCbCr encoding of the data (from enum v4l2_ycbcr_encoding)
- * @hsv_enc: HSV encoding of the data (from enum v4l2_hsv_encoding)
- * @quantization: quantization of the data (from enum v4l2_quantization)
- * @xfer_func: transfer function of the data (from enum v4l2_xfer_func)
+ * @field: used interlacing type (from enum v4l2_field), zero for metadata
+ * mbus codes
+ * @colorspace: colorspace of the data (from enum v4l2_colorspace), zero on
+ * metadata mbus codes
+ * @ycbcr_enc: YCbCr encoding of the data (from enum v4l2_ycbcr_encoding), zero
+ * for metadata mbus codes
+ * @hsv_enc: HSV encoding of the data (from enum v4l2_hsv_encoding), zero for
+ * metadata mbus codes
+ * @quantization: quantization of the data (from enum v4l2_quantization), zero
+ * for metadata mbus codes
+ * @xfer_func: transfer function of the data (from enum v4l2_xfer_func), zero
+ * for metadata mbus codes
* @flags: flags (V4L2_MBUS_FRAMEFMT_*)
* @reserved: reserved bytes that can be later used
*/
diff --git a/include/linux/v4l2-subdev.h b/include/linux/v4l2-subdev.h
index a38454d9..839b1329 100644
--- a/include/linux/v4l2-subdev.h
+++ b/include/linux/v4l2-subdev.h
@@ -6,24 +6,12 @@
*
* Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
* Sakari Ailus <sakari.ailus@iki.fi>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __LINUX_V4L2_SUBDEV_H
#define __LINUX_V4L2_SUBDEV_H
+#include <linux/const.h>
#include <linux/ioctl.h>
#include <linux/types.h>
#include <linux/v4l2-common.h>
@@ -44,12 +32,15 @@ enum v4l2_subdev_format_whence {
* @which: format type (from enum v4l2_subdev_format_whence)
* @pad: pad number, as reported by the media API
* @format: media bus format (format code and frame size)
+ * @stream: stream number, defined in subdev routing
+ * @reserved: drivers and applications must zero this array
*/
struct v4l2_subdev_format {
__u32 which;
__u32 pad;
struct v4l2_mbus_framefmt format;
- __u32 reserved[8];
+ __u32 stream;
+ __u32 reserved[7];
};
/**
@@ -57,12 +48,19 @@ struct v4l2_subdev_format {
* @which: format type (from enum v4l2_subdev_format_whence)
* @pad: pad number, as reported by the media API
* @rect: pad crop rectangle boundaries
+ * @stream: stream number, defined in subdev routing
+ * @reserved: drivers and applications must zero this array
+ *
+ * The subdev crop API is an obsolete interface and may be removed in the
+ * future. It is superseded by the selection API. No new extensions to this
+ * structure will be accepted.
*/
struct v4l2_subdev_crop {
__u32 which;
__u32 pad;
struct v4l2_rect rect;
- __u32 reserved[8];
+ __u32 stream;
+ __u32 reserved[7];
};
#define V4L2_SUBDEV_MBUS_CODE_CSC_COLORSPACE 0x00000001
@@ -78,6 +76,8 @@ struct v4l2_subdev_crop {
* @code: format code (MEDIA_BUS_FMT_ definitions)
* @which: format type (from enum v4l2_subdev_format_whence)
* @flags: flags set by the driver, (V4L2_SUBDEV_MBUS_CODE_*)
+ * @stream: stream number, defined in subdev routing
+ * @reserved: drivers and applications must zero this array
*/
struct v4l2_subdev_mbus_code_enum {
__u32 pad;
@@ -85,15 +85,22 @@ struct v4l2_subdev_mbus_code_enum {
__u32 code;
__u32 which;
__u32 flags;
- __u32 reserved[7];
+ __u32 stream;
+ __u32 reserved[6];
};
/**
* struct v4l2_subdev_frame_size_enum - Media bus format enumeration
- * @pad: pad number, as reported by the media API
* @index: format index during enumeration
+ * @pad: pad number, as reported by the media API
* @code: format code (MEDIA_BUS_FMT_ definitions)
+ * @min_width: minimum frame width, in pixels
+ * @max_width: maximum frame width, in pixels
+ * @min_height: minimum frame height, in pixels
+ * @max_height: maximum frame height, in pixels
* @which: format type (from enum v4l2_subdev_format_whence)
+ * @stream: stream number, defined in subdev routing
+ * @reserved: drivers and applications must zero this array
*/
struct v4l2_subdev_frame_size_enum {
__u32 index;
@@ -104,18 +111,24 @@ struct v4l2_subdev_frame_size_enum {
__u32 min_height;
__u32 max_height;
__u32 which;
- __u32 reserved[8];
+ __u32 stream;
+ __u32 reserved[7];
};
/**
* struct v4l2_subdev_frame_interval - Pad-level frame rate
* @pad: pad number, as reported by the media API
* @interval: frame interval in seconds
+ * @stream: stream number, defined in subdev routing
+ * @which: interval type (from enum v4l2_subdev_format_whence)
+ * @reserved: drivers and applications must zero this array
*/
struct v4l2_subdev_frame_interval {
__u32 pad;
struct v4l2_fract interval;
- __u32 reserved[9];
+ __u32 stream;
+ __u32 which;
+ __u32 reserved[7];
};
/**
@@ -126,7 +139,9 @@ struct v4l2_subdev_frame_interval {
* @width: frame width in pixels
* @height: frame height in pixels
* @interval: frame interval in seconds
- * @which: format type (from enum v4l2_subdev_format_whence)
+ * @which: interval type (from enum v4l2_subdev_format_whence)
+ * @stream: stream number, defined in subdev routing
+ * @reserved: drivers and applications must zero this array
*/
struct v4l2_subdev_frame_interval_enum {
__u32 index;
@@ -136,7 +151,8 @@ struct v4l2_subdev_frame_interval_enum {
__u32 height;
struct v4l2_fract interval;
__u32 which;
- __u32 reserved[8];
+ __u32 stream;
+ __u32 reserved[7];
};
/**
@@ -148,6 +164,7 @@ struct v4l2_subdev_frame_interval_enum {
* defined in v4l2-common.h; V4L2_SEL_TGT_* .
* @flags: constraint flags, defined in v4l2-common.h; V4L2_SEL_FLAG_*.
* @r: coordinates of the selection window
+ * @stream: stream number, defined in subdev routing
* @reserved: for future use, set to zero for now
*
* Hardware may use multiple helper windows to process a video stream.
@@ -160,7 +177,8 @@ struct v4l2_subdev_selection {
__u32 target;
__u32 flags;
struct v4l2_rect r;
- __u32 reserved[8];
+ __u32 stream;
+ __u32 reserved[7];
};
/**
@@ -178,6 +196,83 @@ struct v4l2_subdev_capability {
/* The v4l2 sub-device video device node is registered in read-only mode. */
#define V4L2_SUBDEV_CAP_RO_SUBDEV 0x00000001
+/* The v4l2 sub-device supports routing and multiplexed streams. */
+#define V4L2_SUBDEV_CAP_STREAMS 0x00000002
+
+/*
+ * Is the route active? An active route will start when streaming is enabled
+ * on a video node.
+ */
+#define V4L2_SUBDEV_ROUTE_FL_ACTIVE (1U << 0)
+/*
+ * Is the route immutable? The ACTIVE flag of an immutable route may not be
+ * unset.
+ */
+#define V4L2_SUBDEV_ROUTE_FL_IMMUTABLE (1U << 1)
+
+/**
+ * struct v4l2_subdev_route - A route inside a subdev
+ *
+ * @sink_pad: the sink pad index
+ * @sink_stream: the sink stream identifier
+ * @source_pad: the source pad index
+ * @source_stream: the source stream identifier
+ * @flags: route flags V4L2_SUBDEV_ROUTE_FL_*
+ * @reserved: drivers and applications must zero this array
+ */
+struct v4l2_subdev_route {
+ __u32 sink_pad;
+ __u32 sink_stream;
+ __u32 source_pad;
+ __u32 source_stream;
+ __u32 flags;
+ __u32 reserved[5];
+};
+
+/**
+ * struct v4l2_subdev_routing - Subdev routing information
+ *
+ * @which: configuration type (from enum v4l2_subdev_format_whence)
+ * @len_routes: the length of the routes array, in routes; set by the user, not
+ * modified by the kernel
+ * @routes: pointer to the routes array
+ * @num_routes: the total number of routes, possibly more than fits in the
+ * routes array
+ * @reserved: drivers and applications must zero this array
+ */
+struct v4l2_subdev_routing {
+ __u32 which;
+ __u32 len_routes;
+ __u64 routes;
+ __u32 num_routes;
+ __u32 reserved[11];
+};
+
+/*
+ * The client is aware of streams. Setting this flag enables the use of 'stream'
+ * fields (referring to the stream number) with various ioctls. If this is not
+ * set (which is the default), the 'stream' fields will be forced to 0 by the
+ * kernel.
+ */
+#define V4L2_SUBDEV_CLIENT_CAP_STREAMS (1ULL << 0)
+
+/*
+ * The client is aware of the struct v4l2_subdev_frame_interval which field. If
+ * this is not set (which is the default), the which field is forced to
+ * V4L2_SUBDEV_FORMAT_ACTIVE by the kernel.
+ */
+#define V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH (1ULL << 1)
+
+/**
+ * struct v4l2_subdev_client_capability - Capabilities of the client accessing
+ * the subdev
+ *
+ * @capabilities: A bitmask of V4L2_SUBDEV_CLIENT_CAP_* flags.
+ */
+struct v4l2_subdev_client_capability {
+ __u64 capabilities;
+};
+
/* Backwards compatibility define --- to be removed */
#define v4l2_subdev_edid v4l2_edid
@@ -193,6 +288,11 @@ struct v4l2_subdev_capability {
#define VIDIOC_SUBDEV_S_CROP _IOWR('V', 60, struct v4l2_subdev_crop)
#define VIDIOC_SUBDEV_G_SELECTION _IOWR('V', 61, struct v4l2_subdev_selection)
#define VIDIOC_SUBDEV_S_SELECTION _IOWR('V', 62, struct v4l2_subdev_selection)
+#define VIDIOC_SUBDEV_G_ROUTING _IOWR('V', 38, struct v4l2_subdev_routing)
+#define VIDIOC_SUBDEV_S_ROUTING _IOWR('V', 39, struct v4l2_subdev_routing)
+#define VIDIOC_SUBDEV_G_CLIENT_CAP _IOR('V', 101, struct v4l2_subdev_client_capability)
+#define VIDIOC_SUBDEV_S_CLIENT_CAP _IOWR('V', 102, struct v4l2_subdev_client_capability)
+
/* The following ioctls are identical to the ioctls in videodev2.h */
#define VIDIOC_SUBDEV_G_STD _IOR('V', 23, v4l2_std_id)
#define VIDIOC_SUBDEV_S_STD _IOW('V', 24, v4l2_std_id)
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index f5407540..317d063a 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -243,6 +243,7 @@ enum v4l2_colorspace {
/* DCI-P3 colorspace, used by cinema projectors */
V4L2_COLORSPACE_DCI_P3 = 12,
+
};
/*
@@ -474,7 +475,6 @@ struct v4l2_capability {
#define V4L2_CAP_META_CAPTURE 0x00800000 /* Is a metadata capture device */
#define V4L2_CAP_READWRITE 0x01000000 /* read/write systemcalls */
-#define V4L2_CAP_ASYNCIO 0x02000000 /* async I/O */
#define V4L2_CAP_STREAMING 0x04000000 /* streaming I/O ioctls */
#define V4L2_CAP_META_OUTPUT 0x08000000 /* Is a metadata output device */
@@ -549,6 +549,15 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_RGBX32 v4l2_fourcc('X', 'B', '2', '4') /* 32 RGBX-8-8-8-8 */
#define V4L2_PIX_FMT_ARGB32 v4l2_fourcc('B', 'A', '2', '4') /* 32 ARGB-8-8-8-8 */
#define V4L2_PIX_FMT_XRGB32 v4l2_fourcc('B', 'X', '2', '4') /* 32 XRGB-8-8-8-8 */
+#define V4L2_PIX_FMT_RGBX1010102 v4l2_fourcc('R', 'X', '3', '0') /* 32 RGBX-10-10-10-2 */
+#define V4L2_PIX_FMT_RGBA1010102 v4l2_fourcc('R', 'A', '3', '0') /* 32 RGBA-10-10-10-2 */
+#define V4L2_PIX_FMT_ARGB2101010 v4l2_fourcc('A', 'R', '3', '0') /* 32 ARGB-2-10-10-10 */
+
+/* RGB formats (6 or 8 bytes per pixel) */
+#define V4L2_PIX_FMT_BGR48_12 v4l2_fourcc('B', '3', '1', '2') /* 48 BGR 12-bit per component */
+#define V4L2_PIX_FMT_BGR48 v4l2_fourcc('B', 'G', 'R', '6') /* 48 BGR 16-bit per component */
+#define V4L2_PIX_FMT_RGB48 v4l2_fourcc('R', 'G', 'B', '6') /* 48 RGB 16-bit per component */
+#define V4L2_PIX_FMT_ABGR64_12 v4l2_fourcc('B', '4', '1', '2') /* 64 BGRA 12-bit per component */
/* Grey formats */
#define V4L2_PIX_FMT_GREY v4l2_fourcc('G', 'R', 'E', 'Y') /* 8 Greyscale */
@@ -556,6 +565,7 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_Y6 v4l2_fourcc('Y', '0', '6', ' ') /* 6 Greyscale */
#define V4L2_PIX_FMT_Y10 v4l2_fourcc('Y', '1', '0', ' ') /* 10 Greyscale */
#define V4L2_PIX_FMT_Y12 v4l2_fourcc('Y', '1', '2', ' ') /* 12 Greyscale */
+#define V4L2_PIX_FMT_Y012 v4l2_fourcc('Y', '0', '1', '2') /* 12 Greyscale */
#define V4L2_PIX_FMT_Y14 v4l2_fourcc('Y', '1', '4', ' ') /* 14 Greyscale */
#define V4L2_PIX_FMT_Y16 v4l2_fourcc('Y', '1', '6', ' ') /* 16 Greyscale */
#define V4L2_PIX_FMT_Y16_BE v4l2_fourcc_be('Y', '1', '6', ' ') /* 16 Greyscale BE */
@@ -563,6 +573,9 @@ struct v4l2_pix_format {
/* Grey bit-packed formats */
#define V4L2_PIX_FMT_Y10BPACK v4l2_fourcc('Y', '1', '0', 'B') /* 10 Greyscale bit-packed */
#define V4L2_PIX_FMT_Y10P v4l2_fourcc('Y', '1', '0', 'P') /* 10 Greyscale, MIPI RAW10 packed */
+#define V4L2_PIX_FMT_IPU3_Y10 v4l2_fourcc('i', 'p', '3', 'y') /* IPU3 packed 10-bit greyscale */
+#define V4L2_PIX_FMT_Y12P v4l2_fourcc('Y', '1', '2', 'P') /* 12 Greyscale, MIPI RAW12 packed */
+#define V4L2_PIX_FMT_Y14P v4l2_fourcc('Y', '1', '4', 'P') /* 14 Greyscale, MIPI RAW14 packed */
/* Palette formats */
#define V4L2_PIX_FMT_PAL8 v4l2_fourcc('P', 'A', 'L', '8') /* 8 8-bit palette */
@@ -580,12 +593,24 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_YUV444 v4l2_fourcc('Y', '4', '4', '4') /* 16 xxxxyyyy uuuuvvvv */
#define V4L2_PIX_FMT_YUV555 v4l2_fourcc('Y', 'U', 'V', 'O') /* 16 YUV-5-5-5 */
#define V4L2_PIX_FMT_YUV565 v4l2_fourcc('Y', 'U', 'V', 'P') /* 16 YUV-5-6-5 */
+#define V4L2_PIX_FMT_YUV24 v4l2_fourcc('Y', 'U', 'V', '3') /* 24 YUV-8-8-8 */
#define V4L2_PIX_FMT_YUV32 v4l2_fourcc('Y', 'U', 'V', '4') /* 32 YUV-8-8-8-8 */
#define V4L2_PIX_FMT_AYUV32 v4l2_fourcc('A', 'Y', 'U', 'V') /* 32 AYUV-8-8-8-8 */
#define V4L2_PIX_FMT_XYUV32 v4l2_fourcc('X', 'Y', 'U', 'V') /* 32 XYUV-8-8-8-8 */
#define V4L2_PIX_FMT_VUYA32 v4l2_fourcc('V', 'U', 'Y', 'A') /* 32 VUYA-8-8-8-8 */
#define V4L2_PIX_FMT_VUYX32 v4l2_fourcc('V', 'U', 'Y', 'X') /* 32 VUYX-8-8-8-8 */
+#define V4L2_PIX_FMT_YUVA32 v4l2_fourcc('Y', 'U', 'V', 'A') /* 32 YUVA-8-8-8-8 */
+#define V4L2_PIX_FMT_YUVX32 v4l2_fourcc('Y', 'U', 'V', 'X') /* 32 YUVX-8-8-8-8 */
#define V4L2_PIX_FMT_M420 v4l2_fourcc('M', '4', '2', '0') /* 12 YUV 4:2:0 2 lines y, 1 line uv interleaved */
+#define V4L2_PIX_FMT_YUV48_12 v4l2_fourcc('Y', '3', '1', '2') /* 48 YUV 4:4:4 12-bit per component */
+
+/*
+ * YCbCr packed format. For each Y2xx format, xx bits of valid data occupy the MSBs
+ * of the 16 bit components, and 16-xx bits of zero padding occupy the LSBs.
+ */
+#define V4L2_PIX_FMT_Y210 v4l2_fourcc('Y', '2', '1', '0') /* 32 YUYV 4:2:2 */
+#define V4L2_PIX_FMT_Y212 v4l2_fourcc('Y', '2', '1', '2') /* 32 YUYV 4:2:2 */
+#define V4L2_PIX_FMT_Y216 v4l2_fourcc('Y', '2', '1', '6') /* 32 YUYV 4:2:2 */
/* two planes -- one Y, one Cr + Cb interleaved */
#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 */
@@ -594,15 +619,15 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1') /* 16 Y/CrCb 4:2:2 */
#define V4L2_PIX_FMT_NV24 v4l2_fourcc('N', 'V', '2', '4') /* 24 Y/CbCr 4:4:4 */
#define V4L2_PIX_FMT_NV42 v4l2_fourcc('N', 'V', '4', '2') /* 24 Y/CrCb 4:4:4 */
-#define V4L2_PIX_FMT_HM12 v4l2_fourcc('H', 'M', '1', '2') /* 8 YUV 4:2:0 16x16 macroblocks */
+#define V4L2_PIX_FMT_P010 v4l2_fourcc('P', '0', '1', '0') /* 24 Y/CbCr 4:2:0 10-bit per component */
+#define V4L2_PIX_FMT_P012 v4l2_fourcc('P', '0', '1', '2') /* 24 Y/CbCr 4:2:0 12-bit per component */
/* two non contiguous planes - one Y, one Cr + Cb interleaved */
#define V4L2_PIX_FMT_NV12M v4l2_fourcc('N', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 */
#define V4L2_PIX_FMT_NV21M v4l2_fourcc('N', 'M', '2', '1') /* 21 Y/CrCb 4:2:0 */
#define V4L2_PIX_FMT_NV16M v4l2_fourcc('N', 'M', '1', '6') /* 16 Y/CbCr 4:2:2 */
#define V4L2_PIX_FMT_NV61M v4l2_fourcc('N', 'M', '6', '1') /* 16 Y/CrCb 4:2:2 */
-#define V4L2_PIX_FMT_NV12MT v4l2_fourcc('T', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 64x32 macroblocks */
-#define V4L2_PIX_FMT_NV12MT_16X16 v4l2_fourcc('V', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 16x16 macroblocks */
+#define V4L2_PIX_FMT_P012M v4l2_fourcc('P', 'M', '1', '2') /* 24 Y/CbCr 4:2:0 12-bit per component */
/* three planes - Y Cb, Cr */
#define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y', 'U', 'V', '9') /* 9 YUV 4:1:0 */
@@ -620,6 +645,21 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_YUV444M v4l2_fourcc('Y', 'M', '2', '4') /* 24 YUV444 planar */
#define V4L2_PIX_FMT_YVU444M v4l2_fourcc('Y', 'M', '4', '2') /* 24 YVU444 planar */
+/* Tiled YUV formats */
+#define V4L2_PIX_FMT_NV12_4L4 v4l2_fourcc('V', 'T', '1', '2') /* 12 Y/CbCr 4:2:0 4x4 tiles */
+#define V4L2_PIX_FMT_NV12_16L16 v4l2_fourcc('H', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 16x16 tiles */
+#define V4L2_PIX_FMT_NV12_32L32 v4l2_fourcc('S', 'T', '1', '2') /* 12 Y/CbCr 4:2:0 32x32 tiles */
+#define V4L2_PIX_FMT_NV15_4L4 v4l2_fourcc('V', 'T', '1', '5') /* 15 Y/CbCr 4:2:0 10-bit 4x4 tiles */
+#define V4L2_PIX_FMT_P010_4L4 v4l2_fourcc('T', '0', '1', '0') /* 12 Y/CbCr 4:2:0 10-bit 4x4 macroblocks */
+#define V4L2_PIX_FMT_NV12_8L128 v4l2_fourcc('A', 'T', '1', '2') /* Y/CbCr 4:2:0 8x128 tiles */
+#define V4L2_PIX_FMT_NV12_10BE_8L128 v4l2_fourcc_be('A', 'X', '1', '2') /* Y/CbCr 4:2:0 10-bit 8x128 tiles */
+
+/* Tiled YUV formats, non contiguous planes */
+#define V4L2_PIX_FMT_NV12MT v4l2_fourcc('T', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 64x32 tiles */
+#define V4L2_PIX_FMT_NV12MT_16X16 v4l2_fourcc('V', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 16x16 tiles */
+#define V4L2_PIX_FMT_NV12M_8L128 v4l2_fourcc('N', 'A', '1', '2') /* Y/CbCr 4:2:0 8x128 tiles */
+#define V4L2_PIX_FMT_NV12M_10BE_8L128 v4l2_fourcc_be('N', 'T', '1', '2') /* Y/CbCr 4:2:0 10-bit 8x128 tiles */
+
/* Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm */
#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1') /* 8 BGBG.. GRGR.. */
#define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G') /* 8 GBGB.. RGRG.. */
@@ -688,11 +728,18 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_VC1_ANNEX_G v4l2_fourcc('V', 'C', '1', 'G') /* SMPTE 421M Annex G compliant stream */
#define V4L2_PIX_FMT_VC1_ANNEX_L v4l2_fourcc('V', 'C', '1', 'L') /* SMPTE 421M Annex L compliant stream */
#define V4L2_PIX_FMT_VP8 v4l2_fourcc('V', 'P', '8', '0') /* VP8 */
+#define V4L2_PIX_FMT_VP8_FRAME v4l2_fourcc('V', 'P', '8', 'F') /* VP8 parsed frame */
#define V4L2_PIX_FMT_VP9 v4l2_fourcc('V', 'P', '9', '0') /* VP9 */
+#define V4L2_PIX_FMT_VP9_FRAME v4l2_fourcc('V', 'P', '9', 'F') /* VP9 parsed frame */
#define V4L2_PIX_FMT_HEVC v4l2_fourcc('H', 'E', 'V', 'C') /* HEVC aka H.265 */
#define V4L2_PIX_FMT_FWHT v4l2_fourcc('F', 'W', 'H', 'T') /* Fast Walsh Hadamard Transform (vicodec) */
#define V4L2_PIX_FMT_FWHT_STATELESS v4l2_fourcc('S', 'F', 'W', 'H') /* Stateless FWHT (vicodec) */
#define V4L2_PIX_FMT_H264_SLICE v4l2_fourcc('S', '2', '6', '4') /* H264 parsed slices */
+#define V4L2_PIX_FMT_HEVC_SLICE v4l2_fourcc('S', '2', '6', '5') /* HEVC parsed slices */
+#define V4L2_PIX_FMT_AV1_FRAME v4l2_fourcc('A', 'V', '1', 'F') /* AV1 parsed frame */
+#define V4L2_PIX_FMT_SPK v4l2_fourcc('S', 'P', 'K', '0') /* Sorenson Spark */
+#define V4L2_PIX_FMT_RV30 v4l2_fourcc('R', 'V', '3', '0') /* RealVideo 8 */
+#define V4L2_PIX_FMT_RV40 v4l2_fourcc('R', 'V', '4', '0') /* RealVideo 9 & 10 */
/* Vendor-specific formats */
#define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A') /* cpia1 YUV */
@@ -725,17 +772,35 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_Y12I v4l2_fourcc('Y', '1', '2', 'I') /* Greyscale 12-bit L/R interleaved */
#define V4L2_PIX_FMT_Z16 v4l2_fourcc('Z', '1', '6', ' ') /* Depth data 16-bit */
#define V4L2_PIX_FMT_MT21C v4l2_fourcc('M', 'T', '2', '1') /* Mediatek compressed block mode */
+#define V4L2_PIX_FMT_MM21 v4l2_fourcc('M', 'M', '2', '1') /* Mediatek 8-bit block mode, two non-contiguous planes */
+#define V4L2_PIX_FMT_MT2110T v4l2_fourcc('M', 'T', '2', 'T') /* Mediatek 10-bit block tile mode */
+#define V4L2_PIX_FMT_MT2110R v4l2_fourcc('M', 'T', '2', 'R') /* Mediatek 10-bit block raster mode */
#define V4L2_PIX_FMT_INZI v4l2_fourcc('I', 'N', 'Z', 'I') /* Intel Planar Greyscale 10-bit and Depth 16-bit */
-#define V4L2_PIX_FMT_SUNXI_TILED_NV12 v4l2_fourcc('S', 'T', '1', '2') /* Sunxi Tiled NV12 Format */
#define V4L2_PIX_FMT_CNF4 v4l2_fourcc('C', 'N', 'F', '4') /* Intel 4-bit packed depth confidence information */
#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4') /* BTTV 8-bit dithered RGB */
+#define V4L2_PIX_FMT_QC08C v4l2_fourcc('Q', '0', '8', 'C') /* Qualcomm 8-bit compressed */
+#define V4L2_PIX_FMT_QC10C v4l2_fourcc('Q', '1', '0', 'C') /* Qualcomm 10-bit compressed */
+#define V4L2_PIX_FMT_AJPG v4l2_fourcc('A', 'J', 'P', 'G') /* Aspeed JPEG */
+#define V4L2_PIX_FMT_HEXTILE v4l2_fourcc('H', 'X', 'T', 'L') /* Hextile compressed */
-/* 10bit raw bayer packed, 32 bytes for every 25 pixels, last LSB 6 bits unused */
+/* 10bit raw packed, 32 bytes for every 25 pixels, last LSB 6 bits unused */
#define V4L2_PIX_FMT_IPU3_SBGGR10 v4l2_fourcc('i', 'p', '3', 'b') /* IPU3 packed 10-bit BGGR bayer */
#define V4L2_PIX_FMT_IPU3_SGBRG10 v4l2_fourcc('i', 'p', '3', 'g') /* IPU3 packed 10-bit GBRG bayer */
#define V4L2_PIX_FMT_IPU3_SGRBG10 v4l2_fourcc('i', 'p', '3', 'G') /* IPU3 packed 10-bit GRBG bayer */
#define V4L2_PIX_FMT_IPU3_SRGGB10 v4l2_fourcc('i', 'p', '3', 'r') /* IPU3 packed 10-bit RGGB bayer */
+/* Raspberry Pi PiSP compressed formats. */
+#define V4L2_PIX_FMT_PISP_COMP1_RGGB v4l2_fourcc('P', 'C', '1', 'R') /* PiSP 8-bit mode 1 compressed RGGB bayer */
+#define V4L2_PIX_FMT_PISP_COMP1_GRBG v4l2_fourcc('P', 'C', '1', 'G') /* PiSP 8-bit mode 1 compressed GRBG bayer */
+#define V4L2_PIX_FMT_PISP_COMP1_GBRG v4l2_fourcc('P', 'C', '1', 'g') /* PiSP 8-bit mode 1 compressed GBRG bayer */
+#define V4L2_PIX_FMT_PISP_COMP1_BGGR v4l2_fourcc('P', 'C', '1', 'B') /* PiSP 8-bit mode 1 compressed BGGR bayer */
+#define V4L2_PIX_FMT_PISP_COMP1_MONO v4l2_fourcc('P', 'C', '1', 'M') /* PiSP 8-bit mode 1 compressed monochrome */
+#define V4L2_PIX_FMT_PISP_COMP2_RGGB v4l2_fourcc('P', 'C', '2', 'R') /* PiSP 8-bit mode 2 compressed RGGB bayer */
+#define V4L2_PIX_FMT_PISP_COMP2_GRBG v4l2_fourcc('P', 'C', '2', 'G') /* PiSP 8-bit mode 2 compressed GRBG bayer */
+#define V4L2_PIX_FMT_PISP_COMP2_GBRG v4l2_fourcc('P', 'C', '2', 'g') /* PiSP 8-bit mode 2 compressed GBRG bayer */
+#define V4L2_PIX_FMT_PISP_COMP2_BGGR v4l2_fourcc('P', 'C', '2', 'B') /* PiSP 8-bit mode 2 compressed BGGR bayer */
+#define V4L2_PIX_FMT_PISP_COMP2_MONO v4l2_fourcc('P', 'C', '2', 'M') /* PiSP 8-bit mode 2 compressed monochrome */
+
/* SDR formats - used only for Software Defined Radio devices */
#define V4L2_SDR_FMT_CU8 v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 */
#define V4L2_SDR_FMT_CU16LE v4l2_fourcc('C', 'U', '1', '6') /* IQ u16le */
@@ -764,6 +829,31 @@ struct v4l2_pix_format {
/* Vendor specific - used for RK_ISP1 camera sub-system */
#define V4L2_META_FMT_RK_ISP1_PARAMS v4l2_fourcc('R', 'K', '1', 'P') /* Rockchip ISP1 3A Parameters */
#define V4L2_META_FMT_RK_ISP1_STAT_3A v4l2_fourcc('R', 'K', '1', 'S') /* Rockchip ISP1 3A Statistics */
+#define V4L2_META_FMT_RK_ISP1_EXT_PARAMS v4l2_fourcc('R', 'K', '1', 'E') /* Rockchip ISP1 3a Extensible Parameters */
+
+/* Vendor specific - used for RaspberryPi PiSP */
+#define V4L2_META_FMT_RPI_BE_CFG v4l2_fourcc('R', 'P', 'B', 'C') /* PiSP BE configuration */
+
+/* The metadata format identifier for FE configuration buffers. */
+#define V4L2_META_FMT_RPI_FE_CFG v4l2_fourcc('R', 'P', 'F', 'C')
+
+/* The metadata format identifier for FE stats buffers. */
+#define V4L2_META_FMT_RPI_FE_STATS v4l2_fourcc('R', 'P', 'F', 'S')
+
+#define V4L2_META_FMT_MALI_C55_PARAMS v4l2_fourcc('C', '5', '5', 'P') /* ARM Mali-C55 Parameters */
+#define V4L2_META_FMT_MALI_C55_3A_STATS v4l2_fourcc('C', '5', '5', 'S') /* ARM Mali-C55 3A Statistics */
+
+/*
+ * Line-based metadata formats. Remember to update v4l_fill_fmtdesc() when
+ * adding new ones!
+ */
+#define V4L2_META_FMT_GENERIC_8 v4l2_fourcc('M', 'E', 'T', '8') /* Generic 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_10 v4l2_fourcc('M', 'C', '1', 'A') /* 10-bit CSI-2 packed 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_12 v4l2_fourcc('M', 'C', '1', 'C') /* 12-bit CSI-2 packed 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_14 v4l2_fourcc('M', 'C', '1', 'E') /* 14-bit CSI-2 packed 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_16 v4l2_fourcc('M', 'C', '1', 'G') /* 16-bit CSI-2 packed 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_20 v4l2_fourcc('M', 'C', '1', 'K') /* 20-bit CSI-2 packed 8-bit metadata */
+#define V4L2_META_FMT_GENERIC_CSI2_24 v4l2_fourcc('M', 'C', '1', 'O') /* 24-bit CSI-2 packed 8-bit metadata */
/* priv field value to indicates that subsequent fields are valid. */
#define V4L2_PIX_FMT_PRIV_MAGIC 0xfeedcafe
@@ -795,6 +885,7 @@ struct v4l2_fmtdesc {
#define V4L2_FMT_FLAG_CSC_YCBCR_ENC 0x0080
#define V4L2_FMT_FLAG_CSC_HSV_ENC V4L2_FMT_FLAG_CSC_YCBCR_ENC
#define V4L2_FMT_FLAG_CSC_QUANTIZATION 0x0100
+#define V4L2_FMT_FLAG_META_LINE_BASED 0x0200
/* Frame Size and frame rate enumeration */
/*
@@ -930,9 +1021,12 @@ struct v4l2_requestbuffers {
__u32 type; /* enum v4l2_buf_type */
__u32 memory; /* enum v4l2_memory */
__u32 capabilities;
- __u32 reserved[1];
+ __u8 flags;
+ __u8 reserved[3];
};
+#define V4L2_MEMORY_FLAG_NON_COHERENT (1 << 0)
+
/* capabilities for struct v4l2_requestbuffers and v4l2_create_buffers */
#define V4L2_BUF_CAP_SUPPORTS_MMAP (1 << 0)
#define V4L2_BUF_CAP_SUPPORTS_USERPTR (1 << 1)
@@ -941,21 +1035,25 @@ struct v4l2_requestbuffers {
#define V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS (1 << 4)
#define V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF (1 << 5)
#define V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS (1 << 6)
+#define V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS (1 << 7)
+#define V4L2_BUF_CAP_SUPPORTS_REMOVE_BUFS (1 << 8)
/**
* struct v4l2_plane - plane info for multi-planar buffers
* @bytesused: number of bytes occupied by data in the plane (payload)
* @length: size of this plane (NOT the payload) in bytes
- * @mem_offset: when memory in the associated struct v4l2_buffer is
+ * @m.mem_offset: when memory in the associated struct v4l2_buffer is
* V4L2_MEMORY_MMAP, equals the offset from the start of
* the device memory for this plane (or is a "cookie" that
* should be passed to mmap() called on the video node)
- * @userptr: when memory is V4L2_MEMORY_USERPTR, a userspace pointer
+ * @m.userptr: when memory is V4L2_MEMORY_USERPTR, a userspace pointer
* pointing to this plane
- * @fd: when memory is V4L2_MEMORY_DMABUF, a userspace file
+ * @m.fd: when memory is V4L2_MEMORY_DMABUF, a userspace file
* descriptor associated with this plane
+ * @m: union of @mem_offset, @userptr and @fd
* @data_offset: offset in the plane to the start of data; usually 0,
* unless there is a header in front of the data
+ * @reserved: drivers and applications must zero this array
*
* Multi-planar buffers consist of one or more planes, e.g. an YCbCr buffer
* with two planes can have one plane for Y, and another for interleaved CbCr
@@ -988,19 +1086,23 @@ struct v4l2_plane {
* @sequence: sequence count of this frame
* @memory: enum v4l2_memory; the method, in which the actual video data is
* passed
- * @offset: for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;
+ * @m.offset: for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;
* offset from the start of the device memory for this plane,
* (or a "cookie" that should be passed to mmap() as offset)
- * @userptr: for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;
+ * @m.userptr: for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;
* a userspace pointer pointing to this buffer
- * @fd: for non-multiplanar buffers with memory == V4L2_MEMORY_DMABUF;
+ * @m.fd: for non-multiplanar buffers with memory == V4L2_MEMORY_DMABUF;
* a userspace file descriptor associated with this buffer
- * @planes: for multiplanar buffers; userspace pointer to the array of plane
+ * @m.planes: for multiplanar buffers; userspace pointer to the array of plane
* info structs for this buffer
+ * @m: union of @offset, @userptr, @planes and @fd
* @length: size in bytes of the buffer (NOT its payload) for single-plane
* buffers (when type != *_MPLANE); number of elements in the
* planes array for multi-plane buffers
+ * @reserved2: drivers and applications must zero this field
* @request_fd: fd of the request that this buffer should use
+ * @reserved: for backwards compatibility with applications that do not know
+ * about @request_fd
*
* Contains data exchanged by application and driver using one of the Streaming
* I/O methods.
@@ -1033,7 +1135,7 @@ struct v4l2_buffer {
/**
* v4l2_timeval_to_ns - Convert timeval to nanoseconds
- * @ts: pointer to the timeval variable to be converted
+ * @tv: pointer to the timeval variable to be converted
*
* Returns the scalar nanosecond representation of the timeval
* parameter.
@@ -1093,6 +1195,7 @@ static __inline__ __u64 v4l2_timeval_to_ns(const struct timeval *tv)
* @flags: flags for newly created file, currently only O_CLOEXEC is
* supported, refer to manual of open syscall for more details
* @fd: file descriptor associated with DMABUF (set by driver)
+ * @reserved: drivers and applications must zero this array
*
* Contains data used for exporting a video buffer as DMABUF file descriptor.
* The buffer is identified by a 'cookie' returned by VIDIOC_QUERYBUF
@@ -1524,7 +1627,8 @@ struct v4l2_bt_timings {
((bt)->width + V4L2_DV_BT_BLANKING_WIDTH(bt))
#define V4L2_DV_BT_BLANKING_HEIGHT(bt) \
((bt)->vfrontporch + (bt)->vsync + (bt)->vbackporch + \
- (bt)->il_vfrontporch + (bt)->il_vsync + (bt)->il_vbackporch)
+ ((bt)->interlaced ? \
+ ((bt)->il_vfrontporch + (bt)->il_vsync + (bt)->il_vbackporch) : 0))
#define V4L2_DV_BT_FRAME_HEIGHT(bt) \
((bt)->height + V4L2_DV_BT_BLANKING_HEIGHT(bt))
@@ -1615,7 +1719,7 @@ struct v4l2_input {
__u8 name[32]; /* Label */
__u32 type; /* Type of input */
__u32 audioset; /* Associated audios (bitfield) */
- __u32 tuner; /* enum v4l2_tuner_type */
+ __u32 tuner; /* Tuner index */
v4l2_std_id std;
__u32 status;
__u32 capabilities;
@@ -1702,6 +1806,8 @@ struct v4l2_ext_control {
__u8 *p_u8;
__u16 *p_u16;
__u32 *p_u32;
+ __s32 *p_s32;
+ __s64 *p_s64;
struct v4l2_area *p_area;
struct v4l2_ctrl_h264_sps *p_h264_sps;
struct v4l2_ctrl_h264_pps *p_h264_pps;
@@ -1710,8 +1816,25 @@ struct v4l2_ext_control {
struct v4l2_ctrl_h264_slice_params *p_h264_slice_params;
struct v4l2_ctrl_h264_decode_params *p_h264_decode_params;
struct v4l2_ctrl_fwht_params *p_fwht_params;
+ struct v4l2_ctrl_vp8_frame *p_vp8_frame;
+ struct v4l2_ctrl_mpeg2_sequence *p_mpeg2_sequence;
+ struct v4l2_ctrl_mpeg2_picture *p_mpeg2_picture;
+ struct v4l2_ctrl_mpeg2_quantisation *p_mpeg2_quantisation;
+ struct v4l2_ctrl_vp9_compressed_hdr *p_vp9_compressed_hdr_probs;
+ struct v4l2_ctrl_vp9_frame *p_vp9_frame;
+ struct v4l2_ctrl_hevc_sps *p_hevc_sps;
+ struct v4l2_ctrl_hevc_pps *p_hevc_pps;
+ struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params;
+ struct v4l2_ctrl_hevc_scaling_matrix *p_hevc_scaling_matrix;
+ struct v4l2_ctrl_hevc_decode_params *p_hevc_decode_params;
+ struct v4l2_ctrl_av1_sequence *p_av1_sequence;
+ struct v4l2_ctrl_av1_tile_group_entry *p_av1_tile_group_entry;
+ struct v4l2_ctrl_av1_frame *p_av1_frame;
+ struct v4l2_ctrl_av1_film_grain *p_av1_film_grain;
+ struct v4l2_ctrl_hdr10_cll_info *p_hdr10_cll_info;
+ struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering_display;
void *ptr;
- };
+ } __attribute__ ((packed));
} __attribute__ ((packed));
struct v4l2_ext_controls {
@@ -1753,6 +1876,9 @@ enum v4l2_ctrl_type {
V4L2_CTRL_TYPE_U32 = 0x0102,
V4L2_CTRL_TYPE_AREA = 0x0106,
+ V4L2_CTRL_TYPE_HDR10_CLL_INFO = 0x0110,
+ V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY = 0x0111,
+
V4L2_CTRL_TYPE_H264_SPS = 0x0200,
V4L2_CTRL_TYPE_H264_PPS = 0x0201,
V4L2_CTRL_TYPE_H264_SCALING_MATRIX = 0x0202,
@@ -1761,6 +1887,26 @@ enum v4l2_ctrl_type {
V4L2_CTRL_TYPE_H264_PRED_WEIGHTS = 0x0205,
V4L2_CTRL_TYPE_FWHT_PARAMS = 0x0220,
+
+ V4L2_CTRL_TYPE_VP8_FRAME = 0x0240,
+
+ V4L2_CTRL_TYPE_MPEG2_QUANTISATION = 0x0250,
+ V4L2_CTRL_TYPE_MPEG2_SEQUENCE = 0x0251,
+ V4L2_CTRL_TYPE_MPEG2_PICTURE = 0x0252,
+
+ V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR = 0x0260,
+ V4L2_CTRL_TYPE_VP9_FRAME = 0x0261,
+
+ V4L2_CTRL_TYPE_HEVC_SPS = 0x0270,
+ V4L2_CTRL_TYPE_HEVC_PPS = 0x0271,
+ V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS = 0x0272,
+ V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX = 0x0273,
+ V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS = 0x0274,
+
+ V4L2_CTRL_TYPE_AV1_SEQUENCE = 0x280,
+ V4L2_CTRL_TYPE_AV1_TILE_GROUP_ENTRY = 0x281,
+ V4L2_CTRL_TYPE_AV1_FRAME = 0x282,
+ V4L2_CTRL_TYPE_AV1_FILM_GRAIN = 0x283,
};
/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */
@@ -1816,6 +1962,7 @@ struct v4l2_querymenu {
#define V4L2_CTRL_FLAG_HAS_PAYLOAD 0x0100
#define V4L2_CTRL_FLAG_EXECUTE_ON_WRITE 0x0200
#define V4L2_CTRL_FLAG_MODIFY_LAYOUT 0x0400
+#define V4L2_CTRL_FLAG_DYNAMIC_ARRAY 0x0800
/* Query flags, to be ORed with the control ID */
#define V4L2_CTRL_FLAG_NEXT_CTRL 0x80000000
@@ -2198,6 +2345,7 @@ struct v4l2_mpeg_vbi_fmt_ivtv {
* this plane will be used
* @bytesperline: distance in bytes between the leftmost pixels in two
* adjacent lines
+ * @reserved: drivers and applications must zero this array
*/
struct v4l2_plane_pix_format {
__u32 sizeimage;
@@ -2216,8 +2364,10 @@ struct v4l2_plane_pix_format {
* @num_planes: number of planes for this format
* @flags: format flags (V4L2_PIX_FMT_FLAG_*)
* @ycbcr_enc: enum v4l2_ycbcr_encoding, Y'CbCr encoding
+ * @hsv_enc: enum v4l2_hsv_encoding, HSV encoding
* @quantization: enum v4l2_quantization, colorspace quantization
* @xfer_func: enum v4l2_xfer_func, colorspace transfer function
+ * @reserved: drivers and applications must zero this array
*/
struct v4l2_pix_format_mplane {
__u32 width;
@@ -2242,6 +2392,7 @@ struct v4l2_pix_format_mplane {
* struct v4l2_sdr_format - SDR format definition
* @pixelformat: little endian four character code (fourcc)
* @buffersize: maximum size in bytes required for data
+ * @reserved: drivers and applications must zero this array
*/
struct v4l2_sdr_format {
__u32 pixelformat;
@@ -2253,21 +2404,32 @@ struct v4l2_sdr_format {
* struct v4l2_meta_format - metadata format definition
* @dataformat: little endian four character code (fourcc)
* @buffersize: maximum size in bytes required for data
+ * @width: number of data units of data per line (valid for line
+ * based formats only, see format documentation)
+ * @height: number of lines of data per buffer (valid for line based
+ * formats only)
+ * @bytesperline: offset between the beginnings of two adjacent lines in
+ * bytes (valid for line based formats only)
*/
struct v4l2_meta_format {
__u32 dataformat;
__u32 buffersize;
+ __u32 width;
+ __u32 height;
+ __u32 bytesperline;
} __attribute__ ((packed));
/**
* struct v4l2_format - stream data format
- * @type: enum v4l2_buf_type; type of the data stream
- * @pix: definition of an image format
- * @pix_mp: definition of a multiplanar image format
- * @win: definition of an overlaid image
- * @vbi: raw VBI capture or output parameters
- * @sliced: sliced VBI capture or output parameters
- * @raw_data: placeholder for future extensions and custom formats
+ * @type: enum v4l2_buf_type; type of the data stream
+ * @fmt.pix: definition of an image format
+ * @fmt.pix_mp: definition of a multiplanar image format
+ * @fmt.win: definition of an overlaid image
+ * @fmt.vbi: raw VBI capture or output parameters
+ * @fmt.sliced: sliced VBI capture or output parameters
+ * @fmt.raw_data: placeholder for future extensions and custom formats
+ * @fmt: union of @pix, @pix_mp, @win, @vbi, @sliced, @sdr,
+ * @meta and @raw_data
*/
struct v4l2_format {
__u32 type;
@@ -2317,6 +2479,7 @@ struct v4l2_event_vsync {
#define V4L2_EVENT_CTRL_CH_VALUE (1 << 0)
#define V4L2_EVENT_CTRL_CH_FLAGS (1 << 1)
#define V4L2_EVENT_CTRL_CH_RANGE (1 << 2)
+#define V4L2_EVENT_CTRL_CH_DIMENSIONS (1 << 3)
struct v4l2_event_ctrl {
__u32 changes;
@@ -2436,6 +2599,12 @@ struct v4l2_dbg_chip_info {
* @memory: enum v4l2_memory; buffer memory type
* @format: frame format, for which buffers are requested
* @capabilities: capabilities of this buffer type.
+ * @flags: additional buffer management attributes (ignored unless the
+ * queue has V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS capability
+ * and configured for MMAP streaming I/O).
+ * @max_num_buffers: if V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS capability flag is set
+ * this field indicate the maximum possible number of buffers
+ * for this queue.
* @reserved: future extensions
*/
struct v4l2_create_buffers {
@@ -2444,7 +2613,23 @@ struct v4l2_create_buffers {
__u32 memory;
struct v4l2_format format;
__u32 capabilities;
- __u32 reserved[7];
+ __u32 flags;
+ __u32 max_num_buffers;
+ __u32 reserved[5];
+};
+
+/**
+ * struct v4l2_remove_buffers - VIDIOC_REMOVE_BUFS argument
+ * @index: the first buffer to be removed
+ * @count: number of buffers to removed
+ * @type: enum v4l2_buf_type
+ * @reserved: future extensions
+ */
+struct v4l2_remove_buffers {
+ __u32 index;
+ __u32 count;
+ __u32 type;
+ __u32 reserved[13];
};
/*
@@ -2546,10 +2731,21 @@ struct v4l2_create_buffers {
#define VIDIOC_DBG_G_CHIP_INFO _IOWR('V', 102, struct v4l2_dbg_chip_info)
#define VIDIOC_QUERY_EXT_CTRL _IOWR('V', 103, struct v4l2_query_ext_ctrl)
+#define VIDIOC_REMOVE_BUFS _IOWR('V', 104, struct v4l2_remove_buffers)
+
/* Reminder: when adding new ioctls please add support for them to
drivers/media/v4l2-core/v4l2-compat-ioctl32.c as well! */
#define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */
+/* Deprecated definitions kept for backwards compatibility */
+#define V4L2_PIX_FMT_HM12 V4L2_PIX_FMT_NV12_16L16
+#define V4L2_PIX_FMT_SUNXI_TILED_NV12 V4L2_PIX_FMT_NV12_32L32
+/*
+ * This capability was never implemented, anyone using this cap should drop it
+ * from their code.
+ */
+#define V4L2_CAP_ASYNCIO 0x02000000
+
#endif /* __LINUX_VIDEODEV2_H */
diff --git a/include/meson.build b/include/meson.build
index 2ac9a3a0..19b93a7b 100644
--- a/include/meson.build
+++ b/include/meson.build
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: CC0-1.0
-libcamera_include_dir = 'libcamera'
+include_build_dir = meson.current_build_dir()
subdir('android')
subdir('libcamera')