Created
March 8, 2018 14:14
-
-
Save avafinger/40e7751f5d8e8fbe0225e3ad4c5da0bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- /arm/ubuntu/h5/mainline/kernel_4.15.y/drivers/gpu/drm/sun4i/sun4i_crtc.c | |
+++ /arm/ubuntu/h2/mainline/kernel_4.15.y/drivers/gpu/drm/sun4i/sun4i_crtc.c | |
@@ -93,6 +93,8 @@ | |
DRM_DEBUG_DRIVER("Disabling the CRTC\n"); | |
+ drm_crtc_vblank_off(crtc); | |
+ | |
sun4i_tcon_set_status(scrtc->tcon, encoder, false); | |
if (crtc->state->event && !crtc->state->active) { | |
@@ -113,6 +115,8 @@ | |
DRM_DEBUG_DRIVER("Enabling the CRTC\n"); | |
sun4i_tcon_set_status(scrtc->tcon, encoder, true); | |
+ | |
+ drm_crtc_vblank_on(crtc); | |
} | |
static void sun4i_crtc_mode_set_nofb(struct drm_crtc *crtc) | |
--- /arm/ubuntu/h5/mainline/kernel_4.15.y/drivers/gpu/drm/sun4i/sun4i_tcon.c | |
+++ /arm/ubuntu/h2/mainline/kernel_4.15.y/drivers/gpu/drm/sun4i/sun4i_tcon.c | |
@@ -338,6 +338,9 @@ | |
regmap_update_bits(tcon->regs, SUN4I_TCON_GCTL_REG, | |
SUN4I_TCON_GCTL_IOMAP_MASK, | |
SUN4I_TCON_GCTL_IOMAP_TCON0); | |
+ | |
+ /* Enable the output on the pins */ | |
+ regmap_write(tcon->regs, SUN4I_TCON0_IO_TRI_REG, 0xe0000000); | |
} | |
static void sun4i_tcon0_mode_set_rgb(struct sun4i_tcon *tcon, | |
--- /arm/ubuntu/h5/mainline/kernel_4.15.y/drivers/gpu/drm/drm_fb_helper.c | |
+++ /arm/ubuntu/h2/mainline/kernel_4.15.y/drivers/gpu/drm/drm_fb_helper.c | |
@@ -150,6 +150,9 @@ | |
{ | |
int err; | |
+ if (!fb_helper) | |
+ return 0; | |
+ | |
mutex_lock(&fb_helper->lock); | |
err = __drm_fb_helper_add_one_connector(fb_helper, connector); | |
mutex_unlock(&fb_helper->lock); | |
@@ -174,13 +177,15 @@ | |
*/ | |
int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper) | |
{ | |
- struct drm_device *dev = fb_helper->dev; | |
+ struct drm_device *dev; | |
struct drm_connector *connector; | |
struct drm_connector_list_iter conn_iter; | |
int i, ret = 0; | |
- if (!drm_fbdev_emulation) | |
+ if (!drm_fbdev_emulation || !fb_helper) | |
return 0; | |
+ | |
+ dev = fb_helper->dev; | |
mutex_lock(&fb_helper->lock); | |
drm_connector_list_iter_begin(dev, &conn_iter); | |
@@ -245,6 +250,9 @@ | |
{ | |
int err; | |
+ if (!fb_helper) | |
+ return 0; | |
+ | |
mutex_lock(&fb_helper->lock); | |
err = __drm_fb_helper_remove_one_connector(fb_helper, connector); | |
mutex_unlock(&fb_helper->lock); | |
@@ -350,6 +358,7 @@ | |
static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool active) | |
{ | |
struct drm_device *dev = fb_helper->dev; | |
+ struct drm_plane_state *plane_state; | |
struct drm_plane *plane; | |
struct drm_atomic_state *state; | |
int i, ret; | |
@@ -368,8 +377,6 @@ | |
retry: | |
plane_mask = 0; | |
drm_for_each_plane(plane, dev) { | |
- struct drm_plane_state *plane_state; | |
- | |
plane_state = drm_atomic_get_plane_state(state, plane); | |
if (IS_ERR(plane_state)) { | |
ret = PTR_ERR(plane_state); | |
@@ -392,6 +399,10 @@ | |
for (i = 0; i < fb_helper->crtc_count; i++) { | |
struct drm_mode_set *mode_set = &fb_helper->crtc_info[i].mode_set; | |
+ struct drm_plane *primary = mode_set->crtc->primary; | |
+ | |
+ /* Cannot fail as we've already gotten the plane state above */ | |
+ plane_state = drm_atomic_get_new_plane_state(state, primary); | |
ret = __drm_atomic_helper_set_config(mode_set, state); | |
if (ret != 0) | |
@@ -498,7 +509,7 @@ | |
bool do_delayed; | |
int ret; | |
- if (!drm_fbdev_emulation) | |
+ if (!drm_fbdev_emulation || !fb_helper) | |
return -ENODEV; | |
if (READ_ONCE(fb_helper->deferred_setup)) | |
@@ -2598,7 +2609,7 @@ | |
{ | |
int err = 0; | |
- if (!drm_fbdev_emulation) | |
+ if (!drm_fbdev_emulation || !fb_helper) | |
return 0; | |
mutex_lock(&fb_helper->lock); | |
--- /arm/ubuntu/h5/mainline/kernel_4.15.y/drivers/gpu/drm/drm_framebuffer.c | |
+++ /arm/ubuntu/h2/mainline/kernel_4.15.y/drivers/gpu/drm/drm_framebuffer.c | |
@@ -766,14 +766,18 @@ | |
struct drm_plane *plane; | |
struct drm_connector *conn; | |
struct drm_connector_state *conn_state; | |
- int i, ret = 0; | |
+ int i, ret; | |
unsigned plane_mask; | |
+ bool disable_crtcs = false; | |
+ | |
+retry_disable: | |
+ drm_modeset_acquire_init(&ctx, 0); | |
state = drm_atomic_state_alloc(dev); | |
- if (!state) | |
- return -ENOMEM; | |
- | |
- drm_modeset_acquire_init(&ctx, 0); | |
+ if (!state) { | |
+ ret = -ENOMEM; | |
+ goto out; | |
+ } | |
state->acquire_ctx = &ctx; | |
retry: | |
@@ -794,7 +798,7 @@ | |
goto unlock; | |
} | |
- if (plane_state->crtc->primary == plane) { | |
+ if (disable_crtcs && plane_state->crtc->primary == plane) { | |
struct drm_crtc_state *crtc_state; | |
crtc_state = drm_atomic_get_existing_crtc_state(state, plane_state->crtc); | |
@@ -819,6 +823,7 @@ | |
plane->old_fb = plane->fb; | |
} | |
+ /* This list is only filled when disable_crtcs is set. */ | |
for_each_new_connector_in_state(state, conn, conn_state, i) { | |
ret = drm_atomic_set_crtc_for_connector(conn_state, NULL); | |
@@ -841,8 +846,14 @@ | |
drm_atomic_state_put(state); | |
+out: | |
drm_modeset_drop_locks(&ctx); | |
drm_modeset_acquire_fini(&ctx); | |
+ | |
+ if (ret == -EINVAL && !disable_crtcs) { | |
+ disable_crtcs = true; | |
+ goto retry_disable; | |
+ } | |
return ret; | |
} | |
--- /arm/ubuntu/h5/mainline/kernel_4.15.y/drivers/gpu/drm/drm_gem_framebuffer_helper.c | |
+++ /arm/ubuntu/h2/mainline/kernel_4.15.y/drivers/gpu/drm/drm_gem_framebuffer_helper.c | |
@@ -300,6 +300,9 @@ | |
if (obj->size < mode_cmd.pitches[0] * mode_cmd.height) | |
return ERR_PTR(-EINVAL); | |
+ if (!funcs) | |
+ funcs = &drm_gem_fb_funcs; | |
+ | |
return drm_gem_fb_alloc(dev, &mode_cmd, &obj, 1, funcs); | |
} | |
EXPORT_SYMBOL(drm_gem_fbdev_fb_create); | |
--- /arm/ubuntu/h5/mainline/kernel_4.15.y/drivers/gpu/drm/drm_vblank.c | |
+++ /arm/ubuntu/h2/mainline/kernel_4.15.y/drivers/gpu/drm/drm_vblank.c | |
@@ -663,14 +663,16 @@ | |
delta_ns = div_s64(1000000LL * (vpos * mode->crtc_htotal + hpos), | |
mode->crtc_clock); | |
- /* save this only for debugging purposes */ | |
+ /* Subtract time delta from raw timestamp to get final | |
+ * vblank_time timestamp for end of vblank. | |
+ */ | |
+ *vblank_time = ktime_sub_ns(etime, delta_ns); | |
+ | |
+ if ((drm_debug & DRM_UT_VBL) == 0) | |
+ return true; | |
+ | |
ts_etime = ktime_to_timespec64(etime); | |
ts_vblank_time = ktime_to_timespec64(*vblank_time); | |
- /* Subtract time delta from raw timestamp to get final | |
- * vblank_time timestamp for end of vblank. | |
- */ | |
- etime = ktime_sub_ns(etime, delta_ns); | |
- *vblank_time = etime; | |
DRM_DEBUG_VBL("crtc %u : v p(%d,%d)@ %lld.%06ld -> %lld.%06ld [e %d us, %d rep]\n", | |
pipe, hpos, vpos, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment