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 F2FA3C636D6 for ; Thu, 2 Feb 2023 10:49:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232891AbjBBKtZ (ORCPT ); Thu, 2 Feb 2023 05:49:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232820AbjBBKtJ (ORCPT ); Thu, 2 Feb 2023 05:49:09 -0500 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on20623.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eaf::623]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 673F07C711; Thu, 2 Feb 2023 02:48:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hd0NmV9qowgEdJPuf1CbAoppsd5ze5sh4nGa8IUHui1HfvEiQvZ4ss9mUdav0XpAh7elQ5FZ25rtY6M/VHhz9OPeoo9NekDOh5qHNXHCbYyNdUKbWkfYECEsdkDppu/mAwVDrXLT03MtWgy9tDeGfOTmWK1Xtdv7v4VzFvtZl1ubExYzxdt1i3V/4lWwdZSjp/Hli/JUFOEFgMWpuS8BBcBhUmQvInFjaG/14yqIWApL6gwbVqc8exe6FBXCZ7r2ki629KtKjDGuwVe16S9QI4a9AlZAN9cqf+JoyL/umWn66gOWSo6MlHgIznSXb3ZAnBbyd+uI4xqxMKNfRTv8Hw== 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=iWwit33bqjXqSZrqWj7LtxcXi9st6ebbG/kfQ7qVqUs=; b=oagUPSntZIlMnfHuhypfPML7epB+MjhOFxt3+8zpGqZbQiEhK9DgJh7ullMpaHg/e57+lZ4vVOXuY2yKTpUUyMFgSruhPxQhzD3+iF0UL1ssCIryiAt574m2Rg3boaMKmW44aMJMsfPG2j3wWmyBh5QzJ1pcvzEba58Kp0ZAflaKEb01eZ9q/CojqQHHp4eysRO1RAcMOkhrXDtw5TMSLO86QBm1XWRT2I7rhsvthm1cI7Cq7SnrmyyvaBoT/4BKoAkaEUE6k5JPqP4BGW4+SWHGmhbF9x8Mr7pOtRaqGd+TAWT6auBbYyNGnZ4inDGxu+Hvr0p/IkLmtx5Tnp41Iw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wolfvision.net; dmarc=pass action=none header.from=wolfvision.net; dkim=pass header.d=wolfvision.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wolfvision.net; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iWwit33bqjXqSZrqWj7LtxcXi9st6ebbG/kfQ7qVqUs=; b=Q0FaJbZ/vJSco5xFn+YBM5fARaGVPv+hJ0dLy0QmdqfCOFu6iug8vSNFsz0HlfRLbMQ7lMQhqs7O9ZmX6JAexY7PaXUWn5e/zWIj8+So1g+JxJyjVjqQyxxCeshKC0TmyRmOjqsLHwk/X3VkNa5NUt/72OpE64vNP/x/CjFvKbw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from DU0PR08MB9155.eurprd08.prod.outlook.com (2603:10a6:10:416::5) by DBBPR08MB6297.eurprd08.prod.outlook.com (2603:10a6:10:20b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Thu, 2 Feb 2023 10:47:24 +0000 Received: from DU0PR08MB9155.eurprd08.prod.outlook.com ([fe80::4718:6092:e763:4219]) by DU0PR08MB9155.eurprd08.prod.outlook.com ([fe80::4718:6092:e763:4219%2]) with mapi id 15.20.6064.025; Thu, 2 Feb 2023 10:47:23 +0000 Message-ID: <8d605b82-3367-e555-90e8-64015d5a8db4@wolfvision.net> Date: Thu, 2 Feb 2023 11:47:21 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH v2 2/2] media: i2c: add imx415 cmos image sensor driver Content-Language: en-US To: Sakari Ailus Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Gerald Loacker , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Laurent Pinchart , Hans Verkuil , Marco Felsch , Mikhail Rudenko , =?UTF-8?Q?Krzysztof_Ha=c5=82asa?= , Marek Vasut References: <20230124060107.3922237-1-michael.riesch@wolfvision.net> <20230124060107.3922237-3-michael.riesch@wolfvision.net> <395807d3-e242-5779-5c6d-06d750357b8c@wolfvision.net> From: Michael Riesch In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: ZR2P278CA0003.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:50::6) To DU0PR08MB9155.eurprd08.prod.outlook.com (2603:10a6:10:416::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR08MB9155:EE_|DBBPR08MB6297:EE_ X-MS-Office365-Filtering-Correlation-Id: 3120f67e-c913-471d-53f9-08db050ade20 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2byYN9U8suTB/MZaPJITPwFDU9M2GDFFMn9ThrYFlyApqBmNHWjODmsNUGNyCEfQY3D3YSOtXXt6F5hP0PpLJGT2lifyM5K43T5xh0logLT9GJrNaEFwsej+tOI0HbzYQdN1hNMy03MZ3bCWt16g5SQvZoZjjxVNFOGWzI5LioBx38HQLDqEVtaTHsUFNKCb82GwU2kBbb6Cos6X+0aOxuLiA5DNA9t5cBiXwcESkCv5BLka/KCBs+2PbOZts5RSiqCzNSEpvXEOhQ5tmk56rMioazVNBo5h8EXXrSVR17FmyG1WBsOkS3qa8ueU2EoNqx1pHrRnBhGIRXONi2dqUCGBOHjoLKnCq6letUDcznjV6U91pqO7Py48L92C1fwP7c09R7zNLuwz5mmgIG6BcGj6kXb6b+pxyi556m4/x/idKC6kP7xbe9Q1CdliB8iASqXZpRWOgT64i0bZ1zNSfhGi/Y1CMzSyNTmfVrz9bI40EL2/xU7fbX59KIC7FnK2U0pwi5PtQAnPfwROp7npfLLF0Fxjl5cmBOqosx5QnuqlcO/DOpuzoYByjZ0JMATiIZU/3S3/NBaWbncAlsCPs23ofqwP5gkQukIKeVNxxFQoxu/wHhXCRWZIbKz1xloTbMV/i3vPwxwEcC3AsGMcGiJDcxUJBhx7rC1NoeWA9+go06zduVzt/Amrs3IbeSFohks8f3JVbNvTVbJgLJNmbpda86gz8tJvCj8xke8JmAM= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR08MB9155.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(396003)(39850400004)(346002)(136003)(376002)(366004)(451199018)(31686004)(2906002)(31696002)(8936002)(6916009)(478600001)(8676002)(38100700002)(4326008)(36756003)(44832011)(5660300002)(6486002)(186003)(2616005)(6512007)(52116002)(86362001)(53546011)(7416002)(6506007)(83380400001)(66476007)(66556008)(41300700001)(66946007)(316002)(54906003)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exch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xdjB0cmRyR2FD?= =?utf-8?B?V0EwcmF5T2RoeXQra3JseDU3RlFpaHF6ci9Ec2x4QW1KVDlhWEFCL3FDMXFG?= =?utf-8?B?SlRPdGpNcGVlYVk4dDFIV3pqSlZyZDFPeGxsdmMyZUhMQjE1RDc3R1lnNE1L?= =?utf-8?B?TTRPZ3U1QitNVWRUWHhsK096RDYzVDIzSjVFaGI0QndlNGVVczNaT1VCWGFT?= =?utf-8?B?Z3NFSkh6TktJMlQ3MVdaK29HS05yVG84OEdyeWt5Q1YvVnZRQXpKUlNzZ2ZJ?= =?utf-8?B?VjJTQS9lYi82U05NOUtiZmFRc1ZKMHZ6NlhuSU02SnFwQ1VnY2pDSER5RWVz?= =?utf-8?B?RjcrYVFhVGNuZkxGMzVZUG5hdGI3ZkNncmZDT1FwOWNCMFhTalROQ3hpdE9C?= =?utf-8?B?VXluRjlycjU3cFduVEdpVXd5VzdldVJPckdjVWtydzJxUmVNTHV4Rkg3S2xz?= =?utf-8?B?VWR1Z0JEZjVRMVpaNjNHVytPTFM4Sm5xalNEdDl6bW9YMHFINXRrVk5EaWdl?= =?utf-8?Q?qf0W1U4lup2QEVekuIX0oDQ3egvZD/qY4fsTLZiXhM=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 3120f67e-c913-471d-53f9-08db050ade20 X-MS-Exchange-CrossTenant-AuthSource: DU0PR08MB9155.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 10:47:23.8791 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e94ec9da-9183-471e-83b3-51baa8eb804f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: I/dzH04K1b/9/UkN9j3r16hxHxr+Y9pec9M6B70sGWoSPjAAxXkBCxpUbgZq2E+A52Ih70Yed2RoPqeVQ1f3e2xd521yGh6NtEze1j4W6r8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB6297 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sakari, We tried to gather more precise information from the IMX415 data sheet and support package, but these documents are super secret and equally super vague. On 2/2/23 10:01, Sakari Ailus wrote: > [...] >>>> +static int imx415_stream_on(struct imx415 *sensor) >>>> +{ >>>> + int ret; >>>> + >>>> + ret = imx415_write(sensor, IMX415_MODE, IMX415_MODE_OPERATING); >>>> + if (ret) >>>> + return ret; >>>> + >>>> + /* wait at least 24 ms for internal regulator stabilization */ >>>> + msleep(30); >>> >>> This is a very, very long time to wait for a regulator. Most probably >>> either the time is too long or we're waiting for something else. >> >> I just realized that both msleep calls are after setting the mode to >> operating, i.e., after getting the sensor out of standby. The other >> instance of this code (see below) documents that clearly, but this >> "regulator stabilization" comment here is seems wrong indeed. The data sheet mentions "Some time is required for sensor internal circuit stabilization..." and "...after internal regulator stabilization 24 ms or more." Well, there you go -- we need to wait some time or more for whatever reason :-) >> >>>> + >>>> + return imx415_write(sensor, IMX415_XMSTA, IMX415_XMSTA_START); >>>> +} >>>> [...]>> +static int imx415_subdev_init(struct imx415 *sensor) >>>> +{ >>>> + struct i2c_client *client = to_i2c_client(sensor->dev); >>>> + int ret; >>>> + >>>> + v4l2_i2c_subdev_init(&sensor->subdev, client, &imx415_subdev_ops); >>>> + >>>> + ret = imx415_ctrls_init(sensor); >>>> + if (ret < 0) >>>> + return ret; >>>> + >>>> + sensor->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; >>> >>> Add V4L2_SUBDEV_FL_HAS_EVENTS. >> >> Just for my understanding: why is this required/a good idea? >> >>>> [...] >>>> +static int imx415_identify_model(struct imx415 *sensor) >>>> +{ >>>> + int model, ret; >>>> + >>>> + /* >>>> + * While most registers can be read when the sensor is in standby, this >>>> + * is not the case of the sensor info register :-( >>>> + */ >>>> + ret = imx415_write(sensor, IMX415_MODE, IMX415_MODE_OPERATING); >>>> + if (ret < 0) >>>> + return dev_err_probe(sensor->dev, ret, >>>> + "failed to get sensor out of standby\n"); >>>> + >>>> + /* >>>> + * According to the datasheet we have to wait at least 63 us after >>>> + * leaving standby mode. But this doesn't work even after 30 ms. >>>> + * So probably this should be 63 ms and therefore we wait for 80 ms. >>>> + */ >>>> + msleep(80); >>> >>> Wow. >> >> This is the other occurrence of this long sleep. We could refactor this >> code into a imx415_wakeup() method if desired. Otherwise, we need to >> align the sleep period and the explanation at least. > > I'm ok with the code, it's just a very, very long delay. It is, and it is far from obvious how this delay comes about. The data sheet does not specify this register at all, it is described somewhere in the support package (as the comment above states a delay of 63 microseconds is mentioned). Our tests indicated that the delay a) read out the sensor info b) turn on the stream can be different. Therefore, it might make sense to use different msleep() calls as done in the v2 of our series. We'll try to get an updated data sheet to sort this issue out, but for the time being can we get v3 into mainline? Best regards, Michael