diff options
author | Thomas Zimmermann <tzimmermann@suse.de> | 2019-12-02 12:15:56 +0100 |
---|---|---|
committer | Thomas Zimmermann <tzimmermann@suse.de> | 2019-12-10 14:28:04 +0100 |
commit | e7d70cd4948e543739e9859d2b4ab30448067d32 (patch) | |
tree | a47c530bf477bb0cbacd8d5cb8c2ee340923233b /drivers/gpu/drm/ast | |
parent | drm/ast: Introduce struct ast_crtc_state (diff) | |
download | linux-e7d70cd4948e543739e9859d2b4ab30448067d32.tar.xz linux-e7d70cd4948e543739e9859d2b4ab30448067d32.zip |
drm/ast: Store VBIOS mode info in struct ast_crtc_state
After looking up VBIOS mode information in CRTC's atomic_check(), we
can reuse it in atomic_flush(). No need for a second look-up.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191202111557.15176-7-tzimmermann@suse.de
Diffstat (limited to 'drivers/gpu/drm/ast')
-rw-r--r-- | drivers/gpu/drm/ast/ast_drv.h | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/ast/ast_mode.c | 58 |
2 files changed, 32 insertions, 28 deletions
diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h index e13afb8a706f..72883b5aefa7 100644 --- a/drivers/gpu/drm/ast/ast_drv.h +++ b/drivers/gpu/drm/ast/ast_drv.h @@ -283,6 +283,8 @@ struct ast_vbios_mode_info { struct ast_crtc_state { struct drm_crtc_state base; + + struct ast_vbios_mode_info vbios_mode_info; }; #define to_ast_crtc_state(state) container_of(state, struct ast_crtc_state, base) diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c index ad2e0562ec55..a27724832845 100644 --- a/drivers/gpu/drm/ast/ast_mode.c +++ b/drivers/gpu/drm/ast/ast_mode.c @@ -784,24 +784,25 @@ static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc, { struct ast_private *ast = crtc->dev->dev_private; struct drm_plane_state *plane_state; + struct ast_crtc_state *ast_state; bool succ; - struct drm_display_mode adjusted_mode; - struct ast_vbios_mode_info vbios_mode; if (ast->chip == AST1180) { DRM_ERROR("AST 1180 modesetting not supported\n"); return -EINVAL; } + ast_state = to_ast_crtc_state(state); plane_state = crtc->primary->state; - if (plane_state && plane_state->fb) { - succ = ast_get_vbios_mode_info(plane_state->fb->format, - &state->mode, &adjusted_mode, - &vbios_mode); - if (!succ) - return -EINVAL; - } + if (!plane_state || !plane_state->fb) + return 0; + + succ = ast_get_vbios_mode_info(plane_state->fb->format, &state->mode, + &state->adjusted_mode, + &ast_state->vbios_mode_info); + if (!succ) + return -EINVAL; return 0; } @@ -820,40 +821,36 @@ static void ast_crtc_helper_atomic_flush(struct drm_crtc *crtc, struct drm_device *dev = crtc->dev; struct ast_private *ast = dev->dev_private; const struct drm_framebuffer *fb = crtc->primary->state->fb; + struct ast_crtc_state *ast_state; const struct drm_format_info *format; - struct drm_display_mode adjusted_mode; - struct ast_vbios_mode_info vbios_mode; - bool succ; + struct ast_vbios_mode_info *vbios_mode_info; + struct drm_display_mode *adjusted_mode; crtc->state->no_vblank = true; if (!fb) return; - format = fb->format; + ast_state = to_ast_crtc_state(crtc->state); - memset(&adjusted_mode, 0, sizeof(adjusted_mode)); - drm_mode_copy(&adjusted_mode, &crtc->state->adjusted_mode); - - succ = ast_get_vbios_mode_info(format, - &crtc->state->adjusted_mode, - &adjusted_mode, &vbios_mode); - if (WARN_ON_ONCE(!succ)) - return; /* BUG: didn't validate this in atomic_check() */ + format = fb->format; + vbios_mode_info = &ast_state->vbios_mode_info; ast_set_color_reg(ast, format); - ast_set_vbios_color_reg(ast, format, &vbios_mode); + ast_set_vbios_color_reg(ast, format, vbios_mode_info); if (!crtc->state->mode_changed) return; - ast_set_vbios_mode_reg(ast, &adjusted_mode, &vbios_mode); + adjusted_mode = &crtc->state->adjusted_mode; + + ast_set_vbios_mode_reg(ast, adjusted_mode, vbios_mode_info); ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa1, 0x06); - ast_set_std_reg(ast, &adjusted_mode, &vbios_mode); - ast_set_crtc_reg(ast, &adjusted_mode, &vbios_mode); - ast_set_dclk_reg(ast, &adjusted_mode, &vbios_mode); + ast_set_std_reg(ast, adjusted_mode, vbios_mode_info); + ast_set_crtc_reg(ast, adjusted_mode, vbios_mode_info); + ast_set_dclk_reg(ast, adjusted_mode, vbios_mode_info); ast_set_crtthd_reg(ast); - ast_set_sync_reg(ast, &adjusted_mode, &vbios_mode); + ast_set_sync_reg(ast, adjusted_mode, vbios_mode_info); } static void @@ -887,7 +884,7 @@ static void ast_crtc_destroy(struct drm_crtc *crtc) static struct drm_crtc_state * ast_crtc_atomic_duplicate_state(struct drm_crtc *crtc) { - struct ast_crtc_state *new_ast_state; + struct ast_crtc_state *new_ast_state, *ast_state; if (WARN_ON(!crtc->state)) return NULL; @@ -897,6 +894,11 @@ ast_crtc_atomic_duplicate_state(struct drm_crtc *crtc) return NULL; __drm_atomic_helper_crtc_duplicate_state(crtc, &new_ast_state->base); + ast_state = to_ast_crtc_state(crtc->state); + + memcpy(&new_ast_state->vbios_mode_info, &ast_state->vbios_mode_info, + sizeof(new_ast_state->vbios_mode_info)); + return &new_ast_state->base; } |