Do I need to define the all the Usage Tags in the input report of a sensor to retrieve minimum any one field or Only a Usage Tag which I wanted to retrieve is enough.e.g for an input report of an accelerometer which has the below fields(added new one in Bold),
HID_USAGE_SENSOR_ACCEL_X_AXIS
HID_USAGE_SENSOR_ACCEL_Y_AXIS
HID_USAGE_SENSOR_ACCEL_Z_AXIS
HID_USAGE_SENSOR_DATA_MOTION_STATE,
HID_USAGE_SENSOR_DATA_CUSTOM_VALUE_2
HID_USAGE_SENSOR_DATA_CUSTOM_VALUE_3
HID_USAGE_SENSOR_DATA_CUSTOM_VALUE_4
I want to retrieve Custom_Value_4 do I also need to define parameters for Data_Motion_state, Custom_Value2,Custom_Value3 as well apart from Custom_Value4 in the below structure.
enum accel_3d_channel {.. }
struct accel_3d_state {.. }
static const struct iio_chan_spec accel_3d_channels[] = { ..}
I did so but was getting error - "failed to setup attributes" but after I modified the code in the function : accel_3d_parse_report() like below to accommodate all the non Contigous Usage Tags and associated them with their channels - *_SCAN_INDEX_* . I did not get this error but some other error (listed at the end of the mail)
//First Three channel X,Y and Z whose Usage Tags are contionus - 0x200453/54/55
for (i = 0; i <= CHANNEL_SCAN_INDEX_Z; ++i) {
ret = sensor_hub_input_get_attribute_info(hsdev,
HID_INPUT_REPORT,
usage_id,
HID_USAGE_SENSOR_ACCEL_X_AXIS + i,
&st->accel[CHANNEL_SCAN_INDEX_X + i]);
accel_3d_adjust_channel_bit_mask(channels,
CHANNEL_SCAN_INDEX_X + i,
st->accel[CHANNEL_SCAN_INDEX_X + i].size);
}
//Fourth channel For Data Motion - 0x200451
ret = sensor_hub_input_get_attribute_info(hsdev,
HID_INPUT_REPORT,
usage_id,
HID_USAGE_SENSOR_DATA_MOTION_STATE, // For CHANNEL_SCAN_DATA_MOTION
&st->accel[CHANNEL_SCAN_INDEX_X + i]);
accel_3d_adjust_channel_bit_mask(channels,
CHANNEL_SCAN_INDEX_X + i,
st->accel[CHANNEL_SCAN_INDEX_X + i].size);
//Last Three Channel for Custom Value 2,3,4 - 0x200545/46/47
for (i = 0; i <= 2; ++i) {
ret = sensor_hub_input_get_attribute_info(hsdev,
HID_INPUT_REPORT,
usage_id,
HID_USAGE_SENSOR_DATA_CUSTOM_VALUE_2 + i,
&st->accel[CHANNEL_SCAN_INDEX_X + i + 4]); //start after CHANNEL_SCAN_DATA_MOTION Channel
accel_3d_adjust_channel_bit_mask(channels,
CHANNEL_SCAN_INDEX_X + i + 4,
st->accel[CHANNEL_SCAN_INDEX_X + i].size);
}
But now I am getting a different error :
[13778.127716] iio iio:device4: tried to double register : in_accel_x_index
[13778.127899] hid_sensor_accel_3d HID-SENSOR-200073.3.auto: failed to initialize trigger buffer
[13778.143676] hid_sensor_accel_3d: probe of HID-SENSOR-200073.3.auto failed with error -16
I am still figuring out where else Do I have to modify the code in order to receive the above custom values ..
Thanks,
S