Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2220172rdb; Mon, 9 Oct 2023 17:52:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEP/SB315mEHvroXNmzQIf0H5uV3cHoaFT0NIF1ij2zgjV77H+A3P1rm7sZnyLs7dgIgFg9 X-Received: by 2002:a05:6a00:14ce:b0:68f:cdb8:ae33 with SMTP id w14-20020a056a0014ce00b0068fcdb8ae33mr22496892pfu.10.1696899142586; 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=RO0kmqljT/o54MJfSFPVNDPuS14QspVQdQlWK0Wo7Q3Akpmnrgnj6ty133N+1hlkvg MG2GAn6cW9ph9147gPdmYkyxCUg4vHG7TwO1R2KbnkgErnOZkceI8ecbpykuQec2v64n vh81aIL5aMt+gniavml2L39RlRs7p3QdEVXiHfq9IO4ZWI1YixHEJJLvHb95BWopVNM4 PRHJKG1+H56ozWjCuZsrBIeIo/V6pT31WT2QIkrCGbhHn/4sJY2OTExDclwRgD0IRD0t DSjENIwUVFLm3iAjtiHQFwuDJ2iimq/Me18Fo4qQVKCwkCR64t4H4PDU2CtOUEryoJoS rWvw== 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 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id w15-20020a056a0014cf00b0068e4a646d2csi8957033pfu.252.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 23.128.96.34 as permitted sender) client-ip=23.128.96.34; 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 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 11B0D806228D; Mon, 9 Oct 2023 17:52:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379308AbjJJAvy (ORCPT + 99 others); Mon, 9 Oct 2023 20:51:54 -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 Content-Transfer-Encoding: 8bit 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 autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Mon, 09 Oct 2023 17:52:19 -0700 (PDT) X-Spam-Level: **** 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 --- 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, }; -- 2.34.1