/*****************************************************************************
Driver interface   -------------------------hct_driver  erick
*****************************************************************************/
static ssize_t store_flashContrl_value(struct device_driver *ddri, char *buf, size_t count)
{
    int sensorDev = 1;
	int strobeId = 1;
	FLASHLIGHT_FUNCTION_STRUCT** ppF=0;

	ppF = &g_pFlashInitFunc[0][0][0];
	constantFlashlightInit(ppF);


	if((*ppF)!=0)
	{
		(*ppF)->flashlight_open(0);
		logI("setFlashDrv ok %d",__LINE__);

	    if(!strncmp(buf, "on", 2))
		{
			printk("Ja_yyy-----flashlight_ioctl: on \n");
			(*ppF)->flashlight_ioctl(FLASH_IOC_SET_TIME_OUT_TIME_MS,0);
			(*ppF)->flashlight_ioctl(FLASH_IOC_SET_DUTY,0);
			(*ppF)->flashlight_ioctl(FLASH_IOC_SET_ONOFF,1);
		}	
		else
		{
			printk("Ja_yyy-----flashlight_ioctl: offffff \n");
			(*ppF)->flashlight_ioctl(FLASH_IOC_SET_ONOFF,0);
		}
	}
	else
	{
		logE("set function pointer not found!!");
		return -1;
	}
	
	return count;	 
}
//========================================================================
static int setFlashDrv(int sensorDev, int strobeId)
{
	int partId;
	int sensorDevIndex;
    int strobeIndex;
	int partIndex;
	FLASHLIGHT_FUNCTION_STRUCT** ppF=0;
	sensorDevIndex = getSensorDevIndex(sensorDev);
	strobeIndex = getStrobeIndex(strobeId);
	if(sensorDevIndex<0 || strobeIndex<0 )
		return -1;
	partId = g_strobePartId[sensorDevIndex][strobeIndex];
	partIndex = getPartIndex(partId);
	if(partIndex<0)
		return -1;

	logI("setFlashDrv sensorDev=%d, strobeId=%d, partId=%d ~",sensorDev, strobeId, partId);

	ppF = &g_pFlashInitFunc[sensorDevIndex][strobeIndex][partIndex];
	if(sensorDev==e_CAMERA_MAIN_SENSOR)
	{
    	#if defined(DUMMY_FLASHLIGHT)
    	    strobeInit_dummy(ppF);
    	#else
        	if(strobeId==1)
        	{
                if(partId==1)
        			constantFlashlightInit(ppF);
        		else if(partId==2)
        			strobeInit_main_sid1_part2(ppF);
        	}
        	else if(strobeId==2)
        	{
        		if(partId==1)
        			strobeInit_main_sid2_part1(ppF);

        		else if(partId==2)
        			strobeInit_main_sid2_part2(ppF);
        	}
        #endif
	}
	else if(sensorDev==e_CAMERA_SUB_SENSOR)
	{
	    if(strobeId==1)
    	{
            if(partId==1)
    			subStrobeInit(ppF);
    		else if(partId==2)
    			strobeInit_sub_sid1_part2(ppF);
    	}
    	else if(strobeId==2)
    	{
    		if(partId==1)
    			strobeInit_sub_sid2_part1(ppF);
    		else if(partId==2)
    			strobeInit_sub_sid2_part2(ppF);
    	}
	}


	if((*ppF)!=0)
	{
		(*ppF)->flashlight_open(0);
		logI("setFlashDrv ok %d",__LINE__);
	}
	else
	{
		logE("set function pointer not found!!");
		return -1;
	}
	return 0;
}
Пример #3
0
/*******************************************************************************
* kdSetDriver
********************************************************************************/
int kdSetFlashlightDrv(unsigned int *pSensorId)
{
	int partId;
	if(*pSensorId==e_CAMERA_MAIN_SENSOR)
		partId = g_strobePartIdMain;
	else if(*pSensorId==e_CAMERA_SUB_SENSOR)
		partId = g_strobePartIdSub;
	else
		partId=1;

	PK_DBG("sensorDev=%d, strobePartIdaa= %d\n",*pSensorId, partId);


	if(*pSensorId==e_CAMERA_MAIN_SENSOR)
	{

#if defined(DUMMY_FLASHLIGHT)
		defaultFlashlightInit(&g_pFlashlightFunc);

#else
		if(partId==1)
			constantFlashlightInit(&g_pFlashlightFunc);
		else //if(partId==2)
			mainStrobe2Init(&g_pFlashlightFunc);
#endif
	}
	else if(*pSensorId==e_CAMERA_SUB_SENSOR && partId==1)
	{
		subStrobeInit(&g_pFlashlightFunc);
	}
	else if(*pSensorId==e_CAMERA_SUB_SENSOR && partId==2)
	{
		subStrobe2Init(&g_pFlashlightFunc);
	}
	else
	{
		defaultFlashlightInit(&g_pFlashlightFunc);
	}


/*
    PK_DBG("[kdSetFlashlightDrv] flashlightIdx: %d, seonsorId %d\n",flashlightIdx, (int)(*pSensorId));

    if (NULL != kdFlashlightList[flashlightIdx].flashlightInit) {
        kdFlashlightList[flashlightIdx].flashlightInit(&g_pFlashlightFunc);
        if (NULL == g_pFlashlightFunc) {
            PK_DBG("[kdSetFlashlightDrv] flashlightIdx init fail\n");
            if (NULL != kdFlashlightList[KD_DEFAULT_FLASHLIGHT_INDEX].flashlightInit) {
                kdFlashlightList[KD_DEFAULT_FLASHLIGHT_INDEX].flashlightInit(&g_pFlashlightFunc);
                if (NULL == g_pFlashlightFunc) {
                    PK_DBG("[kdSetFlashlightDrv] KD_DEFAULT_FLASHLIGHT_INDEX init fail\n");
                    return -EIO;
                }
            }
        }
    }*/

    //open flashlight driver
    if (g_pFlashlightFunc) {
       g_pFlashlightFunc->flashlight_open(0);
    }

	return 0;
}