light_cm36651.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright (C) 2012, Samsung Electronics Co. Ltd. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. */
  15. #include "../ssp.h"
  16. #define VENDOR "CAPELLA"
  17. #define CHIP_ID "CM36651"
  18. /*************************************************************************/
  19. /* factory Sysfs */
  20. /*************************************************************************/
  21. static ssize_t light_vendor_show(struct device *dev,
  22. struct device_attribute *attr, char *buf)
  23. {
  24. return sprintf(buf, "%s\n", VENDOR);
  25. }
  26. static ssize_t light_name_show(struct device *dev,
  27. struct device_attribute *attr, char *buf)
  28. {
  29. return sprintf(buf, "%s\n", CHIP_ID);
  30. }
  31. static ssize_t light_lux_show(struct device *dev,
  32. struct device_attribute *attr, char *buf)
  33. {
  34. struct ssp_data *data = dev_get_drvdata(dev);
  35. return sprintf(buf, "%u,%u,%u,%u\n",
  36. data->buf[LIGHT_SENSOR].r, data->buf[LIGHT_SENSOR].g,
  37. data->buf[LIGHT_SENSOR].b, data->buf[LIGHT_SENSOR].w);
  38. }
  39. static ssize_t light_data_show(struct device *dev,
  40. struct device_attribute *attr, char *buf)
  41. {
  42. struct ssp_data *data = dev_get_drvdata(dev);
  43. return sprintf(buf, "%u,%u,%u,%u\n",
  44. data->buf[LIGHT_SENSOR].r, data->buf[LIGHT_SENSOR].g,
  45. data->buf[LIGHT_SENSOR].b, data->buf[LIGHT_SENSOR].w);
  46. }
  47. static DEVICE_ATTR(vendor, S_IRUGO, light_vendor_show, NULL);
  48. static DEVICE_ATTR(name, S_IRUGO, light_name_show, NULL);
  49. static DEVICE_ATTR(lux, S_IRUGO, light_lux_show, NULL);
  50. static DEVICE_ATTR(raw_data, S_IRUGO, light_data_show, NULL);
  51. static struct device_attribute *light_attrs[] = {
  52. &dev_attr_vendor,
  53. &dev_attr_name,
  54. &dev_attr_lux,
  55. &dev_attr_raw_data,
  56. NULL,
  57. };
  58. void initialize_light_factorytest(struct ssp_data *data)
  59. {
  60. sensors_register(data->light_device, data, light_attrs, "light_sensor");
  61. }
  62. void remove_light_factorytest(struct ssp_data *data)
  63. {
  64. sensors_unregister(data->light_device, light_attrs);
  65. }