From patchwork Wed Dec 6 22:33:58 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: 174754 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4421365vqy; Wed, 6 Dec 2023 14:39:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IGXjf7HYti5nlWF/YMXLZNZLgE+e26CRTg2NCPFYptabj02Ibwbvj4ue07ld5VlxT00Yoy0 X-Received: by 2002:a17:90a:1f42:b0:286:6cc0:caec with SMTP id y2-20020a17090a1f4200b002866cc0caecmr1718312pjy.99.1701902388221; Wed, 06 Dec 2023 14:39:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701902388; cv=none; d=google.com; s=arc-20160816; b=rZ86XSJSCILm79XUsCgtySrzVQEjY1XKZYfNn/rXAvxlU8FphCubvWXoMhAKOm29TB NwOkBdcSdkn2Em4fIo0tPq13xZOYINaXfWafmog65d983S8vBPhY1BbBtBPMUuLISNuk yKZOEtu553UIABTvvmXjmGDJ2siAt2PK1bTcHF7N0aNl6VqVUQGBhCGs42W9kcLUYDxB 5gsH/6lKDzQ97rgpcCRL3v88HF7z+nVBxDKL2aXnOE4ytUKSQD1tYtQ+Yl0yKr7soAiJ OsfscWUDw1hOSyLjxuo+BGX2NgqRSghIJtT5qZv9fepx0aPHoxL8ddPbDiHpJad4VYP2 OK2w== 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=CV/PGkM48TYYrGHj1qVouJyVjdtdZa4oYy7EH7GiyE4=; fh=Gadr0aUB8zty8NH/YaNy5EBNIZUlZSGENDAW2PTeJWI=; b=qXeNbwRuE7fWsX/UgNaQxBY3UYi/pOHISxomZGz02MQEm69NR4H7D2UpSTgEYWSDZJ C3901BhxBZUerE3tyQFEQyTJ/kD45Q5FUtwysCC7sHcDQe+9n2i1rqANM13ITGZ6TSyM cs6hIxJmSoARFpQWqYv2W99/3Qk0ICu8Gu7fnUYNy/m5ceJDEeZhE+Q8aIaKc6mYL/bR Ueq0ADSHfHyItirjDFldGLlii7fN/Y+eD7GBy/XuJDpOdDsQRKnGt7VFXRjJEUlLWkPO Zf1pX1CKp6PbpL5r+rtJi6u7Sn3YZgdxgIbuh12wktdv9CH8klyUkRLBPRzC/NoHql2W Ue8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id v22-20020a17090abb9600b002868673f28dsi469708pjr.156.2023.12.06.14.39.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 14:39:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id D69F381EE52E; Wed, 6 Dec 2023 14:39:41 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377591AbjLFWjd (ORCPT + 99 others); Wed, 6 Dec 2023 17:39:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377507AbjLFWjb (ORCPT ); Wed, 6 Dec 2023 17:39:31 -0500 Received: from smtprelay03.ispgateway.de (smtprelay03.ispgateway.de [80.67.31.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9366D5B; Wed, 6 Dec 2023 14:39:37 -0800 (PST) Received: from [92.206.191.209] (helo=note-book.lan) by smtprelay03.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.1) (envelope-from ) id 1rB0TI-0007Ur-2A; Wed, 06 Dec 2023 23:34:24 +0100 From: =?utf-8?q?Andr=C3=A9_Apitzsch?= Date: Wed, 06 Dec 2023 23:33:58 +0100 Subject: [PATCH v4 4/4] media: i2c: imx214: Add sensor's pixel matrix size MIME-Version: 1.0 Message-Id: <20231206-imx214-v4-4-7ef604b01dcb@apitzsch.eu> References: <20231206-imx214-v4-0-7ef604b01dcb@apitzsch.eu> In-Reply-To: <20231206-imx214-v4-0-7ef604b01dcb@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.4 X-Df-Sender: YW5kcmVAYXBpdHpzY2guZXU= X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,PDS_OTHER_BAD_TLD,RCVD_IN_SBL_CSS,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Wed, 06 Dec 2023 14:39:42 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784573998159244151 X-GMAIL-MSGID: 1784573998159244151 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 132267e3a8f5..d67b5b928b9d 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,