rsphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget"/translations/zh_CN/hid/hid-sensormodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget"/translations/zh_TW/hid/hid-sensormodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget"/translations/it_IT/hid/hid-sensormodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget"/translations/ja_JP/hid/hid-sensormodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget"/translations/ko_KR/hid/hid-sensormodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget"/translations/sp_SP/hid/hid-sensormodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(hHID Sensors Frameworkh]hHID Sensors Framework}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhj`hhubh)}(hSo if any driver with this name is inserted, then the probe routine for that function will be called. So an accelerometer processing driver can register with this name and will be probed if there is an accelerometer-3D detected.h]hSo if any driver with this name is inserted, then the probe routine for that function will be called. So an accelerometer processing driver can register with this name and will be probed if there is an accelerometer-3D detected.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK@hj`hhubh)}(hThe core driver provides a set of APIs which can be used by the processing drivers to register and get events for that usage id. Also it provides parsing functions, which get and set each input/feature/output report.h]hThe core driver provides a set of APIs which can be used by the processing drivers to register and get events for that usage id. Also it provides parsing functions, which get and set each input/feature/output report.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKDhj`hhubeh}(h] core-driverah ]h"] core driverah$]h&]uh1hhjhhhhhK7ubh)}(hhh](h)}(h2Individual sensor processing part (sensor drivers)h]h2Individual sensor processing part (sensor drivers)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKIubh)}(hThe processing driver will use an interface provided by the core driver to parse the report and get the indexes of the fields and also can get events. This driver can use IIO interface to use the standard ABI defined for a type of sensor.h]hThe processing driver will use an interface provided by the core driver to parse the report and get the indexes of the fields and also can get events. This driver can use IIO interface to use the standard ABI defined for a type of sensor.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKKhjhhubeh}(h]0individual-sensor-processing-part-sensor-driversah ]h"]2individual sensor processing part (sensor drivers)ah$]h&]uh1hhjhhhhhKIubeh}(h]implementationah ]h"]implementationah$]h&]uh1hhhhhhhhK+ubh)}(hhh](h)}(hCore driver Interfaceh]hCore driver Interface}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKQubh)}(hCallback structure::h]hCallback structure:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKShjhhubh)}(hXEach processing driver can use this structure to set some callbacks. int (*suspend)(..): Callback when HID suspend is received int (*resume)(..): Callback when HID resume is received int (*capture_sample)(..): Capture a sample for one of its data fields int (*send_event)(..): One complete event is received which can have multiple data fields.h]hXEach processing driver can use this structure to set some callbacks. int (*suspend)(..): Callback when HID suspend is received int (*resume)(..): Callback when HID resume is received int (*capture_sample)(..): Capture a sample for one of its data fields int (*send_event)(..): One complete event is received which can have multiple data fields.}hj sbah}(h]h ]h"]h$]h&]hhuh1hhhhKUhjhhubh)}(hRegistration functions::h]hRegistration functions:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK\hjhhubh)}(hint sensor_hub_register_callback(struct hid_sensor_hub_device *hsdev, u32 usage_id, struct hid_sensor_hub_callbacks *usage_callback):h]hint sensor_hub_register_callback(struct hid_sensor_hub_device *hsdev, u32 usage_id, struct hid_sensor_hub_callbacks *usage_callback):}hj)sbah}(h]h ]h"]h$]h&]hhuh1hhhhK^hjhhubh)}(hURegisters callbacks for a usage id. The callback functions are not allowed to sleep::h]hTRegisters callbacks for a usage id. The callback functions are not allowed to sleep:}(hj7hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKbhjhhubh)}(hhint sensor_hub_remove_callback(struct hid_sensor_hub_device *hsdev, u32 usage_id):h]hhint sensor_hub_remove_callback(struct hid_sensor_hub_device *hsdev, u32 usage_id):}hjEsbah}(h]h ]h"]h$]h&]hhuh1hhhhKfhjhhubh)}(h!Removes callbacks for a usage id.h]h!Removes callbacks for a usage id.}(hjShhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKihjhhubh)}(hParsing function::h]hParsing function:}(hjahhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKlhjhhubh)}(hint sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev, u8 type, u32 usage_id, u32 attr_usage_id, struct hid_sensor_hub_attribute_info *info);h]hint sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev, u8 type, u32 usage_id, u32 attr_usage_id, struct hid_sensor_hub_attribute_info *info);}hjosbah}(h]h ]h"]h$]h&]hhuh1hhhhKnhjhhubh)}(hXA processing driver can look for some field of interest and check if it exists in a report descriptor. If it exists it will store necessary information so that fields can be set or get individually. These indexes avoid searching every time and getting field index to get or set.h]hXA processing driver can look for some field of interest and check if it exists in a report descriptor. If it exists it will store necessary information so that fields can be set or get individually. These indexes avoid searching every time and getting field index to get or set.}(hj}hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKshjhhubh)}(hSet Feature report::h]hSet Feature report:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKyhjhhubh)}(hint sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id, u32 field_index, s32 value);h]hint sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id, u32 field_index, s32 value);}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhK{hjhhubh)}(hThis interface is used to set a value for a field in feature report. For example if there is a field report_interval, which is parsed by a call to sensor_hub_input_get_attribute_info before, then it can directly set that individual field::h]hThis interface is used to set a value for a field in feature report. For example if there is a field report_interval, which is parsed by a call to sensor_hub_input_get_attribute_info before, then it can directly set that individual field:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK~hjhhubh)}(hint sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id, u32 field_index, s32 *value);h]hint sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id, u32 field_index, s32 *value);}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhKhjhhubh)}(hThis interface is used to get a value for a field in input report. For example if there is a field report_interval, which is parsed by a call to sensor_hub_input_get_attribute_info before, then it can directly get that individual field value::h]hThis interface is used to get a value for a field in input report. For example if there is a field report_interval, which is parsed by a call to sensor_hub_input_get_attribute_info before, then it can directly get that individual field value:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hint sensor_hub_input_attr_get_raw_value(struct hid_sensor_hub_device *hsdev, u32 usage_id, u32 attr_usage_id, u32 report_id);h]hint sensor_hub_input_attr_get_raw_value(struct hid_sensor_hub_device *hsdev, u32 usage_id, u32 attr_usage_id, u32 report_id);}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhKhjhhubh)}(hXpThis is used to get a particular field value through input reports. For example accelerometer wants to poll X axis value, then it can call this function with the usage id of X axis. HID sensors can provide events, so this is not necessary to poll for any field. If there is some new sample, the core driver will call registered callback function to process the sample.h]hXpThis is used to get a particular field value through input reports. For example accelerometer wants to poll X axis value, then it can call this function with the usage id of X axis. HID sensors can provide events, so this is not necessary to poll for any field. If there is some new sample, the core driver will call registered callback function to process the sample.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh transition)}(h ----------h]h}(h]h ]h"]h$]h&]uh1jhhhKhjhhubh)}(hhh](h)}(hHID Custom and generic Sensorsh]hHID Custom and generic Sensors}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hXHID Sensor specification defines two special sensor usage types. Since they don't represent a standard sensor, it is not possible to define using Linux IIO type interfaces. The purpose of these sensors is to extend the functionality or provide a way to obfuscate the data being communicated by a sensor. Without knowing the mapping between the data and its encapsulated form, it is difficult for an application/driver to determine what data is being communicated by the sensor. This allows some differentiating use cases, where vendor can provide applications. Some common use cases are debug other sensors or to provide some events like keyboard attached/detached or lid open/close.h]hXHID Sensor specification defines two special sensor usage types. Since they don’t represent a standard sensor, it is not possible to define using Linux IIO type interfaces. The purpose of these sensors is to extend the functionality or provide a way to obfuscate the data being communicated by a sensor. Without knowing the mapping between the data and its encapsulated form, it is difficult for an application/driver to determine what data is being communicated by the sensor. This allows some differentiating use cases, where vendor can provide applications. Some common use cases are debug other sensors or to provide some events like keyboard attached/detached or lid open/close.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hTo allow application to utilize these sensors, here they are exported using sysfs attribute groups, attributes and misc device interface.h]hTo allow application to utilize these sensors, here they are exported using sysfs attribute groups, attributes and misc device interface.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(h,An example of this representation on sysfs::h]h+An example of this representation on sysfs:}(hj&hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hXp/sys/devices/pci0000:00/INT33C2:00/i2c-0/i2c-INT33D1:00/0018:8086:09FA.0001/HID-SENSOR-2000e1.6.auto$ tree -R . │   ├── enable_sensor │   │   ├── feature-0-200316 │   │   │   ├── feature-0-200316-maximum │   │   │   ├── feature-0-200316-minimum │   │   │   ├── feature-0-200316-name │   │   │   ├── feature-0-200316-size │   │   │   ├── feature-0-200316-unit-expo │   │   │   ├── feature-0-200316-units │   │   │   ├── feature-0-200316-value │   │   ├── feature-1-200201 │   │   │   ├── feature-1-200201-maximum │   │   │   ├── feature-1-200201-minimum │   │   │   ├── feature-1-200201-name │   │   │   ├── feature-1-200201-size │   │   │   ├── feature-1-200201-unit-expo │   │   │   ├── feature-1-200201-units │   │   │   ├── feature-1-200201-value │   │   ├── input-0-200201 │   │   │   ├── input-0-200201-maximum │   │   │   ├── input-0-200201-minimum │   │   │   ├── input-0-200201-name │   │   │   ├── input-0-200201-size │   │   │   ├── input-0-200201-unit-expo │   │   │   ├── input-0-200201-units │   │   │   ├── input-0-200201-value │   │   ├── input-1-200202 │   │   │   ├── input-1-200202-maximum │   │   │   ├── input-1-200202-minimum │   │   │   ├── input-1-200202-name │   │   │   ├── input-1-200202-size │   │   │   ├── input-1-200202-unit-expo │   │   │   ├── input-1-200202-units │   │   │   ├── input-1-200202-valueh]hXp/sys/devices/pci0000:00/INT33C2:00/i2c-0/i2c-INT33D1:00/0018:8086:09FA.0001/HID-SENSOR-2000e1.6.auto$ tree -R . │   ├── enable_sensor │   │   ├── feature-0-200316 │   │   │   ├── feature-0-200316-maximum │   │   │   ├── feature-0-200316-minimum │   │   │   ├── feature-0-200316-name │   │   │   ├── feature-0-200316-size │   │   │   ├── feature-0-200316-unit-expo │   │   │   ├── feature-0-200316-units │   │   │   ├── feature-0-200316-value │   │   ├── feature-1-200201 │   │   │   ├── feature-1-200201-maximum │   │   │   ├── feature-1-200201-minimum │   │   │   ├── feature-1-200201-name │   │   │   ├── feature-1-200201-size │   │   │   ├── feature-1-200201-unit-expo │   │   │   ├── feature-1-200201-units │   │   │   ├── feature-1-200201-value │   │   ├── input-0-200201 │   │   │   ├── input-0-200201-maximum │   │   │   ├── input-0-200201-minimum │   │   │   ├── input-0-200201-name │   │   │   ├── input-0-200201-size │   │   │   ├── input-0-200201-unit-expo │   │   │   ├── input-0-200201-units │   │   │   ├── input-0-200201-value │   │   ├── input-1-200202 │   │   │   ├── input-1-200202-maximum │   │   │   ├── input-1-200202-minimum │   │   │   ├── input-1-200202-name │   │   │   ├── input-1-200202-size │   │   │   ├── input-1-200202-unit-expo │   │   │   ├── input-1-200202-units │   │   │   ├── input-1-200202-value}hj4sbah}(h]h ]h"]h$]h&]hhuh1hhhhKhjhhubh)}(hHere there is a custom sensor with four fields: two feature and two inputs. Each field is represented by a set of attributes. All fields except the "value" are read only. The value field is a read-write field.h]hHere there is a custom sensor with four fields: two feature and two inputs. Each field is represented by a set of attributes. All fields except the “value” are read only. The value field is a read-write field.}(hjBhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(h Example::h]hExample:}(hjPhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hX/sys/bus/platform/devices/HID-SENSOR-2000e1.6.auto/feature-0-200316$ grep -r . * feature-0-200316-maximum:6 feature-0-200316-minimum:0 feature-0-200316-name:property-reporting-state feature-0-200316-size:1 feature-0-200316-unit-expo:0 feature-0-200316-units:25 feature-0-200316-value:1h]hX/sys/bus/platform/devices/HID-SENSOR-2000e1.6.auto/feature-0-200316$ grep -r . * feature-0-200316-maximum:6 feature-0-200316-minimum:0 feature-0-200316-name:property-reporting-state feature-0-200316-size:1 feature-0-200316-unit-expo:0 feature-0-200316-units:25 feature-0-200316-value:1}hj^sbah}(h]h ]h"]h$]h&]hhuh1hhhhKhjhhubh)}(hhh](h)}(hHow to enable such sensor?h]hHow to enable such sensor?}(hjohhhNhNubah}(h]h ]h"]h$]h&]uh1hhjlhhhhhKubh)}(hVBy default sensor can be power gated. To enable sysfs attribute "enable" can be used::h]hYBy default sensor can be power gated. To enable sysfs attribute “enable” can be used:}(hj}hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjlhhubh)}(h$ echo 1 > enable_sensorh]h$ echo 1 > enable_sensor}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhKhjlhhubh)}(hOnce enabled and powered on, sensor can report value using HID reports. These reports are pushed using misc device interface in a FIFO order::h]hOnce enabled and powered on, sensor can report value using HID reports. These reports are pushed using misc device interface in a FIFO order:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjlhhubh)}(h/dev$ tree | grep HID-SENSOR-2000e1.6.auto │   │   │   ├── 10:53 -> ../HID-SENSOR-2000e1.6.auto │   ├── HID-SENSOR-2000e1.6.autoh]h/dev$ tree | grep HID-SENSOR-2000e1.6.auto │   │   │   ├── 10:53 -> ../HID-SENSOR-2000e1.6.auto │   ├── HID-SENSOR-2000e1.6.auto}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhKhjlhhubh)}(hEach report can be of variable length preceded by a header. This header consists of a 32-bit usage id, 64-bit time stamp and 32-bit length field of raw data.h]hEach report can be of variable length preceded by a header. This header consists of a 32-bit usage id, 64-bit time stamp and 32-bit length field of raw data.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjlhhubeh}(h]how-to-enable-such-sensorah ]h"]how to enable such sensor?ah$]h&]uh1hhjhhhhhKubeh}(h]hid-custom-and-generic-sensorsah ]h"]hid custom and generic sensorsah$]h&]uh1hhjhhhhhKubeh}(h]core-driver-interfaceah ]h"]core driver interfaceah$]h&]uh1hhhhhhhhKQubeh}(h]hid-sensors-frameworkah ]h"]hid sensors frameworkah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjerror_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(jjjjjjjjjjjjjju nametypes}(jjjjjjjuh}(jhjjjj`jjjjjjjjlu footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages] transformerN include_log] decorationNhhub.