[{"id":22123,"web_url":"https://patchwork.libcamera.org/comment/22123/","msgid":"<CAOgh=FzWb+GAH1+9QLTRK3FMibfpD8vrY=Zn7W-UROszo26QAg@mail.gmail.com>","date":"2022-02-04T11:43:32","subject":"Re: [libcamera-devel] [PATCH] Remove limitation that camera and\n\tdisplay must match","submitter":{"id":101,"url":"https://patchwork.libcamera.org/api/people/101/","name":"Eric Curtin","email":"ecurtin@redhat.com"},"content":"On Fri, 4 Feb 2022 at 11:13, Eric Curtin <ecurtin@redhat.com> wrote:\n>\n> There is a limitation that requires input and output\n> to be pixel for pixel identical in terms of height\n> and width. Remove this limitation to enable more\n> hardware that doesn't match. Centralize the image.\n>\n> Signed-off-by: Eric Curtin <ecurtin@redhat.com>\n> ---\n>  src/cam/kms_sink.cpp | 27 +++++++++------------------\n>  src/cam/kms_sink.h   |  2 ++\n>  2 files changed, 11 insertions(+), 18 deletions(-)\n>\n> diff --git a/src/cam/kms_sink.cpp b/src/cam/kms_sink.cpp\n> index 973cd370..159b9355 100644\n> --- a/src/cam/kms_sink.cpp\n> +++ b/src/cam/kms_sink.cpp\n> @@ -113,24 +113,15 @@ int KMSSink::configure(const libcamera::CameraConfiguration &config)\n>         const libcamera::StreamConfiguration &cfg = config.at(0);\n>\n>         const std::vector<DRM::Mode> &modes = connector_->modes();\n> -       const auto iter = std::find_if(modes.begin(), modes.end(),\n> -                                      [&](const DRM::Mode &mode) {\n> -                                              return mode.hdisplay == cfg.size.width &&\n> -                                                     mode.vdisplay == cfg.size.height;\n> -                                      });\n> -       if (iter == modes.end()) {\n> -               std::cerr\n> -                       << \"No mode matching \" << cfg.size.toString()\n> -                       << std::endl;\n> -               return -EINVAL;\n> -       }\n>\n>         int ret = configurePipeline(cfg.pixelFormat);\n>         if (ret < 0)\n>                 return ret;\n>\n> -       mode_ = &*iter;\n> +       mode_ = &modes[0];\n>         size_ = cfg.size;\n> +       x_ = (mode_->hdisplay - size_.width) / 2;\n> +       y_ = (mode_->vdisplay - size_.height) / 2;\n>         stride_ = cfg.stride;\n>\n>         return 0;\n> @@ -297,12 +288,12 @@ bool KMSSink::processRequest(libcamera::Request *camRequest)\n>                 drmRequest->addProperty(plane_, \"CRTC_ID\", crtc_->id());\n>                 drmRequest->addProperty(plane_, \"SRC_X\", 0 << 16);\n>                 drmRequest->addProperty(plane_, \"SRC_Y\", 0 << 16);\n> -               drmRequest->addProperty(plane_, \"SRC_W\", mode_->hdisplay << 16);\n> -               drmRequest->addProperty(plane_, \"SRC_H\", mode_->vdisplay << 16);\n> -               drmRequest->addProperty(plane_, \"CRTC_X\", 0);\n> -               drmRequest->addProperty(plane_, \"CRTC_Y\", 0);\n> -               drmRequest->addProperty(plane_, \"CRTC_W\", mode_->hdisplay);\n> -               drmRequest->addProperty(plane_, \"CRTC_H\", mode_->vdisplay);\n> +               drmRequest->addProperty(plane_, \"SRC_W\", size_.width << 16);\n> +               drmRequest->addProperty(plane_, \"SRC_H\", size_.height << 16);\n> +               drmRequest->addProperty(plane_, \"CRTC_X\", x_);\n> +               drmRequest->addProperty(plane_, \"CRTC_Y\", y_);\n> +               drmRequest->addProperty(plane_, \"CRTC_W\", size_.width);\n> +               drmRequest->addProperty(plane_, \"CRTC_H\", size_.height);\n>\n>                 flags |= DRM::AtomicRequest::FlagAllowModeset;\n>         }\n> diff --git a/src/cam/kms_sink.h b/src/cam/kms_sink.h\n> index 4a0a872c..1b08e887 100644\n> --- a/src/cam/kms_sink.h\n> +++ b/src/cam/kms_sink.h\n> @@ -61,6 +61,8 @@ private:\n>         libcamera::PixelFormat format_;\n>         libcamera::Size size_;\n>         unsigned int stride_;\n> +       unsigned int x_;  // Where to start drawing camera output\n> +       unsigned int y_;  // Where to start drawing camera output\n>\n>         std::map<libcamera::FrameBuffer *, std::unique_ptr<DRM::FrameBuffer>> buffers_;\n>\n> --\n> 2.34.1\n>\n\nMight require a follow on commit for the larger camera resolution on\nsmaller display case, if DRM allows you to write to negative pixels,\nit might just work to change those unsigned ints to signed ints. Not a\nscenario I come across on my hardware.","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 427B8BDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  4 Feb 2022 11:43:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A2E4F609A9;\n\tFri,  4 Feb 2022 12:43:53 +0100 (CET)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9DD906020C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  4 Feb 2022 12:43:51 +0100 (CET)","from mail-oo1-f72.google.com (mail-oo1-f72.google.com\n\t[209.85.161.72]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n\tus-mta-225-D6bd20MIOAya5dJdsQrZFw-1; Fri, 04 Feb 2022 06:43:49 -0500","by mail-oo1-f72.google.com with SMTP id\n\tl10-20020a4ac60a000000b002de84253574so3080743ooq.19\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 04 Feb 2022 03:43:49 -0800 (PST)"],"Authentication-Results":["lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"PKVr+IK3\"; dkim-atps=neutral","relay.mimecast.com;\n\tauth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ecurtin@redhat.com"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1643975030;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=U1FJTi1ozX/h5YUJQNUk1J6C3YZ0hWDACG+7MXDNqfs=;\n\tb=PKVr+IK3sEelzAftEuZmEabFyLZ1DVpl/bu8ThiBUfGZAOTdPVgzRjQETLCKCVE66m2+I6\n\tjByHLE20slptU1tgOCYXgV6fk1xtIKQ7M02wu3teTbQllyJwq5m1+hbTlXSAWc0oMraVPb\n\tmVS0Fr4jk6SaaxxfYP8GQOlT1VSGm6c=","X-MC-Unique":"D6bd20MIOAya5dJdsQrZFw-1","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=U1FJTi1ozX/h5YUJQNUk1J6C3YZ0hWDACG+7MXDNqfs=;\n\tb=KeUcyZ6MlFSanDicZO4UCgMut6oAXMoGWmfbROewH7t0xi9CijQ80ljR/sHYibiaFc\n\t2cD5T6jPVzZ65nvJ2F6EPVXHbm+BCfKdMHq4NRGjXGhDIRf31wwofXtRK6z5aenz2HLH\n\tw9bG7duvjYgOiQnuTCG5yssP+WeMycUf4hHL4guy6mhmgMijlBdDj8XUnevmXbiRS9bq\n\t17m1Wy7ojZybft5LXq1QsztGtPWTKhXdX6LKSrxLB5igbkaeQNCSfmSXoACwhuoOhhcz\n\tf8AOzAQHusveMP51lDfMr8wAJRtWC4+0jKqZotnx289JF6NBj5JjjyI+qlIZprKDCJ/h\n\tJX7Q==","X-Gm-Message-State":"AOAM531a0QI+l1l0tAFVPjLe+MMM/40VWLETV5kBarPWMxjCUSVSKVh5\n\t8gQ85jnXlZNcdhPxrcpHnjw/zW1bqNpbhXDij76utWb7BXXpUFxbJFWcigipgqZV1aZA8Q1RDkl\n\tIBr//0HmFaCnM0T68LWULGUMzNl+Pkcrqa9TJI39Sr2LiLGmw5w==","X-Received":["by 2002:a05:6870:a899:: with SMTP id\n\teb25mr499156oab.39.1643975028666; \n\tFri, 04 Feb 2022 03:43:48 -0800 (PST)","by 2002:a05:6870:a899:: with SMTP id\n\teb25mr499147oab.39.1643975028333; \n\tFri, 04 Feb 2022 03:43:48 -0800 (PST)"],"X-Google-Smtp-Source":"ABdhPJwQ5ogW+AXUjcOxnQcqTgrwC/DZOnizrlPFQL0O7gdx5gIbp53ROZ8Xl7nYIQ5INUPDZfhxs8EvY0m3TMNP6o0=","MIME-Version":"1.0","References":"<20220204111254.22884-1-ecurtin@redhat.com>","In-Reply-To":"<20220204111254.22884-1-ecurtin@redhat.com>","From":"Eric Curtin <ecurtin@redhat.com>","Date":"Fri, 4 Feb 2022 11:43:32 +0000","Message-ID":"<CAOgh=FzWb+GAH1+9QLTRK3FMibfpD8vrY=Zn7W-UROszo26QAg@mail.gmail.com>","To":"libcamera-devel@lists.libcamera.org","X-Mimecast-Spam-Score":"0","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH] Remove limitation that camera and\n\tdisplay must match","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]