Beispiel #1
0
/** Function to open the ODM device with a set of default values. The values
 * are hardcoded as of now. Each time the device is closed/open, previous
 * settings will be lost. This function will help in switching
 * between power modes
 */
NvBool open_def_odm_accl(void)
{
	NvBool err;

	err = NvOdmAccelOpen(&(accel_dev->hOdmAcr));
	if (!err) {
		pr_err("open_def_odm_accl: NvOdmAccelOpen failed\n");
		return err;
	}
#if 0 //derick 20100715 not use
	err = NvOdmAccelSetIntForceThreshold(accel_dev->hOdmAcr,
		 NvOdmAccelInt_MotionThreshold, 0, 900);
	if (!err) {
		pr_err("open_def_odm_accl: Set Motion Thresold failed\n");
		return err;
	}

	err = NvOdmAccelSetIntEnable(accel_dev->hOdmAcr,
		NvOdmAccelInt_MotionThreshold, NvOdmAccelAxis_All, 0, NV_TRUE);

	if (!err) {
		pr_err("open_def_odm_accl: Enable Motion Thresold failed\n");
		return err;
	}

	err = NvOdmAccelSetIntEnable(accel_dev->hOdmAcr,
		NvOdmAccelInt_TapThreshold, NvOdmAccelAxis_All, 0, NV_TRUE);

	if (!err) {
		pr_err("open_def_odm_accl: Enable Tap Threshold failed\n");
		return err;
	}

	err = NvOdmAccelSetIntForceThreshold(accel_dev->hOdmAcr,
		NvOdmAccelInt_TapThreshold, 0, 120);

	if (!err) {
		pr_err("open_def_odm_accl: Set Tap Threshold failed\n");
		return err;
	}

	err = NvOdmAccelSetIntTimeThreshold(accel_dev->hOdmAcr,
		NvOdmAccelInt_TapThreshold, 0, 2);

	if (!err) {
		pr_err("open_def_odm_accl: SetIntTimeThreshold failed\n");
		return err;
	}
#endif
	return err;
}
Beispiel #2
0
/** Function to open the ODM device with a set of default values. The values
 * are hardcoded as of now. Each time the device is closed/open, previous 
 * settings will be lost. This function will help in switching
 * between power modes
 */
int open_def_odm_gyro_accel(void)
{
	NvS32 err = -1;
	err = NvOdmGyroAccelOpen(&(star_motion_dev->hOdmGyroAccel));
	//printk(" ##  open_def_odm_gyro_accel  ##\n");
	if (!err) {
		err = -ENODEV;
		printk("open_def_odm_gyro_accel: NvOdmGyroAccelOpen failed\n");
		
		return err;
	}
	
#if 0	
	
	err = NvOdmAccelSetIntEnable(star_motion_dev->hOdmGyroAccel,
		NvOdmAccelInt_MotionThreshold, NvOdmAccelAxis_All, 0, NV_TRUE);
	
	
	if (!err) {
		pr_err("open_def_odm_accl: NvOdmAccelSetIntEnable failed\n");
		return err;
	}	
    
	
	NvOdmAccelSetSampleRate(star_motion_dev->hOdmGyroAccel, 800);
	if (!err) {
		printk("TEST1=8  %s \n",__FUNCTION__);
		pr_err("open_def_odm_accl: NvOdmAccelSetIntEnable failed\n");
		return err;
	}

		err = NvOdmAccelSetIntForceThreshold(accel_dev->hOdmAcr,
		 NvOdmAccelInt_MotionThreshold, 0, 900);
	if (!err) {
		printk("TEST1=7  %s \n",__FUNCTION__);
		pr_err("open_def_odm_accl: NvOdmAccelSetIntForceThreshold\n");
		return err;
	}

	err = NvOdmAccelSetIntEnable(accel_dev->hOdmAcr,
		NvOdmAccelInt_MotionThreshold, NvOdmAccelAxis_All, 0, NV_TRUE);

	if (!err) {
		printk("TEST1=8  %s \n",__FUNCTION__);
		pr_err("open_def_odm_accl: NvOdmAccelSetIntEnable failed\n");
		return err;
	}
	
	/*
	err = NvOdmAccelSetIntEnable(accel_dev->hOdmAcr,
		NvOdmAccelInt_TapThreshold, NvOdmAccelAxis_All, 0, NV_TRUE);

	if (!err) {
		printk("TEST1=9  %s \n",__FUNCTION__);
		pr_err("open_def_odm_accl: NvOdmAccelSetIntEnable failed\n");
		return err;
	}*/

	err = NvOdmAccelSetIntForceThreshold(accel_dev->hOdmAcr,
		NvOdmAccelInt_TapThreshold, 0, 120);

	if (!err) {
		printk("TEST1=10  %s \n",__FUNCTION__);
		pr_err("open_def_odm_accl: NvOdmAccelSetIntForceThreshold\n");
		return err;
	}

	err = NvOdmAccelSetIntTimeThreshold(accel_dev->hOdmAcr,
		NvOdmAccelInt_TapThreshold, 0, 2);

	if (!err) {
		printk("TEST1=11  %s \n",__FUNCTION__);
		pr_err("open_def_odm_accl: NvOdmAccelSetIntTimeThreshold\n");
		return err;
	}
#endif
	return err;
}
Beispiel #3
0
/**Function to parse the values sent through sysfs and sets them accordingly
 */
void change_nvodm_accelerometer_settings(NvU32 command, NvS32 value)
{
	switch (command) {
	case COMMAND_LOG:
		accel_dev->show_log = (value == 0 ? NV_FALSE : NV_TRUE);
		break;
	case COMMAND_FREQUENCY:
		if (value <  3) {
			NvOdmAccelSetSampleRate(accel_dev->hOdmAcr,
				NvOdmAccelPower_Low);
			if (NvOdmAccelSetSampleRate(accel_dev->hOdmAcr, value)) {
				accel_dev->freq = value;
			}
		} else {
			NvOdmAccelSetSampleRate(accel_dev->hOdmAcr,
				NvOdmAccelPower_Fullrun);
			if (NvOdmAccelSetSampleRate(accel_dev->hOdmAcr, value)) {
				accel_dev->freq = value;
			}
		}
		break;
	case COMMAND_TIMETAP:
		if( value > 0) {
			NvOdmAccelSetIntEnable(accel_dev->hOdmAcr,
				NvOdmAccelInt_TapThreshold,
				NvOdmAccelAxis_All, 0, NV_TRUE);

			NvOdmAccelSetIntTimeThreshold(accel_dev->hOdmAcr,
				NvOdmAccelInt_TapThreshold, 0, value);
		} else {
			NvOdmAccelSetIntEnable(accel_dev->hOdmAcr,
				NvOdmAccelInt_TapThreshold,
				NvOdmAccelAxis_All, 0, NV_FALSE);
		}
		break;
	case COMMAND_FORCETAP:
		if( value > 0) {
			NvOdmAccelSetIntEnable(accel_dev->hOdmAcr,
				NvOdmAccelInt_TapThreshold,
				NvOdmAccelAxis_All, 0, NV_TRUE);

			NvOdmAccelSetIntForceThreshold(accel_dev->hOdmAcr,
				NvOdmAccelInt_TapThreshold, 0, value);
		} else {
			NvOdmAccelSetIntEnable(accel_dev->hOdmAcr,
				NvOdmAccelInt_TapThreshold,
				NvOdmAccelAxis_All, 0, NV_FALSE);
		}
		break;
	case COMMAND_FORCEMOTION:
		if (value > 0) {
			NvOdmAccelSetIntEnable(accel_dev->hOdmAcr,
				NvOdmAccelInt_MotionThreshold,
				NvOdmAccelAxis_All, 0, NV_TRUE);
			NvOdmAccelSetIntForceThreshold(accel_dev->hOdmAcr,
				NvOdmAccelInt_MotionThreshold, 0, value);
		} else {
			NvOdmAccelSetIntEnable(accel_dev->hOdmAcr,
				NvOdmAccelInt_MotionThreshold,
				NvOdmAccelAxis_All, 0, NV_FALSE);
		}
		break;
	case COMMAND_OPENCLOSE:
		if (value) {
			if (!accel_dev->hOdmAcr)
				open_def_odm_accl();
		} else {
			if (accel_dev->hOdmAcr)
				close_odm_accl();
		}
		break;
	default:
		break;
	}
}