static void pega_accel_poll(struct input_polled_dev *ipd) { struct device *parent = ipd->input->dev.parent; struct asus_laptop *asus = dev_get_drvdata(parent); /* In some cases, the very first call to poll causes a * recursive fault under the polldev worker. This is * apparently related to very early userspace access to the * device, and perhaps a firmware bug. Fake the first report. */ if (!asus->pega_acc_live) { asus->pega_acc_live = true; input_report_abs(ipd->input, ABS_X, 0); input_report_abs(ipd->input, ABS_Y, 0); input_report_abs(ipd->input, ABS_Z, 0); input_sync(ipd->input); return; } asus->pega_acc_x = pega_acc_axis(asus, asus->pega_acc_x, METHOD_XLRX); asus->pega_acc_y = pega_acc_axis(asus, asus->pega_acc_y, METHOD_XLRY); asus->pega_acc_z = pega_acc_axis(asus, asus->pega_acc_z, METHOD_XLRZ); /* Note transform, convert to "right/up/out" in the native * landscape orientation (i.e. the vector is the direction of * "real up" in the device's cartiesian coordinates). */ input_report_abs(ipd->input, ABS_X, -asus->pega_acc_x); input_report_abs(ipd->input, ABS_Y, -asus->pega_acc_y); input_report_abs(ipd->input, ABS_Z, asus->pega_acc_z); input_sync(ipd->input); }
static void pega_accel_poll(struct input_polled_dev *ipd) { struct device *parent = ipd->input->dev.parent; struct asus_laptop *asus = dev_get_drvdata(parent); if (!asus->pega_acc_live) { asus->pega_acc_live = true; input_report_abs(ipd->input, ABS_X, 0); input_report_abs(ipd->input, ABS_Y, 0); input_report_abs(ipd->input, ABS_Z, 0); input_sync(ipd->input); return; } asus->pega_acc_x = pega_acc_axis(asus, asus->pega_acc_x, METHOD_XLRX); asus->pega_acc_y = pega_acc_axis(asus, asus->pega_acc_y, METHOD_XLRY); asus->pega_acc_z = pega_acc_axis(asus, asus->pega_acc_z, METHOD_XLRZ); input_report_abs(ipd->input, ABS_X, -asus->pega_acc_x); input_report_abs(ipd->input, ABS_Y, -asus->pega_acc_y); input_report_abs(ipd->input, ABS_Z, asus->pega_acc_z); input_sync(ipd->input); }