[{"id":1435,"web_url":"https://patchwork.libcamera.org/comment/1435/","msgid":"<20190417115744.zwtsccdvs4vxup5h@uno.localdomain>","date":"2019-04-17T11:57:44","subject":"Re: [libcamera-devel] [PATCH v2 10/13] libcamera: v4l2-subdevice:\n\tAdd method to retrieve the media entity","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent,\n\nOn Wed, Apr 17, 2019 at 01:08:36AM +0300, Laurent Pinchart wrote:\n> Add a method to retrieve the media entity associated with a subdevice.\n> The entityName() and deviceNode() methods are not needed anymore as they\n> can be accessed through the media entity, remove them.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\nAs the purpose of the patch has been clarified in a previous answer\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\n> ---\n>  src/libcamera/include/v4l2_subdevice.h      |  3 +--\n>  src/libcamera/pipeline/ipu3/ipu3.cpp        |  4 ++--\n>  src/libcamera/v4l2_subdevice.cpp            | 22 +++++++--------------\n>  test/v4l2_subdevice/list_formats.cpp        |  6 +++---\n>  test/v4l2_subdevice/v4l2_subdevice_test.cpp |  2 +-\n>  5 files changed, 14 insertions(+), 23 deletions(-)\n>\n> diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h\n> index e592d67dd043..c7b0b4cb76ea 100644\n> --- a/src/libcamera/include/v4l2_subdevice.h\n> +++ b/src/libcamera/include/v4l2_subdevice.h\n> @@ -41,8 +41,7 @@ public:\n>  \tbool isOpen() const;\n>  \tvoid close();\n>\n> -\tconst std::string &deviceNode() const { return entity_->deviceNode(); }\n> -\tconst std::string &entityName() const { return entity_->name(); }\n> +\tconst MediaEntity *entity() const { return entity_; }\n>\n>  \tint setCrop(unsigned int pad, Rectangle *rect);\n>  \tint setCompose(unsigned int pad, Rectangle *rect);\n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index 4ddd1ede1c81..e3c79f93963e 100644\n> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> @@ -579,7 +579,7 @@ int PipelineHandlerIPU3::registerCameras()\n>  \t\t\t\t\t&IPU3CameraData::imguOutputBufferReady);\n>\n>  \t\t/* Create and register the Camera instance. */\n> -\t\tstd::string cameraName = cio2->sensor_->entityName() + \" \"\n> +\t\tstd::string cameraName = cio2->sensor_->entity()->name() + \" \"\n>  \t\t\t\t       + std::to_string(id);\n>  \t\tstd::shared_ptr<Camera> camera = Camera::create(this,\n>  \t\t\t\t\t\t\t\tcameraName,\n> @@ -1055,7 +1055,7 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)\n>  \t\t}\n>  \t}\n>  \tif (maxSize_.width == 0) {\n> -\t\tLOG(IPU3, Info) << \"Sensor '\" << sensor_->entityName()\n> +\t\tLOG(IPU3, Info) << \"Sensor '\" << sensor_->entity()->name()\n>  \t\t\t\t<< \"' detected, but no supported image format \"\n>  \t\t\t\t<< \" found: skip camera creation\";\n>  \t\treturn -ENODEV;\n> diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\n> index a03fadfd579e..5d5b168f98a2 100644\n> --- a/src/libcamera/v4l2_subdevice.cpp\n> +++ b/src/libcamera/v4l2_subdevice.cpp\n> @@ -131,12 +131,12 @@ int V4L2Subdevice::open()\n>  \t\treturn -EBUSY;\n>  \t}\n>\n> -\tret = ::open(deviceNode().c_str(), O_RDWR);\n> +\tret = ::open(entity_->deviceNode().c_str(), O_RDWR);\n>  \tif (ret < 0) {\n>  \t\tret = -errno;\n>  \t\tLOG(V4L2Subdev, Error)\n> -\t\t\t<< \"Failed to open V4L2 subdevice '\" << deviceNode()\n> -\t\t\t<< \"': \" << strerror(-ret);\n> +\t\t\t<< \"Failed to open V4L2 subdevice '\"\n> +\t\t\t<< entity_->deviceNode() << \"': \" << strerror(-ret);\n>  \t\treturn ret;\n>  \t}\n>  \tfd_ = ret;\n> @@ -166,17 +166,9 @@ void V4L2Subdevice::close()\n>  }\n>\n>  /**\n> - * \\fn V4L2Subdevice::deviceNode()\n> - * \\brief Retrieve the path of the device node associated with the subdevice\n> - *\n> - * \\return The subdevice's device node system path\n> - */\n> -\n> -/**\n> - * \\fn V4L2Subdevice::entityName()\n> - * \\brief Retrieve the name of the media entity associated with the subdevice\n> - *\n> - * \\return The name of the media entity the subdevice is associated to\n> + * \\fn V4L2Subdevice::entity()\n> + * \\brief Retrieve the media entity associated with the subdevice\n> + * \\return The subdevice's associated media entity.\n>   */\n>\n>  /**\n> @@ -343,7 +335,7 @@ V4L2Subdevice *V4L2Subdevice::fromEntityName(const MediaDevice *media,\n>\n>  std::string V4L2Subdevice::logPrefix() const\n>  {\n> -\treturn \"'\" + entityName() + \"'\";\n> +\treturn \"'\" + entity_->name() + \"'\";\n>  }\n>\n>  int V4L2Subdevice::enumPadSizes(unsigned int pad,unsigned int code,\n> diff --git a/test/v4l2_subdevice/list_formats.cpp b/test/v4l2_subdevice/list_formats.cpp\n> index 09dec9abe854..18dd8761a8ab 100644\n> --- a/test/v4l2_subdevice/list_formats.cpp\n> +++ b/test/v4l2_subdevice/list_formats.cpp\n> @@ -52,7 +52,7 @@ int ListFormatsTest::run()\n>  \tformats = scaler_->formats(0);\n>  \tif (formats.empty()) {\n>  \t\tcerr << \"Failed to list formats on pad 0 of subdevice \"\n> -\t\t     << scaler_->entityName() << endl;\n> +\t\t     << scaler_->entity()->name() << endl;\n>  \t\treturn TestFail;\n>  \t}\n>  \tfor (auto it = formats.begin(); it != formats.end(); ++it)\n> @@ -61,7 +61,7 @@ int ListFormatsTest::run()\n>  \tformats = scaler_->formats(1);\n>  \tif (formats.empty()) {\n>  \t\tcerr << \"Failed to list formats on pad 1 of subdevice \"\n> -\t\t     << scaler_->entityName() << endl;\n> +\t\t     << scaler_->entity()->name() << endl;\n>  \t\treturn TestFail;\n>  \t}\n>  \tfor (auto it = formats.begin(); it != formats.end(); ++it)\n> @@ -71,7 +71,7 @@ int ListFormatsTest::run()\n>  \tformats = scaler_->formats(2);\n>  \tif (!formats.empty()) {\n>  \t\tcerr << \"Listing formats on non-existing pad 2 of subdevice \"\n> -\t\t     << scaler_->entityName()\n> +\t\t     << scaler_->entity()->name()\n>  \t\t     << \" should return an empty format list\" << endl;\n>  \t\treturn TestFail;\n>  \t}\n> diff --git a/test/v4l2_subdevice/v4l2_subdevice_test.cpp b/test/v4l2_subdevice/v4l2_subdevice_test.cpp\n> index 06582969eb45..dfcf779af95e 100644\n> --- a/test/v4l2_subdevice/v4l2_subdevice_test.cpp\n> +++ b/test/v4l2_subdevice/v4l2_subdevice_test.cpp\n> @@ -66,7 +66,7 @@ int V4L2SubdeviceTest::init()\n>  \tret = scaler_->open();\n>  \tif (ret) {\n>  \t\tcerr << \"Unable to open video subdevice \"\n> -\t\t     << scaler_->deviceNode() << endl;\n> +\t\t     << scaler_->entity()->deviceNode() << endl;\n>  \t\tmedia_->release();\n>  \t\treturn TestSkip;\n>  \t}\n> --\n> Regards,\n>\n> Laurent Pinchart\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","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 7020460DBE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 17 Apr 2019 13:56:53 +0200 (CEST)","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 E0B5B20003;\n\tWed, 17 Apr 2019 11:56:52 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Wed, 17 Apr 2019 13:57:44 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190417115744.zwtsccdvs4vxup5h@uno.localdomain>","References":"<20190416220839.1577-1-laurent.pinchart@ideasonboard.com>\n\t<20190416220839.1577-11-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"euiay7amscgnak2q\"","Content-Disposition":"inline","In-Reply-To":"<20190416220839.1577-11-laurent.pinchart@ideasonboard.com>","User-Agent":"NeoMutt/20180716","Subject":"Re: [libcamera-devel] [PATCH v2 10/13] libcamera: v4l2-subdevice:\n\tAdd method to retrieve the media entity","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":"Wed, 17 Apr 2019 11:56:53 -0000"}}]