/* Channel definitions (same order as prox_usage_ids) */ staticconststruct iio_chan_spec prox_channels[] = {
PROX_CHANNEL(true, HID_HUMAN_PRESENCE),
PROX_CHANNEL(true, HID_HUMAN_PROXIMITY),
PROX_CHANNEL(false, 0),
};
/* Adjust channel real bits based on report descriptor */ staticvoid prox_adjust_channel_bit_mask(struct iio_chan_spec *channels, int channel, int size)
{
channels[channel].scan_type.sign = 's'; /* Real storage bits will change based on the report desc. */
channels[channel].scan_type.realbits = size * 8; /* Maximum size of a sample to capture is u32 */
channels[channel].scan_type.storagebits = sizeof(u32) * 8;
}
/* Channel read_raw handler */ staticint prox_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask)
{ struct prox_state *prox_state = iio_priv(indio_dev); struct hid_sensor_hub_device *hsdev; int report_id;
u32 address; int ret_type;
s32 min;
*val = 0;
*val2 = 0; switch (mask) { case IIO_CHAN_INFO_RAW: case IIO_CHAN_INFO_PROCESSED: if (chan->scan_index >= prox_state->num_channels) return -EINVAL;
address = prox_state->channel2usage[chan->scan_index];
report_id = prox_state->prox_attr[chan->scan_index].report_id;
hsdev = prox_state->common_attributes.hsdev;
min = prox_state->prox_attr[chan->scan_index].logical_minimum;
hid_sensor_power_state(&prox_state->common_attributes, true);
*val = sensor_hub_input_attr_get_raw_value(hsdev,
hsdev->usage,
address,
report_id,
SENSOR_HUB_SYNC,
min < 0); if (prox_state->channel2usage[chan->scan_index] ==
HID_USAGE_SENSOR_HUMAN_ATTENTION)
*val *= 100;
hid_sensor_power_state(&prox_state->common_attributes, false);
ret_type = IIO_VAL_INT; break; case IIO_CHAN_INFO_SCALE: if (chan->scan_index >= prox_state->num_channels) return -EINVAL;
/* Parse report which is specific to an usage id*/ staticint prox_parse_report(struct platform_device *pdev, struct hid_sensor_hub_device *hsdev, struct prox_state *st)
{ struct iio_chan_spec *channels = st->channels; int index = 0; int ret; int i;
for (i = 0; i < MAX_CHANNELS; i++) {
u32 usage_id = prox_usage_ids[i];
/* Function to initialize the processing for usage id */ staticint hid_prox_probe(struct platform_device *pdev)
{ struct hid_sensor_hub_device *hsdev = dev_get_platdata(&pdev->dev); int ret = 0; staticconstchar *name = "prox"; struct iio_dev *indio_dev; struct prox_state *prox_state;
ret = hid_sensor_parse_common_attributes(hsdev, hsdev->usage,
&prox_state->common_attributes,
prox_sensitivity_addresses,
ARRAY_SIZE(prox_sensitivity_addresses)); if (ret) {
dev_err(&pdev->dev, "failed to setup common attributes\n"); return ret;
}
ret = prox_parse_report(pdev, hsdev, prox_state); if (ret) {
dev_err(&pdev->dev, "failed to setup attributes\n"); return ret;
}
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.