Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2544348iof; Wed, 8 Jun 2022 07:11:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykAzphI3VbzIbV21eNhicu7fpX0zCfj3hvxgRBzfLHz6gFgDQ9ortCfjI0SnSWve0BbWxI X-Received: by 2002:a17:90b:33c4:b0:1e8:6e2f:97a2 with SMTP id lk4-20020a17090b33c400b001e86e2f97a2mr21012358pjb.165.1654697513629; Wed, 08 Jun 2022 07:11:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654697513; cv=none; d=google.com; s=arc-20160816; b=CJCRmB1Ib4Kvki1uRTWp7A5kkoqMAH0l5Gp/yZ6kqJhE8YFS+ES40+B3YpWEuulQ7D JzyR8ZUjYIppoZtmqJzSJL6lfUhOrhOBVf/pBYX5V2heQ99X8YHsdcI5poKA58vgK6WZ l3/0vQENRmeQe0phStZtyZvWuMwlMK8CtieJksUbr1vWSR3csj1GrPum3SZBCINarLD5 yT4pJaeaqBk4uDSnr1zIy9mTBNSK+1MjIBl7uc4JR5SBB3nTLGpJVLjl0y40rxfSlZ/e GlBbf6tJsIpK75PvNhUpGBPa0sWkv5PD5upqZ+7/xG+IxxlIoLjf6FCl/EtFYhZFdd+N U/Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from; bh=6cD4MJyPLGUtg9MlCWloufoK7AdO8OaucY6wf7Z/saE=; b=oRfym+rHcOeUKHxy/NBNgvR5ymoedMkCBKIWvDzfWIZNyoLG0/x0kM1r2ME3Oh9nSB D2xJ9xZr/iGVuV12OhLrzHm1R5H04SLq1vGga6S3U8Vju1hrZttH5ufE0fGtXnQdWnk/ vp5du+NgyeiEVvXMrrJTvfYGDuFjsuKQ0vQkDDgX1Ukih9Y+PgxrQRm4HMS73C22AcZx bo82kiu0tE5ZNJ5NhAjFsjXjb8cNWCs5IFra7DVrTP+W6rVzCiPPFrUeYhb3pZe2fa/6 T5uSnplIReV8dP2++FsRYruIoFCc/3C0DSzqqeXNWotCZhNfVJXV/yCuNnMcojpd8GII mXgg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id p15-20020a17090a930f00b001e2f31e3b38si25692753pjo.34.2022.06.08.07.11.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 07:11:53 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 62F20271ABC; Wed, 8 Jun 2022 06:45:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240669AbiFHNo6 (ORCPT + 99 others); Wed, 8 Jun 2022 09:44:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240622AbiFHNoq (ORCPT ); Wed, 8 Jun 2022 09:44:46 -0400 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::222]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4EB6B0F; Wed, 8 Jun 2022 06:44:44 -0700 (PDT) Received: (Authenticated sender: foss@0leil.net) by mail.gandi.net (Postfix) with ESMTPSA id A47A34000D; Wed, 8 Jun 2022 13:44:41 +0000 (UTC) From: Quentin Schulz Cc: shawnx.tu@intel.com, mchehab@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, foss+kernel@0leil.net, Quentin Schulz Subject: [PATCH v7 4/4] media: i2c: ov5675: add .get_selection support Date: Wed, 8 Jun 2022 15:44:20 +0200 Message-Id: <20220608134420.1750530-4-foss+kernel@0leil.net> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220608134420.1750530-1-foss+kernel@0leil.net> References: <20220608134420.1750530-1-foss+kernel@0leil.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,PDS_OTHER_BAD_TLD, RDNS_NONE,SPF_HELO_NONE,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 lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Quentin Schulz The sensor has 2592*1944 active pixels, surrounded by 16 active dummy pixels and there are an additional 24 black rows "at the bottom". [2624] +-----+------------------+-----+ | | 16 dummy | | +-----+------------------+-----+ | | | | | | [2592] | | | | | | |16 | valid | 16 |[2000] |dummy| |dummy| | | [1944]| | | | | | +-----+------------------+-----+ | | 16 dummy | | +-----+------------------+-----+ | | 24 black lines | | +-----+------------------+-----+ The top-left coordinate is gotten from the registers specified in the modes which are identical for both currently supported modes. There are currently two modes supported by this driver: 2592*1944 and 1296*972. The second mode is obtained thanks to subsampling while keeping the same field of view (FoV). No cropping involved, hence the harcoded values. Signed-off-by: Quentin Schulz --- v7: - fixed incorrect V4L2_SEL_TGT_CROP_BOUNDS introduced in v6, v6: - explicit a bit more the commit log around subsampling for lower resolution modes, - (again) fixed reporting for V4L2_SEL_TGT_CROP_* thanks to Jacopo's help, v4: - explicit a bit more the commit log, - added drawing in the commit log, - fixed reporting for V4L2_SEL_TGT_CROP_* thanks to Jacopo's help, added in v3 drivers/media/i2c/ov5675.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/media/i2c/ov5675.c b/drivers/media/i2c/ov5675.c index 80840ad7bbb0..5f70ead2dd47 100644 --- a/drivers/media/i2c/ov5675.c +++ b/drivers/media/i2c/ov5675.c @@ -1121,6 +1121,31 @@ static int ov5675_get_format(struct v4l2_subdev *sd, return 0; } +static int ov5675_get_selection(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, + struct v4l2_subdev_selection *sel) +{ + if (sel->which != V4L2_SUBDEV_FORMAT_ACTIVE) + return -EINVAL; + + switch (sel->target) { + case V4L2_SEL_TGT_CROP_BOUNDS: + sel->r.top = 0; + sel->r.left = 0; + sel->r.width = 2624; + sel->r.height = 2000; + return 0; + case V4L2_SEL_TGT_CROP: + case V4L2_SEL_TGT_CROP_DEFAULT: + sel->r.top = 16; + sel->r.left = 16; + sel->r.width = 2592; + sel->r.height = 1944; + return 0; + } + return -EINVAL; +} + static int ov5675_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_mbus_code_enum *code) @@ -1170,6 +1195,7 @@ static const struct v4l2_subdev_video_ops ov5675_video_ops = { static const struct v4l2_subdev_pad_ops ov5675_pad_ops = { .set_fmt = ov5675_set_format, .get_fmt = ov5675_get_format, + .get_selection = ov5675_get_selection, .enum_mbus_code = ov5675_enum_mbus_code, .enum_frame_size = ov5675_enum_frame_size, }; -- 2.36.1