exynos-fimc.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. * Samsung S5P/Exynos4 SoC series camera interface driver header
  3. *
  4. * Copyright (C) 2010 - 2013 Samsung Electronics Co., Ltd.
  5. * Sylwester Nawrocki <s.nawrocki@samsung.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #ifndef S5P_FIMC_H_
  12. #define S5P_FIMC_H_
  13. #include <media/media-entity.h>
  14. #include <media/v4l2-dev.h>
  15. #include <media/v4l2-mediabus.h>
  16. /*
  17. * Enumeration of data inputs to the camera subsystem.
  18. */
  19. enum fimc_input {
  20. FIMC_INPUT_PARALLEL_0 = 1,
  21. FIMC_INPUT_PARALLEL_1,
  22. FIMC_INPUT_MIPI_CSI2_0 = 3,
  23. FIMC_INPUT_MIPI_CSI2_1,
  24. FIMC_INPUT_WRITEBACK_A = 5,
  25. FIMC_INPUT_WRITEBACK_B,
  26. FIMC_INPUT_WRITEBACK_ISP = 5,
  27. };
  28. /*
  29. * Enumeration of the FIMC data bus types.
  30. */
  31. enum fimc_bus_type {
  32. /* Camera parallel bus */
  33. FIMC_BUS_TYPE_ITU_601 = 1,
  34. /* Camera parallel bus with embedded synchronization */
  35. FIMC_BUS_TYPE_ITU_656,
  36. /* Camera MIPI-CSI2 serial bus */
  37. FIMC_BUS_TYPE_MIPI_CSI2,
  38. /* FIFO link from LCD controller (WriteBack A) */
  39. FIMC_BUS_TYPE_LCD_WRITEBACK_A,
  40. /* FIFO link from LCD controller (WriteBack B) */
  41. FIMC_BUS_TYPE_LCD_WRITEBACK_B,
  42. /* FIFO link from FIMC-IS */
  43. FIMC_BUS_TYPE_ISP_WRITEBACK = FIMC_BUS_TYPE_LCD_WRITEBACK_B,
  44. };
  45. #define fimc_input_is_parallel(x) ((x) == 1 || (x) == 2)
  46. #define fimc_input_is_mipi_csi(x) ((x) == 3 || (x) == 4)
  47. /*
  48. * The subdevices' group IDs.
  49. */
  50. #define GRP_ID_SENSOR (1 << 8)
  51. #define GRP_ID_FIMC_IS_SENSOR (1 << 9)
  52. #define GRP_ID_WRITEBACK (1 << 10)
  53. #define GRP_ID_CSIS (1 << 11)
  54. #define GRP_ID_FIMC (1 << 12)
  55. #define GRP_ID_FLITE (1 << 13)
  56. #define GRP_ID_FIMC_IS (1 << 14)
  57. /**
  58. * struct fimc_source_info - video source description required for the host
  59. * interface configuration
  60. *
  61. * @fimc_bus_type: FIMC camera input type
  62. * @sensor_bus_type: image sensor bus type, MIPI, ITU-R BT.601 etc.
  63. * @flags: the parallel sensor bus flags defining signals polarity (V4L2_MBUS_*)
  64. * @mux_id: FIMC camera interface multiplexer index (separate for MIPI and ITU)
  65. */
  66. struct fimc_source_info {
  67. enum fimc_bus_type fimc_bus_type;
  68. enum fimc_bus_type sensor_bus_type;
  69. u16 flags;
  70. u16 mux_id;
  71. };
  72. /*
  73. * v4l2_device notification id. This is only for internal use in the kernel.
  74. * Sensor subdevs should issue S5P_FIMC_TX_END_NOTIFY notification in single
  75. * frame capture mode when there is only one VSYNC pulse issued by the sensor
  76. * at begining of the frame transmission.
  77. */
  78. #define S5P_FIMC_TX_END_NOTIFY _IO('e', 0)
  79. #define FIMC_MAX_PLANES 3
  80. /**
  81. * struct fimc_fmt - color format data structure
  82. * @mbus_code: media bus pixel code, -1 if not applicable
  83. * @name: format description
  84. * @fourcc: fourcc code for this format, 0 if not applicable
  85. * @color: the driver's private color format id
  86. * @memplanes: number of physically non-contiguous data planes
  87. * @colplanes: number of physically contiguous data planes
  88. * @colorspace: v4l2 colorspace (V4L2_COLORSPACE_*)
  89. * @depth: per plane driver's private 'number of bits per pixel'
  90. * @mdataplanes: bitmask indicating meta data plane(s), (1 << plane_no)
  91. * @flags: flags indicating which operation mode format applies to
  92. */
  93. struct fimc_fmt {
  94. u32 mbus_code;
  95. char *name;
  96. u32 fourcc;
  97. u32 color;
  98. u16 memplanes;
  99. u16 colplanes;
  100. u8 colorspace;
  101. u8 depth[FIMC_MAX_PLANES];
  102. u16 mdataplanes;
  103. u16 flags;
  104. #define FMT_FLAGS_CAM (1 << 0)
  105. #define FMT_FLAGS_M2M_IN (1 << 1)
  106. #define FMT_FLAGS_M2M_OUT (1 << 2)
  107. #define FMT_FLAGS_M2M (1 << 1 | 1 << 2)
  108. #define FMT_HAS_ALPHA (1 << 3)
  109. #define FMT_FLAGS_COMPRESSED (1 << 4)
  110. #define FMT_FLAGS_WRITEBACK (1 << 5)
  111. #define FMT_FLAGS_RAW_BAYER (1 << 6)
  112. #define FMT_FLAGS_YUV (1 << 7)
  113. };
  114. struct exynos_media_pipeline;
  115. /*
  116. * Media pipeline operations to be called from within a video node, i.e. the
  117. * last entity within the pipeline. Implemented by related media device driver.
  118. */
  119. struct exynos_media_pipeline_ops {
  120. int (*prepare)(struct exynos_media_pipeline *p,
  121. struct media_entity *me);
  122. int (*unprepare)(struct exynos_media_pipeline *p);
  123. int (*open)(struct exynos_media_pipeline *p, struct media_entity *me,
  124. bool resume);
  125. int (*close)(struct exynos_media_pipeline *p);
  126. int (*set_stream)(struct exynos_media_pipeline *p, bool state);
  127. };
  128. struct exynos_video_entity {
  129. struct video_device vdev;
  130. struct exynos_media_pipeline *pipe;
  131. };
  132. struct exynos_media_pipeline {
  133. struct media_pipeline mp;
  134. const struct exynos_media_pipeline_ops *ops;
  135. };
  136. static inline struct exynos_video_entity *vdev_to_exynos_video_entity(
  137. struct video_device *vdev)
  138. {
  139. return container_of(vdev, struct exynos_video_entity, vdev);
  140. }
  141. #define fimc_pipeline_call(ent, op, args...) \
  142. (!(ent) ? -ENOENT : (((ent)->pipe->ops && (ent)->pipe->ops->op) ? \
  143. (ent)->pipe->ops->op(((ent)->pipe), ##args) : -ENOIOCTLCMD)) \
  144. #endif /* S5P_FIMC_H_ */