[PATCH 3/3] py: Add bindings for ControlId vendor information

Laurent Pinchart laurent.pinchart at ideasonboard.com
Thu Oct 10 22:48:23 CEST 2024


On Thu, Oct 10, 2024 at 09:26:47PM +0100, Kieran Bingham wrote:
> Quoting Paul Elder (2024-10-10 09:47:19)
> > Add python bindings for quering vendor information from a ControlId.
> > 
> > Example usage:
> > >>> cid
> > libcamera.ControlId(20, Saturation, ControlType.Float)
> 
> Is it worth updating __repr__ to report the vendor as well ?

Sounds like a worthwhile improvement.

> - or even
> update the print of the name parameter so it shows the same way it could
> be used?

If we include the vendor name in the name property then we should do the
same in C++. I don't think that would be a good idea though, as there
are use cases for handling the vendor and name separately (Paul
mentioned in the cover letter grouping controls per vendor in a UI).

> > >>> cid.vendor
> > 'libcamera'
> > 
> > Signed-off-by: Paul Elder <paul.elder at ideasonboard.com>
> > ---
> >  src/py/libcamera/py_main.cpp | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp
> > index 983b76f6e998..11e9dd6bf6eb 100644
> > --- a/src/py/libcamera/py_main.cpp
> > +++ b/src/py/libcamera/py_main.cpp
> > @@ -400,6 +400,7 @@ PYBIND11_MODULE(_libcamera, m)
> >                 .def_property_readonly("id", &ControlId::id)
> >                 .def_property_readonly("name", &ControlId::name)
> >                 .def_property_readonly("type", &ControlId::type)
> > +               .def_property_readonly("vendor", &ControlId::vendor)
> >                 .def("__str__", [](const ControlId &self) { return self.name(); })
> >                 .def("__repr__", [](const ControlId &self) {
> >                         return py::str("libcamera.ControlId({}, {}, {})")

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list