struct vc4_hvs_state {
struct drm_private_state base;
unsigned int unassigned_channels;
- unsigned int num_outputs;
- unsigned long fifo_load;
- unsigned long core_clock_rate;
};
static struct vc4_hvs_state *
}
static struct vc4_hvs_state *
-vc4_hvs_get_new_global_state(struct drm_atomic_state *state)
-{
- struct vc4_dev *vc4 = to_vc4_dev(state->dev);
- struct drm_private_state *priv_state;
-
- priv_state = drm_atomic_get_new_private_obj_state(state, &vc4->hvs_channels);
- if (IS_ERR(priv_state))
- return ERR_CAST(priv_state);
-
- return to_vc4_hvs_state(priv_state);
-}
-
-static struct vc4_hvs_state *
vc4_hvs_get_global_state(struct drm_atomic_state *state)
{
struct vc4_dev *vc4 = to_vc4_dev(state->dev);
struct vc4_dev *vc4 = to_vc4_dev(dev);
struct vc4_hvs *hvs = vc4->hvs;
struct drm_crtc_state *new_crtc_state;
- struct vc4_hvs_state *hvs_state;
struct drm_crtc *crtc;
struct clk_request *core_req;
int i;
- hvs_state = vc4_hvs_get_new_global_state(state);
- if (WARN_ON(!hvs_state))
- return;
-
for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
struct vc4_crtc_state *vc4_crtc_state;
vc4_hvs_mask_underrun(dev, vc4_crtc_state->assigned_channel);
}
- if (vc4->hvs && vc4->hvs->hvs5) {
- /*
- * Do a temporary request on the core clock during the
- * modeset.
- */
+ if (vc4->hvs && vc4->hvs->hvs5)
core_req = clk_request_start(hvs->core_clk, 500000000);
- /*
- * And remove the previous one based on the HVS
- * requirements if any.
- */
- clk_request_done(hvs->core_req);
- }
-
drm_atomic_helper_wait_for_fences(dev, state, false);
drm_atomic_helper_wait_for_dependencies(state);
drm_atomic_helper_commit_cleanup_done(state);
- if (vc4->hvs && vc4->hvs->hvs5) {
- drm_dbg(dev, "Running the core clock at %lu Hz\n",
- hvs_state->core_clock_rate);
-
- /*
- * Request a clock rate based on the current HVS
- * requirements.
- */
- hvs->core_req = clk_request_start(hvs->core_clk,
- hvs_state->core_clock_rate);
-
- /* And drop the temporary request */
+ if (vc4->hvs && vc4->hvs->hvs5)
clk_request_done(core_req);
- }
drm_atomic_state_put(state);
__drm_atomic_helper_private_obj_duplicate_state(obj, &state->base);
state->unassigned_channels = old_state->unassigned_channels;
- state->fifo_load = old_state->fifo_load;
- state->num_outputs = old_state->num_outputs;
- state->core_clock_rate = old_state->core_clock_rate;
return &state->base;
}
}
static int
-vc4_core_clock_atomic_check(struct drm_atomic_state *state)
-{
- struct vc4_dev *vc4 = to_vc4_dev(state->dev);
- struct drm_private_state *priv_state;
- struct vc4_hvs_state *hvs_new_state;
- struct vc4_load_tracker_state *load_state;
- struct drm_crtc_state *old_crtc_state, *new_crtc_state;
- struct drm_crtc *crtc;
- unsigned long pixel_rate;
- unsigned long cob_rate;
- unsigned int i;
-
- priv_state = drm_atomic_get_private_obj_state(state,
- &vc4->load_tracker);
- if (IS_ERR(priv_state))
- return PTR_ERR(priv_state);
-
- load_state = to_vc4_load_tracker_state(priv_state);
-
- hvs_new_state = vc4_hvs_get_global_state(state);
- if (!hvs_new_state)
- return -EINVAL;
-
- for_each_oldnew_crtc_in_state(state, crtc,
- old_crtc_state,
- new_crtc_state,
- i) {
- if (old_crtc_state->active) {
- struct vc4_crtc_state *old_vc4_state =
- to_vc4_crtc_state(old_crtc_state);
-
- hvs_new_state->num_outputs -= 1;
- hvs_new_state->fifo_load -= old_vc4_state->hvs_load;
- }
-
- if (new_crtc_state->active) {
- struct vc4_crtc_state *new_vc4_state =
- to_vc4_crtc_state(new_crtc_state);
-
- hvs_new_state->num_outputs += 1;
- hvs_new_state->fifo_load += new_vc4_state->hvs_load;
- }
- }
-
- cob_rate = hvs_new_state->fifo_load;
- pixel_rate = load_state->hvs_load;
- if (hvs_new_state->num_outputs > 1) {
- pixel_rate = (pixel_rate * 40) / 100;
- } else {
- pixel_rate = (pixel_rate * 60) / 100;
- }
-
- hvs_new_state->core_clock_rate = max(cob_rate, pixel_rate);
-
- return 0;
-}
-
-
-static int
vc4_atomic_check(struct drm_device *dev, struct drm_atomic_state *state)
{
int ret;
if (ret)
return ret;
- ret = vc4_load_tracker_atomic_check(state);
- if (ret)
- return ret;
-
- return vc4_core_clock_atomic_check(state);
+ return vc4_load_tracker_atomic_check(state);
}
static const struct drm_mode_config_funcs vc4_mode_funcs = {