hid-sensor-attributes.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * HID Sensors Driver
  3. * Copyright (c) 2012, Intel Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  17. *
  18. */
  19. #ifndef _HID_SENSORS_ATTRIBUTES_H
  20. #define _HID_SENSORS_ATTRIBUTES_H
  21. /* Common hid sensor iio structure */
  22. struct hid_sensor_iio_common {
  23. struct hid_sensor_hub_device *hsdev;
  24. struct platform_device *pdev;
  25. unsigned usage_id;
  26. bool data_ready;
  27. struct hid_sensor_hub_attribute_info poll;
  28. struct hid_sensor_hub_attribute_info report_state;
  29. struct hid_sensor_hub_attribute_info power_state;
  30. struct hid_sensor_hub_attribute_info sensitivity;
  31. };
  32. /*Convert from hid unit expo to regular exponent*/
  33. static inline int hid_sensor_convert_exponent(int unit_expo)
  34. {
  35. if (unit_expo < 0x08)
  36. return unit_expo;
  37. else if (unit_expo <= 0x0f)
  38. return -(0x0f-unit_expo+1);
  39. else
  40. return 0;
  41. }
  42. int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
  43. u32 usage_id,
  44. struct hid_sensor_iio_common *st);
  45. int hid_sensor_write_raw_hyst_value(struct hid_sensor_iio_common *st,
  46. int val1, int val2);
  47. int hid_sensor_read_raw_hyst_value(struct hid_sensor_iio_common *st,
  48. int *val1, int *val2);
  49. int hid_sensor_write_samp_freq_value(struct hid_sensor_iio_common *st,
  50. int val1, int val2);
  51. int hid_sensor_read_samp_freq_value(struct hid_sensor_iio_common *st,
  52. int *val1, int *val2);
  53. #endif