Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3949308rdb; Mon, 11 Dec 2023 05:01:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IEtl6kDxW3wK3zNNC3yb2B0oYWmesSYd830UVVJtVbXaJmqEQpaREbrCrDnkgV56ikDRUbJ X-Received: by 2002:a17:90b:3655:b0:286:9cdc:c2d5 with SMTP id nh21-20020a17090b365500b002869cdcc2d5mr3280688pjb.43.1702299681863; Mon, 11 Dec 2023 05:01:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702299681; cv=none; d=google.com; s=arc-20160816; b=FTu+07Mb4qN1fjilHp4+rdUbRUwUNcPHvvGsZIleaM0pnGKXrpCsanX+1xN3vDasw3 Ndrr5Zr2ELa2x0n4YgQA2nxEzZYTqUQyUrsEh5HSbRb59itO3+FZPe66TOTBatB/QqFk eB4JARzfwt5ATbIu10E81FlTc6r+Rk9gukhIChbkwkLTKDQvOrZMjGanP28PBO4slFUg 0XSzx+QFynKtzCYdnYHBrUBAE6Tpsx61vm2TJt99gM5GryGHTya//EZGmCR8EEKbqTqy aeX0opS7hQbl43RCwkpRC+xarutbFwYZ4dejCy6/iJWxD5maBZ/5HmuMrBI2rCS9UvDX MCzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/CkAdQDunTbs+4VpihCudAB31cApQmVeADbuKzwehwU=; fh=5WFlYumxFb4YMTIyFXnieMfGzo3YjRfO3j2f2Wqiw4A=; b=xsgt1Afp9hMACaB848cxVeqUSM8wwg0jqmgy0ZErLveXPcX9pkveAbOy6avY3gx1Pn kTzpsJIgmGRIwom5mA8CHQ2uXqqx4vDapAVLcybbpXl1wcrkFVsBi9tS86qkgdx+2CJq UfHcONj6USouMfFDzAE4DBj0fo+JMa3rg+cCAmkWfP5f+oytK4UG5ECuG5cyFnapuDm4 NpznKP8Ae2FHo43ca+zQ2h+my/+8Vfaoex3Xpx2JdtIuDiuY72LdEXy1P0YY+mP1xAId 8P2ePJdY4EmZSOHB/tDirIVEFdsoZBEtizYcjtS1y2bxFeFlVz0+rEksKJh8DUwpZNO7 7sOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=CWPrdnvc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id p16-20020a17090adf9000b00286ad92ab6fsi7175317pjv.185.2023.12.11.05.01.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 05:01:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=CWPrdnvc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 42A2C808E661; Mon, 11 Dec 2023 05:00:56 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234943AbjLKNAZ (ORCPT + 99 others); Mon, 11 Dec 2023 08:00:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234950AbjLKNAT (ORCPT ); Mon, 11 Dec 2023 08:00:19 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EF11FF; Mon, 11 Dec 2023 05:00:22 -0800 (PST) Received: from umang.jain (unknown [103.251.226.68]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C35841515; Mon, 11 Dec 2023 13:59:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1702299577; bh=v4zXIcoXuUwhPMrAke1jILyP8oPZPN1RS9zYrSyz7ak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CWPrdnvcj1ATNUi9LlVubPvyrBxQ8bFZ6UwWDhK7CA814WS+OQr4Il860MjthLyWG XrspKJBRN3g9vhELPgtdhLth6LU+/t0hbxPKekj3g0OTJWM1RiIz26L4Bf5Uzox/CT jbq53RkQxVZj6zt7S7z0FDFTdsF1nsa6ZQtkZt44= From: Umang Jain To: devicetree@vger.kernel.org, linux-media@vger.kernel.org Cc: "Paul J . Murphy" , Daniele Alessandrelli , Sakari Ailus , Mauro Carvalho Chehab , Kieran Bingham , Umang Jain , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 5/7] media: i2c: imx335: Implement get selection API Date: Mon, 11 Dec 2023 18:29:47 +0530 Message-ID: <20231211125950.108092-6-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231211125950.108092-1-umang.jain@ideasonboard.com> References: <20231211125950.108092-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 11 Dec 2023 05:00:56 -0800 (PST) X-Spam-Level: * From: Kieran Bingham Support reporting of the Sensor Native and Active pixel array areas through the Selection API. The implementation reports a single target crop only for the mode that is presently exposed by the driver. Reviewed-by: Umang Jain Signed-off-by: Kieran Bingham --- drivers/media/i2c/imx335.c | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c index b25216b3350e..a924b7222ca3 100644 --- a/drivers/media/i2c/imx335.c +++ b/drivers/media/i2c/imx335.c @@ -55,6 +55,14 @@ #define IMX335_REG_MIN 0x00 #define IMX335_REG_MAX 0xfffff +/* IMX335 native and active pixel array size. */ +#define IMX335_NATIVE_WIDTH 2616U +#define IMX335_NATIVE_HEIGHT 1964U +#define IMX335_PIXEL_ARRAY_LEFT 12U +#define IMX335_PIXEL_ARRAY_TOP 12U +#define IMX335_PIXEL_ARRAY_WIDTH 2592U +#define IMX335_PIXEL_ARRAY_HEIGHT 1944U + /** * struct imx335_reg - imx335 sensor register * @address: Register address @@ -645,6 +653,41 @@ static int imx335_init_pad_cfg(struct v4l2_subdev *sd, return imx335_set_pad_format(sd, sd_state, &fmt); } +/** + * imx335_get_selection() - Selection API + * @sd: pointer to imx335 V4L2 sub-device structure + * @sd_state: V4L2 sub-device configuration + * @sel: V4L2 selection info + * + * Return: 0 if successful, error code otherwise. + */ +static int imx335_get_selection(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_selection *sel) +{ + switch (sel->target) { + case V4L2_SEL_TGT_NATIVE_SIZE: + sel->r.top = 0; + sel->r.left = 0; + sel->r.width = IMX335_NATIVE_WIDTH; + sel->r.height = IMX335_NATIVE_HEIGHT; + + return 0; + + case V4L2_SEL_TGT_CROP: + case V4L2_SEL_TGT_CROP_DEFAULT: + case V4L2_SEL_TGT_CROP_BOUNDS: + sel->r.top = IMX335_PIXEL_ARRAY_TOP; + sel->r.left = IMX335_PIXEL_ARRAY_LEFT; + sel->r.width = IMX335_PIXEL_ARRAY_WIDTH; + sel->r.height = IMX335_PIXEL_ARRAY_HEIGHT; + + return 0; + } + + return -EINVAL; +} + /** * imx335_start_streaming() - Start sensor stream * @imx335: pointer to imx335 device @@ -862,6 +905,8 @@ static const struct v4l2_subdev_pad_ops imx335_pad_ops = { .init_cfg = imx335_init_pad_cfg, .enum_mbus_code = imx335_enum_mbus_code, .enum_frame_size = imx335_enum_frame_size, + .get_selection = imx335_get_selection, + .set_selection = imx335_get_selection, .get_fmt = imx335_get_pad_format, .set_fmt = imx335_set_pad_format, }; -- 2.41.0