From patchwork Thu May 28 15:25:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 3874 Return-Path: Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EF5D8603D3 for ; Thu, 28 May 2020 17:25:53 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=es-iitr-ac-in.20150623.gappssmtp.com header.i=@es-iitr-ac-in.20150623.gappssmtp.com header.b="oaxzp8Lp"; dkim-atps=neutral Received: by mail-pf1-x441.google.com with SMTP id 23so13669919pfy.8 for ; Thu, 28 May 2020 08:25:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=JGerUiMwD4TPyY7YJ6ZMEHa/dDQf/1B9KIWcsIL8sYE=; b=oaxzp8LpNiDulwg4KLSq/vU7J8jsYv4DazCNeH94HugZaU+SEfFmg7AfSUR6MAyS/s h29eBFxJei8MfZzdQpgmdFLXvccHn03AbrlHdOMiVL52M0yMg6n/iYNXO7XVa9luTUYk 1eKDc1CGI3ZwlDL+J7QXC/a+KjpihPcmAxQSapy+WsUXrsPQ4tGdDl/Y0b/FI8bYEiJ4 leYdML+I3kFMI4khE93cbhfsennsCdhAywNKPNl1tE6C269dGDZvlXS95NwRWxB/QATi c0vxlJn5c+rsjn/E6tIoP/3vSEAghOYf80gqEJj1ED2tyThEPf2fDhGIKTlOJRsmCp8g R8Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=JGerUiMwD4TPyY7YJ6ZMEHa/dDQf/1B9KIWcsIL8sYE=; b=tLPJLzKOHNLOnNlW6Gg2frspvyq2wBv47jA5h3e6NAkgVVfC4fyyRRuvVitnKZ3XLW CyUxWOAd9AGyaAeUlINthMCfCPt3cOBqA7xCo7rRrqyhGEcKETI4e/Vknrgq7eB2FSSL CXtbXmAvfeqAC+FXbI2aisjhM9oWu++jwWyayJu6Onv0rItrCZFfzsP+FVSgd19MbUdN ZxhIrhtchVc8Dur9HGN4yXTn7IPRqHpxIr+WxYd2OofI9HybQDJYUfj5bK4Uqa9fyQ+z NVydC1pTSiHF6yDbG0OPRHsxLZHWsINzekKWIR6fyXBW6fIFoxekpPChQW4GE2kB/RXE EBiw== X-Gm-Message-State: AOAM530nKOp9YCeke0H+bv09LbFu2B1pS9Ez4AK+NPBH36/WCepVu+ry NWpPjts4MV+RrLBc4jERNNtQxA== X-Google-Smtp-Source: ABdhPJzbTFwhfdnlUu86Zythh2dWM/V1TGtHKEEYWEPYd1NpL8yLFGEsRuRpWhtDX3tXX0FraqYmlg== X-Received: by 2002:a63:1348:: with SMTP id 8mr3435955pgt.8.1590679551758; Thu, 28 May 2020 08:25:51 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.169]) by smtp.gmail.com with ESMTPSA id y23sm5978397pje.3.2020.05.28.08.25.49 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 May 2020 08:25:51 -0700 (PDT) Date: Thu, 28 May 2020 20:55:44 +0530 From: Kaaira Gupta To: kieran.bingham@ideasonboard.com, libcamera-devel@lists.libcamera.org Message-ID: <20200528152544.GA31247@kaaira-HP-Pavilion-Notebook> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Subject: [libcamera-devel] [PATCH] libcamera: v4l2subdev: Print mbus string instead of code X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 May 2020 15:25:54 -0000 Modify toString() to print mbus format string instead of its hex code as the string is easier to understand. Signed-off-by: Kaaira Gupta --- src/libcamera/v4l2_subdevice.cpp | 166 ++++++++++++++++--------------- 1 file changed, 87 insertions(+), 79 deletions(-) diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index 7aefc1b..bdbca03 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -35,84 +35,93 @@ LOG_DECLARE_CATEGORY(V4L2) namespace { +/* + * \var mbusFormat + * \brief A struct of bits per pixel and mbus format + */ +struct mbusFormat { + unsigned int bits; + std::string format; +}; + /* * \var formatInfoMap - * \brief A map that associates bits per pixel to V4L2 media bus codes + * \brief A map that associates mbusFormat struct to V4L2 media bus codes */ -const std::map formatInfoMap = { - { V4L2_MBUS_FMT_RGB444_2X8_PADHI_BE, 16 }, - { V4L2_MBUS_FMT_RGB444_2X8_PADHI_LE, 16 }, - { V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE, 16 }, - { V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE, 16 }, - { V4L2_MBUS_FMT_BGR565_2X8_BE, 16 }, - { V4L2_MBUS_FMT_BGR565_2X8_LE, 16 }, - { V4L2_MBUS_FMT_RGB565_2X8_BE, 16 }, - { V4L2_MBUS_FMT_RGB565_2X8_LE, 16 }, - { V4L2_MBUS_FMT_RGB666_1X18, 18 }, - { V4L2_MBUS_FMT_RGB888_1X24, 24 }, - { V4L2_MBUS_FMT_RGB888_2X12_BE, 24 }, - { V4L2_MBUS_FMT_RGB888_2X12_LE, 24 }, - { V4L2_MBUS_FMT_ARGB8888_1X32, 32 }, - { V4L2_MBUS_FMT_Y8_1X8, 8 }, - { V4L2_MBUS_FMT_UV8_1X8, 8 }, - { V4L2_MBUS_FMT_UYVY8_1_5X8, 12 }, - { V4L2_MBUS_FMT_VYUY8_1_5X8, 12 }, - { V4L2_MBUS_FMT_YUYV8_1_5X8, 12 }, - { V4L2_MBUS_FMT_YVYU8_1_5X8, 12 }, - { V4L2_MBUS_FMT_UYVY8_2X8, 16 }, - { V4L2_MBUS_FMT_VYUY8_2X8, 16 }, - { V4L2_MBUS_FMT_YUYV8_2X8, 16 }, - { V4L2_MBUS_FMT_YVYU8_2X8, 16 }, - { V4L2_MBUS_FMT_Y10_1X10, 10 }, - { V4L2_MBUS_FMT_UYVY10_2X10, 20 }, - { V4L2_MBUS_FMT_VYUY10_2X10, 20 }, - { V4L2_MBUS_FMT_YUYV10_2X10, 20 }, - { V4L2_MBUS_FMT_YVYU10_2X10, 20 }, - { V4L2_MBUS_FMT_Y12_1X12, 12 }, - { V4L2_MBUS_FMT_UYVY8_1X16, 16 }, - { V4L2_MBUS_FMT_VYUY8_1X16, 16 }, - { V4L2_MBUS_FMT_YUYV8_1X16, 16 }, - { V4L2_MBUS_FMT_YVYU8_1X16, 16 }, - { V4L2_MBUS_FMT_YDYUYDYV8_1X16, 16 }, - { V4L2_MBUS_FMT_UYVY10_1X20, 20 }, - { V4L2_MBUS_FMT_VYUY10_1X20, 20 }, - { V4L2_MBUS_FMT_YUYV10_1X20, 20 }, - { V4L2_MBUS_FMT_YVYU10_1X20, 20 }, - { V4L2_MBUS_FMT_YUV10_1X30, 30 }, - { V4L2_MBUS_FMT_AYUV8_1X32, 32 }, - { V4L2_MBUS_FMT_UYVY12_2X12, 24 }, - { V4L2_MBUS_FMT_VYUY12_2X12, 24 }, - { V4L2_MBUS_FMT_YUYV12_2X12, 24 }, - { V4L2_MBUS_FMT_YVYU12_2X12, 24 }, - { V4L2_MBUS_FMT_UYVY12_1X24, 24 }, - { V4L2_MBUS_FMT_VYUY12_1X24, 24 }, - { V4L2_MBUS_FMT_YUYV12_1X24, 24 }, - { V4L2_MBUS_FMT_YVYU12_1X24, 24 }, - { V4L2_MBUS_FMT_SBGGR8_1X8, 8 }, - { V4L2_MBUS_FMT_SGBRG8_1X8, 8 }, - { V4L2_MBUS_FMT_SGRBG8_1X8, 8 }, - { V4L2_MBUS_FMT_SRGGB8_1X8, 8 }, - { V4L2_MBUS_FMT_SBGGR10_ALAW8_1X8, 8 }, - { V4L2_MBUS_FMT_SGBRG10_ALAW8_1X8, 8 }, - { V4L2_MBUS_FMT_SGRBG10_ALAW8_1X8, 8 }, - { V4L2_MBUS_FMT_SRGGB10_ALAW8_1X8, 8 }, - { V4L2_MBUS_FMT_SBGGR10_DPCM8_1X8, 8 }, - { V4L2_MBUS_FMT_SGBRG10_DPCM8_1X8, 8 }, - { V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8, 8 }, - { V4L2_MBUS_FMT_SRGGB10_DPCM8_1X8, 8 }, - { V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE, 16 }, - { V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE, 16 }, - { V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE, 16 }, - { V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE, 16 }, - { V4L2_MBUS_FMT_SBGGR10_1X10, 10 }, - { V4L2_MBUS_FMT_SGBRG10_1X10, 10 }, - { V4L2_MBUS_FMT_SGRBG10_1X10, 10 }, - { V4L2_MBUS_FMT_SRGGB10_1X10, 10 }, - { V4L2_MBUS_FMT_SBGGR12_1X12, 12 }, - { V4L2_MBUS_FMT_SGBRG12_1X12, 12 }, - { V4L2_MBUS_FMT_SGRBG12_1X12, 12 }, - { V4L2_MBUS_FMT_SRGGB12_1X12, 12 }, - { V4L2_MBUS_FMT_AHSV8888_1X32, 32 }, +const std::map formatInfoMap = { + { V4L2_MBUS_FMT_RGB444_2X8_PADHI_BE, { 16, "RGB444_2X8_PADHI_BE" } }, + { V4L2_MBUS_FMT_RGB444_2X8_PADHI_LE, { 16, "RGB444_2X8_PADHI_LE" } }, + { V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE, { 16, "RGB555_2X8_PADHI_BE" } }, + { V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE, { 16, "RGB555_2X8_PADHI_LE" } }, + { V4L2_MBUS_FMT_BGR565_2X8_BE, { 16, "BGR565_2X8_BE" } }, + { V4L2_MBUS_FMT_BGR565_2X8_LE, { 16, "BGR565_2X8_LE" } }, + { V4L2_MBUS_FMT_RGB565_2X8_BE, { 16, "RGB565_2X8_BE" } }, + { V4L2_MBUS_FMT_RGB565_2X8_LE, { 16, "RGB565_2X8_LE" } }, + { V4L2_MBUS_FMT_RGB666_1X18, { 18, "RGB666_1X18" } }, + { V4L2_MBUS_FMT_RGB888_1X24, { 24, "RGB888_1X24" } }, + { V4L2_MBUS_FMT_RGB888_2X12_BE, { 24, "RGB888_2X12_BE" } }, + { V4L2_MBUS_FMT_RGB888_2X12_LE, { 24, "RGB888_2X12_LE" } }, + { V4L2_MBUS_FMT_ARGB8888_1X32, { 32, "ARGB8888_1X32" } }, + { V4L2_MBUS_FMT_Y8_1X8, { 8, "Y8_1X8" } }, + { V4L2_MBUS_FMT_UV8_1X8, { 8, "UV8_1X8" } }, + { V4L2_MBUS_FMT_UYVY8_1_5X8, { 12, "UYVY8_1_5X8" } }, + { V4L2_MBUS_FMT_VYUY8_1_5X8, { 12, "VYUY8_1_5X8" } }, + { V4L2_MBUS_FMT_YUYV8_1_5X8, { 12, "YUYV8_1_5X8" } }, + { V4L2_MBUS_FMT_YVYU8_1_5X8, { 12, "YVYU8_1_5X8" } }, + { V4L2_MBUS_FMT_UYVY8_2X8, { 16, "UYVY8_2X8" } }, + { V4L2_MBUS_FMT_VYUY8_2X8, { 16, "VYUY8_2X8" } }, + { V4L2_MBUS_FMT_YUYV8_2X8, { 16, "YUYV8_2X8" } }, + { V4L2_MBUS_FMT_YVYU8_2X8, { 16, "YVYU8_2X8" } }, + { V4L2_MBUS_FMT_Y10_1X10, { 10, "Y10_1X10" } }, + { V4L2_MBUS_FMT_UYVY10_2X10, { 20, "UYVY10_2X10" } }, + { V4L2_MBUS_FMT_VYUY10_2X10, { 20, "VYUY10_2X10" } }, + { V4L2_MBUS_FMT_YUYV10_2X10, { 20, "YUYV10_2X10" } }, + { V4L2_MBUS_FMT_YVYU10_2X10, { 20, "YVYU10_2X10" } }, + { V4L2_MBUS_FMT_Y12_1X12, { 12, "Y12_1X12" } }, + { V4L2_MBUS_FMT_UYVY8_1X16, { 16, "UYVY8_1X16" } }, + { V4L2_MBUS_FMT_VYUY8_1X16, { 16, "VYUY8_1X16" } }, + { V4L2_MBUS_FMT_YUYV8_1X16, { 16, "YUYV8_1X16" } }, + { V4L2_MBUS_FMT_YVYU8_1X16, { 16, "YVYU8_1X16" } }, + { V4L2_MBUS_FMT_YDYUYDYV8_1X16, { 16, "YDYUYDYV8_1X16" } }, + { V4L2_MBUS_FMT_UYVY10_1X20, { 20, "UYVY10_1X20" } }, + { V4L2_MBUS_FMT_VYUY10_1X20, { 20, "VYUY10_1X20" } }, + { V4L2_MBUS_FMT_YUYV10_1X20, { 20, "YUYV10_1X20" } }, + { V4L2_MBUS_FMT_YVYU10_1X20, { 20, "YVYU10_1X20" } }, + { V4L2_MBUS_FMT_YUV10_1X30, { 30, "YUV10_1X30" } }, + { V4L2_MBUS_FMT_AYUV8_1X32, { 32, "AYUV8_1X32" } }, + { V4L2_MBUS_FMT_UYVY12_2X12, { 24, "UYVY12_2X12" } }, + { V4L2_MBUS_FMT_VYUY12_2X12, { 24, "VYUY12_2X12" } }, + { V4L2_MBUS_FMT_YUYV12_2X12, { 24, "YUYV12_2X12" } }, + { V4L2_MBUS_FMT_YVYU12_2X12, { 24, "YVYU12_2X12" } }, + { V4L2_MBUS_FMT_UYVY12_1X24, { 24, "UYVY12_1X24" } }, + { V4L2_MBUS_FMT_VYUY12_1X24, { 24, "VYUY12_1X24" } }, + { V4L2_MBUS_FMT_YUYV12_1X24, { 24, "YUYV12_1X24" } }, + { V4L2_MBUS_FMT_YVYU12_1X24, { 24, "YVYU12_1X24" } }, + { V4L2_MBUS_FMT_SBGGR8_1X8, { 8, "SBGGR8_1X8" } }, + { V4L2_MBUS_FMT_SGBRG8_1X8, { 8, "SGBRG8_1X8" } }, + { V4L2_MBUS_FMT_SGRBG8_1X8, { 8, "SGRBG8_1X8" } }, + { V4L2_MBUS_FMT_SRGGB8_1X8, { 8, "SRGGB8_1X8" } }, + { V4L2_MBUS_FMT_SBGGR10_ALAW8_1X8, { 8, "SBGGR10_ALAW8_1X8" } }, + { V4L2_MBUS_FMT_SGBRG10_ALAW8_1X8, { 8, "SGBRG10_ALAW8_1X8" } }, + { V4L2_MBUS_FMT_SGRBG10_ALAW8_1X8, { 8, "SGRBG10_ALAW8_1X8" } }, + { V4L2_MBUS_FMT_SRGGB10_ALAW8_1X8, { 8, "SRGGB10_ALAW8_1X8" } }, + { V4L2_MBUS_FMT_SBGGR10_DPCM8_1X8, { 8, "SBGGR10_DPCM8_1X8" } }, + { V4L2_MBUS_FMT_SGBRG10_DPCM8_1X8, { 8, "SGBRG10_DPCM8_1X8" } }, + { V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8, { 8, "SGRBG10_DPCM8_1X8" } }, + { V4L2_MBUS_FMT_SRGGB10_DPCM8_1X8, { 8, "SRGGB10_DPCM8_1X8" } }, + { V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE, { 16, "SBGGR10_2X8_PADHI_BE" } }, + { V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE, { 16, "SBGGR10_2X8_PADHI_LE" } }, + { V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE, { 16, "SBGGR10_2X8_PADLO_BE" } }, + { V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE, { 16, "SBGGR10_2X8_PADLO_LE" } }, + { V4L2_MBUS_FMT_SBGGR10_1X10, { 10, "SBGGR10_1X10" } }, + { V4L2_MBUS_FMT_SGBRG10_1X10, { 10, "SGBRG10_1X10" } }, + { V4L2_MBUS_FMT_SGRBG10_1X10, { 10, "SGRBG10_1X10" } }, + { V4L2_MBUS_FMT_SRGGB10_1X10, { 10, "SRGGB10_1X10" } }, + { V4L2_MBUS_FMT_SBGGR12_1X12, { 12, "SBGGR12_1X12" } }, + { V4L2_MBUS_FMT_SGBRG12_1X12, { 12, "SGBRG12_1X12" } }, + { V4L2_MBUS_FMT_SGRBG12_1X12, { 12, "SGRBG12_1X12" } }, + { V4L2_MBUS_FMT_SRGGB12_1X12, { 12, "SRGGB12_1X12" } }, + { V4L2_MBUS_FMT_AHSV8888_1X32, { 32, "AHSV8888_1X32" } }, }; } /* namespace */ @@ -161,9 +170,8 @@ const std::map formatInfoMap = { */ const std::string V4L2SubdeviceFormat::toString() const { - std::stringstream ss; - ss << size.toString() << "-" << utils::hex(mbus_code, 4); - return ss.str(); + std::string mbus = size.toString() + "-" + (formatInfoMap.find(mbus_code)->second).format; + return mbus; } /** @@ -180,7 +188,7 @@ uint8_t V4L2SubdeviceFormat::bitsPerPixel() const return 0; } - return it->second; + return (it->second).bits; } /**