From patchwork Sat Oct 28 08:41:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Apitzsch?= X-Patchwork-Id: 159240 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp1109463vqb; Sat, 28 Oct 2023 01:43:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEPyET+4Rp2RgaP45F1KdQqXfswVNfHHLe1iNzXKG6/RvfRye4VSaKk3NVRaWQzdaONAVuc X-Received: by 2002:a17:903:4345:b0:1cc:2526:1e4 with SMTP id lo5-20020a170903434500b001cc252601e4mr2749673plb.52.1698482583558; Sat, 28 Oct 2023 01:43:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698482583; cv=none; d=google.com; s=arc-20160816; b=oUjnZym8oj/qMg+//Ll2faA1s/K/CaB1AzFuQf000gdFyYkKwvN0tXnhSGFHhqIF3B ibklBysieeJcGHzihdX7bjE36qjcQ9PgrDJQsKoJX2TF/y8SZXSgFw2Cb9g72bhxuAo3 jplMuP/v0S7ZoxREZNRpzyE6N2OjYwn7daw7TJ5IpLoOrwjb3C2moOgYWFtBx/so5+rq Keo0JC1ifXE7pn/89CjeTteV7WGAD+IgmQE6npXfllHXmkk3xCUQsXgrfVYZ5HYrlWF0 V3tebgDqmxDdCzl5LgAZ9tdMorccJ5hSf13V8VWclwEDdLI9XtsU0swpltlVOKW2Nj0p r8wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from; bh=/iDa0/PFXQS9HVxupIKe9gKZ0fPF20TIJE5T+tr/XhU=; fh=Gadr0aUB8zty8NH/YaNy5EBNIZUlZSGENDAW2PTeJWI=; b=uxtR352nvmMxa0oj0p2kffGQnggbXKVIgLnwwIEALeDfB29vhQMo3BpFxuLcwFaywq AsApZdSwTN/5DT2zIADKhj4fTQ/EfVPOY90jbCn6zW1udot/1k8FV+Zab7kLJaeiZZ2n bEguChbmzPZ/Ush5HlBmtIbkaP3Uzlnm8ajgDH+im90waRjoElrsajlfTsUHziI+sgjA pXpw1EXxZLNP6t3mBkRPL7NxyY1Tgk+O+vUdIJnmYdHfknr6DIkPxB9khFi/3OkGUbWr CJ8/TdsFuP1/VQsbcGs38BcqQvLqZKWvooZcQ/pV2McA38yO2350HlD5mBJmBNEN9rk4 Juog== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id l6-20020a170903120600b001cc0d2e97f8si2371828plh.575.2023.10.28.01.43.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 01:43:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 5E3F68076C85; Sat, 28 Oct 2023 01:43:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232405AbjJ1Imj (ORCPT + 28 others); Sat, 28 Oct 2023 04:42:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229492AbjJ1ImX (ORCPT ); Sat, 28 Oct 2023 04:42:23 -0400 Received: from smtprelay07.ispgateway.de (smtprelay07.ispgateway.de [134.119.228.97]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85064121; Sat, 28 Oct 2023 01:42:19 -0700 (PDT) Received: from [92.206.139.21] (helo=note-book.lan) by smtprelay07.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.1) (envelope-from ) id 1qwetd-0006mt-1Y; Sat, 28 Oct 2023 10:42:17 +0200 From: =?utf-8?q?Andr=C3=A9_Apitzsch?= Date: Sat, 28 Oct 2023 10:41:48 +0200 Subject: [PATCH v3 4/4] media: i2c: imx214: Add sensor's pixel matrix size MIME-Version: 1.0 Message-Id: <20231028-imx214-v3-4-cd4bf77f9690@apitzsch.eu> References: <20231028-imx214-v3-0-cd4bf77f9690@apitzsch.eu> In-Reply-To: <20231028-imx214-v3-0-cd4bf77f9690@apitzsch.eu> To: Ricardo Ribalda , Sakari Ailus , Mauro Carvalho Chehab Cc: Kieran Bingham , Jacopo Mondi , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, =?utf-8?q?Andr=C3=A9_Apitzsch?= X-Mailer: b4 0.12.3 X-Df-Sender: YW5kcmVAYXBpdHpzY2guZXU= X-Spam-Status: No, score=1.2 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,PDS_OTHER_BAD_TLD,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sat, 28 Oct 2023 01:43:00 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780988073063658392 X-GMAIL-MSGID: 1780988073063658392 Set effective and active sensor pixel sizes as shown in product brief[1]. [1]: https://www.mouser.com/datasheet/2/897/ProductBrief_IMX214_20150428-1289331.pdf Reviewed-by: Jacopo Mondi Signed-off-by: André Apitzsch --- drivers/media/i2c/imx214.c | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c index 81f126a1b145..0aba28d6dc2f 100644 --- a/drivers/media/i2c/imx214.c +++ b/drivers/media/i2c/imx214.c @@ -36,6 +36,14 @@ #define IMX214_EXPOSURE_STEP 1 #define IMX214_EXPOSURE_DEFAULT 3184 +/* IMX214 native and active pixel array size */ +#define IMX214_NATIVE_WIDTH 4224U +#define IMX214_NATIVE_HEIGHT 3136U +#define IMX214_PIXEL_ARRAY_LEFT 8U +#define IMX214_PIXEL_ARRAY_TOP 8U +#define IMX214_PIXEL_ARRAY_WIDTH 4208U +#define IMX214_PIXEL_ARRAY_HEIGHT 3120U + static const char * const imx214_supply_name[] = { "vdda", "vddd", @@ -634,14 +642,31 @@ static int imx214_get_selection(struct v4l2_subdev *sd, { struct imx214 *imx214 = to_imx214(sd); - if (sel->target != V4L2_SEL_TGT_CROP) - return -EINVAL; + switch (sel->target) { + case V4L2_SEL_TGT_CROP: + mutex_lock(&imx214->mutex); + sel->r = *__imx214_get_pad_crop(imx214, sd_state, sel->pad, + sel->which); + mutex_unlock(&imx214->mutex); + return 0; - mutex_lock(&imx214->mutex); - sel->r = *__imx214_get_pad_crop(imx214, sd_state, sel->pad, - sel->which); - mutex_unlock(&imx214->mutex); - return 0; + case V4L2_SEL_TGT_NATIVE_SIZE: + sel->r.top = 0; + sel->r.left = 0; + sel->r.width = IMX214_NATIVE_WIDTH; + sel->r.height = IMX214_NATIVE_HEIGHT; + return 0; + + case V4L2_SEL_TGT_CROP_DEFAULT: + case V4L2_SEL_TGT_CROP_BOUNDS: + sel->r.top = IMX214_PIXEL_ARRAY_TOP; + sel->r.left = IMX214_PIXEL_ARRAY_LEFT; + sel->r.width = IMX214_PIXEL_ARRAY_WIDTH; + sel->r.height = IMX214_PIXEL_ARRAY_HEIGHT; + return 0; + } + + return -EINVAL; } static int imx214_entity_init_cfg(struct v4l2_subdev *subdev,