From patchwork Thu Jun 20 21:36:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Selvaraj X-Patchwork-Id: 20359 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 7F2AFC3294 for ; Thu, 20 Jun 2024 21:46:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D2764654A9; Thu, 20 Jun 2024 23:46:14 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="drQbbvM2"; dkim-atps=neutral Received: from mail-ot1-x330.google.com (mail-ot1-x330.google.com [IPv6:2607:f8b0:4864:20::330]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E41B9654A3 for ; Thu, 20 Jun 2024 23:36:23 +0200 (CEST) Received: by mail-ot1-x330.google.com with SMTP id 46e09a7af769-7009a3976ebso14693a34.1 for ; Thu, 20 Jun 2024 14:36:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718919381; x=1719524181; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wzHF0XV8hR+AE00WCp7mRWTjwhN1sMx3rrREb4N+3kk=; b=drQbbvM2/MxHZWsWLBMUYGzTbhd+HzkzWL0A5pqCAqU2Cy2T4KJUGRiDCrYzyPUQyd SpqReYoeBOQ9+63kXzO9oFDJ3pStozPxHanApS7O9GDBoPfCZxFxUgDdecVeg71I50JO 0sztUz9Zea/sWpiSG+Lr0lok1s+zbeYgN2oz295X4ljCo2If9v5VPcV3GLsKLaEKBPnB Nv76r0X/3n+iWUeZV/EfpG9WXG8Xh2FRzEblynpvMyyzyF8+IuENk4b2b1TVPNbewCpg eX8Eaiazd/mem21zIUtndAXZwJmen40nzIz3pstL+mlp2xLotULgAk+M+UKQWaqtJkZ1 uiNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718919381; x=1719524181; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wzHF0XV8hR+AE00WCp7mRWTjwhN1sMx3rrREb4N+3kk=; b=BwAMIPkWoOaU0KDngL2z2mcwvkOPA7lCmqRjx9mfODSiNk/ClZq705VHN4T0u50c+S Ilq8pRSN6DHSyz1+CsaEGqZA07AMnpEuQMeTFwKcxTnYiYjwOorYOh/OnTFvbDmCGYbO BtY++TU+vqypr8o23Cuc70FNrNLALv2fY5FROiddnx9QmgM2riZ5IIZB6ytN3NkloAbd kM4lv02+OIh4crjL5CX0gvEcCa9ur6GPx+2MB3mLrbivRyb0JW3yqIgqNL73BGShnIM6 3qD4FtOPPlW8fDINLSc1JLDBexf206gzk1Z4taXmEpgdiGL3x42UFSnB57jDgEMc/MNZ I8kw== X-Gm-Message-State: AOJu0YysDcSzpxOsIwG74qDu0q58i0dRPmi4Ho3l4pCK01rn9iDUggcC 40WgzRooTeeIdtSkkEowmFDIV2FRvm21R95N1aRH/V5s3JAoNLmXIGEdIv1c X-Google-Smtp-Source: AGHT+IEpBkP3gTS0/f4ukcwUpMq5NiCXQqYDriqxfLNfkO6A4NsrGabjRyQD8E2kDxMzDiBKOgxqYQ== X-Received: by 2002:a05:6830:350e:b0:6f9:624c:b58e with SMTP id 46e09a7af769-7007568d576mr7281759a34.2.1718919381531; Thu, 20 Jun 2024 14:36:21 -0700 (PDT) Received: from localhost.localdomain ([67.6.32.220]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7009c65d116sm60530a34.57.2024.06.20.14.36.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 14:36:20 -0700 (PDT) From: Joel Selvaraj To: libcamera-devel@lists.libcamera.org Cc: Joel Selvaraj Subject: [PATCH 2/2] qcam: introduce a command line argument to rotate the viewfinder output Date: Thu, 20 Jun 2024 16:36:07 -0500 Message-ID: <20240620213607.32583-3-joelselvaraj.oss@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240620213607.32583-1-joelselvaraj.oss@gmail.com> References: <20240620213607.32583-1-joelselvaraj.oss@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 20 Jun 2024 23:46:10 +0200 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Sometimes devicetrees may not specify the rotation or incorrectly specify it. Introduce a command line argument to quickly test different rotations. This also helps in easily identifying the rotation at which the camera is mounted if kernel developer doesn't already know it. Signed-off-by: Joel Selvaraj --- src/apps/qcam/main.cpp | 3 +++ src/apps/qcam/main_window.cpp | 19 +++++++++++++++++++ src/apps/qcam/main_window.h | 1 + 3 files changed, 23 insertions(+) diff --git a/src/apps/qcam/main.cpp b/src/apps/qcam/main.cpp index 9846fba5..9100c69d 100644 --- a/src/apps/qcam/main.cpp +++ b/src/apps/qcam/main.cpp @@ -37,6 +37,9 @@ OptionsParser::Options parseOptions(int argc, char *argv[]) ArgumentRequired, "camera"); parser.addOption(OptHelp, OptionNone, "Display this help message", "help"); + parser.addOption(OptOrientation, OptionString, + "Desired image orientation (rot0, rot90, rot180, rot270)", + "orientation", ArgumentRequired, "orientation"); parser.addOption(OptRenderer, OptionString, "Choose the renderer type {qt,gles} (default: qt)", "renderer", ArgumentRequired, "renderer"); diff --git a/src/apps/qcam/main_window.cpp b/src/apps/qcam/main_window.cpp index 18c94cf3..aa4a0fa0 100644 --- a/src/apps/qcam/main_window.cpp +++ b/src/apps/qcam/main_window.cpp @@ -399,6 +399,25 @@ int MainWindow::startCapture() if (rotation) orientation = orientationFromRotation(*rotation); + /* Override if user specifies orientation in command line argument */ + if (options_.isSet(OptOrientation)) { + std::string orientOpt = options_[OptOrientation].toString(); + static const std::map possible_orientations{ + { "rot0", Orientation::Rotate0 }, + { "rot90", Orientation::Rotate90 }, + { "rot180", Orientation::Rotate180 }, + { "rot270", Orientation::Rotate270 }, + }; + + auto requested_orientation = possible_orientations.find(orientOpt); + if (requested_orientation == possible_orientations.end()) { + std::cerr << "Unsupported orientation " << orientOpt << std::endl; + return -EINVAL; + } + + orientation = requested_orientation->second; + } + StreamConfiguration &vfConfig = config_->at(0); /* Use a format supported by the viewfinder if available. */ diff --git a/src/apps/qcam/main_window.h b/src/apps/qcam/main_window.h index 4cead734..6dbcd88d 100644 --- a/src/apps/qcam/main_window.h +++ b/src/apps/qcam/main_window.h @@ -40,6 +40,7 @@ class HotplugEvent; enum { OptCamera = 'c', OptHelp = 'h', + OptOrientation = 'o', OptRenderer = 'r', OptStream = 's', OptVerbose = 'v',