]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
drm/amd/display: Rename more dc_surface stuff to plane_state
[mirror_ubuntu-bionic-kernel.git] / drivers / gpu / drm / amd / display / dc / dcn10 / dcn10_hw_sequencer.c
index 4cbca15e1cc5035303425648f0332b9eac873d22..5922cf8272f5d239553ee180e88f0cc46921b5a9 100644 (file)
@@ -31,9 +31,9 @@
 #include "dce110/dce110_hw_sequencer.h"
 #include "dce/dce_hwseq.h"
 #include "abm.h"
+#include "dcn10/dcn10_mem_input.h"
 #include "dcn10/dcn10_dpp.h"
 #include "dcn10/dcn10_mpc.h"
-#include "mem_input.h"
 #include "timing_generator.h"
 #include "opp.h"
 #include "ipp.h"
@@ -218,6 +218,306 @@ static void dpp_pg_control(
        }
 }
 
+static uint32_t convert_and_clamp(
+       uint32_t wm_ns,
+       uint32_t refclk_mhz,
+       uint32_t clamp_value)
+{
+       uint32_t ret_val = 0;
+       ret_val = wm_ns * refclk_mhz;
+       ret_val /= 1000;
+
+       if (ret_val > clamp_value)
+               ret_val = clamp_value;
+
+       return ret_val;
+}
+
+static void program_watermarks(
+               struct dce_hwseq *hws,
+               struct dcn_watermark_set *watermarks,
+               unsigned int refclk_mhz)
+{
+       uint32_t force_en = hws->ctx->dc->debug.disable_stutter ? 1 : 0;
+       /*
+        * Need to clamp to max of the register values (i.e. no wrap)
+        * for dcn1, all wm registers are 21-bit wide
+        */
+       uint32_t prog_wm_value;
+
+       /* Repeat for water mark set A, B, C and D. */
+       /* clock state A */
+       prog_wm_value = convert_and_clamp(watermarks->a.urgent_ns,
+                       refclk_mhz, 0x1fffff);
+       REG_WRITE(DCHUBBUB_ARB_DATA_URGENCY_WATERMARK_A, prog_wm_value);
+
+       dm_logger_write(hws->ctx->logger, LOG_HW_MARKS,
+               "URGENCY_WATERMARK_A calculated =%d\n"
+               "HW register value = 0x%x\n",
+               watermarks->a.urgent_ns, prog_wm_value);
+
+       prog_wm_value = convert_and_clamp(watermarks->a.pte_meta_urgent_ns,
+                       refclk_mhz, 0x1fffff);
+       REG_WRITE(DCHUBBUB_ARB_PTE_META_URGENCY_WATERMARK_A, prog_wm_value);
+       dm_logger_write(hws->ctx->logger, LOG_HW_MARKS,
+               "PTE_META_URGENCY_WATERMARK_A calculated =%d\n"
+               "HW register value = 0x%x\n",
+               watermarks->a.pte_meta_urgent_ns, prog_wm_value);
+
+
+       prog_wm_value = convert_and_clamp(
+                       watermarks->a.cstate_pstate.cstate_enter_plus_exit_ns,
+                       refclk_mhz, 0x1fffff);
+
+       REG_WRITE(DCHUBBUB_ARB_ALLOW_SR_ENTER_WATERMARK_A, prog_wm_value);
+       dm_logger_write(hws->ctx->logger, LOG_HW_MARKS,
+               "SR_ENTER_EXIT_WATERMARK_A calculated =%d\n"
+               "HW register value = 0x%x\n",
+               watermarks->a.cstate_pstate.cstate_enter_plus_exit_ns, prog_wm_value);
+
+
+       prog_wm_value = convert_and_clamp(
+                       watermarks->a.cstate_pstate.cstate_exit_ns,
+                       refclk_mhz, 0x1fffff);
+       REG_WRITE(DCHUBBUB_ARB_ALLOW_SR_EXIT_WATERMARK_A, prog_wm_value);
+       dm_logger_write(hws->ctx->logger, LOG_HW_MARKS,
+               "SR_EXIT_WATERMARK_A calculated =%d\n"
+               "HW register value = 0x%x\n",
+               watermarks->a.cstate_pstate.cstate_exit_ns, prog_wm_value);
+
+
+       prog_wm_value = convert_and_clamp(
+                       watermarks->a.cstate_pstate.pstate_change_ns,
+                       refclk_mhz, 0x1fffff);
+       REG_WRITE(DCHUBBUB_ARB_ALLOW_DRAM_CLK_CHANGE_WATERMARK_A, prog_wm_value);
+       dm_logger_write(hws->ctx->logger, LOG_HW_MARKS,
+               "DRAM_CLK_CHANGE_WATERMARK_A calculated =%d\n"
+               "HW register value = 0x%x\n\n",
+               watermarks->a.cstate_pstate.pstate_change_ns, prog_wm_value);
+
+
+       /* clock state B */
+       prog_wm_value = convert_and_clamp(
+                       watermarks->b.urgent_ns, refclk_mhz, 0x1fffff);
+       REG_WRITE(DCHUBBUB_ARB_DATA_URGENCY_WATERMARK_B, prog_wm_value);
+       dm_logger_write(hws->ctx->logger, LOG_HW_MARKS,
+               "URGENCY_WATERMARK_B calculated =%d\n"
+               "HW register value = 0x%x\n",
+               watermarks->b.urgent_ns, prog_wm_value);
+
+
+       prog_wm_value = convert_and_clamp(
+                       watermarks->b.pte_meta_urgent_ns,
+                       refclk_mhz, 0x1fffff);
+       REG_WRITE(DCHUBBUB_ARB_PTE_META_URGENCY_WATERMARK_B, prog_wm_value);
+       dm_logger_write(hws->ctx->logger, LOG_HW_MARKS,
+               "PTE_META_URGENCY_WATERMARK_B calculated =%d\n"
+               "HW register value = 0x%x\n",
+               watermarks->b.pte_meta_urgent_ns, prog_wm_value);
+
+
+       prog_wm_value = convert_and_clamp(
+                       watermarks->b.cstate_pstate.cstate_enter_plus_exit_ns,
+                       refclk_mhz, 0x1fffff);
+       REG_WRITE(DCHUBBUB_ARB_ALLOW_SR_ENTER_WATERMARK_B, prog_wm_value);
+       dm_logger_write(hws->ctx->logger, LOG_HW_MARKS,
+               "SR_ENTER_WATERMARK_B calculated =%d\n"
+               "HW register value = 0x%x\n",
+               watermarks->b.cstate_pstate.cstate_enter_plus_exit_ns, prog_wm_value);
+
+
+       prog_wm_value = convert_and_clamp(
+                       watermarks->b.cstate_pstate.cstate_exit_ns,
+                       refclk_mhz, 0x1fffff);
+       REG_WRITE(DCHUBBUB_ARB_ALLOW_SR_EXIT_WATERMARK_B, prog_wm_value);
+       dm_logger_write(hws->ctx->logger, LOG_HW_MARKS,
+               "SR_EXIT_WATERMARK_B calculated =%d\n"
+               "HW register value = 0x%x\n",
+               watermarks->b.cstate_pstate.cstate_exit_ns, prog_wm_value);
+
+       prog_wm_value = convert_and_clamp(
+                       watermarks->b.cstate_pstate.pstate_change_ns,
+                       refclk_mhz, 0x1fffff);
+       REG_WRITE(DCHUBBUB_ARB_ALLOW_DRAM_CLK_CHANGE_WATERMARK_B, prog_wm_value);
+       dm_logger_write(hws->ctx->logger, LOG_HW_MARKS,
+               "DRAM_CLK_CHANGE_WATERMARK_B calculated =%d\n\n"
+               "HW register value = 0x%x\n",
+               watermarks->b.cstate_pstate.pstate_change_ns, prog_wm_value);
+
+       /* clock state C */
+       prog_wm_value = convert_and_clamp(
+                       watermarks->c.urgent_ns, refclk_mhz, 0x1fffff);
+       REG_WRITE(DCHUBBUB_ARB_DATA_URGENCY_WATERMARK_C, prog_wm_value);
+       dm_logger_write(hws->ctx->logger, LOG_HW_MARKS,
+               "URGENCY_WATERMARK_C calculated =%d\n"
+               "HW register value = 0x%x\n",
+               watermarks->c.urgent_ns, prog_wm_value);
+
+
+       prog_wm_value = convert_and_clamp(
+                       watermarks->c.pte_meta_urgent_ns,
+                       refclk_mhz, 0x1fffff);
+       REG_WRITE(DCHUBBUB_ARB_PTE_META_URGENCY_WATERMARK_C, prog_wm_value);
+       dm_logger_write(hws->ctx->logger, LOG_HW_MARKS,
+               "PTE_META_URGENCY_WATERMARK_C calculated =%d\n"
+               "HW register value = 0x%x\n",
+               watermarks->c.pte_meta_urgent_ns, prog_wm_value);
+
+
+       prog_wm_value = convert_and_clamp(
+                       watermarks->c.cstate_pstate.cstate_enter_plus_exit_ns,
+                       refclk_mhz, 0x1fffff);
+       REG_WRITE(DCHUBBUB_ARB_ALLOW_SR_ENTER_WATERMARK_C, prog_wm_value);
+       dm_logger_write(hws->ctx->logger, LOG_HW_MARKS,
+               "SR_ENTER_WATERMARK_C calculated =%d\n"
+               "HW register value = 0x%x\n",
+               watermarks->c.cstate_pstate.cstate_enter_plus_exit_ns, prog_wm_value);
+
+
+       prog_wm_value = convert_and_clamp(
+                       watermarks->c.cstate_pstate.cstate_exit_ns,
+                       refclk_mhz, 0x1fffff);
+       REG_WRITE(DCHUBBUB_ARB_ALLOW_SR_EXIT_WATERMARK_C, prog_wm_value);
+       dm_logger_write(hws->ctx->logger, LOG_HW_MARKS,
+               "SR_EXIT_WATERMARK_C calculated =%d\n"
+               "HW register value = 0x%x\n",
+               watermarks->c.cstate_pstate.cstate_exit_ns, prog_wm_value);
+
+
+       prog_wm_value = convert_and_clamp(
+                       watermarks->c.cstate_pstate.pstate_change_ns,
+                       refclk_mhz, 0x1fffff);
+       REG_WRITE(DCHUBBUB_ARB_ALLOW_DRAM_CLK_CHANGE_WATERMARK_C, prog_wm_value);
+       dm_logger_write(hws->ctx->logger, LOG_HW_MARKS,
+               "DRAM_CLK_CHANGE_WATERMARK_C calculated =%d\n\n"
+               "HW register value = 0x%x\n",
+               watermarks->c.cstate_pstate.pstate_change_ns, prog_wm_value);
+
+       /* clock state D */
+       prog_wm_value = convert_and_clamp(
+                       watermarks->d.urgent_ns, refclk_mhz, 0x1fffff);
+       REG_WRITE(DCHUBBUB_ARB_DATA_URGENCY_WATERMARK_D, prog_wm_value);
+       dm_logger_write(hws->ctx->logger, LOG_HW_MARKS,
+               "URGENCY_WATERMARK_D calculated =%d\n"
+               "HW register value = 0x%x\n",
+               watermarks->d.urgent_ns, prog_wm_value);
+
+       prog_wm_value = convert_and_clamp(
+                       watermarks->d.pte_meta_urgent_ns,
+                       refclk_mhz, 0x1fffff);
+       REG_WRITE(DCHUBBUB_ARB_PTE_META_URGENCY_WATERMARK_D, prog_wm_value);
+       dm_logger_write(hws->ctx->logger, LOG_HW_MARKS,
+               "PTE_META_URGENCY_WATERMARK_D calculated =%d\n"
+               "HW register value = 0x%x\n",
+               watermarks->d.pte_meta_urgent_ns, prog_wm_value);
+
+
+       prog_wm_value = convert_and_clamp(
+                       watermarks->d.cstate_pstate.cstate_enter_plus_exit_ns,
+                       refclk_mhz, 0x1fffff);
+       REG_WRITE(DCHUBBUB_ARB_ALLOW_SR_ENTER_WATERMARK_D, prog_wm_value);
+       dm_logger_write(hws->ctx->logger, LOG_HW_MARKS,
+               "SR_ENTER_WATERMARK_D calculated =%d\n"
+               "HW register value = 0x%x\n",
+               watermarks->d.cstate_pstate.cstate_enter_plus_exit_ns, prog_wm_value);
+
+
+       prog_wm_value = convert_and_clamp(
+                       watermarks->d.cstate_pstate.cstate_exit_ns,
+                       refclk_mhz, 0x1fffff);
+       REG_WRITE(DCHUBBUB_ARB_ALLOW_SR_EXIT_WATERMARK_D, prog_wm_value);
+       dm_logger_write(hws->ctx->logger, LOG_HW_MARKS,
+               "SR_EXIT_WATERMARK_D calculated =%d\n"
+               "HW register value = 0x%x\n",
+               watermarks->d.cstate_pstate.cstate_exit_ns, prog_wm_value);
+
+
+       prog_wm_value = convert_and_clamp(
+                       watermarks->d.cstate_pstate.pstate_change_ns,
+                       refclk_mhz, 0x1fffff);
+       REG_WRITE(DCHUBBUB_ARB_ALLOW_DRAM_CLK_CHANGE_WATERMARK_D, prog_wm_value);
+       dm_logger_write(hws->ctx->logger, LOG_HW_MARKS,
+               "DRAM_CLK_CHANGE_WATERMARK_D calculated =%d\n"
+               "HW register value = 0x%x\n\n",
+               watermarks->d.cstate_pstate.pstate_change_ns, prog_wm_value);
+
+       REG_UPDATE(DCHUBBUB_ARB_WATERMARK_CHANGE_CNTL,
+                       DCHUBBUB_ARB_WATERMARK_CHANGE_REQUEST, 1);
+       REG_UPDATE(DCHUBBUB_ARB_WATERMARK_CHANGE_CNTL,
+                       DCHUBBUB_ARB_WATERMARK_CHANGE_REQUEST, 0);
+       REG_UPDATE(DCHUBBUB_ARB_SAT_LEVEL,
+                       DCHUBBUB_ARB_SAT_LEVEL, 60 * refclk_mhz);
+       REG_UPDATE(DCHUBBUB_ARB_DF_REQ_OUTSTAND,
+                       DCHUBBUB_ARB_MIN_REQ_OUTSTAND, 68);
+
+       REG_UPDATE_2(DCHUBBUB_ARB_DRAM_STATE_CNTL,
+                       DCHUBBUB_ARB_ALLOW_SELF_REFRESH_FORCE_VALUE, 0,
+                       DCHUBBUB_ARB_ALLOW_SELF_REFRESH_FORCE_ENABLE, force_en);
+
+#if 0
+       REG_UPDATE_2(DCHUBBUB_ARB_WATERMARK_CHANGE_CNTL,
+                       DCHUBBUB_ARB_WATERMARK_CHANGE_DONE_INTERRUPT_DISABLE, 1,
+                       DCHUBBUB_ARB_WATERMARK_CHANGE_REQUEST, 1);
+#endif
+}
+
+
+static void dcn10_update_dchub(
+       struct dce_hwseq *hws,
+       struct dchub_init_data *dh_data)
+{
+       /* TODO: port code from dal2 */
+       switch (dh_data->fb_mode) {
+       case FRAME_BUFFER_MODE_ZFB_ONLY:
+               /*For ZFB case need to put DCHUB FB BASE and TOP upside down to indicate ZFB mode*/
+               REG_UPDATE(DCHUBBUB_SDPIF_FB_TOP,
+                               SDPIF_FB_TOP, 0);
+
+               REG_UPDATE(DCHUBBUB_SDPIF_FB_BASE,
+                               SDPIF_FB_BASE, 0x0FFFF);
+
+               REG_UPDATE(DCHUBBUB_SDPIF_AGP_BASE,
+                               SDPIF_AGP_BASE, dh_data->zfb_phys_addr_base >> 22);
+
+               REG_UPDATE(DCHUBBUB_SDPIF_AGP_BOT,
+                               SDPIF_AGP_BOT, dh_data->zfb_mc_base_addr >> 22);
+
+               REG_UPDATE(DCHUBBUB_SDPIF_AGP_TOP,
+                               SDPIF_AGP_TOP, (dh_data->zfb_mc_base_addr +
+                                               dh_data->zfb_size_in_byte - 1) >> 22);
+               break;
+       case FRAME_BUFFER_MODE_MIXED_ZFB_AND_LOCAL:
+               /*Should not touch FB LOCATION (done by VBIOS on AsicInit table)*/
+
+               REG_UPDATE(DCHUBBUB_SDPIF_AGP_BASE,
+                               SDPIF_AGP_BASE, dh_data->zfb_phys_addr_base >> 22);
+
+               REG_UPDATE(DCHUBBUB_SDPIF_AGP_BOT,
+                               SDPIF_AGP_BOT, dh_data->zfb_mc_base_addr >> 22);
+
+               REG_UPDATE(DCHUBBUB_SDPIF_AGP_TOP,
+                               SDPIF_AGP_TOP, (dh_data->zfb_mc_base_addr +
+                                               dh_data->zfb_size_in_byte - 1) >> 22);
+               break;
+       case FRAME_BUFFER_MODE_LOCAL_ONLY:
+               /*Should not touch FB LOCATION (done by VBIOS on AsicInit table)*/
+               REG_UPDATE(DCHUBBUB_SDPIF_AGP_BASE,
+                               SDPIF_AGP_BASE, 0);
+
+               REG_UPDATE(DCHUBBUB_SDPIF_AGP_BOT,
+                               SDPIF_AGP_BOT, 0X03FFFF);
+
+               REG_UPDATE(DCHUBBUB_SDPIF_AGP_TOP,
+                               SDPIF_AGP_TOP, 0);
+               break;
+       default:
+               break;
+       }
+
+       dh_data->dchub_initialzied = true;
+       dh_data->dchub_info_valid = false;
+}
+
 static void hubp_pg_control(
                struct dce_hwseq *hws,
                unsigned int hubp_inst,
@@ -328,7 +628,7 @@ static void dcn10_init_hw(struct core_dc *dc)
                 * required signal (which may be different from the
                 * default signal on connector).
                 */
-               struct core_link *link = dc->links[i];
+               struct dc_link *link = dc->links[i];
 
                link->link_enc->funcs->hw_init(link->link_enc);
        }
@@ -336,15 +636,10 @@ static void dcn10_init_hw(struct core_dc *dc)
        for (i = 0; i < dc->res_pool->pipe_count; i++) {
                struct transform *xfm = dc->res_pool->transforms[i];
                struct timing_generator *tg = dc->res_pool->timing_generators[i];
-               struct mpcc *mpcc = dc->res_pool->mpcc[i];
-               struct mpcc_cfg mpcc_cfg;
 
                xfm->funcs->transform_reset(xfm);
-               mpcc_cfg.opp_id = 0xf;
-               mpcc_cfg.top_dpp_id = 0xf;
-               mpcc_cfg.bot_mpcc_id = 0xf;
-               mpcc_cfg.top_of_tree = true;
-               mpcc->funcs->set(mpcc, &mpcc_cfg);
+               dc->res_pool->mpc->funcs->remove(
+                               dc->res_pool->mpc, dc->res_pool->opps[i], i);
 
                /* Blank controller using driver code instead of
                 * command table.
@@ -384,12 +679,12 @@ static enum dc_status dcn10_prog_pixclk_crtc_otg(
                struct validate_context *context,
                struct core_dc *dc)
 {
-       struct core_stream *stream = pipe_ctx->stream;
+       struct dc_stream_state *stream = pipe_ctx->stream;
        enum dc_color_space color_space;
        struct tg_color black_color = {0};
-       bool enableStereo    = stream->public.timing.timing_3d_format == TIMING_3D_FORMAT_NONE ?
+       bool enableStereo    = stream->timing.timing_3d_format == TIMING_3D_FORMAT_NONE ?
                        false:true;
-       bool rightEyePolarity = stream->public.timing.flags.RIGHT_EYE_3D_POLARITY;
+       bool rightEyePolarity = stream->timing.flags.RIGHT_EYE_3D_POLARITY;
 
 
        /* by upper caller loop, pipe0 is parent pipe and be called first.
@@ -422,7 +717,7 @@ static enum dc_status dcn10_prog_pixclk_crtc_otg(
 
        pipe_ctx->tg->funcs->program_timing(
                        pipe_ctx->tg,
-                       &stream->public.timing,
+                       &stream->timing,
                        true);
 
        pipe_ctx->opp->funcs->opp_set_stereo_polarity(
@@ -442,7 +737,7 @@ static enum dc_status dcn10_prog_pixclk_crtc_otg(
                                &stream->clamping);
 #endif
        /* program otg blank color */
-       color_space = stream->public.output_color_space;
+       color_space = stream->output_color_space;
        color_space_to_black_color(dc, color_space, &black_color);
        pipe_ctx->tg->funcs->set_blank_color(
                        pipe_ctx->tg,
@@ -515,82 +810,143 @@ static void reset_back_end_for_pipe(
                                        pipe_ctx->pipe_idx, pipe_ctx->tg->inst);
 }
 
-static void plane_atomic_stop(
-               struct core_dc *dc,
+/* trigger HW to start disconnect plane from stream on the next vsync */
+static void plane_atomic_disconnect(struct core_dc *dc,
                int fe_idx)
 {
-       struct mpcc_cfg mpcc_cfg;
        struct mem_input *mi = dc->res_pool->mis[fe_idx];
-       struct transform *xfm = dc->res_pool->transforms[fe_idx];
-       struct mpcc *mpcc = dc->res_pool->mpcc[fe_idx];
-       struct timing_generator *tg = dc->res_pool->timing_generators[mpcc->opp_id];
+       struct mpc *mpc = dc->res_pool->mpc;
+       int opp_id, z_idx;
+       int mpcc_id = -1;
+
+       /* look at tree rather than mi here to know if we already reset */
+       for (opp_id = 0; opp_id < dc->res_pool->pipe_count; opp_id++) {
+               struct output_pixel_processor *opp = dc->res_pool->opps[opp_id];
 
+               for (z_idx = 0; z_idx < opp->mpc_tree.num_pipes; z_idx++) {
+                       if (opp->mpc_tree.dpp[z_idx] == fe_idx) {
+                               mpcc_id = opp->mpc_tree.mpcc[z_idx];
+                               break;
+                       }
+               }
+               if (mpcc_id != -1)
+                       break;
+       }
+       /*Already reset*/
+       if (opp_id == dc->res_pool->pipe_count)
+               return;
+
+       if (dc->public.debug.sanity_checks)
+               verify_allow_pstate_change_high(dc->hwseq);
        mi->funcs->dcc_control(mi, false, false);
+       if (dc->public.debug.sanity_checks)
+               verify_allow_pstate_change_high(dc->hwseq);
 
-       mpcc_cfg.opp_id = 0xf;
-       mpcc_cfg.top_dpp_id = 0xf;
-       mpcc_cfg.bot_mpcc_id = 0xf;
-       mpcc_cfg.top_of_tree = tg->inst == mpcc->inst;
-       mpcc->funcs->set(mpcc, &mpcc_cfg);
+       mpc->funcs->remove(mpc, dc->res_pool->opps[opp_id], fe_idx);
+}
+
+/* disable HW used by plane.
+ * note:  cannot disable until disconnect is complete */
+static void plane_atomic_disable(struct core_dc *dc,
+               int fe_idx)
+{
+       struct dce_hwseq *hws = dc->hwseq;
+       struct mem_input *mi = dc->res_pool->mis[fe_idx];
+       struct mpc *mpc = dc->res_pool->mpc;
+       int opp_id = mi->opp_id;
 
+       if (opp_id == 0xf)
+               return;
+
+       mpc->funcs->wait_for_idle(mpc, mi->mpcc_id);
+       dc->res_pool->opps[mi->opp_id]->mpcc_disconnect_pending[mi->mpcc_id] = false;
+       /*dm_logger_write(dc->ctx->logger, LOG_ERROR,
+                       "[debug_mpo: atomic disable finished on mpcc %d]\n",
+                       fe_idx);*/
+
+       mi->funcs->set_blank(mi, true);
+       /*todo: unhack this*/
+       mi->opp_id = 0xf;
+       mi->mpcc_id = 0xf;
+
+       if (dc->public.debug.sanity_checks)
+               verify_allow_pstate_change_high(dc->hwseq);
+
+       REG_UPDATE(HUBP_CLK_CNTL[fe_idx],
+                       HUBP_CLOCK_ENABLE, 0);
+       REG_UPDATE(DPP_CONTROL[fe_idx],
+                       DPP_CLOCK_ENABLE, 0);
+
+       if (dc->res_pool->opps[opp_id]->mpc_tree.num_pipes == 0)
+               REG_UPDATE(OPP_PIPE_CONTROL[opp_id],
+                               OPP_PIPE_CLOCK_EN, 0);
+
+       if (dc->public.debug.sanity_checks)
+               verify_allow_pstate_change_high(dc->hwseq);
+}
+
+/*
+ * kill power to plane hw
+ * note: cannot power down until plane is disable
+ */
+static void plane_atomic_power_down(struct core_dc *dc, int fe_idx)
+{
+       struct dce_hwseq *hws = dc->hwseq;
+       struct transform *xfm = dc->res_pool->transforms[fe_idx];
+
+       REG_SET(DC_IP_REQUEST_CNTL, 0,
+                       IP_REQUEST_EN, 1);
+       dpp_pg_control(hws, fe_idx, false);
+       hubp_pg_control(hws, fe_idx, false);
        xfm->funcs->transform_reset(xfm);
+       REG_SET(DC_IP_REQUEST_CNTL, 0,
+                       IP_REQUEST_EN, 0);
+       dm_logger_write(dc->ctx->logger, LOG_DC,
+                       "Power gated front end %d\n", fe_idx);
+
+       if (dc->public.debug.sanity_checks)
+               verify_allow_pstate_change_high(dc->hwseq);
 }
 
+
 static void reset_front_end(
                struct core_dc *dc,
                int fe_idx)
 {
        struct dce_hwseq *hws = dc->hwseq;
-       struct mem_input *mi = dc->res_pool->mis[fe_idx];
-       struct mpcc *mpcc = dc->res_pool->mpcc[fe_idx];
-       struct timing_generator *tg = dc->res_pool->timing_generators[mpcc->opp_id];
-       unsigned int opp_id = mpcc->opp_id;
+       struct timing_generator *tg;
+       int opp_id = dc->res_pool->mis[fe_idx]->opp_id;
 
        /*Already reset*/
        if (opp_id == 0xf)
                return;
 
+       tg = dc->res_pool->timing_generators[opp_id];
        tg->funcs->lock(tg);
 
-       plane_atomic_stop(dc, fe_idx);
+       plane_atomic_disconnect(dc, fe_idx);
 
        REG_UPDATE(OTG_GLOBAL_SYNC_STATUS[tg->inst], VUPDATE_NO_LOCK_EVENT_CLEAR, 1);
        tg->funcs->unlock(tg);
 
        if (dc->public.debug.sanity_checks)
-               verify_allow_pstate_change_high(dc->hwseq);
+               verify_allow_pstate_change_high(hws);
 
        if (tg->ctx->dce_environment != DCE_ENV_FPGA_MAXIMUS)
                REG_WAIT(OTG_GLOBAL_SYNC_STATUS[tg->inst],
                                VUPDATE_NO_LOCK_EVENT_OCCURRED, 1, 20000, 200000);
 
-       mpcc->funcs->wait_for_idle(mpcc);
-
-       mi->funcs->set_blank(mi, true);
-
-       if (dc->public.debug.sanity_checks)
-               verify_allow_pstate_change_high(dc->hwseq);
-
-       REG_UPDATE(HUBP_CLK_CNTL[fe_idx],
-                       HUBP_CLOCK_ENABLE, 0);
-       REG_UPDATE(DPP_CONTROL[fe_idx],
-                       DPP_CLOCK_ENABLE, 0);
-
-       if (tg->inst == mpcc->inst)
-               REG_UPDATE(OPP_PIPE_CONTROL[opp_id],
-                               OPP_PIPE_CLOCK_EN, 0);
+       plane_atomic_disable(dc, fe_idx);
 
        dm_logger_write(dc->ctx->logger, LOG_DC,
                                        "Reset front end %d\n",
                                        fe_idx);
-
-       if (dc->public.debug.sanity_checks)
-               verify_allow_pstate_change_high(dc->hwseq);
 }
 
 static void dcn10_power_down_fe(struct core_dc *dc, int fe_idx)
 {
        struct dce_hwseq *hws = dc->hwseq;
+       struct transform *xfm = dc->res_pool->transforms[fe_idx];
 
        reset_front_end(dc, fe_idx);
 
@@ -598,6 +954,7 @@ static void dcn10_power_down_fe(struct core_dc *dc, int fe_idx)
                        IP_REQUEST_EN, 1);
        dpp_pg_control(hws, fe_idx, false);
        hubp_pg_control(hws, fe_idx, false);
+       xfm->funcs->transform_reset(xfm);
        REG_SET(DC_IP_REQUEST_CNTL, 0,
                        IP_REQUEST_EN, 0);
        dm_logger_write(dc->ctx->logger, LOG_DC,
@@ -614,6 +971,37 @@ static void reset_hw_ctx_wrap(
        int i;
 
        /* Reset Front End*/
+       /* Lock*/
+       for (i = 0; i < dc->res_pool->pipe_count; i++) {
+               struct pipe_ctx *cur_pipe_ctx = &dc->current_context->res_ctx.pipe_ctx[i];
+               struct timing_generator *tg = cur_pipe_ctx->tg;
+
+               if (cur_pipe_ctx->stream)
+                       tg->funcs->lock(tg);
+       }
+       /* Disconnect*/
+       for (i = dc->res_pool->pipe_count - 1; i >= 0 ; i--) {
+               struct pipe_ctx *pipe_ctx_old =
+                       &dc->current_context->res_ctx.pipe_ctx[i];
+               struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
+
+               if (!pipe_ctx->stream ||
+                               !pipe_ctx->plane_state ||
+                               pipe_need_reprogram(pipe_ctx_old, pipe_ctx)) {
+
+                       plane_atomic_disconnect(dc, i);
+               }
+       }
+       /* Unlock*/
+       for (i = dc->res_pool->pipe_count - 1; i >= 0; i--) {
+               struct pipe_ctx *cur_pipe_ctx = &dc->current_context->res_ctx.pipe_ctx[i];
+               struct timing_generator *tg = cur_pipe_ctx->tg;
+
+               if (cur_pipe_ctx->stream)
+                       tg->funcs->unlock(tg);
+       }
+
+       /* Disable and Powerdown*/
        for (i = dc->res_pool->pipe_count - 1; i >= 0 ; i--) {
                struct pipe_ctx *pipe_ctx_old =
                        &dc->current_context->res_ctx.pipe_ctx[i];
@@ -622,11 +1010,16 @@ static void reset_hw_ctx_wrap(
                /*if (!pipe_ctx_old->stream)
                        continue;*/
 
-               if (!pipe_ctx->stream || !pipe_ctx->surface)
-                       dcn10_power_down_fe(dc, i);
-               else if (pipe_need_reprogram(pipe_ctx_old, pipe_ctx))
-                       reset_front_end(dc, i);
+               if (pipe_ctx->stream && pipe_ctx->plane_state
+                               && !pipe_need_reprogram(pipe_ctx_old, pipe_ctx))
+                       continue;
+
+               plane_atomic_disable(dc, i);
+
+               if (!pipe_ctx->stream || !pipe_ctx->plane_state)
+                       plane_atomic_power_down(dc, i);
        }
+
        /* Reset Back End*/
        for (i = dc->res_pool->pipe_count - 1; i >= 0 ; i--) {
                struct pipe_ctx *pipe_ctx_old =
@@ -645,24 +1038,24 @@ static void reset_hw_ctx_wrap(
 static bool patch_address_for_sbs_tb_stereo(
                struct pipe_ctx *pipe_ctx, PHYSICAL_ADDRESS_LOC *addr)
 {
-       struct core_surface *surface = pipe_ctx->surface;
+       struct dc_plane_state *plane_state = pipe_ctx->plane_state;
        bool sec_split = pipe_ctx->top_pipe &&
-                       pipe_ctx->top_pipe->surface == pipe_ctx->surface;
-       if (sec_split && surface->public.address.type == PLN_ADDR_TYPE_GRPH_STEREO &&
-               (pipe_ctx->stream->public.timing.timing_3d_format ==
+                       pipe_ctx->top_pipe->plane_state == pipe_ctx->plane_state;
+       if (sec_split && plane_state->address.type == PLN_ADDR_TYPE_GRPH_STEREO &&
+               (pipe_ctx->stream->timing.timing_3d_format ==
                 TIMING_3D_FORMAT_SIDE_BY_SIDE ||
-                pipe_ctx->stream->public.timing.timing_3d_format ==
+                pipe_ctx->stream->timing.timing_3d_format ==
                 TIMING_3D_FORMAT_TOP_AND_BOTTOM)) {
-               *addr = surface->public.address.grph_stereo.left_addr;
-               surface->public.address.grph_stereo.left_addr =
-               surface->public.address.grph_stereo.right_addr;
+               *addr = plane_state->address.grph_stereo.left_addr;
+               plane_state->address.grph_stereo.left_addr =
+               plane_state->address.grph_stereo.right_addr;
                return true;
        } else {
-               if (pipe_ctx->stream->public.view_format != VIEW_3D_FORMAT_NONE &&
-                       surface->public.address.type != PLN_ADDR_TYPE_GRPH_STEREO) {
-                       surface->public.address.type = PLN_ADDR_TYPE_GRPH_STEREO;
-                       surface->public.address.grph_stereo.right_addr =
-                       surface->public.address.grph_stereo.left_addr;
+               if (pipe_ctx->stream->view_format != VIEW_3D_FORMAT_NONE &&
+                       plane_state->address.type != PLN_ADDR_TYPE_GRPH_STEREO) {
+                       plane_state->address.type = PLN_ADDR_TYPE_GRPH_STEREO;
+                       plane_state->address.grph_stereo.right_addr =
+                       plane_state->address.grph_stereo.left_addr;
                }
        }
        return false;
@@ -672,22 +1065,22 @@ static void update_plane_addr(const struct core_dc *dc, struct pipe_ctx *pipe_ct
 {
        bool addr_patched = false;
        PHYSICAL_ADDRESS_LOC addr;
-       struct core_surface *surface = pipe_ctx->surface;
+       struct dc_plane_state *plane_state = pipe_ctx->plane_state;
 
-       if (surface == NULL)
+       if (plane_state == NULL)
                return;
        addr_patched = patch_address_for_sbs_tb_stereo(pipe_ctx, &addr);
        pipe_ctx->mi->funcs->mem_input_program_surface_flip_and_addr(
                        pipe_ctx->mi,
-                       &surface->public.address,
-                       surface->public.flip_immediate);
-       surface->status.requested_address = surface->public.address;
+                       &plane_state->address,
+                       plane_state->flip_immediate);
+       plane_state->status.requested_address = plane_state->address;
        if (addr_patched)
-               pipe_ctx->surface->public.address.grph_stereo.left_addr = addr;
+               pipe_ctx->plane_state->address.grph_stereo.left_addr = addr;
 }
 
 static bool dcn10_set_input_transfer_func(
-       struct pipe_ctx *pipe_ctx, const struct core_surface *surface)
+       struct pipe_ctx *pipe_ctx, const struct dc_plane_state *plane_state)
 {
        struct input_pixel_processor *ipp = pipe_ctx->ipp;
        const struct dc_transfer_func *tf = NULL;
@@ -696,12 +1089,12 @@ static bool dcn10_set_input_transfer_func(
        if (ipp == NULL)
                return false;
 
-       if (surface->public.in_transfer_func)
-               tf = surface->public.in_transfer_func;
+       if (plane_state->in_transfer_func)
+               tf = plane_state->in_transfer_func;
 
-       if (surface->public.gamma_correction && dce_use_lut(surface))
+       if (plane_state->gamma_correction && dce_use_lut(plane_state))
                ipp->funcs->ipp_program_input_lut(ipp,
-                               surface->public.gamma_correction);
+                               plane_state->gamma_correction);
 
        if (tf == NULL)
                ipp->funcs->ipp_set_degamma(ipp, IPP_DEGAMMA_MODE_BYPASS);
@@ -1052,27 +1445,27 @@ static bool dcn10_translate_regamma_to_hw_format(const struct dc_transfer_func
 
 static bool dcn10_set_output_transfer_func(
        struct pipe_ctx *pipe_ctx,
-       const struct core_stream *stream)
+       const struct dc_stream_state *stream)
 {
-       struct output_pixel_processor *opp = pipe_ctx->opp;
+       struct transform *xfm = pipe_ctx->xfm;
 
-       if (opp == NULL)
+       if (xfm == NULL)
                return false;
 
-       opp->regamma_params.hw_points_num = GAMMA_HW_POINTS_NUM;
+       xfm->regamma_params.hw_points_num = GAMMA_HW_POINTS_NUM;
 
-       if (stream->public.out_transfer_func &&
-               stream->public.out_transfer_func->type ==
+       if (stream->out_transfer_func &&
+               stream->out_transfer_func->type ==
                        TF_TYPE_PREDEFINED &&
-               stream->public.out_transfer_func->tf ==
+               stream->out_transfer_func->tf ==
                        TRANSFER_FUNCTION_SRGB) {
-               opp->funcs->opp_set_regamma_mode(opp, OPP_REGAMMA_SRGB);
+               xfm->funcs->opp_set_regamma_mode(xfm, OPP_REGAMMA_SRGB);
        } else if (dcn10_translate_regamma_to_hw_format(
-                               stream->public.out_transfer_func, &opp->regamma_params)) {
-                       opp->funcs->opp_program_regamma_pwl(opp, &opp->regamma_params);
-                       opp->funcs->opp_set_regamma_mode(opp, OPP_REGAMMA_USER);
+                               stream->out_transfer_func, &xfm->regamma_params)) {
+                       xfm->funcs->opp_program_regamma_pwl(xfm, &xfm->regamma_params);
+                       xfm->funcs->opp_set_regamma_mode(xfm, OPP_REGAMMA_USER);
        } else {
-               opp->funcs->opp_set_regamma_mode(opp, OPP_REGAMMA_BYPASS);
+               xfm->funcs->opp_set_regamma_mode(xfm, OPP_REGAMMA_BYPASS);
        }
 
        return true;
@@ -1083,6 +1476,8 @@ static void dcn10_pipe_control_lock(
        struct pipe_ctx *pipe,
        bool lock)
 {
+       struct mem_input *mi = NULL;
+       mi = dc->res_pool->mis[pipe->pipe_idx];
        /* use TG master update lock to lock everything on the TG
         * therefore only top pipe need to lock
         */
@@ -1294,7 +1689,7 @@ static void dcn10_power_on_fe(
        struct pipe_ctx *pipe_ctx,
        struct validate_context *context)
 {
-       struct dc_surface *dc_surface = &pipe_ctx->surface->public;
+       struct dc_plane_state *plane_state = pipe_ctx->plane_state;
        struct dce_hwseq *hws = dc->hwseq;
 
        power_on_plane(dc->hwseq,
@@ -1309,24 +1704,24 @@ static void dcn10_power_on_fe(
                        OPP_PIPE_CLOCK_EN, 1);
        /*TODO: REG_UPDATE(DENTIST_DISPCLK_CNTL, DENTIST_DPPCLK_WDIVIDER, 0x1f);*/
 
-       if (dc_surface) {
+       if (plane_state) {
                dm_logger_write(dc->ctx->logger, LOG_DC,
                                "Pipe:%d 0x%x: addr hi:0x%x, "
                                "addr low:0x%x, "
                                "src: %d, %d, %d,"
                                " %d; dst: %d, %d, %d, %d;\n",
                                pipe_ctx->pipe_idx,
-                               dc_surface,
-                               dc_surface->address.grph.addr.high_part,
-                               dc_surface->address.grph.addr.low_part,
-                               dc_surface->src_rect.x,
-                               dc_surface->src_rect.y,
-                               dc_surface->src_rect.width,
-                               dc_surface->src_rect.height,
-                               dc_surface->dst_rect.x,
-                               dc_surface->dst_rect.y,
-                               dc_surface->dst_rect.width,
-                               dc_surface->dst_rect.height);
+                               plane_state,
+                               plane_state->address.grph.addr.high_part,
+                               plane_state->address.grph.addr.low_part,
+                               plane_state->src_rect.x,
+                               plane_state->src_rect.y,
+                               plane_state->src_rect.width,
+                               plane_state->src_rect.height,
+                               plane_state->dst_rect.x,
+                               plane_state->dst_rect.y,
+                               plane_state->dst_rect.width,
+                               plane_state->dst_rect.height);
 
                dm_logger_write(dc->ctx->logger, LOG_HW_SET_MODE,
                                "Pipe %d: width, height, x, y\n"
@@ -1352,35 +1747,35 @@ static void program_gamut_remap(struct pipe_ctx *pipe_ctx)
        adjust.gamut_adjust_type = GRAPHICS_GAMUT_ADJUST_TYPE_BYPASS;
 
 
-       if (pipe_ctx->stream->public.gamut_remap_matrix.enable_remap == true) {
+       if (pipe_ctx->stream->gamut_remap_matrix.enable_remap == true) {
                adjust.gamut_adjust_type = GRAPHICS_GAMUT_ADJUST_TYPE_SW;
                adjust.temperature_matrix[0] =
                                pipe_ctx->stream->
-                               public.gamut_remap_matrix.matrix[0];
+                               gamut_remap_matrix.matrix[0];
                adjust.temperature_matrix[1] =
                                pipe_ctx->stream->
-                               public.gamut_remap_matrix.matrix[1];
+                               gamut_remap_matrix.matrix[1];
                adjust.temperature_matrix[2] =
                                pipe_ctx->stream->
-                               public.gamut_remap_matrix.matrix[2];
+                               gamut_remap_matrix.matrix[2];
                adjust.temperature_matrix[3] =
                                pipe_ctx->stream->
-                               public.gamut_remap_matrix.matrix[4];
+                               gamut_remap_matrix.matrix[4];
                adjust.temperature_matrix[4] =
                                pipe_ctx->stream->
-                               public.gamut_remap_matrix.matrix[5];
+                               gamut_remap_matrix.matrix[5];
                adjust.temperature_matrix[5] =
                                pipe_ctx->stream->
-                               public.gamut_remap_matrix.matrix[6];
+                               gamut_remap_matrix.matrix[6];
                adjust.temperature_matrix[6] =
                                pipe_ctx->stream->
-                               public.gamut_remap_matrix.matrix[8];
+                               gamut_remap_matrix.matrix[8];
                adjust.temperature_matrix[7] =
                                pipe_ctx->stream->
-                               public.gamut_remap_matrix.matrix[9];
+                               gamut_remap_matrix.matrix[9];
                adjust.temperature_matrix[8] =
                                pipe_ctx->stream->
-                               public.gamut_remap_matrix.matrix[10];
+                               gamut_remap_matrix.matrix[10];
        }
 
        pipe_ctx->xfm->funcs->transform_set_gamut_remap(pipe_ctx->xfm, &adjust);
@@ -1394,23 +1789,23 @@ static void program_csc_matrix(struct pipe_ctx *pipe_ctx,
        int i;
        struct out_csc_color_matrix tbl_entry;
 
-       if (pipe_ctx->stream->public.csc_color_matrix.enable_adjustment
+       if (pipe_ctx->stream->csc_color_matrix.enable_adjustment
                                == true) {
                        enum dc_color_space color_space =
-                               pipe_ctx->stream->public.output_color_space;
+                               pipe_ctx->stream->output_color_space;
 
                        //uint16_t matrix[12];
                        for (i = 0; i < 12; i++)
-                               tbl_entry.regval[i] = pipe_ctx->stream->public.csc_color_matrix.matrix[i];
+                               tbl_entry.regval[i] = pipe_ctx->stream->csc_color_matrix.matrix[i];
 
                        tbl_entry.color_space = color_space;
                        //tbl_entry.regval = matrix;
-                       pipe_ctx->opp->funcs->opp_set_csc_adjustment(pipe_ctx->opp, &tbl_entry);
+                       pipe_ctx->xfm->funcs->opp_set_csc_adjustment(pipe_ctx->xfm, &tbl_entry);
        }
 }
 static bool is_lower_pipe_tree_visible(struct pipe_ctx *pipe_ctx)
 {
-       if (pipe_ctx->surface->public.visible)
+       if (pipe_ctx->plane_state->visible)
                return true;
        if (pipe_ctx->bottom_pipe && is_lower_pipe_tree_visible(pipe_ctx->bottom_pipe))
                return true;
@@ -1419,7 +1814,7 @@ static bool is_lower_pipe_tree_visible(struct pipe_ctx *pipe_ctx)
 
 static bool is_upper_pipe_tree_visible(struct pipe_ctx *pipe_ctx)
 {
-       if (pipe_ctx->surface->public.visible)
+       if (pipe_ctx->plane_state->visible)
                return true;
        if (pipe_ctx->top_pipe && is_upper_pipe_tree_visible(pipe_ctx->top_pipe))
                return true;
@@ -1428,7 +1823,7 @@ static bool is_upper_pipe_tree_visible(struct pipe_ctx *pipe_ctx)
 
 static bool is_pipe_tree_visible(struct pipe_ctx *pipe_ctx)
 {
-       if (pipe_ctx->surface->public.visible)
+       if (pipe_ctx->plane_state->visible)
                return true;
        if (pipe_ctx->top_pipe && is_upper_pipe_tree_visible(pipe_ctx->top_pipe))
                return true;
@@ -1503,12 +1898,12 @@ static void update_dchubp_dpp(
        struct dce_hwseq *hws = dc->hwseq;
        struct mem_input *mi = pipe_ctx->mi;
        struct input_pixel_processor *ipp = pipe_ctx->ipp;
-       struct core_surface *surface = pipe_ctx->surface;
-       union plane_size size = surface->public.plane_size;
+       struct dc_plane_state *plane_state = pipe_ctx->plane_state;
+       union plane_size size = plane_state->plane_size;
        struct default_adjustment ocsc = {0};
-       struct tg_color black_color = {0};
-       struct mpcc_cfg mpcc_cfg;
-       bool per_pixel_alpha = surface->public.per_pixel_alpha && pipe_ctx->bottom_pipe;
+       struct mpcc_cfg mpcc_cfg = {0};
+       struct pipe_ctx *top_pipe;
+       bool per_pixel_alpha = plane_state->per_pixel_alpha && pipe_ctx->bottom_pipe;
 
        /* TODO: proper fix once fpga works */
        /* depends on DML calculation, DPP clock value may change dynamically */
@@ -1541,41 +1936,36 @@ static void update_dchubp_dpp(
        if (dc->public.config.gpu_vm_support)
                mi->funcs->mem_input_program_pte_vm(
                                pipe_ctx->mi,
-                               surface->public.format,
-                               &surface->public.tiling_info,
-                               surface->public.rotation);
+                               plane_state->format,
+                               &plane_state->tiling_info,
+                               plane_state->rotation);
 
        ipp->funcs->ipp_setup(ipp,
-                       surface->public.format,
+                       plane_state->format,
                        1,
                        IPP_OUTPUT_FORMAT_12_BIT_FIX);
 
-       pipe_ctx->scl_data.lb_params.alpha_en = per_pixel_alpha;
-       mpcc_cfg.top_dpp_id = pipe_ctx->pipe_idx;
-       if (pipe_ctx->bottom_pipe)
-               mpcc_cfg.bot_mpcc_id = pipe_ctx->bottom_pipe->mpcc->inst;
+       mpcc_cfg.mi = mi;
+       mpcc_cfg.opp = pipe_ctx->opp;
+       for (top_pipe = pipe_ctx->top_pipe; top_pipe; top_pipe = top_pipe->top_pipe)
+               mpcc_cfg.z_index++;
+       if (dc->public.debug.surface_visual_confirm)
+               dcn10_get_surface_visual_confirm_color(
+                               pipe_ctx, &mpcc_cfg.black_color);
        else
-               mpcc_cfg.bot_mpcc_id = 0xf;
-       mpcc_cfg.opp_id = pipe_ctx->tg->inst;
-       mpcc_cfg.top_of_tree = pipe_ctx->pipe_idx == pipe_ctx->tg->inst;
+               color_space_to_black_color(
+                       dc, pipe_ctx->stream->output_color_space,
+                       &mpcc_cfg.black_color);
        mpcc_cfg.per_pixel_alpha = per_pixel_alpha;
        /* DCN1.0 has output CM before MPC which seems to screw with
         * pre-multiplied alpha.
         */
        mpcc_cfg.pre_multiplied_alpha = is_rgb_cspace(
-                       pipe_ctx->stream->public.output_color_space)
+                       pipe_ctx->stream->output_color_space)
                                        && per_pixel_alpha;
-       pipe_ctx->mpcc->funcs->set(pipe_ctx->mpcc, &mpcc_cfg);
-
-       if (dc->public.debug.surface_visual_confirm) {
-               dcn10_get_surface_visual_confirm_color(pipe_ctx, &black_color);
-       } else {
-               color_space_to_black_color(
-                       dc, pipe_ctx->stream->public.output_color_space,
-                       &black_color);
-       }
-       pipe_ctx->mpcc->funcs->set_bg_color(pipe_ctx->mpcc, &black_color);
+       dc->res_pool->mpc->funcs->add(dc->res_pool->mpc, &mpcc_cfg);
 
+       pipe_ctx->scl_data.lb_params.alpha_en = per_pixel_alpha;
        pipe_ctx->scl_data.lb_params.depth = LB_PIXEL_DEPTH_30BPP;
        /* scaler configuration */
        pipe_ctx->xfm->funcs->transform_set_scaler(
@@ -1587,17 +1977,17 @@ static void update_dchubp_dpp(
        program_gamut_remap(pipe_ctx);
 
        /*TODO add adjustments parameters*/
-       ocsc.out_color_space = pipe_ctx->stream->public.output_color_space;
+       ocsc.out_color_space = pipe_ctx->stream->output_color_space;
        pipe_ctx->xfm->funcs->opp_set_csc_default(pipe_ctx->xfm, &ocsc);
 
        mi->funcs->mem_input_program_surface_config(
                mi,
-               surface->public.format,
-               &surface->public.tiling_info,
+               plane_state->format,
+               &plane_state->tiling_info,
                &size,
-               surface->public.rotation,
-               &surface->public.dcc,
-               surface->public.horizontal_mirror);
+               plane_state->rotation,
+               &plane_state->dcc,
+               plane_state->horizontal_mirror);
 
        mi->funcs->set_blank(mi, !is_pipe_tree_visible(pipe_ctx));
 }
@@ -1615,8 +2005,7 @@ static void program_all_pipe_in_tree(
                 * this OTG. this is done only one time.
                 */
                /* watermark is for all pipes */
-               pipe_ctx->mi->funcs->program_watermarks(
-                               pipe_ctx->mi, &context->bw.dcn.watermarks, ref_clk_mhz);
+               program_watermarks(dc->hwseq, &context->bw.dcn.watermarks, ref_clk_mhz);
 
                if (dc->public.debug.sanity_checks) {
                        /* pstate stuck check after watermark update */
@@ -1636,7 +2025,7 @@ static void program_all_pipe_in_tree(
                pipe_ctx->tg->funcs->set_blank(pipe_ctx->tg, !is_pipe_tree_visible(pipe_ctx));
        }
 
-       if (pipe_ctx->surface != NULL) {
+       if (pipe_ctx->plane_state != NULL) {
                dcn10_power_on_fe(dc, pipe_ctx, context);
                update_dchubp_dpp(dc, pipe_ctx, context);
        }
@@ -1679,7 +2068,7 @@ static void dcn10_pplib_apply_display_requirements(
 
 static void dcn10_apply_ctx_for_surface(
                struct core_dc *dc,
-               struct core_surface *surface,
+               const struct dc_plane_state *plane_state,
                struct validate_context *context)
 {
        int i, be_idx;
@@ -1687,11 +2076,11 @@ static void dcn10_apply_ctx_for_surface(
        if (dc->public.debug.sanity_checks)
                verify_allow_pstate_change_high(dc->hwseq);
 
-       if (!surface)
+       if (!plane_state)
                return;
 
        for (be_idx = 0; be_idx < dc->res_pool->pipe_count; be_idx++)
-               if (surface == context->res_ctx.pipe_ctx[be_idx].surface)
+               if (plane_state == context->res_ctx.pipe_ctx[be_idx].plane_state)
                        break;
 
        /* reset unused mpcc */
@@ -1700,7 +2089,7 @@ static void dcn10_apply_ctx_for_surface(
                struct pipe_ctx *old_pipe_ctx =
                                &dc->current_context->res_ctx.pipe_ctx[i];
 
-               if (!pipe_ctx->surface && !old_pipe_ctx->surface)
+               if (!pipe_ctx->plane_state && !old_pipe_ctx->plane_state)
                        continue;
 
                /*
@@ -1708,8 +2097,8 @@ static void dcn10_apply_ctx_for_surface(
                 * fairly hacky right now, using opp_id as indicator
                 */
 
-               if (pipe_ctx->surface && !old_pipe_ctx->surface) {
-                       if (pipe_ctx->mpcc->opp_id != 0xf && pipe_ctx->tg->inst == be_idx) {
+               if (pipe_ctx->plane_state && !old_pipe_ctx->plane_state) {
+                       if (pipe_ctx->mi->opp_id != 0xf && pipe_ctx->tg->inst == be_idx) {
                                dcn10_power_down_fe(dc, pipe_ctx->pipe_idx);
                                /*
                                 * power down fe will unlock when calling reset, need
@@ -1720,11 +2109,8 @@ static void dcn10_apply_ctx_for_surface(
                }
 
 
-               if ((!pipe_ctx->surface && old_pipe_ctx->surface)
+               if ((!pipe_ctx->plane_state && old_pipe_ctx->plane_state)
                                || (!pipe_ctx->stream && old_pipe_ctx->stream)) {
-                       struct mpcc_cfg mpcc_cfg;
-                       int opp_id_cached = old_pipe_ctx->mpcc->opp_id;
-
                        if (old_pipe_ctx->tg->inst != be_idx)
                                continue;
 
@@ -1734,26 +2120,22 @@ static void dcn10_apply_ctx_for_surface(
                        }
 
                        /* reset mpc */
-                       mpcc_cfg.opp_id = 0xf;
-                       mpcc_cfg.top_dpp_id = 0xf;
-                       mpcc_cfg.bot_mpcc_id = 0xf;
-                       mpcc_cfg.top_of_tree = !old_pipe_ctx->top_pipe;
-                       old_pipe_ctx->mpcc->funcs->set(old_pipe_ctx->mpcc, &mpcc_cfg);
-                       old_pipe_ctx->top_pipe->opp->mpcc_disconnect_pending[old_pipe_ctx->mpcc->inst] = true;
+                       dc->res_pool->mpc->funcs->remove(
+                                       dc->res_pool->mpc,
+                                       old_pipe_ctx->opp,
+                                       old_pipe_ctx->pipe_idx);
+                       old_pipe_ctx->opp->mpcc_disconnect_pending[old_pipe_ctx->mi->mpcc_id] = true;
+
+                       /*dm_logger_write(dc->ctx->logger, LOG_ERROR,
+                                       "[debug_mpo: apply_ctx disconnect pending on mpcc %d]\n",
+                                       old_pipe_ctx->mpcc->inst);*/
 
                        if (dc->public.debug.sanity_checks)
                                verify_allow_pstate_change_high(dc->hwseq);
 
-                       /*
-                        * the mpcc is the only thing that keeps track of the mpcc
-                        * mapping for reset front end right now. Might need some
-                        * rework.
-                        */
-                       old_pipe_ctx->mpcc->opp_id = opp_id_cached;
-
                        old_pipe_ctx->top_pipe = NULL;
                        old_pipe_ctx->bottom_pipe = NULL;
-                       old_pipe_ctx->surface = NULL;
+                       old_pipe_ctx->plane_state = NULL;
 
                        dm_logger_write(dc->ctx->logger, LOG_DC,
                                        "Reset mpcc for pipe %d\n",
@@ -1764,7 +2146,7 @@ static void dcn10_apply_ctx_for_surface(
        for (i = 0; i < dc->res_pool->pipe_count; i++) {
                struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
 
-               if (pipe_ctx->surface != surface)
+               if (pipe_ctx->plane_state != plane_state)
                        continue;
 
                /* looking for top pipe to program */
@@ -1939,11 +2321,11 @@ static void set_plane_config(
 }
 
 static void dcn10_config_stereo_parameters(
-               struct core_stream *stream, struct crtc_stereo_flags *flags)
+               struct dc_stream_state *stream, struct crtc_stereo_flags *flags)
 {
-       enum view_3d_format view_format = stream->public.view_format;
+       enum view_3d_format view_format = stream->view_format;
        enum dc_timing_3d_format timing_3d_format =\
-                       stream->public.timing.timing_3d_format;
+                       stream->timing.timing_3d_format;
        bool non_stereo_timing = false;
 
        if (timing_3d_format == TIMING_3D_FORMAT_NONE ||
@@ -1960,14 +2342,14 @@ static void dcn10_config_stereo_parameters(
                        timing_3d_format == TIMING_3D_FORMAT_DP_HDMI_INBAND_FA ||
                        timing_3d_format == TIMING_3D_FORMAT_SIDEBAND_FA) {
                        enum display_dongle_type dongle = \
-                                       stream->sink->link->public.ddc->dongle_type;
+                                       stream->sink->link->ddc->dongle_type;
                        if (dongle == DISPLAY_DONGLE_DP_VGA_CONVERTER ||
                                dongle == DISPLAY_DONGLE_DP_DVI_CONVERTER ||
                                dongle == DISPLAY_DONGLE_DP_HDMI_CONVERTER)
                                flags->DISABLE_STEREO_DP_SYNC = 1;
                }
                flags->RIGHT_EYE_POLARITY =\
-                               stream->public.timing.flags.RIGHT_EYE_3D_POLARITY;
+                               stream->timing.flags.RIGHT_EYE_3D_POLARITY;
                if (timing_3d_format == TIMING_3D_FORMAT_HW_FRAME_PACKING)
                        flags->FRAME_PACKED = 1;
        }
@@ -1978,53 +2360,101 @@ static void dcn10_config_stereo_parameters(
 static void dcn10_setup_stereo(struct pipe_ctx *pipe_ctx, struct core_dc *dc)
 {
        struct crtc_stereo_flags flags = { 0 };
-       struct core_stream *stream = pipe_ctx->stream;
+       struct dc_stream_state *stream = pipe_ctx->stream;
 
        dcn10_config_stereo_parameters(stream, &flags);
 
        pipe_ctx->opp->funcs->opp_set_stereo_polarity(
                pipe_ctx->opp,
                flags.PROGRAM_STEREO == 1 ? true:false,
-               stream->public.timing.flags.RIGHT_EYE_3D_POLARITY == 1 ? true:false);
+               stream->timing.flags.RIGHT_EYE_3D_POLARITY == 1 ? true:false);
 
        pipe_ctx->tg->funcs->program_stereo(
                pipe_ctx->tg,
-               &stream->public.timing,
+               &stream->timing,
                &flags);
 
        return;
 }
 
-static void dcn10_log_hw_state(struct core_dc *dc)
+
+static void log_mpc_crc(struct core_dc *dc)
 {
        struct dc_context *dc_ctx = dc->ctx;
        struct dce_hwseq *hws = dc->hwseq;
 
-       DTN_INFO("%s: Hello World", __func__);
-
        if (REG(MPC_CRC_RESULT_GB))
                DTN_INFO("MPC_CRC_RESULT_GB:%d MPC_CRC_RESULT_C:%d MPC_CRC_RESULT_AR:%d\n",
                REG_READ(MPC_CRC_RESULT_GB), REG_READ(MPC_CRC_RESULT_C), REG_READ(MPC_CRC_RESULT_AR));
        if (REG(DPP_TOP0_DPP_CRC_VAL_B_A))
                DTN_INFO("DPP_TOP0_DPP_CRC_VAL_B_A:%d DPP_TOP0_DPP_CRC_VAL_R_G:%d\n",
                REG_READ(DPP_TOP0_DPP_CRC_VAL_B_A), REG_READ(DPP_TOP0_DPP_CRC_VAL_R_G));
-       /* todo: add meaningful register reads and print out HW state
-        *
-        */
 }
 
-static void dcn10_wait_for_mpcc_disconnect(struct resource_pool *res_pool, struct pipe_ctx *pipe_ctx)
+static void dcn10_log_hw_state(struct core_dc *dc)
 {
+       struct dc_context *dc_ctx = dc->ctx;
+       struct resource_pool *pool = dc->res_pool;
        int i;
-       for (i = 0; i < MAX_PIPES; i++) {
-               if (!pipe_ctx->opp || !pipe_ctx->mpcc)
-                       continue;
 
+       DTN_INFO_BEGIN();
+
+       DTN_INFO("HUBP:\t format \t addr_hi \t width \t height \t rotation \t"
+                       "mirror \t  sw_mode \t dcc_en \t blank_en \t ttu_dis \t"
+                       "min_ttu_vblank \t qos_low_wm \t qos_high_wm \n");
+
+       for (i = 0; i < pool->pipe_count; i++) {
+               struct mem_input *mi = pool->mis[i];
+               struct dcn_hubp_state s;
+
+               dcn10_mem_input_read_state(TO_DCN10_MEM_INPUT(mi), &s);
+
+               DTN_INFO("[%d]:\t %xh \t %xh \t %d \t %d \t %xh \t %xh \t "
+                               "%d \t %d \t %d \t %d \t"
+                               "%d \t %d \t %d \n",
+                               i,
+                               s.pixel_format,
+                               s.inuse_addr_hi,
+                               s.viewport_width,
+                               s.viewport_height,
+                               s.rotation_angle,
+                               s.h_mirror_en,
+                               s.sw_mode,
+                               s.dcc_en,
+                               s.blank_en,
+                               s.ttu_disable,
+                               s.min_ttu_vblank,
+                               s.qos_level_low_wm,
+                               s.qos_level_high_wm);
+       }
+       DTN_INFO("\n");
+
+       log_mpc_crc(dc);
+
+       DTN_INFO_END();
+}
+
+static void dcn10_wait_for_mpcc_disconnect(
+               struct core_dc *dc,
+               struct resource_pool *res_pool,
+               struct pipe_ctx *pipe_ctx)
+{
+       int i;
+
+       if (!pipe_ctx->opp)
+               return;
+
+       for (i = 0; i < MAX_PIPES; i++) {
                if (pipe_ctx->opp->mpcc_disconnect_pending[i]) {
-                       pipe_ctx->mpcc->funcs->wait_for_idle(res_pool->mpcc[i]);
+                       res_pool->mpc->funcs->wait_for_idle(res_pool->mpc, i);
                        pipe_ctx->opp->mpcc_disconnect_pending[i] = false;
+                       res_pool->mis[i]->funcs->set_blank(res_pool->mis[i], true);
+                       /*dm_logger_write(dc->ctx->logger, LOG_ERROR,
+                                       "[debug_mpo: wait_for_mpcc finished waiting on mpcc %d]\n",
+                                       i);*/
                }
        }
+
 }
 
 static bool dcn10_dummy_display_power_gating(
@@ -2038,34 +2468,34 @@ static bool dcn10_dummy_display_power_gating(
 
 void dcn10_update_pending_status(struct pipe_ctx *pipe_ctx)
 {
-       struct core_surface *surface = pipe_ctx->surface;
+       struct dc_plane_state *plane_state = pipe_ctx->plane_state;
        struct timing_generator *tg = pipe_ctx->tg;
 
-       if (surface->ctx->dc->debug.sanity_checks) {
-               struct core_dc *dc = DC_TO_CORE(surface->ctx->dc);
+       if (plane_state->ctx->dc->debug.sanity_checks) {
+               struct core_dc *dc = DC_TO_CORE(plane_state->ctx->dc);
 
                verify_allow_pstate_change_high(dc->hwseq);
        }
 
-       if (surface == NULL)
+       if (plane_state == NULL)
                return;
 
-       surface->status.is_flip_pending =
+       plane_state->status.is_flip_pending =
                        pipe_ctx->mi->funcs->mem_input_is_flip_pending(
                                        pipe_ctx->mi);
 
        /* DCN we read INUSE address in MI, do we still need this wa? */
-       if (surface->status.is_flip_pending &&
-                       !surface->public.visible) {
+       if (plane_state->status.is_flip_pending &&
+                       !plane_state->visible) {
                pipe_ctx->mi->current_address =
                                pipe_ctx->mi->request_address;
                BREAK_TO_DEBUGGER();
        }
 
-       surface->status.current_address = pipe_ctx->mi->current_address;
+       plane_state->status.current_address = pipe_ctx->mi->current_address;
        if (pipe_ctx->mi->current_address.type == PLN_ADDR_TYPE_GRPH_STEREO &&
                        tg->funcs->is_stereo_left_eye) {
-               surface->status.is_right_eye =
+               plane_state->status.is_right_eye =
                                !tg->funcs->is_stereo_left_eye(pipe_ctx->tg);
        }
 }
@@ -2078,6 +2508,7 @@ static const struct hw_sequencer_funcs dcn10_funcs = {
        .apply_ctx_for_surface = dcn10_apply_ctx_for_surface,
        .set_plane_config = set_plane_config,
        .update_plane_addr = update_plane_addr,
+       .update_dchub = dcn10_update_dchub,
        .update_pending_status = dcn10_update_pending_status,
        .set_input_transfer_func = dcn10_set_input_transfer_func,
        .set_output_transfer_func = dcn10_set_output_transfer_func,