From patchwork Tue Mar 29 13:02:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Curtin X-Patchwork-Id: 15585 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 C2B18C0F1B for ; Tue, 29 Mar 2022 13:02:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 33A99604C5; Tue, 29 Mar 2022 15:02:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1648558955; bh=C6CUWvwA8Yll6z+vU04qdwV5Pp5haM//IuaBI2z4WqI=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=SoDSBGNpXPSV7fuwqIgcWBAx7qc4OrravfHD0ALZWMLHV8vo5MMYGx4oxlTKoIkob 5txd7cXObtvk2v62uaRRKYH9kDXNHjdkIi5jVXnZUcDyanb3/UwwmRBhAiSeMWlPLK mtEOM/vSFM+qvgTImtedOgbkmYDVBSLRuvurx8tatj2HzaWFDqEtLjpfQrXiyR47QL 2h8f9oYpicnjZt1E13JXxUAkR3fWSDCuG9nnjYytsdOVvDLXywzvtwNn6prCL6lDcm TOrKHpjQLk7q4d7zkJ9WjHYQlGWkJ4LJzwNzplD8HeZbesmwnjNv+jdD4PAWAo6AgX pye3FjGfYnKjA== Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4019960135 for ; Tue, 29 Mar 2022 15:02:33 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="NFw4OvoX"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648558952; 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=EQJVlohLk3bwktDvP+k7cN4qz9JVFBof77e2hkOnHhs=; b=NFw4OvoXXCHfhGy21AeRqbm3yqxXpWjYUphNvHrNIcWozKJ5JYd7FnpKu0O0Rc2cl70Ieb ONqFW9/LcwwDEp7LQ7T8/J70pyGPBoaB+nWY1GhFMkH70WDts81JGotNTzfL8uTIvN/JoX C79z3mjhY1UDVyt5CEXdtcIiXFY5R6c= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-481-y8NuMXD8Momb2OqKmlcvXg-1; Tue, 29 Mar 2022 09:02:30 -0400 X-MC-Unique: y8NuMXD8Momb2OqKmlcvXg-1 Received: by mail-wr1-f69.google.com with SMTP id z1-20020adfec81000000b001f1f7e7ec99so5044251wrn.17 for ; Tue, 29 Mar 2022 06:02:30 -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=EQJVlohLk3bwktDvP+k7cN4qz9JVFBof77e2hkOnHhs=; b=xamMY9qh4cxn/81QaEr20hclJsXzdA0Lw0mtcCbW3CB5pcTHtdUl68Ob4HTXLkbkAg GdFxF4Qr6nIJny0rkkxXXVb6dS1eH1uCYg5SuSsU0N2zp89GMo20BX7rG8MZRHJ2BVI5 Cw+hgA272wNtwkwLv0eFpDB7d/yAKzCNo7KYDwCObFnr+odI5Xl+dsedL2/iIHT8KXza uc4yUdUMoxogFy1i+gpWxG3kHlpn3xTKX5ftSTzTGsdDykLzmwwnmnJkTc0/lvRtzLZK me+5gMC0pmiUNQN0e6dlnoPVlesKVD2zOWsUQerM/ImpEBhX50DoxdC+QZfWSpZDiH9N rbmA== X-Gm-Message-State: AOAM5318VFsBnvKnsbvIM/cux3kgOIw5GTWl1mpuLwtDoFoB7/GK0L+r RMguie9xx+YMlL/qE473QPKA07+otrFayMQEOjOld6xbB0W36aGKgSH8yxswiSBj9Etke7rWflx 1OPLCP53PLEgJKaE2qyN4CehO1gSpNnOlS+/a33uQ3XimLCZiA0ZXV6kIMEkCz1FgF+OjOo02Gl 9IQBuWgMwa X-Received: by 2002:a7b:c925:0:b0:38c:82d7:868d with SMTP id h5-20020a7bc925000000b0038c82d7868dmr6572664wml.100.1648558948591; Tue, 29 Mar 2022 06:02:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/uINRd1Pmegd381U1iTWHpWGpkF2eXX726h+YCHsGoGT0sBL+JFRodl3we95H7FWo9CFCqg== X-Received: by 2002:a7b:c925:0:b0:38c:82d7:868d with SMTP id h5-20020a7bc925000000b0038c82d7868dmr6572597wml.100.1648558948033; Tue, 29 Mar 2022 06:02:28 -0700 (PDT) Received: from p1.Home ([2001:8a0:6724:4500:a69c:e66f:828e:b340]) by smtp.gmail.com with ESMTPSA id m3-20020a5d6243000000b001e33760776fsm14804330wrv.10.2022.03.29.06.02.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Mar 2022 06:02:27 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 29 Mar 2022 14:02:21 +0100 Message-Id: <20220329130221.31972-1-ecurtin@redhat.com> X-Mailer: git-send-email 2.35.1 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 v3] 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 right 0, 0 corner. Signed-off-by: Eric Curtin --- Changes in v2: - Tested and support drawing from negative pixel range kernel parameter (video=960x540@60) was useful here 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. --- src/cam/kms_sink.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/cam/kms_sink.cpp b/src/cam/kms_sink.cpp index da579846..5847c4e1 100644 --- a/src/cam/kms_sink.cpp +++ b/src/cam/kms_sink.cpp @@ -119,17 +119,21 @@ int KMSSink::configure(const libcamera::CameraConfiguration &config) mode.vdisplay == cfg.size.height; }); if (iter == modes.end()) { - std::cerr - << "No mode matching " << cfg.size.toString() - << 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; @@ -297,12 +301,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; }