Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp604858pxb; Tue, 5 Apr 2022 15:41:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVHkLBFQcPvPQKquhJmXnCR/0AZb/KUiUNR4IhWi2uQUXHRB03xcZZomsOH+ku2+3XLHRN X-Received: by 2002:a63:6a04:0:b0:398:6e02:60d4 with SMTP id f4-20020a636a04000000b003986e0260d4mr4611130pgc.509.1649198517127; Tue, 05 Apr 2022 15:41:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649198517; cv=none; d=google.com; s=arc-20160816; b=D7VuWf0W1aU5SnKHrawThQOxnoCZLu8UGav2YWpM5zNZO6YA8wuXdMKQrzvnJixyLS y1wfWS24QFqtj1vCQqEB9DxlnwBWMYko6NnPfPu2enXHxLSDeDF7He1v4DXg+uErQ328 cxjYq6Y9nj56jeTabgRz2v9JYsZz+7mNbO1u2ArH1sF3XANHaZ8h7R7Uh12jq2Qlah0b jLRosBNzYmOd7Dcg1+X/DMkP62HjzrkwIHY5+cPbvzKdzKxD7+6etEF01thT86BCt/5L u2jqAeFP/nQb9ASkOfW8F8cquWkqaOpSw3rSl4WTVeK+b6UoQqg+7Tu17mZkUcxzk1AF g84g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5e5c5pEO07ctt/PmLZji5HG7ECVW9074SdpIXIDhqPg=; b=aKpmjF2jfri4JmPahEOZuvPk49Vvn9vuXxlr6fF4+FIDedQYGm/JjDjbZ7lb5p0X35 LplewlUbdCYULfB88E07U79mdUo3wEBPvV/F743MO01QQKtGoOtH/Ihwy12duOOdwgEW y+o2kAeqN2yVttJ5U2yxLTAeiRxrA9p5Hu1mCyPc2Heo7kF6+KMDZV6lltlUkK/dKCll Y92tZFnL8FeStjNWZkZb+WUJ56HIbsFEy8ouiEetfsWgGkZFpEnHE4so0cMZP7nKYdc2 6I9tDZZsbvoTcW79cscT2BYdmowBcRJyoQqMgcq8P6G8FLXUe50tKkJVoTtao+uwK7S8 tQ0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZZElOt3d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k9-20020a056a00134900b004fabd831538si273518pfu.196.2022.04.05.15.41.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 15:41:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZZElOt3d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7E8012714E; Tue, 5 Apr 2022 15:23:03 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346951AbiDEOBD (ORCPT + 99 others); Tue, 5 Apr 2022 10:01:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235682AbiDEJ3d (ORCPT ); Tue, 5 Apr 2022 05:29:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FCB3E2F71; Tue, 5 Apr 2022 02:16:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EAA0561645; Tue, 5 Apr 2022 09:16:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02542C385A0; Tue, 5 Apr 2022 09:16:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150218; bh=5l6ORz8eE2NVxh7n5XMeTQ77XrdLfW9u905815LIC3s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZZElOt3doTCyCCojIhQif4JBInsMAQbEv9g6oswOEHoZY6k5w10BMJZPyemZbkz3t weAcXNhaaIv54ZqaXv7dIPcsgWKHG47uHAc5qNaVTzOcR5ZVQnna8xzjDLSy5JW5O/ CO2agx3b9avaybxPTqP4RjEZK5hFv3VrQ3v8Xl5o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Janusz Krzysztofik , Sakari Ailus , Mauro Carvalho Chehab Subject: [PATCH 5.16 0995/1017] media: ov6650: Fix crop rectangle affected by set format Date: Tue, 5 Apr 2022 09:31:48 +0200 Message-Id: <20220405070423.738331346@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Janusz Krzysztofik commit 985d2d7a482e9b64ef9643702b066da9cbd6ae8e upstream. According to subdevice interface specification found in V4L2 API documentation, set format pad operations should not affect image geometry set in preceding image processing steps. Unfortunately, that requirement is not respected by the driver implementation of set format as it was not the case when that code was still implementing a pair of now obsolete .s_mbus_fmt() / .try_mbus_fmt() video operations before they have been merged and reused as an implementation of .set_fmt() pad operation by commit 717fd5b4907a ("[media] v4l2: replace try_mbus_fmt by set_fmt"). Exclude non-compliant crop rectangle adjustments from set format try, as well as a call to .set_selection() from set format active processing path, so only frame scaling is applied as needed and crop rectangle is no longer modified. [Sakari Ailus: Rebase on subdev state patches] Fixes: 717fd5b4907a ("[media] v4l2: replace try_mbus_fmt by set_fmt") Signed-off-by: Janusz Krzysztofik Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/i2c/ov6650.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -693,11 +693,7 @@ static int ov6650_set_fmt(struct v4l2_su struct v4l2_mbus_framefmt *mf = &format->format; struct i2c_client *client = v4l2_get_subdevdata(sd); struct ov6650 *priv = to_ov6650(client); - struct v4l2_subdev_selection sel = { - .which = V4L2_SUBDEV_FORMAT_ACTIVE, - .target = V4L2_SEL_TGT_CROP, - }; - struct v4l2_rect *crop = &sel.r; + struct v4l2_rect *crop; bool half_scale; if (format->pad) @@ -721,24 +717,13 @@ static int ov6650_set_fmt(struct v4l2_su } if (format->which == V4L2_SUBDEV_FORMAT_TRY) - *crop = sd_state->pads->try_crop; + crop = &sd_state->pads->try_crop; else - *crop = priv->rect; + crop = &priv->rect; half_scale = !is_unscaled_ok(mf->width, mf->height, crop); - /* adjust new crop rectangle position against its current center */ - crop->left += (crop->width - (mf->width << half_scale)) / 2; - crop->top += (crop->height - (mf->height << half_scale)) / 2; - /* adjust new crop rectangle size */ - crop->width = mf->width << half_scale; - crop->height = mf->height << half_scale; - if (format->which == V4L2_SUBDEV_FORMAT_TRY) { - /* store new crop rectangle, hadware bound, in pad config */ - ov6650_bind_align_crop_rectangle(crop); - sd_state->pads->try_crop = *crop; - /* store new mbus frame format code and size in pad config */ sd_state->pads->try_fmt.width = crop->width >> half_scale; sd_state->pads->try_fmt.height = crop->height >> half_scale; @@ -751,12 +736,7 @@ static int ov6650_set_fmt(struct v4l2_su mf->code = sd_state->pads->try_fmt.code; } else { - int ret; - - /* apply new crop rectangle */ - ret = ov6650_set_selection(sd, NULL, &sel); - if (ret) - return ret; + int ret = 0; /* apply new media bus frame format and scaling if changed */ if (mf->code != priv->code || half_scale != priv->half_scale)