From patchwork Sun May 4 10:13:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 887347 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6069C13D for ; Sun, 4 May 2025 10:13:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746353635; cv=none; b=h8B0b0iSFEj2xGVsXZft7iTTYkv95TmCwPCQAv98UsS5mnNJl7DKKZ9uUshfyb9MVXxewkMAP6nvWLdvJcowp2MHFovufsb/1ErbvzzEUY7WZOaBTj5UElEoYWXhKro0PNX9sZmzcGD++bC7BWYS+8+ENNThjlB4QeYGAYIi3JY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746353635; c=relaxed/simple; bh=bvC0BQtfp2b9J+3XaSmjvMaLfkCLlX9XjeiHOQaAJqY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MF1Ax6Y2ziceEnnyFHCrXY1fubOW97UGr24Kizi5qEMa2etfoQ469JR6D1db5V2Spb5DIhC5TdBW++r1iiHvDXPg+ZOx97iGJmhWHygzAEdGkcL8+fxAqDdMbPeiGZKOtZMQquf1hJtAcA/8VG8RmS8mIXLs1doY7O8x0HWnTQc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=NmREyYqe; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NmREyYqe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1746353632; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6wP/8r552zwJme8w/ZtyfDKRBo0lLtYbWvY6L9kruW8=; b=NmREyYqep3e+DtXL4/Q1xxEpx7iqQvVDb0wtu/Zau4W98OMMd9KLDyehbzDn/2nY7l4HF1 YPEE7WWL3oz+7axgqLrB8tb/k5FsodOGE4yiVYq8xRzYEcVVbOqA0s19/P3MU8JaIk4F6w QbPDo8fNMtMAEUfRZIHcgYA30x5pZUc= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-640-YHljO2YvM3uULtIyKvb61g-1; Sun, 04 May 2025 06:13:47 -0400 X-MC-Unique: YHljO2YvM3uULtIyKvb61g-1 X-Mimecast-MFC-AGG-ID: YHljO2YvM3uULtIyKvb61g_1746353626 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8969D180048E; Sun, 4 May 2025 10:13:46 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.45.224.28]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8ABAA1800352; Sun, 4 May 2025 10:13:43 +0000 (UTC) From: Hans de Goede To: Laurent Pinchart , Sakari Ailus Cc: Hans de Goede , Mauro Carvalho Chehab , Mathis Foerst , linux-media@vger.kernel.org Subject: [PATCH 02/13] media: mt9m114: Add support for clock-frequency property Date: Sun, 4 May 2025 12:13:23 +0200 Message-ID: <20250504101336.18748-3-hdegoede@redhat.com> In-Reply-To: <20250504101336.18748-1-hdegoede@redhat.com> References: <20250504101336.18748-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Add support for platforms that do not have a clock provider, but instead specify the clock frequency by using the "clock-frequency" property. E.g. ACPI platforms turn the clock on/off through ACPI power-resources depending on the runtime-pm state, so there is no clock provider. Signed-off-by: Hans de Goede --- drivers/media/i2c/mt9m114.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c index 5f0b0ad8f885..be1d2ec64b89 100644 --- a/drivers/media/i2c/mt9m114.c +++ b/drivers/media/i2c/mt9m114.c @@ -377,6 +377,7 @@ struct mt9m114 { struct gpio_desc *reset; struct regulator_bulk_data supplies[3]; struct v4l2_fwnode_endpoint bus_cfg; + u32 clk_freq; struct { unsigned int m; @@ -2122,14 +2123,13 @@ static int mt9m114_power_on(struct mt9m114 *sensor) /* Perform a hard reset if available, or a soft reset otherwise. */ if (sensor->reset) { - long freq = clk_get_rate(sensor->clk); unsigned int duration; /* * The minimum duration is 50 clock cycles, thus typically * around 2µs. Double it to be safe. */ - duration = DIV_ROUND_UP(2 * 50 * 1000000, freq); + duration = DIV_ROUND_UP(2 * 50 * 1000000, sensor->clk_freq); gpiod_set_value(sensor->reset, 1); fsleep(duration); @@ -2249,7 +2249,7 @@ static int mt9m114_clk_init(struct mt9m114 *sensor) * for 16-bit per pixel, transmitted in DDR over a single lane. For * parallel mode, the sensor ouputs one pixel in two PIXCLK cycles. */ - sensor->pixrate = clk_get_rate(sensor->clk) * sensor->pll.m + sensor->pixrate = sensor->clk_freq * sensor->pll.m / ((sensor->pll.n + 1) * (sensor->pll.p + 1)); link_freq = sensor->bus_cfg.bus_type == V4L2_MBUS_CSI2_DPHY @@ -2360,13 +2360,25 @@ static int mt9m114_probe(struct i2c_client *client) return ret; /* Acquire clocks, GPIOs and regulators. */ - sensor->clk = devm_clk_get(dev, NULL); + sensor->clk = devm_clk_get_optional(dev, NULL); if (IS_ERR(sensor->clk)) { ret = PTR_ERR(sensor->clk); dev_err_probe(dev, ret, "Failed to get clock\n"); goto error_ep_free; } + if (sensor->clk) { + sensor->clk_freq = clk_get_rate(sensor->clk); + } else { + ret = fwnode_property_read_u32(dev_fwnode(dev), + "clock-frequency", + &sensor->clk_freq); + if (ret) { + dev_err_probe(dev, ret, "Failed to read clock-freq\n"); + goto error_ep_free; + } + } + sensor->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); if (IS_ERR(sensor->reset)) { ret = PTR_ERR(sensor->reset); From patchwork Sun May 4 10:13:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 887346 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC21417A2EA for ; Sun, 4 May 2025 10:13:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746353641; cv=none; b=uvY/iGh3mZy4wwJcca53p9lYhCIsmVPVZwdqnX8Lp6/7oHL5sSh6RfzG2QTk9OzEZ9IMFKR2ZbSxF/ADWYY2a26Ea5Q/RCXxhqyx0J27glgVBhCYp/iNVYUao96511CuvujfnOoiiCGRri2ZZ5O86mfgS5nX5dROebSKH+Y05kA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746353641; c=relaxed/simple; bh=LqxEWSMgWq2atOABy0fD7H/XlYIKdrcxXHJQWkvwjrI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sarbCH2yHU0ROaHRfptTB7/SS/MnRmIyDbOXjR4eMNVtTqcbO0bx6O/gZOrd1IMfwu6AjWU/QVyIDNc3KNtrWM967W8mvg2juGxJyJguooqt4Eo4I5PXo6jhuwfjWc9qkWYoE4MjOkkEjOXDqKb7vf4S2sNluZXASrSPcixADGQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=hu/u+Jnd; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hu/u+Jnd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1746353638; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F6Jc8Z4iBsA3hp0G3zs6iyupsxApdijj1MByUrqAJh4=; b=hu/u+JndsO8wkOJQo7aCJVNvnh9J+avDvDIdqPdt+CRT3cnjdjOlYGhvrLa2dr5Zcfpwgg B433TbVBAVXMb3IDSNDtmkZPx61hljrQsdfXxq+fCvCa2XWP+95CNks8BIZjplntRLu+6E BywXmjN7uZb6B9NrTfRGhBZVZEpz2x4= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-517-kjTbCInTO02oc_xlgjK6Qg-1; Sun, 04 May 2025 06:13:53 -0400 X-MC-Unique: kjTbCInTO02oc_xlgjK6Qg-1 X-Mimecast-MFC-AGG-ID: kjTbCInTO02oc_xlgjK6Qg_1746353632 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F3FD618004A7; Sun, 4 May 2025 10:13:51 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.45.224.28]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CAB2A18001D5; Sun, 4 May 2025 10:13:49 +0000 (UTC) From: Hans de Goede To: Laurent Pinchart , Sakari Ailus Cc: Hans de Goede , Mauro Carvalho Chehab , Mathis Foerst , linux-media@vger.kernel.org Subject: [PATCH 04/13] media: mt9m114: Lower minimum vblank value Date: Sun, 4 May 2025 12:13:25 +0200 Message-ID: <20250504101336.18748-5-hdegoede@redhat.com> In-Reply-To: <20250504101336.18748-1-hdegoede@redhat.com> References: <20250504101336.18748-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 As the comment above the defines says, the minimum values are undocumented so the lowest values seen in register lists are used. The version of the mt9m114 driver shipped together with the atomisp code uses 21 for vblank in its register lists, lower MT9M114_MIN_VBLANK accordingly. Signed-off-by: Hans de Goede Reviewed-by: Laurent Pinchart --- drivers/media/i2c/mt9m114.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c index 9fdfd90afc22..b40142aed3e8 100644 --- a/drivers/media/i2c/mt9m114.c +++ b/drivers/media/i2c/mt9m114.c @@ -324,13 +324,13 @@ /* * The minimum amount of horizontal and vertical blanking is undocumented. The - * minimum values that have been seen in register lists are 303 and 38, use + * minimum values that have been seen in register lists are 303 and 21, use * them. * * Set the default to achieve 1280x960 at 30fps with a 48 MHz pixclock. */ #define MT9M114_MIN_HBLANK 303 -#define MT9M114_MIN_VBLANK 38 +#define MT9M114_MIN_VBLANK 21 #define MT9M114_DEF_HBLANK 323 #define MT9M114_DEF_VBLANK 39 From patchwork Sun May 4 10:13:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 887345 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89192193436 for ; Sun, 4 May 2025 10:14:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746353645; cv=none; b=lT3ssBueG471y3LpZHFYLZhbwFO0Nbn+4J3eOkPKg88bxyZXLBFT8qxQsuorKDGkkmqoXEuDrx0PXIkKqSDFJbOCtIAJAaJGdw6apMUDIuws4750srHoYlK5NB1cT9HvMkzntED2lakPA2AKhqdjR75G6YJDMvrmwwkEms181ow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746353645; c=relaxed/simple; bh=vyn+DDC7SkIx5eEVofgyHS6mFvGswWa+sCfodU3Nq3k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=O1y8fsQAs7+/Fi+z+PpOKNMIDKCVSeLNv8xhWXJsNrIACI3aCYuvpf7oTO7KlJR5zl64OyfQak+2fWIU9wkaS/FMz65BMQv9u+3N7A085AQSMaO9mX4WCWPaF9ii0j1XpWfZDCYunLFWmk08oCVbak2jb00ERzBPXbaewelxgP8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Pyn90OoU; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Pyn90OoU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1746353642; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vgoKdbjwnhfhBfLTf3YreY3wtiPcWI+0JOVcMIXy7HI=; b=Pyn90OoU2jskQDBj6ZRaWmbGmfqoxZBb77Q3iYKB7D+Hem41rzP6saPjwtEetskD2YElhB rHKAHp20GYVzED6ljtaxUjTj+Xm3dNigpPpJjwmlEAjc5nplzcs4tu7c0PFJZqEIeM+eWE BypQML64A/0US2mmQ4JblYNWzcn45ss= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-136-8q2IXuqlNGyoRoAMf4Hqpw-1; Sun, 04 May 2025 06:13:59 -0400 X-MC-Unique: 8q2IXuqlNGyoRoAMf4Hqpw-1 X-Mimecast-MFC-AGG-ID: 8q2IXuqlNGyoRoAMf4Hqpw_1746353638 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AAE2F1800446; Sun, 4 May 2025 10:13:57 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.45.224.28]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 46DFD1800352; Sun, 4 May 2025 10:13:54 +0000 (UTC) From: Hans de Goede To: Laurent Pinchart , Sakari Ailus Cc: Hans de Goede , Mauro Carvalho Chehab , Mathis Foerst , linux-media@vger.kernel.org Subject: [PATCH 06/13] media: mt9m114: Tweak default hblank and vblank for more accurate fps Date: Sun, 4 May 2025 12:13:27 +0200 Message-ID: <20250504101336.18748-7-hdegoede@redhat.com> In-Reply-To: <20250504101336.18748-1-hdegoede@redhat.com> References: <20250504101336.18748-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 The PLL gets programmed to achieve a 48 MHz pixelclock, with the original vblank + hblank defaults this results in a fps of: 48000000 / ((1296 + 307) * (976 + 23) = 29.974 fps Tweak the defaults to get closer to 30 fps: 48000000 / ((1296 + 308) * (976 + 21) = 30.015 fps This improves things from being 0.026 fps too low to 0.015 fps too high. Signed-off-by: Hans de Goede Reviewed-by: Laurent Pinchart --- drivers/media/i2c/mt9m114.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c index 52337c719e22..ba8b7660f88a 100644 --- a/drivers/media/i2c/mt9m114.c +++ b/drivers/media/i2c/mt9m114.c @@ -331,8 +331,8 @@ */ #define MT9M114_MIN_HBLANK 303 #define MT9M114_MIN_VBLANK 21 -#define MT9M114_DEF_HBLANK 307 -#define MT9M114_DEF_VBLANK 23 +#define MT9M114_DEF_HBLANK 308 +#define MT9M114_DEF_VBLANK 21 #define MT9M114_DEF_FRAME_RATE 30 #define MT9M114_MAX_FRAME_RATE 120 From patchwork Sun May 4 10:13:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 887344 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C40141A23BA for ; Sun, 4 May 2025 10:14:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746353650; cv=none; b=ee5yX9Fm9jFyEflpcgl/5S1coYbBVhs+dVM4+IYzeKaZ8RucN0JQ5bclf0pb3W3bOqFuPUnmOaiTg0aMLHRC2GrKqZ1DiLc+ExtvVhEJMZ4fxmEr3VslDTt7IVcXenZdwsiMXMrND+eA4dRk2dc/w42T8Mg5raBPOVdCieTNPyc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746353650; c=relaxed/simple; bh=aCJXRlNiHCKdef3iolamO6INkCu0doUgW+ue4UDKKu4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ouaqJHuiPYjV9S9DbcHPt81dKfFPjVLNMn8ZqLx9pJH0IT+B4uCSl7hpJnODnper4VvOpGbQFAG1E4XFj/ZWIXNw/Esy/Dl+j3S/xfU636hteltRiu0kcU50ec0o2cZVIIBXx0mXdHEHLSXjiznPDQkILGGYMVI9EeoSKCvdzIE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=eQLTXI1I; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="eQLTXI1I" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1746353647; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GbEjBUZ5UDkw7aTvBxao1bCKPxFAdmSmmU19A2ESQPs=; b=eQLTXI1IDORVSa9nDEaGZanxzQtttqUVfmZLoZD4TjqoRDtJgqtw2Vh+sMQd5MlvGBwRk6 bgXZHq1gI7ph8VMbVObqTssLsY59P+0R9AwgwCRMIsUSck9LHByuhbMBOY9BzMYEmS6V1l pkb6OiTM7F27k8ZRBwAK92vDHw2/WKg= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-448-al00gUUGNyqqYBtrkduxdQ-1; Sun, 04 May 2025 06:14:04 -0400 X-MC-Unique: al00gUUGNyqqYBtrkduxdQ-1 X-Mimecast-MFC-AGG-ID: al00gUUGNyqqYBtrkduxdQ_1746353642 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CE68419560BB; Sun, 4 May 2025 10:14:02 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.45.224.28]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B06821800352; Sun, 4 May 2025 10:14:00 +0000 (UTC) From: Hans de Goede To: Laurent Pinchart , Sakari Ailus Cc: Hans de Goede , Mauro Carvalho Chehab , Mathis Foerst , linux-media@vger.kernel.org Subject: [PATCH 08/13] media: mt9m114: Avoid a reset low spike during probe() Date: Sun, 4 May 2025 12:13:29 +0200 Message-ID: <20250504101336.18748-9-hdegoede@redhat.com> In-Reply-To: <20250504101336.18748-1-hdegoede@redhat.com> References: <20250504101336.18748-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 mt9m114_probe() requests the reset GPIO in output low state: sensor->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); and then almost immediately afterwards calls mt9m114_power_on() which does: gpiod_set_value(sensor->reset, 1); fsleep(duration); gpiod_set_value(sensor->reset, 0); which means that if the reset pin was high before this code runs that it will very briefly be driven low because of passing GPIOD_OUT_LOW when requesting the GPIO only to be driven high again possibly directly after that. Such a very brief driving low of the reset pin may put the chip in a confused state. Request the GPIO in high (reset the chip) state instead to avoid this, turning the initial gpiod_set_value() in mt9m114_power_on() into a no-op. and the fsleep() ensures that it will stay high long enough to properly reset the chip. Signed-off-by: Hans de Goede --- drivers/media/i2c/mt9m114.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c index be3e7bb44ad8..43efcbdf614e 100644 --- a/drivers/media/i2c/mt9m114.c +++ b/drivers/media/i2c/mt9m114.c @@ -2412,7 +2412,7 @@ static int mt9m114_probe(struct i2c_client *client) } } - sensor->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); + sensor->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); if (IS_ERR(sensor->reset)) { ret = PTR_ERR(sensor->reset); dev_err_probe(dev, ret, "Failed to get reset GPIO\n"); From patchwork Sun May 4 10:13:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 887343 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2151C193436 for ; Sun, 4 May 2025 10:14:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746353655; cv=none; b=ntmOvuWZGmXsnU40VeoJQYRxsK3YtgqTu9qT7OS0dsV0gVlZbSQtCCTyp7GifatMAsG9UlCiRLuRi69SlTZmZLWLL/yFo0m5dRpq9i77N26Nv6MaudyXSZYKk/MHiAbPxfVMQaoL7QCKABgyTwQQ/Q0XLqQOYDVV9rtD+Zea5bo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746353655; c=relaxed/simple; bh=T5k9q2djfs9UhMaFc7+o4FGkxOnhwVtoKkI+S7f/6W0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DOpKKDQ4i+DpL7hSUfntH+hMJd63ZDK8kVBEA7e+I70NT2g9U7eVlFedqvGUUzxCw4gNpkJU4JrJSGj6ERoXAmJxwQcCYDRulfv3tD5eEZFVdZwG7EWDlInDFsEADBBv7ogfFmv3Xa8VT1C8mcNCiHovkHKd3HVWPh/3nyKmvJ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=dkZ4dZJp; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dkZ4dZJp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1746353652; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2FRShK50C1CbTfOcTcqcTH2Iiq263DOCt3b+mBJ1vHo=; b=dkZ4dZJpZb4hjjlCF4v03mPDVmX7/X4crR2n5kx4AB9TnVDvAV0NLLJjYZYSSxoZXsuu+p x/p+h9GTd+FhOuH5BqJIcZs8vs24X5+iQeIB7rNx4p8Q8wqJJdSsvBJUyKBq0k8IUvuTad 8uwR+tp9N19qxA+aTfN7SCle56BQ7kw= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-474-U2zKpWQzOwmdYHxvZ44ytg-1; Sun, 04 May 2025 06:14:09 -0400 X-MC-Unique: U2zKpWQzOwmdYHxvZ44ytg-1 X-Mimecast-MFC-AGG-ID: U2zKpWQzOwmdYHxvZ44ytg_1746353648 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5748519560BB; Sun, 4 May 2025 10:14:08 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.45.224.28]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3980F1800352; Sun, 4 May 2025 10:14:05 +0000 (UTC) From: Hans de Goede To: Laurent Pinchart , Sakari Ailus Cc: Hans de Goede , Mauro Carvalho Chehab , Mathis Foerst , linux-media@vger.kernel.org Subject: [PATCH 10/13] media: mt9m114: Fix scaler bypass mode Date: Sun, 4 May 2025 12:13:31 +0200 Message-ID: <20250504101336.18748-11-hdegoede@redhat.com> In-Reply-To: <20250504101336.18748-1-hdegoede@redhat.com> References: <20250504101336.18748-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 As indicated by the comment in mt9m114_ifp_set_fmt(): /* If the output format is RAW10, bypass the scaler. */ if (format->code == MEDIA_BUS_FMT_SGRBG10_1X10) ... The intend of the driver is that the scalar is bypassed when the ISP source/output pad's pixel-format is set to MEDIA_BUS_FMT_SGRBG10_1X10. This patch makes 2 changes which are required to get this to work properly: 1. Set the MT9M114_CAM_OUTPUT_FORMAT_BT656_CROP_SCALE_DISABLE bit in the MT9M114_CAM_OUTPUT_FORMAT register. 2. Disable cropping/composing by setting crop and compose selections on the ISP sink/input format to the format widthxheight @ 0x0. Signed-off-by: Hans de Goede --- drivers/media/i2c/mt9m114.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c index fa7c2137c6ba..2ebd115b2ddf 100644 --- a/drivers/media/i2c/mt9m114.c +++ b/drivers/media/i2c/mt9m114.c @@ -468,7 +468,8 @@ static const struct mt9m114_format_info mt9m114_format_infos[] = { /* Keep the format compatible with the IFP sink pad last. */ .code = MEDIA_BUS_FMT_SGRBG10_1X10, .output_format = MT9M114_CAM_OUTPUT_FORMAT_BAYER_FORMAT_RAWR10 - | MT9M114_CAM_OUTPUT_FORMAT_FORMAT_BAYER, + | MT9M114_CAM_OUTPUT_FORMAT_FORMAT_BAYER + | MT9M114_CAM_OUTPUT_FORMAT_BT656_CROP_SCALE_DISABLE, .flags = MT9M114_FMT_FLAG_PARALLEL | MT9M114_FMT_FLAG_CSI2, } }; @@ -796,7 +797,7 @@ static int mt9m114_configure(struct mt9m114 *sensor, const struct v4l2_mbus_framefmt *ifp_format; const struct v4l2_rect *ifp_crop; const struct v4l2_rect *ifp_compose; - unsigned int hratio, vratio; + unsigned int border, hratio, vratio; u64 output_format; u64 read_mode; int ret = 0; @@ -856,10 +857,12 @@ static int mt9m114_configure(struct mt9m114 *sensor, * by demosaicing that are taken into account in the crop rectangle but * not in the hardware. */ + border = (ifp_format->code == MEDIA_BUS_FMT_SGRBG10_1X10) ? 0 : 4; + cci_write(sensor->regmap, MT9M114_CAM_CROP_WINDOW_XOFFSET, - ifp_crop->left - 4, &ret); + ifp_crop->left - border, &ret); cci_write(sensor->regmap, MT9M114_CAM_CROP_WINDOW_YOFFSET, - ifp_crop->top - 4, &ret); + ifp_crop->top - border, &ret); cci_write(sensor->regmap, MT9M114_CAM_CROP_WINDOW_WIDTH, ifp_crop->width, &ret); cci_write(sensor->regmap, MT9M114_CAM_CROP_WINDOW_HEIGHT, @@ -898,7 +901,8 @@ static int mt9m114_configure(struct mt9m114 *sensor, MT9M114_CAM_OUTPUT_FORMAT_BAYER_FORMAT_MASK | MT9M114_CAM_OUTPUT_FORMAT_FORMAT_MASK | MT9M114_CAM_OUTPUT_FORMAT_SWAP_BYTES | - MT9M114_CAM_OUTPUT_FORMAT_SWAP_RED_BLUE); + MT9M114_CAM_OUTPUT_FORMAT_SWAP_RED_BLUE | + MT9M114_CAM_OUTPUT_FORMAT_BT656_CROP_SCALE_DISABLE); output_format |= ifp_info->output_format; cci_write(sensor->regmap, MT9M114_CAM_OUTPUT_FORMAT, @@ -1805,6 +1809,7 @@ static int mt9m114_ifp_set_fmt(struct v4l2_subdev *sd, { struct mt9m114 *sensor = ifp_to_mt9m114(sd); struct v4l2_mbus_framefmt *format; + struct v4l2_rect *crop; format = v4l2_subdev_state_get_format(state, fmt->pad); @@ -1825,8 +1830,15 @@ static int mt9m114_ifp_set_fmt(struct v4l2_subdev *sd, format->code = info->code; /* If the output format is RAW10, bypass the scaler. */ - if (format->code == MEDIA_BUS_FMT_SGRBG10_1X10) + if (format->code == MEDIA_BUS_FMT_SGRBG10_1X10) { *format = *v4l2_subdev_state_get_format(state, 0); + crop = v4l2_subdev_state_get_crop(state, 0); + crop->left = 0; + crop->top = 0; + crop->width = format->width; + crop->height = format->height; + *v4l2_subdev_state_get_compose(state, 0) = *crop; + } } fmt->format = *format; @@ -1846,6 +1858,10 @@ static int mt9m114_ifp_get_selection(struct v4l2_subdev *sd, if (sel->pad != 0) return -EINVAL; + /* Crop and compose are not supported when bypassing the scaler */ + if (v4l2_subdev_state_get_format(state, 1)->code == MEDIA_BUS_FMT_SGRBG10_1X10) + return -EINVAL; + switch (sel->target) { case V4L2_SEL_TGT_CROP: sel->r = *v4l2_subdev_state_get_crop(state, 0); @@ -1906,6 +1922,10 @@ static int mt9m114_ifp_set_selection(struct v4l2_subdev *sd, if (sel->pad != 0) return -EINVAL; + /* Crop and compose cannot be changed when bypassing the scaler */ + if (v4l2_subdev_state_get_format(state, 1)->code == MEDIA_BUS_FMT_SGRBG10_1X10) + return -EINVAL; + format = v4l2_subdev_state_get_format(state, 0); crop = v4l2_subdev_state_get_crop(state, 0); compose = v4l2_subdev_state_get_compose(state, 0); From patchwork Sun May 4 10:13:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 887342 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 852BE1A0B0E for ; Sun, 4 May 2025 10:14:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746353663; cv=none; b=rErTCM99OnoiFVs8KqK3mUepd57CJeDtGbm72U9/BQcJ7UjIBblfxsqzCHcDAAfd+IKqxSIl0GRahTTvZTd8/ixPo+fPwcbP80YzvtvYPv0//26yihhgF2n5yzIYCSA7G3a2RiJ2miiaOQ//4FM6vmaCxbpRrkAV429/kYqrVrA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746353663; c=relaxed/simple; bh=qd5/g/AJYIODv9irBFsMwq0+F/SINibZrn8bfBcLZXo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y/QZZVxF1KUetTlaOZ96aEeNQJWrkN8Du+CjSmYgHDsMGh5+P3AgsKVeYeFydxxLkPJrLLaQOQxRIWf+WZN1AX92ZHeJ1dh+hj6vMOoZ9MdPLU6LEHaIvA8KHfxqE6qDLA7kU8hLW0J5fKmh4yuDTROZIwUiMPx7IHEVOJ2Wz4E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=h9qHH7V1; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="h9qHH7V1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1746353658; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wLCdMVtARY4bPj489vmIhB6NUFFAUV6TVgaq2tIKtxM=; b=h9qHH7V1XazjuVJUl4KwmIK96nxscctYdnIAwLubbULI1yTVsrsY3qjyZGHfzMsorz10tA h3OsZ7iUYI5driVZ7zeyhzBgF0SoKqBzs24gNNagtHwef+WCw7bcz5Ex0dfBSW8dSfmWfa APGKHLCS1yw01v9WW54JniOGmyehO3c= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-151-r8hW-Jz8NkiUquhHwAA8NQ-1; Sun, 04 May 2025 06:14:12 -0400 X-MC-Unique: r8hW-Jz8NkiUquhHwAA8NQ-1 X-Mimecast-MFC-AGG-ID: r8hW-Jz8NkiUquhHwAA8NQ_1746353651 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1256E1956089; Sun, 4 May 2025 10:14:11 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.45.224.28]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D13261800352; Sun, 4 May 2025 10:14:08 +0000 (UTC) From: Hans de Goede To: Laurent Pinchart , Sakari Ailus Cc: Hans de Goede , Mauro Carvalho Chehab , Mathis Foerst , linux-media@vger.kernel.org Subject: [PATCH 11/13] media: mt9m114: Drop start-, stop-streaming sequence from initialize Date: Sun, 4 May 2025 12:13:32 +0200 Message-ID: <20250504101336.18748-12-hdegoede@redhat.com> In-Reply-To: <20250504101336.18748-1-hdegoede@redhat.com> References: <20250504101336.18748-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Drop the start-, stop-streaming sequence from initialize. When streaming is started with a runtime-suspended sensor, mt9m114_start_streaming() will runtime-resume the sensor which calls mt9m114_initialize() immediately followed by calling mt9m114_set_state(ENTER_CONFIG_CHANGE). This results in the following state changes in quick succession: mt9m114_set_state(ENTER_CONFIG_CHANGE) -> transitions to STREAMING mt9m114_set_state(ENTER_SUSPEND) -> transitions to SUSPENDED mt9m114_set_state(ENTER_CONFIG_CHANGE) -> transitions to STREAMING these quick state changes confuses the CSI receiver on atomisp devices causing streaming to not work. Drop the state changes from mt9m114_initialize() so that only a single mt9m114_set_state(ENTER_CONFIG_CHANGE) call is made when streaming is started with a runtime-suspend sensor. This means that the sensor may have config changes pending when mt9m114_runtime_suspend() gets called the first time after mt9m114_probe(), when streaming was not started within the 1 second runtime-pm timeout. Keep track of this and do the ENTER_CONFIG_CHANGE + ENTER suspend from mt9m114_runtime_suspend() if necessary. Signed-off-by: Hans de Goede --- drivers/media/i2c/mt9m114.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c index 2ebd115b2ddf..28c5a5752621 100644 --- a/drivers/media/i2c/mt9m114.c +++ b/drivers/media/i2c/mt9m114.c @@ -391,6 +391,7 @@ struct mt9m114 { unsigned int pixrate; bool streaming; + bool config_change_pending; /* Pixel Array */ struct { @@ -776,14 +777,7 @@ static int mt9m114_initialize(struct mt9m114 *sensor) if (ret < 0) return ret; - ret = mt9m114_set_state(sensor, MT9M114_SYS_STATE_ENTER_CONFIG_CHANGE); - if (ret < 0) - return ret; - - ret = mt9m114_set_state(sensor, MT9M114_SYS_STATE_ENTER_SUSPEND); - if (ret < 0) - return ret; - + sensor->config_change_pending = true; return 0; } @@ -958,6 +952,7 @@ static int mt9m114_start_streaming(struct mt9m114 *sensor, if (ret) goto error; + sensor->config_change_pending = false; sensor->streaming = true; return 0; @@ -2251,6 +2246,14 @@ static int __maybe_unused mt9m114_runtime_suspend(struct device *dev) struct v4l2_subdev *sd = dev_get_drvdata(dev); struct mt9m114 *sensor = ifp_to_mt9m114(sd); + if (sensor->config_change_pending) { + /* mt9m114_set_state() prints errors itself, no need to check */ + mt9m114_set_state(sensor, + MT9M114_SYS_STATE_ENTER_CONFIG_CHANGE); + mt9m114_set_state(sensor, + MT9M114_SYS_STATE_ENTER_SUSPEND); + } + mt9m114_power_off(sensor); return 0;