soc_camera_platform.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 soc_camera_device *icd;
  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(struct soc_camera_device *icd,
  28. struct platform_device **pdev,
  29. struct soc_camera_link *plink,
  30. void (*release)(struct device *dev),
  31. int id)
  32. {
  33. struct soc_camera_platform_info *info = plink->priv;
  34. int ret;
  35. if (icd->link != plink)
  36. return -ENODEV;
  37. if (*pdev)
  38. return -EBUSY;
  39. *pdev = platform_device_alloc("soc_camera_platform", id);
  40. if (!*pdev)
  41. return -ENOMEM;
  42. info->icd = icd;
  43. (*pdev)->dev.platform_data = info;
  44. (*pdev)->dev.release = release;
  45. ret = platform_device_add(*pdev);
  46. if (ret < 0) {
  47. platform_device_put(*pdev);
  48. *pdev = NULL;
  49. info->icd = NULL;
  50. }
  51. return ret;
  52. }
  53. static inline void soc_camera_platform_del(const struct soc_camera_device *icd,
  54. struct platform_device *pdev,
  55. const struct soc_camera_link *plink)
  56. {
  57. if (icd->link != plink || !pdev)
  58. return;
  59. platform_device_unregister(pdev);
  60. }
  61. #endif /* __SOC_CAMERA_H__ */