From patchwork Fri Jun 9 05:45:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "G.N. Zhou (OSS)" X-Patchwork-Id: 13273237 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 2DD0FC7EE29 for ; Fri, 9 Jun 2023 05:40:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237066AbjFIFko (ORCPT ); Fri, 9 Jun 2023 01:40:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229493AbjFIFkk (ORCPT ); Fri, 9 Jun 2023 01:40:40 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2077.outbound.protection.outlook.com [40.107.8.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C1CE2D7C for ; Thu, 8 Jun 2023 22:40:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oOkpVAbaFxJyo7etFJDUOLBWBXTpG+H044haTZiJTK/gPl0TxpEu0y0egKoz5BqpC1+4WkTyTO98RYyslZ5Fswtx8/y9Zfw2njb6Yg2v53oCqZmuLfJlgXm78xgLTsb9ee0i5mHhJdAb6Kz2jxgdgKMAOuUfjQC9qc3e4R3/98BlEpWtCsM6Y79QxAEXiimibThKc8p3RFaQZRp6TuhJjLSn2YGqUEDfsVSMyYIAK5mKIi9+rh/YnZIzcBM296PHD6JmDPFKCaVPlpc+juV8mkPWGXmg6SDSEc/bcex0qR7K1inBRQjlmyPkiGIusAW0qqWeDW70w95KEUBxEou14Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1eZKymzF+Mmk96FM/uniNFWiVpD6qX4GA+c+hlSLr8A=; b=Hsq+wdbrpsqmvW5cGpkNY/Gj5LF9K//h7OZTTVKQoQQ4lg+paIe1wA41zeojltgVxRseu6P6+EcXJQXCwEein8KGcX3fMlg36/MzagfOq+FUHl5dZ6xVdPPlBC0Yz8+RP4NQEhhqzIlCwPfezIxgpypjtCrwnlUlBYFjTXrPVa1kQhBoQDuX9WSS6L4ZPQO+zn0KHUi6hF4gRJfoJ2dzjMYhAP2gQ5LSn32b2Stv4AgJTXVay4XhNNHrqIZjSGyVRwQe+PxEHLBwloV+HeS2usqtflMuOalWnHvgB3q3Y7cC99cQwlrzkZ9kGh+cuH5jhJ9A1nRZg2oI9AOePopKCA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1eZKymzF+Mmk96FM/uniNFWiVpD6qX4GA+c+hlSLr8A=; b=NVGzedrfTFpS8J6KvQgMcKKNbe4X7llfxEKuyBhRLPWcyr4dBotjuAYy9PS2mA+Eqyc1x8FOtLecU2DlZYPqBuxcj4cuTbzet/huL+uawQuA57m5qJcVuPSbFFdhdVmn1bvd2c2JpjEXoSZ3Uf3jhnIzIuHk6e1hf1EwI4+gjtM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AS8PR04MB9080.eurprd04.prod.outlook.com (2603:10a6:20b:447::16) by DBBPR04MB7770.eurprd04.prod.outlook.com (2603:10a6:10:1ed::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.38; Fri, 9 Jun 2023 05:40:35 +0000 Received: from AS8PR04MB9080.eurprd04.prod.outlook.com ([fe80::1a0c:99b1:603a:e219]) by AS8PR04MB9080.eurprd04.prod.outlook.com ([fe80::1a0c:99b1:603a:e219%3]) with mapi id 15.20.6455.030; Fri, 9 Jun 2023 05:40:35 +0000 From: guoniu.zhou@oss.nxp.com To: linux-media@vger.kernel.org, jacopo.mondi@ideasonboard.com, sakari.ailus@linux.intel.com Cc: mchehab@kernel.org, slongerbeam@gmail.com, laurent.pinchart@ideasonboard.com, jacopo@jmondi.org Subject: [PATCH v2] media: ov5640: fix low resolution image abnormal issue Date: Fri, 9 Jun 2023 13:45:25 +0800 Message-Id: <20230609054525.4067113-1-guoniu.zhou@oss.nxp.com> X-Mailer: git-send-email 2.37.1 X-ClientProxiedBy: SG2PR06CA0195.apcprd06.prod.outlook.com (2603:1096:4:1::27) To AS8PR04MB9080.eurprd04.prod.outlook.com (2603:10a6:20b:447::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB9080:EE_|DBBPR04MB7770:EE_ X-MS-Office365-Filtering-Correlation-Id: d1969a13-f4ed-40fd-352c-08db68ac0c06 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hKYDFAQF453OfeKaip69b+JpGzLUiLpRj5aDDl4W3KPnqcynBSy+/UcSx03D+uDlBHa6JF72BdtTKzANW170hrM7GmnlPg+bBNi1jTptbXKY8hT6sNsvskl3kn7WzQgL/oXmeBqRbQ9qyctOwUWkzRm0Xl5EKJQi+i4OyP1wW8yoiLRvpLBSkkMhZX0bR9V2+Hl91IOaIT+w/ZNEoX0eJUBux080NQPLurvMU8W8NtHPeJ15fm3F3vSmTig3Bs425Ahg69xuL2ykKR1rdwWq67uPSxgIrrSwxvZ1dZlXEJjqGX8CuYLbwbRbamyA822fln8yWKs9/Cuz+vfghJyUtUEHpp0Bwgv8TXa8SkuoqUFSYoV3cDdWit6+cko+j2rXhqnWK47FaQghtG7TuJiHpCrSqoZPs0yKyrO3dLUEtADeWKon3tKcchsOoSN9EpBUMFqBBmenKNcxvDTXgWH7p1tDbDiwZLFmszV9rdmrV6mXlWbbByCl1/D+FMy1s1oFAQO8iJ7KZfVozXJELnlF/CqYkNHVqF5CoCuNtHZ9+6IHeZJg2to/6T3Jfn2ufmndP1aMZILfCskgVegNr/2Lb1DFUvsLiIliKh8qoy1/hy9/kmP3Y2cZrujizQl/WaX5 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR04MB9080.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(376002)(366004)(136003)(39860400002)(346002)(451199021)(2906002)(86362001)(5660300002)(6666004)(83380400001)(52116002)(6486002)(186003)(26005)(6512007)(1076003)(6506007)(9686003)(478600001)(66946007)(316002)(38350700002)(41300700001)(4326008)(2616005)(38100700002)(66556008)(66476007)(8676002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mHZ/1Mr1mOmQ4/F1LK7jqOqd3D3Reb+HAHMeE5nf4DJBZ0tnEI7UTOwfml/b52fph9eknEmBs6hT+dxZ6Z4lwnn2+KmcuMUKgTAARIspwYipHJk4WhtcxqZ8ttozGqW4T3d5qJLCCCj8ROBIXU6ptejejJgiFDULVSx2MFs4+6dBa16BBCwdXp+b4LTTpKkSEaTZePZGcZUlP6axIes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0h+S22vGyvrvc/tnCAd47MDRhCJBO96/xdvaRGlDuarXbiyBQkth+jSle2dlivVV0JXulZSSAl/GeYc8r2MY9j9JV75M5MBuyDc6luXVgXLyIUGdpDLYpD6jIUG+KclvVCysuv4kMBZuBIxIg6DMSP0iKdBSTRKEzMpkIttsO6rfbWfeAPVVnfxmRbukLtc+TEUTpmoQRRd4jwi6WrP9Gk8L8RPBJV/kr1Es0+rk3p+RsvfGOiH1mbYXT1iqT41jZF8c3saimxA/bYWF0aUIoQvgtcajb3H X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d1969a13-f4ed-40fd-352c-08db68ac0c06 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB9080.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2023 05:40:35.1140 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Nsk0zvqPTzFoYybq8H+1XvLpiHjqoTHicE9JVS6aL3ztP2epXMX/CqjO4ANXbbYQIhEgrvDR2adv8RR7WrokdQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7770 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: "Guoniu.zhou" OV5640 will output abnormal image data when work at low resolution (320x240, 176x144 and 160x120) after switching from high resolution, such as 1080P, the time interval between high and low switching must be less than 1000ms in order to OV5640 don't enter suspend state during the time. The reason is by 0x3824 value don't restore to initialize value when do resolution switching. In high resolution setting array, 0x3824 is set to 0x04, but low resolution setting array remove 0x3824 in commit db15c1957a2d ("media: ov5640: Remove duplicated mode settings"). So when do resolution switching from high to low, such as 1080P to 320x240, and the time interval is less than auto suspend delay time which means global initialize setting array will not be loaded, the output image data are abnormal. Hence move 0x3824 from ov5640_init_setting[] table to ov5640_setting_low_res[] table and also move 0x4407 0x460b, 0x460c to avoid same issue. Signed-off-by: Guoniu.zhou Reviewed-by: Jacopo Mondi --- v1->v2: 1) Move 0x4407, 0x460b, 0x460c from ov5640_init_setting[] table to ov5640_setting_low_res[] table. 2) Add mode switching test from 2592x1944 to other resolutions, the result is okay. --- drivers/media/i2c/ov5640.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c index 1536649b9e90..1bc4d72a906e 100644 --- a/drivers/media/i2c/ov5640.c +++ b/drivers/media/i2c/ov5640.c @@ -568,9 +568,7 @@ static const struct reg_value ov5640_init_setting[] = { {0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0}, {0x3000, 0x00, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3004, 0xff, 0, 0}, {0x3006, 0xc3, 0, 0}, {0x302e, 0x08, 0, 0}, {0x4300, 0x3f, 0, 0}, - {0x501f, 0x00, 0, 0}, {0x4407, 0x04, 0, 0}, - {0x440e, 0x00, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0}, - {0x4837, 0x0a, 0, 0}, {0x3824, 0x02, 0, 0}, + {0x501f, 0x00, 0, 0}, {0x440e, 0x00, 0, 0}, {0x4837, 0x0a, 0, 0}, {0x5000, 0xa7, 0, 0}, {0x5001, 0xa3, 0, 0}, {0x5180, 0xff, 0, 0}, {0x5181, 0xf2, 0, 0}, {0x5182, 0x00, 0, 0}, {0x5183, 0x14, 0, 0}, {0x5184, 0x25, 0, 0}, {0x5185, 0x24, 0, 0}, {0x5186, 0x09, 0, 0}, @@ -634,7 +632,8 @@ static const struct reg_value ov5640_setting_low_res[] = { {0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, {0x3a0e, 0x03, 0, 0}, {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x03, 0, 0}, {0x3a15, 0xd8, 0, 0}, {0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0}, - {0x4407, 0x04, 0, 0}, {0x5001, 0xa3, 0, 0}, + {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0}, + {0x3824, 0x02, 0, 0}, {0x5001, 0xa3, 0, 0}, }; static const struct reg_value ov5640_setting_720P_1280_720[] = {