drm/rockchip: drv: add support rockchip dmc

Signed-off-by: Sandy Huang <hjc@rock-chips.com>
Change-Id: I5f966c0797b8467c66f0bb501d554516f99b2376
This commit is contained in:
Sandy Huang
2021-07-22 16:42:00 +08:00
committed by Tao Huang
parent 641da0dc82
commit 870bbda749

View File

@@ -5,6 +5,7 @@
*/
#include <linux/kernel.h>
#include <linux/devfreq.h>
#include <drm/drm.h>
#include <drm/drm_atomic.h>
@@ -13,6 +14,7 @@
#include <drm/drm_fourcc.h>
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_probe_helper.h>
#include <soc/rockchip/rockchip_dmc.h>
#include "rockchip_drm_drv.h"
#include "rockchip_drm_fb.h"
@@ -53,6 +55,29 @@ rockchip_fb_alloc(struct drm_device *dev, const struct drm_mode_fb_cmd2 *mode_cm
return fb;
}
static int rockchip_drm_bandwidth_atomic_check(struct drm_device *dev,
struct drm_atomic_state *state,
struct dmcfreq_vop_info *vop_info)
{
struct rockchip_drm_private *priv = dev->dev_private;
struct drm_crtc_state *old_crtc_state;
const struct rockchip_crtc_funcs *funcs;
struct drm_crtc *crtc;
int i;
vop_info->bw_mbyte = 0;
vop_info->plane_num = 0;
for_each_old_crtc_in_state(state, crtc, old_crtc_state, i) {
funcs = priv->crtc_funcs[drm_crtc_index(crtc)];
if (funcs && funcs->bandwidth)
vop_info->bw_mbyte += funcs->bandwidth(crtc, old_crtc_state, &vop_info->plane_num);
}
return 0;
}
/**
* rockchip_drm_atomic_helper_commit_tail_rpm - commit atomic update to hardware
* @old_state: new modeset state to be committed
@@ -66,11 +91,16 @@ rockchip_fb_alloc(struct drm_device *dev, const struct drm_mode_fb_cmd2 *mode_cm
static void rockchip_drm_atomic_helper_commit_tail_rpm(struct drm_atomic_state *old_state)
{
struct drm_device *dev = old_state->dev;
struct dmcfreq_vop_info vop_info;
drm_atomic_helper_commit_modeset_disables(dev, old_state);
drm_atomic_helper_commit_modeset_enables(dev, old_state);
rockchip_drm_bandwidth_atomic_check(dev, old_state, &vop_info);
rockchip_dmcfreq_vop_bandwidth_update(&vop_info);
drm_atomic_helper_commit_planes(dev, old_state, DRM_PLANE_COMMIT_ACTIVE_ONLY);
drm_atomic_helper_fake_vblank(old_state);