/* Callback handler to send event after all samples are received and captured */ staticint hid_time_proc_event(struct hid_sensor_hub_device *hsdev, unsigned usage_id, void *priv)
{ unsignedlong flags; struct hid_time_state *time_state = platform_get_drvdata(priv);
switch (usage_id) { case HID_USAGE_SENSOR_TIME_YEAR: /* * The draft for HID-sensors (HUTRR39) currently doesn't define * the range for the year attribute. Therefor we support * 8 bit (0-99) and 16 or 32 bits (full) as size for the year.
*/ if (raw_len == 1) {
time_buf->tm_year = *(u8 *)raw_data; if (time_buf->tm_year < 70) /* assume we are in 1970...2069 */
time_buf->tm_year += 100;
} else
time_buf->tm_year =
(int)hid_time_value(raw_len, raw_data)-1900; break; case HID_USAGE_SENSOR_TIME_MONTH: /* sensors are sending the month as 1-12, we need 0-11 */
time_buf->tm_mon = (int)hid_time_value(raw_len, raw_data)-1; break; case HID_USAGE_SENSOR_TIME_DAY:
time_buf->tm_mday = (int)hid_time_value(raw_len, raw_data); break; case HID_USAGE_SENSOR_TIME_HOUR:
time_buf->tm_hour = (int)hid_time_value(raw_len, raw_data); break; case HID_USAGE_SENSOR_TIME_MINUTE:
time_buf->tm_min = (int)hid_time_value(raw_len, raw_data); break; case HID_USAGE_SENSOR_TIME_SECOND:
time_buf->tm_sec = (int)hid_time_value(raw_len, raw_data); break; default: return -EINVAL;
} return 0;
}
/* small helper, haven't found any other way */ staticconstchar *hid_time_attrib_name(u32 attrib_id)
{ staticconstchar unknown[] = "unknown"; unsigned i;
for (i = 0; i < TIME_RTC_CHANNEL_MAX; ++i) { if (hid_time_addresses[i] == attrib_id) return hid_time_channel_names[i];
} return unknown; /* should never happen */
}
reinit_completion(&time_state->comp_last_time); /* get a report with all values through requesting one value */
sensor_hub_input_attr_get_raw_value(time_state->common_attributes.hsdev,
HID_USAGE_SENSOR_TIME, hid_time_addresses[0],
time_state->info[0].report_id, SENSOR_HUB_SYNC, false); /* wait for all values (event) */
ret = wait_for_completion_killable_timeout(
&time_state->comp_last_time, HZ*6); if (ret > 0) { /* no error */
spin_lock_irqsave(&time_state->lock_last_time, flags);
*tm = time_state->last_time;
spin_unlock_irqrestore(&time_state->lock_last_time, flags); return 0;
} if (!ret) return -EIO; /* timeouted */ return ret; /* killed (-ERESTARTSYS) */
}
ret = hid_sensor_parse_common_attributes(hsdev,
HID_USAGE_SENSOR_TIME,
&time_state->common_attributes,
NULL,
0); if (ret) {
dev_err(&pdev->dev, "failed to setup common attributes!\n"); return ret;
}
ret = hid_time_parse_report(pdev, hsdev, HID_USAGE_SENSOR_TIME,
time_state); if (ret) {
dev_err(&pdev->dev, "failed to setup attributes!\n"); return ret;
}
ret = sensor_hub_device_open(hsdev); if (ret) {
dev_err(&pdev->dev, "failed to open sensor hub device!\n"); goto err_open;
}
/* * Enable HID input processing early in order to be able to read the * clock already in devm_rtc_device_register().
*/
hid_device_io_start(hsdev->hdev);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.