| Message ID | 20261118-sklug-binning-factors-v1-v1-1-5e552aefbb07@ideasonboard.com |
|---|---|
| State | New |
| Headers | show |
| Series |
|
| Related | show |
2026. 11. 18. 17:08 keltezéssel, Stefan Klug írta: > Add whence parameter to V4L2Subdevice::setSelection() and > V4L2Subdevice::getSelection() to be able to use try state with these > functions. > > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> > --- This appears to be the same as https://patchwork.libcamera.org/patch/28790/. Maybe you could take that as-is. In any case, this looks ok, apart from the missing documentation updates. > include/libcamera/internal/v4l2_subdevice.h | 14 ++++++++------ > src/libcamera/v4l2_subdevice.cpp | 8 ++++---- > 2 files changed, 12 insertions(+), 10 deletions(-) > > diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h > index c37a82afa881..36848915fbb1 100644 > --- a/include/libcamera/internal/v4l2_subdevice.h > +++ b/include/libcamera/internal/v4l2_subdevice.h > @@ -123,16 +123,18 @@ public: > const MediaEntity *entity() const { return entity_; } > > int getSelection(const Stream &stream, unsigned int target, > - Rectangle *rect); > - int getSelection(unsigned int pad, unsigned int target, Rectangle *rect) > + Rectangle *rect, Whence whence = ActiveFormat); > + int getSelection(unsigned int pad, unsigned int target, Rectangle *rect, > + Whence whence = ActiveFormat) > { > - return getSelection({ pad, 0 }, target, rect); > + return getSelection({ pad, 0 }, target, rect, whence); > } > int setSelection(const Stream &stream, unsigned int target, > - Rectangle *rect); > - int setSelection(unsigned int pad, unsigned int target, Rectangle *rect) > + Rectangle *rect, Whence whence = ActiveFormat); > + int setSelection(unsigned int pad, unsigned int target, Rectangle *rect, > + Whence whence = ActiveFormat) > { > - return setSelection({ pad, 0 }, target, rect); > + return setSelection({ pad, 0 }, target, rect, whence); > } > > Formats formats(const Stream &stream); > diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp > index a69de154e8bb..e5b88c4a3ed1 100644 > --- a/src/libcamera/v4l2_subdevice.cpp > +++ b/src/libcamera/v4l2_subdevice.cpp > @@ -1177,11 +1177,11 @@ int V4L2Subdevice::open() > * \return 0 on success or a negative error code otherwise > */ > int V4L2Subdevice::getSelection(const Stream &stream, unsigned int target, > - Rectangle *rect) > + Rectangle *rect, Whence whence) > { > struct v4l2_subdev_selection sel = {}; > > - sel.which = V4L2_SUBDEV_FORMAT_ACTIVE; > + sel.which = whence; > sel.pad = stream.pad; > sel.stream = stream.stream; > sel.target = target; > @@ -1225,11 +1225,11 @@ int V4L2Subdevice::getSelection(const Stream &stream, unsigned int target, > * \return 0 on success or a negative error code otherwise > */ > int V4L2Subdevice::setSelection(const Stream &stream, unsigned int target, > - Rectangle *rect) > + Rectangle *rect, Whence whence) > { > struct v4l2_subdev_selection sel = {}; > > - sel.which = V4L2_SUBDEV_FORMAT_ACTIVE; > + sel.which = whence; > sel.pad = stream.pad; > sel.stream = stream.stream; > sel.target = target; >
diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h index c37a82afa881..36848915fbb1 100644 --- a/include/libcamera/internal/v4l2_subdevice.h +++ b/include/libcamera/internal/v4l2_subdevice.h @@ -123,16 +123,18 @@ public: const MediaEntity *entity() const { return entity_; } int getSelection(const Stream &stream, unsigned int target, - Rectangle *rect); - int getSelection(unsigned int pad, unsigned int target, Rectangle *rect) + Rectangle *rect, Whence whence = ActiveFormat); + int getSelection(unsigned int pad, unsigned int target, Rectangle *rect, + Whence whence = ActiveFormat) { - return getSelection({ pad, 0 }, target, rect); + return getSelection({ pad, 0 }, target, rect, whence); } int setSelection(const Stream &stream, unsigned int target, - Rectangle *rect); - int setSelection(unsigned int pad, unsigned int target, Rectangle *rect) + Rectangle *rect, Whence whence = ActiveFormat); + int setSelection(unsigned int pad, unsigned int target, Rectangle *rect, + Whence whence = ActiveFormat) { - return setSelection({ pad, 0 }, target, rect); + return setSelection({ pad, 0 }, target, rect, whence); } Formats formats(const Stream &stream); diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index a69de154e8bb..e5b88c4a3ed1 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -1177,11 +1177,11 @@ int V4L2Subdevice::open() * \return 0 on success or a negative error code otherwise */ int V4L2Subdevice::getSelection(const Stream &stream, unsigned int target, - Rectangle *rect) + Rectangle *rect, Whence whence) { struct v4l2_subdev_selection sel = {}; - sel.which = V4L2_SUBDEV_FORMAT_ACTIVE; + sel.which = whence; sel.pad = stream.pad; sel.stream = stream.stream; sel.target = target; @@ -1225,11 +1225,11 @@ int V4L2Subdevice::getSelection(const Stream &stream, unsigned int target, * \return 0 on success or a negative error code otherwise */ int V4L2Subdevice::setSelection(const Stream &stream, unsigned int target, - Rectangle *rect) + Rectangle *rect, Whence whence) { struct v4l2_subdev_selection sel = {}; - sel.which = V4L2_SUBDEV_FORMAT_ACTIVE; + sel.which = whence; sel.pad = stream.pad; sel.stream = stream.stream; sel.target = target;
Add whence parameter to V4L2Subdevice::setSelection() and V4L2Subdevice::getSelection() to be able to use try state with these functions. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> --- include/libcamera/internal/v4l2_subdevice.h | 14 ++++++++------ src/libcamera/v4l2_subdevice.cpp | 8 ++++---- 2 files changed, 12 insertions(+), 10 deletions(-)