From patchwork Fri Jun 17 09:41:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Curtin X-Patchwork-Id: 16263 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 87D1FBD161 for ; Fri, 17 Jun 2022 09:43:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B444E65637; Fri, 17 Jun 2022 11:43:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655459018; bh=4GxBk7J+00sFdXFylC0biNbTuUpfGXkfQOYO6Bn+4yE=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=cdDN7nhHNHL7R3TVyeaEP/nl9k/mI226Cq90VGoo/UXLFOc+5gAf8lq39ZY6wlsQt 6iVMbtn3+gOkTNCyRbjv+AYnzInHVloCuqaMUkfmIIje9O3TVLHC83xBeKOkP6AL/6 K8BOEx3CY15bOCdc7Mf4Buu313+npO1EbDWGGWm0Y+wqMK5Yds09zB4+39k/Cu28Kn F6/n6RrqNc8urVOGScY/NMZ1U5fcb7ulsKNoLUPHtRat9BP8OgZ9v4jLkZLBqJsVlT ViBC+Qjd2Y0NEl2bZ3Vm4t29XGvWxm21KJOS8lVNfozZ7j+vj9fL6MoP+/hfNo55NU 4K8APc0EKo9PA== Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F2CFD60471 for ; Fri, 17 Jun 2022 11:43:36 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="REpT7qzC"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655459015; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=zJLqg48dUbUt9QM3UnR4QrsWr/X0Q/gejKwt0mseLnM=; b=REpT7qzCglo0YVtCT5TpXz1iihA1c6Z9Winy2BoZl4V3ooIP+TY7O/4SkM8wpw9jXJv47X 3WOosPOl7rs+dLj88uux8McED3v8tDv7FHgCmm7OVJo7RNFgIxIh9I/B1x3XuhzB1fQ7tQ qLnpn5uK4wJUWXmcmIJqTNDaGcaHgzE= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-306-BhwiYXM9PdOpoYZL_vi4bQ-1; Fri, 17 Jun 2022 05:43:34 -0400 X-MC-Unique: BhwiYXM9PdOpoYZL_vi4bQ-1 Received: by mail-wm1-f71.google.com with SMTP id l4-20020a05600c1d0400b0039c60535405so1389541wms.6 for ; Fri, 17 Jun 2022 02:43:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=zJLqg48dUbUt9QM3UnR4QrsWr/X0Q/gejKwt0mseLnM=; b=5SrXibx85ec48/NTJj/8ZiCQIkgoUPFqggZdMScamrPir54yyBSi0SqK6O29JWpil3 40mBpyyitpsdPkR1xJ5DH0tn1CBmYzAF3VME4m2X9ebs2ovVR8rm4aSncR+L4eZmCgpn h7+4blnBBZxgBp3hamNYoCC3s4rPt3PKy3cnBQmImSMyDiHjPIfn864gquoovHUoJ8nJ TRhSoPMvL3tLs8vcl3yn/qyrwxPtQBu4AxQ0islP6ajTG+bI2NY8lAyRZRv+075TXiC+ ydNIQjmzZsYG8RISXEsoQSq1Sp2trWkHsNR1A9GRzrVT0wXNNJLmeBu5DG12TchKLGXz t1sQ== X-Gm-Message-State: AJIora8d2AmhplFeOS8L7i0KPJGZPb7oChC6g1Ne0fS7YjxZwcBuWnlU Lm28wJlD5ZbrsO4k7mEWeL47jhQc7VHc/78vYqrc5v4gwNPCTgZ/llJ6cU9DqgQhvfbZNGKfFTE O0aTT/ELzHiwwszPRKzbkbmv5FDS12C53IncLkRjU663eNxR2ZUe/Xwy8MSzC5azuOfF02xnVQg B83YusHCv9 X-Received: by 2002:a7b:c38b:0:b0:39c:6964:34a2 with SMTP id s11-20020a7bc38b000000b0039c696434a2mr9173949wmj.165.1655459012836; Fri, 17 Jun 2022 02:43:32 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v2CUEBbsYdzYt38tMo5CCQcTzNsRyRGMGte81xN2XU8Fagl8BmoIld158eDzCxy/Te+D+Tlg== X-Received: by 2002:a7b:c38b:0:b0:39c:6964:34a2 with SMTP id s11-20020a7bc38b000000b0039c696434a2mr9173917wmj.165.1655459012575; Fri, 17 Jun 2022 02:43:32 -0700 (PDT) Received: from p1.Home ([2001:8a0:6724:4500:a69c:e66f:828e:b340]) by smtp.gmail.com with ESMTPSA id l3-20020a5d5263000000b0020ff7246934sm3988556wrc.95.2022.06.17.02.43.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 02:43:32 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 17 Jun 2022 10:41:27 +0100 Message-Id: <20220617094126.6781-1-ecurtin@redhat.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ecurtin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [libcamera-devel] [PATCH v4] cam: kms_sink: Remove limitation that camera and display must match 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-Patchwork-Original-From: Eric Curtin via libcamera-devel From: Eric Curtin Reply-To: Eric Curtin Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" There is a limitation that requires input and output to be pixel for pixel identical in terms of height and width. Remove this limitation to enable more hardware that doesn't match. Just start drawing from top left 0, 0 corner. Signed-off-by: Eric Curtin --- Changes in v4: - Change commit message to say top left - Spaces to tabs Changes in v3: - Much simplified version of the patch where we just attempt to draw from point 0, 0. Only in the case where we do not find a matching mode. Can expand to do centralization, scaling, etc. in further patches if needs be. Changes in v2: - Tested and support drawing from negative pixel range kernel parameter (video=960x540@60) was useful here --- src/cam/kms_sink.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/cam/kms_sink.cpp b/src/cam/kms_sink.cpp index 7add81a6..985b5f2e 100644 --- a/src/cam/kms_sink.cpp +++ b/src/cam/kms_sink.cpp @@ -119,15 +119,20 @@ int KMSSink::configure(const libcamera::CameraConfiguration &config) mode.vdisplay == cfg.size.height; }); if (iter == modes.end()) { - std::cerr << "No mode matching " << cfg.size << std::endl; - return -EINVAL; + if (modes.empty()) { + std::cerr << "No modes\n"; + return -EINVAL; + } + + mode_ = &modes[0]; + } else { + mode_ = &*iter; } int ret = configurePipeline(cfg.pixelFormat); if (ret < 0) return ret; - mode_ = &*iter; size_ = cfg.size; stride_ = cfg.stride; @@ -295,12 +300,12 @@ bool KMSSink::processRequest(libcamera::Request *camRequest) drmRequest->addProperty(plane_, "CRTC_ID", crtc_->id()); drmRequest->addProperty(plane_, "SRC_X", 0 << 16); drmRequest->addProperty(plane_, "SRC_Y", 0 << 16); - drmRequest->addProperty(plane_, "SRC_W", mode_->hdisplay << 16); - drmRequest->addProperty(plane_, "SRC_H", mode_->vdisplay << 16); + drmRequest->addProperty(plane_, "SRC_W", size_.width << 16); + drmRequest->addProperty(plane_, "SRC_H", size_.height << 16); drmRequest->addProperty(plane_, "CRTC_X", 0); drmRequest->addProperty(plane_, "CRTC_Y", 0); - drmRequest->addProperty(plane_, "CRTC_W", mode_->hdisplay); - drmRequest->addProperty(plane_, "CRTC_H", mode_->vdisplay); + drmRequest->addProperty(plane_, "CRTC_W", size_.width); + drmRequest->addProperty(plane_, "CRTC_H", size_.height); flags |= DRM::AtomicRequest::FlagAllowModeset; }