Skip to content
Snippets Groups Projects
Commit e6d442ae authored by Thomas Zimmermann's avatar Thomas Zimmermann
Browse files

drm/mgag200: Compute PLL values during atomic check


PLL setup can fail if the display mode's clock is not supported by
any PLL configuration. Compute the PLL values during atomic check, so
that atomic commits can fail at the appropriate time. If successful,
use the values in the atomic-update phase.

Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
parent 75af717b
No related branches found
No related merge requests found
...@@ -129,6 +129,8 @@ struct mgag200_pll_values { ...@@ -129,6 +129,8 @@ struct mgag200_pll_values {
struct mgag200_crtc_state { struct mgag200_crtc_state {
struct drm_crtc_state base; struct drm_crtc_state base;
struct mgag200_pll_values pixpll;
}; };
static inline struct mgag200_crtc_state *to_mgag200_crtc_state(struct drm_crtc_state *base) static inline struct mgag200_crtc_state *to_mgag200_crtc_state(struct drm_crtc_state *base)
......
...@@ -1802,6 +1802,7 @@ mgag200_simple_display_pipe_enable(struct drm_simple_display_pipe *pipe, ...@@ -1802,6 +1802,7 @@ mgag200_simple_display_pipe_enable(struct drm_simple_display_pipe *pipe,
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
struct mga_device *mdev = to_mga_device(dev); struct mga_device *mdev = to_mga_device(dev);
struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode; struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode;
struct mgag200_crtc_state *mgag200_crtc_state = to_mgag200_crtc_state(crtc_state);
struct drm_framebuffer *fb = plane_state->fb; struct drm_framebuffer *fb = plane_state->fb;
struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state); struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
struct drm_rect fullscreen = { struct drm_rect fullscreen = {
...@@ -1810,15 +1811,13 @@ mgag200_simple_display_pipe_enable(struct drm_simple_display_pipe *pipe, ...@@ -1810,15 +1811,13 @@ mgag200_simple_display_pipe_enable(struct drm_simple_display_pipe *pipe,
.y1 = 0, .y1 = 0,
.y2 = fb->height, .y2 = fb->height,
}; };
struct mgag200_pll_values pixpll;
if (mdev->type == G200_WB || mdev->type == G200_EW3) if (mdev->type == G200_WB || mdev->type == G200_EW3)
mgag200_g200wb_hold_bmc(mdev); mgag200_g200wb_hold_bmc(mdev);
mgag200_set_format_regs(mdev, fb); mgag200_set_format_regs(mdev, fb);
mgag200_set_mode_regs(mdev, adjusted_mode); mgag200_set_mode_regs(mdev, adjusted_mode);
mgag200_compute_pixpll_values(mdev, adjusted_mode->clock, &pixpll); mgag200_set_pixpll(mdev, &mgag200_crtc_state->pixpll);
mgag200_set_pixpll(mdev, &pixpll);
if (mdev->type == G200_ER) if (mdev->type == G200_ER)
mgag200_g200er_reset_tagfifo(mdev); mgag200_g200er_reset_tagfifo(mdev);
...@@ -1852,8 +1851,12 @@ mgag200_simple_display_pipe_check(struct drm_simple_display_pipe *pipe, ...@@ -1852,8 +1851,12 @@ mgag200_simple_display_pipe_check(struct drm_simple_display_pipe *pipe,
struct drm_crtc_state *crtc_state) struct drm_crtc_state *crtc_state)
{ {
struct drm_plane *plane = plane_state->plane; struct drm_plane *plane = plane_state->plane;
struct drm_device *dev = plane->dev;
struct mga_device *mdev = to_mga_device(dev);
struct mgag200_crtc_state *mgag200_crtc_state = to_mgag200_crtc_state(crtc_state);
struct drm_framebuffer *new_fb = plane_state->fb; struct drm_framebuffer *new_fb = plane_state->fb;
struct drm_framebuffer *fb = NULL; struct drm_framebuffer *fb = NULL;
int ret;
if (!new_fb) if (!new_fb)
return 0; return 0;
...@@ -1864,6 +1867,13 @@ mgag200_simple_display_pipe_check(struct drm_simple_display_pipe *pipe, ...@@ -1864,6 +1867,13 @@ mgag200_simple_display_pipe_check(struct drm_simple_display_pipe *pipe,
if (!fb || (fb->format != new_fb->format)) if (!fb || (fb->format != new_fb->format))
crtc_state->mode_changed = true; /* update PLL settings */ crtc_state->mode_changed = true; /* update PLL settings */
if (crtc_state->mode_changed) {
ret = mgag200_compute_pixpll_values(mdev, crtc_state->mode.clock,
&mgag200_crtc_state->pixpll);
if (ret)
return ret;
}
return 0; return 0;
} }
...@@ -1891,6 +1901,7 @@ mgag200_simple_display_pipe_duplicate_crtc_state(struct drm_simple_display_pipe ...@@ -1891,6 +1901,7 @@ mgag200_simple_display_pipe_duplicate_crtc_state(struct drm_simple_display_pipe
{ {
struct drm_crtc *crtc = &pipe->crtc; struct drm_crtc *crtc = &pipe->crtc;
struct drm_crtc_state *crtc_state = crtc->state; struct drm_crtc_state *crtc_state = crtc->state;
struct mgag200_crtc_state *mgag200_crtc_state = to_mgag200_crtc_state(crtc_state);
struct mgag200_crtc_state *new_mgag200_crtc_state; struct mgag200_crtc_state *new_mgag200_crtc_state;
if (!crtc_state) if (!crtc_state)
...@@ -1901,6 +1912,9 @@ mgag200_simple_display_pipe_duplicate_crtc_state(struct drm_simple_display_pipe ...@@ -1901,6 +1912,9 @@ mgag200_simple_display_pipe_duplicate_crtc_state(struct drm_simple_display_pipe
return NULL; return NULL;
__drm_atomic_helper_crtc_duplicate_state(crtc, &new_mgag200_crtc_state->base); __drm_atomic_helper_crtc_duplicate_state(crtc, &new_mgag200_crtc_state->base);
memcpy(&new_mgag200_crtc_state->pixpll, &mgag200_crtc_state->pixpll,
sizeof(new_mgag200_crtc_state->pixpll));
return &new_mgag200_crtc_state->base; return &new_mgag200_crtc_state->base;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment