//static int ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
static long unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
#ifdef QA_TEST
    int i;
#endif

	DbgOut((KERN_INFO "tspdrv: ioctl cmd[0x%x].\n", cmd));

    switch (cmd)
    {
#if 0 // We don't used linear motor.     
#ifdef VIBE_TUNING
#if 1 //def CONFIG_KTTECH_MODEL_O6
             case TSPDRV_TUNING_ARG1: //M     // 0x52b9 
                    printk("[tspdrv] TSPDRV_TUNING_ARG1 arg : %lu\n", arg);
                    g_nLRA_PWM_M = arg;
                    break;
             case TSPDRV_TUNING_ARG2: //N & D  // ox52ba 
                    printk("[tspdrv] TSPDRV_TUNING_ARG2 arg : %lu\n", arg);
                    g_nLRA_PWM_N = arg;
                    g_nLRA_PWM_D= arg >> 1;
                    break;
             case TSPDRV_TUNING_ARG3: //Multiplier  // 0x52bb 
                    printk("[tspdrv] TSPDRV_TUNING_ARG2 arg : %lu\n", arg);
                    g_nLRA_PWM_Multiplier = arg;
                    break;
#endif					
#ifdef CONFIG_KTTECH_MODEL_O3
        case TSPDRV_TUNING_ARG1:
        	g_nLRA_PWM_M = arg; /* set value of g_PWM_duty_max in ImmVibeSPI */
	DbgOut((KERN_INFO "tspdrv: ioctl cmd[185].\n"));
        	break;
        case TSPDRV_TUNING_ARG2:
        	g_nLRA_PWM_N = arg; /* set value of g_PWM_ctrl in ImmVibeSPI */
        	g_nLRA_PWM_D = g_nLRA_PWM_N>>1; //D = N/2
	DbgOut((KERN_INFO "tspdrv: ioctl cmd[186].\n"));
        	break;
        case TSPDRV_TUNING_ARG3:
        	g_nLRA_PWM_Multiplier = arg; /* set value of g_PWM_multiplier in ImmVibeSPI */
	DbgOut((KERN_INFO "tspdrv: ioctl cmd[187].\n"));
        	break;
#endif			
#endif /* VIBE_TUNING */
#endif 
        case TSPDRV_STOP_KERNEL_TIMER:   // 0x5201
            /* 
            ** As we send one sample ahead of time, we need to finish playing the last sample
            ** before stopping the timer. So we just set a flag here.
            */
            if (true == g_bIsPlaying) g_bStopRequested = true;

#ifdef VIBEOSKERNELPROCESSDATA
            /* Last data processing to disable amp and stop timer */
            VibeOSKernelProcessData(NULL);
#endif

#ifdef QA_TEST
            if (g_nForceLogIndex)
            {
                for (i=0; i<g_nForceLogIndex; i++)
                {
                    printk("<6>%d\t%d\n", g_nTime, g_nForceLog[i]);
                    g_nTime += TIME_INCREMENT;
                }
            }
            g_nTime = 0;
            g_nForceLogIndex = 0;
#endif
            break;

        case TSPDRV_MAGIC_NUMBER:
            file->private_data = (void*)TSPDRV_MAGIC_NUMBER;
            break;

        case TSPDRV_ENABLE_AMP:   // 0x5203 
#ifdef CONFIG_SPIDER_SADR
            sadr_device_set_data(vib_dev_id,0xFFFFFFFF);
#else
            ImmVibeSPI_ForceOut_AmpEnable(arg);
#endif
            DbgRecorderReset((arg));
            DbgRecord((arg,";------- TSPDRV_ENABLE_AMP ---------\n"));
            break;

        case TSPDRV_DISABLE_AMP:   // 0x5204 
            /* Small fix for now to handle proper combination of TSPDRV_STOP_KERNEL_TIMER and TSPDRV_DISABLE_AMP together */
            /* If a stop was requested, ignore the request as the amp will be disabled by the timer proc when it's ready */
            if(!g_bStopRequested)
            {
#ifdef CONFIG_SPIDER_SADR
                sadr_device_set_data(vib_dev_id,0);
#else
                ImmVibeSPI_ForceOut_AmpDisable(arg);
#endif
            }
            break;

        case TSPDRV_GET_NUM_ACTUATORS:  // 0x5205 
            return NUM_ACTUATORS;
    }

    return 0;
}
Esempio n. 2
0
static long unlocked_ioctl(struct file *file, unsigned int cmd,
	unsigned long arg)
{
#ifdef QA_TEST
	int i;
#endif

	DbgOut((KERN_INFO "tspdrv: ioctl cmd[0x%x].\n", cmd));

	switch (cmd) {
	case TSPDRV_STOP_KERNEL_TIMER:
		/*
		  * As we send one sample ahead of time,
		  * we need to finish playing the last sample
		  * before stopping the timer. So we just set a flag here.
		  */
		if (true == g_bIsPlaying)
			g_bStopRequested = true;

#ifdef VIBEOSKERNELPROCESSDATA
		/* Last data processing to disable amp and stop timer */
		VibeOSKernelProcessData(NULL);
#endif

#ifdef QA_TEST
		if (g_nForceLogIndex) {
			for (i = 0; i < g_nForceLogIndex; i++) {
				printk(KERN_DEBUG "<6>%d\t%d\n",
					g_nTime, g_nForceLog[i]);
				g_nTime += TIME_INCREMENT;
			}
		}
		g_nTime = 0;
		g_nForceLogIndex = 0;
#endif
		break;

	case TSPDRV_MAGIC_NUMBER:
		file->private_data = (void *)TSPDRV_MAGIC_NUMBER;
		break;

	case TSPDRV_ENABLE_AMP:
		ImmVibeSPI_ForceOut_AmpEnable(arg);
		DbgRecorderReset((arg));
		DbgRecord((arg, ";------- TSPDRV_ENABLE_AMP ---------\n"));
		break;

	case TSPDRV_DISABLE_AMP:
		/* Small fix for now to handle proper combination of
		  * TSPDRV_STOP_KERNEL_TIMER and TSPDRV_DISABLE_AMP together
		  * If a stop was requested, ignore the request as the amp
		  * will be disabled by the timer proc when it's ready
		  */
		if (!g_bStopRequested)
			ImmVibeSPI_ForceOut_AmpDisable(arg);

		break;

	case TSPDRV_GET_NUM_ACTUATORS:
		return NUM_ACTUATORS;
	}

	return 0;
}