fimc-mdevice.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd.
  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 version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #ifndef FIMC_MDEVICE_H_
  9. #define FIMC_MDEVICE_H_
  10. #include <linux/clk.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/mutex.h>
  13. #include <media/media-device.h>
  14. #include <media/media-entity.h>
  15. #include <media/v4l2-device.h>
  16. #include <media/v4l2-subdev.h>
  17. #include "fimc-core.h"
  18. #include "fimc-lite.h"
  19. #include "mipi-csis.h"
  20. /* Group IDs of sensor, MIPI-CSIS, FIMC-LITE and the writeback subdevs. */
  21. #define GRP_ID_SENSOR (1 << 8)
  22. #define GRP_ID_FIMC_IS_SENSOR (1 << 9)
  23. #define GRP_ID_WRITEBACK (1 << 10)
  24. #define GRP_ID_CSIS (1 << 11)
  25. #define GRP_ID_FIMC (1 << 12)
  26. #define GRP_ID_FLITE (1 << 13)
  27. #define GRP_ID_FIMC_IS (1 << 14)
  28. #define FIMC_MAX_SENSORS 8
  29. #define FIMC_MAX_CAMCLKS 2
  30. struct fimc_csis_info {
  31. struct v4l2_subdev *sd;
  32. int id;
  33. };
  34. struct fimc_camclk_info {
  35. struct clk *clock;
  36. int use_count;
  37. unsigned long frequency;
  38. };
  39. /**
  40. * struct fimc_sensor_info - image data source subdev information
  41. * @pdata: sensor's atrributes passed as media device's platform data
  42. * @subdev: image sensor v4l2 subdev
  43. * @host: fimc device the sensor is currently linked to
  44. *
  45. * This data structure applies to image sensor and the writeback subdevs.
  46. */
  47. struct fimc_sensor_info {
  48. struct fimc_source_info pdata;
  49. struct v4l2_subdev *subdev;
  50. struct fimc_dev *host;
  51. };
  52. /**
  53. * struct fimc_md - fimc media device information
  54. * @csis: MIPI CSIS subdevs data
  55. * @sensor: array of registered sensor subdevs
  56. * @num_sensors: actual number of registered sensors
  57. * @camclk: external sensor clock information
  58. * @fimc: array of registered fimc devices
  59. * @media_dev: top level media device
  60. * @v4l2_dev: top level v4l2_device holding up the subdevs
  61. * @pdev: platform device this media device is hooked up into
  62. * @user_subdev_api: true if subdevs are not configured by the host driver
  63. * @slock: spinlock protecting @sensor array
  64. */
  65. struct fimc_md {
  66. struct fimc_csis_info csis[CSIS_MAX_ENTITIES];
  67. struct fimc_sensor_info sensor[FIMC_MAX_SENSORS];
  68. int num_sensors;
  69. struct fimc_camclk_info camclk[FIMC_MAX_CAMCLKS];
  70. struct fimc_lite *fimc_lite[FIMC_LITE_MAX_DEVS];
  71. struct fimc_dev *fimc[FIMC_MAX_DEVS];
  72. struct media_device media_dev;
  73. struct v4l2_device v4l2_dev;
  74. struct platform_device *pdev;
  75. bool user_subdev_api;
  76. spinlock_t slock;
  77. };
  78. #define is_subdev_pad(pad) (pad == NULL || \
  79. media_entity_type(pad->entity) == MEDIA_ENT_T_V4L2_SUBDEV)
  80. #define me_subtype(me) \
  81. ((me->type) & (MEDIA_ENT_TYPE_MASK | MEDIA_ENT_SUBTYPE_MASK))
  82. #define subdev_has_devnode(__sd) (__sd->flags & V4L2_SUBDEV_FL_HAS_DEVNODE)
  83. static inline struct fimc_md *entity_to_fimc_mdev(struct media_entity *me)
  84. {
  85. return me->parent == NULL ? NULL :
  86. container_of(me->parent, struct fimc_md, media_dev);
  87. }
  88. static inline void fimc_md_graph_lock(struct fimc_dev *fimc)
  89. {
  90. mutex_lock(&fimc->vid_cap.vfd.entity.parent->graph_mutex);
  91. }
  92. static inline void fimc_md_graph_unlock(struct fimc_dev *fimc)
  93. {
  94. mutex_unlock(&fimc->vid_cap.vfd.entity.parent->graph_mutex);
  95. }
  96. int fimc_md_set_camclk(struct v4l2_subdev *sd, bool on);
  97. #endif