From patchwork Mon Jul 27 16:21:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 9022 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 6F694BD86F for ; Mon, 27 Jul 2020 16:21:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3AD0A616B9; Mon, 27 Jul 2020 18:21:57 +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="ha/2+6qW"; dkim-atps=neutral Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 95B24605B2 for ; Mon, 27 Jul 2020 18:21:55 +0200 (CEST) Received: by mail-pl1-x629.google.com with SMTP id 72so8292810ple.0 for ; Mon, 27 Jul 2020 09:21:55 -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=z90V0beLLE9VzXH+tiPKxbEQOcvvOKJveodD5jSzWoE=; b=ha/2+6qWMrOmP++Sj6xPcVd2I9dnpb7AqBtllVpxhAqOdgldl1A6h36IJWlhHp8IOj AKMNtCxDqNDiOdI2iFrCeMoQBP3WXWdBwDazfTf6aFDJ+kJHK3nzwtGz+s4U1yhCU02H yPuZZigN7INR8c5tUJqG4g5gxLFQ7vsBxBNwtNvljTkyOXhTpl+/eEkj3WrqtEAIeKAa X9La+JuXMcJtnAKuwGbjSpiF1IP8Wh57QSmNfgqgfRzRgVn0aTa21JXDG0TvMWKBRKMO 3msIgCArtvd0hfXvICXGcNxdrFHV7q/VqxdWVK9OHNWPP+d1xxd9twz7y/N60ACWk6Vu RNzw== 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=z90V0beLLE9VzXH+tiPKxbEQOcvvOKJveodD5jSzWoE=; b=DQ7U00S5cf1v7dCpp0AIgkQnHJYkOoEkMB2WjzzxX7F+J3zFjuAnKPaA7Sc0pZVjBa phLJqEWfPmy0iA2hPkXwWj1+hV4KVkTNqF9dIuuoyLXiqpRkd2CIokdCWeQC7B80XVeW pSxa/wQley/Iceyxn3JLRETtgFG7AgiiL4d5J8P+xfof00eJKnaLgLOVx6cEZZr+NZ8O N+23OMWsuFqNMXyXMCm6KSF6nNrV2hHC7BNGD5+6Cw9moFcjEVeCGNuDMOJ3iyNuCTFS cBMiXZnNYI3hISWy7KtJNlZXKOwavZcRLzFva2Zro0dH69v0o3UFj960r6ac3genVkMt 5tkg== X-Gm-Message-State: AOAM533TiumovacG92G4NdEYhmyDQ1Jnn4rJCj68MW+346TLuHA2+MVQ JpTF8E7/vCWlX31fW+FGj2rpyg== X-Google-Smtp-Source: ABdhPJyRZCGmOBRfDqiu/A8rou5zcjoGo1s9ELrAuj32pf9uvZjWGlt0XE1vbPABHGC0xHN6TQ3xog== X-Received: by 2002:a17:902:b207:: with SMTP id t7mr19308837plr.135.1595866914237; Mon, 27 Jul 2020 09:21:54 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.178]) by smtp.gmail.com with ESMTPSA id m4sm8439652pgh.9.2020.07.27.09.21.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2020 09:21:53 -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 21:51:41 +0530 Message-Id: <20200727162143.31317-2-kgupta@es.iitr.ac.in> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200727162143.31317-1-kgupta@es.iitr.ac.in> References: <20200727162143.31317-1-kgupta@es.iitr.ac.in> Subject: [libcamera-devel] [PATCH v4 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 PixelFormatInfo, given format name as a string. Signed-off-by: Kaaira Gupta Reviewed-by: Kieran Bingham --- include/libcamera/internal/formats.h | 1 + src/libcamera/formats.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h index 0bb1510..b8e4749 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 PixelFormatInfo &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..5f14281 100644 --- a/src/libcamera/formats.cpp +++ b/src/libcamera/formats.cpp @@ -663,6 +663,22 @@ const PixelFormatInfo &PixelFormatInfo::info(const V4L2PixelFormat &format) return info->second; } +/** + * \brief Retrieve information about a pixel format + * \param[in] name The name of pixel format + * \return The PixelFormatInfo describing the \a name if known, or an + * invalid PixelFormatInfo otherwise + */ +const PixelFormatInfo &PixelFormatInfo::info(const std::string &name) +{ + for (const auto &info : pixelFormatInfo) { + if (info.second.name == name) + return info.second; + } + + return pixelFormatInfoInvalid; +} + /** * \brief Compute the stride * \param[in] width The width of the line, in pixels From patchwork Mon Jul 27 16:21:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 9023 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 1B280BD86F for ; Mon, 27 Jul 2020 16:22:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DBEA461759; Mon, 27 Jul 2020 18:22:00 +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="kwLZHoQf"; dkim-atps=neutral Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A44F5613AA for ; Mon, 27 Jul 2020 18:21:59 +0200 (CEST) Received: by mail-pj1-x1030.google.com with SMTP id k71so9759324pje.0 for ; Mon, 27 Jul 2020 09:21:59 -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=w9eGLE0dedOumJlBcT9N4fn1cOiqA+G5CpQFzujn6Gg=; b=kwLZHoQf+fsf2oEKKAKU2/+LKo0SO8u3bcv1bP49o9CfN25C7mqq5c5/9up28yfd2g Djf5d2cN4kCDne5SFTR/eUmW4ErS80dcD3SYLzW7GUnjpFxhN6oj0u/L38nW3PktfGyG IQaN70/CsIMjmxK47hkkWezGitFjWgHs1isNqdeH0FXlwtMk8Xeysv6apyHZ/zPUboCc 6uJhVGx66W5I3LOf8NzmIdpSEItZUO1KFlQ5ogrvkNrGHKoyzmZ22htPSntIUUOCUfFK o6txt8Rmn3mKMtjPlLIZVGyEsm6i2x3L/rVglGzojuxckgGKQc9i3RJtPHCpJlICubmQ MR6w== 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=w9eGLE0dedOumJlBcT9N4fn1cOiqA+G5CpQFzujn6Gg=; b=Dn0Dg4C2rXR1Ve4tcsFQ2hLaaMq0dshiRG/dicDRLI7uRiKlph/lYmcX49vSdnezLj o8/DctMsF9BjqI7BV/RUl4OQtjM3xLpXT8eT9Y4xayl7QbcnS/RprNDfRDAHRUjokQt0 9lbbfF1928XsMUGxhbbri6SRkb7PC8XdascwOgjwgF2O9zZqOHEXYt7D0CL1fAND/r/R OpECHwPOd6Z8jvY/7itN6MzmA9ukqFfYnAKUHiK4ETgzLB5I6kP0vccHoO4xQnbIeksh welPOLjFvcDtzNgVOn2eMWUZ8ECFDN2PzQ+2Wrysp4piR5Iuo8x07nWYEpuS6JNg/2p1 Wp7Q== X-Gm-Message-State: AOAM532F17I5/kwCGtTBL712wECScVnD7F1IJHln0cK4uC2n18x2oV0E FF3B3r/Dy+DmsLL+XWmgYhOM4g== X-Google-Smtp-Source: ABdhPJzCrFia1VZOy46tNkaseMC1pSDvEjbPgJK76M/xcp7g6zereODJzgVcibViFEUldKukNIWSQA== X-Received: by 2002:a17:90b:188b:: with SMTP id mn11mr49157pjb.179.1595866918296; Mon, 27 Jul 2020 09:21:58 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.178]) by smtp.gmail.com with ESMTPSA id gn5sm78288pjb.23.2020.07.27.09.21.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2020 09:21:57 -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 21:51:42 +0530 Message-Id: <20200727162143.31317-3-kgupta@es.iitr.ac.in> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200727162143.31317-1-kgupta@es.iitr.ac.in> References: <20200727162143.31317-1-kgupta@es.iitr.ac.in> Subject: [libcamera-devel] [PATCH v4 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 Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- 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..9b07781 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 corresponding to the string + * \return Pixel format + */ +PixelFormat PixelFormat::fromString(const std::string &name) +{ + return PixelFormatInfo::info(name).format; +} + } /* namespace libcamera */ From patchwork Mon Jul 27 16:21:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 9024 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 91EDABD86F for ; Mon, 27 Jul 2020 16:22:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5C93F611A2; Mon, 27 Jul 2020 18:22:05 +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="U6hHlBrB"; dkim-atps=neutral Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AE7F7605B2 for ; Mon, 27 Jul 2020 18:22:03 +0200 (CEST) Received: by mail-pg1-x541.google.com with SMTP id t6so9957106pgq.1 for ; Mon, 27 Jul 2020 09:22:03 -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=U6hHlBrBoTT0lSTKdJqUc4kPLvFa8R2FhCelYIfEjD4l/BIeHnSFdqUxtKECQCyWRE DEg8EF5jxCi4vWX8XJSjc/nsYrD0E2MiZN8I5ooinjeNILDrJdYb6ECBcUNgOMaKuCIw E7kfLAGcZ6HuBb3MherrnBXomkA3xDfCn/auS8J5WwAmCxL9Y2ONdwzZSWLv2fd0cvu7 CvZIoPBD2vNQbywMdpey0QeoOu9+IEXaclyetCxUHxkscFRHj9SlNuQD387hbVP473vq kmaV7tiLZrHL6AWc/DeRNvPwC+14hE3WW7l4JTc9gl8C34wsaqb7dg4Xl4srLxtNHhkx X+aA== 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=iWlHlgUTKaL8I559g5rVTpfZm5U0bbvdPO2BPkeQkGY2NsYQ7Il0t3wOfOTJigtOAg tBUdTs5DyZ2+vRIOqr/lT1djTliolkaSV3JDkDkfIel+I94k/iNVNqxUVg/PhW34vA3B 5e2IsuazPa4Ow/KuB9DxVW70z207s1r9MJ+IqQRalqR9JeyWWwA+PS73eGulrNiBKn4y kDh8u4mUtQxZ/s1+cNNd/qRxfpb84DciWrsRNpnVh1YCmLVjc5Lmm5w75zXCVf1N3fDl k8P9qqQb1nzy3nGWBj4epytU4867YJPvDrXwe6+7EYj7SUvU39V6lWcukXa/nmi1ncgX LluQ== X-Gm-Message-State: AOAM532uZqAK0LOOtVIsPdtsoeeJ62Cz70Vyt/tj7cbnQ8fSWgr72ido xLhY8E3RgkvN9ZOWVNzJFpKbtmw29Zs= X-Google-Smtp-Source: ABdhPJzYy9T/m2Hnh/9axzubc85MNseZn+F31JezUzycu265cF7a7z5SnzRrh6LMyKMAgTF0QGcdkw== X-Received: by 2002:a63:be47:: with SMTP id g7mr20215120pgo.7.1595866922331; Mon, 27 Jul 2020 09:22:02 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.178]) by smtp.gmail.com with ESMTPSA id n14sm15811266pgd.78.2020.07.27.09.22.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2020 09:22:01 -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 21:51:43 +0530 Message-Id: <20200727162143.31317-4-kgupta@es.iitr.ac.in> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200727162143.31317-1-kgupta@es.iitr.ac.in> References: <20200727162143.31317-1-kgupta@es.iitr.ac.in> Subject: [libcamera-devel] [PATCH v4 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 Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- 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;