[{"id":1874,"web_url":"https://patchwork.libcamera.org/comment/1874/","msgid":"<20190612115732.GB1053@bigcity.dyn.berto.se>","date":"2019-06-12T11:57:32","subject":"Re: [libcamera-devel] [PATCH] tests: Add CameraSensor class test","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your work.\n\nOn 2019-06-11 16:26:57 +0300, Laurent Pinchart wrote:\n> Add a test to verify media bus codes, sizes and resolution retrieval\n> through the CameraSensor APÏ based on the Sensor A in the vimc pipeline.\n\nÏ like döts :-)\n\n> Also check that the getFormat() method returns the expected media bus\n> code and size.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  test/camera-sensor.cpp | 112 +++++++++++++++++++++++++++++++++++++++++\n>  test/meson.build       |   1 +\n>  2 files changed, 113 insertions(+)\n>  create mode 100644 test/camera-sensor.cpp\n> \n> diff --git a/test/camera-sensor.cpp b/test/camera-sensor.cpp\n> new file mode 100644\n> index 000000000000..5f128906ce0e\n> --- /dev/null\n> +++ b/test/camera-sensor.cpp\n> @@ -0,0 +1,112 @@\n> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> +/*\n> + * Copyright (C) 2019, Google Inc.\n> + *\n> + * camera-sensor.cpp - Camera sensor tests\n> + */\n> +\n> +#include <algorithm>\n> +#include <iostream>\n> +\n> +#include <linux/media-bus-format.h>\n> +\n> +#include \"camera_sensor.h\"\n> +#include \"device_enumerator.h\"\n> +#include \"media_device.h\"\n> +#include \"v4l2_subdevice.h\"\n> +\n> +#include \"test.h\"\n> +\n> +using namespace std;\n> +using namespace libcamera;\n> +\n> +class CameraSensorTest : public Test\n> +{\n> +protected:\n> +\tint init()\n> +\t{\n> +\t\tenumerator_ = DeviceEnumerator::create();\n> +\t\tif (!enumerator_) {\n> +\t\t\tcerr << \"Failed to create device enumerator\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\tif (enumerator_->enumerate()) {\n> +\t\t\tcerr << \"Failed to enumerate media devices\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\tDeviceMatch dm(\"vimc\");\n> +\t\tmedia_ = enumerator_->search(dm);\n> +\t\tif (!media_) {\n> +\t\t\tcerr << \"Unable to find \\'vimc\\' media device node\" << endl;\n> +\t\t\treturn TestSkip;\n> +\t\t}\n> +\n> +\t\tMediaEntity *entity = media_->getEntityByName(\"Sensor A\");\n> +\t\tif (!entity) {\n> +\t\t\tcerr << \"Unable to find media entity 'Sensor A'\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\tsensor_ = new CameraSensor(entity);\n> +\t\tif (sensor_->init() < 0) {\n> +\t\t\tcerr << \"Unable to initialise camera sensor\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\treturn TestPass;\n> +\t}\n> +\n> +\tint run()\n> +\t{\n> +\t\tconst std::vector<unsigned int> &codes = sensor_->mbusCodes();\n> +\t\tauto iter = std::find(codes.begin(), codes.end(),\n> +\t\t\t\t      MEDIA_BUS_FMT_ARGB8888_1X32);\n> +\t\tif (iter == codes.end()) {\n> +\t\t\tcerr << \"Sensor doesn't support ARGB8888_1X32\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\tconst std::vector<Size> &sizes = sensor_->sizes();\n> +\t\tauto iter2 = std::find(sizes.begin(), sizes.end(),\n> +\t\t\t\t       Size(4096, 2160));\n> +\t\tif (iter2 == sizes.end()) {\n> +\t\t\tcerr << \"Sensor doesn't support 4096x2160\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\tconst Size &resolution = sensor_->resolution();\n> +\t\tif (resolution != Size(4096, 2160)) {\n> +\t\t\tcerr << \"Incorrect sensor resolution \"\n> +\t\t\t     << resolution.toString() << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\tV4L2SubdeviceFormat format = sensor_->getFormat({MEDIA_BUS_FMT_UYVY8_2X8,\n> +\t\t\t\t\t\t\t\t MEDIA_BUS_FMT_SBGGR10_1X10,\n> +\t\t\t\t\t\t\t\t MEDIA_BUS_FMT_BGR888_1X24},\n> +\t\t\t\t\t\t\t\tSize(1024, 768));\n> +\t\tif (format.mbus_code != MEDIA_BUS_FMT_SBGGR10_1X10 ||\n> +\t\t    format.size != Size(4096, 2160)) {\n> +\t\t\tcerr << \"Failed to get a suitable format, expected 4096x2160-0x\"\n> +\t\t\t     << std::hex << MEDIA_BUS_FMT_SBGGR10_1X10\n> +\t\t\t     << \", got \" << format.toString() << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\treturn TestPass;\n> +\t}\n> +\n> +\tvoid cleanup()\n> +\t{\n> +\t\tdelete sensor_;\n> +\t}\n> +\n> +private:\n> +\tstd::unique_ptr<DeviceEnumerator> enumerator_;\n> +\tstd::shared_ptr<MediaDevice> media_;\n> +\tCameraSensor *sensor_;\n> +};\n> +\n> +TEST_REGISTER(CameraSensorTest)\n> diff --git a/test/meson.build b/test/meson.build\n> index 609aeab80e7d..25f181c20308 100644\n> --- a/test/meson.build\n> +++ b/test/meson.build\n> @@ -17,6 +17,7 @@ public_tests = [\n>  ]\n>  \n>  internal_tests = [\n> +    ['camera-sensor',                   'camera-sensor.cpp'],\n>  ]\n>  \n>  foreach t : public_tests\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":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lj1-x243.google.com (mail-lj1-x243.google.com\n\t[IPv6:2a00:1450:4864:20::243])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C593361E06\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 12 Jun 2019 13:57:34 +0200 (CEST)","by mail-lj1-x243.google.com with SMTP id t28so14818118lje.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 12 Jun 2019 04:57:34 -0700 (PDT)","from localhost (89-233-230-99.cust.bredband2.com. [89.233.230.99])\n\tby smtp.gmail.com with ESMTPSA id\n\t16sm3041267lfy.21.2019.06.12.04.57.33\n\t(version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256);\n\tWed, 12 Jun 2019 04:57:33 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to\n\t:user-agent; bh=tUTJh7BARrp12yhYeLkeoCnyD5/EvuVyECMYzrxIBdQ=;\n\tb=bZ/p2p9JjUYIBythF4bpWNIeZjd5SEewW2goKCz9XeM9uY37kzM6viFqI1SDZX/p7H\n\tkihi2eMOXrhIPQTi1+DuqvVsyM7OjKWFf8HQZGaIriKJq5Ohqriu2IRBTsW6zJVxR82r\n\tunQsEgjmCYErhY3BfRBFqEifn7TXhGNnLhxtMVVnQ1Q9ldeuEnS9NORav33u8cMqCyTJ\n\tYCWM5uIGDErH5tZr7W5SzoRknFSeDjSPlCogYi1p0tYa6ZMB5TC2FK6j9XkQqc0SFp6j\n\tfZ5qQO2Dee1xl1rtxRRs4B7iemGv8u3Ki1oXp90zi3jzsrtcKoYqp5qiULiPNYUc39Ts\n\tFaWQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to:user-agent;\n\tbh=tUTJh7BARrp12yhYeLkeoCnyD5/EvuVyECMYzrxIBdQ=;\n\tb=thu12DNMQAnwd1as/u7HSL9hjo1PZ9D+/eFf/5gXUoy6fym9aoqg+fqqtmBXTCK3JX\n\tyWLMZNGxrfqUAXBl7Y38OQ4WWEAK2aK9+IaAyqQmiRvhVL6D0fC9+AIkYagy7fDHvz7X\n\txY1tz2P4ydvTfpEV/5pPBoARfud77AiwrmRMxgZ+Xa5pKH8hvCgN45pvCmst75iUs2An\n\tTN3fQDfhs6NzjdXx8blWUa2yvt9H79BsgLwiMUUuA4waIONe3hfbcdXGD3PwRWA5joTF\n\t2XqVgj5vVUAI4xp2NRXMsmIdqhAa6AdmlGY5MG5SI+eHbSn6UaK6a6ClKkUlgbqw46wm\n\tPjPw==","X-Gm-Message-State":"APjAAAXU8CDVu39HVypYQrVAIapoF3/3PVo3jFcNWW3TB0tQSWzjO2lC\n\tfSaUxjzjP6xMigawYBntPynU1w==","X-Google-Smtp-Source":"APXvYqwQ/LsjX3bt6paIwSiSKzwIkHdErafzto6hLfAgh68X8h0rqBkT1abvp9YVNxg6Ji6RFURLJw==","X-Received":"by 2002:a2e:89d0:: with SMTP id\n\tc16mr33471992ljk.219.1560340653902; \n\tWed, 12 Jun 2019 04:57:33 -0700 (PDT)","Date":"Wed, 12 Jun 2019 13:57:32 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, Mickael Guene <mickael.guene@st.com>","Message-ID":"<20190612115732.GB1053@bigcity.dyn.berto.se>","References":"<1560253031-98823-1-git-send-email-mickael.guene@st.com>\n\t<20190611132657.22133-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190611132657.22133-1-laurent.pinchart@ideasonboard.com>","User-Agent":"Mutt/1.12.0 (2019-05-25)","Subject":"Re: [libcamera-devel] [PATCH] tests: Add CameraSensor class test","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, 12 Jun 2019 11:57:35 -0000"}}]