예제 #1
0
LCM_DRIVER *disp_drv_get_lcm_driver(const char* lcm_name)
{
	LCM_DRIVER *lcm = NULL;
	printf("[LCM Auto Detect], we have %d lcm drivers built in\n", lcm_count);

	if(lcm_count ==1)
	{
		// we need to verify whether the lcm is connected
		// even there is only one lcm type defined
		lcm = lcm_driver_list[0];
		lcm->set_util_funcs(&lcm_utils);
		lcm->get_params(&s_lcm_params);

		lcm_params = &s_lcm_params;
		lcm_drv = lcm;
		isLCMFound = TRUE;
        
        printf("[LCM Specified]\t[%s]\n", (lcm->name==NULL)?"unknown":lcm->name);

		goto done;
	}
	else
	{
		int i;

		for(i = 0;i < lcm_count;i++)
		{
			lcm_params = &s_lcm_params;
			lcm = lcm_driver_list[i];

			printf("[LCM Auto Detect] [%d] - [%s]\t", 
				i, 
				(lcm->name==NULL)?"unknown":lcm->name);

			lcm->set_util_funcs(&lcm_utils);
			memset((void*)lcm_params, 0, sizeof(LCM_PARAMS));
			lcm->get_params(lcm_params);

			disp_drv_init_ctrl_if();
			disp_drv_set_driving_current(lcm_params);
			disp_drv_init_io_pad(lcm_params);

			if(lcm_name != NULL)
			{
				if(!strcmp(lcm_name,lcm->name))
				{
					printf("\t\t[success]\n");
					isLCMFound = TRUE;
					lcm_drv = lcm;

					goto done;
				}
				else
				{
					printf("\t\t[fail]\n");
				}
			}
			else 
			{
				if(LCM_TYPE_DSI == lcm_params->type){
					init_dsi();
				}
				if(lcm->compare_id != NULL && lcm->compare_id())
				{
					printf("\t\t[success]\n");
					isLCMFound = TRUE;
					lcm_drv = lcm;

					goto done;
				}
				else
				{
					printf("\t\t[fail]\n");
					if(LCM_TYPE_DSI == lcm_params->type)
						DSI_Deinit();
				}
			}
		}
	}

done:
	return lcm;
}
const LCM_DRIVER *disphal_get_lcm_driver(const char *lcm_name, unsigned int *lcm_index)
{
    LCM_DRIVER *lcm = NULL;
    bool isLCMFound = false;
    printk("[LCM Auto Detect], we have %d lcm drivers built in\n", lcm_count);
    printk("[LCM Auto Detect], try to find driver for [%s]\n", 
        (lcm_name==NULL)?"unknown":lcm_name);

    if(lcm_count == 1)
    {
        // we need to verify whether the lcm is connected
        // even there is only one lcm type defined
        lcm = lcm_driver_list[0];
        lcm->set_util_funcs(&lcm_utils);
        *lcm_index = 0;
        printk("[LCM Specified]\t[%s]\n", (lcm->name==NULL)?"unknown":lcm->name);
        isLCMFound = true;
        goto done;
    }
    else
    {
        int i;
        for(i = 0;i < lcm_count;i++)
        {
            lcm = lcm_driver_list[i];
            printk("[LCM Auto Detect] [%d] - [%s]\t", i, (lcm->name==NULL)?"unknown":lcm->name);
            lcm->set_util_funcs(&lcm_utils);
            memset((void*)&s_lcm_params, 0, sizeof(LCM_PARAMS));
            lcm->get_params(&s_lcm_params);

            disphal_init_ctrl_if();
            LCD_Set_DrivingCurrent(&s_lcm_params);
            LCD_Init_IO_pad(&s_lcm_params);

            if(lcm_name != NULL)
            {
                if(!strcmp(lcm_name,lcm->name))
                {
                    printk("\t\t[success]\n");
                    *lcm_index = i;
                    isLCMFound = true;
                    goto done;
                }
                else
                {
                    printk("\t\t[fail]\n");
                }
            }
            else 
            {
                if(LCM_TYPE_DSI == lcm_params->type)
                {
                    init_dsi(FALSE);
                }

                if(lcm->compare_id != NULL && lcm->compare_id())
                {
                    printk("\t\t[success]\n");
                    isLCMFound = true;
                    *lcm_index = i;
                    goto done;
                }
                else
                {
                    if(LCM_TYPE_DSI == lcm_params->type)
                        DSI_Deinit();
                    printk("\t\t[fail]\n");
                }
            }
        }
    }
done:
    if (isLCMFound)
    {
        memset((void*)&s_lcm_params, 0, sizeof(LCM_PARAMS));
        lcm->get_params(&s_lcm_params);
        return lcm;
    }
    else
        return NULL;
}
예제 #3
0
BOOL DISP_SelectDeviceBoot(const char* lcm_name)
{
	LCM_DRIVER *lcm = NULL;
	int i;

	printk("%s\n", __func__);
	if(lcm_name == NULL)
	{
		// we can't do anything in boot stage if lcm_name is NULL
		return false;
	}
	for(i = 0;i < lcm_count;i++)
	{
		lcm_params = &s_lcm_params;
		lcm = lcm_driver_list[i];

		printk("[LCM Auto Detect] [%d] - [%s]\t", 
			i, 
			(lcm->name==NULL)?"unknown":lcm->name);

		lcm->set_util_funcs(&lcm_utils);
		memset((void*)lcm_params, 0, sizeof(LCM_PARAMS));
		lcm->get_params(lcm_params);

		// if lcm type is speficied, we don't need to compare the lcm name
		// in case the uboot is old version, which don't have lcm name in command line
		if(lcm_count == 1)
		{
			lcm_drv = lcm;
			isLCMFound = TRUE;
			break;
		}

		if(!strcmp(lcm_name,lcm->name))
		{
			printk("\t\t[success]\n");
			lcm_drv = lcm;
			isLCMFound = TRUE;

			break;
		}
		else
		{
			printk("\t\t[fail]\n");
		}
	}

	if (NULL == lcm_drv)
	{
		printk("%s, disp_drv_get_lcm_driver() returns NULL\n", __func__);
		return FALSE;
	}

	switch(lcm_params->type)
	{
		case LCM_TYPE_DBI : disp_drv = DISP_GetDriverDBI(); break;
		case LCM_TYPE_DPI : disp_drv = DISP_GetDriverDPI(); break;
		case LCM_TYPE_DSI : disp_drv = DISP_GetDriverDSI(); break;
		default : ASSERT(0);
	}

	disp_dump_lcm_parameters(lcm_params);
	return TRUE;
}
static long fbconfig_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
	int ret = 0;
	void __user *argp = (void __user *)arg;
	DISP_DRV_WRAN("sxk=>run in fbconfig_ioctl**\n");

	switch (cmd) {
	case LCM_GET_ID:
		{
			/* get_lcm_id() need implemented in lcm driver ... */
#if 0
			LCM_DRIVER *lcm = lcm_drv;
			unsigned int lcm_id = lcm->get_lcm_id();
#else
			unsigned int lcm_id = 0;
#endif
			return copy_to_user(argp, &lcm_id, sizeof(lcm_id)) ? -EFAULT : 0;
		}
	case LCM_GET_DSI_CONTINU:
		{
			int ret;
			if (fbconfig_if_drv->set_spread_frequency)
				ret = fbconfig_if_drv->set_spread_frequency(10);
			DISP_DRV_WRAN("fbconfig=>LCM_GET_DSI_CONTINU:%d\n", ret);
			return copy_to_user(argp, &ret, sizeof(ret)) ? -EFAULT : 0;
		}
	case LCM_TEST_DSI_CLK:
		{
			LCM_TYPE_FB lcm_fb;
			lcm_fb.clock = lcm_params->dsi.PLL_CLOCK;
			lcm_fb.lcm_type = lcm_params->dsi.mode;
			DISP_DRV_WRAN("fbconfig=>LCM_TEST_DSI_CLK:%d\n", ret);
			return copy_to_user(argp, &lcm_fb, sizeof(lcm_fb)) ? -EFAULT : 0;
		}
	case LCM_GET_DSI_CLK:
		{
			int ret;
			if (fbconfig_if_drv->set_spread_frequency)
				ret = fbconfig_if_drv->set_spread_frequency(11);
			DISP_DRV_WRAN("fbconfig=>LCM_GET_DSI_CLK:%d\n", ret);
			return copy_to_user(argp, &ret, sizeof(ret)) ? -EFAULT : 0;
		}
	case LCM_GET_DSI_CLK_V2:
		{
			unsigned int ret = 0;
			MIPI_CLK_V2 clock_v2;
			if (fbconfig_if_drv->set_spread_frequency)
				ret = fbconfig_if_drv->set_spread_frequency(11);
			clock_v2.div1 = ret & 0x00000600;
			clock_v2.div2 = ret & 0x00000180;
			clock_v2.fbk_div = ret & 0x0000007F;
			return copy_to_user(argp, &clock_v2, sizeof(clock_v2)) ? -EFAULT : 0;
		}
	case LCM_GET_DSI_SSC:
		{
			int ret;
			if (fbconfig_if_drv->set_spread_frequency)
				ret = fbconfig_if_drv->set_spread_frequency(9);
			DISP_DRV_WRAN("fbconfig=>LCM_GET_DSI_SSC:%d\n", ret);
			return copy_to_user(argp, &ret, sizeof(ret)) ? -EFAULT : 0;
		}
	case LCM_GET_DSI_LANE_NUM:
		{
			int ret;
			if (fbconfig_if_drv->set_spread_frequency)
				ret = fbconfig_if_drv->set_spread_frequency(12);
			DISP_DRV_WRAN("fbconfig=>LCM_GET_DSI_LANE_NUM:%d\n", ret);
			return copy_to_user(argp, &ret, sizeof(ret)) ? -EFAULT : 0;
		}
	case LCM_GET_DSI_TE:
		{
			int ret;
			if (fbconfig_if_drv->set_spread_frequency)
				ret = fbconfig_if_drv->set_spread_frequency(13);
			DISP_DRV_WRAN("fbconfig=>LCM_GET_DSI_TE:%d\n", ret);
			return copy_to_user(argp, &ret, sizeof(ret)) ? -EFAULT : 0;
		}
	case LCM_GET_DSI_TIMING:
		{
			int ret = 0;
			MIPI_TIMING timing;
			if (copy_from_user(&timing, (void __user *)argp, sizeof(timing))) {
				DISP_DRV_WRAN("[MIPI_SET_TIMING]: copy_from_user failed! line:%d\n", __LINE__);
				return -EFAULT;
			}
			if (fbconfig_if_drv->set_spread_frequency)
				ret = fbconfig_if_drv->set_spread_frequency(100 + timing.type);
			DISP_DRV_WRAN("fbconfig=>LCM_GET_DSI_TIMING:%d\n", ret);
			timing.value = ret;
			return copy_to_user(argp, &timing, sizeof(timing)) ? -EFAULT : 0;
		}
	case DRIVER_IC_CONFIG:
		{
			DISP_DRV_WRAN("sxk=>run in case:DRIVER_IC_CONFIG**\n");
			if (record_list_initialed == 0) {
				record_list_init();
				if (copy_from_user(record_head, (void __user *)arg, sizeof(CONFIG_RECORD))) {
					DISP_DRV_WRAN("sxk=>copy_from_user failed! line:%d\n", __LINE__);
					return -EFAULT;
				}
#if 0
				print_record(record_head);
#endif
				record_list_initialed = 1;
			} else {
				if (copy_from_user(record_tmp, (void __user *)arg, sizeof(CONFIG_RECORD))) {
					DISP_DRV_WRAN("[DRIVER_IC_CONFIG]: copy_from_user failed! line:%d\n", __LINE__);
					return -EFAULT;
				}
#if 0				/* FBCONFIG_DEBUG */
				DISP_DRV_WRAN("sxk=>will print before add to list\n");
				print_record(record_tmp);
#endif
				record_list_add();	/* add new node to list ; */

			}

			return 0;
		}
	case MIPI_SET_CLK:
		{
			unsigned int clk;
			if (copy_from_user(&clk, (void __user *)argp, sizeof(clk))) {
				DISP_DRV_WRAN("[MIPI_SET_CLK]: copy_from_user failed! line:%d\n", __LINE__);
				return -EFAULT;
			} else {
				fbconfig_disp_set_mipi_clk(clk);
			}
			return 0;
		}
	case MIPI_SET_CLK_V2:
		{
			MIPI_CLK_V2 clk;
			if (copy_from_user(&clk, (void __user *)argp, sizeof(clk))) {
				DISP_DRV_WRAN("[MIPI_SET_CLK]: copy_from_user failed! line:%d\n", __LINE__);
				return -EFAULT;
			} else {
				unsigned int clk_v2 = 0;
				/* div1_2bits  div2_2bits  fbk_div_7bits */
				clk_v2 = (clk.div1 << 9) | (clk.div2 << 7) | clk.fbk_div;
				fbconfig_disp_set_mipi_clk(clk_v2);
			}
			return 0;
		}
	case MIPI_SET_SSC:
		{
			unsigned int ssc;
			DISP_DRV_WRAN("sxk=>debug.c call set mipi ssc line:%d\n", __LINE__);
			if (copy_from_user(&ssc, (void __user *)argp, sizeof(ssc))) {
				DISP_DRV_WRAN("[MIPI_SET_SSC]: copy_from_user failed! line:%d\n", __LINE__);
				return -EFAULT;
			} else {
				DISP_DRV_WRAN("sxk=>debug.c call set mipi ssc line:%d\n", __LINE__);
				fbconfig_disp_set_mipi_ssc(ssc);
			}
			return 0;
		}
	case MIPI_SET_LANE:
		{
			unsigned int lane_num;
			if (copy_from_user(&lane_num, (void __user *)argp, sizeof(lane_num))) {
				DISP_DRV_WRAN("[MIPI_SET_LANE]: copy_from_user failed! line:%d\n", __LINE__);
				return -EFAULT;
			} else {
				fbconfig_disp_set_mipi_lane_num(lane_num);
			}
			return 0;
		}
	case MIPI_SET_TIMING:
		{
			if (!is_early_suspended) {
				MIPI_TIMING timing;
				if (copy_from_user(&timing, (void __user *)argp, sizeof(timing))) {
					DISP_DRV_WRAN("[MIPI_SET_TIMING]: copy_from_user failed! line:%d\n", __LINE__);
					return -EFAULT;
				} else {
					fbconfig_disp_set_mipi_timing(timing);
				}
				return 0;
			} else
				return -EFAULT;
		}
	case TE_SET_ENABLE:
		{
			char enable;
			if (copy_from_user(&enable, (void __user *)argp, sizeof(enable))) {
				DISP_DRV_WRAN("[TE_SET_ENABLE]: copy_from_user failed! line:%d\n", __LINE__);
				return -EFAULT;
			} else {
				if (fbconfig_if_drv->set_te_enable)
					fbconfig_if_drv->set_te_enable(enable);
			}
			return 0;
		}
	case FB_LAYER_GET_EN:
		{
			FBCONFIG_LAYER_INFO layers;
			fbconfig_get_layer_info(&layers);
			return copy_to_user(argp, &layers, sizeof(layers)) ? -EFAULT : 0;
		}
	case FB_LAYER_GET_SIZE:
		{
			LAYER_H_SIZE tmp;
			int layer_size, enable, height, fmt;
			if (copy_from_user(&tmp, (void __user *)argp, sizeof(LAYER_H_SIZE))) {
				DISP_DRV_WRAN("[TE_SET_ENABLE]: copy_from_user failed! line:%d\n", __LINE__);
				return -EFAULT;
			}
			global_layer_id = tmp.height;
			DISP_DRV_WRAN("sxk==>global_layer_id is %d\n", global_layer_id);
			fbconfig_get_layer_height(global_layer_id, &layer_size, &enable, &height, &fmt);
			if ((layer_size == 0) || (enable == 0) || (height == 0))
				return -2;
			else {
				tmp.height = height;
				tmp.layer_size = layer_size;
				tmp.fmt = DP_COLOR_BITS_PER_PIXEL(fmt);
				return copy_to_user(argp, &tmp, sizeof(tmp)) ? -EFAULT : 0;
			}
		}
	case FB_LAYER_DUMP:
		{
			int layer_size, enable;
			int ret = 0;
			unsigned int kva = 0;
			unsigned int mapped_size = 0;
			unsigned int mva = fbconfig_get_layer_vaddr(global_layer_id, &layer_size, &enable);
			if ((layer_size != 0) && (enable != 0)) {
				DISP_DRV_WRAN("sxk==>FB_LAYER_DUMP==>layer_size is %d   mva is 0x%x\n", layer_size,
					      mva);
				m4u_mva_map_kernel(mva, layer_size, 0, &kva, &mapped_size);
				DISP_DRV_WRAN("sxk==> addr from user space is 0x%x\n", (unsigned int)argp);
				DISP_DRV_WRAN("sxk==> kva is 0x%x   mmaped size is %d\n", kva, mapped_size);
				ret = copy_to_user(argp, (void *)kva, mapped_size) ? -EFAULT : 0;
				m4u_mva_unmap_kernel(mva, mapped_size, kva);
				return ret;
			} else
				return -2;
		}
	case MIPI_SET_CC:
		{
			int enable;
			if (copy_from_user(&enable, (void __user *)argp, sizeof(enable))) {
				DISP_DRV_WRAN("[MIPI_SET_CC]: copy_from_user failed! line:%d\n", __LINE__);
				return -EFAULT;
			} else {
				if (fbconfig_if_drv->set_continuous_clock)
					fbconfig_if_drv->set_continuous_clock(enable);
			}
			return 0;
		}
	case LCM_GET_ESD:
		{
			ESD_PARA esd_para;
			int i = 0;
			if (copy_from_user(&esd_para, (void __user *)arg, sizeof(esd_para))) {
				DISP_DRV_WRAN("[LCM_GET_ESD]: copy_from_user failed! line:%d\n", __LINE__);
				return -EFAULT;
			}
			esd_check_addr = esd_para.addr;
			esd_check_para_num = esd_para.para_num;
			ret = fbconfig_get_esd_check();
			if ((ret != 0) && (esd_check_buffer != NULL)) {
				kfree(esd_check_buffer);
				return -2;
			} else {
				for (i = 0; i < esd_check_para_num + 6; i++)
					DISP_DRV_WRAN("sxk=>%s, esd_check_buffer[%d]=0x%x\n", __func__, i,
						      esd_check_buffer[i]);
				return 0;
			}
		}
	case LCM_GET_ESD_RET:
		{
			ret =
			    (copy_to_user(argp, (void *)esd_check_buffer, sizeof(char) * (esd_check_para_num + 6)) ?
			     -EFAULT : 0);
			if (esd_check_buffer != NULL) {
				kfree(esd_check_buffer);
				esd_check_buffer = NULL;
			}
			return ret;
		}
	case DRIVER_IC_RESET:
		{
			fbconfig_reset_lcm_setting();
			fbconfig_free_backup_setting();
			return 0;
		}
	default:
		return ret;
	}
}
예제 #5
0
LCM_DRIVER *disp_drv_get_lcm_driver(const char *lcm_name)
{
	LCM_DRIVER *lcm = NULL;
	printk("[LCM Auto Detect], we have %d lcm drivers built in\n", lcm_count);
	printk("[LCM Auto Detect], try to find driver for [%s]\n", 
			(lcm_name==NULL)?"unknown":lcm_name);

	if(lcm_count ==1)
	{
		// we need to verify whether the lcm is connected
		// even there is only one lcm type defined
		lcm = lcm_driver_list[0];
		lcm->set_util_funcs(&lcm_utils);
		lcm->get_params(&s_lcm_params);

		lcm_params = &s_lcm_params;
		lcm_drv = lcm;
		disp_drv_init_ctrl_if();
		disp_drv_set_driving_current(lcm_params);
		disp_drv_init_io_pad(lcm_params);

		if(lcm_drv->compare_id)
		{
			if(LCM_TYPE_DSI == lcm_params->type){
				init_dsi(FALSE);
			}

			if(lcm_drv->compare_id() == TRUE)
			{
				printk("[LCM Specified] compare id success\n");
				isLCMFound = TRUE;
			}
			else
			{
				printk("[LCM Specified] compare id fail\n");
				printk("%s, lcm is not connected\n", __func__);

				if(LCM_TYPE_DSI == lcm_params->type)
					DSI_Deinit();
			}
		}
		else
		{
			printk("[LCM Specified] don't support read deivce id\n");
		}

        printk("[LCM Specified]\t[%s]\n", (lcm->name==NULL)?"unknown":lcm->name);

		goto done;
	}
	else
	{
		int i;

		for(i = 0;i < lcm_count;i++)
		{
			lcm_params = &s_lcm_params;
			lcm = lcm_driver_list[i];

			printk("[LCM Auto Detect] [%d] - [%s]\t", i, (lcm->name==NULL)?"unknown":lcm->name);

			lcm->set_util_funcs(&lcm_utils);
			memset((void*)lcm_params, 0, sizeof(LCM_PARAMS));
			lcm->get_params(lcm_params);

			disp_drv_init_ctrl_if();
			disp_drv_set_driving_current(lcm_params);
			disp_drv_init_io_pad(lcm_params);

			if(lcm_name != NULL)
			{
				if(!strcmp(lcm_name,lcm->name))
				{
					printk("\t\t[success]\n");
					isLCMFound = TRUE;
					lcm_drv = lcm;

					goto done;
				}
				else
				{
					printk("\t\t[fail]\n");
				}
			}
			else 
			{
				if(LCM_TYPE_DSI == lcm_params->type){
					init_dsi(FALSE);
				}

				if(lcm->compare_id != NULL && lcm->compare_id())
				{
					printk("\t\t[success]\n");
					isLCMFound = TRUE;
					lcm_drv = lcm;

					goto done;
				}
				else
				{
				
					if(LCM_TYPE_DSI == lcm_params->type)
						DSI_Deinit();
					printk("\t\t[fail]\n");
				}
			}
		}
#if 1//LK@6575,0319,use the first lcm in the lcm list as default if no lcm detected.
			lcm = lcm_driver_list[0];
#endif		
	}
done:
	return lcm_drv;
}