From patchwork Sun Jun 19 00:31:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 583768 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70488C433EF for ; Sun, 19 Jun 2022 00:32:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232063AbiFSAcL (ORCPT ); Sat, 18 Jun 2022 20:32:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230223AbiFSAcJ (ORCPT ); Sat, 18 Jun 2022 20:32:09 -0400 Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C88212754 for ; Sat, 18 Jun 2022 17:32:09 -0700 (PDT) Received: from tr.lan (ip-86-49-12-201.net.upcbroadband.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id A962C84011; Sun, 19 Jun 2022 02:32:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1655598727; bh=Zvcp4X4KdNsJRnyDVBfmY7McmCaxjrR0FJcA7VzhJGA=; h=From:To:Cc:Subject:Date:From; b=x/6Ijx6L5gm7KhOgbgYtMahEG5FoffZM21RSpbSZO2l45thQn4EVTYFFAQzxNqX/A Tt/TS+/P9Mr90csFKnqEPGlqXwHxRLV+1VEfkgyIR59yysVP+14eNwrfacXeo67sCP 3aXuQAbVxX9lESLwsi/Bb9pZg+xg0e41SD/J0xkNSYa2PhouD+lGFN/+Hbj0nY7YHJ fGBOKav08ra7P5MEJqd1xydHcpbjdgw+MnizDoT3RXuQrav182RsT5D74rwHij2p9n qjfROjO8daXK2KcEUrztdMZgzSy7nmzNcrpe1Q/TU5qUM17efhR/6ulZ0jO0n27hFd +oXJ8oivxZ6Cg== From: Marek Vasut To: linux-media@vger.kernel.org Cc: Marek Vasut , Laurent Pinchart , Mauro Carvalho Chehab , Sakari Ailus , Stefan Riedmueller Subject: [PATCH v2] media: mt9p031: Implement crop bounds get selection Date: Sun, 19 Jun 2022 02:31:58 +0200 Message-Id: <20220619003158.720050-1-marex@denx.de> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Implement V4L2_SEL_TGT_CROP_BOUNDS query in get_selection subdev op for this sensor. This is required e.g. to bind it to STM32MP15x DCMI. Signed-off-by: Marek Vasut Cc: Laurent Pinchart Cc: Mauro Carvalho Chehab Cc: Sakari Ailus Cc: Stefan Riedmueller Reviewed-by: Laurent Pinchart --- V2: Use min/max sizes for crop bounds --- drivers/media/i2c/mt9p031.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c index cbce8b88dbcf5..69a3165b8fb91 100644 --- a/drivers/media/i2c/mt9p031.c +++ b/drivers/media/i2c/mt9p031.c @@ -623,12 +623,20 @@ static int mt9p031_get_selection(struct v4l2_subdev *subdev, { struct mt9p031 *mt9p031 = to_mt9p031(subdev); - if (sel->target != V4L2_SEL_TGT_CROP) + switch (sel->target) { + case V4L2_SEL_TGT_CROP_BOUNDS: + sel->r.left = MT9P031_COLUMN_START_MIN; + sel->r.top = MT9P031_ROW_START_MIN; + sel->r.width = MT9P031_WINDOW_WIDTH_MAX; + sel->r.height = MT9P031_WINDOW_HEIGHT_MAX; + return 0; + case V4L2_SEL_TGT_CROP: + sel->r = *__mt9p031_get_pad_crop(mt9p031, sd_state, + sel->pad, sel->which); + return 0; + default: return -EINVAL; - - sel->r = *__mt9p031_get_pad_crop(mt9p031, sd_state, sel->pad, - sel->which); - return 0; + } } static int mt9p031_set_selection(struct v4l2_subdev *subdev,