From patchwork Fri Feb 4 11:12:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Curtin X-Patchwork-Id: 15326 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 9D168BF415 for ; Fri, 4 Feb 2022 11:13:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0F500609F3; Fri, 4 Feb 2022 12:13:09 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="WEVZN71j"; dkim-atps=neutral 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 16CB86020C for ; Fri, 4 Feb 2022 12:13:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643973185; 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=Rby2O3MQprBTZmRTZX6NzdWcuJPIQ1oJKVI9BXV82xg=; b=WEVZN71jrVVM/fa8sUv02UZ7v6VvxhLu/MMJziV4GZ5ppgEHrx6Ok7uLxM1lymxwbbAWbr TgyCYY9ZuSzGJPAc/MUYl/k0D8mXJehTNf3KSPghlstesdBRdTWQquDntUZg8sjy3A7qnG sfVWGsZCGFBHIeFDYt4k7MRJJMGnH6c= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-625-EjPoU4F-MminSVz70XDXDg-1; Fri, 04 Feb 2022 06:13:05 -0500 X-MC-Unique: EjPoU4F-MminSVz70XDXDg-1 Received: by mail-wm1-f70.google.com with SMTP id n7-20020a1c7207000000b0034ec3d8ce0aso2235939wmc.8 for ; Fri, 04 Feb 2022 03:13:04 -0800 (PST) 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=Rby2O3MQprBTZmRTZX6NzdWcuJPIQ1oJKVI9BXV82xg=; b=a6aoc1DabilHlcw21TtVo8mKaIeX5ixyref3gx1G0yQ7o0ZHIy0NXQRaYv5OtVaK68 r2xFc6zA+LUksZyflqowArbBnUvvVnlSbtUL8V6XwVYkRJjnkgi0Z+Tl2iB2G5BJ2hCb gkbJ8QKmmNWXRVtPI15jpmHhinYpg000qSef5DVaOX+2G31dTWM5w0OSEKHAj1/twREw k6zcZfbpIeRP2fd5vpT/cfYWML0/fBBUS7HpzsQO7rNGD1TaLr8gVCtNqqmEbVFnuq7e ojs2F1zC94ws3F2wXMKB/hvHmupJ+yocnGnwsCFe4etRrnBDOYlXO/N8EQXlLHYLkYCU RW+Q== X-Gm-Message-State: AOAM530J9WGpvxd5lNBiezLuMqgPHvQ2X7caLw4qW86PyJYJEB2PAsX6 IclukeTwTUOhqiVinmyekH7SA/0yfYJJPZldsiDK8U0YXi8qZLyHcxXRunoynRMzPjNUbsyqiH8 J01lIWglsOWCTyivEFHMioUQrP7+z6RmJDyd+/shTgDdGnbZVYec0dBifwG67Pe3nZ05We0aJ38 jRbP5feWPO X-Received: by 2002:a5d:5846:: with SMTP id i6mr2044287wrf.4.1643973183621; Fri, 04 Feb 2022 03:13:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJz7mZODr7Zkk4ECnkXycpPZh0r5arLB9YjpuI6fu7WFALLpk8awRVmQvkmv6s8+XSeaRXc9zg== X-Received: by 2002:a5d:5846:: with SMTP id i6mr2044268wrf.4.1643973183365; Fri, 04 Feb 2022 03:13:03 -0800 (PST) Received: from p1.Home ([2001:8a0:6724:4500:1e3a:8e9c:379e:f6ba]) by smtp.gmail.com with ESMTPSA id f13sm1747113wri.44.2022.02.04.03.13.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 03:13:02 -0800 (PST) From: Eric Curtin To: libcamera-devel@lists.libcamera.org Date: Fri, 4 Feb 2022 11:12:54 +0000 Message-Id: <20220204111254.22884-1-ecurtin@redhat.com> X-Mailer: git-send-email 2.34.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] 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: , 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. Centralize the image. Signed-off-by: Eric Curtin --- src/cam/kms_sink.cpp | 27 +++++++++------------------ src/cam/kms_sink.h | 2 ++ 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/cam/kms_sink.cpp b/src/cam/kms_sink.cpp index 973cd370..159b9355 100644 --- a/src/cam/kms_sink.cpp +++ b/src/cam/kms_sink.cpp @@ -113,24 +113,15 @@ int KMSSink::configure(const libcamera::CameraConfiguration &config) const libcamera::StreamConfiguration &cfg = config.at(0); const std::vector &modes = connector_->modes(); - const auto iter = std::find_if(modes.begin(), modes.end(), - [&](const DRM::Mode &mode) { - return mode.hdisplay == cfg.size.width && - mode.vdisplay == cfg.size.height; - }); - if (iter == modes.end()) { - std::cerr - << "No mode matching " << cfg.size.toString() - << std::endl; - return -EINVAL; - } int ret = configurePipeline(cfg.pixelFormat); if (ret < 0) return ret; - mode_ = &*iter; + mode_ = &modes[0]; size_ = cfg.size; + x_ = (mode_->hdisplay - size_.width) / 2; + y_ = (mode_->vdisplay - size_.height) / 2; stride_ = cfg.stride; return 0; @@ -297,12 +288,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_, "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_, "SRC_W", size_.width << 16); + drmRequest->addProperty(plane_, "SRC_H", size_.height << 16); + drmRequest->addProperty(plane_, "CRTC_X", x_); + drmRequest->addProperty(plane_, "CRTC_Y", y_); + drmRequest->addProperty(plane_, "CRTC_W", size_.width); + drmRequest->addProperty(plane_, "CRTC_H", size_.height); flags |= DRM::AtomicRequest::FlagAllowModeset; } diff --git a/src/cam/kms_sink.h b/src/cam/kms_sink.h index 4a0a872c..1b08e887 100644 --- a/src/cam/kms_sink.h +++ b/src/cam/kms_sink.h @@ -61,6 +61,8 @@ private: libcamera::PixelFormat format_; libcamera::Size size_; unsigned int stride_; + unsigned int x_; // Where to start drawing camera output + unsigned int y_; // Where to start drawing camera output std::map> buffers_;