Message ID | 20210415044854.3348529-3-hiroh@chromium.org |
---|---|
State | Changes Requested |
Headers | show |
Series |
|
Related | show |
Hi Hiro, Thank you for the patch. On Thu, Apr 15, 2021 at 01:48:54PM +0900, Hirokazu Honda wrote: > V4L2Device::updateControls() takes two arguments, raw array and > its size, for the v4l2_ext_control values. This replaces it with > std::vector. Even better, you can use Span<v4l2_ext_control>. > Signed-off-by: Hirokazu Honda <hiroh@chromium.org> > --- > include/libcamera/internal/v4l2_device.h | 3 +-- > src/libcamera/v4l2_device.cpp | 11 ++++------- > 2 files changed, 5 insertions(+), 9 deletions(-) > > diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h > index d006bf68..4cce3840 100644 > --- a/include/libcamera/internal/v4l2_device.h > +++ b/include/libcamera/internal/v4l2_device.h > @@ -55,8 +55,7 @@ protected: > private: > void listControls(); > void updateControls(ControlList *ctrls, > - const struct v4l2_ext_control *v4l2Ctrls, > - unsigned int count); > + const std::vector<v4l2_ext_control> &v4l2Ctrls); > > void eventAvailable(EventNotifier *notifier); > > diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp > index 5ec1b10e..217a39e3 100644 > --- a/src/libcamera/v4l2_device.cpp > +++ b/src/libcamera/v4l2_device.cpp > @@ -250,7 +250,7 @@ ControlList V4L2Device::getControls(const std::vector<uint32_t> &ids) > v4l2Ctrls.resize(errorIdx); > } > > - updateControls(&ctrls, v4l2Ctrls.data(), v4l2Ctrls.size()); > + updateControls(&ctrls, v4l2Ctrls); > > return ctrls; > } > @@ -350,7 +350,7 @@ int V4L2Device::setControls(ControlList *ctrls) > ret = errorIdx; > } > > - updateControls(ctrls, v4l2Ctrls.data(), v4l2Ctrls.size()); > + updateControls(ctrls, v4l2Ctrls); > > return ret; > } > @@ -514,14 +514,11 @@ void V4L2Device::listControls() > * values in \a v4l2Ctrls > * \param[inout] ctrls List of V4L2 controls to update > * \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, > - const struct v4l2_ext_control *v4l2Ctrls, > - unsigned int count) > + const std::vector<v4l2_ext_control> &v4l2Ctrls) > { > - for (unsigned int i = 0; i < count; i++) { > - const struct v4l2_ext_control &v4l2Ctrl = v4l2Ctrls[i]; > + for (const v4l2_ext_control &v4l2Ctrl : v4l2Ctrls) { > const unsigned int id = v4l2Ctrl.id; > if (!ctrls->contains(id)) { > LOG(V4L2, Error) << "ControlList doesn't contain id: "
diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h index d006bf68..4cce3840 100644 --- a/include/libcamera/internal/v4l2_device.h +++ b/include/libcamera/internal/v4l2_device.h @@ -55,8 +55,7 @@ protected: private: void listControls(); void updateControls(ControlList *ctrls, - const struct v4l2_ext_control *v4l2Ctrls, - unsigned int count); + const std::vector<v4l2_ext_control> &v4l2Ctrls); void eventAvailable(EventNotifier *notifier); diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 5ec1b10e..217a39e3 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -250,7 +250,7 @@ ControlList V4L2Device::getControls(const std::vector<uint32_t> &ids) v4l2Ctrls.resize(errorIdx); } - updateControls(&ctrls, v4l2Ctrls.data(), v4l2Ctrls.size()); + updateControls(&ctrls, v4l2Ctrls); return ctrls; } @@ -350,7 +350,7 @@ int V4L2Device::setControls(ControlList *ctrls) ret = errorIdx; } - updateControls(ctrls, v4l2Ctrls.data(), v4l2Ctrls.size()); + updateControls(ctrls, v4l2Ctrls); return ret; } @@ -514,14 +514,11 @@ void V4L2Device::listControls() * values in \a v4l2Ctrls * \param[inout] ctrls List of V4L2 controls to update * \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, - const struct v4l2_ext_control *v4l2Ctrls, - unsigned int count) + const std::vector<v4l2_ext_control> &v4l2Ctrls) { - for (unsigned int i = 0; i < count; i++) { - const struct v4l2_ext_control &v4l2Ctrl = v4l2Ctrls[i]; + for (const v4l2_ext_control &v4l2Ctrl : v4l2Ctrls) { const unsigned int id = v4l2Ctrl.id; if (!ctrls->contains(id)) { LOG(V4L2, Error) << "ControlList doesn't contain id: "
V4L2Device::updateControls() takes two arguments, raw array and its size, for the v4l2_ext_control values. This replaces it with std::vector. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> --- include/libcamera/internal/v4l2_device.h | 3 +-- src/libcamera/v4l2_device.cpp | 11 ++++------- 2 files changed, 5 insertions(+), 9 deletions(-)