[{"id":260,"web_url":"https://patchwork.libcamera.org/comment/260/","msgid":"<2057673.D26n9uUBnN@avalon>","date":"2019-01-08T18:18:45","subject":"Re: [libcamera-devel] [PATCH v2 3/4] libcamera: Add link handling\n\tfunctions","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Tuesday, 8 January 2019 19:04:06 EET Jacopo Mondi wrote:\n> Add a function to the MediaLink class to set the state of a link to\n> enabled or disabled. The function makes use of an internal MediaDevice\n> method, which is defined private and only accessible by the MediaLink\n> setEnable() function itself.\n> \n> Also add to MediaDevice a function to reset all links registered in the\n> media graph.\n\nI would have split this to a separate patch, but it's not a big deal.\n\n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n> v1->v2:\n> - Add resetLinks() function\n> - s/enable()/setEnable()\n> - s/setLink()/setupLink()\n> - Pass MediaLink and not two MediaPads to MediaDevice::setupLink\n> \n>  src/libcamera/include/media_device.h |  4 ++\n>  src/libcamera/include/media_object.h |  1 +\n>  src/libcamera/media_device.cpp       | 75 ++++++++++++++++++++++++++++\n>  src/libcamera/media_object.cpp       | 29 +++++++++++\n>  4 files changed, 109 insertions(+)\n> \n> diff --git a/src/libcamera/include/media_device.h\n> b/src/libcamera/include/media_device.h index 397d349..0f423aa 100644\n> --- a/src/libcamera/include/media_device.h\n> +++ b/src/libcamera/include/media_device.h\n> @@ -45,6 +45,7 @@ public:\n>  \tMediaLink *link(const MediaEntity *source, unsigned int sourceIdx,\n>  \t\t\tconst MediaEntity *sink, unsigned int sinkIdx);\n>  \tMediaLink *link(const MediaPad *source, const MediaPad *sink);\n> +\tint resetLinks();\n\nI wonder if this should be called disableLinks() or disableAllLinks() to \nbetter reflect the purpose.\n\n> \n>  private:\n>  \tstd::string driver_;\n> @@ -65,6 +66,9 @@ private:\n>  \tbool populateEntities(const struct media_v2_topology &topology);\n>  \tbool populatePads(const struct media_v2_topology &topology);\n>  \tbool populateLinks(const struct media_v2_topology &topology);\n> +\n> +\tfriend int MediaLink::setEnable(bool enable);\n> +\tint setupLink(const MediaLink *link, unsigned int flags);\n>  };\n> \n>  } /* namespace libcamera */\n> diff --git a/src/libcamera/include/media_object.h\n> b/src/libcamera/include/media_object.h index d92aab3..bb46fac 100644\n> --- a/src/libcamera/include/media_object.h\n> +++ b/src/libcamera/include/media_object.h\n> @@ -41,6 +41,7 @@ public:\n>  \tMediaPad *source() const { return source_; }\n>  \tMediaPad *sink() const { return sink_; }\n>  \tunsigned int flags() const { return flags_; }\n> +\tint setEnable(bool enable);\n\ns/setEnable/setEnabled/ ?\n\n> \n>  private:\n>  \tfriend class MediaDevice;\n> diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\n> index 7ce5c22..9900c3f 100644\n> --- a/src/libcamera/media_device.cpp\n> +++ b/src/libcamera/media_device.cpp\n> @@ -385,6 +385,35 @@ MediaLink *MediaDevice::link(const MediaPad *source,\n> const MediaPad *sink) return nullptr;\n>  }\n> \n> +/**\n> + * \\brief Reset all links in the media device\n\nHow about \"Disable all links in the media device\" ?\n\n> + *\n> + * Reset the media device links, clearing the MEDIA_LNK_FL_ENABLED flag\n> + * on links which are not flagged as IMMUTABLE.\n\nAnd updating this accordingly. The \"reset\" concept isn't clearly defined in \nthe MC API, and why media-ctl implements it, I think stating the purpose more \nexplicitly would be clearer.\n\n> + * \\return 0 for success, or a negative error code otherwise\n\ns/for/on/\n\n> + */\n> +int MediaDevice::resetLinks()\n> +{\n> +\tfor (MediaEntity *entity : entities_) {\n> +\t\tfor (MediaPad *pad : entity->pads()) {\n> +\t\t\tif (pad->flags() & MEDIA_PAD_FL_SINK)\n\nI'd rather write this !(pad->flags() & MEDIA_PAD_FL_SOURCE) in case we later \nget pads that have neither flag set.\n\n> +\t\t\t\tcontinue;\n> +\n> +\t\t\tfor (MediaLink *link : pad->links()) {\n> +\t\t\t\tif (link->flags() & MEDIA_LNK_FL_IMMUTABLE)\n> +\t\t\t\t\tcontinue;\n> +\n> +\t\t\t\tint ret = link->setEnable(false);\n> +\t\t\t\tif (ret)\n> +\t\t\t\t\treturn ret;\n> +\t\t\t}\n> +\t\t}\n> +\t}\n\nWe don't need to do so in this patch, but do you think we should keep a list \nof links internally in MediaDevice for the purpose of iterating over them \neasily here ?\n\n> +\treturn 0;\n> +}\n> +\n>  /**\n>   * \\var MediaDevice::objects_\n>   * \\brief Global map of media objects (entities, pads, links) keyed by\n> their @@ -601,4 +630,50 @@ bool MediaDevice::populateLinks(const struct\n> media_v2_topology &topology) return true;\n>  }\n> \n> +/**\n> + * \\brief Apply \\a flags to a link between two pads\n> + * \\param link The link to apply flags on\n\ns/on/to/\n\n> + * \\param flags The flags to apply to the link\n> + *\n> + * This function applies the link \\a flags (as defined by the\n> MEDIA_LNK_FL_* + * macros from the Media Controller API) to the given \\a\n> link. It implements + * low-level link setup as it performs no checks on\n> the validity of the \\a + * flags, and assumes that the supplied \\a flags\n> are valid for the link (e.g. + * immutable links cannot be disabled).\"\n\ns/\"//\n\n> +*\n> + * \\sa MediaLink::setEnable(bool enable)\n> + *\n> + * \\return 0 for success, or a negative error code otherwise\n\ns/for/on/\n\n> + */\n> +int MediaDevice::setupLink(const MediaLink *link, unsigned int flags)\n> +{\n> +\tstruct media_link_desc linkDesc = { };\n> +\tMediaPad *source = link->source();\n> +\tMediaPad *sink = link->sink();\n> +\n> +\tlinkDesc.source.entity = source->entity()->id();\n> +\tlinkDesc.source.index = source->index();\n> +\tlinkDesc.source.flags = MEDIA_PAD_FL_SOURCE;\n> +\n> +\tlinkDesc.sink.entity = sink->entity()->id();\n> +\tlinkDesc.sink.index = sink->index();\n> +\tlinkDesc.sink.flags = MEDIA_PAD_FL_SINK;\n> +\n> +\tlinkDesc.flags = flags;\n> +\n> +\tint ret = ioctl(fd_, MEDIA_IOC_SETUP_LINK, &linkDesc);\n> +\tif (ret) {\n> +\t\tret = -errno;\n> +\t\tLOG(Error) << \"Failed to setup link: \" << strerror(-ret);\n> +\t\treturn ret;\n> +\t}\n> +\n> +\tLOG(Debug) << source->entity()->name() << \"[\"\n> +\t\t   << source->index() << \"] -> \"\n> +\t\t   << sink->entity()->name() << \"[\"\n> +\t\t   << sink->index() << \"]: \" << flags;\n> +\n> +\treturn 0;\n> +}\n> +\n>  } /* namespace libcamera */\n> diff --git a/src/libcamera/media_object.cpp b/src/libcamera/media_object.cpp\n> index 612550d..c6cb02b 100644\n> --- a/src/libcamera/media_object.cpp\n> +++ b/src/libcamera/media_object.cpp\n> @@ -15,6 +15,7 @@\n>  #include <linux/media.h>\n> \n>  #include \"log.h\"\n> +#include \"media_device.h\"\n>  #include \"media_object.h\"\n> \n>  /**\n> @@ -89,6 +90,34 @@ namespace libcamera {\n>   * Each link is referenced in the link array of both of the pads it\n> connect. */\n> \n> +/**\n> + * \\brief Enable or disable a lik\n\ns/lik/link/\n\n> + * \\param enable True to enable the link, false to disable it\n> + *\n> + * Set the status of a link, according to the value of \\a enable.\n\ns/link,/link/\n\n> + * Links between two pads can be set to the enabled or disabled state\n> freely, + * unless they're immutable links, whose status cannot be changed.\n> + * Enabling an immutable link is not considered an error, while trying to\n> + * disable it is.\n> + *\n> + * Enabling a link establishes a data connection between two pads, while\n> + * disabling it interrupts such a connections.\n\ns/connections/connection/\n\nor possibly better\n\ns/such a connections/that connection/\n\n> + *\n> + * \\return 0 on success, or a negative error code otherwise\n> + */\n> +int MediaLink::setEnable(bool enable)\n> +{\n> +\tunsigned int flags = enable ? MEDIA_LNK_FL_ENABLED : 0;\n> +\n> +\tint ret = dev_->setupLink(this, flags);\n> +\tif (ret)\n> +\t\treturn ret;\n> +\n> +\tflags_ = flags;\n> +\n> +\treturn 0;\n> +}\n> +\n>  /**\n>   * \\brief Construct a MediaLink\n>   * \\param link The media link kernel data","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F0C1560B2E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  8 Jan 2019 19:17:37 +0100 (CET)","from avalon.localnet (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 567C9586;\n\tTue,  8 Jan 2019 19:17:37 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1546971457;\n\tbh=cEnar9vElIM2zqwgGKZf5CDU43KXqXPvX7fVNOaI5Us=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=VCvMwy6kRxdQ6LCGu6men2r6WgfgJvdkebRsa5WsS6NgjymTiO4DMZ4pG08dCSp/3\n\tv7Ziv3DlKICZ9AbmWEDmesisRB95FOIsChEp8bv1wE7ZBtVAZNncnTWB3Rh3833u86\n\tkV7/qVBdyS8JNDvX5aJnJZjfO8AexlzdZJucb0sk=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 08 Jan 2019 20:18:45 +0200","Message-ID":"<2057673.D26n9uUBnN@avalon>","Organization":"Ideas on Board Oy","In-Reply-To":"<20190108170407.4770-4-jacopo@jmondi.org>","References":"<20190108170407.4770-1-jacopo@jmondi.org>\n\t<20190108170407.4770-4-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"7Bit","Content-Type":"text/plain; charset=\"us-ascii\"","Subject":"Re: [libcamera-devel] [PATCH v2 3/4] libcamera: Add link handling\n\tfunctions","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Tue, 08 Jan 2019 18:17:38 -0000"}},{"id":263,"web_url":"https://patchwork.libcamera.org/comment/263/","msgid":"<20190108195242.n27hhtbspjlg65wq@uno.localdomain>","date":"2019-01-08T19:52:42","subject":"Re: [libcamera-devel] [PATCH v2 3/4] libcamera: Add link handling\n\tfunctions","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent,\n\nOn Tue, Jan 08, 2019 at 08:18:45PM +0200, Laurent Pinchart wrote:\n> Hi Jacopo,\n>\n> Thank you for the patch.\n>\n> On Tuesday, 8 January 2019 19:04:06 EET Jacopo Mondi wrote:\n> > Add a function to the MediaLink class to set the state of a link to\n> > enabled or disabled. The function makes use of an internal MediaDevice\n> > method, which is defined private and only accessible by the MediaLink\n> > setEnable() function itself.\n> >\n> > Also add to MediaDevice a function to reset all links registered in the\n> > media graph.\n>\n> I would have split this to a separate patch, but it's not a big deal.\n>\n> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > ---\n> > v1->v2:\n> > - Add resetLinks() function\n> > - s/enable()/setEnable()\n> > - s/setLink()/setupLink()\n> > - Pass MediaLink and not two MediaPads to MediaDevice::setupLink\n> >\n> >  src/libcamera/include/media_device.h |  4 ++\n> >  src/libcamera/include/media_object.h |  1 +\n> >  src/libcamera/media_device.cpp       | 75 ++++++++++++++++++++++++++++\n> >  src/libcamera/media_object.cpp       | 29 +++++++++++\n> >  4 files changed, 109 insertions(+)\n> >\n> > diff --git a/src/libcamera/include/media_device.h\n> > b/src/libcamera/include/media_device.h index 397d349..0f423aa 100644\n> > --- a/src/libcamera/include/media_device.h\n> > +++ b/src/libcamera/include/media_device.h\n> > @@ -45,6 +45,7 @@ public:\n> >  \tMediaLink *link(const MediaEntity *source, unsigned int sourceIdx,\n> >  \t\t\tconst MediaEntity *sink, unsigned int sinkIdx);\n> >  \tMediaLink *link(const MediaPad *source, const MediaPad *sink);\n> > +\tint resetLinks();\n>\n> I wonder if this should be called disableLinks() or disableAllLinks() to\n> better reflect the purpose.\n>\n\nI find reset confusing as well, although it is used already, but I\nfind the enable/disable terms better... I'll go with disableLinks()\n> >\n> >  private:\n> >  \tstd::string driver_;\n> > @@ -65,6 +66,9 @@ private:\n> >  \tbool populateEntities(const struct media_v2_topology &topology);\n> >  \tbool populatePads(const struct media_v2_topology &topology);\n> >  \tbool populateLinks(const struct media_v2_topology &topology);\n> > +\n> > +\tfriend int MediaLink::setEnable(bool enable);\n> > +\tint setupLink(const MediaLink *link, unsigned int flags);\n> >  };\n> >\n> >  } /* namespace libcamera */\n> > diff --git a/src/libcamera/include/media_object.h\n> > b/src/libcamera/include/media_object.h index d92aab3..bb46fac 100644\n> > --- a/src/libcamera/include/media_object.h\n> > +++ b/src/libcamera/include/media_object.h\n> > @@ -41,6 +41,7 @@ public:\n> >  \tMediaPad *source() const { return source_; }\n> >  \tMediaPad *sink() const { return sink_; }\n> >  \tunsigned int flags() const { return flags_; }\n> > +\tint setEnable(bool enable);\n>\n> s/setEnable/setEnabled/ ?\n>\n\nIt's maybe stupid but, since we have disableLinks() should we have an\nenable() and a disable() function?\n\n> >\n> >  private:\n> >  \tfriend class MediaDevice;\n> > diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\n> > index 7ce5c22..9900c3f 100644\n> > --- a/src/libcamera/media_device.cpp\n> > +++ b/src/libcamera/media_device.cpp\n> > @@ -385,6 +385,35 @@ MediaLink *MediaDevice::link(const MediaPad *source,\n> > const MediaPad *sink) return nullptr;\n> >  }\n> >\n> > +/**\n> > + * \\brief Reset all links in the media device\n>\n> How about \"Disable all links in the media device\" ?\n>\n> > + *\n> > + * Reset the media device links, clearing the MEDIA_LNK_FL_ENABLED flag\n> > + * on links which are not flagged as IMMUTABLE.\n>\n> And updating this accordingly. The \"reset\" concept isn't clearly defined in\n> the MC API, and why media-ctl implements it, I think stating the purpose more\n> explicitly would be clearer.\n>\n\nAgree\n\n> > + * \\return 0 for success, or a negative error code otherwise\n>\n> s/for/on/\n>\n> > + */\n> > +int MediaDevice::resetLinks()\n> > +{\n> > +\tfor (MediaEntity *entity : entities_) {\n> > +\t\tfor (MediaPad *pad : entity->pads()) {\n> > +\t\t\tif (pad->flags() & MEDIA_PAD_FL_SINK)\n>\n> I'd rather write this !(pad->flags() & MEDIA_PAD_FL_SOURCE) in case we later\n> get pads that have neither flag set.\n>\n\nack\n\n> > +\t\t\t\tcontinue;\n> > +\n> > +\t\t\tfor (MediaLink *link : pad->links()) {\n> > +\t\t\t\tif (link->flags() & MEDIA_LNK_FL_IMMUTABLE)\n> > +\t\t\t\t\tcontinue;\n> > +\n> > +\t\t\t\tint ret = link->setEnable(false);\n> > +\t\t\t\tif (ret)\n> > +\t\t\t\t\treturn ret;\n> > +\t\t\t}\n> > +\t\t}\n> > +\t}\n>\n> We don't need to do so in this patch, but do you think we should keep a list\n> of links internally in MediaDevice for the purpose of iterating over them\n> easily here ?\n>\n\nI thought about it... If it is just for this maybe no.. it's not a big\ndeal though, it's just a list of references...\n\n> > +\treturn 0;\n> > +}\n> > +\n> >  /**\n> >   * \\var MediaDevice::objects_\n> >   * \\brief Global map of media objects (entities, pads, links) keyed by\n> > their @@ -601,4 +630,50 @@ bool MediaDevice::populateLinks(const struct\n> > media_v2_topology &topology) return true;\n> >  }\n> >\n> > +/**\n> > + * \\brief Apply \\a flags to a link between two pads\n> > + * \\param link The link to apply flags on\n>\n> s/on/to/\n>\n> > + * \\param flags The flags to apply to the link\n> > + *\n> > + * This function applies the link \\a flags (as defined by the\n> > MEDIA_LNK_FL_* + * macros from the Media Controller API) to the given \\a\n> > link. It implements + * low-level link setup as it performs no checks on\n> > the validity of the \\a + * flags, and assumes that the supplied \\a flags\n> > are valid for the link (e.g. + * immutable links cannot be disabled).\"\n>\n> s/\"//\n>\n> > +*\n> > + * \\sa MediaLink::setEnable(bool enable)\n> > + *\n> > + * \\return 0 for success, or a negative error code otherwise\n>\n> s/for/on/\n>\n> > + */\n> > +int MediaDevice::setupLink(const MediaLink *link, unsigned int flags)\n> > +{\n> > +\tstruct media_link_desc linkDesc = { };\n> > +\tMediaPad *source = link->source();\n> > +\tMediaPad *sink = link->sink();\n> > +\n> > +\tlinkDesc.source.entity = source->entity()->id();\n> > +\tlinkDesc.source.index = source->index();\n> > +\tlinkDesc.source.flags = MEDIA_PAD_FL_SOURCE;\n> > +\n> > +\tlinkDesc.sink.entity = sink->entity()->id();\n> > +\tlinkDesc.sink.index = sink->index();\n> > +\tlinkDesc.sink.flags = MEDIA_PAD_FL_SINK;\n> > +\n> > +\tlinkDesc.flags = flags;\n> > +\n> > +\tint ret = ioctl(fd_, MEDIA_IOC_SETUP_LINK, &linkDesc);\n> > +\tif (ret) {\n> > +\t\tret = -errno;\n> > +\t\tLOG(Error) << \"Failed to setup link: \" << strerror(-ret);\n> > +\t\treturn ret;\n> > +\t}\n> > +\n> > +\tLOG(Debug) << source->entity()->name() << \"[\"\n> > +\t\t   << source->index() << \"] -> \"\n> > +\t\t   << sink->entity()->name() << \"[\"\n> > +\t\t   << sink->index() << \"]: \" << flags;\n> > +\n> > +\treturn 0;\n> > +}\n> > +\n> >  } /* namespace libcamera */\n> > diff --git a/src/libcamera/media_object.cpp b/src/libcamera/media_object.cpp\n> > index 612550d..c6cb02b 100644\n> > --- a/src/libcamera/media_object.cpp\n> > +++ b/src/libcamera/media_object.cpp\n> > @@ -15,6 +15,7 @@\n> >  #include <linux/media.h>\n> >\n> >  #include \"log.h\"\n> > +#include \"media_device.h\"\n> >  #include \"media_object.h\"\n> >\n> >  /**\n> > @@ -89,6 +90,34 @@ namespace libcamera {\n> >   * Each link is referenced in the link array of both of the pads it\n> > connect. */\n> >\n> > +/**\n> > + * \\brief Enable or disable a lik\n>\n> s/lik/link/\n>\n> > + * \\param enable True to enable the link, false to disable it\n> > + *\n> > + * Set the status of a link, according to the value of \\a enable.\n>\n> s/link,/link/\n>\n> > + * Links between two pads can be set to the enabled or disabled state\n> > freely, + * unless they're immutable links, whose status cannot be changed.\n> > + * Enabling an immutable link is not considered an error, while trying to\n> > + * disable it is.\n> > + *\n> > + * Enabling a link establishes a data connection between two pads, while\n> > + * disabling it interrupts such a connections.\n>\n> s/connections/connection/\n>\n> or possibly better\n>\n> s/such a connections/that connection/\n>\n\nYes, better\n\n> > + *\n> > + * \\return 0 on success, or a negative error code otherwise\n> > + */\n> > +int MediaLink::setEnable(bool enable)\n> > +{\n> > +\tunsigned int flags = enable ? MEDIA_LNK_FL_ENABLED : 0;\n> > +\n> > +\tint ret = dev_->setupLink(this, flags);\n> > +\tif (ret)\n> > +\t\treturn ret;\n> > +\n> > +\tflags_ = flags;\n> > +\n> > +\treturn 0;\n> > +}\n> > +\n> >  /**\n> >   * \\brief Construct a MediaLink\n> >   * \\param link The media link kernel data\n\nThanks\n  j\n\n>\n> --\n> Regards,\n>\n> Laurent Pinchart\n>\n>\n>","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net\n\t[217.70.183.200])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EB73260B2E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  8 Jan 2019 20:52:35 +0100 (CET)","from uno.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 7340220006;\n\tTue,  8 Jan 2019 19:52:35 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Tue, 8 Jan 2019 20:52:42 +0100","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190108195242.n27hhtbspjlg65wq@uno.localdomain>","References":"<20190108170407.4770-1-jacopo@jmondi.org>\n\t<20190108170407.4770-4-jacopo@jmondi.org>\n\t<2057673.D26n9uUBnN@avalon>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"wo6gy24m3xmewxgg\"","Content-Disposition":"inline","In-Reply-To":"<2057673.D26n9uUBnN@avalon>","User-Agent":"NeoMutt/20180716","Subject":"Re: [libcamera-devel] [PATCH v2 3/4] libcamera: Add link handling\n\tfunctions","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Tue, 08 Jan 2019 19:52:36 -0000"}},{"id":265,"web_url":"https://patchwork.libcamera.org/comment/265/","msgid":"<25786247.GziirNbZzo@avalon>","date":"2019-01-08T20:26:00","subject":"Re: [libcamera-devel] [PATCH v2 3/4] libcamera: Add link handling\n\tfunctions","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn Tuesday, 8 January 2019 21:52:42 EET Jacopo Mondi wrote:\n> On Tue, Jan 08, 2019 at 08:18:45PM +0200, Laurent Pinchart wrote:\n> > On Tuesday, 8 January 2019 19:04:06 EET Jacopo Mondi wrote:\n> >> Add a function to the MediaLink class to set the state of a link to\n> >> enabled or disabled. The function makes use of an internal MediaDevice\n> >> method, which is defined private and only accessible by the MediaLink\n> >> setEnable() function itself.\n> >> \n> >> Also add to MediaDevice a function to reset all links registered in the\n> >> media graph.\n> > \n> > I would have split this to a separate patch, but it's not a big deal.\n> > \n> >> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> >> ---\n> >> v1->v2:\n> >> - Add resetLinks() function\n> >> - s/enable()/setEnable()\n> >> - s/setLink()/setupLink()\n> >> - Pass MediaLink and not two MediaPads to MediaDevice::setupLink\n> >> \n> >>  src/libcamera/include/media_device.h |  4 ++\n> >>  src/libcamera/include/media_object.h |  1 +\n> >>  src/libcamera/media_device.cpp       | 75 ++++++++++++++++++++++++++++\n> >>  src/libcamera/media_object.cpp       | 29 +++++++++++\n> >>  4 files changed, 109 insertions(+)\n> >> \n> >> diff --git a/src/libcamera/include/media_device.h\n> >> b/src/libcamera/include/media_device.h index 397d349..0f423aa 100644\n> >> --- a/src/libcamera/include/media_device.h\n> >> +++ b/src/libcamera/include/media_device.h\n> >> @@ -45,6 +45,7 @@ public:\n> >>  \tMediaLink *link(const MediaEntity *source, unsigned int sourceIdx,\n> >>  \t\t\tconst MediaEntity *sink, unsigned int sinkIdx);\n> >>  \tMediaLink *link(const MediaPad *source, const MediaPad *sink);\n> >> \n> > > +\tint resetLinks();\n> > \n> > I wonder if this should be called disableLinks() or disableAllLinks() to\n> > better reflect the purpose.\n> \n> I find reset confusing as well, although it is used already, but I\n> find the enable/disable terms better... I'll go with disableLinks()\n> \n> >>  private:\n> >>  \tstd::string driver_;\n> >> \n> >> @@ -65,6 +66,9 @@ private:\n> >>  \tbool populateEntities(const struct media_v2_topology &topology);\n> >>  \tbool populatePads(const struct media_v2_topology &topology);\n> >>  \tbool populateLinks(const struct media_v2_topology &topology);\n> >> +\n> >> +\tfriend int MediaLink::setEnable(bool enable);\n> >> +\tint setupLink(const MediaLink *link, unsigned int flags);\n> >>  };\n> >>  \n> >>  } /* namespace libcamera */\n> >> diff --git a/src/libcamera/include/media_object.h\n> >> b/src/libcamera/include/media_object.h index d92aab3..bb46fac 100644\n> >> --- a/src/libcamera/include/media_object.h\n> >> +++ b/src/libcamera/include/media_object.h\n> >> @@ -41,6 +41,7 @@ public:\n> >>  \tMediaPad *source() const { return source_; }\n> >>  \tMediaPad *sink() const { return sink_; }\n> >>  \tunsigned int flags() const { return flags_; }\n> >> +\tint setEnable(bool enable);\n> > \n> > s/setEnable/setEnabled/ ?\n> \n> It's maybe stupid but, since we have disableLinks() should we have an\n> enable() and a disable() function?\n\nIt's a good question. As the property is \"enabled\", having enabled() and \nsetEnabled() accessors is simple and logical. enable() and disable() would be \nas well, but it would be a special case. I'm tempted to stick to setEnabled() \nto follow the generic rule.\n\n> >>  private:\n> >>  \tfriend class MediaDevice;\n> >> \n\n[snip]","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["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 A9CFA60B2E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  8 Jan 2019 21:24:51 +0100 (CET)","from avalon.localnet (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 25CBC586;\n\tTue,  8 Jan 2019 21:24:51 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1546979091;\n\tbh=e7wusNxueL2PXupv3Df+O0KvaZOV82mHOL7L4+Sb1Z4=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=h1I+kekI4EK4DKxCxyjyqt3Uf1PhEeqNpJPcyVav1X8xXK9zWUoANLB3sUNVmbDT9\n\tP3tpYjuv1mSF4kX+fEW/2cT5L7jWs7qq1qTRngSLzIAqXZbV5cMUqRpzhVMSTegieb\n\tVEeotevBQChL6XzdeYVBuYWWh9sM9X0hP7igoh6o=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Date":"Tue, 08 Jan 2019 22:26:00 +0200","Message-ID":"<25786247.GziirNbZzo@avalon>","Organization":"Ideas on Board Oy","In-Reply-To":"<20190108195242.n27hhtbspjlg65wq@uno.localdomain>","References":"<20190108170407.4770-1-jacopo@jmondi.org>\n\t<2057673.D26n9uUBnN@avalon>\n\t<20190108195242.n27hhtbspjlg65wq@uno.localdomain>","MIME-Version":"1.0","Content-Transfer-Encoding":"7Bit","Content-Type":"text/plain; charset=\"us-ascii\"","Subject":"Re: [libcamera-devel] [PATCH v2 3/4] libcamera: Add link handling\n\tfunctions","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Tue, 08 Jan 2019 20:24:51 -0000"}}]