[{"id":32570,"web_url":"https://patchwork.libcamera.org/comment/32570/","msgid":"<173348771788.1166077.10184345273898477688@ping.linuxembedded.co.uk>","date":"2024-12-06T12:21:57","subject":"Re: [PATCH v3 2/4] utils: codegen: controls.py: Parse direction\n\tinformation","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Paul Elder (2024-11-29 09:19:14)\n> In preparation for adding support for querying direction information\n> from controls, parse the direction information from control ID\n> definitions. This can later be plugged in directly to the IPA code\n> generators simply by using ctrl.direction.\n> \n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> \n> ---\n> Changes in v3:\n> - minor reordering\n> \n> Changes in v2:\n> - prevent errors in parsing properties, since the direction field is now\n>   required yet properties can only be out\n>   - do this by expanding the Control constructor to take the mode\n>     argument, so that needs to be passed in by the users of Control\n> ---\n>  src/py/libcamera/gen-py-controls.py |  2 +-\n>  utils/codegen/controls.py           | 24 +++++++++++++++++++++++-\n>  utils/codegen/gen-controls.py       |  2 +-\n>  utils/codegen/gen-gst-controls.py   |  2 +-\n>  4 files changed, 26 insertions(+), 4 deletions(-)\n> \n> diff --git a/src/py/libcamera/gen-py-controls.py b/src/py/libcamera/gen-py-controls.py\n> index cf09c146084d..d43a7c1c7eab 100755\n> --- a/src/py/libcamera/gen-py-controls.py\n> +++ b/src/py/libcamera/gen-py-controls.py\n> @@ -83,7 +83,7 @@ def main(argv):\n>              vendors.append(vendor)\n>  \n>          for ctrl in data['controls']:\n> -            ctrl = Control(*ctrl.popitem(), vendor)\n> +            ctrl = Control(*ctrl.popitem(), vendor, args.mode)\n>              controls.append(extend_control(ctrl, args.mode))\n>  \n>      data = {\n> diff --git a/utils/codegen/controls.py b/utils/codegen/controls.py\n> index 03c77cc64abe..602f15b25fb6 100644\n> --- a/utils/codegen/controls.py\n> +++ b/utils/codegen/controls.py\n> @@ -28,7 +28,7 @@ class ControlEnum(object):\n>  \n>  \n>  class Control(object):\n> -    def __init__(self, name, data, vendor):\n> +    def __init__(self, name, data, vendor, mode):\n>          self.__name = name\n>          self.__data = data\n>          self.__enum_values = None\n> @@ -60,6 +60,16 @@ class Control(object):\n>  \n>              self.__size = num_elems\n>  \n> +        if mode == 'properties':\n> +            self.__direction = 'out'\n> +        else:\n> +            direction = self.__data.get('direction')\n> +            if direction is None:\n> +                raise RuntimeError(f'Control `{self.__name}` missing required field `{direction}`')\n> +            if direction not in ['in', 'out', 'inout']:\n> +                raise RuntimeError(f'Control `{self.__name}` direction `{direction}` is invalid; must be one of `in`, `out`, or `inout`')\n> +            self.__direction = direction\n> +\n>      @property\n>      def description(self):\n>          \"\"\"The control description\"\"\"\n> @@ -111,6 +121,18 @@ class Control(object):\n>          else:\n>              return f\"Span<const {typ}>\"\n>  \n> +    @property\n> +    def direction(self):\n> +        in_flag = 'ControlId::Direction::In'\n> +        out_flag = 'ControlId::Direction::Out'\n> +\n> +        if self.__direction == 'inout':\n> +            return f'{in_flag} | {out_flag}'\n> +        if self.__direction == 'in':\n> +            return in_flag\n> +        if self.__direction == 'out':\n> +            return out_flag\n> +\n>      @property\n>      def element_type(self):\n>          return self.__data.get('type')\n> diff --git a/utils/codegen/gen-controls.py b/utils/codegen/gen-controls.py\n> index 3034e9a54760..59b716c1c48c 100755\n> --- a/utils/codegen/gen-controls.py\n> +++ b/utils/codegen/gen-controls.py\n> @@ -71,7 +71,7 @@ def main(argv):\n>          ctrls = controls.setdefault(vendor, [])\n>  \n>          for i, ctrl in enumerate(data['controls']):\n> -            ctrl = Control(*ctrl.popitem(), vendor)\n> +            ctrl = Control(*ctrl.popitem(), vendor, args.mode)\n>              ctrls.append(extend_control(ctrl, i, ranges))\n>  \n>      # Sort the vendors by range numerical value\n> diff --git a/utils/codegen/gen-gst-controls.py b/utils/codegen/gen-gst-controls.py\n> index 2601a67588a3..df0988266294 100755\n> --- a/utils/codegen/gen-gst-controls.py\n> +++ b/utils/codegen/gen-gst-controls.py\n> @@ -154,7 +154,7 @@ def main(argv):\n>          ctrls = controls.setdefault(vendor, [])\n>  \n>          for ctrl in data['controls']:\n> -            ctrl = Control(*ctrl.popitem(), vendor)\n> +            ctrl = Control(*ctrl.popitem(), vendor, mode='controls')\n>  \n>              if ctrl.name in exposed_controls:\n>                  ctrls.append(extend_control(ctrl))\n> -- \n> 2.39.2\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 54C72BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  6 Dec 2024 12:22:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 94C146613A;\n\tFri,  6 Dec 2024 13:22:02 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 628D4618B3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  6 Dec 2024 13:22:01 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C2FFB74C;\n\tFri,  6 Dec 2024 13:21:31 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"H7SSY8Bn\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1733487691;\n\tbh=dvDkRzLdyfm53G7znKYL/wZSFct8wnmJJOEvnrXC4VM=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=H7SSY8Bn0qwshdnqcwFSFFldUSMzy4Z3ewZedhNpRfvdjFXDBQ7Bko2mA3SddW2j2\n\tAIq0lBok2XJIHQpqh9h+gkKFZSZOtbbE3m1UoCwi1LC+PawPNKYVrw9TuEi0lxaHjT\n\tiaRSHve85fJXPkvNxNnHDIbG6rwapAr+22OyVXT0=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20241129091916.298359-3-paul.elder@ideasonboard.com>","References":"<20241129091916.298359-1-paul.elder@ideasonboard.com>\n\t<20241129091916.298359-3-paul.elder@ideasonboard.com>","Subject":"Re: [PATCH v3 2/4] utils: codegen: controls.py: Parse direction\n\tinformation","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Paul Elder <paul.elder@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Fri, 06 Dec 2024 12:21:57 +0000","Message-ID":"<173348771788.1166077.10184345273898477688@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":32572,"web_url":"https://patchwork.libcamera.org/comment/32572/","msgid":"<173348925086.3135963.8504536559787815395@ping.linuxembedded.co.uk>","date":"2024-12-06T12:47:30","subject":"Re: [PATCH v3 2/4] utils: codegen: controls.py: Parse direction\n\tinformation","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Paul Elder (2024-11-29 09:19:14)\n> In preparation for adding support for querying direction information\n> from controls, parse the direction information from control ID\n> definitions. This can later be plugged in directly to the IPA code\n> generators simply by using ctrl.direction.\n> \n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> ---\n> Changes in v3:\n> - minor reordering\n> \n> Changes in v2:\n> - prevent errors in parsing properties, since the direction field is now\n>   required yet properties can only be out\n>   - do this by expanding the Control constructor to take the mode\n>     argument, so that needs to be passed in by the users of Control\n> ---\n>  src/py/libcamera/gen-py-controls.py |  2 +-\n>  utils/codegen/controls.py           | 24 +++++++++++++++++++++++-\n>  utils/codegen/gen-controls.py       |  2 +-\n>  utils/codegen/gen-gst-controls.py   |  2 +-\n>  4 files changed, 26 insertions(+), 4 deletions(-)\n> \n> diff --git a/src/py/libcamera/gen-py-controls.py b/src/py/libcamera/gen-py-controls.py\n> index cf09c146084d..d43a7c1c7eab 100755\n> --- a/src/py/libcamera/gen-py-controls.py\n> +++ b/src/py/libcamera/gen-py-controls.py\n> @@ -83,7 +83,7 @@ def main(argv):\n>              vendors.append(vendor)\n>  \n>          for ctrl in data['controls']:\n> -            ctrl = Control(*ctrl.popitem(), vendor)\n> +            ctrl = Control(*ctrl.popitem(), vendor, args.mode)\n>              controls.append(extend_control(ctrl, args.mode))\n>  \n>      data = {\n> diff --git a/utils/codegen/controls.py b/utils/codegen/controls.py\n> index 03c77cc64abe..602f15b25fb6 100644\n> --- a/utils/codegen/controls.py\n> +++ b/utils/codegen/controls.py\n> @@ -28,7 +28,7 @@ class ControlEnum(object):\n>  \n>  \n>  class Control(object):\n> -    def __init__(self, name, data, vendor):\n> +    def __init__(self, name, data, vendor, mode):\n>          self.__name = name\n>          self.__data = data\n>          self.__enum_values = None\n> @@ -60,6 +60,16 @@ class Control(object):\n>  \n>              self.__size = num_elems\n>  \n> +        if mode == 'properties':\n> +            self.__direction = 'out'\n> +        else:\n> +            direction = self.__data.get('direction')\n> +            if direction is None:\n> +                raise RuntimeError(f'Control `{self.__name}` missing required field `{direction}`')\n> +            if direction not in ['in', 'out', 'inout']:\n> +                raise RuntimeError(f'Control `{self.__name}` direction `{direction}` is invalid; must be one of `in`, `out`, or `inout`')\n> +            self.__direction = direction\n> +\n>      @property\n>      def description(self):\n>          \"\"\"The control description\"\"\"\n> @@ -111,6 +121,18 @@ class Control(object):\n>          else:\n>              return f\"Span<const {typ}>\"\n>  \n> +    @property\n> +    def direction(self):\n> +        in_flag = 'ControlId::Direction::In'\n> +        out_flag = 'ControlId::Direction::Out'\n\nDoes this work ? Are these the flags that are only introduced in the\nnext patch ?\n\n\n\n> +\n> +        if self.__direction == 'inout':\n> +            return f'{in_flag} | {out_flag}'\n> +        if self.__direction == 'in':\n> +            return in_flag\n> +        if self.__direction == 'out':\n> +            return out_flag\n> +\n>      @property\n>      def element_type(self):\n>          return self.__data.get('type')\n> diff --git a/utils/codegen/gen-controls.py b/utils/codegen/gen-controls.py\n> index 3034e9a54760..59b716c1c48c 100755\n> --- a/utils/codegen/gen-controls.py\n> +++ b/utils/codegen/gen-controls.py\n> @@ -71,7 +71,7 @@ def main(argv):\n>          ctrls = controls.setdefault(vendor, [])\n>  \n>          for i, ctrl in enumerate(data['controls']):\n> -            ctrl = Control(*ctrl.popitem(), vendor)\n> +            ctrl = Control(*ctrl.popitem(), vendor, args.mode)\n>              ctrls.append(extend_control(ctrl, i, ranges))\n>  \n>      # Sort the vendors by range numerical value\n> diff --git a/utils/codegen/gen-gst-controls.py b/utils/codegen/gen-gst-controls.py\n> index 2601a67588a3..df0988266294 100755\n> --- a/utils/codegen/gen-gst-controls.py\n> +++ b/utils/codegen/gen-gst-controls.py\n> @@ -154,7 +154,7 @@ def main(argv):\n>          ctrls = controls.setdefault(vendor, [])\n>  \n>          for ctrl in data['controls']:\n> -            ctrl = Control(*ctrl.popitem(), vendor)\n> +            ctrl = Control(*ctrl.popitem(), vendor, mode='controls')\n>  \n>              if ctrl.name in exposed_controls:\n>                  ctrls.append(extend_control(ctrl))\n> -- \n> 2.39.2\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id DD480BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  6 Dec 2024 12:47:36 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EA48B6613E;\n\tFri,  6 Dec 2024 13:47:35 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6DC46618B3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  6 Dec 2024 13:47:34 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B2E46B2B;\n\tFri,  6 Dec 2024 13:47:04 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"aTDKVR2i\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1733489224;\n\tbh=2KBfdZMxImI9OPwqqPruozfdL5UlWalJ0YPL6cXi5nM=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=aTDKVR2iYIl8/1z7qFgN9F/3gjJCE4jFecArSjbbtb/mB2ltarPz/Ty2udSgD6DD1\n\trqZWR0LGImHOg1OVxWuH9eeWa6j2Yq6S9NX6Y+pAxFe8hh9KVQRiToi07nRv8MSak4\n\tLL7ufUAGLO2aj8g9/Y6um3cBPT/Ve7X6d4QwTNx8=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20241129091916.298359-3-paul.elder@ideasonboard.com>","References":"<20241129091916.298359-1-paul.elder@ideasonboard.com>\n\t<20241129091916.298359-3-paul.elder@ideasonboard.com>","Subject":"Re: [PATCH v3 2/4] utils: codegen: controls.py: Parse direction\n\tinformation","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Paul Elder <paul.elder@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Fri, 06 Dec 2024 12:47:30 +0000","Message-ID":"<173348925086.3135963.8504536559787815395@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":32578,"web_url":"https://patchwork.libcamera.org/comment/32578/","msgid":"<20241206131611.GH25902@pendragon.ideasonboard.com>","date":"2024-12-06T13:16:11","subject":"Re: [PATCH v3 2/4] utils: codegen: controls.py: Parse direction\n\tinformation","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Fri, Dec 06, 2024 at 12:47:30PM +0000, Kieran Bingham wrote:\n> Quoting Paul Elder (2024-11-29 09:19:14)\n> > In preparation for adding support for querying direction information\n> > from controls, parse the direction information from control ID\n> > definitions. This can later be plugged in directly to the IPA code\n> > generators simply by using ctrl.direction.\n> > \n> > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > \n> > ---\n> > Changes in v3:\n> > - minor reordering\n> > \n> > Changes in v2:\n> > - prevent errors in parsing properties, since the direction field is now\n> >   required yet properties can only be out\n> >   - do this by expanding the Control constructor to take the mode\n> >     argument, so that needs to be passed in by the users of Control\n> > ---\n> >  src/py/libcamera/gen-py-controls.py |  2 +-\n> >  utils/codegen/controls.py           | 24 +++++++++++++++++++++++-\n> >  utils/codegen/gen-controls.py       |  2 +-\n> >  utils/codegen/gen-gst-controls.py   |  2 +-\n> >  4 files changed, 26 insertions(+), 4 deletions(-)\n> > \n> > diff --git a/src/py/libcamera/gen-py-controls.py b/src/py/libcamera/gen-py-controls.py\n> > index cf09c146084d..d43a7c1c7eab 100755\n> > --- a/src/py/libcamera/gen-py-controls.py\n> > +++ b/src/py/libcamera/gen-py-controls.py\n> > @@ -83,7 +83,7 @@ def main(argv):\n> >              vendors.append(vendor)\n> >  \n> >          for ctrl in data['controls']:\n> > -            ctrl = Control(*ctrl.popitem(), vendor)\n> > +            ctrl = Control(*ctrl.popitem(), vendor, args.mode)\n> >              controls.append(extend_control(ctrl, args.mode))\n> >  \n> >      data = {\n> > diff --git a/utils/codegen/controls.py b/utils/codegen/controls.py\n> > index 03c77cc64abe..602f15b25fb6 100644\n> > --- a/utils/codegen/controls.py\n> > +++ b/utils/codegen/controls.py\n> > @@ -28,7 +28,7 @@ class ControlEnum(object):\n> >  \n> >  \n> >  class Control(object):\n> > -    def __init__(self, name, data, vendor):\n> > +    def __init__(self, name, data, vendor, mode):\n> >          self.__name = name\n> >          self.__data = data\n> >          self.__enum_values = None\n> > @@ -60,6 +60,16 @@ class Control(object):\n> >  \n> >              self.__size = num_elems\n> >  \n> > +        if mode == 'properties':\n> > +            self.__direction = 'out'\n> > +        else:\n> > +            direction = self.__data.get('direction')\n> > +            if direction is None:\n> > +                raise RuntimeError(f'Control `{self.__name}` missing required field `{direction}`')\n> > +            if direction not in ['in', 'out', 'inout']:\n> > +                raise RuntimeError(f'Control `{self.__name}` direction `{direction}` is invalid; must be one of `in`, `out`, or `inout`')\n> > +            self.__direction = direction\n> > +\n> >      @property\n> >      def description(self):\n> >          \"\"\"The control description\"\"\"\n> > @@ -111,6 +121,18 @@ class Control(object):\n> >          else:\n> >              return f\"Span<const {typ}>\"\n> >  \n> > +    @property\n> > +    def direction(self):\n> > +        in_flag = 'ControlId::Direction::In'\n> > +        out_flag = 'ControlId::Direction::Out'\n> \n> Does this work ? Are these the flags that are only introduced in the\n> next patch ?\n\nAs the template is only modified in the next patch, this patch alone\nshouldn't cause any difference in the generated code.\n\n> > +\n> > +        if self.__direction == 'inout':\n> > +            return f'{in_flag} | {out_flag}'\n> > +        if self.__direction == 'in':\n> > +            return in_flag\n> > +        if self.__direction == 'out':\n> > +            return out_flag\n> > +\n> >      @property\n> >      def element_type(self):\n> >          return self.__data.get('type')\n> > diff --git a/utils/codegen/gen-controls.py b/utils/codegen/gen-controls.py\n> > index 3034e9a54760..59b716c1c48c 100755\n> > --- a/utils/codegen/gen-controls.py\n> > +++ b/utils/codegen/gen-controls.py\n> > @@ -71,7 +71,7 @@ def main(argv):\n> >          ctrls = controls.setdefault(vendor, [])\n> >  \n> >          for i, ctrl in enumerate(data['controls']):\n> > -            ctrl = Control(*ctrl.popitem(), vendor)\n> > +            ctrl = Control(*ctrl.popitem(), vendor, args.mode)\n> >              ctrls.append(extend_control(ctrl, i, ranges))\n> >  \n> >      # Sort the vendors by range numerical value\n> > diff --git a/utils/codegen/gen-gst-controls.py b/utils/codegen/gen-gst-controls.py\n> > index 2601a67588a3..df0988266294 100755\n> > --- a/utils/codegen/gen-gst-controls.py\n> > +++ b/utils/codegen/gen-gst-controls.py\n> > @@ -154,7 +154,7 @@ def main(argv):\n> >          ctrls = controls.setdefault(vendor, [])\n> >  \n> >          for ctrl in data['controls']:\n> > -            ctrl = Control(*ctrl.popitem(), vendor)\n> > +            ctrl = Control(*ctrl.popitem(), vendor, mode='controls')\n> >  \n> >              if ctrl.name in exposed_controls:\n> >                  ctrls.append(extend_control(ctrl))","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D92A7BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  6 Dec 2024 13:16:27 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8284666151;\n\tFri,  6 Dec 2024 14:16:27 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BC93D618B3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  6 Dec 2024 14:16:25 +0100 (CET)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 39FAA641;\n\tFri,  6 Dec 2024 14:15:56 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Vi72E/i4\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1733490956;\n\tbh=qh5CCTJzLdP6WZze9E2dI9wgOfucPvfOEf41MHglOlo=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Vi72E/i43Gz8y0tFtOzJJKsUlQ3A+w9hq1t0JPng1z8HUVLeg3Vs1CFsDnR0dt8xv\n\tlEJtlue8WIZnMi0eoTlX1MVRDPTW1187DQmwiNjTQfw4ymm9gV9h9/xstRoEOifvGj\n\tV3w9AO9qR9cS05A0zffGYWwKKDQ7cu8B7881eOuQ=","Date":"Fri, 6 Dec 2024 15:16:11 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Paul Elder <paul.elder@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v3 2/4] utils: codegen: controls.py: Parse direction\n\tinformation","Message-ID":"<20241206131611.GH25902@pendragon.ideasonboard.com>","References":"<20241129091916.298359-1-paul.elder@ideasonboard.com>\n\t<20241129091916.298359-3-paul.elder@ideasonboard.com>\n\t<173348925086.3135963.8504536559787815395@ping.linuxembedded.co.uk>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<173348925086.3135963.8504536559787815395@ping.linuxembedded.co.uk>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":32581,"web_url":"https://patchwork.libcamera.org/comment/32581/","msgid":"<173349192292.3135963.7564517634473801446@ping.linuxembedded.co.uk>","date":"2024-12-06T13:32:02","subject":"Re: [PATCH v3 2/4] utils: codegen: controls.py: Parse direction\n\tinformation","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2024-12-06 13:16:11)\n> On Fri, Dec 06, 2024 at 12:47:30PM +0000, Kieran Bingham wrote:\n> > Quoting Paul Elder (2024-11-29 09:19:14)\n> > > In preparation for adding support for querying direction information\n> > > from controls, parse the direction information from control ID\n> > > definitions. This can later be plugged in directly to the IPA code\n> > > generators simply by using ctrl.direction.\n> > > \n> > > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> > > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > > \n> > > ---\n> > > Changes in v3:\n> > > - minor reordering\n> > > \n> > > Changes in v2:\n> > > - prevent errors in parsing properties, since the direction field is now\n> > >   required yet properties can only be out\n> > >   - do this by expanding the Control constructor to take the mode\n> > >     argument, so that needs to be passed in by the users of Control\n> > > ---\n> > >  src/py/libcamera/gen-py-controls.py |  2 +-\n> > >  utils/codegen/controls.py           | 24 +++++++++++++++++++++++-\n> > >  utils/codegen/gen-controls.py       |  2 +-\n> > >  utils/codegen/gen-gst-controls.py   |  2 +-\n> > >  4 files changed, 26 insertions(+), 4 deletions(-)\n> > > \n> > > diff --git a/src/py/libcamera/gen-py-controls.py b/src/py/libcamera/gen-py-controls.py\n> > > index cf09c146084d..d43a7c1c7eab 100755\n> > > --- a/src/py/libcamera/gen-py-controls.py\n> > > +++ b/src/py/libcamera/gen-py-controls.py\n> > > @@ -83,7 +83,7 @@ def main(argv):\n> > >              vendors.append(vendor)\n> > >  \n> > >          for ctrl in data['controls']:\n> > > -            ctrl = Control(*ctrl.popitem(), vendor)\n> > > +            ctrl = Control(*ctrl.popitem(), vendor, args.mode)\n> > >              controls.append(extend_control(ctrl, args.mode))\n> > >  \n> > >      data = {\n> > > diff --git a/utils/codegen/controls.py b/utils/codegen/controls.py\n> > > index 03c77cc64abe..602f15b25fb6 100644\n> > > --- a/utils/codegen/controls.py\n> > > +++ b/utils/codegen/controls.py\n> > > @@ -28,7 +28,7 @@ class ControlEnum(object):\n> > >  \n> > >  \n> > >  class Control(object):\n> > > -    def __init__(self, name, data, vendor):\n> > > +    def __init__(self, name, data, vendor, mode):\n> > >          self.__name = name\n> > >          self.__data = data\n> > >          self.__enum_values = None\n> > > @@ -60,6 +60,16 @@ class Control(object):\n> > >  \n> > >              self.__size = num_elems\n> > >  \n> > > +        if mode == 'properties':\n> > > +            self.__direction = 'out'\n> > > +        else:\n> > > +            direction = self.__data.get('direction')\n> > > +            if direction is None:\n> > > +                raise RuntimeError(f'Control `{self.__name}` missing required field `{direction}`')\n> > > +            if direction not in ['in', 'out', 'inout']:\n> > > +                raise RuntimeError(f'Control `{self.__name}` direction `{direction}` is invalid; must be one of `in`, `out`, or `inout`')\n> > > +            self.__direction = direction\n> > > +\n> > >      @property\n> > >      def description(self):\n> > >          \"\"\"The control description\"\"\"\n> > > @@ -111,6 +121,18 @@ class Control(object):\n> > >          else:\n> > >              return f\"Span<const {typ}>\"\n> > >  \n> > > +    @property\n> > > +    def direction(self):\n> > > +        in_flag = 'ControlId::Direction::In'\n> > > +        out_flag = 'ControlId::Direction::Out'\n> > \n> > Does this work ? Are these the flags that are only introduced in the\n> > next patch ?\n> \n> As the template is only modified in the next patch, this patch alone\n> shouldn't cause any difference in the generated code.\n\nOk, thanks - well the already given tag still stands then.\n--\nKieran\n\n> \n> > > +\n> > > +        if self.__direction == 'inout':\n> > > +            return f'{in_flag} | {out_flag}'\n> > > +        if self.__direction == 'in':\n> > > +            return in_flag\n> > > +        if self.__direction == 'out':\n> > > +            return out_flag\n> > > +\n> > >      @property\n> > >      def element_type(self):\n> > >          return self.__data.get('type')\n> > > diff --git a/utils/codegen/gen-controls.py b/utils/codegen/gen-controls.py\n> > > index 3034e9a54760..59b716c1c48c 100755\n> > > --- a/utils/codegen/gen-controls.py\n> > > +++ b/utils/codegen/gen-controls.py\n> > > @@ -71,7 +71,7 @@ def main(argv):\n> > >          ctrls = controls.setdefault(vendor, [])\n> > >  \n> > >          for i, ctrl in enumerate(data['controls']):\n> > > -            ctrl = Control(*ctrl.popitem(), vendor)\n> > > +            ctrl = Control(*ctrl.popitem(), vendor, args.mode)\n> > >              ctrls.append(extend_control(ctrl, i, ranges))\n> > >  \n> > >      # Sort the vendors by range numerical value\n> > > diff --git a/utils/codegen/gen-gst-controls.py b/utils/codegen/gen-gst-controls.py\n> > > index 2601a67588a3..df0988266294 100755\n> > > --- a/utils/codegen/gen-gst-controls.py\n> > > +++ b/utils/codegen/gen-gst-controls.py\n> > > @@ -154,7 +154,7 @@ def main(argv):\n> > >          ctrls = controls.setdefault(vendor, [])\n> > >  \n> > >          for ctrl in data['controls']:\n> > > -            ctrl = Control(*ctrl.popitem(), vendor)\n> > > +            ctrl = Control(*ctrl.popitem(), vendor, mode='controls')\n> > >  \n> > >              if ctrl.name in exposed_controls:\n> > >                  ctrls.append(extend_control(ctrl))\n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 5B2F0BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  6 Dec 2024 13:32:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 69EB46614D;\n\tFri,  6 Dec 2024 14:32:06 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AACF7618B3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  6 Dec 2024 14:32:05 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 11D8F641;\n\tFri,  6 Dec 2024 14:31:36 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"rXV71KSZ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1733491896;\n\tbh=edtZXzLrOKQgUi03adMA2+oR2aVyublgvXKqYSjjvSs=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=rXV71KSZlpngcP0o79OPdbPFF9mLDk2+Ng9FXwXCmX0aOHop9IwtFeP1BQJgR7e+O\n\t3FCt6jqnj/iiT0lFTZMbmUblBZkHXORFgtdXHpRRNK69+Yu3xeakKeP3vG38LG7QXy\n\toNP9jRCTz3TV+tHDdnev6nRD13kZirknHTd0S0Ug=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20241206131611.GH25902@pendragon.ideasonboard.com>","References":"<20241129091916.298359-1-paul.elder@ideasonboard.com>\n\t<20241129091916.298359-3-paul.elder@ideasonboard.com>\n\t<173348925086.3135963.8504536559787815395@ping.linuxembedded.co.uk>\n\t<20241206131611.GH25902@pendragon.ideasonboard.com>","Subject":"Re: [PATCH v3 2/4] utils: codegen: controls.py: Parse direction\n\tinformation","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Paul Elder <paul.elder@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Date":"Fri, 06 Dec 2024 13:32:02 +0000","Message-ID":"<173349192292.3135963.7564517634473801446@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]