diff --git a/linux-5.10/rk3568_patch/kernel.patch b/linux-5.10/rk3568_patch/kernel.patch index 5d5b1b11d4a1e0e54f7254b00f7e470b411f3ee3..fde8e83ec3f539f4b403b3be4a4ffcefa9f54d4c 100755 --- a/linux-5.10/rk3568_patch/kernel.patch +++ b/linux-5.10/rk3568_patch/kernel.patch @@ -610074,26 +610074,25 @@ index af98bfcde518..b80ef0c6dc53 100644 - if (crtc->state->self_refresh_active) - rockchip_drm_set_win_enabled(crtc, false); - -- mutex_lock(&vop->vop_lock); +- if (crtc->state->self_refresh_active) + if (crtc->state->self_refresh_active) { + vop_crtc_atomic_disable_for_psr(crtc, old_state); -+ goto out; + goto out; + } +- mutex_lock(&vop->vop_lock); +- + vop_lock(vop); + VOP_CTRL_SET(vop, reg_done_frm, 1); + VOP_CTRL_SET(vop, dsp_interlace, 0); drm_crtc_vblank_off(crtc); -- -- if (crtc->state->self_refresh_active) -- goto out; + VOP_CTRL_SET(vop, out_mode, ROCKCHIP_OUT_MODE_P888); + VOP_CTRL_SET(vop, afbdc_en, 0); + vop_disable_all_planes(vop); /* * Vop standby will take effect at end of current frame, -@@ -721,28 +1668,34 @@ static void vop_crtc_atomic_disable(struct drm_crtc *crtc, +@@ -721,24 +1668,32 @@ static void vop_crtc_atomic_disable(struct drm_crtc *crtc, spin_lock(&vop->reg_lock); @@ -610133,13 +610132,9 @@ index af98bfcde518..b80ef0c6dc53 100644 - pm_runtime_put(vop->dev); + rockchip_clear_system_status(sys_status); - out: -- mutex_unlock(&vop->vop_lock); -- - if (crtc->state->event && !crtc->state->active) { - spin_lock_irq(&crtc->dev->event_lock); - drm_crtc_send_vblank_event(crtc, crtc->state->event); -@@ -752,23 +1705,29 @@ static void vop_crtc_atomic_disable(struct drm_crtc *crtc, + mutex_unlock(&vop->vop_lock); + +@@ -752,23 +1707,29 @@ static void vop_crtc_atomic_disable(struct drm_crtc *crtc, } } @@ -610176,7 +610171,7 @@ index af98bfcde518..b80ef0c6dc53 100644 DRM_DEBUG_KMS("Unsupported format modifier 0x%llx\n", modifier); return false; -@@ -783,33 +1742,89 @@ static int vop_plane_atomic_check(struct drm_plane *plane, +@@ -783,34 +1744,90 @@ static int vop_plane_atomic_check(struct drm_plane *plane, struct drm_crtc *crtc = state->crtc; struct drm_crtc_state *crtc_state; struct drm_framebuffer *fb = state->fb; @@ -610226,10 +610221,7 @@ index af98bfcde518..b80ef0c6dc53 100644 + state->crtc_h); return 0; + } - -- ret = vop_convert_format(fb->format->format); -- if (ret < 0) -- return ret; ++ + src->x1 = state->src.x1; + src->y1 = state->src.y1; + src->x2 = state->src.x2; @@ -610271,9 +610263,14 @@ index af98bfcde518..b80ef0c6dc53 100644 + return -EINVAL; + } +- ret = vop_convert_format(fb->format->format); +- if (ret < 0) +- return ret; +- /* * Src.x1 can be odd when do clip, but yuv plane start point -@@ -825,28 +1840,28 @@ static int vop_plane_atomic_check(struct drm_plane *plane, + * need align with 2 pixel. +@@ -825,28 +1842,28 @@ static int vop_plane_atomic_check(struct drm_plane *plane, return -EINVAL; } @@ -610320,7 +610317,7 @@ index af98bfcde518..b80ef0c6dc53 100644 } return 0; -@@ -855,44 +1870,148 @@ static int vop_plane_atomic_check(struct drm_plane *plane, +@@ -855,44 +1872,148 @@ static int vop_plane_atomic_check(struct drm_plane *plane, static void vop_plane_atomic_disable(struct drm_plane *plane, struct drm_plane_state *old_state) { @@ -610485,7 +610482,7 @@ index af98bfcde518..b80ef0c6dc53 100644 /* * can't update plane when vop is disabled. -@@ -908,206 +2027,448 @@ static void vop_plane_atomic_update(struct drm_plane *plane, +@@ -908,206 +2029,448 @@ static void vop_plane_atomic_update(struct drm_plane *plane, return; } @@ -610728,8 +610725,10 @@ index af98bfcde518..b80ef0c6dc53 100644 + vop->rockchip_crtc.vop_dump_times--; + } +#endif -+} -+ + } + +-static int vop_plane_atomic_async_check(struct drm_plane *plane, +- struct drm_plane_state *state) +static const struct drm_plane_helper_funcs plane_helper_funcs = { + .prepare_fb = vop_plane_prepare_fb, + .cleanup_fb = vop_plane_cleanup_fb, @@ -610768,23 +610767,36 @@ index af98bfcde518..b80ef0c6dc53 100644 + uint32_t src_x, uint32_t src_y, + uint32_t src_w, uint32_t src_h, + struct drm_modeset_acquire_ctx *ctx) -+{ + { +- struct vop_win *vop_win = to_vop_win(plane); +- const struct vop_win_data *win = vop_win->data; +- int min_scale = win->phy->scl ? FRAC_16_16(1, 8) : +- DRM_PLANE_HELPER_NO_SCALING; +- int max_scale = win->phy->scl ? FRAC_16_16(8, 1) : +- DRM_PLANE_HELPER_NO_SCALING; +- struct drm_crtc_state *crtc_state; + struct drm_atomic_state *state; + struct drm_plane_state *plane_state; + struct vop_plane_state *vop_plane_state; + int ret = 0; -+ + +- if (plane != state->crtc->cursor) +- return -EINVAL; + state = drm_atomic_state_alloc(plane->dev); + if (!state) + return -ENOMEM; -+ + +- if (!plane->state) +- return -EINVAL; + state->acquire_ctx = ctx; + plane_state = drm_atomic_get_plane_state(state, plane); + if (IS_ERR(plane_state)) { + ret = PTR_ERR(plane_state); + goto fail; + } -+ + +- if (!plane->state->fb) +- return -EINVAL; + vop_plane_state = to_vop_plane_state(plane_state); + + ret = drm_atomic_set_crtc_for_plane(plane_state, crtc); @@ -610807,10 +610819,8 @@ index af98bfcde518..b80ef0c6dc53 100644 +fail: + drm_atomic_state_put(state); + return ret; - } - --static int vop_plane_atomic_async_check(struct drm_plane *plane, -- struct drm_plane_state *state) ++} ++ +/** + * drm_atomic_helper_disable_plane copy from drm_atomic_helper_disable_plane + * be designed to support async commit at ioctl DRM_IOCTL_MODE_SETPLANE. @@ -610826,27 +610836,16 @@ index af98bfcde518..b80ef0c6dc53 100644 +static int __maybe_unused +rockchip_atomic_helper_disable_plane(struct drm_plane *plane, + struct drm_modeset_acquire_ctx *ctx) - { -- struct vop_win *vop_win = to_vop_win(plane); -- const struct vop_win_data *win = vop_win->data; -- int min_scale = win->phy->scl ? FRAC_16_16(1, 8) : -- DRM_PLANE_HELPER_NO_SCALING; -- int max_scale = win->phy->scl ? FRAC_16_16(8, 1) : -- DRM_PLANE_HELPER_NO_SCALING; -- struct drm_crtc_state *crtc_state; ++{ + struct drm_atomic_state *state; + struct drm_plane_state *plane_state; + struct vop_plane_state *vop_plane_state; + int ret = 0; - -- if (plane != state->crtc->cursor) -- return -EINVAL; ++ + state = drm_atomic_state_alloc(plane->dev); + if (!state) + return -ENOMEM; - -- if (!plane->state) -- return -EINVAL; ++ + state->acquire_ctx = ctx; + plane_state = drm_atomic_get_plane_state(state, plane); + if (IS_ERR(plane_state)) { @@ -610854,9 +610853,7 @@ index af98bfcde518..b80ef0c6dc53 100644 + goto fail; + } + vop_plane_state = to_vop_plane_state(plane_state); - -- if (!plane->state->fb) -- return -EINVAL; ++ + if ((plane_state->crtc && plane_state->crtc->cursor == plane) || + vop_plane_state->async_commit) + plane_state->state->legacy_cursor_update = true; @@ -611074,7 +611071,7 @@ index af98bfcde518..b80ef0c6dc53 100644 }; static int vop_crtc_enable_vblank(struct drm_crtc *crtc) -@@ -1120,276 +2481,1510 @@ static int vop_crtc_enable_vblank(struct drm_crtc *crtc) +@@ -1120,276 +2483,1510 @@ static int vop_crtc_enable_vblank(struct drm_crtc *crtc) spin_lock_irqsave(&vop->irq_lock, flags); @@ -612790,7 +612787,7 @@ index af98bfcde518..b80ef0c6dc53 100644 } static void vop_wait_for_irq_handler(struct vop *vop) -@@ -1413,72 +4008,67 @@ static void vop_wait_for_irq_handler(struct vop *vop) +@@ -1413,72 +4010,67 @@ static void vop_wait_for_irq_handler(struct vop *vop) synchronize_irq(vop->irq); } @@ -612911,7 +612908,7 @@ index af98bfcde518..b80ef0c6dc53 100644 /* * There is a (rather unlikely) possiblity that a vblank interrupt -@@ -1496,13 +4086,11 @@ static void vop_crtc_atomic_flush(struct drm_crtc *crtc, +@@ -1496,13 +4088,11 @@ static void vop_crtc_atomic_flush(struct drm_crtc *crtc, crtc->state->event = NULL; } spin_unlock_irq(&crtc->dev->event_lock); @@ -612927,7 +612924,7 @@ index af98bfcde518..b80ef0c6dc53 100644 continue; drm_framebuffer_get(old_plane_state->fb); -@@ -1514,8 +4102,8 @@ static void vop_crtc_atomic_flush(struct drm_crtc *crtc, +@@ -1514,8 +4104,8 @@ static void vop_crtc_atomic_flush(struct drm_crtc *crtc, static const struct drm_crtc_helper_funcs vop_crtc_helper_funcs = { .mode_fixup = vop_crtc_mode_fixup, @@ -612937,7 +612934,7 @@ index af98bfcde518..b80ef0c6dc53 100644 .atomic_flush = vop_crtc_atomic_flush, .atomic_enable = vop_crtc_atomic_enable, .atomic_disable = vop_crtc_atomic_disable, -@@ -1526,14 +4114,36 @@ static void vop_crtc_destroy(struct drm_crtc *crtc) +@@ -1526,14 +4116,36 @@ static void vop_crtc_destroy(struct drm_crtc *crtc) drm_crtc_cleanup(crtc); } @@ -612976,7 +612973,7 @@ index af98bfcde518..b80ef0c6dc53 100644 if (!rockchip_state) return NULL; -@@ -1550,17 +4160,6 @@ static void vop_crtc_destroy_state(struct drm_crtc *crtc, +@@ -1550,17 +4162,6 @@ static void vop_crtc_destroy_state(struct drm_crtc *crtc, kfree(s); } @@ -612994,7 +612991,7 @@ index af98bfcde518..b80ef0c6dc53 100644 #ifdef CONFIG_DRM_ANALOGIX_DP static struct drm_connector *vop_get_edp_connector(struct vop *vop) { -@@ -1624,20 +4223,118 @@ vop_crtc_verify_crc_source(struct drm_crtc *crtc, const char *source_name, +@@ -1624,20 +4225,118 @@ vop_crtc_verify_crc_source(struct drm_crtc *crtc, const char *source_name, { return -ENODEV; } @@ -613115,7 +613112,7 @@ index af98bfcde518..b80ef0c6dc53 100644 }; static void vop_fb_unref_worker(struct drm_flip_work *work, void *val) -@@ -1645,22 +4342,23 @@ static void vop_fb_unref_worker(struct drm_flip_work *work, void *val) +@@ -1645,22 +4344,23 @@ static void vop_fb_unref_worker(struct drm_flip_work *work, void *val) struct vop *vop = container_of(work, struct vop, fb_unref_work); struct drm_framebuffer *fb = val; @@ -613143,7 +613140,7 @@ index af98bfcde518..b80ef0c6dc53 100644 if (test_and_clear_bit(VOP_PENDING_FB_UNREF, &vop->pending)) drm_flip_work_commit(&vop->fb_unref_work, system_unbound_wq); -@@ -1669,8 +4367,9 @@ static void vop_handle_vblank(struct vop *vop) +@@ -1669,8 +4369,9 @@ static void vop_handle_vblank(struct vop *vop) static irqreturn_t vop_isr(int irq, void *data) { struct vop *vop = data; @@ -613154,7 +613151,7 @@ index af98bfcde518..b80ef0c6dc53 100644 int ret = IRQ_NONE; /* -@@ -1689,14 +4388,14 @@ static irqreturn_t vop_isr(int irq, void *data) +@@ -1689,14 +4390,14 @@ static irqreturn_t vop_isr(int irq, void *data) * interrupt register has interrupt status, enable and clear bits, we * must hold irq_lock to avoid a race with enable/disable_vblank(). */ @@ -613171,7 +613168,7 @@ index af98bfcde518..b80ef0c6dc53 100644 /* This is expected for vop iommu irqs, since the irq is shared */ if (!active_irqs) -@@ -1714,17 +4413,42 @@ static irqreturn_t vop_isr(int irq, void *data) +@@ -1714,17 +4415,42 @@ static irqreturn_t vop_isr(int irq, void *data) ret = IRQ_HANDLED; } @@ -613218,7 +613215,7 @@ index af98bfcde518..b80ef0c6dc53 100644 out_disable: vop_core_clks_disable(vop); -@@ -1733,27 +4457,230 @@ static irqreturn_t vop_isr(int irq, void *data) +@@ -1733,27 +4459,230 @@ static irqreturn_t vop_isr(int irq, void *data) return ret; } @@ -613456,7 +613453,7 @@ index af98bfcde518..b80ef0c6dc53 100644 int i; /* -@@ -1761,29 +4688,20 @@ static int vop_create_crtc(struct vop *vop) +@@ -1761,29 +4690,20 @@ static int vop_create_crtc(struct vop *vop) * to pass them to drm_crtc_init_with_planes, which sets the * "possible_crtcs" to the newly initialized crtc. */ @@ -613493,7 +613490,7 @@ index af98bfcde518..b80ef0c6dc53 100644 if (plane->type == DRM_PLANE_TYPE_PRIMARY) primary = plane; else if (plane->type == DRM_PLANE_TYPE_CURSOR) -@@ -1796,37 +4714,24 @@ static int vop_create_crtc(struct vop *vop) +@@ -1796,37 +4716,24 @@ static int vop_create_crtc(struct vop *vop) goto err_cleanup_planes; drm_crtc_helper_add(crtc, &vop_crtc_helper_funcs); @@ -613537,7 +613534,7 @@ index af98bfcde518..b80ef0c6dc53 100644 } port = of_get_child_by_name(dev->of_node, "port"); -@@ -1843,15 +4748,64 @@ static int vop_create_crtc(struct vop *vop) +@@ -1843,15 +4750,64 @@ static int vop_create_crtc(struct vop *vop) init_completion(&vop->dsp_hold_completion); init_completion(&vop->line_flag_completion); crtc->port = port; @@ -613605,7 +613602,7 @@ index af98bfcde518..b80ef0c6dc53 100644 err_cleanup_crtc: drm_crtc_cleanup(crtc); err_cleanup_planes: -@@ -1863,7 +4817,7 @@ static int vop_create_crtc(struct vop *vop) +@@ -1863,7 +4819,7 @@ static int vop_create_crtc(struct vop *vop) static void vop_destroy_crtc(struct vop *vop) { @@ -613614,7 +613611,7 @@ index af98bfcde518..b80ef0c6dc53 100644 struct drm_device *drm_dev = vop->drm_dev; struct drm_plane *plane, *tmp; -@@ -1891,187 +4845,129 @@ static void vop_destroy_crtc(struct vop *vop) +@@ -1891,187 +4847,129 @@ static void vop_destroy_crtc(struct vop *vop) drm_flip_work_cleanup(&vop->fb_unref_work); } @@ -613898,7 +613895,7 @@ index af98bfcde518..b80ef0c6dc53 100644 static int vop_bind(struct device *dev, struct device *master, void *data) { -@@ -2080,46 +4976,97 @@ static int vop_bind(struct device *dev, struct device *master, void *data) +@@ -2080,46 +4978,97 @@ static int vop_bind(struct device *dev, struct device *master, void *data) struct drm_device *drm_dev = data; struct vop *vop; struct resource *res; @@ -614009,7 +614006,7 @@ index af98bfcde518..b80ef0c6dc53 100644 irq = platform_get_irq(pdev, 0); if (irq < 0) { DRM_DEV_ERROR(dev, "cannot find irq for vop\n"); -@@ -2131,53 +5078,51 @@ static int vop_bind(struct device *dev, struct device *master, void *data) +@@ -2131,53 +5080,51 @@ static int vop_bind(struct device *dev, struct device *master, void *data) spin_lock_init(&vop->irq_lock); mutex_init(&vop->vop_lock);