Re: [PATCH 06/16] drm/i915/fbdev: Move intel_fb_initial_config() to fbdev helper
Den 27.03.2019 14.33, skrev Jani Nikula: > On Tue, 26 Mar 2019, Noralf Trønnes wrote: >> It is generic code and having it in the helper will let other drivers >> benefit from it. >> >> One change was necessary assuming this to be true: >> INTEL_INFO(dev_priv)->num_pipes == dev->mode_config.num_crtc > > This holds after intel_modeset_init(), in time for the use here. > >> Suggested-by: Daniel Vetter >> Cc: Jani Nikula >> Cc: Joonas Lahtinen >> Cc: Rodrigo Vivi >> Cc: intel-...@lists.freedesktop.org >> Signed-off-by: Noralf Trønnes > > Reviewed-by: Jani Nikula > > and > > Acked-by: Jani Nikula > > for merging via drm-misc or whichever tree makes most sense. > Thanks, I'll take it through drm-misc. One of the patches had a conflict with drm-tip, so I didn't get a CI run. I'll apply this if CI agrees when I submit the next version. Noralf. > >> --- >> drivers/gpu/drm/drm_fb_helper.c| 194 - >> drivers/gpu/drm/i915/intel_fbdev.c | 218 - >> include/drm/drm_fb_helper.h| 23 --- >> 3 files changed, 190 insertions(+), 245 deletions(-) >> >> diff --git a/drivers/gpu/drm/drm_fb_helper.c >> b/drivers/gpu/drm/drm_fb_helper.c >> index 36310901e935..634f4dcf0c41 100644 >> --- a/drivers/gpu/drm/drm_fb_helper.c >> +++ b/drivers/gpu/drm/drm_fb_helper.c >> @@ -2545,6 +2545,194 @@ static int drm_pick_crtcs(struct drm_fb_helper >> *fb_helper, >> return best_score; >> } >> >> +static struct drm_fb_helper_crtc * >> +drm_fb_helper_crtc(struct drm_fb_helper *fb_helper, struct drm_crtc *crtc) >> +{ >> +int i; >> + >> +for (i = 0; i < fb_helper->crtc_count; i++) >> +if (fb_helper->crtc_info[i].mode_set.crtc == crtc) >> +return _helper->crtc_info[i]; >> + >> +return NULL; >> +} >> + >> +/* Try to read the BIOS display configuration and use it for the initial >> config */ >> +static bool drm_fb_helper_firmware_config(struct drm_fb_helper *fb_helper, >> + struct drm_fb_helper_crtc **crtcs, >> + struct drm_display_mode **modes, >> + struct drm_fb_offset *offsets, >> + bool *enabled, int width, int height) >> +{ >> +struct drm_device *dev = fb_helper->dev; >> +unsigned int count = min(fb_helper->connector_count, BITS_PER_LONG); >> +unsigned long conn_configured, conn_seq; >> +int i, j; >> +bool *save_enabled; >> +bool fallback = true, ret = true; >> +int num_connectors_enabled = 0; >> +int num_connectors_detected = 0; >> +struct drm_modeset_acquire_ctx ctx; >> + >> +save_enabled = kcalloc(count, sizeof(bool), GFP_KERNEL); >> +if (!save_enabled) >> +return false; >> + >> +drm_modeset_acquire_init(, 0); >> + >> +while (drm_modeset_lock_all_ctx(dev, ) != 0) >> +drm_modeset_backoff(); >> + >> +memcpy(save_enabled, enabled, count); >> +conn_seq = GENMASK(count - 1, 0); >> +conn_configured = 0; >> +retry: >> +for (i = 0; i < count; i++) { >> +struct drm_fb_helper_connector *fb_conn; >> +struct drm_connector *connector; >> +struct drm_encoder *encoder; >> +struct drm_fb_helper_crtc *new_crtc; >> + >> +fb_conn = fb_helper->connector_info[i]; >> +connector = fb_conn->connector; >> + >> +if (conn_configured & BIT(i)) >> +continue; >> + >> +/* First pass, only consider tiled connectors */ >> +if (conn_seq == GENMASK(count - 1, 0) && !connector->has_tile) >> +continue; >> + >> +if (connector->status == connector_status_connected) >> +num_connectors_detected++; >> + >> +if (!enabled[i]) { >> +DRM_DEBUG_KMS("connector %s not enabled, skipping\n", >> + connector->name); >> +conn_configured |= BIT(i); >> +continue; >> +} >> + >> +if (connector->force == DRM_FORCE_OFF) { >> +DRM_DEBUG_KMS("connector %s is disabled by user, >> skipping\n", >> + connector->name); >> +enabled[i] = false; >> +continue; >> +} >> + >> +encoder = connector->state->best_encoder; >> +if (!encoder || WARN_ON(!connector->state->crtc)) { >> +if (connector->force > DRM_FORCE_OFF) >> +goto bail; >> + >> +DRM_DEBUG_KMS("connector %s has no encoder or crtc, >> skipping\n", >> + connector->name); >> +enabled[i] = false; >> +conn_configured |= BIT(i); >> +continue; >> +} >> + >> +
Re: [PATCH 06/16] drm/i915/fbdev: Move intel_fb_initial_config() to fbdev helper
On Tue, 26 Mar 2019, Noralf Trønnes wrote: > It is generic code and having it in the helper will let other drivers > benefit from it. > > One change was necessary assuming this to be true: > INTEL_INFO(dev_priv)->num_pipes == dev->mode_config.num_crtc This holds after intel_modeset_init(), in time for the use here. > Suggested-by: Daniel Vetter > Cc: Jani Nikula > Cc: Joonas Lahtinen > Cc: Rodrigo Vivi > Cc: intel-...@lists.freedesktop.org > Signed-off-by: Noralf Trønnes Reviewed-by: Jani Nikula and Acked-by: Jani Nikula for merging via drm-misc or whichever tree makes most sense. > --- > drivers/gpu/drm/drm_fb_helper.c| 194 - > drivers/gpu/drm/i915/intel_fbdev.c | 218 - > include/drm/drm_fb_helper.h| 23 --- > 3 files changed, 190 insertions(+), 245 deletions(-) > > diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c > index 36310901e935..634f4dcf0c41 100644 > --- a/drivers/gpu/drm/drm_fb_helper.c > +++ b/drivers/gpu/drm/drm_fb_helper.c > @@ -2545,6 +2545,194 @@ static int drm_pick_crtcs(struct drm_fb_helper > *fb_helper, > return best_score; > } > > +static struct drm_fb_helper_crtc * > +drm_fb_helper_crtc(struct drm_fb_helper *fb_helper, struct drm_crtc *crtc) > +{ > + int i; > + > + for (i = 0; i < fb_helper->crtc_count; i++) > + if (fb_helper->crtc_info[i].mode_set.crtc == crtc) > + return _helper->crtc_info[i]; > + > + return NULL; > +} > + > +/* Try to read the BIOS display configuration and use it for the initial > config */ > +static bool drm_fb_helper_firmware_config(struct drm_fb_helper *fb_helper, > + struct drm_fb_helper_crtc **crtcs, > + struct drm_display_mode **modes, > + struct drm_fb_offset *offsets, > + bool *enabled, int width, int height) > +{ > + struct drm_device *dev = fb_helper->dev; > + unsigned int count = min(fb_helper->connector_count, BITS_PER_LONG); > + unsigned long conn_configured, conn_seq; > + int i, j; > + bool *save_enabled; > + bool fallback = true, ret = true; > + int num_connectors_enabled = 0; > + int num_connectors_detected = 0; > + struct drm_modeset_acquire_ctx ctx; > + > + save_enabled = kcalloc(count, sizeof(bool), GFP_KERNEL); > + if (!save_enabled) > + return false; > + > + drm_modeset_acquire_init(, 0); > + > + while (drm_modeset_lock_all_ctx(dev, ) != 0) > + drm_modeset_backoff(); > + > + memcpy(save_enabled, enabled, count); > + conn_seq = GENMASK(count - 1, 0); > + conn_configured = 0; > +retry: > + for (i = 0; i < count; i++) { > + struct drm_fb_helper_connector *fb_conn; > + struct drm_connector *connector; > + struct drm_encoder *encoder; > + struct drm_fb_helper_crtc *new_crtc; > + > + fb_conn = fb_helper->connector_info[i]; > + connector = fb_conn->connector; > + > + if (conn_configured & BIT(i)) > + continue; > + > + /* First pass, only consider tiled connectors */ > + if (conn_seq == GENMASK(count - 1, 0) && !connector->has_tile) > + continue; > + > + if (connector->status == connector_status_connected) > + num_connectors_detected++; > + > + if (!enabled[i]) { > + DRM_DEBUG_KMS("connector %s not enabled, skipping\n", > + connector->name); > + conn_configured |= BIT(i); > + continue; > + } > + > + if (connector->force == DRM_FORCE_OFF) { > + DRM_DEBUG_KMS("connector %s is disabled by user, > skipping\n", > + connector->name); > + enabled[i] = false; > + continue; > + } > + > + encoder = connector->state->best_encoder; > + if (!encoder || WARN_ON(!connector->state->crtc)) { > + if (connector->force > DRM_FORCE_OFF) > + goto bail; > + > + DRM_DEBUG_KMS("connector %s has no encoder or crtc, > skipping\n", > + connector->name); > + enabled[i] = false; > + conn_configured |= BIT(i); > + continue; > + } > + > + num_connectors_enabled++; > + > + new_crtc = drm_fb_helper_crtc(fb_helper, > connector->state->crtc); > + > + /* > + * Make sure we're not trying to drive multiple connectors > + * with a single CRTC, since our cloning support may not > + * match the BIOS. > +
[PATCH 06/16] drm/i915/fbdev: Move intel_fb_initial_config() to fbdev helper
It is generic code and having it in the helper will let other drivers benefit from it. One change was necessary assuming this to be true: INTEL_INFO(dev_priv)->num_pipes == dev->mode_config.num_crtc Suggested-by: Daniel Vetter Cc: Jani Nikula Cc: Joonas Lahtinen Cc: Rodrigo Vivi Cc: intel-...@lists.freedesktop.org Signed-off-by: Noralf Trønnes --- drivers/gpu/drm/drm_fb_helper.c| 194 - drivers/gpu/drm/i915/intel_fbdev.c | 218 - include/drm/drm_fb_helper.h| 23 --- 3 files changed, 190 insertions(+), 245 deletions(-) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 36310901e935..634f4dcf0c41 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -2545,6 +2545,194 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper, return best_score; } +static struct drm_fb_helper_crtc * +drm_fb_helper_crtc(struct drm_fb_helper *fb_helper, struct drm_crtc *crtc) +{ + int i; + + for (i = 0; i < fb_helper->crtc_count; i++) + if (fb_helper->crtc_info[i].mode_set.crtc == crtc) + return _helper->crtc_info[i]; + + return NULL; +} + +/* Try to read the BIOS display configuration and use it for the initial config */ +static bool drm_fb_helper_firmware_config(struct drm_fb_helper *fb_helper, + struct drm_fb_helper_crtc **crtcs, + struct drm_display_mode **modes, + struct drm_fb_offset *offsets, + bool *enabled, int width, int height) +{ + struct drm_device *dev = fb_helper->dev; + unsigned int count = min(fb_helper->connector_count, BITS_PER_LONG); + unsigned long conn_configured, conn_seq; + int i, j; + bool *save_enabled; + bool fallback = true, ret = true; + int num_connectors_enabled = 0; + int num_connectors_detected = 0; + struct drm_modeset_acquire_ctx ctx; + + save_enabled = kcalloc(count, sizeof(bool), GFP_KERNEL); + if (!save_enabled) + return false; + + drm_modeset_acquire_init(, 0); + + while (drm_modeset_lock_all_ctx(dev, ) != 0) + drm_modeset_backoff(); + + memcpy(save_enabled, enabled, count); + conn_seq = GENMASK(count - 1, 0); + conn_configured = 0; +retry: + for (i = 0; i < count; i++) { + struct drm_fb_helper_connector *fb_conn; + struct drm_connector *connector; + struct drm_encoder *encoder; + struct drm_fb_helper_crtc *new_crtc; + + fb_conn = fb_helper->connector_info[i]; + connector = fb_conn->connector; + + if (conn_configured & BIT(i)) + continue; + + /* First pass, only consider tiled connectors */ + if (conn_seq == GENMASK(count - 1, 0) && !connector->has_tile) + continue; + + if (connector->status == connector_status_connected) + num_connectors_detected++; + + if (!enabled[i]) { + DRM_DEBUG_KMS("connector %s not enabled, skipping\n", + connector->name); + conn_configured |= BIT(i); + continue; + } + + if (connector->force == DRM_FORCE_OFF) { + DRM_DEBUG_KMS("connector %s is disabled by user, skipping\n", + connector->name); + enabled[i] = false; + continue; + } + + encoder = connector->state->best_encoder; + if (!encoder || WARN_ON(!connector->state->crtc)) { + if (connector->force > DRM_FORCE_OFF) + goto bail; + + DRM_DEBUG_KMS("connector %s has no encoder or crtc, skipping\n", + connector->name); + enabled[i] = false; + conn_configured |= BIT(i); + continue; + } + + num_connectors_enabled++; + + new_crtc = drm_fb_helper_crtc(fb_helper, connector->state->crtc); + + /* +* Make sure we're not trying to drive multiple connectors +* with a single CRTC, since our cloning support may not +* match the BIOS. +*/ + for (j = 0; j < count; j++) { + if (crtcs[j] == new_crtc) { + DRM_DEBUG_KMS("fallback: cloned configuration\n"); + goto bail; + } + } + + DRM_DEBUG_KMS("looking for cmdline mode