Example #1
0
static int ldi_init(struct k3_fb_data_type *k3fd)
{
	u32 edc_base = 0;
	struct k3_panel_info *pinfo = NULL;

	BUG_ON(k3fd == NULL);

	pinfo = &(k3fd->panel_info);
	edc_base = k3fd->edc_base;

	set_LDI_HRZ_CTRL0_hfp(edc_base, pinfo->ldi.h_front_porch);
	set_LDI_HRZ_CTRL0_hbp(edc_base, pinfo->ldi.h_back_porch);
	set_LDI_HRZ_CTRL1_hsw(edc_base, pinfo->ldi.h_pulse_width);
	set_LDI_VRT_CTRL0_vfp(edc_base, pinfo->ldi.v_front_porch);
	set_LDI_VRT_CTRL0_vbp(edc_base, pinfo->ldi.v_back_porch);
	if (pinfo->ldi.v_pulse_width > 15)
		pinfo->ldi.v_pulse_width = 15;
	set_LDI_VRT_CTRL1_vsw(edc_base, pinfo->ldi.v_pulse_width);
	set_LDI_PLR_CTRL_hsync(edc_base, pinfo->ldi.hsync_plr);
	set_LDI_PLR_CTRL_vsync(edc_base, pinfo->ldi.vsync_plr);
	set_LDI_PLR_CTRL_pixel_clk(edc_base, pinfo->ldi.pixelclk_plr);
	set_LDI_PLR_CTRL_data_en(edc_base, pinfo->ldi.data_en_plr);

	set_LDI_DSP_SIZE_hsize(edc_base, pinfo->xres);
	set_LDI_DSP_SIZE_vsize(edc_base, pinfo->yres);

	set_LDI_WORK_MODE_work_mode(edc_base, LDI_WORK);
	set_LDI_WORK_MODE_colorbar_en(edc_base, K3_DISABLE);
	set_LDI_CTRL_bgr(edc_base, pinfo->bgr_fmt);
	set_LDI_CTRL_bpp(edc_base, pinfo->bpp);
	set_LDI_CTRL_disp_mode(edc_base, pinfo->ldi.disp_mode);
	set_LDI_CTRL_corlorbar_width(edc_base, 0x3C);
	if (pinfo->type == PANEL_MIPI_CMD) {
		set_LDI_CTRL_ldi_en(edc_base, K3_DISABLE);
	} else {
		set_LDI_CTRL_ldi_en(edc_base, K3_ENABLE);
	}
	set_LDI_INT_CLR(edc_base, 0xFFFFFFFF);

	if (pinfo->type == PANEL_HDMI) {
		/* dsi pixel off */
		set_reg(edc_base + LDI_HDMI_DSI_GT, 0x1, 1, 0);
	}

	if (!(pinfo->bl_set_type & BL_SET_BY_PWM)) {
		set_reg(edc_base + LDI_DE_SPACE_LOW, 0x1, 1, 1);
	}

	return 0;
}
Example #2
0
static int ldi_on(struct platform_device *pdev)
{
	int ret = 0;
	struct k3_fb_data_type *k3fd = NULL;

	BUG_ON(pdev == NULL);

	k3fd = (struct k3_fb_data_type *)platform_get_drvdata(pdev);
	BUG_ON(k3fd == NULL);

	/* ldi clock enable */
	ret = clk_enable(k3fd->ldi_clk);
	if (ret != 0) {
		k3fb_loge("failed to enable ldi_clk, error=%d!\n", ret);
		return ret;
	}

	/* ldi init */
	ldi_init(k3fd);

	if (k3fd->panel_info.type == PANEL_LDI) {
		/* set LCD init step before LCD on*/
		k3fd->panel_info.lcd_init_step = LCD_INIT_POWER_ON;
		ret = panel_next_on(pdev);
	}

	ret = panel_next_on(pdev);

	set_LDI_CTRL_ldi_en(k3fd->edc_base, K3_ENABLE);

	return ret;
}
STATIC int balong_ade_overlay_commit(struct ade_compose_data_type    *ade_pri_data, void __user *p)
{
    struct overlay_compose_info comp_info;
    struct balong_fb_data_type *balongfd = NULL;
    int ret = 0;
    u32 struct_len = sizeof(struct ovly_hnd_info) * ADE_OVERLAY_MAX_LAYERS;
#if ADE_SYNC_SUPPORT
    int fenceId = 0;
    unsigned long flags;
#endif

    BUG_ON(ade_pri_data == NULL);

    balongfb_logi_display_debugfs("balong_ade_overlay_commit enter succ ! \n");

    if (copy_from_user(&comp_info, p, sizeof(comp_info))) {
        balongfb_loge("copy from user failed!\n");
        return -EFAULT;
    }

    balongfd = (struct balong_fb_data_type *)platform_get_drvdata(ade_pri_data->parent);
    BUG_ON(balongfd == NULL);
    if ((!balongfd->frame_updated) && lcd_pwr_status.panel_power_on)
    {

        balongfd->frame_updated = 1;
        lcd_pwr_status.lcd_dcm_pwr_status |= BIT(2);
        do_gettimeofday(&lcd_pwr_status.tvl_set_frame);
        time_to_tm(lcd_pwr_status.tvl_set_frame.tv_sec, 0, &lcd_pwr_status.tm_set_frame);
    }
    down(&balong_fb_blank_sem);
    if (!balongfd->ade_core_power_on) {
        up(&balong_fb_blank_sem);
        balongfb_logi("ade_core_power_on is false !\n");
        return -EPERM;
    }


    if (ADE_TRUE == comp_info.is_finished) {
        spin_lock_irqsave(&balongfd->refresh_lock, flags);
        balongfd->refresh++;
        spin_unlock_irqrestore(&balongfd->refresh_lock, flags);
        balongfd->timeline_max++;
        //release the reserved buffer of fb
        if((true == ade_pri_data->fb_reserved_flag) && (ade_pri_data->frame_count)) {
            balong_ion_free_mem_to_buddy();
            ade_pri_data->fb_reserved_flag = false;
        }

        if (PANEL_MIPI_VIDEO == ade_pri_data->lcd_type) {
            spin_lock_irqsave(&(balongfd->vsync_info.spin_lock), flags);
            set_LDI_INT_MASK_bit(balongfd->ade_base, LDI_ISR_FRAME_END_INT);
            balongfd->vsync_info.vsync_ctrl_expire_count = 0;
            spin_unlock_irqrestore(&(balongfd->vsync_info.spin_lock), flags);

            if (balongfd->vsync_info.vsync_ctrl_disabled_set) {
                if (balongfd->ldi_irq) {
                    enable_irq(balongfd->ldi_irq);
                    balongfd->vsync_info.vsync_ctrl_disabled_set = false;
                }
            }
        }

#ifndef PC_UT_TEST_ON
#ifdef CONFIG_TRACING
        trace_dot(SF, "7", 0);
#endif
#endif

#if ADE_DEBUG_LOG_ENABLE
        g_debug_frame_number = comp_info.frame_number;
#endif
    }

    ret = ade_overlay_commit(ade_pri_data, &comp_info);

    if ((ADE_TRUE == comp_info.is_finished)) {
        if (ret == 0) {
            set_LDI_INT_MASK_bit(ade_pri_data->ade_base, LDI_ISR_UNDER_FLOW_INT);
#if PARTIAL_UPDATE
            if ((PANEL_MIPI_CMD == ade_pri_data->lcd_type) && (true == balongfd->dirty_update)) {
                balongfb_set_display_region(balongfd);
                balongfd->dirty_update = false;
            }
#endif
            if (PANEL_MIPI_VIDEO == ade_pri_data->lcd_type) {
                if ((ade_pri_data->overlay_ctl.comp_info.compose_mode != OVERLAY_COMP_TYPE_ONLINE)
                    || (balongfd->vpu_power_on)){
                     /* ade_core_rate is default value (360M) */
                     balongfd->ade_set_core_rate = balongfd->ade_core_rate;
                }

                if (balongfd->last_ade_core_rate != balongfd->ade_set_core_rate) {
                    if (clk_set_rate(balongfd->ade_clk, balongfd->ade_set_core_rate) != 0) {
                          balongfb_loge("clk_set_rate ade_core_rate error \n");
                    }
                }

                balongfd->last_ade_core_rate = balongfd->ade_set_core_rate;

            }

            set_LDI_CTRL_ldi_en(ade_pri_data->ade_base, ADE_ENABLE);
            balongfd->ade_ldi_on = true;
            if (PANEL_MIPI_CMD == ade_pri_data->lcd_type) {
                set_LDI_INT_MASK_bit(balongfd->ade_base, LDI_ISR_DSI_TE0_PIN_INT);

                /* enable fake vsync timer */
                if (balongfd->frc_state != BALONG_FB_FRC_IDLE_PLAYING) {
                    balongfd->use_cmd_vsync = (balongfb_frc_get_fps(balongfd) < BALONG_FB_FRC_NORMAL_FPS ? true : false);
                }

                /* report vsync with timer */
                if (balongfd->use_cmd_vsync) {
                    hrtimer_restart(&balongfd->cmd_vsync_hrtimer);
                } else {
                    hrtimer_cancel(&balongfd->cmd_vsync_hrtimer);
                }
            }

#ifndef PC_UT_TEST_ON
#ifdef CONFIG_TRACING
            trace_dot(SF, "8", 0);
#endif
#endif

#if ADE_SYNC_SUPPORT
            /* In online/hybrid mode, ADE must create release fenceFd.
             * In offline mode, don't create release fenceFd
             * because ADE will read HAL's offline buffer instead of layer's buffer.
             */
            /*
               spin_lock_irqsave(&balongfd->refresh_lock, flags);
               balongfd->refresh++;
               spin_unlock_irqrestore(&balongfd->refresh_lock, flags);
               balongfd->timeline_max++;
             */
            if ((OVERLAY_COMP_TYPE_ONLINE == comp_info.compose_mode)
                    || (OVERLAY_COMP_TYPE_HYBRID == comp_info.compose_mode)) {

                fenceId = balong_ade_overlay_fence_create(balongfd->timeline, "ADE", balongfd->timeline_max);
                if (fenceId < 0) {
                    balongfb_loge("ADE failed to create fence!\n");
                }
                comp_info.release_fence = fenceId;
                if (copy_to_user((struct overlay_compose_info __user*)p, &comp_info, sizeof(struct overlay_compose_info))
                        && (fenceId >= 0)) {
                    fenceId = -EFAULT;
                    balongfb_loge("ADE failed to copy fence to user!\n");
                    put_unused_fd(comp_info.release_fence);

                    up(&balong_fb_blank_sem);
                    return fenceId;
                }
            }
#endif /* ADE_SYNC_SUPPORT */
            ade_overlay_handle_unlock(balongfd);
            memcpy(balongfd->locked_hnd, balongfd->locking_hnd, struct_len);
            memset(balongfd->locking_hnd, 0, struct_len);
        } else {
            ade_overlay_handle_unlock(balongfd);
            memcpy(balongfd->locked_hnd, balongfd->locking_hnd, struct_len);
            memset(balongfd->locking_hnd, 0, struct_len);
            up(&balong_fb_blank_sem);
            return ret;
        }
    }

    up(&balong_fb_blank_sem);

    balongfb_logi_display_debugfs("balong_ade_overlay_commit exit succ ! \n");
    return 0;
}