コード例 #1
0
ファイル: tegra_odm_accel.c プロジェクト: Feeyo/LG_Optimus2X
/**
 * Thread that waits for the interrupt from ODM and then sends out the
 * corresponding events.
 */
static int tegra_acc_thread(void *pdata)
{
	struct tegra_acc_device_data *accelerometer =
		(struct tegra_acc_device_data*)pdata;
	NvS32 x=0, y=0, z=0;
	accelerometer->bThreadAlive = 1;

	while (accelerometer->bThreadAlive) {
		NvOdmAccelWaitInt(accelerometer->hOdmAcr,
			&(accelerometer->IntType),
			&(accelerometer->IntMotionAxis),
			&(accelerometer->IntTapAxis));
		NvOdmAccelGetAcceleration(
			accelerometer->hOdmAcr, &x, &y, &z);
		if (accelerometer->show_log) {
			printk("Accelerometer: x=%d, y=%d, z=%d\n", x, y, z);
		}

		input_report_abs(accelerometer->input_dev, ABS_X, x);
		input_report_abs(accelerometer->input_dev, ABS_Y, y);
		input_report_abs(accelerometer->input_dev, ABS_Z, z);
		input_sync(accelerometer->input_dev);

		accelerometer->prev_data.x = x;
		accelerometer->prev_data.y = y;
		accelerometer->prev_data.z = z;
	}

	return 0;
}
コード例 #2
0
/**
 * Thread that waits for the interrupt from ODM and then sends out the
 * corresponding events.
 */
static int tegra_acc_thread(void *pdata)
{
	struct tegra_acc_device_data *accelerometer =
		(struct tegra_acc_device_data*)pdata;
	NvS32 x=0, y=0, z=0;
	accelerometer->bThreadAlive = 1;
	accelerometer->show_log = 0; //derick 20100713 debug
	while (accelerometer->bThreadAlive) {
		NvOdmAccelWaitInt(accelerometer->hOdmAcr,
			&(accelerometer->IntType),
			&(accelerometer->IntMotionAxis),
			&(accelerometer->IntTapAxis));
		NvOdmAccelGetAcceleration(
			accelerometer->hOdmAcr, &x, &y, &z);
		if (accelerometer->show_log) {
			printk("Accelerometer: x=%d, y=%d, z=%d\n", x, y, z);
		}
//NvOsDebugPrintf("G-sensor read data.\r\n");
		input_report_abs(accelerometer->input_dev, ABS_X, x);
		input_report_abs(accelerometer->input_dev, ABS_Y, y);
		input_report_abs(accelerometer->input_dev, ABS_Z, z);
		input_sync(accelerometer->input_dev);
		
		lsm303dlh_acc_tempdata[0]=x;
		lsm303dlh_acc_tempdata[1]=y;
		lsm303dlh_acc_tempdata[2]=z;
		
		accelerometer->prev_data.x = x;
		accelerometer->prev_data.y = y;
		accelerometer->prev_data.z = z;
	}

	return 0;
}