示例#1
0
void disp_bls_init(unsigned int srcWidth, unsigned int srcHeight)
{
    struct cust_mt65xx_led *cust_led_list = get_cust_led_list();
    struct cust_mt65xx_led *cust = NULL;
    struct PWM_config *config_data = NULL;

    if(cust_led_list)
    {
        cust = &cust_led_list[MT65XX_LED_TYPE_LCD];
        if((strcmp(cust->name,"lcd-backlight") == 0) && (cust->mode == MT65XX_LED_MODE_CUST_BLS_PWM))
        {
            config_data = &cust->config_data;
            if (config_data->clock_source >= 0 && config_data->clock_source <= 3)
            {
            	unsigned int regVal = DISP_REG_GET(CLK_CFG_1);
                DISP_REG_SET(CLK_CFG_1, (regVal & ~0x3) | config_data->clock_source);
                printf("disp_bls_init : CLK_CFG_1 0x%x => 0x%x\n", regVal, DISP_REG_GET(CLK_CFG_1));
            }
            gPWMDiv = (config_data->div == 0) ? PWM_DEFAULT_DIV_VALUE : config_data->div;
            gPWMDiv &= 0x3FF;
            printf("disp_bls_init : PWM config data (%d,%d)\n", config_data->clock_source, config_data->div);
        }
    }
    
    printf("[DDP] disp_bls_init : srcWidth = %d, srcHeight = %d\n", srcWidth, srcHeight);
    printf("[DDP] disp_bls_init : CG = 0x%x, BLS_EN = 0x%x, PWM_DUTY = %d\n", 
        DISP_REG_GET(DISP_REG_CONFIG_MMSYS_CG_CON0), 
        DISP_REG_GET(DISP_REG_BLS_EN),
        DISP_REG_GET(DISP_REG_BLS_PWM_DUTY));
    
    DISP_REG_SET(DISP_REG_BLS_SRC_SIZE, (srcHeight << 16) | srcWidth);
    DISP_REG_SET(DISP_REG_BLS_PWM_DUTY, 0);
    DISP_REG_SET(DISP_REG_BLS_PWM_CON, 0x0 | (gPWMDiv << 16));
    DISP_REG_SET(DISP_REG_BLS_EN, 0x00010000);
}
示例#2
0
int disp_bls_config(void)
{
#if !defined(MTK_AAL_SUPPORT) 
    struct cust_mt65xx_led *cust_led_list = get_cust_led_list();
    struct cust_mt65xx_led *cust = NULL;
    struct PWM_config *config_data = NULL;

    if(cust_led_list)
    {
        cust = &cust_led_list[MT65XX_LED_TYPE_LCD];
        if((strcmp(cust->name,"lcd-backlight") == 0) && (cust->mode == MT65XX_LED_MODE_CUST_BLS_PWM))
        {
            config_data = &cust->config_data;
            if (config_data->clock_source >= 0 && config_data->clock_source <= 3)
            {
		unsigned int regVal = DISP_REG_GET(CLK_CFG_1);
                DISP_REG_SET(CLK_CFG_1, (regVal & ~0x3) | config_data->clock_source);
                printf("disp_bls_config : CLK_CFG_1 0x%x => 0x%x\n", regVal, DISP_REG_GET(CLK_CFG_1));
            }
            gPWMDiv = (config_data->div == 0) ? PWM_DEFAULT_DIV_VALUE : config_data->div;
            gPWMDiv &= 0x3FF;
            printf("disp_bls_config : PWM config data (%d,%d)\n", config_data->clock_source, config_data->div);
        }
    }
    
    printf("[DDP] disp_bls_config : CG = 0x%x, BLS_EN = 0x%x, PWM_DUTY = %d\n", 
        DISP_REG_GET(DISP_REG_CONFIG_MMSYS_CG_CON0), 
        DISP_REG_GET(DISP_REG_BLS_EN),
        DISP_REG_GET(DISP_REG_BLS_PWM_DUTY));
#ifdef USE_DISP_BLS_MUTEX
    printf("[DDP] disp_bls_config : gBLSMutexID = %d\n", gBLSMutexID);
    DISP_REG_SET(DISP_REG_CONFIG_MUTEX_RST(gBLSMutexID), 1);
    DISP_REG_SET(DISP_REG_CONFIG_MUTEX_RST(gBLSMutexID), 0);
    DISP_REG_SET(DISP_REG_CONFIG_MUTEX_MOD(gBLSMutexID), 0x200);    // BLS
    DISP_REG_SET(DISP_REG_CONFIG_MUTEX_SOF(gBLSMutexID), 0);        // single mode
    DISP_REG_SET(DISP_REG_CONFIG_MUTEX_EN(gBLSMutexID), 1);

    if (disp_bls_get_mutex() == 0)
    {
#else
        DISP_REG_SET(DISP_REG_BLS_DEBUG, 0x3);
#endif

        DISP_REG_SET(DISP_REG_BLS_PWM_DUTY, 0);
        DISP_REG_SET(DISP_REG_BLS_PWM_CON, 0x0 | (gPWMDiv << 16));
        DISP_REG_SET(DISP_REG_BLS_EN, 0x00010000);

#ifdef USE_DISP_BLS_MUTEX
        if (disp_bls_release_mutex() == 0)
            return 0;
    }
    return -1;
#else
    DISP_REG_SET(DISP_REG_BLS_DEBUG, 0x0);
#endif

#endif
    return 0;
}
示例#3
0
struct cust_mt65xx_led *mt_get_cust_led_list(void)
{
	struct cust_mt65xx_led *cust_led_list = get_cust_led_dtsi();

	if (cust_led_list == NULL) {
		LEDS_DEBUG("mt_get_cust_led_list can not get the led info from devices tree .\n");
		cust_led_list = get_cust_led_list();
	}
	return cust_led_list;
}
void disp_bls_init(unsigned int srcWidth, unsigned int srcHeight)
{       
    DDP_DRV_DBG("disp_bls_init : srcWidth = %d, srcHeight = %d\n", srcWidth, srcHeight);

    struct cust_mt65xx_led *cust_led_list = get_cust_led_list();
    struct cust_mt65xx_led *cust = NULL;
    struct PWM_config *config_data = NULL;

    if(cust_led_list)
    {
        cust = &cust_led_list[MT65XX_LED_TYPE_LCD];
        if((strcmp(cust->name,"lcd-backlight") == 0) && (cust->mode == MT65XX_LED_MODE_CUST_BLS_PWM))
        {
            config_data = &cust->config_data;
            if (config_data->clock_source >= 0 && config_data->clock_source <= 1)
            {
                unsigned int regVal = DISP_REG_GET(0xF0000000);
                if(config_data->clock_source == 0)
                    clkmux_sel(MT_CLKMUX_PWM_MM_MUX_SEL, MT_CG_SYS_26M, "DISP_PWM");
                else
                    clkmux_sel(MT_CLKMUX_PWM_MM_MUX_SEL, MT_CG_UPLL_D12, "DISP_PWM");
                DISP_DBG("disp_bls_init : 0xF0000000: 0x%x => 0x%x\n", regVal, DISP_REG_GET(0xF0000000));
            }
        }
    }

    // TODO: fix register setting
    DISP_REG_SET(DISP_REG_BLS_SRC_SIZE, (srcHeight << 16) | srcWidth);
    DISP_REG_SET(DISP_REG_BLS_PWM_DUTY, DISP_REG_GET(DISP_REG_BLS_PWM_DUTY));
    DISP_REG_SET(DISP_REG_BLS_PWM_CON, 0x0);
    DISP_REG_SET(DISP_REG_BLS_INTEN, 0xF);

    disp_bls_update_gamma_lut();
    //disp_bls_update_pwm_lut();  // not used in 6572

#if 0 // TODO: fix Dither setting
    // Dithering
    DISP_REG_SET(DISP_REG_BLS_DITHER(0), 0x00000001);
    DISP_REG_SET(DISP_REG_BLS_DITHER(6), 0x00000000);
    DISP_REG_SET(DISP_REG_BLS_DITHER(13), 0x00000222);
    DISP_REG_SET(DISP_REG_BLS_DITHER(14), 0x00000000);
    DISP_REG_SET(DISP_REG_BLS_DITHER(15), 0x22220001);
    DISP_REG_SET(DISP_REG_BLS_DITHER(16), 0x22222222);
    DISP_REG_SET(DISP_REG_BLS_DITHER(17), 0x00000000);
#endif

    DISP_REG_SET(DISP_REG_BLS_EN, 0x00010001);          // enable BLS_EN

    disp_bls_config_full(srcWidth, srcHeight);

#if 0
    disp_dump_reg(DISP_MODULE_BLS);
#endif

}
示例#5
0
void disp_bls_init(unsigned int srcWidth, unsigned int srcHeight)
{
    struct cust_mt65xx_led *cust_led_list = get_cust_led_list();
    struct cust_mt65xx_led *cust = NULL;
    struct PWM_config *config_data = NULL;

    if(cust_led_list)
    {
        cust = &cust_led_list[MT65XX_LED_TYPE_LCD];
        if((strcmp(cust->name,"lcd-backlight") == 0) && (cust->mode == MT65XX_LED_MODE_CUST_BLS_PWM))
        {
            config_data = &cust->config_data;
            if (config_data->clock_source >= 0 && config_data->clock_source <= 3)
            {
                unsigned int regVal = DISP_REG_GET(CLK_CFG_1);
                clkmux_sel(MT_MUX_PWM, config_data->clock_source, "DISP_PWM");
                BLS_DBG("disp_bls_init : CLK_CFG_1 0x%x => 0x%x\n", regVal, DISP_REG_GET(CLK_CFG_1));
            }
            gPWMDiv = (config_data->div == 0) ? PWM_DEFAULT_DIV_VALUE : config_data->div;
            gPWMDiv &= 0x3FF;
            BLS_MSG("disp_bls_init : PWM config data (%d,%d)\n", config_data->clock_source, config_data->div);
        }
    }
        
    BLS_DBG("disp_bls_init : srcWidth = %d, srcHeight = %d\n", srcWidth, srcHeight);
    BLS_MSG("disp_bls_init : BLS_EN=0x%x, PWM_DUTY=%d, PWM_DUTY_RD=%d, CG=0x%x, %d, %d\n", 
        DISP_REG_GET(DISP_REG_BLS_EN),
        DISP_REG_GET(DISP_REG_BLS_PWM_DUTY),
        DISP_REG_GET(DISP_REG_BLS_PWM_DUTY_RD),
        DISP_REG_GET(DISP_REG_CONFIG_MMSYS_CG_CON0),
        clock_is_on(MT_CG_DISP0_MDP_BLS_26M),
        clock_is_on(MT_CG_DISP0_DISP_BLS));
      
    DISP_REG_SET(DISP_REG_BLS_SRC_SIZE, (srcHeight << 16) | srcWidth);
    DISP_REG_SET(DISP_REG_BLS_PWM_CON, 0x0 | (gPWMDiv << 16));
    DISP_REG_SET(DISP_REG_BLS_BLS_SETTING, 0x0);
    DISP_REG_SET(DISP_REG_BLS_INTEN, 0xF);
    if (!(DISP_REG_GET(DISP_REG_BLS_EN) & 0x10000))
        DISP_REG_SET(DISP_REG_BLS_PWM_DUTY, 0);

    disp_bls_update_gamma_lut();
    //disp_bls_update_pwm_lut();

    disp_bls_config_full(srcWidth, srcHeight);

    if (dbg_log) 
        disp_dump_reg(DISP_MODULE_BLS);
}
示例#6
0
文件: ddp_pwm.c 项目: SelfImp/m75
static int disp_pwm_config_init(DISP_MODULE_ENUM module, disp_ddp_path_config* pConfig, void* cmdq)
{
    struct cust_mt65xx_led *cust_led_list;
    struct cust_mt65xx_led *cust;
    struct PWM_config *config_data;
    unsigned int pwm_div;
    disp_pwm_id_t id = (module == DISP_MODULE_PWM0 ? DISP_PWM0 : DISP_PWM1);
    unsigned int reg_base = pwm_get_reg_base(id);
    int index = index_of_pwm(id);

    pwm_div = PWM_DEFAULT_DIV_VALUE;
    cust_led_list = get_cust_led_list();
    if (cust_led_list)
    {
        /* WARNING: may overflow if MT65XX_LED_TYPE_LCD not configured properly */
        cust = &cust_led_list[MT65XX_LED_TYPE_LCD];
        if ((strcmp(cust->name,"lcd-backlight") == 0) && (cust->mode == MT65XX_LED_MODE_CUST_BLS_PWM))
        {
            config_data = &cust->config_data;
            if (config_data->clock_source >= 0 && config_data->clock_source <= 3)
            {
                unsigned int regVal = DISP_REG_GET(CLK_CFG_1);
                clkmux_sel(MT_MUX_PWM, config_data->clock_source, "DISP_PWM");
                PWM_MSG("disp_pwm_init : CLK_CFG_1 0x%x => 0x%x", regVal, DISP_REG_GET(CLK_CFG_1));
            }
            /* Some backlight chip/PMIC(e.g. MT6332) only accept slower clock */
            pwm_div = (config_data->div == 0) ? PWM_DEFAULT_DIV_VALUE : config_data->div;
            pwm_div &= 0x3FF;
            PWM_MSG("disp_pwm_init : PWM config data (%d,%d)", config_data->clock_source, config_data->div);
        }
    }

    atomic_set(&g_pwm_backlight[index], -1);

    /* We don't enable PWM until we really need */
    DISP_REG_MASK(cmdq, reg_base + DISP_PWM_CON_0_OFF, pwm_div << 16, (0x3ff << 16));

    DISP_REG_MASK(cmdq, reg_base + DISP_PWM_CON_1_OFF, 1023, 0x3ff); /* 1024 levels */
    /* We don't init the backlight here until AAL/Android give */

    return 0;
}
示例#7
0
//this API add for control the power and temperature
//if enabe=1, the value of brightness will smaller  than max_level, whatever lightservice transfers to driver
int setMaxbrightness(int max_level, int enable)
{

	struct cust_mt65xx_led *cust_led_list = get_cust_led_list();
	mutex_lock(&bl_level_limit_mutex);
	if (1 == enable)
	{
		limit_flag = 1;
		limit = max_level;
		mutex_unlock(&bl_level_limit_mutex);
		LEDS_DEBUG("[LED] setMaxbrightness limit happen and release lock!!\n");
		printk("setMaxbrightness enable:last_level=%d\n", last_level);
		printk("setMaxbrightness enable:current_level=%d\n", current_level);
		//if (limit < last_level){
		if (0 != current_level){
		printk("mt65xx_leds_set_cust in setMaxbrightness:value control start! limit=%d\n", limit);
		mt65xx_led_set_cust(&cust_led_list[MT65XX_LED_TYPE_LCD], limit);
		}
	}
	else
	{
		limit_flag = 0;
		limit = 255;
		mutex_unlock(&bl_level_limit_mutex);
		LEDS_DEBUG("[LED] setMaxbrightness limit closed and and release lock!!\n");
		printk("setMaxbrightness disable:last_level=%d\n", last_level);
		printk("setMaxbrightness enable:current_level=%d\n", current_level);
		//if (last_level != 0){
		if (0 != current_level){
		printk("control temperature close:limit=%d\n", limit);
		mt65xx_led_set_cust(&cust_led_list[MT65XX_LED_TYPE_LCD], last_level);
		
		//printk("mt65xx_leds_set_cust in setMaxbrightness:value control close!\n");
		}
	}
 	
	LEDS_DEBUG("[LED] setMaxbrightness limit_flag = %d, limit=%d, current_level=%d\n",limit_flag, limit, current_level);
	
	return 0;
	
}
示例#8
0
int mt65xx_leds_brightness_set(enum mt65xx_led_type type, enum led_brightness level)
{
	struct cust_mt65xx_led *cust_led_list = get_cust_led_list();

	if (type < 0 || type >= MT65XX_LED_TYPE_TOTAL)
		return -1;

	if (level > LED_FULL)
		level = LED_FULL;
	else if (level < 0)
		level = 0;

	if (g_lastlevel[type] != level) {
		g_lastlevel[type] = level;
		printf("[LEDS]uboot: %s level is %d \n\r", cust_led_list[type].name, level);
		return mt65xx_led_set_cust(&cust_led_list[type], level);
	}
	else {
		return -1;
	}

}
示例#9
0
struct cust_mt65xx_led * mt_get_cust_led_list(void)
{
	return get_cust_led_list();
}
示例#10
0
int disp_bls_config(void)
{
#if !defined(CONFIG_MTK_AAL_SUPPORT)
    struct cust_mt65xx_led *cust_led_list = get_cust_led_list();
    struct cust_mt65xx_led *cust = NULL;
    struct PWM_config *config_data = NULL;

    if(cust_led_list)
    {
        cust = &cust_led_list[MT65XX_LED_TYPE_LCD];
        if((strcmp(cust->name,"lcd-backlight") == 0) && (cust->mode == MT65XX_LED_MODE_CUST_BLS_PWM))
        {
            config_data = &cust->config_data;
            if (config_data->clock_source >= 0 && config_data->clock_source <= 3)
            { 
                unsigned int regVal = DISP_REG_GET(CLK_CFG_1);
                clkmux_sel(MT_MUX_PWM, config_data->clock_source, "DISP_PWM");
                BLS_DBG("disp_bls_init : CLK_CFG_1 0x%x => 0x%x\n", regVal, DISP_REG_GET(CLK_CFG_1));
            }
            gPWMDiv = (config_data->div == 0) ? PWM_DEFAULT_DIV_VALUE : config_data->div;
            gPWMDiv &= 0x3FF;
            BLS_MSG("disp_bls_config : PWM config data (%d,%d)\n", config_data->clock_source, config_data->div);
        }
    }
    
    if (!clock_is_on(MT_CG_DISP0_MDP_BLS_26M) || !gBLSPowerOn)
    {
        BLS_MSG("disp_bls_config: enable clock\n");
        enable_clock(MT_CG_DISP0_SMI_LARB0, "DDP");
        enable_clock(MT_CG_DISP0_MDP_BLS_26M         , "DDP");
        gBLSPowerOn = 1;
    }

    BLS_MSG("disp_bls_config : BLS_EN=0x%x, PWM_DUTY=%d, PWM_DUTY_RD=%d, CG=0x%x, %d, %d\n", 
        DISP_REG_GET(DISP_REG_BLS_EN),
        DISP_REG_GET(DISP_REG_BLS_PWM_DUTY),
        DISP_REG_GET(DISP_REG_BLS_PWM_DUTY_RD),
        DISP_REG_GET(DISP_REG_CONFIG_MMSYS_CG_CON0),
        clock_is_on(MT_CG_DISP0_MDP_BLS_26M),
        clock_is_on(MT_CG_DISP0_DISP_BLS));

#ifdef USE_DISP_BLS_MUTEX 
    BLS_MSG("disp_bls_config : gBLSMutexID = %d\n", gBLSMutexID);

    DISP_REG_SET(DISP_REG_CONFIG_MUTEX_RST(gBLSMutexID), 1);
    DISP_REG_SET(DISP_REG_CONFIG_MUTEX_RST(gBLSMutexID), 0);
    DISP_REG_SET(DISP_REG_CONFIG_MUTEX_MOD(gBLSMutexID), 0x200);    // BLS
    DISP_REG_SET(DISP_REG_CONFIG_MUTEX_SOF(gBLSMutexID), 0);        // single mode
    DISP_REG_SET(DISP_REG_CONFIG_MUTEX_EN(gBLSMutexID), 1);

    if (disp_bls_get_mutex() == 0)
    {
    
#else
    BLS_MSG("disp_bls_config\n");
    DISP_REG_SET(DISP_REG_BLS_DEBUG, 0x3);
#endif

        if (!(DISP_REG_GET(DISP_REG_BLS_EN) & 0x10000))
            DISP_REG_SET(DISP_REG_BLS_PWM_DUTY, 0);
        DISP_REG_SET(DISP_REG_BLS_PWM_CON, 0x0 | (gPWMDiv << 16));
        //DISP_REG_SET(DISP_REG_BLS_EN, 0x00010001); //Enable BLS_EN

#ifdef USE_DISP_BLS_MUTEX 

        if (disp_bls_release_mutex() == 0)
            return 0;
    }
    return -1;
#else
    DISP_REG_SET(DISP_REG_BLS_DEBUG, 0x0);
#endif

#endif
    BLS_MSG("disp_bls_config:-\n");
    return 0;
}
int  mt65xx_blink_set(enum mt65xx_led_type type, unsigned long  delay_on, unsigned long  delay_off)
{
	//struct mt65xx_led_data *led_data = led_data_back;
	static int got_wake_lock = 0;
	struct nled_setting nled_tmp_setting = {0,0,0};

	struct cust_mt65xx_led *cust_led_list = get_cust_led_list();
	
	blink_led_data->cust = cust_led_list[type];
	
	// only allow software blink when delay_on or delay_off changed
	if (delay_on != blink_led_data->delay_on || delay_off != blink_led_data->delay_off ||type != blink_led_data->type ) 
	{
		blink_led_data->delay_on = delay_on;
		blink_led_data->delay_off = delay_off;
		blink_led_data->type = type;

		
		if (blink_led_data->delay_on && blink_led_data->delay_off)
		{ // enable blink
		        
			blink_led_data->level = 255; // when enable blink  then to set the level  (255)
			
			if(blink_led_data->cust.mode == MT65XX_LED_MODE_PWM && 
			     (blink_led_data->cust.data != PWM3 && blink_led_data->cust.data != PWM4 && blink_led_data->cust.data != PWM5))
			{
				nled_tmp_setting.nled_mode = NLED_BLINK;
				nled_tmp_setting.blink_off_time = blink_led_data->delay_off;
				nled_tmp_setting.blink_on_time = blink_led_data->delay_on;
				led_blink_pmic(blink_led_data->cust.data, &nled_tmp_setting);
				return 0;
			}
			
			//#if defined (CONFIG_ARCH_MT6575) || defined (CONFIG_ARCH_MT6575T)|| defined (CONFIG_ARCH_MT6577)
			else if((blink_led_data->cust.mode == MT65XX_LED_MODE_PMIC) && (blink_led_data->cust.data == MT65XX_LED_PMIC_NLED_ISINK4
				|| blink_led_data->cust.data == MT65XX_LED_PMIC_NLED_ISINK5 || blink_led_data->cust.data == MT65XX_LED_PMIC_NLED_ISINK0))
			{
				if(get_chip_eco_ver() == CHIP_E2) 
				{
					nled_tmp_setting.nled_mode = NLED_BLINK;
					nled_tmp_setting.blink_off_time = blink_led_data->delay_off;
					nled_tmp_setting.blink_on_time = blink_led_data->delay_on;
					led_blink_pmic(blink_led_data->cust.data, &nled_tmp_setting);
					return 0;
				} 
				else 
				{
				//	wake_lock(&leds_suspend_lock);
				}
			}
			//#endif		
			
			else if (!got_wake_lock) 
			{
			//	wake_lock(&leds_suspend_lock);
				got_wake_lock = 1;
			}
		}
		else if (!blink_led_data->delay_on && !blink_led_data->delay_off)
		{ // disable blink
			if(blink_led_data->cust.mode == MT65XX_LED_MODE_PWM && 
			(blink_led_data->cust.data != PWM3 && blink_led_data->cust.data != PWM4 && blink_led_data->cust.data != PWM5))
			{
				brightness_set_pmic(blink_led_data->cust.data, 0);
				return 0;
			}
			
			//#if defined (CONFIG_ARCH_MT6575) || defined (CONFIG_ARCH_MT6575T)|| defined (CONFIG_ARCH_MT6577)
			else if((blink_led_data->cust.mode == MT65XX_LED_MODE_PMIC) && (blink_led_data->cust.data == MT65XX_LED_PMIC_NLED_ISINK4
				|| blink_led_data->cust.data == MT65XX_LED_PMIC_NLED_ISINK5 || blink_led_data->cust.data == MT65XX_LED_PMIC_NLED_ISINK0))
			{
				if(get_chip_eco_ver() == CHIP_E2) 
				{
					brightness_set_pmic(blink_led_data->cust.data, 0);
					return 0;
				} 
				else 
				{
				//	wake_unlock(&leds_suspend_lock);
				}
			}
			//#endif	
			
			else if (got_wake_lock) 
			{
			//	wake_unlock(&leds_suspend_lock);
				got_wake_lock = 0;
			}
		}
		return -1;
	}

	// delay_on and delay_off are not changed
	return 0;
}