Re: [PATCH v2 2/2] media: i2c: mt9m114: add support for Aptina MI1040
From: johannes . goede
Date: Thu Feb 12 2026 - 10:59:47 EST
Hi,
On 12-Feb-26 13:23, Svyatoslav Ryhel wrote:
> Slightly different version of MT9M114 camera module is used in a several
> devices like ASUS Nexus 7 (2012) or ASUS Transformer Prime TF201 and is
> called Aptina MI1040. The only difference found so far is lacking ability
> to poll STATE register during power on sequence, which causes driver to
> fail with time out error. Add state_polling flag to diverge models and
> address quirk found in MI1040.
>
> Signed-off-by: Svyatoslav Ryhel <clamor95@xxxxxxxxx>
> ---
> drivers/media/i2c/mt9m114.c | 29 ++++++++++++++++++++++++-----
> 1 file changed, 24 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c
> index d5b142fe68a9..a4b021702a1f 100644
> --- a/drivers/media/i2c/mt9m114.c
> +++ b/drivers/media/i2c/mt9m114.c
> @@ -373,6 +373,10 @@ enum {
> * Data Structures
> */
>
> +struct mt9m114_model_info {
> + bool state_polling;
> +};
> +
> enum mt9m114_format_flag {
> MT9M114_FMT_FLAG_PARALLEL = BIT(0),
> MT9M114_FMT_FLAG_CSI2 = BIT(1),
> @@ -422,6 +426,8 @@ struct mt9m114 {
>
> struct v4l2_ctrl *tpg[4];
> } ifp;
> +
> + const struct mt9m114_model_info *info;
> };
>
> /* -----------------------------------------------------------------------------
> @@ -2279,9 +2285,11 @@ static int mt9m114_power_on(struct mt9m114 *sensor)
> * reaches the standby mode (either initiated manually above in
> * parallel mode, or automatically after reset in MIPI mode).
> */
> - ret = mt9m114_poll_state(sensor, MT9M114_SYS_STATE_STANDBY);
> - if (ret < 0)
> - goto error_clock;
> + if (sensor->info->state_polling) {
> + ret = mt9m114_poll_state(sensor, MT9M114_SYS_STATE_STANDBY);
> + if (ret < 0)
> + goto error_clock;
> + }
So I would expect a flag called state_polling to be checked
in mt9m114_poll_state(). It looks like you are only disabling
one specific case of state polling, not all of them.
Please rename the flag to reflect this.
>
> return 0;
>
> @@ -2527,6 +2535,8 @@ static int mt9m114_probe(struct i2c_client *client)
> if (ret < 0)
> return ret;
>
> + sensor->info = device_get_match_data(dev);
> +
This can return NULL when the driver is manually bound through
sysfs, which will result in a crash later on when checked in
mt9m114_power_on()
Regards,
Hans
> /* Acquire clocks, GPIOs and regulators. */
> sensor->clk = devm_v4l2_sensor_clk_get(dev, NULL);
> if (IS_ERR(sensor->clk)) {
> @@ -2641,9 +2651,18 @@ static void mt9m114_remove(struct i2c_client *client)
> pm_runtime_set_suspended(dev);
> }
>
> +static const struct mt9m114_model_info mt9m114_models_default = {
> + .state_polling = true,
> +};
> +
> +static const struct mt9m114_model_info mt9m114_models_aptina = {
> + .state_polling = false,
> +};
> +
> static const struct of_device_id mt9m114_of_ids[] = {
> - { .compatible = "onnn,mt9m114" },
> - { /* sentinel */ },
> + { .compatible = "onnn,mt9m114", .data = &mt9m114_models_default },
> + { .compatible = "aptina,mi1040", .data = &mt9m114_models_aptina },
> + { /* sentinel */ }
> };
> MODULE_DEVICE_TABLE(of, mt9m114_of_ids);
>