Skip to content

Commit 762f8c1

Browse files
Thomas Zimmermannjnikula
authored andcommitted
drm/{i915,xe}: Implement fbdev client callbacks
Move code from ad-hoc fbdev callbacks into DRM client functions and remove the old callbacks. The functions instruct the client to poll for changed output or restore the display. The DRM core calls both, the old callbacks and the new client helpers, from the same places. The new functions perform the same operation as before, so there's no change in functionality. Fox xe, remove xe_display_last_close(), which restored the fbdev display. As with i915, the DRM core's drm_lastclose() performs this operation automatically. v8: - mention xe in commit message v7: - update xe driver v6: - return errors from client callbacks (Jouni) Signed-off-by: Thomas Zimmermann <[email protected]> Reviewed-by: Jouni Högander <[email protected]> Acked-by: Lucas De Marchi <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Jani Nikula <[email protected]>
1 parent f3a36cb commit 762f8c1

File tree

5 files changed

+25
-49
lines changed

5 files changed

+25
-49
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ void intel_display_driver_init_hw(struct drm_i915_private *i915)
9999
static const struct drm_mode_config_funcs intel_mode_funcs = {
100100
.fb_create = intel_user_framebuffer_create,
101101
.get_format_info = intel_fb_get_format_info,
102-
.output_poll_changed = intel_fbdev_output_poll_changed,
103102
.mode_valid = intel_mode_valid,
104103
.atomic_check = intel_atomic_check,
105104
.atomic_commit = intel_atomic_commit,

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

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -551,13 +551,13 @@ void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous
551551
intel_fbdev_hpd_set_suspend(dev_priv, state);
552552
}
553553

554-
void intel_fbdev_output_poll_changed(struct drm_device *dev)
554+
static int intel_fbdev_output_poll_changed(struct drm_device *dev)
555555
{
556556
struct intel_fbdev *ifbdev = to_i915(dev)->display.fbdev.fbdev;
557557
bool send_hpd;
558558

559559
if (!ifbdev)
560-
return;
560+
return -EINVAL;
561561

562562
intel_fbdev_sync(ifbdev);
563563

@@ -568,21 +568,29 @@ void intel_fbdev_output_poll_changed(struct drm_device *dev)
568568

569569
if (send_hpd && (ifbdev->vma || ifbdev->helper.deferred_setup))
570570
drm_fb_helper_hotplug_event(&ifbdev->helper);
571+
572+
return 0;
571573
}
572574

573-
void intel_fbdev_restore_mode(struct drm_i915_private *dev_priv)
575+
static int intel_fbdev_restore_mode(struct drm_i915_private *dev_priv)
574576
{
575577
struct intel_fbdev *ifbdev = dev_priv->display.fbdev.fbdev;
578+
int ret;
576579

577580
if (!ifbdev)
578-
return;
581+
return -EINVAL;
579582

580583
intel_fbdev_sync(ifbdev);
581584
if (!ifbdev->vma)
582-
return;
585+
return -ENOMEM;
583586

584-
if (drm_fb_helper_restore_fbdev_mode_unlocked(&ifbdev->helper) == 0)
585-
intel_fbdev_invalidate(ifbdev);
587+
ret = drm_fb_helper_restore_fbdev_mode_unlocked(&ifbdev->helper);
588+
if (ret)
589+
return ret;
590+
591+
intel_fbdev_invalidate(ifbdev);
592+
593+
return 0;
586594
}
587595

588596
/*
@@ -594,12 +602,21 @@ static void intel_fbdev_client_unregister(struct drm_client_dev *client)
594602

595603
static int intel_fbdev_client_restore(struct drm_client_dev *client)
596604
{
605+
struct drm_i915_private *dev_priv = to_i915(client->dev);
606+
int ret;
607+
608+
ret = intel_fbdev_restore_mode(dev_priv);
609+
if (ret)
610+
return ret;
611+
612+
vga_switcheroo_process_delayed_switch();
613+
597614
return 0;
598615
}
599616

600617
static int intel_fbdev_client_hotplug(struct drm_client_dev *client)
601618
{
602-
return 0;
619+
return intel_fbdev_output_poll_changed(client->dev);
603620
}
604621

605622
static const struct drm_client_funcs intel_fbdev_client_funcs = {

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ void intel_fbdev_initial_config_async(struct drm_i915_private *dev_priv);
1919
void intel_fbdev_unregister(struct drm_i915_private *dev_priv);
2020
void intel_fbdev_fini(struct drm_i915_private *dev_priv);
2121
void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous);
22-
void intel_fbdev_output_poll_changed(struct drm_device *dev);
23-
void intel_fbdev_restore_mode(struct drm_i915_private *dev_priv);
2422
struct intel_framebuffer *intel_fbdev_framebuffer(struct intel_fbdev *fbdev);
2523
#else
2624
static inline int intel_fbdev_init(struct drm_device *dev)
@@ -44,13 +42,6 @@ static inline void intel_fbdev_set_suspend(struct drm_device *dev, int state, bo
4442
{
4543
}
4644

47-
static inline void intel_fbdev_output_poll_changed(struct drm_device *dev)
48-
{
49-
}
50-
51-
static inline void intel_fbdev_restore_mode(struct drm_i915_private *i915)
52-
{
53-
}
5445
static inline struct intel_framebuffer *intel_fbdev_framebuffer(struct intel_fbdev *fbdev)
5546
{
5647
return NULL;

drivers/gpu/drm/i915/i915_driver.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -920,27 +920,6 @@ static int i915_driver_open(struct drm_device *dev, struct drm_file *file)
920920
return 0;
921921
}
922922

923-
/**
924-
* i915_driver_lastclose - clean up after all DRM clients have exited
925-
* @dev: DRM device
926-
*
927-
* Take care of cleaning up after all DRM clients have exited. In the
928-
* mode setting case, we want to restore the kernel's initial mode (just
929-
* in case the last client left us in a bad state).
930-
*
931-
* Additionally, in the non-mode setting case, we'll tear down the GTT
932-
* and DMA structures, since the kernel won't be using them, and clea
933-
* up any GEM state.
934-
*/
935-
static void i915_driver_lastclose(struct drm_device *dev)
936-
{
937-
struct drm_i915_private *i915 = to_i915(dev);
938-
939-
intel_fbdev_restore_mode(i915);
940-
941-
vga_switcheroo_process_delayed_switch();
942-
}
943-
944923
static void i915_driver_postclose(struct drm_device *dev, struct drm_file *file)
945924
{
946925
struct drm_i915_file_private *file_priv = file->driver_priv;
@@ -1831,7 +1810,6 @@ static const struct drm_driver i915_drm_driver = {
18311810
DRIVER_SYNCOBJ_TIMELINE,
18321811
.release = i915_driver_release,
18331812
.open = i915_driver_open,
1834-
.lastclose = i915_driver_lastclose,
18351813
.postclose = i915_driver_postclose,
18361814
.show_fdinfo = PTR_IF(IS_ENABLED(CONFIG_PROC_FS), i915_drm_client_fdinfo),
18371815

drivers/gpu/drm/xe/display/xe_display.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,6 @@ bool xe_display_driver_probe_defer(struct pci_dev *pdev)
5151
return intel_display_driver_probe_defer(pdev);
5252
}
5353

54-
static void xe_display_last_close(struct drm_device *dev)
55-
{
56-
struct xe_device *xe = to_xe_device(dev);
57-
58-
if (xe->info.enable_display)
59-
intel_fbdev_restore_mode(to_xe_device(dev));
60-
}
61-
6254
/**
6355
* xe_display_driver_set_hooks - Add driver flags and hooks for display
6456
* @driver: DRM device driver
@@ -73,7 +65,6 @@ void xe_display_driver_set_hooks(struct drm_driver *driver)
7365
return;
7466

7567
driver->driver_features |= DRIVER_MODESET | DRIVER_ATOMIC;
76-
driver->lastclose = xe_display_last_close;
7768
}
7869

7970
static void unset_display_features(struct xe_device *xe)

0 commit comments

Comments
 (0)