Skip to content

Commit 3fdd5bf

Browse files
committed
drm/i915/panel: register drm_panel and call prepare/unprepare for ICL+ DSI
Allocate and register a drm_panel so that drm_panel_followers can find the panel. Pass the drm_connector::kdev device to drm_panel allocation for matching. That's only available after drm_sysfs_connector_add(), so we need to postpone the drm_panel allocation until .late_register() hook. The drm_panel framework is moving towards devm_drm_panel_alloc(). It requires a wrapper struct, and struct intel_panel would be the natural candidate. However, we can't postpone its allocation until .late_register(), so we have to use __devm_drm_panel_alloc() directly for now. Call the drm_panel_prepare() and drm_panel_unprepare() functions for ICL+ DSI, so that followers get notified of the panel power state changes. This can later be expanded to VLV+ DSI and eDP. Cc: Maxime Ripard <[email protected]> Cc: Heikki Krogerus <[email protected]> Cc: Lee Shawn C <[email protected]> Tested-by: Lee Shawn C <[email protected]> Reviewed-by: Maxime Ripard <[email protected]> Link: https://lore.kernel.org/r/13d15c1414e65ffb21944d66e2820befdab54e98.1749199013.git.jani.nikula@intel.com Signed-off-by: Jani Nikula <[email protected]>
1 parent 421ae44 commit 3fdd5bf

File tree

4 files changed

+93
-1
lines changed

4 files changed

+93
-1
lines changed

drivers/gpu/drm/i915/display/icl_dsi.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,8 @@ static void gen11_dsi_enable(struct intel_atomic_state *state,
12761276
intel_backlight_enable(crtc_state, conn_state);
12771277
intel_dsi_vbt_exec_sequence(intel_dsi, MIPI_SEQ_BACKLIGHT_ON);
12781278

1279+
intel_panel_prepare(crtc_state, conn_state);
1280+
12791281
intel_crtc_vblank_on(crtc_state);
12801282
}
12811283

@@ -1409,6 +1411,8 @@ static void gen11_dsi_disable(struct intel_atomic_state *state,
14091411
{
14101412
struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder);
14111413

1414+
intel_panel_unprepare(old_conn_state);
1415+
14121416
/* step1: turn off backlight */
14131417
intel_dsi_vbt_exec_sequence(intel_dsi, MIPI_SEQ_BACKLIGHT_OFF);
14141418
intel_backlight_disable(old_conn_state);

drivers/gpu/drm/i915/display/intel_display_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <drm/drm_crtc.h>
3838
#include <drm/drm_encoder.h>
3939
#include <drm/drm_framebuffer.h>
40+
#include <drm/drm_panel.h>
4041
#include <drm/drm_rect.h>
4142
#include <drm/drm_vblank_work.h>
4243
#include <drm/intel/i915_hdcp_interface.h>
@@ -384,6 +385,9 @@ struct intel_vbt_panel_data {
384385
};
385386

386387
struct intel_panel {
388+
/* Simple drm_panel */
389+
struct drm_panel *base;
390+
387391
/* Fixed EDID for eDP and LVDS. May hold ERR_PTR for invalid EDID. */
388392
const struct drm_edid *fixed_edid;
389393

drivers/gpu/drm/i915/display/intel_panel.c

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,12 +463,92 @@ void intel_panel_fini(struct intel_connector *connector)
463463
}
464464
}
465465

466+
const struct drm_panel_funcs dummy_panel_funcs = {
467+
};
468+
466469
int intel_panel_register(struct intel_connector *connector)
467470
{
468-
return intel_backlight_device_register(connector);
471+
struct intel_display *display = to_intel_display(connector);
472+
struct intel_panel *panel = &connector->panel;
473+
int ret;
474+
475+
ret = intel_backlight_device_register(connector);
476+
if (ret)
477+
return ret;
478+
479+
if (connector->base.connector_type == DRM_MODE_CONNECTOR_DSI) {
480+
struct device *dev = connector->base.kdev;
481+
struct drm_panel *base;
482+
483+
/* Sanity check. */
484+
if (drm_WARN_ON(display->drm, !dev))
485+
goto out;
486+
487+
/*
488+
* We need drm_connector::kdev for allocating the panel, to make
489+
* drm_panel_add_follower() lookups work. The kdev is
490+
* initialized in drm_sysfs_connector_add(), just before the
491+
* connector .late_register() hooks. So we can't allocate the
492+
* panel at connector init time, and can't allocate struct
493+
* intel_panel with a drm_panel sub-struct. For now, use
494+
* __devm_drm_panel_alloc() directly.
495+
*
496+
* The lookups also depend on drm_connector::fwnode being set in
497+
* intel_acpi_assign_connector_fwnodes(). However, if that's
498+
* missing, it will gracefully lead to -EPROBE_DEFER in
499+
* drm_panel_add_follower().
500+
*/
501+
base = __devm_drm_panel_alloc(dev, sizeof(*base), 0,
502+
&dummy_panel_funcs,
503+
connector->base.connector_type);
504+
if (IS_ERR(base)) {
505+
ret = PTR_ERR(base);
506+
goto err;
507+
}
508+
509+
panel->base = base;
510+
511+
drm_panel_add(panel->base);
512+
513+
drm_dbg_kms(display->drm, "[CONNECTOR:%d:%s] Registered panel device '%s', has fwnode: %s\n",
514+
connector->base.base.id, connector->base.name,
515+
dev_name(dev), str_yes_no(dev_fwnode(dev)));
516+
}
517+
518+
out:
519+
return 0;
520+
521+
err:
522+
intel_backlight_device_unregister(connector);
523+
524+
return ret;
469525
}
470526

471527
void intel_panel_unregister(struct intel_connector *connector)
472528
{
529+
struct intel_panel *panel = &connector->panel;
530+
531+
if (panel->base)
532+
drm_panel_remove(panel->base);
533+
473534
intel_backlight_device_unregister(connector);
474535
}
536+
537+
/* Notify followers, if any, about power being up. */
538+
void intel_panel_prepare(const struct intel_crtc_state *crtc_state,
539+
const struct drm_connector_state *conn_state)
540+
{
541+
struct intel_connector *connector = to_intel_connector(conn_state->connector);
542+
struct intel_panel *panel = &connector->panel;
543+
544+
drm_panel_prepare(panel->base);
545+
}
546+
547+
/* Notify followers, if any, about power going down. */
548+
void intel_panel_unprepare(const struct drm_connector_state *old_conn_state)
549+
{
550+
struct intel_connector *connector = to_intel_connector(old_conn_state->connector);
551+
struct intel_panel *panel = &connector->panel;
552+
553+
drm_panel_unprepare(panel->base);
554+
}

drivers/gpu/drm/i915/display/intel_panel.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,8 @@ void intel_panel_add_vbt_sdvo_fixed_mode(struct intel_connector *connector);
5353
void intel_panel_add_encoder_fixed_mode(struct intel_connector *connector,
5454
struct intel_encoder *encoder);
5555

56+
void intel_panel_prepare(const struct intel_crtc_state *crtc_state,
57+
const struct drm_connector_state *conn_state);
58+
void intel_panel_unprepare(const struct drm_connector_state *old_conn_state);
59+
5660
#endif /* __INTEL_PANEL_H__ */

0 commit comments

Comments
 (0)