{"id":16263,"url":"https://patchwork.libcamera.org/api/patches/16263/?format=json","web_url":"https://patchwork.libcamera.org/patch/16263/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220617094126.6781-1-ecurtin@redhat.com>","date":"2022-06-17T09:41:27","name":"[libcamera-devel,v4] cam: kms_sink: Remove limitation that camera and display must match","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"6fee478204eca9d1bdd36d2032f47f1bf5d8f3fb","submitter":{"id":101,"url":"https://patchwork.libcamera.org/api/people/101/?format=json","name":"Eric Curtin","email":"ecurtin@redhat.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16263/mbox/","series":[{"id":3187,"url":"https://patchwork.libcamera.org/api/series/3187/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3187","date":"2022-06-17T09:41:27","name":"[libcamera-devel,v4] cam: kms_sink: Remove limitation that camera and display must match","version":4,"mbox":"https://patchwork.libcamera.org/series/3187/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16263/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16263/checks/","tags":{},"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 87D1FBD161\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 17 Jun 2022 09:43:39 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B444E65637;\n\tFri, 17 Jun 2022 11:43:38 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F2CFD60471\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 17 Jun 2022 11:43:36 +0200 (CEST)","from mail-wm1-f71.google.com (mail-wm1-f71.google.com\n\t[209.85.128.71]) 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-306-BhwiYXM9PdOpoYZL_vi4bQ-1; Fri, 17 Jun 2022 05:43:34 -0400","by mail-wm1-f71.google.com with SMTP id\n\tl4-20020a05600c1d0400b0039c60535405so1389541wms.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 17 Jun 2022 02:43:34 -0700 (PDT)","from p1.Home ([2001:8a0:6724:4500:a69c:e66f:828e:b340])\n\tby smtp.gmail.com with ESMTPSA id\n\tl3-20020a5d5263000000b0020ff7246934sm3988556wrc.95.2022.06.17.02.43.31\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 17 Jun 2022 02:43:32 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1655459018;\n\tbh=4GxBk7J+00sFdXFylC0biNbTuUpfGXkfQOYO6Bn+4yE=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=cdDN7nhHNHL7R3TVyeaEP/nl9k/mI226Cq90VGoo/UXLFOc+5gAf8lq39ZY6wlsQt\n\t6iVMbtn3+gOkTNCyRbjv+AYnzInHVloCuqaMUkfmIIje9O3TVLHC83xBeKOkP6AL/6\n\tK8BOEx3CY15bOCdc7Mf4Buu313+npO1EbDWGGWm0Y+wqMK5Yds09zB4+39k/Cu28Kn\n\tF6/n6RrqNc8urVOGScY/NMZ1U5fcb7ulsKNoLUPHtRat9BP8OgZ9v4jLkZLBqJsVlT\n\tViBC+Qjd2Y0NEl2bZ3Vm4t29XGvWxm21KJOS8lVNfozZ7j+vj9fL6MoP+/hfNo55NU\n\t4K8APc0EKo9PA==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1655459015;\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\tcontent-transfer-encoding:content-transfer-encoding;\n\tbh=zJLqg48dUbUt9QM3UnR4QrsWr/X0Q/gejKwt0mseLnM=;\n\tb=REpT7qzCglo0YVtCT5TpXz1iihA1c6Z9Winy2BoZl4V3ooIP+TY7O/4SkM8wpw9jXJv47X\n\t3WOosPOl7rs+dLj88uux8McED3v8tDv7FHgCmm7OVJo7RNFgIxIh9I/B1x3XuhzB1fQ7tQ\n\tqLnpn5uK4wJUWXmcmIJqTNDaGcaHgzE="],"Authentication-Results":["lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=redhat.com\n\theader.i=@redhat.com header.b=\"REpT7qzC\"; \n\tdkim-atps=neutral","relay.mimecast.com;\n\tauth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ecurtin@redhat.com"],"X-MC-Unique":"BhwiYXM9PdOpoYZL_vi4bQ-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:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=zJLqg48dUbUt9QM3UnR4QrsWr/X0Q/gejKwt0mseLnM=;\n\tb=5SrXibx85ec48/NTJj/8ZiCQIkgoUPFqggZdMScamrPir54yyBSi0SqK6O29JWpil3\n\t40mBpyyitpsdPkR1xJ5DH0tn1CBmYzAF3VME4m2X9ebs2ovVR8rm4aSncR+L4eZmCgpn\n\th7+4blnBBZxgBp3hamNYoCC3s4rPt3PKy3cnBQmImSMyDiHjPIfn864gquoovHUoJ8nJ\n\tTRhSoPMvL3tLs8vcl3yn/qyrwxPtQBu4AxQ0islP6ajTG+bI2NY8lAyRZRv+075TXiC+\n\tydNIQjmzZsYG8RISXEsoQSq1Sp2trWkHsNR1A9GRzrVT0wXNNJLmeBu5DG12TchKLGXz\n\tt1sQ==","X-Gm-Message-State":"AJIora8d2AmhplFeOS8L7i0KPJGZPb7oChC6g1Ne0fS7YjxZwcBuWnlU\n\tLm28wJlD5ZbrsO4k7mEWeL47jhQc7VHc/78vYqrc5v4gwNPCTgZ/llJ6cU9DqgQhvfbZNGKfFTE\n\tO0aTT/ELzHiwwszPRKzbkbmv5FDS12C53IncLkRjU663eNxR2ZUe/Xwy8MSzC5azuOfF02xnVQg\n\tB83YusHCv9","X-Received":["by 2002:a7b:c38b:0:b0:39c:6964:34a2 with SMTP id\n\ts11-20020a7bc38b000000b0039c696434a2mr9173949wmj.165.1655459012836; \n\tFri, 17 Jun 2022 02:43:32 -0700 (PDT)","by 2002:a7b:c38b:0:b0:39c:6964:34a2 with SMTP id\n\ts11-20020a7bc38b000000b0039c696434a2mr9173917wmj.165.1655459012575; \n\tFri, 17 Jun 2022 02:43:32 -0700 (PDT)"],"X-Google-Smtp-Source":"AGRyM1v2CUEBbsYdzYt38tMo5CCQcTzNsRyRGMGte81xN2XU8Fagl8BmoIld158eDzCxy/Te+D+Tlg==","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","X-Mimecast-Spam-Score":"0","X-Mimecast-Originator":"redhat.com","Content-Transfer-Encoding":"8bit","Content-Type":"text/plain; charset=\"US-ASCII\"; x-default=true","Subject":"[libcamera-devel] [PATCH v4] cam: kms_sink: Remove limitation that\n\tcamera and display 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>","From":"Eric Curtin via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Eric Curtin <ecurtin@redhat.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"There is a limitation that requires input and output to be pixel\nfor pixel identical in terms of height and width. Remove this\nlimitation to enable more hardware that doesn't match. Just start\ndrawing from top left 0, 0 corner.\n\nSigned-off-by: Eric Curtin <ecurtin@redhat.com>\n---\nChanges in v4:\n- Change commit message to say top left\n- Spaces to tabs\n\nChanges in v3:\n- Much simplified version of the patch where we just attempt to\n  draw from point 0, 0. Only in the case where we do not find a\n  matching mode. Can expand to do centralization, scaling, etc.\n  in further patches if needs be.\n\nChanges in v2:\n- Tested and support drawing from negative pixel range\n  kernel parameter (video=960x540@60) was useful here\n---\n src/cam/kms_sink.cpp | 19 ++++++++++++-------\n 1 file changed, 12 insertions(+), 7 deletions(-)","diff":"diff --git a/src/cam/kms_sink.cpp b/src/cam/kms_sink.cpp\nindex 7add81a6..985b5f2e 100644\n--- a/src/cam/kms_sink.cpp\n+++ b/src/cam/kms_sink.cpp\n@@ -119,15 +119,20 @@ int KMSSink::configure(const libcamera::CameraConfiguration &config)\n \t\t\t\t\t\t      mode.vdisplay == cfg.size.height;\n \t\t\t\t       });\n \tif (iter == modes.end()) {\n-\t\tstd::cerr << \"No mode matching \" << cfg.size << std::endl;\n-\t\treturn -EINVAL;\n+\t\tif (modes.empty()) {\n+\t\t\tstd::cerr << \"No modes\\n\";\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tmode_ = &modes[0];\n+\t} else {\n+\t\tmode_ = &*iter;\n \t}\n \n \tint ret = configurePipeline(cfg.pixelFormat);\n \tif (ret < 0)\n \t\treturn ret;\n \n-\tmode_ = &*iter;\n \tsize_ = cfg.size;\n \tstride_ = cfg.stride;\n \n@@ -295,12 +300,12 @@ bool KMSSink::processRequest(libcamera::Request *camRequest)\n \t\tdrmRequest->addProperty(plane_, \"CRTC_ID\", crtc_->id());\n \t\tdrmRequest->addProperty(plane_, \"SRC_X\", 0 << 16);\n \t\tdrmRequest->addProperty(plane_, \"SRC_Y\", 0 << 16);\n-\t\tdrmRequest->addProperty(plane_, \"SRC_W\", mode_->hdisplay << 16);\n-\t\tdrmRequest->addProperty(plane_, \"SRC_H\", mode_->vdisplay << 16);\n+\t\tdrmRequest->addProperty(plane_, \"SRC_W\", size_.width << 16);\n+\t\tdrmRequest->addProperty(plane_, \"SRC_H\", size_.height << 16);\n \t\tdrmRequest->addProperty(plane_, \"CRTC_X\", 0);\n \t\tdrmRequest->addProperty(plane_, \"CRTC_Y\", 0);\n-\t\tdrmRequest->addProperty(plane_, \"CRTC_W\", mode_->hdisplay);\n-\t\tdrmRequest->addProperty(plane_, \"CRTC_H\", mode_->vdisplay);\n+\t\tdrmRequest->addProperty(plane_, \"CRTC_W\", size_.width);\n+\t\tdrmRequest->addProperty(plane_, \"CRTC_H\", size_.height);\n \n \t\tflags |= DRM::AtomicRequest::FlagAllowModeset;\n \t}\n","prefixes":["libcamera-devel","v4"]}