mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Esteban Urrutia <esteuwu@proton.me>
To: Neil Armstrong <neil.armstrong@linaro.org>,
	Jessica Zhang <jesszhan0024@gmail.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>
Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, phone-devel@vger.kernel.org
Subject: Re: [PATCH 2/2] drm/panel: Add driver for Novatek NT37703 based panels
Date: Wed, 12 Aug 2026 20:05:30 +0000	[thread overview]
Message-ID: <d74f4f83-b7a3-413b-8c12-e52d90914ada@proton.me> (raw)
In-Reply-To: <7757da0a-ef3a-44b0-99c2-af9af3e21a0b@linaro.org>

On 8/12/26 7:55 AM, Neil Armstrong wrote:
>> +static int nt37703_get_modes(struct drm_panel *panel, struct drm_connector *connector)
>> +{
>> +	struct panel_info *pinfo = to_panel_info(panel);
>> +	int i;
>> +
>> +	for (i = 0; i < pinfo->desc->num_modes; i++) {
>> +		const struct drm_display_mode *m = &pinfo->desc->modes[i];
>> +		struct drm_display_mode *mode;
>> +
>> +		mode = drm_mode_duplicate(connector->dev, m);
>> +		if (!mode) {
>> +			dev_err(panel->dev, "Failed to add mode %ux%u@%u\n", m->hdisplay,
>> +				m->vdisplay, drm_mode_vrefresh(m));
>> +			return -ENOMEM;
>> +		}
>> +
>> +		mode->type = DRM_MODE_TYPE_DRIVER;
>> +		if (i == 0)
>> +			mode->type |= DRM_MODE_TYPE_PREFERRED;
>> +
>> +		drm_mode_set_name(mode);
>> +		drm_mode_probed_add(connector, mode);
>> +	}
>> +
>> +	connector->display_info.width_mm = pinfo->desc->width_mm;
>> +	connector->display_info.height_mm = pinfo->desc->height_mm;
>> +
>> +	return pinfo->desc->num_modes;
> 
> The only supported panel only supports a single mode, just support
> a single mode for now and drop this open coded support for multiple modes.
> 
> You can add it later if somehow you need multiple modes.


The idea is that for each new panel, instead of modifying the driver,
only these structures are added:
- (panel)_modes[]
- (panel)_init_sequence()
- struct drm_dsc_config (panel)_dsc
- (panel)_desc
And modifying the of_device_id table afterwards.

So dropping only the modes would mean getting rid of all these
altogether, otherwise the only supported mode would be hardcoded which
renders these structures useless.

[...]

>> +static int nt37703_probe(struct mipi_dsi_device *dsi)
>> +{
>> +	struct device *dev = &dsi->dev;
>> +	struct panel_info *pinfo;
>> +	int ret;
>> +
>> +	pinfo = devm_drm_panel_alloc(dev, struct panel_info, panel, &nt37703_panel_funcs,
>> +				     DRM_MODE_CONNECTOR_DSI);
>> +	if (IS_ERR(pinfo))
>> +		return PTR_ERR(pinfo);
>> +
>> +	pinfo->desc = of_device_get_match_data(dev);
>> +	if (IS_ERR(pinfo->desc))
>> +		return PTR_ERR(pinfo->desc);
>> +
>> +	ret = devm_regulator_bulk_get_const(dev, ARRAY_SIZE(nt37703_supplies), nt37703_supplies,
>> +					    &pinfo->supplies);
>> +	if (ret < 0)
>> +		return dev_err_probe(dev, ret, "Failed to get regulators\n");
>> +
>> +	pinfo->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
>> +	if (IS_ERR(pinfo->reset_gpio))
>> +		return dev_err_probe(dev, PTR_ERR(pinfo->reset_gpio),
>> +				     "Failed to get reset-gpios\n");
>> +
>> +	pinfo->dsi = dsi;
>> +	mipi_dsi_set_drvdata(dsi, pinfo);
>> +
>> +	dsi->lanes = pinfo->desc->lanes;
>> +	dsi->format = pinfo->desc->format;
>> +	dsi->mode_flags = pinfo->desc->mode_flags;
>> +
>> +	pinfo->panel.prepare_prev_first = true;
>> +
>> +	pinfo->panel.backlight = nt37703_create_backlight(dsi);
>> +	if (IS_ERR(pinfo->panel.backlight))
>> +		return dev_err_probe(dev, PTR_ERR(pinfo->panel.backlight),
>> +				     "Failed to create backlight\n");
>> +
>> +	drm_panel_add(&pinfo->panel);
> 
> Use devm_ variant


Ack

>> +
>> +	/* This panel only supports DSC; unconditionally enable it */
>> +	pinfo->dsc = *(pinfo->desc->dsc);
>> +	dsi->dsc = &pinfo->dsc;
>> +
>> +	ret = mipi_dsi_attach(dsi);
> 
> Use devm_ variant

Ack


>> +	if (ret < 0) {
>> +		drm_panel_remove(&pinfo->panel);
>> +		return dev_err_probe(dev, ret, "Failed to attach to DSI host\n");
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>> +static void nt37703_remove(struct mipi_dsi_device *dsi)
>> +{
>> +	struct panel_info *pinfo = mipi_dsi_get_drvdata(dsi);
>> +	int ret;
>> +
>> +	ret = mipi_dsi_detach(dsi);
>> +	if (ret < 0)
>> +		dev_err(&dsi->dev, "Failed to detach from DSI host: %d\n", ret);
>> +
>> +	drm_panel_remove(&pinfo->panel);
>> +}
> 
> And drop the remove()


Ack

Thanks for reviewing.
Regards,
Esteban


      reply	other threads:[~2026-08-12 20:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-11  5:52 [PATCH 0/2] Add panel driver for Novatek NT37703 Esteban Urrutia via B4 Relay
2026-08-11  5:52 ` [PATCH 1/2] dt-bindings: display: panel: Add bindings " Esteban Urrutia via B4 Relay
2026-08-11 13:05   ` David Heidelberg
2026-08-12  5:21     ` Esteban Urrutia
2026-08-12  8:46       ` David Heidelberg
2026-08-12 11:52         ` Neil Armstrong
2026-08-12 12:15           ` David Heidelberg
2026-08-12 12:22             ` Neil Armstrong
2026-08-12 12:53               ` David Heidelberg
2026-08-12 14:29                 ` Neil Armstrong
2026-08-12 20:10           ` Esteban Urrutia
2026-08-11  5:52 ` [PATCH 2/2] drm/panel: Add driver for Novatek NT37703 based panels Esteban Urrutia via B4 Relay
2026-08-11 14:28   ` Uwe Kleine-König
2026-08-12 11:55   ` Neil Armstrong
2026-08-12 20:05     ` Esteban Urrutia [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d74f4f83-b7a3-413b-8c12-e52d90914ada@proton.me \
    --to=esteuwu@proton.me \
    --cc=airlied@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jesszhan0024@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=phone-devel@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®