From patchwork Sat May 31 16:31:36 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: 893719 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 47DC917F4F6 for ; Sat, 31 May 2025 16:31:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748709119; cv=none; b=flS+QkcCPoYAFjSfONvJWye8dYDdlyHRTBa1gOopRm+maKj7ZBW79Tbwcr+wppIY02RaU7vF8s5VovoDXlYaNVo9oMWhtnNZY4JguG3xZBJxh+m+8m3Abvnhyj/P9xZWU58HPa2JVHMTgOE3I3F9GtTFf5jod/Dbf4koxK4FKL8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748709119; c=relaxed/simple; bh=H1hVFrLqQx9qxOhe1aNvAQrEbPdB21UNiSFh2xSwzRM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e8f8X7PPNk12epOz+AEO6jydYO6sK9/4QRjlwaS4KsLSnHaMa0EFtGyjW7w01HcaA8xuMPcp6UvtffjR8XqCqd03T6YmYxQHBi9sIF1HYOTG0BFsdZFcQEjD+zxd+TMiW2xRgYA6xyFM6z6IbP1YY+GGtlRwm/ARpVJSekkKxeo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZQKE0V/z; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZQKE0V/z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85826C4CEEF; Sat, 31 May 2025 16:31:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748709119; bh=H1hVFrLqQx9qxOhe1aNvAQrEbPdB21UNiSFh2xSwzRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZQKE0V/zlNDlH5LgkTNqqpz9WdCIr+e/HB2lFyhTRrt4pf9uSiHN0tkqk+PJRcI5e GwOJgtobavdjLnWApObogDEjv1S5AjdQQPt8lB93tyYi3QHx0gfARdSov9HhT32kbs ncjSzEwaFSP40DHH+CBc5oXmXOAk5DjotsLmdTMXigP9Gzzj5qPTmwXn8CTD1eDZmT 9FtOmd5SiXIjdB0+IQrK0KYp+vpSQdneMn/3TUEHGwPBvB4wFCEuJJWedAdgzEu1EL 6PYsUwEUEtACbp6y5TKxiybtcFHpLlT/w1YyRR6WjKPXPitJuFtLkP9ttenO4wcUny Hj7cRIbqFhvFg== From: Hans de Goede To: Sakari Ailus , Laurent Pinchart Cc: Hans de Goede , Mathis Foerst , Mauro Carvalho Chehab , linux-media@vger.kernel.org, Hans de Goede Subject: [PATCH v2 01/12] media: aptina-pll: Debug log p1 min and max values Date: Sat, 31 May 2025 18:31:36 +0200 Message-ID: <20250531163148.83497-2-hansg@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250531163148.83497-1-hansg@kernel.org> References: <20250531163148.83497-1-hansg@kernel.org> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Make aptina_pll_calculate() debug log the calculated p1 min and max values, this makes it easier to see how the m, n and p1 values were chosen. Reviewed-by: Laurent Pinchart Signed-off-by: Hans de Goede --- drivers/media/i2c/aptina-pll.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/i2c/aptina-pll.c b/drivers/media/i2c/aptina-pll.c index b1f89bbf9d47..cd2ed4583c97 100644 --- a/drivers/media/i2c/aptina-pll.c +++ b/drivers/media/i2c/aptina-pll.c @@ -129,6 +129,8 @@ int aptina_pll_calculate(struct device *dev, p1_max = min(limits->p1_max, limits->out_clock_max * div / (pll->ext_clock * pll->m)); + dev_dbg(dev, "pll: p1 min %u max %u\n", p1_min, p1_max); + for (p1 = p1_max & ~1; p1 >= p1_min; p1 -= 2) { unsigned int mf_inc = p1 / gcd(div, p1); unsigned int mf_high; From patchwork Sat May 31 16:31:37 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: 893601 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A2A2017A2F7 for ; Sat, 31 May 2025 16:32:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748709121; cv=none; b=QzKAO5PYKR81jDtEbnjES/Apmkp4/6Z0/eqQijUMftSu3a/RjEINcUtveozNEsAF82pUyKmHQegLf/bV2uFA29KJUfC5BajPunpeedSMbvN6B4WVIixnL81skmpo6sUI2mXC9fhXfGrffQpPzMIaeW5Mm/jQCSr9Nq2stKjFBLI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748709121; c=relaxed/simple; bh=S74UMftPAlRwGiL4tm80DNwdcWwLDYkmDZTnhCtBExw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kjT5GvueKfBiIatdMMSkIlQ1xeL+Bzg0nvcM26Nu65PJdqWLU3lk5xnp7AcrjwbD0f/tzrDoiwqEfa/0NP19zuSbXW/45kgIOfFGxbXica4KuCZApWFWkzW4hUlUmkcETBjjmKx5xZWT/XCqinBXK/kQ9GAXbjOobrqDGQ5ercY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=r6Mgc+90; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="r6Mgc+90" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EC02C4CEE3; Sat, 31 May 2025 16:31:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748709121; bh=S74UMftPAlRwGiL4tm80DNwdcWwLDYkmDZTnhCtBExw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r6Mgc+90dt+G/UhjsWFTnLZqMGAbJ5g0zevKveJSOVuIS7R3tCXT/lda2rLwKFCop TZSVw33QJ3aORAJjNf5FDvirjO8OtIYl3nxoCieJzQiLUeu6qCy9hp111d4iFiie4o i7lRHMdbYGGYSyRt6PSvQf5RsewK10V3p8oWt6obypD53H6NoPaumAfxUE2NIDy0NU YQv3i020MnYlUKZBARNf45Uu+Fzwni+ZiimKeapoQoPdyj4pk/ak8n4m5ojEncICYH VjExTHQxmnzeT6xMbE8LesSNOR0QmAQla6gZn9KPFVHXWwokPDukJZ/V+cqla2IWjX 4mw/8zzHf2Mcg== From: Hans de Goede To: Sakari Ailus , Laurent Pinchart Cc: Hans de Goede , Mathis Foerst , Mauro Carvalho Chehab , linux-media@vger.kernel.org, Hans de Goede Subject: [PATCH v2 02/12] media: mt9m114: Add support for clock-frequency property Date: Sat, 31 May 2025 18:31:37 +0200 Message-ID: <20250531163148.83497-3-hansg@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250531163148.83497-1-hansg@kernel.org> References: <20250531163148.83497-1-hansg@kernel.org> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- Note as discussed during review of v1, this needs to be moved over to the solution from: https://lore.kernel.org/r/20250321130329.342236-1-mehdi.djait@linux.intel.com once that has landed upstream. I'll submit a follow-up patch to move to that solution once it has landed upstream. --- drivers/media/i2c/mt9m114.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c index 3f540ca40f3c..5a7c45ce2169 100644 --- a/drivers/media/i2c/mt9m114.c +++ b/drivers/media/i2c/mt9m114.c @@ -388,6 +388,7 @@ struct mt9m114 { unsigned int pixrate; bool streaming; + u32 clk_freq; /* Pixel Array */ struct { @@ -2134,14 +2135,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); @@ -2279,7 +2279,7 @@ static int mt9m114_clk_init(struct mt9m114 *sensor) * Check if EXTCLK fits the configured link frequency. Bypass the PLL * in this case. */ - pixrate = clk_get_rate(sensor->clk) / 2; + pixrate = sensor->clk_freq / 2; if (mt9m114_verify_link_frequency(sensor, pixrate) == 0) { sensor->pixrate = pixrate; sensor->bypass_pll = true; @@ -2287,7 +2287,7 @@ static int mt9m114_clk_init(struct mt9m114 *sensor) } /* Check if the PLL configuration fits the configured link frequency. */ - pixrate = clk_get_rate(sensor->clk) * sensor->pll.m + pixrate = sensor->clk_freq * sensor->pll.m / ((sensor->pll.n + 1) * (sensor->pll.p + 1)); if (mt9m114_verify_link_frequency(sensor, pixrate) == 0) { sensor->pixrate = pixrate; @@ -2395,13 +2395,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 Sat May 31 16:31:38 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: 893718 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 5570113CA97 for ; Sat, 31 May 2025 16:32:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748709123; cv=none; b=BKvp+vss/7AKhH+f8piJfmzNTePaglMmNYOa3ez2AFXgRGVIBDxML10pZXlgy78ZSTHB5llRFKsriDCr+Vh9KvlSGUf7k4FxHia63d8AbR/9iXUbJ0lXlTU5n9ip0DPixW97MZKvTZWKpCoGjkRf1yFyfkFTkuCdLapCF4vc9yw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748709123; c=relaxed/simple; bh=voer7miYAFU+uyWXu5yCJhGNfL1zEk8UsA8rG5NtZuk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aL33SJ7LzYg/aZ9sMhMlulNhiafscapho3j6FEwAUwFeZGD2hKZuOIPOsSb9/XORIC+wJkYATh7xmTgIzK/Rthlwywh47vvqhaQLSYCu9oLDIan0pAgYNP3eYkZ+QY9GdBX52Fx/1IW+zffuheAqVQ19AKPtnf3znqQvSN+YyeQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XPKIkMHM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XPKIkMHM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 995DDC4CEEF; Sat, 31 May 2025 16:32:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748709123; bh=voer7miYAFU+uyWXu5yCJhGNfL1zEk8UsA8rG5NtZuk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XPKIkMHMmybMrUVzREsFshALsZQ4aIoqJkJCix+Hh1Cw09/9gNqk60mBctw4S3GSZ Ksv620GdP6ojZPip78Y+xCciXFD3z2rIFTFmd87asMmrMauTGlmPAflireCqhrjlOt BPzLR4F+9l8grNXxrc9VYvIw1F+aE6pZd1tOfDuL7kG+Sjg2AhfzMlT5AMBWptow41 OQKVmgxg/3fo8cDXgxDz7AhdoGvLXQKOt+8AOEYopuI/5/qqP87XVJDnWyt6jn7Qoj Zy0qyOXzNJ/PPuRXd3uAoNi64z8cw5W3BQzCA4TWDKc42Oea82zXDt2WzjNxm/mnWC ypqm5kARtM4qg== From: Hans de Goede To: Sakari Ailus , Laurent Pinchart Cc: Hans de Goede , Mathis Foerst , Mauro Carvalho Chehab , linux-media@vger.kernel.org, Hans de Goede Subject: [PATCH v2 03/12] media: mt9m114: Use aptina-PLL helper to get PLL values Date: Sat, 31 May 2025 18:31:38 +0200 Message-ID: <20250531163148.83497-4-hansg@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250531163148.83497-1-hansg@kernel.org> References: <20250531163148.83497-1-hansg@kernel.org> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Before this change the driver used hardcoded PLL m, n and p values to achieve a 48MHz pixclock when used with an external clock with a frequency of 24 MHz. Use aptina_pll_calculate() to allow the driver to work with different external clock frequencies. The m, n, and p values will be unchanged with a 24 MHz extclk and this has also been tested with a 19.2 MHz clock where m gets increased from 32 to 40. Suggested-by: Laurent Pinchart Signed-off-by: Hans de Goede --- Changes in v2: - Add select VIDEO_APTINA_PLL to Kconfig - Use correct aptina_pll_limits --- drivers/media/i2c/Kconfig | 1 + drivers/media/i2c/mt9m114.c | 54 ++++++++++++++++++++++++++----------- 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig index dc2c429734fc..1820ec37404a 100644 --- a/drivers/media/i2c/Kconfig +++ b/drivers/media/i2c/Kconfig @@ -285,6 +285,7 @@ config VIDEO_MT9M111 config VIDEO_MT9M114 tristate "onsemi MT9M114 sensor support" select V4L2_CCI_I2C + select VIDEO_APTINA_PLL help This is a Video4Linux2 sensor-level driver for the onsemi MT9M114 camera. diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c index 5a7c45ce2169..e12c69dc9df0 100644 --- a/drivers/media/i2c/mt9m114.c +++ b/drivers/media/i2c/mt9m114.c @@ -31,6 +31,8 @@ #include #include +#include "aptina-pll.h" + /* Sysctl registers */ #define MT9M114_CHIP_ID CCI_REG16(0x0000) #define MT9M114_COMMAND_REGISTER CCI_REG16(0x0080) @@ -263,9 +265,9 @@ #define MT9M114_CAM_SYSCTL_PLL_ENABLE_VALUE BIT(0) #define MT9M114_CAM_SYSCTL_PLL_DISABLE_VALUE 0x00 #define MT9M114_CAM_SYSCTL_PLL_DIVIDER_M_N CCI_REG16(0xc980) -#define MT9M114_CAM_SYSCTL_PLL_DIVIDER_VALUE(m, n) (((n) << 8) | (m)) +#define MT9M114_CAM_SYSCTL_PLL_DIVIDER_VALUE(m, n) ((((n) - 1) << 8) | (m)) #define MT9M114_CAM_SYSCTL_PLL_DIVIDER_P CCI_REG16(0xc982) -#define MT9M114_CAM_SYSCTL_PLL_DIVIDER_P_VALUE(p) ((p) << 8) +#define MT9M114_CAM_SYSCTL_PLL_DIVIDER_P_VALUE(p) (((p) - 1) << 8) #define MT9M114_CAM_PORT_OUTPUT_CONTROL CCI_REG16(0xc984) #define MT9M114_CAM_PORT_PORT_SELECT_PARALLEL (0 << 0) #define MT9M114_CAM_PORT_PORT_SELECT_MIPI (1 << 0) @@ -326,7 +328,7 @@ * minimum values that have been seen in register lists are 303 and 38, use * them. * - * Set the default to achieve 1280x960 at 30fps. + * Set the default to achieve 1280x960 at 30fps with a 48 MHz pixclock. */ #define MT9M114_MIN_HBLANK 303 #define MT9M114_MIN_VBLANK 38 @@ -336,6 +338,8 @@ #define MT9M114_DEF_FRAME_RATE 30 #define MT9M114_MAX_FRAME_RATE 120 +#define MT9M114_DEF_PIXCLOCK 48000000 + #define MT9M114_PIXEL_ARRAY_WIDTH 1296U #define MT9M114_PIXEL_ARRAY_HEIGHT 976U @@ -380,11 +384,7 @@ struct mt9m114 { struct v4l2_fwnode_endpoint bus_cfg; bool bypass_pll; - struct { - unsigned int m; - unsigned int n; - unsigned int p; - } pll; + struct aptina_pll pll; unsigned int pixrate; bool streaming; @@ -757,7 +757,7 @@ static int mt9m114_initialize(struct mt9m114 *sensor) sensor->pll.n), &ret); cci_write(sensor->regmap, MT9M114_CAM_SYSCTL_PLL_DIVIDER_P, - MT9M114_CAM_SYSCTL_PLL_DIVIDER_P_VALUE(sensor->pll.p), + MT9M114_CAM_SYSCTL_PLL_DIVIDER_P_VALUE(sensor->pll.p1), &ret); } @@ -2262,12 +2262,29 @@ static int mt9m114_verify_link_frequency(struct mt9m114 *sensor, static int mt9m114_clk_init(struct mt9m114 *sensor) { + static const struct aptina_pll_limits limits = { + .ext_clock_min = 6000000, + .ext_clock_max = 54000000, + /* int_clock_* limits are not documented taken from mt9p031.c */ + .int_clock_min = 2000000, + .int_clock_max = 13500000, + /* + * out_clock_min is not documented, taken from mt9p031.c. + * out_clock_max is documented as 768MHz, but this leads to + * different PLL settings then used by the vendor's drivers. + */ + .out_clock_min = 180000000, + .out_clock_max = 400000000, + .pix_clock_max = 48000000, + .n_min = 1, + .n_max = 64, + .m_min = 16, + .m_max = 192, + .p1_min = 1, + .p1_max = 64, + }; unsigned int pixrate; - - /* Hardcode the PLL multiplier and dividers to default settings. */ - sensor->pll.m = 32; - sensor->pll.n = 1; - sensor->pll.p = 7; + int ret; /* * Calculate the pixel rate and link frequency. The CSI-2 bus is clocked @@ -2287,8 +2304,15 @@ static int mt9m114_clk_init(struct mt9m114 *sensor) } /* Check if the PLL configuration fits the configured link frequency. */ + sensor->pll.ext_clock = sensor->clk_freq; + sensor->pll.pix_clock = MT9M114_DEF_PIXCLOCK; + + ret = aptina_pll_calculate(&sensor->client->dev, &limits, &sensor->pll); + if (ret) + return ret; + pixrate = sensor->clk_freq * sensor->pll.m - / ((sensor->pll.n + 1) * (sensor->pll.p + 1)); + / (sensor->pll.n * sensor->pll.p1); if (mt9m114_verify_link_frequency(sensor, pixrate) == 0) { sensor->pixrate = pixrate; sensor->bypass_pll = false; From patchwork Sat May 31 16:31:39 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: 893600 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C9DF413CA97 for ; Sat, 31 May 2025 16:32:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748709125; cv=none; b=DaJeK8UYAaPgOxaPHkibMqgruIkFfUs6LTqRqvRoqp5ZjFB1sZSAqZjVB0VLmCOOl/PYnujxxm7cxIxJCkV31B7EyuK6oxHwJT8Kifl/cv2oicHnQ6oD2I8htFoPOtdHtg9SnjF9jGEWPthBO6yigcqaPsg/Kqr6oF08BXoyOUQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748709125; c=relaxed/simple; bh=RVKpnL//EuaqDce6HTso8AIfpegSD2km4o+g5EC/7EE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=re25MvFIgh0uzmrRHzl4boU3uDtF7OA7XG7u6UYVfhuyHPAmPmBLfRatYdA21OGP1QDbfFhkHVmAu9TGRF1dwi1Uq9lnvtwGBIyWduFgMVvakarog4WS6AyWO3+2c4MAZSgggq2wbH2HBZCvDPZXztvE4OEa/rJTWyCm5TWqHK4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=n3mO9XH2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="n3mO9XH2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3546C4CEE3; Sat, 31 May 2025 16:32:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748709125; bh=RVKpnL//EuaqDce6HTso8AIfpegSD2km4o+g5EC/7EE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n3mO9XH20uHQrTJLg8VYZEHLNZxIZO3tvNLHBWPVXhKvjhfuh8awSjpbRpwKcKYjm DqupQiMbju+mWulBEd+YXzVuVZwo0QUP+s20BZWpBx0fI96Jv4Oy0/XCQjCr4JmEi/ WAoPZQTt0nnPJRBurbrGDxctNBuozUsVXAPKiHjYp0N0TIJVVblH4hmBNHrMiBv+z/ C3ylkowH2daTtQBhVkSTtwdBTTBTTkCMYJpFvSzdstFIlo57q1lImVBEqQMPvGqzPp AY+ZjEMeRPs5EsMe7WTO4BDLUgVovdveG38XHa1Niu3UwUHqngpO7ZndsQWW/JTRqv RnsYePD7uxolw== From: Hans de Goede To: Sakari Ailus , Laurent Pinchart Cc: Hans de Goede , Mathis Foerst , Mauro Carvalho Chehab , linux-media@vger.kernel.org, Hans de Goede Subject: [PATCH v2 04/12] media: mt9m114: Lower minimum vblank value Date: Sat, 31 May 2025 18:31:39 +0200 Message-ID: <20250531163148.83497-5-hansg@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250531163148.83497-1-hansg@kernel.org> References: <20250531163148.83497-1-hansg@kernel.org> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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. Reviewed-by: Laurent Pinchart Signed-off-by: Hans de Goede --- 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 e12c69dc9df0..5f59bfd83402 100644 --- a/drivers/media/i2c/mt9m114.c +++ b/drivers/media/i2c/mt9m114.c @@ -325,13 +325,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 Sat May 31 16:31:40 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: 893717 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 6C45513CA97 for ; Sat, 31 May 2025 16:32:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748709127; cv=none; b=kayBM+B+TbO1+Yavy/ywCJok1oXZpaHpZ/ixLQh34QU2xZ204i6BoISfWf6C+m61xs+ofr1YE5D/onkS+YJLW6TLze/+wQ9WyAhZrnCszjkwdVAbo6TnT+Y5fC7Xww/hjhR/faOBgj1rMxA6awW/80a1fn9sii3Y0+l9jrvGDA0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748709127; c=relaxed/simple; bh=zY37WmJMAHAfQBTGFECzVjlgaM7j1inXoMeQuWzx7+U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BTKB1unZ1J9bzojwRFlqvbvL2FW//9eQPbw7ZNRxYxnV760EQVgBMTAcZDYBQgc7vTu59KYDiWea+jpVMBuhvvJKgmFug+kZ+x1ee1ijHt3pIRXyNz9bCIs80Kut9BzVYo0W4YYd9cfHPzk/t0QVfGITNN373G8E7214YOKF4y0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TFrI+JI1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TFrI+JI1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AEBC7C4CEEE; Sat, 31 May 2025 16:32:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748709127; bh=zY37WmJMAHAfQBTGFECzVjlgaM7j1inXoMeQuWzx7+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TFrI+JI1NcQHkfPLiMwU5Iv5mgPBPSMde/MSSXouKbPYs++8bmfhOuoUHuSJh71Fn lPf4aetgBNE8vZXCVhjHvsHF6lqt2bZdXUyj2XOPD60RS9COKoHctlTHMtDK93T8Rk ClnlB+c3QCDu8RHmUH6HRoJ1x0HQS47rh7rOLhMXwL9mOdnQZBxr0KCOUR5ow+nfno 0Zo7Nk9FKzkkiEHwmUP7CBa6vTaJgt48Z2oHD2busw+CQokYSwqI/cPjLEdFE9vpyk LjmCvcj6zg38gvN4xPMWCrFXvFyDdDvX3Jh9x1m8QMcg2/nRYz2DNEWHqk43+CDMgf ZlaMdPkcBMkHw== From: Hans de Goede To: Sakari Ailus , Laurent Pinchart Cc: Hans de Goede , Mathis Foerst , Mauro Carvalho Chehab , linux-media@vger.kernel.org, Hans de Goede Subject: [PATCH v2 05/12] media: mt9m114: Fix default hblank and vblank values Date: Sat, 31 May 2025 18:31:40 +0200 Message-ID: <20250531163148.83497-6-hansg@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250531163148.83497-1-hansg@kernel.org> References: <20250531163148.83497-1-hansg@kernel.org> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The current default hblank and vblank values are based on reaching 30 fps with the pixel-array outputting 1280x960, but the default format for the pixel-array source pad and the isp sink pad is 1296x976, correct the default hblank and vblank values to take this into account. Reviewed-by: Laurent Pinchart Signed-off-by: Hans de Goede --- Changes in v2: - Update comment about resolution / pixrate / FPS to: * Set the default to achieve full resolution (1296x976 analog crop * rectangle, 1280x960 output size) at 30fps with a 48 MHz pixclock. --- drivers/media/i2c/mt9m114.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c index 5f59bfd83402..aa401b3fb4a7 100644 --- a/drivers/media/i2c/mt9m114.c +++ b/drivers/media/i2c/mt9m114.c @@ -328,12 +328,13 @@ * 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. + * Set the default to achieve full resolution (1296x976 analog crop + * rectangle, 1280x960 output size) at 30fps with a 48 MHz pixclock. */ #define MT9M114_MIN_HBLANK 303 #define MT9M114_MIN_VBLANK 21 -#define MT9M114_DEF_HBLANK 323 -#define MT9M114_DEF_VBLANK 39 +#define MT9M114_DEF_HBLANK 307 +#define MT9M114_DEF_VBLANK 23 #define MT9M114_DEF_FRAME_RATE 30 #define MT9M114_MAX_FRAME_RATE 120 From patchwork Sat May 31 16:31:41 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: 893599 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7457313CA97 for ; Sat, 31 May 2025 16:32:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748709129; cv=none; b=EuRIwubV8suVPsZ1C7dO6VF8HpxaAm291dAOcjpxV+XuZepsOrK54eoIoDnFCR2fJ/R74J97lczAo4IJvyDO82dbUXh/7EBVvImPgD9G5Qw3R0SrZ1yKsUCz1/uoGcWcnoDAOW+NdWn4FG3Iqx5eBgSB3kB4Zsm+GTdxI3rQxQE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748709129; c=relaxed/simple; bh=uIdZhHonyW8TgL2dLZHDoVBJMzk+1Hx+gJoSnet/xyc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QrZppYhSJi1TmeC0nxlL6yulyuNqKKqTUi2p6hSyjQjagBF9eVS4xI0QtMIoBEL60K8rKatEJG3vJK9/EDO1cyPnrPwFd79IgCVcUGCZtyFnfQEI8peFnMZ2f5pOaFnqYrk4E4s1j4ozfYs0yuAbekFSmZMJZzC3J2ZOBnuP+Kw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uXEII9fK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uXEII9fK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9C59C4CEEE; Sat, 31 May 2025 16:32:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748709129; bh=uIdZhHonyW8TgL2dLZHDoVBJMzk+1Hx+gJoSnet/xyc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uXEII9fKyxvEXXIdzgBy4a4REVnPnewdGs26GvTJNmQ4IsyxYLdNUY4dpcZP0cuw2 PxJAOHDXCw0/UfKG23S0c+EjNo9pQaDhD3OdNKk+PV8zZzM5U1oBxr368eMrTp1J7t PATVoPWVxjXESb9V978BKjZPHarP52sI1dMHO0Yrc6prKe3l1uhpTz8fB8LLsZPjtz SER5m1IMq8T3taJXdKJHEYBS6Px7u7lRJaNmvMDB2fokYWTnFFSsPXJyjf5FxVSBSe QQAXE56+B+uXUbuzJxOnaq32zxzTj2PSSoCthxbdexnJ5qrH4d8kF9pdupKivnqH7q lSagHOnq6Lxkg== From: Hans de Goede To: Sakari Ailus , Laurent Pinchart Cc: Hans de Goede , Mathis Foerst , Mauro Carvalho Chehab , linux-media@vger.kernel.org, Hans de Goede Subject: [PATCH v2 06/12] media: mt9m114: Tweak default hblank and vblank for more accurate fps Date: Sat, 31 May 2025 18:31:41 +0200 Message-ID: <20250531163148.83497-7-hansg@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250531163148.83497-1-hansg@kernel.org> References: <20250531163148.83497-1-hansg@kernel.org> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The PLL gets programmed to achieve a 48 MHz pixelclock, with the current 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. Reviewed-by: Laurent Pinchart Signed-off-by: Hans de Goede --- 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 aa401b3fb4a7..371e96d9e281 100644 --- a/drivers/media/i2c/mt9m114.c +++ b/drivers/media/i2c/mt9m114.c @@ -333,8 +333,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 Sat May 31 16:31:42 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: 893716 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8158D175D53 for ; Sat, 31 May 2025 16:32:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748709131; cv=none; b=YkvkfKSSpSk8Z4gxuhuZaKINExOliXf0pa+kSdgNniWwzAWAyg16CzllgKmCubCkVWgg57dDjDgVHzMSizKT2M2nBeXJSCVC9PKavy4qI89ECgeaIcHESK5W4L8vuHXXTiDUUZwIwgbDRJGCxHUcwuHZk+In5vcKgF7E4nMS6OA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748709131; c=relaxed/simple; bh=OEefwPIAykmQwDwijRLibsprpZb0BzXfAAn/GoAPEAc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e1HdOtG6r95fOtNsVVme2g/2WUXrvD0xl73a0NYp0qK46mWKruh9IxkalvZYOac+mzSFd6VvmNSIVtUMNR3iWSDo88iJ4Ra/k+3DivOwM/oVX5NWTT6oaMm2s7TkzMmxiOLnXT8zvYRsb2bGen9bOm0qoGsHedvyTe0odSkx7Fs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NLQoWmHF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NLQoWmHF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4509C4CEEE; Sat, 31 May 2025 16:32:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748709131; bh=OEefwPIAykmQwDwijRLibsprpZb0BzXfAAn/GoAPEAc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NLQoWmHFvzQeA4yp1IDOjRsqZ0jij8jNS4xvsgGf9b21KcfrDz7RpE+Zurh0dC6Wm usW2aWnE+aO27PQ8GR5iqlxVv7tTe1xCl75f7BZzDsY1yEyj6jh7VHfbZhabZruUVg l8HKRYYZTMgpLzOuMOmxoEStfhbCvDblQ6BfWlQJiCsr0pdJfESNQHmdY1/g5pZ79V wmf7JqG/E5Nq31ixCJihMafZt35aXQfY8CdoYtJzVVv2HQjJRvPgjDAxYqaHzlaCv9 CJ79RdsD98iqLuMACWt9CM1vced/vTMvvXWdkmfX+f31XUe9GbeNKlS6CegIZqyYP5 kWS5hZlmCTAIQ== From: Hans de Goede To: Sakari Ailus , Laurent Pinchart Cc: Hans de Goede , Mathis Foerst , Mauro Carvalho Chehab , linux-media@vger.kernel.org, Hans de Goede Subject: [PATCH v2 07/12] media: mt9m114: Avoid a reset low spike during probe() Date: Sat, 31 May 2025 18:31:42 +0200 Message-ID: <20250531163148.83497-8-hansg@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250531163148.83497-1-hansg@kernel.org> References: <20250531163148.83497-1-hansg@kernel.org> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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. Reviewed-by: Laurent Pinchart 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 371e96d9e281..fe30b9ff84ad 100644 --- a/drivers/media/i2c/mt9m114.c +++ b/drivers/media/i2c/mt9m114.c @@ -2439,7 +2439,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 Sat May 31 16:31:43 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: 893598 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 89A7013CA97 for ; Sat, 31 May 2025 16:32:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748709133; cv=none; b=IXT6bpOcGVU/Wm1GaLh2hWJGgOl2HcUfd9dycAk8A04hEBdqHzjDGAAL7WCTXvuvZDBpnoz9o1CO0YbtzQH9Uts7G/ac3kkkH0fuSBZitEo+USF6fm+mJylOJCznQiDbZ+UuaEcrJxNGtNKeYSMunq4slC2lBD5amEqjOksSVQQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748709133; c=relaxed/simple; bh=guj1U9Lcnm3RCJhfeQST+5Y4xbLrf2V8aiIW+Ts8LdU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HW6YkeqGjAJIJFDr/gf59ykDb9EORK8Of3ZAqz31tawRXGz2g4flSCxmz+M0vbT8RcXWRv9hhLkYeUAGYcJoYSIDc/Tgel5Qgd1/ZGI1DkJybY4GQAGdb+fg9BueDEreJEKZBxMEIMq6M+whkRPpdEuzR/U9waFzTeSR6ioR4+M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=T9IQNxKx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="T9IQNxKx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF241C4CEE3; Sat, 31 May 2025 16:32:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748709133; bh=guj1U9Lcnm3RCJhfeQST+5Y4xbLrf2V8aiIW+Ts8LdU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T9IQNxKxqcj08L6mFFjwBXl7ZL85UregU0MpZ10Ly11wkIXgWU8dRZ436E0LuWXdr 6/3bgSYtXjcIWn8zk+hAT/G4f4hs3eYNIzEEvnUYfjN7Bb0m+/Xu2zlIkVpQ+NISQI UDHcjFhK2pLH+3gBWWKalLNHyiSoVYD1JifTEsjwcq7jO9ILkgGGNYsVpd1wLsJMHA PSDw8iF9BN2Nam6T6NVEJHaj3gCSW2sdKsW4Ml0bPhNhNHZz/APn6bNrr9pP5fgg7z 9qqsuDu+FBWbCZDYZK4AE7anKlTQAlRHfqtI4C7EqGxgMkBrxtF9Q/R/pXVEkCVvUu BaaCJylBHoT9g== From: Hans de Goede To: Sakari Ailus , Laurent Pinchart Cc: Hans de Goede , Mathis Foerst , Mauro Carvalho Chehab , linux-media@vger.kernel.org, Hans de Goede Subject: [PATCH v2 08/12] media: mt9m114: Put sensor in reset on power-down Date: Sat, 31 May 2025 18:31:43 +0200 Message-ID: <20250531163148.83497-9-hansg@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250531163148.83497-1-hansg@kernel.org> References: <20250531163148.83497-1-hansg@kernel.org> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Put sensor back in reset on power-down. Signed-off-by: Hans de Goede --- Changes in v2 - After setting reset high wait 20 clk cycles before disabling the clk and regulators --- drivers/media/i2c/mt9m114.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c index fe30b9ff84ad..7a1451006cfe 100644 --- a/drivers/media/i2c/mt9m114.c +++ b/drivers/media/i2c/mt9m114.c @@ -2207,6 +2207,13 @@ static int mt9m114_power_on(struct mt9m114 *sensor) static void mt9m114_power_off(struct mt9m114 *sensor) { + unsigned int duration; + + gpiod_set_value(sensor->reset, 1); + /* Power off takes 10 clock cycles. Double it to be safe. */ + duration = DIV_ROUND_UP(2 * 10 * 1000000, sensor->clk_freq); + fsleep(duration); + clk_disable_unprepare(sensor->clk); regulator_bulk_disable(ARRAY_SIZE(sensor->supplies), sensor->supplies); } From patchwork Sat May 31 16:31:44 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: 893715 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 93FC53770B for ; Sat, 31 May 2025 16:32:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748709135; cv=none; b=mOYG52xFGTf6pumqnM6PHT2XrQNONSjp/TkOrRrvYRJ2Kb8xNnlNfwLWBsqwwA3LKclDw8ByI3ToWdfT+Zs/TMO8b9WhbMyltMou4Su7Ly4DvcDjBqzCU/kF++UwIXftQhXdyho/zIAzYgruVj71vw+/4PQYh6BHZgxjQ+PMInY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748709135; c=relaxed/simple; bh=NX9A/f7wtsiD+MejYBwX55+oRAsal/aia2mDKoA9Qd8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sK0skv44RGAeI4REfuaJeiAOnrYvwOdcinRUJMYraVs8AbAefaloACsG/Djtgp7KF4bc9R+eLeVVMk3DS17mvaOFUHrUNtJH2fSqayc5ME/Qct0PsalWChMJ2MORAPQY6T4GuJgNUIi9yOoeoYBEHaaWHQIo9Bzl28O1mT8glOA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=P0m+Lzwe; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="P0m+Lzwe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9673C4CEEE; Sat, 31 May 2025 16:32:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748709135; bh=NX9A/f7wtsiD+MejYBwX55+oRAsal/aia2mDKoA9Qd8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P0m+Lzwe2MGQJoYyhRxvyyG7j4UqIxdnbKGcIoCSzHrvU9hWv5rlByZSX8igHedu0 fFuzYm94o1Cnsf9D6hUGM0jgXjLi4TLd9OGZaWrPjCvTf67JUfAiiBCRd3tXeExwhB daXa/fcXBL0yNlnP97T34H/uXT4z6dNHDbT8S+VL3yfoiP/+KHxkVNU00ItuL3KZ6i VNT4MfQ1Vx/2yOrFRlCG8+3McgyQd8lj4V1RzgpwRiFoeHmTUeGIALYA3LCxM4ocLd 2zopTAEtoc2pkvHDTIcjjHPqwSL3kuBcEVH45cIpMh6ZAU/Cod/G48fTi3b66QZwVX +pRdjwJjl80fQ== From: Hans de Goede To: Sakari Ailus , Laurent Pinchart Cc: Hans de Goede , Mathis Foerst , Mauro Carvalho Chehab , linux-media@vger.kernel.org, Hans de Goede Subject: [PATCH v2 09/12] media: mt9m114: Fix scaler bypass mode Date: Sat, 31 May 2025 18:31:44 +0200 Message-ID: <20250531163148.83497-10-hansg@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250531163148.83497-1-hansg@kernel.org> References: <20250531163148.83497-1-hansg@kernel.org> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- Changes in v2: - When bypassing the scalar make ifp_get_selection() / ifp_set_selection() fill sel->r with a rectangle of (0,0)/wxh and return 0 instead of returning -EINVAL --- drivers/media/i2c/mt9m114.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c index 7a1451006cfe..d954f2be8f0d 100644 --- a/drivers/media/i2c/mt9m114.c +++ b/drivers/media/i2c/mt9m114.c @@ -467,7 +467,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, } }; @@ -850,6 +851,7 @@ static int mt9m114_configure_ifp(struct mt9m114 *sensor, const struct v4l2_mbus_framefmt *format; const struct v4l2_rect *crop; const struct v4l2_rect *compose; + unsigned int border; u64 output_format; int ret = 0; @@ -869,10 +871,12 @@ static int mt9m114_configure_ifp(struct mt9m114 *sensor, * by demosaicing that are taken into account in the crop rectangle but * not in the hardware. */ + border = (format->code == MEDIA_BUS_FMT_SGRBG10_1X10) ? 0 : 4; + cci_write(sensor->regmap, MT9M114_CAM_CROP_WINDOW_XOFFSET, - crop->left - 4, &ret); + crop->left - border, &ret); cci_write(sensor->regmap, MT9M114_CAM_CROP_WINDOW_YOFFSET, - crop->top - 4, &ret); + crop->top - border, &ret); cci_write(sensor->regmap, MT9M114_CAM_CROP_WINDOW_WIDTH, crop->width, &ret); cci_write(sensor->regmap, MT9M114_CAM_CROP_WINDOW_HEIGHT, @@ -911,7 +915,8 @@ static int mt9m114_configure_ifp(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 |= info->output_format; cci_write(sensor->regmap, MT9M114_CAM_OUTPUT_FORMAT, @@ -1810,6 +1815,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); @@ -1830,8 +1836,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; @@ -1851,6 +1864,12 @@ static int mt9m114_ifp_get_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) { + sel->r = *v4l2_subdev_state_get_crop(state, 0); + return 0; + } + switch (sel->target) { case V4L2_SEL_TGT_CROP: sel->r = *v4l2_subdev_state_get_crop(state, 0); @@ -1911,6 +1930,12 @@ 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) { + sel->r = *v4l2_subdev_state_get_crop(state, 0); + return 0; + } + 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 Sat May 31 16:31:45 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: 893597 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A38EA1632CA for ; Sat, 31 May 2025 16:32:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748709137; cv=none; b=iXfQR08cLu1q7ZduNOtrVxD6/s66vGULfFZJdslUrtkSj05NumbZYHtLHWKPVLUNq1Q+2MJqEVFe9835VVdRrxXjzSGoPY9ygnp0qc3EuN+M5+SkDULFAlj+oa0dXiH/VNp75AHP0ZZftjdbR7ban2qBkr+B2g2YPgtV0wKYPDI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748709137; c=relaxed/simple; bh=Q2UPmyRz23e5l/ZA/e5YkvVRAaPDuCB2ItxaZW/lAfY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FCVrdNw8G5GCeQzTOac8Z8YNFY8Avt25wJ/rp47QqGHYa+PYmnmPjSzd1toHSkcic8NNcYQM6tY4fMuvBGWxCV8Oqe3/FjX0c9bNTgG8auY7SlJ7zzWWKTVu2cYFfWXFf+drkbJcpLZPP3t3O7tlKGTlChfoCMtNW5uzVHirZLE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XzgumPdM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XzgumPdM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1C13C4CEEE; Sat, 31 May 2025 16:32:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748709137; bh=Q2UPmyRz23e5l/ZA/e5YkvVRAaPDuCB2ItxaZW/lAfY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XzgumPdMC2ttUtW7Am6dEuZuTFatylfUjyaOM4AElKbXOYJxQtr1hJVGkBStb++ng 9pcxlNyHLL8C0KFdrystWR9Pn4UP0WLdnZYVlnJj3gMcIYct1TBbxOO2rQCWJr9yVR S+kgvwUpHQIFegUJa5+hLlJu4S94tB+PyJ6mMVVqoXvxP8dzj2UhmK5P2rhSx7WpD6 V1yUmz7NO6pmENA5QHCmyieQpTKsP7b+Lr2cU7yTpN+JtJDNEHvk1bPQZksz2ows/t +gdJi60Edlk3MGoaMmEV0bWeRhipMefR0hw+hmvfUFF3Tg8SmAh9VcYTAjNguLHFWX IxOKIBMaOw7yw== From: Hans de Goede To: Sakari Ailus , Laurent Pinchart Cc: Hans de Goede , Mathis Foerst , Mauro Carvalho Chehab , linux-media@vger.kernel.org, Hans de Goede Subject: [PATCH v2 10/12] media: mt9m114: Drop start-, stop-streaming sequence from initialize Date: Sat, 31 May 2025 18:31:45 +0200 Message-ID: <20250531163148.83497-11-hansg@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250531163148.83497-1-hansg@kernel.org> References: <20250531163148.83497-1-hansg@kernel.org> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 d954f2be8f0d..c4d3122d698e 100644 --- a/drivers/media/i2c/mt9m114.c +++ b/drivers/media/i2c/mt9m114.c @@ -389,6 +389,7 @@ struct mt9m114 { unsigned int pixrate; bool streaming; + bool config_change_pending; u32 clk_freq; /* Pixel Array */ @@ -782,14 +783,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; } @@ -976,6 +970,7 @@ static int mt9m114_start_streaming(struct mt9m114 *sensor, if (ret) goto error; + sensor->config_change_pending = false; sensor->streaming = true; return 0; @@ -2267,6 +2262,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; From patchwork Sat May 31 16:31:46 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: 893714 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 0D07C149E13 for ; Sat, 31 May 2025 16:32:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748709140; cv=none; b=KeKLHgfFhCI7iFI3lOB9NHxvESc6Kd1alabtGFAJLCkzYIXRfFJkopUngmgBMP+3k7lIY4WBZZE2jDfJFQ3ZaNGndjiJdN3P95QyR/E/k7y9cjIrtIez+O3ntr6NtZySgUyja3gcyo59VB5dy2hXk1Hr7DpjgbPKwjFT3vRASd4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748709140; c=relaxed/simple; bh=J2efyH+WWYocapP0Ros97+bsaPWVDZcSplpNaWEFkd8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tJo3OPux4pejoQqU9X2UTguOSjkDUma9aPHXaQ8xq4lMdQmwq1tZkdDtNm1JzSn+IFHgMrCuqwW1SPU2HIzu+jjFgu1RVSTaN9SpCwMkC9YXkfFB+ESjsCHW7O9xufSZpVJYnIDGQQ7ZJTIE6skxa5nM8vWbayQaU6iQ8SxrePw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=klMnuxR7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="klMnuxR7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC5FBC4CEEE; Sat, 31 May 2025 16:32:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748709139; bh=J2efyH+WWYocapP0Ros97+bsaPWVDZcSplpNaWEFkd8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=klMnuxR7W627PvYwgJzfJnOUZRuC8kOWt5i/JILMS8gFCu0hhsIQRjvJDD8X4UtSq zdBscUtHBEoz+d0RpYUCOOezC2GJ9gXdO/tuuMWnfpoklyG3bBESF4lMgwWbv6oyQn /ABYOJoPfeGEYQm7asgbqqtWze/jxgKoypDS5iwr183zdKBQtAtkUqLtbkpB13lf7x qb2XshwdQMj47QU79aPQal6muIsYEgYj6+PR1rlxbBlVWdOiLZhzJarv/nDPD1rGeb vJU0/4sVLIY0zs9DD8EHv+hl72KrVFO7MLGmzSaWw50h3TkcAajF5CKkgGOyL6rYAR +KLjfnaUjZ48Q== From: Hans de Goede To: Sakari Ailus , Laurent Pinchart Cc: Hans de Goede , Mathis Foerst , Mauro Carvalho Chehab , linux-media@vger.kernel.org, Hans de Goede Subject: [PATCH v2 11/12] media: mt9m114: Return -EPROBE_DEFER if no endpoint is found Date: Sat, 31 May 2025 18:31:46 +0200 Message-ID: <20250531163148.83497-12-hansg@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250531163148.83497-1-hansg@kernel.org> References: <20250531163148.83497-1-hansg@kernel.org> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 With IPU# bridges, endpoints may only be created when the IPU bridge is initialized. This may happen after the sensor driver's first probe(). Signed-off-by: Hans de Goede --- drivers/media/i2c/mt9m114.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c index c4d3122d698e..72914c47ec9a 100644 --- a/drivers/media/i2c/mt9m114.c +++ b/drivers/media/i2c/mt9m114.c @@ -2399,11 +2399,14 @@ static int mt9m114_parse_dt(struct mt9m114 *sensor) struct fwnode_handle *ep; int ret; + /* + * Sometimes the fwnode graph is initialized by the bridge driver, + * wait for this. + */ ep = fwnode_graph_get_next_endpoint(fwnode, NULL); - if (!ep) { - dev_err(&sensor->client->dev, "No endpoint found\n"); - return -EINVAL; - } + if (!ep) + return dev_err_probe(&sensor->client->dev, -EPROBE_DEFER, + "waiting for fwnode graph endpoint\n"); sensor->bus_cfg.bus_type = V4L2_MBUS_UNKNOWN; ret = v4l2_fwnode_endpoint_alloc_parse(ep, &sensor->bus_cfg); From patchwork Sat May 31 16:31:47 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: 893596 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 245CD17F4F6 for ; Sat, 31 May 2025 16:32:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748709142; cv=none; b=QNLqWs7iw8Lwuns+rm5U18SeKwsgThtoipbmDnHZ7M9lAIbiWf6G0nXWA3B5P+Fk63I97Ill1pOCt3jubsazPlvUJok+DDlvObQDfrcYFQ8OMF9koLdi7SE+yhV5WftmJvWu592nn4m2ROhyVzSNW/snaXSLLwEb+cQbyDgIh60= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748709142; c=relaxed/simple; bh=wQnubiA8yJ/LWSUmzmGSLc7jr5KqwmUcB4wkxP6AlyI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iDo/lH98UeeH7kI2YbRSXvD4ajWnY3sGlrrWeZY0MEf04sdCwAULxQ5lStsbi0pjwF74L7MLZy4SwS5dLw8b0X0brK9UTpYDf44OCxQePldZG1nSFbOgZ5JBlkr4JOQnejz6kxYAnOkjMh+a0oGADf2tD/cUbAoYdTKwsp+oEfo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=I37jfUPZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="I37jfUPZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0257CC4CEEF; Sat, 31 May 2025 16:32:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748709141; bh=wQnubiA8yJ/LWSUmzmGSLc7jr5KqwmUcB4wkxP6AlyI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I37jfUPZhBozpakLRdaENcdjadz1y5MKldbRXGPlpp0KNjbO67V2VEIHEABsSbm1b 6blqAtIpk2wsQg+QY+YNRAyt4KKSglsSggHiy5J/0p8p4YYMXomo0IWQpnZ7wpHMJm mhFM4F/Z6aY7HGQJ0QvtswaWP7Hmo6RI6wk8S6+oR9dD8QRjQC/uPwkX55FiFfVYS4 MyfyPePaYZKUAD7QYDTsXsUuJ/0RGo0IzzFLCSzxn0ECkCyCzRvOHmB61KXBpQWulP TEmEE5WLzfsoFV6jUq8dbx/QuC93dohovNnGMvji/5pePLh8yOydzJ7lYYwH+n7vuN oSYbj0lktCDuQ== From: Hans de Goede To: Sakari Ailus , Laurent Pinchart Cc: Hans de Goede , Mathis Foerst , Mauro Carvalho Chehab , linux-media@vger.kernel.org, Hans de Goede Subject: [PATCH v2 12/12] media: mt9m114: Add ACPI enumeration support Date: Sat, 31 May 2025 18:31:47 +0200 Message-ID: <20250531163148.83497-13-hansg@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250531163148.83497-1-hansg@kernel.org> References: <20250531163148.83497-1-hansg@kernel.org> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add support for the mt9m114 sensor being enumerated through ACPI using the INT33F0 HID as found on the Asus T100TA. Reviewed-by: Laurent Pinchart Signed-off-by: Hans de Goede --- drivers/media/i2c/mt9m114.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c index 72914c47ec9a..ec56768983e4 100644 --- a/drivers/media/i2c/mt9m114.c +++ b/drivers/media/i2c/mt9m114.c @@ -2594,11 +2594,18 @@ static const struct of_device_id mt9m114_of_ids[] = { }; MODULE_DEVICE_TABLE(of, mt9m114_of_ids); +static const struct acpi_device_id mt9m114_acpi_ids[] = { + { "INT33F0" }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(acpi, mt9m114_acpi_ids); + static struct i2c_driver mt9m114_driver = { .driver = { .name = "mt9m114", .pm = &mt9m114_pm_ops, .of_match_table = mt9m114_of_ids, + .acpi_match_table = mt9m114_acpi_ids, }, .probe = mt9m114_probe, .remove = mt9m114_remove,