From patchwork Fri May 29 14:04:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 3883 Return-Path: Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 58621603CF for ; Fri, 29 May 2020 16:04:42 +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="n5LBfQyz"; dkim-atps=neutral Received: by mail-pg1-x52e.google.com with SMTP id d10so1531673pgn.4 for ; Fri, 29 May 2020 07:04:41 -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=YRshYS4DmvHOFGEltynVu1eHk1TgfmvVy+PGEeAFZfQ=; b=n5LBfQyzfW+Jrqq49veJLmeOTshLmrKAy1KH6rnxckYiAMQ0WsAl75Z1bhCfgcRWVt An5MxgwtU5s0TxVKaSKjNffKnF9VPV6H9ZCRY7O+BTl81JtLlEQP7G5rjJdW9bvZ5y+I VLCqK6R097OFPPhJPYtgIyKfWe/57GxvRVpcbHgkRkZ6SKlWYl8y9CA1i4cSMKO093zy fFnZzTABPGrrcK/AhAZ0zGjcRRA1kpjig+WRQriya92EtI5eETdl9zlVWMB+caER8skL c9q+T/lCop4070irskOSDV5tokSB6AzycfqY8zVyvHUF4YsLxer0Urk4fQn76SxpDlL5 3/MA== 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=YRshYS4DmvHOFGEltynVu1eHk1TgfmvVy+PGEeAFZfQ=; b=BmmLywEEmyoD40SW7J6u8rVF6xSP49ZTAyeWfHRUjBZkPrzdosF+6wTy7RWlGTuXMX DJitG0Ic+hst/AILLkewR5VmJnluu5vNZyRe2zDNbMase2tbaDUKubmv5716VDYlrpwx anRLzZmNH9vCRh46fFS48n4n3gPzpq0IPEYhIbt7XPk7bhT5Yf9ndIeptZkB+Z/g+t4n q7vkslMuIHqLNAwLSQCk2qqq+vBwrZoyJutRf/I6Rb7eqv6VBurX75f1ZUOupJd/Q1Vs vpPCYD4Rq9MS6ArqLbcUDLlnkd7Plil7YQYjOD0bswrkaDXPTByEUaMChpinsUL7T8rZ p7uw== X-Gm-Message-State: AOAM532H4qml31ncx4QD0SqwHF4Pt3s15TUO/b7U9nPMonLi4QABWkJm /KXNLRjRCEVOIvbRUN/ivMCCFwbWkdr1qA== X-Google-Smtp-Source: ABdhPJzuBTz+dCEH+G/FfL3ZmerVcCEgXOVGt2hfU7cdvmHigFVLy7EcGU1tXSkF2vOeyYiksdfHQQ== X-Received: by 2002:a63:b0f:: with SMTP id 15mr8269494pgl.6.1590761080037; Fri, 29 May 2020 07:04:40 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.174]) by smtp.gmail.com with ESMTPSA id h3sm8472252pjk.10.2020.05.29.07.04.37 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 May 2020 07:04:39 -0700 (PDT) Date: Fri, 29 May 2020 19:34:33 +0530 From: Kaaira Gupta To: libcamera-devel@lists.libcamera.org, Kieran Bingham Message-ID: <20200529140433.GA18070@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: stream_option: use fourcc values to set cam/qcam formats 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: Fri, 29 May 2020 14:04:43 -0000 Replace hex input for pixelformats with their fourcc values, in cam and qcam. Signed-off-by: Kaaira Gupta --- src/cam/stream_options.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/cam/stream_options.cpp b/src/cam/stream_options.cpp index bd12c8f..9f9536e 100644 --- a/src/cam/stream_options.cpp +++ b/src/cam/stream_options.cpp @@ -6,6 +6,7 @@ */ #include "stream_options.h" +#include #include using namespace libcamera; @@ -19,7 +20,7 @@ StreamKeyValueParser::StreamKeyValueParser() ArgumentRequired); addOption("height", OptionInteger, "Height in pixels", ArgumentRequired); - addOption("pixelformat", OptionInteger, "Pixel format", + addOption("pixelformat", OptionString, "Pixel format fourcc", ArgumentRequired); } @@ -96,8 +97,14 @@ int StreamKeyValueParser::updateConfiguration(CameraConfiguration *config, } /* \todo Translate 4CC string to pixelformat with modifier. */ - if (opts.isSet("pixelformat")) - cfg.pixelFormat = PixelFormat(opts["pixelformat"]); + if (opts.isSet("pixelformat")) { + std::string fourcc = opts["pixelformat"]; + transform(fourcc.begin(), fourcc.end(), fourcc.begin(), ::toupper); + char char_array[5]; + strcpy(char_array, fourcc.c_str()); + cfg.pixelFormat = PixelFormat((__u32)(char_array[0]) | ((__u32)(char_array[1]) << 8) | + ((__u32)(char_array[2]) << 16) | ((__u32)(char_array[3]) << 24)); + } } return 0;