From patchwork Fri Dec 8 15:07:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 175852 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp5516474vqy; Fri, 8 Dec 2023 07:08:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IFAGwjBo0RC87hUT8KGdfxGNOW7Jx4GFXrCkCfXQkaPQIDntH0GrstKh4FuPGVbdDglidWF X-Received: by 2002:a17:903:2301:b0:1d0:6ffe:1e91 with SMTP id d1-20020a170903230100b001d06ffe1e91mr149595plh.116.1702048123382; Fri, 08 Dec 2023 07:08:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702048123; cv=none; d=google.com; s=arc-20160816; b=Uh8miPcwmpS9l19/cXa9O5oUbceFb8Qn/qCWGs1uWY6kcolNRL0W70qn5QRFonV401 /637F+jb2cdlau3pqVURRErchqHDEbXdrPuNpFRE4/G+qRs3vA0ktvDQdfjoKhNHD4gD uGUn1GTLIj06/kedPZR7YwF+dQBgYHyVBP2eILGj5JNxt1b5PixBudiCRaqxp2lI88sl FCDS0sd02s/5oex5PGFb5CgJ+faaRL+179cFBl98yg6djwiHsohtB+xy01n5uUr9vG42 rttRUb0334Xg/c4mW3ls6qUVIivY1u7Y5ueAmj4CYoTPxkrO6rqqo8v/XOGU5BqJqqjK 5ihA== 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=ptIuSn2bwfvIK2DVyAa1CAnL/Kzxp+jTzK/JY173OvY7PRfCYA37H9EqpDTAko3MH2 WD9mD7NFk37XeUPs81Br29d7A+cVzbk1LjzzOvQecdrqWjBUza1n3xbOENZ2TrwUSCG9 3hW+n+5WhCIeE/741/xNV2qITvcVNtppdqFx8l+4I4lutQ0Sj67XkMsudg+X71yAmv74 OU1clnUU+S0fFLRb1wYqT+ylVp3IZYTzEGqICYTc4UAvdYX+ZtUFhuBplgFM+o7nSP/Q WSu34yeC3OPW0vtTRv4I4gd38Xi8VmsRENA1epl65ZeEu+G1f9sS/Ss7s56tquqa6sqc 6AWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=GIWbQKZR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id jn3-20020a170903050300b001d06e87b213si1665495plb.184.2023.12.08.07.08.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 07:08:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=GIWbQKZR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id DF32C811545E; Fri, 8 Dec 2023 07:08:39 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1574212AbjLHPIP (ORCPT + 99 others); Fri, 8 Dec 2023 10:08:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1574185AbjLHPIK (ORCPT ); Fri, 8 Dec 2023 10:08:10 -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 6B38010DE; Fri, 8 Dec 2023 07:08:16 -0800 (PST) Received: from umang.jain (unknown [103.251.226.108]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CC0B91435; Fri, 8 Dec 2023 16:07:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1702048053; bh=v4zXIcoXuUwhPMrAke1jILyP8oPZPN1RS9zYrSyz7ak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GIWbQKZRW9UuEttt6SO7ArZdTB+5QWb0akEHtalYJZjYnfeLHlIZs2shQQsAWSuDC tgDW287BnP69EfmFnUG/o4om2muBsqVNazehX6Od5F2+SkcXhUj6ZKLgsvnSxSCrVv yOkPLhl7iolYwFcef1ZzmaUQLR2ryogZybm0giqI= 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 v3 5/8] media: i2c: imx335: Implement get selection API Date: Fri, 8 Dec 2023 20:37:51 +0530 Message-ID: <20231208150756.124720-6-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231208150756.124720-1-umang.jain@ideasonboard.com> References: <20231208150756.124720-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 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=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Fri, 08 Dec 2023 07:08:40 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784726812504259096 X-GMAIL-MSGID: 1784726812504259096 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, };