Merge tag 'mmc-v4.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
[cascardo/linux.git] / drivers / gpu / drm / sti / sti_gdp.c
index b8d942c..81df309 100644 (file)
@@ -460,6 +460,7 @@ static void sti_gdp_disable(struct sti_gdp *gdp)
                clk_disable_unprepare(gdp->clk_pix);
 
        gdp->plane.status = STI_PLANE_DISABLED;
+       gdp->vtg = NULL;
 }
 
 /**
@@ -473,8 +474,8 @@ static void sti_gdp_disable(struct sti_gdp *gdp)
  * RETURNS:
  * 0 on success.
  */
-int sti_gdp_field_cb(struct notifier_block *nb,
-               unsigned long event, void *data)
+static int sti_gdp_field_cb(struct notifier_block *nb,
+                           unsigned long event, void *data)
 {
        struct sti_gdp *gdp = container_of(nb, struct sti_gdp, vtg_field_nb);
 
@@ -611,7 +612,6 @@ static int sti_gdp_atomic_check(struct drm_plane *drm_plane,
        struct drm_crtc *crtc = state->crtc;
        struct sti_compositor *compo = dev_get_drvdata(gdp->dev);
        struct drm_framebuffer *fb =  state->fb;
-       bool first_prepare = plane->status == STI_PLANE_DISABLED ? true : false;
        struct drm_crtc_state *crtc_state;
        struct sti_mixer *mixer;
        struct drm_display_mode *mode;
@@ -628,8 +628,8 @@ static int sti_gdp_atomic_check(struct drm_plane *drm_plane,
        mode = &crtc_state->mode;
        dst_x = state->crtc_x;
        dst_y = state->crtc_y;
-       dst_w = clamp_val(state->crtc_w, 0, mode->crtc_hdisplay - dst_x);
-       dst_h = clamp_val(state->crtc_h, 0, mode->crtc_vdisplay - dst_y);
+       dst_w = clamp_val(state->crtc_w, 0, mode->hdisplay - dst_x);
+       dst_h = clamp_val(state->crtc_h, 0, mode->vdisplay - dst_y);
        /* src_x are in 16.16 format */
        src_x = state->src_x >> 16;
        src_y = state->src_y >> 16;
@@ -648,10 +648,9 @@ static int sti_gdp_atomic_check(struct drm_plane *drm_plane,
                return -EINVAL;
        }
 
-       if (first_prepare) {
+       if (!gdp->vtg) {
                /* Register gdp callback */
-               gdp->vtg = mixer->id == STI_MIXER_MAIN ?
-                                       compo->vtg_main : compo->vtg_aux;
+               gdp->vtg = compo->vtg[mixer->id];
                if (sti_vtg_register_client(gdp->vtg,
                                            &gdp->vtg_field_nb, crtc)) {
                        DRM_ERROR("Cannot register VTG notifier\n");
@@ -719,7 +718,7 @@ static void sti_gdp_atomic_update(struct drm_plane *drm_plane,
        u32 dma_updated_top;
        u32 dma_updated_btm;
        int format;
-       unsigned int depth, bpp;
+       unsigned int bpp;
        u32 ydo, xdo, yds, xds;
 
        if (!crtc || !fb)
@@ -728,8 +727,8 @@ static void sti_gdp_atomic_update(struct drm_plane *drm_plane,
        mode = &crtc->mode;
        dst_x = state->crtc_x;
        dst_y = state->crtc_y;
-       dst_w = clamp_val(state->crtc_w, 0, mode->crtc_hdisplay - dst_x);
-       dst_h = clamp_val(state->crtc_h, 0, mode->crtc_vdisplay - dst_y);
+       dst_w = clamp_val(state->crtc_w, 0, mode->hdisplay - dst_x);
+       dst_h = clamp_val(state->crtc_h, 0, mode->vdisplay - dst_y);
        /* src_x are in 16.16 format */
        src_x = state->src_x >> 16;
        src_y = state->src_y >> 16;
@@ -758,9 +757,9 @@ static void sti_gdp_atomic_update(struct drm_plane *drm_plane,
                         (unsigned long)cma_obj->paddr);
 
        /* pixel memory location */
-       drm_fb_get_bpp_depth(fb->pixel_format, &depth, &bpp);
+       bpp = drm_format_plane_cpp(fb->pixel_format, 0);
        top_field->gam_gdp_pml = (u32)cma_obj->paddr + fb->offsets[0];
-       top_field->gam_gdp_pml += src_x * (bpp >> 3);
+       top_field->gam_gdp_pml += src_x * bpp;
        top_field->gam_gdp_pml += src_y * fb->pitches[0];
 
        /* output parameters (clamped / cropped) */
@@ -810,7 +809,7 @@ static void sti_gdp_atomic_update(struct drm_plane *drm_plane,
        if (!curr_list) {
                /* First update or invalid node should directly write in the
                 * hw register */
-               DRM_DEBUG_DRIVER("%s first update (or invalid node)",
+               DRM_DEBUG_DRIVER("%s first update (or invalid node)\n",
                                 sti_plane_to_str(plane));
 
                writel(gdp->is_curr_top ?
@@ -846,15 +845,15 @@ static void sti_gdp_atomic_disable(struct drm_plane *drm_plane,
 {
        struct sti_plane *plane = to_sti_plane(drm_plane);
 
-       if (!drm_plane->crtc) {
+       if (!oldstate->crtc) {
                DRM_DEBUG_DRIVER("drm plane:%d not enabled\n",
                                 drm_plane->base.id);
                return;
        }
 
        DRM_DEBUG_DRIVER("CRTC:%d (%s) drm plane:%d (%s)\n",
-                        drm_plane->crtc->base.id,
-                        sti_mixer_to_str(to_sti_mixer(drm_plane->crtc)),
+                        oldstate->crtc->base.id,
+                        sti_mixer_to_str(to_sti_mixer(oldstate->crtc)),
                         drm_plane->base.id, sti_plane_to_str(plane));
 
        plane->status = STI_PLANE_DISABLING;
@@ -882,7 +881,7 @@ static int sti_gdp_late_register(struct drm_plane *drm_plane)
        return gdp_debugfs_init(gdp, drm_plane->dev->primary);
 }
 
-struct drm_plane_funcs sti_gdp_plane_helpers_funcs = {
+static const struct drm_plane_funcs sti_gdp_plane_helpers_funcs = {
        .update_plane = drm_atomic_helper_update_plane,
        .disable_plane = drm_atomic_helper_disable_plane,
        .destroy = sti_gdp_destroy,