ssp_misc.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright (C) 2014, 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 SHAKE_ON 1
  17. #define SHAKE_OFF 2
  18. struct remove_af_noise {
  19. void *af_pdata;
  20. int16_t (*af_func)(void *, bool);
  21. };
  22. static struct remove_af_noise af_sensor;
  23. int remove_af_noise_register(struct remove_af_noise *af_cam)
  24. {
  25. if (af_cam->af_pdata)
  26. af_sensor.af_pdata = af_cam->af_pdata;
  27. if (af_cam->af_func)
  28. af_sensor.af_func = af_cam->af_func;
  29. if (!af_cam->af_pdata || !af_cam->af_func) {
  30. ssp_dbg("[SSP]: %s - no af struct\n", __func__);
  31. return ERROR;
  32. }
  33. return 0;
  34. }
  35. EXPORT_SYMBOL(remove_af_noise_register);
  36. void remove_af_noise_unregister(struct remove_af_noise *af_cam)
  37. {
  38. af_sensor.af_pdata = NULL;
  39. af_sensor.af_func = NULL;
  40. }
  41. EXPORT_SYMBOL(remove_af_noise_unregister);
  42. void report_shake_cam_data(struct ssp_data *data,
  43. struct sensor_value *shake_cam_data)
  44. {
  45. data->buf[SHAKE_CAM].x = shake_cam_data->x;
  46. ssp_dbg("[SSP]: %s - shake = %d\n", __func__,
  47. (char)data->buf[SHAKE_CAM].x);
  48. if (likely(af_sensor.af_pdata && af_sensor.af_func)) {
  49. if ((char)data->buf[SHAKE_CAM].x == SHAKE_ON)
  50. af_sensor.af_func(af_sensor.af_pdata, true);
  51. else if ((char)data->buf[SHAKE_CAM].x == SHAKE_OFF)
  52. af_sensor.af_func(af_sensor.af_pdata, false);
  53. } else {
  54. ssp_dbg("[SSP]: %s - no af_func\n", __func__);
  55. }
  56. }