light_cm3320.c 2.4 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_3320 "CM3320"
  18. #define CHIP_ID "CM3323"
  19. /*************************************************************************/
  20. /* factory Sysfs */
  21. /*************************************************************************/
  22. static ssize_t light_vendor_show(struct device *dev,
  23. struct device_attribute *attr, char *buf)
  24. {
  25. return sprintf(buf, "%s\n", VENDOR);
  26. }
  27. static ssize_t light_name_show(struct device *dev,
  28. struct device_attribute *attr, char *buf)
  29. {
  30. return sprintf(buf, "%s\n", CHIP_ID);
  31. }
  32. static ssize_t light_lux_show(struct device *dev,
  33. struct device_attribute *attr, char *buf)
  34. {
  35. struct ssp_data *data = dev_get_drvdata(dev);
  36. return sprintf(buf, "%u,%u,%u,%u\n",
  37. data->buf[LIGHT_SENSOR].r, data->buf[LIGHT_SENSOR].g,
  38. data->buf[LIGHT_SENSOR].b, data->buf[LIGHT_SENSOR].w);
  39. }
  40. static ssize_t light_data_show(struct device *dev,
  41. struct device_attribute *attr, char *buf)
  42. {
  43. struct ssp_data *data = dev_get_drvdata(dev);
  44. return sprintf(buf, "%u,%u,%u,%u\n",
  45. data->buf[LIGHT_SENSOR].r, data->buf[LIGHT_SENSOR].g,
  46. data->buf[LIGHT_SENSOR].b, data->buf[LIGHT_SENSOR].w);
  47. }
  48. static DEVICE_ATTR(vendor, S_IRUGO, light_vendor_show, NULL);
  49. static DEVICE_ATTR(name, S_IRUGO, light_name_show, NULL);
  50. static DEVICE_ATTR(lux, S_IRUGO, light_lux_show, NULL);
  51. static DEVICE_ATTR(raw_data, S_IRUGO, light_data_show, NULL);
  52. static struct device_attribute *light_attrs[] = {
  53. &dev_attr_vendor,
  54. &dev_attr_name,
  55. &dev_attr_lux,
  56. &dev_attr_raw_data,
  57. NULL,
  58. };
  59. void initialize_light_factorytest(struct ssp_data *data)
  60. {
  61. sensors_register(data->light_device, data, light_attrs, "light_sensor");
  62. }
  63. void remove_light_factorytest(struct ssp_data *data)
  64. {
  65. sensors_unregister(data->light_device, light_attrs);
  66. }