| Message ID | 20260721145958.68489-2-johannes.goede@oss.qualcomm.com |
|---|---|
| State | New |
| Headers | show |
| Series |
|
| Related | show |
Quoting Hans de Goede (2026-07-21 15:59:51) > Add a whence argument to V4L2Subdevice::[get|set]Selection() allowing > callers to specify that the operation should be applied to the try state, > rather then always applying it to the active state. > The documentation for the V4L2Subdevice::Whence only states * \brief Specify the type of format for getFormat() and setFormat() operations Perhaps this could be updated or simplified. But eitherway, adding the whence seems reasonable: Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com> > --- > include/libcamera/internal/v4l2_subdevice.h | 14 ++++++++------ > src/libcamera/v4l2_subdevice.cpp | 20 ++++++++++++++------ > 2 files changed, 22 insertions(+), 12 deletions(-) > > diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h > index c37a82afa..36848915f 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 a69de154e..8f9d4dbd9 100644 > --- a/src/libcamera/v4l2_subdevice.cpp > +++ b/src/libcamera/v4l2_subdevice.cpp > @@ -1171,17 +1171,19 @@ int V4L2Subdevice::open() > * \param[in] stream The stream the rectangle is retrieved from > * \param[in] target The selection target defined by the V4L2_SEL_TGT_* flags > * \param[out] rect The retrieved selection rectangle > + * \param[in] whence The format to get, \ref V4L2Subdevice::ActiveFormat > + * "ActiveFormat" or \ref V4L2Subdevice::TryFormat "TryFormat" > * > * \todo Define a V4L2SelectionTarget enum for the selection target > * > * \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; > @@ -1205,11 +1207,13 @@ int V4L2Subdevice::getSelection(const Stream &stream, unsigned int target, > > /** > * \fn V4L2Subdevice::getSelection(unsigned int pad, unsigned int target, > - * Rectangle *rect) > + * Rectangle *rect, Whence whence = ActiveFormat) > * \brief Get selection rectangle \a rect for \a target > * \param[in] pad The 0-indexed pad number the rectangle is retrieved from > * \param[in] target The selection target defined by the V4L2_SEL_TGT_* flags > * \param[out] rect The retrieved selection rectangle > + * \param[in] whence The format to get, \ref V4L2Subdevice::ActiveFormat > + * "ActiveFormat" or \ref V4L2Subdevice::TryFormat "TryFormat" > * > * \return 0 on success or a negative error code otherwise > */ > @@ -1219,17 +1223,19 @@ int V4L2Subdevice::getSelection(const Stream &stream, unsigned int target, > * \param[in] stream The stream the rectangle is to be applied to > * \param[in] target The selection target defined by the V4L2_SEL_TGT_* flags > * \param[inout] rect The selection rectangle to be applied > + * \param[in] whence The format to get, \ref V4L2Subdevice::ActiveFormat > + * "ActiveFormat" or \ref V4L2Subdevice::TryFormat "TryFormat" > * > * \todo Define a V4L2SelectionTarget enum for the selection 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; > @@ -1258,11 +1264,13 @@ int V4L2Subdevice::setSelection(const Stream &stream, unsigned int target, > > /** > * \fn V4L2Subdevice::setSelection(unsigned int pad, unsigned int target, > - * Rectangle *rect) > + * Rectangle *rect, Whence whence = ActiveFormat) > * \brief Set selection rectangle \a rect for \a target > * \param[in] pad The 0-indexed pad number the rectangle is to be applied to > * \param[in] target The selection target defined by the V4L2_SEL_TGT_* flags > * \param[inout] rect The selection rectangle to be applied > + * \param[in] whence The format to get, \ref V4L2Subdevice::ActiveFormat > + * "ActiveFormat" or \ref V4L2Subdevice::TryFormat "TryFormat" > * > * \todo Define a V4L2SelectionTarget enum for the selection target > * > -- > 2.55.0 >
2026. 07. 21. 16:59 keltezéssel, Hans de Goede írta: > Add a whence argument to V4L2Subdevice::[get|set]Selection() allowing > callers to specify that the operation should be applied to the try state, > rather then always applying it to the active state. > > Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com> > --- Looks ok to me. Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> > include/libcamera/internal/v4l2_subdevice.h | 14 ++++++++------ > src/libcamera/v4l2_subdevice.cpp | 20 ++++++++++++++------ > 2 files changed, 22 insertions(+), 12 deletions(-) > > diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h > index c37a82afa..36848915f 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 a69de154e..8f9d4dbd9 100644 > --- a/src/libcamera/v4l2_subdevice.cpp > +++ b/src/libcamera/v4l2_subdevice.cpp > @@ -1171,17 +1171,19 @@ int V4L2Subdevice::open() > * \param[in] stream The stream the rectangle is retrieved from > * \param[in] target The selection target defined by the V4L2_SEL_TGT_* flags > * \param[out] rect The retrieved selection rectangle > + * \param[in] whence The format to get, \ref V4L2Subdevice::ActiveFormat > + * "ActiveFormat" or \ref V4L2Subdevice::TryFormat "TryFormat" > * > * \todo Define a V4L2SelectionTarget enum for the selection target > * > * \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; > @@ -1205,11 +1207,13 @@ int V4L2Subdevice::getSelection(const Stream &stream, unsigned int target, > > /** > * \fn V4L2Subdevice::getSelection(unsigned int pad, unsigned int target, > - * Rectangle *rect) > + * Rectangle *rect, Whence whence = ActiveFormat) > * \brief Get selection rectangle \a rect for \a target > * \param[in] pad The 0-indexed pad number the rectangle is retrieved from > * \param[in] target The selection target defined by the V4L2_SEL_TGT_* flags > * \param[out] rect The retrieved selection rectangle > + * \param[in] whence The format to get, \ref V4L2Subdevice::ActiveFormat > + * "ActiveFormat" or \ref V4L2Subdevice::TryFormat "TryFormat" > * > * \return 0 on success or a negative error code otherwise > */ > @@ -1219,17 +1223,19 @@ int V4L2Subdevice::getSelection(const Stream &stream, unsigned int target, > * \param[in] stream The stream the rectangle is to be applied to > * \param[in] target The selection target defined by the V4L2_SEL_TGT_* flags > * \param[inout] rect The selection rectangle to be applied > + * \param[in] whence The format to get, \ref V4L2Subdevice::ActiveFormat > + * "ActiveFormat" or \ref V4L2Subdevice::TryFormat "TryFormat" > * > * \todo Define a V4L2SelectionTarget enum for the selection 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; > @@ -1258,11 +1264,13 @@ int V4L2Subdevice::setSelection(const Stream &stream, unsigned int target, > > /** > * \fn V4L2Subdevice::setSelection(unsigned int pad, unsigned int target, > - * Rectangle *rect) > + * Rectangle *rect, Whence whence = ActiveFormat) > * \brief Set selection rectangle \a rect for \a target > * \param[in] pad The 0-indexed pad number the rectangle is to be applied to > * \param[in] target The selection target defined by the V4L2_SEL_TGT_* flags > * \param[inout] rect The selection rectangle to be applied > + * \param[in] whence The format to get, \ref V4L2Subdevice::ActiveFormat > + * "ActiveFormat" or \ref V4L2Subdevice::TryFormat "TryFormat" > * > * \todo Define a V4L2SelectionTarget enum for the selection target > *
diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h index c37a82afa..36848915f 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 a69de154e..8f9d4dbd9 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -1171,17 +1171,19 @@ int V4L2Subdevice::open() * \param[in] stream The stream the rectangle is retrieved from * \param[in] target The selection target defined by the V4L2_SEL_TGT_* flags * \param[out] rect The retrieved selection rectangle + * \param[in] whence The format to get, \ref V4L2Subdevice::ActiveFormat + * "ActiveFormat" or \ref V4L2Subdevice::TryFormat "TryFormat" * * \todo Define a V4L2SelectionTarget enum for the selection target * * \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; @@ -1205,11 +1207,13 @@ int V4L2Subdevice::getSelection(const Stream &stream, unsigned int target, /** * \fn V4L2Subdevice::getSelection(unsigned int pad, unsigned int target, - * Rectangle *rect) + * Rectangle *rect, Whence whence = ActiveFormat) * \brief Get selection rectangle \a rect for \a target * \param[in] pad The 0-indexed pad number the rectangle is retrieved from * \param[in] target The selection target defined by the V4L2_SEL_TGT_* flags * \param[out] rect The retrieved selection rectangle + * \param[in] whence The format to get, \ref V4L2Subdevice::ActiveFormat + * "ActiveFormat" or \ref V4L2Subdevice::TryFormat "TryFormat" * * \return 0 on success or a negative error code otherwise */ @@ -1219,17 +1223,19 @@ int V4L2Subdevice::getSelection(const Stream &stream, unsigned int target, * \param[in] stream The stream the rectangle is to be applied to * \param[in] target The selection target defined by the V4L2_SEL_TGT_* flags * \param[inout] rect The selection rectangle to be applied + * \param[in] whence The format to get, \ref V4L2Subdevice::ActiveFormat + * "ActiveFormat" or \ref V4L2Subdevice::TryFormat "TryFormat" * * \todo Define a V4L2SelectionTarget enum for the selection 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; @@ -1258,11 +1264,13 @@ int V4L2Subdevice::setSelection(const Stream &stream, unsigned int target, /** * \fn V4L2Subdevice::setSelection(unsigned int pad, unsigned int target, - * Rectangle *rect) + * Rectangle *rect, Whence whence = ActiveFormat) * \brief Set selection rectangle \a rect for \a target * \param[in] pad The 0-indexed pad number the rectangle is to be applied to * \param[in] target The selection target defined by the V4L2_SEL_TGT_* flags * \param[inout] rect The selection rectangle to be applied + * \param[in] whence The format to get, \ref V4L2Subdevice::ActiveFormat + * "ActiveFormat" or \ref V4L2Subdevice::TryFormat "TryFormat" * * \todo Define a V4L2SelectionTarget enum for the selection target *
Add a whence argument to V4L2Subdevice::[get|set]Selection() allowing callers to specify that the operation should be applied to the try state, rather then always applying it to the active state. Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com> --- include/libcamera/internal/v4l2_subdevice.h | 14 ++++++++------ src/libcamera/v4l2_subdevice.cpp | 20 ++++++++++++++------ 2 files changed, 22 insertions(+), 12 deletions(-)