* [PATCH v8 0/2] MT9M114 driver bugfix and improvements
@ 2025-07-14 7:59 Mathis Foerst
2025-07-14 7:59 ` [PATCH v8 1/2] media: mt9m114: Allow set_selection while streaming Mathis Foerst
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Mathis Foerst @ 2025-07-14 7:59 UTC (permalink / raw)
To: linux-kernel
Cc: Mathis Foerst, Sakari Ailus, Laurent Pinchart,
Mauro Carvalho Chehab, linux-media, manuel.traut, mathis.foerst
Hi,
this patch series contains the following bugfix and improvements
for the MT9M114 camera driver:
Changelog:
v7 -> v8:
- Add missing braces in 1.
- Fix formatting issues as suggested in review.
v6 -> v7:
- Remove already picked patches 1, 2, 3 and 6.
- Remove patch 4 as suggested in review.
- Fix formatting issues
- Return -EBUSY from mt9m114_pa_set_selection if the cropping size changes
while in streaming state.
v5 -> v6:
- Add 'Reviewed-By:' tags. Sorry for forgetting this in the previous versions
v4 -> v5:
- Apply reformatings and small refactorings as suggested in review comments
- Split PATCH 4 into two parts: One for applying HFLIP / VFLIP while
streaming, one for applying set_selection while streaming.
- Add condition to apply set_selection immediately only if the size of the
cropping rectangle does not change in PATCH 5
- Use device_property_read_u32 instead of of_property_read_u32 in PATCH 7
v3 -> v4:
- Rename DT binding from "onnn,slew-rate" to "slew-rate" in PATCH 1 and 6 as
requested in the review comment.
v2 -> v3:
- Dropped PATCH 2 ("media: mt9m114: Add get_mbus_config").
Based on the comments, this issure won't be fixed in the MT9M114
driver but in "imx-media-csi.c" in a separate patch.
- Renumbered patches accordingly.
- Fix the incomplete renaming of the DT property from 'pad-slew-rate'
to 'onnn,slew-rate' in PATCH 1 and 6.
- Fix checkpatch formatting suggestions in PATCH 2 and 6.
v1 -> v2:
- Fix the subjects of the patches
- Dropped PATCH 1 ("Add bypass-pll DT-binding") as it can be automatically
detected if the PLL should be bypassed.
- Renumbered patches accordingly
- Switch to uint32, add default value and clarify documentation in PATCH 1
- Add 'Fixes' and 'Cc' tags as suggested in PATCH 6
Link to v1 discussion:
https://lore.kernel.org/linux-media/20250226153929.274562-1-mathis.foerst@mt.com/
Link to v2 discussion:
https://lore.kernel.org/linux-media/20250304103647.34235-1-mathis.foerst@mt.com/
Link to v3 discussion:
https://lore.kernel.org/linux-media/20250305101453.708270-1-mathis.foerst@mt.com/
Link to v4 discussion:
https://lore.kernel.org/linux-media/20250307093140.370061-1-mathis.foerst@mt.com/
Bugfixes:
- Fix a deadlock when using the V4L2 pad-ops get/set_frame_interval
New Features:
- Bypass the internal PLL if EXTCLK matches the configured link_frequency
- Make the slew-rate of the output pads configurable via DT
- Allow to change the cropping configuration while the sensor is in streaming
state
Thanks,
Mathis
Mathis Foerst (2):
media: mt9m114: Allow set_selection while streaming
media: mt9m114: Set pad-slew-rate
drivers/media/i2c/mt9m114.c | 69 ++++++++++++++++++++++++++++---------
1 file changed, 53 insertions(+), 16 deletions(-)
base-commit: a8598c7de1bcd94461ca54c972efa9b4ea501fb9
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v8 1/2] media: mt9m114: Allow set_selection while streaming
2025-07-14 7:59 [PATCH v8 0/2] MT9M114 driver bugfix and improvements Mathis Foerst
@ 2025-07-14 7:59 ` Mathis Foerst
2025-07-14 7:59 ` [PATCH v8 2/2] media: mt9m114: Set pad-slew-rate Mathis Foerst
2025-07-15 18:55 ` [PATCH v8 0/2] MT9M114 driver bugfix and improvements Laurent Pinchart
2 siblings, 0 replies; 4+ messages in thread
From: Mathis Foerst @ 2025-07-14 7:59 UTC (permalink / raw)
To: linux-kernel
Cc: Mathis Foerst, Sakari Ailus, Laurent Pinchart,
Mauro Carvalho Chehab, linux-media, manuel.traut, mathis.foerst
The current implementation does not apply changes to the crop-
configuration of the sensor immediately if the sensor is in
streaming state. The user has to stop and restart the stream for
the changes to be applied.
This can be undesirable e.g. in a calibration usecase where the user
wants to see the impact of his changes in a live video stream.
Under the condition that the width & height of the cropped image area
does not change, the changed cropping configuration can be applied to
the pixel-array immediately without disturbing the IFP.
Call mt9m114_configure_pa() in mt9m114_pa_set_selection() if the sensor is
in streaming state and the size of the cropping rectangle didn't change,
issue a CONFIG_CHANGE to apply the changes immediately.
Signed-off-by: Mathis Foerst <mathis.foerst@mt.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
drivers/media/i2c/mt9m114.c | 43 ++++++++++++++++++++++++++-----------
1 file changed, 30 insertions(+), 13 deletions(-)
diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c
index 3f540ca40f3c..2020c33cac02 100644
--- a/drivers/media/i2c/mt9m114.c
+++ b/drivers/media/i2c/mt9m114.c
@@ -1287,6 +1287,7 @@ static int mt9m114_pa_set_selection(struct v4l2_subdev *sd,
struct mt9m114 *sensor = pa_to_mt9m114(sd);
struct v4l2_mbus_framefmt *format;
struct v4l2_rect *crop;
+ int ret = 0;
if (sel->target != V4L2_SEL_TGT_CROP)
return -EINVAL;
@@ -1302,25 +1303,41 @@ static int mt9m114_pa_set_selection(struct v4l2_subdev *sd,
* binning, but binning is configured after setting the selection, so
* we can't know tell here if it will be used.
*/
- crop->left = ALIGN(sel->r.left, 4);
- crop->top = ALIGN(sel->r.top, 2);
- crop->width = clamp_t(unsigned int, ALIGN(sel->r.width, 4),
- MT9M114_PIXEL_ARRAY_MIN_OUTPUT_WIDTH,
- MT9M114_PIXEL_ARRAY_WIDTH - crop->left);
- crop->height = clamp_t(unsigned int, ALIGN(sel->r.height, 2),
- MT9M114_PIXEL_ARRAY_MIN_OUTPUT_HEIGHT,
- MT9M114_PIXEL_ARRAY_HEIGHT - crop->top);
-
- sel->r = *crop;
+ sel->r.left = ALIGN(sel->r.left, 4);
+ sel->r.top = ALIGN(sel->r.top, 2);
+ sel->r.width = clamp_t(unsigned int, ALIGN(sel->r.width, 4),
+ MT9M114_PIXEL_ARRAY_MIN_OUTPUT_WIDTH,
+ MT9M114_PIXEL_ARRAY_WIDTH - sel->r.left);
+ sel->r.height = clamp_t(unsigned int, ALIGN(sel->r.height, 2),
+ MT9M114_PIXEL_ARRAY_MIN_OUTPUT_HEIGHT,
+ MT9M114_PIXEL_ARRAY_HEIGHT - sel->r.top);
+
+ /* Changing the selection size is not allowed in streaming state. */
+ if (sensor->streaming &&
+ (sel->r.height != crop->height || sel->r.width != crop->width))
+ return -EBUSY;
+
+ *crop = sel->r;
/* Reset the format. */
format->width = crop->width;
format->height = crop->height;
- if (sel->which == V4L2_SUBDEV_FORMAT_ACTIVE)
- mt9m114_pa_ctrl_update_blanking(sensor, format);
+ if (sel->which != V4L2_SUBDEV_FORMAT_ACTIVE)
+ return ret;
- return 0;
+ mt9m114_pa_ctrl_update_blanking(sensor, format);
+
+ /* Apply values immediately if streaming. */
+ if (sensor->streaming) {
+ ret = mt9m114_configure_pa(sensor, state);
+ if (ret)
+ return ret;
+ /* Changing the cropping config requires a CONFIG_CHANGE. */
+ ret = mt9m114_set_state(sensor,
+ MT9M114_SYS_STATE_ENTER_CONFIG_CHANGE);
+ }
+ return ret;
}
static const struct v4l2_subdev_pad_ops mt9m114_pa_pad_ops = {
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v8 2/2] media: mt9m114: Set pad-slew-rate
2025-07-14 7:59 [PATCH v8 0/2] MT9M114 driver bugfix and improvements Mathis Foerst
2025-07-14 7:59 ` [PATCH v8 1/2] media: mt9m114: Allow set_selection while streaming Mathis Foerst
@ 2025-07-14 7:59 ` Mathis Foerst
2025-07-15 18:55 ` [PATCH v8 0/2] MT9M114 driver bugfix and improvements Laurent Pinchart
2 siblings, 0 replies; 4+ messages in thread
From: Mathis Foerst @ 2025-07-14 7:59 UTC (permalink / raw)
To: linux-kernel
Cc: Mathis Foerst, Sakari Ailus, Laurent Pinchart,
Mauro Carvalho Chehab, linux-media, manuel.traut, mathis.foerst
The MT9M114 supports the different slew rates (0 to 7) on the output pads.
At the moment, this is hardcoded to 7 (the fastest rate).
The user might want to change this values due to EMC requirements.
Read the 'slew-rate' from the DT and configure the pad slew rates of
the output pads accordingly in mt9m114_initialize().
Remove the hardcoded slew rate setting from the mt9m114_init table.
Signed-off-by: Mathis Foerst <mathis.foerst@mt.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
drivers/media/i2c/mt9m114.c | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c
index 2020c33cac02..72701112fa4b 100644
--- a/drivers/media/i2c/mt9m114.c
+++ b/drivers/media/i2c/mt9m114.c
@@ -18,6 +18,7 @@
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/pm_runtime.h>
+#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/types.h>
@@ -42,6 +43,9 @@
#define MT9M114_RESET_AND_MISC_CONTROL CCI_REG16(0x001a)
#define MT9M114_RESET_SOC BIT(0)
#define MT9M114_PAD_SLEW CCI_REG16(0x001e)
+#define MT9M114_PAD_SLEW_MIN 0
+#define MT9M114_PAD_SLEW_MAX 7
+#define MT9M114_PAD_SLEW_DEFAULT 7
#define MT9M114_PAD_CONTROL CCI_REG16(0x0032)
/* XDMA registers */
@@ -388,6 +392,7 @@ struct mt9m114 {
unsigned int pixrate;
bool streaming;
+ u32 pad_slew_rate;
/* Pixel Array */
struct {
@@ -645,9 +650,6 @@ static const struct cci_reg_sequence mt9m114_init[] = {
{ MT9M114_CAM_SENSOR_CFG_FINE_INTEG_TIME_MAX, 1459 },
{ MT9M114_CAM_SENSOR_CFG_FINE_CORRECTION, 96 },
{ MT9M114_CAM_SENSOR_CFG_REG_0_DATA, 32 },
-
- /* Miscellaneous settings */
- { MT9M114_PAD_SLEW, 0x0777 },
};
/* -----------------------------------------------------------------------------
@@ -779,6 +781,13 @@ static int mt9m114_initialize(struct mt9m114 *sensor)
if (ret < 0)
return ret;
+ value = sensor->pad_slew_rate
+ | sensor->pad_slew_rate << 4
+ | sensor->pad_slew_rate << 8;
+ cci_write(sensor->regmap, MT9M114_PAD_SLEW, value, &ret);
+ if (ret < 0)
+ return ret;
+
ret = mt9m114_set_state(sensor, MT9M114_SYS_STATE_ENTER_CONFIG_CHANGE);
if (ret < 0)
return ret;
@@ -2382,6 +2391,17 @@ static int mt9m114_parse_dt(struct mt9m114 *sensor)
goto error;
}
+ sensor->pad_slew_rate = MT9M114_PAD_SLEW_DEFAULT;
+ device_property_read_u32(&sensor->client->dev, "slew-rate",
+ &sensor->pad_slew_rate);
+
+ if (sensor->pad_slew_rate < MT9M114_PAD_SLEW_MIN ||
+ sensor->pad_slew_rate > MT9M114_PAD_SLEW_MAX) {
+ dev_err(&sensor->client->dev, "Invalid slew-rate %u\n",
+ sensor->pad_slew_rate);
+ return -EINVAL;
+ }
+
return 0;
error:
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v8 0/2] MT9M114 driver bugfix and improvements
2025-07-14 7:59 [PATCH v8 0/2] MT9M114 driver bugfix and improvements Mathis Foerst
2025-07-14 7:59 ` [PATCH v8 1/2] media: mt9m114: Allow set_selection while streaming Mathis Foerst
2025-07-14 7:59 ` [PATCH v8 2/2] media: mt9m114: Set pad-slew-rate Mathis Foerst
@ 2025-07-15 18:55 ` Laurent Pinchart
2 siblings, 0 replies; 4+ messages in thread
From: Laurent Pinchart @ 2025-07-15 18:55 UTC (permalink / raw)
To: Mathis Foerst
Cc: linux-kernel, Sakari Ailus, Mauro Carvalho Chehab, linux-media,
manuel.traut, mathis.foerst
Hi Mathis,
Thank you for the patches.
The series is fully reviewed. It's unfortuantely a bit too late for
v6.17, I expect Sakari will pick it up for v6.18.
On Mon, Jul 14, 2025 at 09:59:25AM +0200, Mathis Foerst wrote:
> Hi,
>
> this patch series contains the following bugfix and improvements
> for the MT9M114 camera driver:
>
> Changelog:
>
> v7 -> v8:
> - Add missing braces in 1.
> - Fix formatting issues as suggested in review.
>
> v6 -> v7:
> - Remove already picked patches 1, 2, 3 and 6.
> - Remove patch 4 as suggested in review.
> - Fix formatting issues
> - Return -EBUSY from mt9m114_pa_set_selection if the cropping size changes
> while in streaming state.
>
> v5 -> v6:
> - Add 'Reviewed-By:' tags. Sorry for forgetting this in the previous versions
>
> v4 -> v5:
> - Apply reformatings and small refactorings as suggested in review comments
> - Split PATCH 4 into two parts: One for applying HFLIP / VFLIP while
> streaming, one for applying set_selection while streaming.
> - Add condition to apply set_selection immediately only if the size of the
> cropping rectangle does not change in PATCH 5
> - Use device_property_read_u32 instead of of_property_read_u32 in PATCH 7
>
> v3 -> v4:
> - Rename DT binding from "onnn,slew-rate" to "slew-rate" in PATCH 1 and 6 as
> requested in the review comment.
>
> v2 -> v3:
> - Dropped PATCH 2 ("media: mt9m114: Add get_mbus_config").
> Based on the comments, this issure won't be fixed in the MT9M114
> driver but in "imx-media-csi.c" in a separate patch.
> - Renumbered patches accordingly.
> - Fix the incomplete renaming of the DT property from 'pad-slew-rate'
> to 'onnn,slew-rate' in PATCH 1 and 6.
> - Fix checkpatch formatting suggestions in PATCH 2 and 6.
>
> v1 -> v2:
> - Fix the subjects of the patches
> - Dropped PATCH 1 ("Add bypass-pll DT-binding") as it can be automatically
> detected if the PLL should be bypassed.
> - Renumbered patches accordingly
> - Switch to uint32, add default value and clarify documentation in PATCH 1
> - Add 'Fixes' and 'Cc' tags as suggested in PATCH 6
>
> Link to v1 discussion:
> https://lore.kernel.org/linux-media/20250226153929.274562-1-mathis.foerst@mt.com/
> Link to v2 discussion:
> https://lore.kernel.org/linux-media/20250304103647.34235-1-mathis.foerst@mt.com/
> Link to v3 discussion:
> https://lore.kernel.org/linux-media/20250305101453.708270-1-mathis.foerst@mt.com/
> Link to v4 discussion:
> https://lore.kernel.org/linux-media/20250307093140.370061-1-mathis.foerst@mt.com/
>
> Bugfixes:
> - Fix a deadlock when using the V4L2 pad-ops get/set_frame_interval
>
> New Features:
> - Bypass the internal PLL if EXTCLK matches the configured link_frequency
> - Make the slew-rate of the output pads configurable via DT
> - Allow to change the cropping configuration while the sensor is in streaming
> state
>
> Thanks,
> Mathis
>
> Mathis Foerst (2):
> media: mt9m114: Allow set_selection while streaming
> media: mt9m114: Set pad-slew-rate
>
> drivers/media/i2c/mt9m114.c | 69 ++++++++++++++++++++++++++++---------
> 1 file changed, 53 insertions(+), 16 deletions(-)
>
>
> base-commit: a8598c7de1bcd94461ca54c972efa9b4ea501fb9
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-07-15 18:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-14 7:59 [PATCH v8 0/2] MT9M114 driver bugfix and improvements Mathis Foerst
2025-07-14 7:59 ` [PATCH v8 1/2] media: mt9m114: Allow set_selection while streaming Mathis Foerst
2025-07-14 7:59 ` [PATCH v8 2/2] media: mt9m114: Set pad-slew-rate Mathis Foerst
2025-07-15 18:55 ` [PATCH v8 0/2] MT9M114 driver bugfix and improvements Laurent Pinchart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).