void generate_gamma(struct SMART_DIM *pSmart, char *str, int size)
{
	long long candela_level[S6E63M0_TABLE_MAX] = {-1, -1, -1, -1, -1, -1};
	int bl_index[S6E63M0_TABLE_MAX] = {-1 , -1, -1, -1, -1, -1};

	unsigned long long temp_cal_data = 0;
	int bl_level, cnt;
	int level_255_temp = 0;
	int level_255_temp_MSB = 0;

	bl_level = pSmart->brightness_level;

	/*calculate candela level */
	for (cnt = 0; cnt < S6E63M0_TABLE_MAX; cnt++) {
		temp_cal_data =
			((long long)(s6e63m0_candela_coeff[S6E63M0_ARRAY[cnt+1]])) *
			((long long)(bl_level));
		candela_level[cnt] = temp_cal_data;
	}

	#ifdef SMART_DIMMING_DEBUG
	printk("%s candela_1:%llu candela_19:%llu  candela_43:%llu  "
		"candela_87:%llu  candela_171:%llu  candela_255:%llu \n", __func__,
		candela_level[0], candela_level[1], candela_level[2],
		candela_level[3], candela_level[4], candela_level[5]);
	#endif

	/*calculate brightness level*/
	for (cnt = 0; cnt < S6E63M0_TABLE_MAX; cnt++) {
		if (searching_function(candela_level[cnt], &(bl_index[cnt]))) {
			printk("%s searching functioin error cnt:%d\n", __func__, cnt);
		}
	}

	#ifdef SMART_DIMMING_DEBUG
	printk("%s bl_index_1:%d bl_index_19:%d bl_index_43:%d "
		"bl_index_87:%d bl_index_171:%d bl_index_255:%d\n", __func__,
		bl_index[0], bl_index[1], bl_index[2], bl_index[3], bl_index[4], bl_index[5]);
	#endif

	/*Generate Gamma table*/
	for (cnt = 0; cnt < S6E63M0_TABLE_MAX; cnt++) {
		(void)Make_hexa[cnt](bl_index , pSmart, str);
	}

	/*subtration MTP_OFFSET value from generated gamma table*/
	str[3] -= pSmart->MTP.R_OFFSET.OFFSET_19;
	str[4] -= pSmart->MTP.G_OFFSET.OFFSET_19;
	str[5] -= pSmart->MTP.B_OFFSET.OFFSET_19;

	str[6] -= pSmart->MTP.R_OFFSET.OFFSET_43;
	str[7] -= pSmart->MTP.G_OFFSET.OFFSET_43;
	str[8] -= pSmart->MTP.B_OFFSET.OFFSET_43;

	str[9] -= pSmart->MTP.R_OFFSET.OFFSET_87;
	str[10] -= pSmart->MTP.G_OFFSET.OFFSET_87;
	str[11] -= pSmart->MTP.B_OFFSET.OFFSET_87;

	str[12] -= pSmart->MTP.R_OFFSET.OFFSET_171;
	str[13] -= pSmart->MTP.G_OFFSET.OFFSET_171;
	str[14] -= pSmart->MTP.B_OFFSET.OFFSET_171;

	level_255_temp = (str[15] << 8) | str[16] ;
	level_255_temp -=  pSmart->MTP.R_OFFSET.OFFSET_255_LSB;
	level_255_temp_MSB = level_255_temp / 256;
	str[15] = level_255_temp_MSB & 0xff;
	str[16] = level_255_temp & 0xff;

	level_255_temp = (str[17] << 8) | str[18] ;
	level_255_temp -=  pSmart->MTP.G_OFFSET.OFFSET_255_LSB;
	level_255_temp_MSB = level_255_temp / 256;
	str[17] = level_255_temp_MSB & 0xff;
	str[18] = level_255_temp & 0xff;

	level_255_temp = (str[19] << 8) | str[20] ;
	level_255_temp -=  pSmart->MTP.B_OFFSET.OFFSET_255_LSB;
	level_255_temp_MSB = level_255_temp / 256;
	str[19] = level_255_temp_MSB & 0xff;
	str[20] = level_255_temp & 0xff;
}
Exemple #2
0
void generate_gamma(struct SMART_DIM *pSmart, char *str, int size)
{
    long long candela_level[EA8868_TABLE_MAX] = {-1, };
    int bl_index[EA8868_TABLE_MAX] = {-1, };

    unsigned long long temp_cal_data = 0;
    int bl_level, cnt;

    bl_level = pSmart->brightness_level;

    printk("generate_gamma bl_level = %d\n",bl_level);

    /*calculate candela level */
    for (cnt = 0; cnt < EA8868_TABLE_MAX; cnt++) {
        temp_cal_data =
            ((long long)(candela_coeff_2p2[EA8868_ARRAY[cnt+1]])) *
            ((long long)(bl_level));
        candela_level[cnt] = temp_cal_data;
    }

#ifdef SMART_DIMMING_DEBUG
    printk("%s candela_1:%llu candela_15:%llu  candela_35:%llu  "
           "candela_59:%llu  candela_171:%llu  candela_87:%llu "
           "candela_255:%llu\n", __func__, candela_level[0],
           candela_level[1], candela_level[2], candela_level[3],
           candela_level[4], candela_level[5], candela_level[6]);
#endif

    /*calculate brightness level*/
    for (cnt = 0; cnt < EA8868_TABLE_MAX; cnt++) {
        if (searching_function(candela_level[cnt], &(bl_index[cnt]))) {
            printk("%s searching functioin error cnt:%d\n",
                   __func__, cnt);
        }
    }

#ifdef SMART_DIMMING_DEBUG
    printk("%s bl_index_1:%d bl_index_15:%d bl_index_35:%d bl_index_59:%d "
           "bl_index_87:%d bl_index_171:%d bl_index_255:%d\n", __func__,
           bl_index[0], bl_index[1], bl_index[2], bl_index[3],
           bl_index[4], bl_index[5], bl_index[6]);
#endif

    /*Generate Gamma table*/
    for (cnt = 0; cnt < EA8868_TABLE_MAX; cnt++) {
        (void)Make_hexa[cnt](bl_index , pSmart, str);
    }

    /*subtration MTP_OFFSET value from generated gamma table*/
    str[1] -= pSmart->MTP.R_OFFSET.OFFSET_255_LSB;
    str[2] -= pSmart->MTP.R_OFFSET.OFFSET_171;
    str[3] -= pSmart->MTP.R_OFFSET.OFFSET_87;
    str[4] -= pSmart->MTP.R_OFFSET.OFFSET_59;
    str[5] -= pSmart->MTP.R_OFFSET.OFFSET_35;
    str[6] -= pSmart->MTP.R_OFFSET.OFFSET_15;

    str[9] -= pSmart->MTP.G_OFFSET.OFFSET_255_LSB;
    str[10] -= pSmart->MTP.G_OFFSET.OFFSET_171;
    str[11] -= pSmart->MTP.G_OFFSET.OFFSET_87;
    str[12] -= pSmart->MTP.G_OFFSET.OFFSET_59;
    str[13] -= pSmart->MTP.G_OFFSET.OFFSET_35;
    str[14] -= pSmart->MTP.G_OFFSET.OFFSET_15;

    str[17] -= pSmart->MTP.B_OFFSET.OFFSET_255_LSB;
    str[18] -= pSmart->MTP.B_OFFSET.OFFSET_171;
    str[19] -= pSmart->MTP.B_OFFSET.OFFSET_87;
    str[20] -= pSmart->MTP.B_OFFSET.OFFSET_59;
    str[21] -= pSmart->MTP.B_OFFSET.OFFSET_35;
    str[22] -= pSmart->MTP.B_OFFSET.OFFSET_15;

}