From patchwork Mon Jul 27 15:18:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 9018 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id A4F33BD878 for ; Mon, 27 Jul 2020 15:18:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6D6FD613B1; Mon, 27 Jul 2020 17:18:42 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=es-iitr-ac-in.20150623.gappssmtp.com header.i=@es-iitr-ac-in.20150623.gappssmtp.com header.b="wdv1/0GZ"; dkim-atps=neutral Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 23240611A2 for ; Mon, 27 Jul 2020 17:18:41 +0200 (CEST) Received: by mail-pg1-x529.google.com with SMTP id p3so9751369pgh.3 for ; Mon, 27 Jul 2020 08:18:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JbzLbXefDsOj7y17Z0ShvC3CdATsNcn1QqYzkV3YnFw=; b=wdv1/0GZtxQcpPHNexzds3aS43iZkh8HUgAA47M9p/v7NIYhdTqCKV35v4Sqbin6ny QY+NgRlTeuoSDt/eeNkgyW0yFkTwy6LEOM4GMErDReu5jHkfr+QdSQId+8k1G6LlZzp6 c8QstnKbBh4KdvXFRMMUB8mA9Zs0gRrrRVbicufeAcVfSTobGgWaazdA8pfwd1i4E6u1 u/eVPPX5YeEwRfCv8g9bLO4wWnbBfVkDp/4oTX9Um7AJNVACoBh/sJr9JHVgVW08d0qM oWAzDgx9Vk7y5jbf0V3sOqepNDfCBlzEvLHtygBW0HY/CJVI3snmaHr7xoMG99IPrUvT +mzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JbzLbXefDsOj7y17Z0ShvC3CdATsNcn1QqYzkV3YnFw=; b=ElcT1ybmy/cY6vDH3984WuG0wTz/FVkkn95RQACgctffJvO2g5xx4n4AL8crBCF60w BBVcM3Ps1juYQR/ys5k+2pYbPV8NJQh+QZdWAq24S79twp0rTNa9/ktFW+QFoEeJleC7 1DQwid4H2xV81FiO858dI+xyuxOjIqN1z+uJI4jTKzQehdVJSTgV+K9YHY4QjQJ+PbzW mIHQ6v7P+3qa1cJf/fay1DRdMNoBuXnoTg1khpXJyxXnd1dsTLAGd+JsieO/J0UIq3P6 wRjbmCzWA0WqSM1WKkUR0gk10KgJEfhjhz4pYmWlDwZuvVMMXCg3x0JWXuVn+ibSLTsx RBkQ== X-Gm-Message-State: AOAM530UqIyNn89mhrB7XjXQYSoblxE+JuK/xRQgxHmlnp/8KOQokPMK akHcyA7p13ROUOz6WhvM3vVciQ== X-Google-Smtp-Source: ABdhPJyeIzAt1t8omGWSzfx6m+pLKQD/KRx0XVwI96yuugLBNW4qqgSFYD/eqkKR97v3TuXszdlKAA== X-Received: by 2002:a63:8f51:: with SMTP id r17mr20106949pgn.124.1595863119601; Mon, 27 Jul 2020 08:18:39 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.178]) by smtp.gmail.com with ESMTPSA id q14sm15239520pgk.86.2020.07.27.08.18.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2020 08:18:39 -0700 (PDT) From: Kaaira Gupta To: libcamera-devel@lists.libcamera.org, Kieran Bingham , =?utf-8?q?Niklas_S=C3=B6derlund?= Date: Mon, 27 Jul 2020 20:48:18 +0530 Message-Id: <20200727151820.24466-2-kgupta@es.iitr.ac.in> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200727151820.24466-1-kgupta@es.iitr.ac.in> References: <20200727151820.24466-1-kgupta@es.iitr.ac.in> Subject: [libcamera-devel] [PATCH v3 1/3] libcamera: formats: PixelFormatInfo: Add name lookup function 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: , Cc: Kaaira Gupta MIME-Version: 1.0 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a function which returns a format, given its name as a string. Signed-off-by: Kaaira Gupta --- include/libcamera/internal/formats.h | 1 + src/libcamera/formats.cpp | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h index 0bb1510..2589e88 100644 --- a/include/libcamera/internal/formats.h +++ b/include/libcamera/internal/formats.h @@ -38,6 +38,7 @@ public: static const PixelFormatInfo &info(const PixelFormat &format); static const PixelFormatInfo &info(const V4L2PixelFormat &format); + static const PixelFormat &info(const std::string &name); unsigned int stride(unsigned int width, unsigned int plane, unsigned int align = 1) const; diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp index 11774b0..8ea5461 100644 --- a/src/libcamera/formats.cpp +++ b/src/libcamera/formats.cpp @@ -23,6 +23,8 @@ namespace libcamera { LOG_DEFINE_CATEGORY(Formats) +const PixelFormat invalidPixelFormat = PixelFormat(); + /** * \class PixelFormatPlaneInfo * \brief Information about a single plane of a pixel format @@ -663,6 +665,24 @@ const PixelFormatInfo &PixelFormatInfo::info(const V4L2PixelFormat &format) return info->second; } +/** + * \brief Retrieve pixel format from its name + * \param[in] name The name of pixel format + * \return The pixel format corresponding to \a name if known, or an invalid + * pixel format otherwise + */ +const PixelFormat &PixelFormatInfo::info(const std::string &name) +{ + auto it = pixelFormatInfo.begin(); + while (it != pixelFormatInfo.end()) { + if (it->second.name == name) { + return it->first; + } + it++; + } + return invalidPixelFormat; +} + /** * \brief Compute the stride * \param[in] width The width of the line, in pixels From patchwork Mon Jul 27 15:18:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 9019 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 0EC6ABD878 for ; Mon, 27 Jul 2020 15:18:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D1F74613B6; Mon, 27 Jul 2020 17:18:46 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=es-iitr-ac-in.20150623.gappssmtp.com header.i=@es-iitr-ac-in.20150623.gappssmtp.com header.b="fae+vz++"; dkim-atps=neutral Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AE3C06118A for ; Mon, 27 Jul 2020 17:18:45 +0200 (CEST) Received: by mail-pl1-x641.google.com with SMTP id p1so8162670pls.4 for ; Mon, 27 Jul 2020 08:18:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xa/CisV5SteNHL1Yw3nkya4xIj19X3nySwYFLzKpMu0=; b=fae+vz++RigG8wOGcZRC/a5hGgYNEU6AsezdIu5S0eBOfzh1ue0UJ7aiqvePOjiJ/B YTu8AZXU2NF32APx5FCdd2eLruh+wHsLD+bxPfW5sqk88sPWXttm4CdcxF/4dHRobnVh g/HOxRPFVhkE6auxYK5Oarzq/Alqnv5bqTYiiNs1QEEGqOdEchA6xk1iKqipV20xcDmN K2x6ZOOhy1IDCY8xMHk2smk+q2leBY8aqd/FNVA587Y0QvNkW6hm5I1ST40y9Ilt4mYS gV19ehcv3vVYngk7imMY0vhRgpL3IM8mqcjGtni+rjeVmAs0nvtdB58Ip/3pEaSNmyFB xfJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xa/CisV5SteNHL1Yw3nkya4xIj19X3nySwYFLzKpMu0=; b=PUZJNLhybgKfk0g85v6inj3M3/h2yV54aczNGpOUG4zvQWtSHDLX3B3mdCSh+qepgY j1aKdDOPQJEGS4qsthU/fdckE8Jx5ke2Et4x0ftKcmkrewSBeO8QYYjA/lOD/oTl2hTx qK8usXjtVNxIfZqpjvz0ojSkppzVWNxfZl0XNsNdRcxCrByF5YUotYOc+rYqidoCiJM0 ILWJHyzNoGMAPDxJIQstWE96SFzZ3MJJrgdzEOXcSmn+g/S/OPawNv0yR2IVQsYuy7oh xZ0SurQuVOS8OzHHWunwe7qQ43VOJerxB6dXzNl551/kvnBPrR6bu0dRlKAf9YwHdxlq xCDw== X-Gm-Message-State: AOAM532VnmV2CiIF+jh8CnjvmMvdfRdA2TjEe9rK5UgLdwsFUJPJyrkL ercWSDzqwlWzRfb0qrbsOMPoxw== X-Google-Smtp-Source: ABdhPJxKf8hj60uxiMyIH+3LsQPDkzjKoi8F3av070rrAgvymYT+lla0gaVLNv+lSU1Gsbo5I+kwEg== X-Received: by 2002:a17:90a:ef17:: with SMTP id k23mr17452606pjz.45.1595863123701; Mon, 27 Jul 2020 08:18:43 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.178]) by smtp.gmail.com with ESMTPSA id s89sm14848706pjj.28.2020.07.27.08.18.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2020 08:18:43 -0700 (PDT) From: Kaaira Gupta To: libcamera-devel@lists.libcamera.org, Kieran Bingham , =?utf-8?q?Niklas_S=C3=B6derlund?= Date: Mon, 27 Jul 2020 20:48:19 +0530 Message-Id: <20200727151820.24466-3-kgupta@es.iitr.ac.in> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200727151820.24466-1-kgupta@es.iitr.ac.in> References: <20200727151820.24466-1-kgupta@es.iitr.ac.in> Subject: [libcamera-devel] [PATCH v3 2/3] libcamera: pixel_format: Add a function to return format based on string 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: , Cc: Kaaira Gupta MIME-Version: 1.0 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a function which retrieves pixel format corrsponding to its name from PixelFormatInfo. Signed-off-by: Kaaira Gupta --- include/libcamera/pixel_format.h | 2 ++ src/libcamera/pixel_format.cpp | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/include/libcamera/pixel_format.h b/include/libcamera/pixel_format.h index 6727315..c4ae088 100644 --- a/include/libcamera/pixel_format.h +++ b/include/libcamera/pixel_format.h @@ -38,6 +38,8 @@ public: std::string toString() const; + static PixelFormat fromString(const std::string &name); + private: uint32_t fourcc_; uint64_t modifier_; diff --git a/src/libcamera/pixel_format.cpp b/src/libcamera/pixel_format.cpp index 14addb5..fbb2158 100644 --- a/src/libcamera/pixel_format.cpp +++ b/src/libcamera/pixel_format.cpp @@ -130,4 +130,13 @@ std::string PixelFormat::toString() const return info.name; } +/** + * \brief Retrive pixel format correspoding to the string + * \return Pixel format + */ +PixelFormat PixelFormat::fromString(const std::string &name) +{ + return PixelFormatInfo::info(name); +} + } /* namespace libcamera */ From patchwork Mon Jul 27 15:18:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 9020 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 7FC38BD878 for ; Mon, 27 Jul 2020 15:18:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4ED35613D2; Mon, 27 Jul 2020 17:18:51 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=es-iitr-ac-in.20150623.gappssmtp.com header.i=@es-iitr-ac-in.20150623.gappssmtp.com header.b="qCRaCI+q"; dkim-atps=neutral Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8E0F66118A for ; Mon, 27 Jul 2020 17:18:49 +0200 (CEST) Received: by mail-pf1-x443.google.com with SMTP id s26so9228790pfm.4 for ; Mon, 27 Jul 2020 08:18:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Vujycd8EPvoebCgjNl2OyNBkTEe2zGIFJY2qcVv2RBk=; b=qCRaCI+qcPA1rrJBhngpz+H7PKYfcQ+AxlIxWVhh+qobqWEgF0qMDdQtVBAHnFDr71 2ItFaEF9S8O/g18DNNA9gk592j0191JPtGl5fdG4i4K50aztu4ALOS2rN37u+wvenBAZ E2LmZZfXhlryIVcU2Wr3kRq0D9ECF0cWLyrM0+wDOXrj5KtYRTgjrDT3OLl1x54i6hjl xrSoIqRyAAL/XsA6AF/+cQ7Ocrp3seHly/38EL4eM4muBHf0TM4hQjs2J6sFM6cS2xm5 hTKHUDyZTBfJeKe5RMqhERyJIdsMeDSMLxwWra0Hc8NxT/95gDGokMKBQDEMRm1081yM 25GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Vujycd8EPvoebCgjNl2OyNBkTEe2zGIFJY2qcVv2RBk=; b=HNgZOZzMtWG2rQ7w+ddanRCX63IATZz1p2yeBwkosl2vwZp1S/lTg7ZXMXUZSdd1sM TPDmFT87sD/M+Dv/SMhiGb2wlfvdi4nA3VtkqvQNxJo/EXqX/qPUXn33IXEPJJJ+AkNH 0MazTF9wfjUFNGOKH0L746CSpR9y+vADNPE0Isk5cIUSEra9M9DQtbTbwmrkVZ6H56Ns HN14XkYQR4qVONGIhLbikQYwGaL3k/gGYgrFSmwX8Nz/3PoL59h7e8zo4krQokQj2zvn /tw8DqaqloDFtC1xsPEjGdYUPUvLJbxGWPP+p1OngsOz7af5moTgDRFHFa7SijeE0leq QW+A== X-Gm-Message-State: AOAM5330eveITMp2gbCTmcCZhNklYFS25gByastpS+isp9WxqF8sSN6q t1T2tqMd6hvORfqqPSiK0hSSvB3GN9s= X-Google-Smtp-Source: ABdhPJxnMmOTSauMtDrfFD4cIpW+AAJ4qrHFxZ4HSlyldcbiw7IWbyAiRVncD4Sv3Qh2auXOjAf2xg== X-Received: by 2002:a63:4144:: with SMTP id o65mr20061672pga.8.1595863128005; Mon, 27 Jul 2020 08:18:48 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.178]) by smtp.gmail.com with ESMTPSA id q24sm14784792pgg.3.2020.07.27.08.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2020 08:18:47 -0700 (PDT) From: Kaaira Gupta To: libcamera-devel@lists.libcamera.org, Kieran Bingham , =?utf-8?q?Niklas_S=C3=B6derlund?= Date: Mon, 27 Jul 2020 20:48:20 +0530 Message-Id: <20200727151820.24466-4-kgupta@es.iitr.ac.in> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200727151820.24466-1-kgupta@es.iitr.ac.in> References: <20200727151820.24466-1-kgupta@es.iitr.ac.in> Subject: [libcamera-devel] [PATCH v3 3/3] libcamera: stream_option: use format name to set cam/qcam format 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: , Cc: Kaaira Gupta MIME-Version: 1.0 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Replace hex input for pixel formats with their format names, for input in cam and qcam. Hence, remove the todo. Signed-off-by: Kaaira Gupta --- src/cam/stream_options.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cam/stream_options.cpp b/src/cam/stream_options.cpp index bd12c8f..4168e5d 100644 --- a/src/cam/stream_options.cpp +++ b/src/cam/stream_options.cpp @@ -19,7 +19,7 @@ StreamKeyValueParser::StreamKeyValueParser() ArgumentRequired); addOption("height", OptionInteger, "Height in pixels", ArgumentRequired); - addOption("pixelformat", OptionInteger, "Pixel format", + addOption("pixelformat", OptionString, "Pixel format name", ArgumentRequired); } @@ -95,9 +95,8 @@ int StreamKeyValueParser::updateConfiguration(CameraConfiguration *config, cfg.size.height = opts["height"]; } - /* \todo Translate 4CC string to pixelformat with modifier. */ if (opts.isSet("pixelformat")) - cfg.pixelFormat = PixelFormat(opts["pixelformat"]); + cfg.pixelFormat = PixelFormat::fromString(opts["pixelformat"].toString()); } return 0;