From patchwork Tue Oct 10 00:51:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 150430 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp2205009vqo; Mon, 9 Oct 2023 17:52:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGnSn80KddsTf/Phxk4Tc8Ie9+9jVB4Oko3y8kmj2rho44tQaF5VpBqxIK7JJomJmFVQjPB X-Received: by 2002:a17:90b:38b:b0:274:9121:382 with SMTP id ga11-20020a17090b038b00b0027491210382mr19082365pjb.22.1696899142366; Mon, 09 Oct 2023 17:52:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696899142; cv=none; d=google.com; s=arc-20160816; b=VnVcBKxZtSCSBquu3xsuxsN8/K/IwDZj42WvEj7vp8AHXkK+KcxAHV2wfJwWM0h3nm qgZAsE+3gqufJZd4HyLzwo5mCNG/7PtSCh3K/mwHhvNdw8I0ck6+P0SywMPJSqxuAq6N 8kVYsgJn3J+4+og4UOPa1PKSwg02fheW/2NNT0+wghYcSNmNDIpsd4FZ9Rh7xl+/oVSt GiO4WQfxt1n214fLLw3iwxvciUl/aUI9gADNkoem9i6quUFv/3uFDPVeU43iXxs6fous +UVXmvGLv2ZYb7I7Q9M7vrei8j2ZBqq5zXkYlFXPjdWuw6QEyBaW2DUPcZg1vU1f2Ezy IzSA== 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=QGfT6ACyGgH55Fimm/Uch7JST0g/Goe4ajDiQXPoeUI=; fh=KPPO4w/WNlKKcUme74fOJWAWFF+MJLt/bRW1ZZ7V1gk=; b=BOldn+L7/bZJhbBH5ggVazSHeurVFnDGdvvPYGXtCrsnNDGid4A8580ZpOT0bFkM9n SJoP9z6Sf3Cw75+9gkuSI1qWJ8zb65bCEZho6zzFyvbIjvaUjITeS3gjIT/3jvaMfNJu W3HyEn8IH62BIlzIkNR7GdwUeRjnPBLELsR8zd66UuYCVf485kW26UoCq2VgiBmvIqJL 4ZWlcme7H/KcNOBXoL9wJGON8VDO/9x1Ze2eDt8znHIDT+DQD9OMP2qyls+DZsjR6Pqj wwB07QqMcO4c37pbBcQnEfmYXC4TOh8Us/DVjxO5rtPDVHBzH9pjwLrH53cZ9jhV0da1 qR/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=TZglu5jK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id w8-20020a63f508000000b0056fed6cf408si10891081pgh.602.2023.10.09.17.52.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 17:52:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=TZglu5jK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 17F4D8029A37; Mon, 9 Oct 2023 17:52:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379317AbjJJAvz (ORCPT + 18 others); Mon, 9 Oct 2023 20:51:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379264AbjJJAvk (ORCPT ); Mon, 9 Oct 2023 20:51:40 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB8F0F1; Mon, 9 Oct 2023 17:51:38 -0700 (PDT) Received: from Monstersaurus.local (aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net [82.37.23.78]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9BC66F02; Tue, 10 Oct 2023 02:51:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1696899093; bh=tDl8dQbSLOdU2vIuvYIAxnS8VvsF93CmOO6YTQ/B+Dc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TZglu5jKFXXyGhPtduqeBPjPLLbK0aaT1Y0KEEdOR2A5CtTBVMnwRcMd0EsdhcGSi 3FhL3w8P7mday7fuDxW3BNgx6o1JxSJpbbivdvtk3/pC4lOJOZoVO/5MjOsTJF0oqC /YbjlloL8jH3tesqoZpuRIo8kwAlT+96Ou00hphA= From: Kieran Bingham To: linux-media@vger.kernel.org, devicetree@vger.kernel.org Cc: Kieran Bingham , "Paul J. Murphy" , Daniele Alessandrelli , Sakari Ailus , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 3/5] media: i2c: imx335: Implement get selection API Date: Tue, 10 Oct 2023 01:51:24 +0100 Message-Id: <20231010005126.3425444-4-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231010005126.3425444-1-kieran.bingham@ideasonboard.com> References: <20231010005126.3425444-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 X-Spam-Status: No, score=4.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 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]); Mon, 09 Oct 2023 17:52:19 -0700 (PDT) X-Spam-Level: **** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779327715090198119 X-GMAIL-MSGID: 1779327715090198119 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. Signed-off-by: Kieran Bingham Reviewed-by: Umang Jain --- drivers/media/i2c/imx335.c | 44 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c index bf12b9b69fce..026777eb362e 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 @@ -651,6 +659,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 @@ -864,6 +907,7 @@ 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, .get_fmt = imx335_get_pad_format, .set_fmt = imx335_set_pad_format, };