[{"id":258,"web_url":"https://patchwork.libcamera.org/comment/258/","msgid":"<24174681.GGRmZq1tg0@avalon>","date":"2019-01-08T18:07:59","subject":"Re: [libcamera-devel] [PATCH v2 1/4] libcamera: Add pointer to\n\tMediaDevice to MediaObject","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:04 EET Jacopo Mondi wrote:\n> Add a MediaDevice member field to the MediaObject class hierarcy.\n> Each media object now has a reference to the media device it belongs to,\n> and which it has been created by.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n> v1->v2:\n> - Use the entity MediaDevice in MediaPad and MediaLink constructors\n> - Incorporate comments changes from Laurent and Niklas on v1\n> \n>  src/libcamera/include/media_object.h |  7 +++++--\n>  src/libcamera/media_device.cpp       |  4 ++--\n>  src/libcamera/media_object.cpp       | 27 +++++++++++++++++++--------\n>  3 files changed, 26 insertions(+), 12 deletions(-)\n> \n> diff --git a/src/libcamera/include/media_object.h\n> b/src/libcamera/include/media_object.h index 04b9a89..d92aab3 100644\n> --- a/src/libcamera/include/media_object.h\n> +++ b/src/libcamera/include/media_object.h\n> @@ -22,13 +22,16 @@ class MediaObject\n>  {\n>  public:\n>  \tunsigned int id() const { return id_; }\n> +\tMediaDevice *dev() const { return dev_; }\n\nFor the reason explained in v1, I would make this either\n\n\tMediaDevice *dev() { return dev_; }\n\tconst MediaDevice *dev() const { return dev_; }\n\nor just\n\n\tMediaDevice *dev() { return dev_; }\n\nAnd I think you can spell the name of the function fully.\n\n>  protected:\n>  \tfriend class MediaDevice;\n> \n> -\tMediaObject(unsigned int id) : id_(id) { }\n> +\tMediaObject(MediaDevice *dev, unsigned int id) :\n> +\t\tdev_(dev), id_(id) { }\n>  \tvirtual ~MediaObject() { }\n> \n> +\tMediaDevice *dev_;\n>  \tunsigned int id_;\n>  };\n> \n> @@ -93,7 +96,7 @@ public:\n>  private:\n>  \tfriend class MediaDevice;\n> \n> -\tMediaEntity(const struct media_v2_entity *entity,\n> +\tMediaEntity(MediaDevice *media, const struct media_v2_entity *entity,\n\nIf MediaObject is constructed with a MediaDevice *dev, should this be \nMediaDevice *dev too ?\n\n>  \t\t    unsigned int major = 0, unsigned int minor = 0);\n>  \tMediaEntity(const MediaEntity &) = delete;\n>  \t~MediaEntity();\n> diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\n> index cf4ff90..b0d10ed 100644\n> --- a/src/libcamera/media_device.cpp\n> +++ b/src/libcamera/media_device.cpp\n> @@ -430,11 +430,11 @@ bool MediaDevice::populateEntities(const struct\n> media_v2_topology &topology)\n> \n>  \t\tMediaEntity *entity;\n>  \t\tif (iface)\n> -\t\t\tentity = new MediaEntity(&mediaEntities[i],\n> +\t\t\tentity = new MediaEntity(this, &mediaEntities[i],\n>  \t\t\t\t\t\t iface->devnode.major,\n>  \t\t\t\t\t\t iface->devnode.minor);\n>  \t\telse\n> -\t\t\tentity = new MediaEntity(&mediaEntities[i]);\n> +\t\t\tentity = new MediaEntity(this, &mediaEntities[i]);\n> \n>  \t\tif (!addObject(entity)) {\n>  \t\t\tdelete entity;\n> diff --git a/src/libcamera/media_object.cpp b/src/libcamera/media_object.cpp\n> index 06a8d64..612550d 100644\n> --- a/src/libcamera/media_object.cpp\n> +++ b/src/libcamera/media_object.cpp\n> @@ -42,16 +42,20 @@ namespace libcamera {\n>   * \\class MediaObject\n>   * \\brief Base class for all media objects\n>   *\n> - * MediaObject is an abstract base class for all media objects in the media\n> - * graph. Every media graph object is identified by an id unique in the\n> media - * device context, and this base class provides that.\n> + * MediaObject is an abstract base class for all media objects in the\n> + * media graph. Each object is identified by a reference to the media\n> + * device it belongs to and a unique id within that media device.\n> + * This base class provide helpers to media objects to keep track of\n> + * these identifiers.\n>   *\n>   * \\sa MediaEntity, MediaPad, MediaLink\n>   */\n> \n>  /**\n>   * \\fn MediaObject::MediaObject()\n> - * \\brief Construct a MediaObject with \\a id\n> + * \\brief Construct a MediaObject part of the MediaDevice \\a dev,\n> + * identified by the \\a id unique in within the device\n\ns/in within/within/\n\n> + * \\param dev The media device this object belongs to\n>   * \\param id The media object id\n>   *\n>   * The caller shall ensure unicity of the object id in the media device\n> context. @@ -69,6 +73,11 @@ namespace libcamera {\n>   * \\brief The media object id\n>   */\n> \n> +/**\n> + * \\var MediaObject::dev_\n> + * \\brief The media device the media object belongs to\n> + */\n> +\n\nCould you keep this in the same order as in the class definition ?\n\n>  /**\n>   * \\class MediaLink\n>   * \\brief The MediaLink represents a link between two pads in the media\n> graph. @@ -88,7 +97,7 @@ namespace libcamera {\n>   */\n>  MediaLink::MediaLink(const struct media_v2_link *link, MediaPad *source,\n>  \t\t     MediaPad *sink)\n> -\t: MediaObject(link->id), source_(source),\n> +\t: MediaObject(source->dev(), link->id), source_(source),\n>  \t  sink_(sink), flags_(link->flags)\n>  {\n>  }\n> @@ -139,7 +148,7 @@ MediaLink::MediaLink(const struct media_v2_link *link,\n> MediaPad *source, * \\param entity The entity the pad belongs to\n>   */\n>  MediaPad::MediaPad(const struct media_v2_pad *pad, MediaEntity *entity)\n> -\t: MediaObject(pad->id), index_(pad->index), entity_(entity),\n> +\t: MediaObject(entity->dev(), pad->id), index_(pad->index),\n> entity_(entity), flags_(pad->flags)\n>  {\n>  }\n> @@ -283,13 +292,15 @@ int MediaEntity::setDeviceNode(const std::string\n> &devnode)\n> \n>  /**\n>   * \\brief Construct a MediaEntity\n> + * \\param dev The media device this entity belongs to\n>   * \\param entity The media entity kernel data\n>   * \\param major The major number of the entity associated interface\n>   * \\param minor The minor number of the entity associated interface\n>   */\n> -MediaEntity::MediaEntity(const struct media_v2_entity *entity,\n> +MediaEntity::MediaEntity(MediaDevice *dev,\n> +\t\t\t const struct media_v2_entity *entity,\n>  \t\t\t unsigned int major, unsigned int minor)\n> -\t: MediaObject(entity->id), name_(entity->name),\n> +\t: MediaObject(dev, entity->id), name_(entity->name),\n>  \t  major_(major), minor_(minor)\n>  {\n>  }\n\nWith the small issues above fixed,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>","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 7720260B2E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  8 Jan 2019 19:06:52 +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 CACA9586;\n\tTue,  8 Jan 2019 19:06:51 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1546970812;\n\tbh=N44ZdlYlBQsMmLsePab+YYDcuoJypItbRr7igAtAawI=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=A46Cjx+NyNlLJrZtIA12AApSfvJWaLKjwLHj/g+2WkI/bM8sdccrYN8av5m1XX/Np\n\txF20bvNzGfIn5rhMHVt9txDQ14cZo5BlS6F/9a8ylQai5vb1yz+fa+qhrQJEsDlsRH\n\t2lGNYlpVRoeWd70mdGSj8lLGVjuiK0mFjb8yptOI=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 08 Jan 2019 20:07:59 +0200","Message-ID":"<24174681.GGRmZq1tg0@avalon>","Organization":"Ideas on Board Oy","In-Reply-To":"<20190108170407.4770-2-jacopo@jmondi.org>","References":"<20190108170407.4770-1-jacopo@jmondi.org>\n\t<20190108170407.4770-2-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"7Bit","Content-Type":"text/plain; charset=\"us-ascii\"","Subject":"Re: [libcamera-devel] [PATCH v2 1/4] libcamera: Add pointer to\n\tMediaDevice to MediaObject","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:06:52 -0000"}},{"id":262,"web_url":"https://patchwork.libcamera.org/comment/262/","msgid":"<20190108193351.ghnidqanaxy7w7pb@uno.localdomain>","date":"2019-01-08T19:33:51","subject":"Re: [libcamera-devel] [PATCH v2 1/4] libcamera: Add pointer to\n\tMediaDevice to MediaObject","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"On Tue, Jan 08, 2019 at 08:07:59PM +0200, Laurent Pinchart wrote:\n> Hi Jacopo,\n>\n> Thank you for the patch.\n>\n> On Tuesday, 8 January 2019 19:04:04 EET Jacopo Mondi wrote:\n> > Add a MediaDevice member field to the MediaObject class hierarcy.\n> > Each media object now has a reference to the media device it belongs to,\n> > and which it has been created by.\n> >\n> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > ---\n> > v1->v2:\n> > - Use the entity MediaDevice in MediaPad and MediaLink constructors\n> > - Incorporate comments changes from Laurent and Niklas on v1\n> >\n> >  src/libcamera/include/media_object.h |  7 +++++--\n> >  src/libcamera/media_device.cpp       |  4 ++--\n> >  src/libcamera/media_object.cpp       | 27 +++++++++++++++++++--------\n> >  3 files changed, 26 insertions(+), 12 deletions(-)\n> >\n> > diff --git a/src/libcamera/include/media_object.h\n> > b/src/libcamera/include/media_object.h index 04b9a89..d92aab3 100644\n> > --- a/src/libcamera/include/media_object.h\n> > +++ b/src/libcamera/include/media_object.h\n> > @@ -22,13 +22,16 @@ class MediaObject\n> >  {\n> >  public:\n> >  \tunsigned int id() const { return id_; }\n> > +\tMediaDevice *dev() const { return dev_; }\n>\n> For the reason explained in v1, I would make this either\n>\n> \tMediaDevice *dev() { return dev_; }\n> \tconst MediaDevice *dev() const { return dev_; }\n>\n> or just\n>\n> \tMediaDevice *dev() { return dev_; }\n\nOk, I might had missed that... a const function could be called on const\ninstances, and if you get a link, then you probably want to modify it,\nand if you try to do so on a const MediaDevice instance, that will\nfail... Is this what you're trying to protect?\n\n\n>\n> And I think you can spell the name of the function fully.\n>\n\nMediaDevice *device() {...}\n?\n\n> >  protected:\n> >  \tfriend class MediaDevice;\n> >\n> > -\tMediaObject(unsigned int id) : id_(id) { }\n> > +\tMediaObject(MediaDevice *dev, unsigned int id) :\n> > +\t\tdev_(dev), id_(id) { }\n> >  \tvirtual ~MediaObject() { }\n> >\n> > +\tMediaDevice *dev_;\n> >  \tunsigned int id_;\n> >  };\n> >\n> > @@ -93,7 +96,7 @@ public:\n> >  private:\n> >  \tfriend class MediaDevice;\n> >\n> > -\tMediaEntity(const struct media_v2_entity *entity,\n> > +\tMediaEntity(MediaDevice *media, const struct media_v2_entity *entity,\n>\n> If MediaObject is constructed with a MediaDevice *dev, should this be\n> MediaDevice *dev too ?\n>\n\nYes, I missed that\n\n> >  \t\t    unsigned int major = 0, unsigned int minor = 0);\n> >  \tMediaEntity(const MediaEntity &) = delete;\n> >  \t~MediaEntity();\n> > diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\n> > index cf4ff90..b0d10ed 100644\n> > --- a/src/libcamera/media_device.cpp\n> > +++ b/src/libcamera/media_device.cpp\n> > @@ -430,11 +430,11 @@ bool MediaDevice::populateEntities(const struct\n> > media_v2_topology &topology)\n> >\n> >  \t\tMediaEntity *entity;\n> >  \t\tif (iface)\n> > -\t\t\tentity = new MediaEntity(&mediaEntities[i],\n> > +\t\t\tentity = new MediaEntity(this, &mediaEntities[i],\n> >  \t\t\t\t\t\t iface->devnode.major,\n> >  \t\t\t\t\t\t iface->devnode.minor);\n> >  \t\telse\n> > -\t\t\tentity = new MediaEntity(&mediaEntities[i]);\n> > +\t\t\tentity = new MediaEntity(this, &mediaEntities[i]);\n> >\n> >  \t\tif (!addObject(entity)) {\n> >  \t\t\tdelete entity;\n> > diff --git a/src/libcamera/media_object.cpp b/src/libcamera/media_object.cpp\n> > index 06a8d64..612550d 100644\n> > --- a/src/libcamera/media_object.cpp\n> > +++ b/src/libcamera/media_object.cpp\n> > @@ -42,16 +42,20 @@ namespace libcamera {\n> >   * \\class MediaObject\n> >   * \\brief Base class for all media objects\n> >   *\n> > - * MediaObject is an abstract base class for all media objects in the media\n> > - * graph. Every media graph object is identified by an id unique in the\n> > media - * device context, and this base class provides that.\n> > + * MediaObject is an abstract base class for all media objects in the\n> > + * media graph. Each object is identified by a reference to the media\n> > + * device it belongs to and a unique id within that media device.\n> > + * This base class provide helpers to media objects to keep track of\n> > + * these identifiers.\n> >   *\n> >   * \\sa MediaEntity, MediaPad, MediaLink\n> >   */\n> >\n> >  /**\n> >   * \\fn MediaObject::MediaObject()\n> > - * \\brief Construct a MediaObject with \\a id\n> > + * \\brief Construct a MediaObject part of the MediaDevice \\a dev,\n> > + * identified by the \\a id unique in within the device\n>\n> s/in within/within/\n>\n> > + * \\param dev The media device this object belongs to\n> >   * \\param id The media object id\n> >   *\n> >   * The caller shall ensure unicity of the object id in the media device\n> > context. @@ -69,6 +73,11 @@ namespace libcamera {\n> >   * \\brief The media object id\n> >   */\n> >\n> > +/**\n> > + * \\var MediaObject::dev_\n> > + * \\brief The media device the media object belongs to\n> > + */\n> > +\n>\n> Could you keep this in the same order as in the class definition ?\n>\n\nYes, I have not updated this...\n\n> >  /**\n> >   * \\class MediaLink\n> >   * \\brief The MediaLink represents a link between two pads in the media\n> > graph. @@ -88,7 +97,7 @@ namespace libcamera {\n> >   */\n> >  MediaLink::MediaLink(const struct media_v2_link *link, MediaPad *source,\n> >  \t\t     MediaPad *sink)\n> > -\t: MediaObject(link->id), source_(source),\n> > +\t: MediaObject(source->dev(), link->id), source_(source),\n> >  \t  sink_(sink), flags_(link->flags)\n> >  {\n> >  }\n> > @@ -139,7 +148,7 @@ MediaLink::MediaLink(const struct media_v2_link *link,\n> > MediaPad *source, * \\param entity The entity the pad belongs to\n> >   */\n> >  MediaPad::MediaPad(const struct media_v2_pad *pad, MediaEntity *entity)\n> > -\t: MediaObject(pad->id), index_(pad->index), entity_(entity),\n> > +\t: MediaObject(entity->dev(), pad->id), index_(pad->index),\n> > entity_(entity), flags_(pad->flags)\n> >  {\n> >  }\n> > @@ -283,13 +292,15 @@ int MediaEntity::setDeviceNode(const std::string\n> > &devnode)\n> >\n> >  /**\n> >   * \\brief Construct a MediaEntity\n> > + * \\param dev The media device this entity belongs to\n> >   * \\param entity The media entity kernel data\n> >   * \\param major The major number of the entity associated interface\n> >   * \\param minor The minor number of the entity associated interface\n> >   */\n> > -MediaEntity::MediaEntity(const struct media_v2_entity *entity,\n> > +MediaEntity::MediaEntity(MediaDevice *dev,\n> > +\t\t\t const struct media_v2_entity *entity,\n> >  \t\t\t unsigned int major, unsigned int minor)\n> > -\t: MediaObject(entity->id), name_(entity->name),\n> > +\t: MediaObject(dev, entity->id), name_(entity->name),\n> >  \t  major_(major), minor_(minor)\n> >  {\n> >  }\n>\n> With the small issues above fixed,\n>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>\n\nThanks\n  j\n\n> --\n> Regards,\n>\n> Laurent Pinchart\n>\n>\n>","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net\n\t[217.70.183.199])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 09A8260B2E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  8 Jan 2019 20:33:50 +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 relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 839A2FF805;\n\tTue,  8 Jan 2019 19:33:49 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Tue, 8 Jan 2019 20:33:51 +0100","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190108193351.ghnidqanaxy7w7pb@uno.localdomain>","References":"<20190108170407.4770-1-jacopo@jmondi.org>\n\t<20190108170407.4770-2-jacopo@jmondi.org>\n\t<24174681.GGRmZq1tg0@avalon>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"zc5uwbpjf4foh7ns\"","Content-Disposition":"inline","In-Reply-To":"<24174681.GGRmZq1tg0@avalon>","User-Agent":"NeoMutt/20180716","Subject":"Re: [libcamera-devel] [PATCH v2 1/4] libcamera: Add pointer to\n\tMediaDevice to MediaObject","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:33:50 -0000"}},{"id":264,"web_url":"https://patchwork.libcamera.org/comment/264/","msgid":"<5125708.86uh5Gzklg@avalon>","date":"2019-01-08T20:20:33","subject":"Re: [libcamera-devel] [PATCH v2 1/4] libcamera: Add pointer to\n\tMediaDevice to MediaObject","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:33:51 EET Jacopo Mondi wrote:\n> On Tue, Jan 08, 2019 at 08:07:59PM +0200, Laurent Pinchart wrote:\n> > On Tuesday, 8 January 2019 19:04:04 EET Jacopo Mondi wrote:\n> >> Add a MediaDevice member field to the MediaObject class hierarcy.\n> >> Each media object now has a reference to the media device it belongs to,\n> >> and which it has been created by.\n> >> \n> >> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> >> ---\n> >> v1->v2:\n> >> - Use the entity MediaDevice in MediaPad and MediaLink constructors\n> >> - Incorporate comments changes from Laurent and Niklas on v1\n> >> \n> >>  src/libcamera/include/media_object.h |  7 +++++--\n> >>  src/libcamera/media_device.cpp       |  4 ++--\n> >>  src/libcamera/media_object.cpp       | 27 +++++++++++++++++++--------\n> >>  3 files changed, 26 insertions(+), 12 deletions(-)\n> >> \n> >> diff --git a/src/libcamera/include/media_object.h\n> >> b/src/libcamera/include/media_object.h index 04b9a89..d92aab3 100644\n> >> --- a/src/libcamera/include/media_object.h\n> >> +++ b/src/libcamera/include/media_object.h\n> >> @@ -22,13 +22,16 @@ class MediaObject\n> >> \n> >>  {\n> >>  \n> >>  public:\n> >>  \tunsigned int id() const { return id_; }\n> >> \n> >> +\tMediaDevice *dev() const { return dev_; }\n> > \n> > For the reason explained in v1, I would make this either\n> > \n> > \tMediaDevice *dev() { return dev_; }\n> > \tconst MediaDevice *dev() const { return dev_; }\n> > \n> > or just\n> > \n> > \tMediaDevice *dev() { return dev_; }\n> \n> Ok, I might had missed that... a const function could be called on const\n> instances, and if you get a link, then you probably want to modify it,\n> and if you try to do so on a const MediaDevice instance, that will\n> fail... Is this what you're trying to protect?\n\nUsing the proposed API, you can do MediaDevice::link(...) ->setEnabled() and \nthat would modify the state of the MediaDevice, even if the MediaDevice \ninstance was originally const. I don't think that's a good idea.\n\n> > And I think you can spell the name of the function fully.\n> \n> MediaDevice *device() {...}\n> ?\n\nYes.\n\n> >>  protected:\n> >>  \tfriend class MediaDevice;\n> >> \n> >> -\tMediaObject(unsigned int id) : id_(id) { }\n> >> +\tMediaObject(MediaDevice *dev, unsigned int id) :\n> >> +\t\tdev_(dev), id_(id) { }\n> >>  \tvirtual ~MediaObject() { }\n> >> \n> >> +\tMediaDevice *dev_;\n> >>  \tunsigned int id_;\n> >>  };\n> >> \n> >> @@ -93,7 +96,7 @@ public:\n> >>  private:\n> >>  \tfriend class MediaDevice;\n> >> \n> >> -\tMediaEntity(const struct media_v2_entity *entity,\n> >> +\tMediaEntity(MediaDevice *media, const struct media_v2_entity *entity,\n> > \n> > If MediaObject is constructed with a MediaDevice *dev, should this be\n> > MediaDevice *dev too ?\n> \n> Yes, I missed that\n> \n> >>  \t\t    unsigned int major = 0, unsigned int minor = 0);\n> >>  \tMediaEntity(const MediaEntity &) = delete;\n> >>  \t~MediaEntity();\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 3C47C60B2E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  8 Jan 2019 21:19:25 +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 59B07586;\n\tTue,  8 Jan 2019 21:19:24 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1546978764;\n\tbh=C4R2ivD0Twmcl6iHwB51JTnUtLUKMPtsKi7T00xX0sM=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=htE0huejcgDeofNUJ5Evk7/ghuzgO+Zwrp3ucpMVZQ1VpU4Znt/AmEw5xGq9oOd7w\n\tV1ten0/ctRVkJiTZxyVz/6VzsIjviq422Ocp03+NX9qXfOb7DZ4iYf1EWu/4bKXWhm\n\t8U5Do/79bBrGCgQdBeiYturq4/f526qnbL62oBUo=","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:20:33 +0200","Message-ID":"<5125708.86uh5Gzklg@avalon>","Organization":"Ideas on Board Oy","In-Reply-To":"<20190108193351.ghnidqanaxy7w7pb@uno.localdomain>","References":"<20190108170407.4770-1-jacopo@jmondi.org>\n\t<24174681.GGRmZq1tg0@avalon>\n\t<20190108193351.ghnidqanaxy7w7pb@uno.localdomain>","MIME-Version":"1.0","Content-Transfer-Encoding":"7Bit","Content-Type":"text/plain; charset=\"us-ascii\"","Subject":"Re: [libcamera-devel] [PATCH v2 1/4] libcamera: Add pointer to\n\tMediaDevice to MediaObject","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:19:25 -0000"}}]