libcamera: V4L2Device: Use Span in updateControls()

V4L2Device::updateControls() takes two arguments, raw array and
its size, for the v4l2_ext_control values. This replaces it with
libcamera::Span.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
Hirokazu Honda 2021-04-23 18:36:53 +09:00 committed by Laurent Pinchart
parent 3c0e99e034
commit c3ab0fa0ce
2 changed files with 6 additions and 8 deletions

View file

@ -14,6 +14,7 @@
#include <linux/videodev2.h> #include <linux/videodev2.h>
#include <libcamera/signal.h> #include <libcamera/signal.h>
#include <libcamera/span.h>
#include "libcamera/internal/log.h" #include "libcamera/internal/log.h"
#include "libcamera/internal/v4l2_controls.h" #include "libcamera/internal/v4l2_controls.h"
@ -55,8 +56,7 @@ protected:
private: private:
void listControls(); void listControls();
void updateControls(ControlList *ctrls, void updateControls(ControlList *ctrls,
const struct v4l2_ext_control *v4l2Ctrls, Span<const v4l2_ext_control> v4l2Ctrls);
unsigned int count);
void eventAvailable(EventNotifier *notifier); void eventAvailable(EventNotifier *notifier);

View file

@ -253,7 +253,7 @@ ControlList V4L2Device::getControls(const std::vector<uint32_t> &ids)
v4l2Ctrls.resize(errorIdx); v4l2Ctrls.resize(errorIdx);
} }
updateControls(&ctrls, v4l2Ctrls.data(), v4l2Ctrls.size()); updateControls(&ctrls, v4l2Ctrls);
return ctrls; return ctrls;
} }
@ -352,7 +352,7 @@ int V4L2Device::setControls(ControlList *ctrls)
ret = errorIdx; ret = errorIdx;
} }
updateControls(ctrls, v4l2Ctrls.data(), v4l2Ctrls.size()); updateControls(ctrls, v4l2Ctrls);
return ret; return ret;
} }
@ -516,15 +516,13 @@ void V4L2Device::listControls()
* values in \a v4l2Ctrls * values in \a v4l2Ctrls
* \param[inout] ctrls List of V4L2 controls to update * \param[inout] ctrls List of V4L2 controls to update
* \param[in] v4l2Ctrls List of V4L2 extended controls as returned by the driver * \param[in] v4l2Ctrls List of V4L2 extended controls as returned by the driver
* \param[in] count The number of controls to update
*/ */
void V4L2Device::updateControls(ControlList *ctrls, void V4L2Device::updateControls(ControlList *ctrls,
const struct v4l2_ext_control *v4l2Ctrls, Span<const v4l2_ext_control> v4l2Ctrls)
unsigned int count)
{ {
unsigned int i = 0; unsigned int i = 0;
for (auto &ctrl : *ctrls) { for (auto &ctrl : *ctrls) {
if (i == count) if (i == v4l2Ctrls.size())
break; break;
const struct v4l2_ext_control *v4l2Ctrl = &v4l2Ctrls[i]; const struct v4l2_ext_control *v4l2Ctrl = &v4l2Ctrls[i];