soc_camera_platform.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Generic Platform Camera Driver Header
  3. *
  4. * Copyright (C) 2008 Magnus Damm
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #ifndef __SOC_CAMERA_H__
  11. #define __SOC_CAMERA_H__
  12. #include <linux/videodev2.h>
  13. #include <media/soc_camera.h>
  14. struct device;
  15. struct soc_camera_platform_info {
  16. const char *format_name;
  17. unsigned long format_depth;
  18. struct v4l2_mbus_framefmt format;
  19. unsigned long bus_param;
  20. struct device *dev;
  21. int (*set_capture)(struct soc_camera_platform_info *info, int enable);
  22. };
  23. static inline void soc_camera_platform_release(struct platform_device **pdev)
  24. {
  25. *pdev = NULL;
  26. }
  27. static inline int soc_camera_platform_add(const struct soc_camera_link *icl,
  28. struct device *dev,
  29. struct platform_device **pdev,
  30. struct soc_camera_link *plink,
  31. void (*release)(struct device *dev),
  32. int id)
  33. {
  34. struct soc_camera_platform_info *info = plink->priv;
  35. int ret;
  36. if (icl != plink)
  37. return -ENODEV;
  38. if (*pdev)
  39. return -EBUSY;
  40. *pdev = platform_device_alloc("soc_camera_platform", id);
  41. if (!*pdev)
  42. return -ENOMEM;
  43. info->dev = dev;
  44. (*pdev)->dev.platform_data = info;
  45. (*pdev)->dev.release = release;
  46. ret = platform_device_add(*pdev);
  47. if (ret < 0) {
  48. platform_device_put(*pdev);
  49. *pdev = NULL;
  50. info->dev = NULL;
  51. }
  52. return ret;
  53. }
  54. static inline void soc_camera_platform_del(const struct soc_camera_link *icl,
  55. struct platform_device *pdev,
  56. const struct soc_camera_link *plink)
  57. {
  58. if (icl != plink || !pdev)
  59. return;
  60. platform_device_unregister(pdev);
  61. }
  62. #endif /* __SOC_CAMERA_H__ */