Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <mripard@kernel.org>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Lee Shawn C <shawn.c.lee@intel.com>
Tested-by: Lee Shawn C <shawn.c.lee@intel.com>
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/r/13d15c1414e65ffb21944d66e2820befdab54e98.1749199013.git.jani.nikula@intel.com
Signed-off-by: Jani Nikula <jani.nikula@intel.com>

+93 -1
+4
drivers/gpu/drm/i915/display/icl_dsi.c
··· 1276 1276 intel_backlight_enable(crtc_state, conn_state); 1277 1277 intel_dsi_vbt_exec_sequence(intel_dsi, MIPI_SEQ_BACKLIGHT_ON); 1278 1278 1279 + intel_panel_prepare(crtc_state, conn_state); 1280 + 1279 1281 intel_crtc_vblank_on(crtc_state); 1280 1282 } 1281 1283 ··· 1410 1408 const struct drm_connector_state *old_conn_state) 1411 1409 { 1412 1410 struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder); 1411 + 1412 + intel_panel_unprepare(old_conn_state); 1413 1413 1414 1414 /* step1: turn off backlight */ 1415 1415 intel_dsi_vbt_exec_sequence(intel_dsi, MIPI_SEQ_BACKLIGHT_OFF);
+4
drivers/gpu/drm/i915/display/intel_display_types.h
··· 37 37 #include <drm/drm_crtc.h> 38 38 #include <drm/drm_encoder.h> 39 39 #include <drm/drm_framebuffer.h> 40 + #include <drm/drm_panel.h> 40 41 #include <drm/drm_rect.h> 41 42 #include <drm/drm_vblank_work.h> 42 43 #include <drm/intel/i915_hdcp_interface.h> ··· 385 384 }; 386 385 387 386 struct intel_panel { 387 + /* Simple drm_panel */ 388 + struct drm_panel *base; 389 + 388 390 /* Fixed EDID for eDP and LVDS. May hold ERR_PTR for invalid EDID. */ 389 391 const struct drm_edid *fixed_edid; 390 392
+81 -1
drivers/gpu/drm/i915/display/intel_panel.c
··· 463 463 } 464 464 } 465 465 466 + const struct drm_panel_funcs dummy_panel_funcs = { 467 + }; 468 + 466 469 int intel_panel_register(struct intel_connector *connector) 467 470 { 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; 469 525 } 470 526 471 527 void intel_panel_unregister(struct intel_connector *connector) 472 528 { 529 + struct intel_panel *panel = &connector->panel; 530 + 531 + if (panel->base) 532 + drm_panel_remove(panel->base); 533 + 473 534 intel_backlight_device_unregister(connector); 535 + } 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); 474 554 }
+4
drivers/gpu/drm/i915/display/intel_panel.h
··· 53 53 void intel_panel_add_encoder_fixed_mode(struct intel_connector *connector, 54 54 struct intel_encoder *encoder); 55 55 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 + 56 60 #endif /* __INTEL_PANEL_H__ */