camss-vfe.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * camss-vfe.h
  4. *
  5. * Qualcomm MSM Camera Subsystem - VFE (Video Front End) Module
  6. *
  7. * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
  8. * Copyright (C) 2015-2018 Linaro Ltd.
  9. */
  10. #ifndef QC_MSM_CAMSS_VFE_H
  11. #define QC_MSM_CAMSS_VFE_H
  12. #include <linux/clk.h>
  13. #include <linux/spinlock_types.h>
  14. #include <media/media-entity.h>
  15. #include <media/v4l2-device.h>
  16. #include <media/v4l2-subdev.h>
  17. #include "camss-video.h"
  18. #define MSM_VFE_PAD_SINK 0
  19. #define MSM_VFE_PAD_SRC 1
  20. #define MSM_VFE_PADS_NUM 2
  21. #define MSM_VFE_LINE_NUM 4
  22. #define MSM_VFE_IMAGE_MASTERS_NUM 7
  23. #define MSM_VFE_COMPOSITE_IRQ_NUM 4
  24. enum vfe_output_state {
  25. VFE_OUTPUT_OFF,
  26. VFE_OUTPUT_RESERVED,
  27. VFE_OUTPUT_SINGLE,
  28. VFE_OUTPUT_CONTINUOUS,
  29. VFE_OUTPUT_IDLE,
  30. VFE_OUTPUT_STOPPING
  31. };
  32. enum vfe_line_id {
  33. VFE_LINE_NONE = -1,
  34. VFE_LINE_RDI0 = 0,
  35. VFE_LINE_RDI1 = 1,
  36. VFE_LINE_RDI2 = 2,
  37. VFE_LINE_PIX = 3
  38. };
  39. struct vfe_output {
  40. u8 wm_num;
  41. u8 wm_idx[3];
  42. int active_buf;
  43. struct camss_buffer *buf[2];
  44. struct camss_buffer *last_buffer;
  45. struct list_head pending_bufs;
  46. unsigned int drop_update_idx;
  47. enum vfe_output_state state;
  48. unsigned int sequence;
  49. int wait_sof;
  50. int wait_reg_update;
  51. struct completion sof;
  52. struct completion reg_update;
  53. };
  54. struct vfe_line {
  55. enum vfe_line_id id;
  56. struct v4l2_subdev subdev;
  57. struct media_pad pads[MSM_VFE_PADS_NUM];
  58. struct v4l2_mbus_framefmt fmt[MSM_VFE_PADS_NUM];
  59. struct v4l2_rect compose;
  60. struct v4l2_rect crop;
  61. struct camss_video video_out;
  62. struct vfe_output output;
  63. const struct vfe_format *formats;
  64. unsigned int nformats;
  65. };
  66. struct vfe_device;
  67. struct vfe_hw_ops {
  68. void (*hw_version_read)(struct vfe_device *vfe, struct device *dev);
  69. u16 (*get_ub_size)(u8 vfe_id);
  70. void (*global_reset)(struct vfe_device *vfe);
  71. void (*halt_request)(struct vfe_device *vfe);
  72. void (*halt_clear)(struct vfe_device *vfe);
  73. void (*wm_enable)(struct vfe_device *vfe, u8 wm, u8 enable);
  74. void (*wm_frame_based)(struct vfe_device *vfe, u8 wm, u8 enable);
  75. void (*wm_line_based)(struct vfe_device *vfe, u32 wm,
  76. struct v4l2_pix_format_mplane *pix,
  77. u8 plane, u32 enable);
  78. void (*wm_set_framedrop_period)(struct vfe_device *vfe, u8 wm, u8 per);
  79. void (*wm_set_framedrop_pattern)(struct vfe_device *vfe, u8 wm,
  80. u32 pattern);
  81. void (*wm_set_ub_cfg)(struct vfe_device *vfe, u8 wm, u16 offset,
  82. u16 depth);
  83. void (*bus_reload_wm)(struct vfe_device *vfe, u8 wm);
  84. void (*wm_set_ping_addr)(struct vfe_device *vfe, u8 wm, u32 addr);
  85. void (*wm_set_pong_addr)(struct vfe_device *vfe, u8 wm, u32 addr);
  86. int (*wm_get_ping_pong_status)(struct vfe_device *vfe, u8 wm);
  87. void (*bus_enable_wr_if)(struct vfe_device *vfe, u8 enable);
  88. void (*bus_connect_wm_to_rdi)(struct vfe_device *vfe, u8 wm,
  89. enum vfe_line_id id);
  90. void (*wm_set_subsample)(struct vfe_device *vfe, u8 wm);
  91. void (*bus_disconnect_wm_from_rdi)(struct vfe_device *vfe, u8 wm,
  92. enum vfe_line_id id);
  93. void (*set_xbar_cfg)(struct vfe_device *vfe, struct vfe_output *output,
  94. u8 enable);
  95. void (*set_rdi_cid)(struct vfe_device *vfe, enum vfe_line_id id,
  96. u8 cid);
  97. void (*set_realign_cfg)(struct vfe_device *vfe, struct vfe_line *line,
  98. u8 enable);
  99. void (*reg_update)(struct vfe_device *vfe, enum vfe_line_id line_id);
  100. void (*reg_update_clear)(struct vfe_device *vfe,
  101. enum vfe_line_id line_id);
  102. void (*enable_irq_wm_line)(struct vfe_device *vfe, u8 wm,
  103. enum vfe_line_id line_id, u8 enable);
  104. void (*enable_irq_pix_line)(struct vfe_device *vfe, u8 comp,
  105. enum vfe_line_id line_id, u8 enable);
  106. void (*enable_irq_common)(struct vfe_device *vfe);
  107. void (*set_demux_cfg)(struct vfe_device *vfe, struct vfe_line *line);
  108. void (*set_scale_cfg)(struct vfe_device *vfe, struct vfe_line *line);
  109. void (*set_crop_cfg)(struct vfe_device *vfe, struct vfe_line *line);
  110. void (*set_clamp_cfg)(struct vfe_device *vfe);
  111. void (*set_qos)(struct vfe_device *vfe);
  112. void (*set_ds)(struct vfe_device *vfe);
  113. void (*set_cgc_override)(struct vfe_device *vfe, u8 wm, u8 enable);
  114. void (*set_camif_cfg)(struct vfe_device *vfe, struct vfe_line *line);
  115. void (*set_camif_cmd)(struct vfe_device *vfe, u8 enable);
  116. void (*set_module_cfg)(struct vfe_device *vfe, u8 enable);
  117. int (*camif_wait_for_stop)(struct vfe_device *vfe, struct device *dev);
  118. void (*isr_read)(struct vfe_device *vfe, u32 *value0, u32 *value1);
  119. void (*violation_read)(struct vfe_device *vfe);
  120. irqreturn_t (*isr)(int irq, void *dev);
  121. };
  122. struct vfe_isr_ops {
  123. void (*reset_ack)(struct vfe_device *vfe);
  124. void (*halt_ack)(struct vfe_device *vfe);
  125. void (*reg_update)(struct vfe_device *vfe, enum vfe_line_id line_id);
  126. void (*sof)(struct vfe_device *vfe, enum vfe_line_id line_id);
  127. void (*comp_done)(struct vfe_device *vfe, u8 comp);
  128. void (*wm_done)(struct vfe_device *vfe, u8 wm);
  129. };
  130. struct vfe_device {
  131. struct camss *camss;
  132. u8 id;
  133. void __iomem *base;
  134. u32 irq;
  135. char irq_name[30];
  136. struct camss_clock *clock;
  137. int nclocks;
  138. struct completion reset_complete;
  139. struct completion halt_complete;
  140. struct mutex power_lock;
  141. int power_count;
  142. struct mutex stream_lock;
  143. int stream_count;
  144. spinlock_t output_lock;
  145. enum vfe_line_id wm_output_map[MSM_VFE_IMAGE_MASTERS_NUM];
  146. struct vfe_line line[MSM_VFE_LINE_NUM];
  147. u32 reg_update;
  148. u8 was_streaming;
  149. const struct vfe_hw_ops *ops;
  150. struct vfe_isr_ops isr_ops;
  151. };
  152. struct resources;
  153. int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe,
  154. const struct resources *res, u8 id);
  155. int msm_vfe_register_entities(struct vfe_device *vfe,
  156. struct v4l2_device *v4l2_dev);
  157. void msm_vfe_unregister_entities(struct vfe_device *vfe);
  158. void msm_vfe_get_vfe_id(struct media_entity *entity, u8 *id);
  159. void msm_vfe_get_vfe_line_id(struct media_entity *entity, enum vfe_line_id *id);
  160. void msm_vfe_stop_streaming(struct vfe_device *vfe);
  161. extern const struct vfe_hw_ops vfe_ops_4_1;
  162. extern const struct vfe_hw_ops vfe_ops_4_7;
  163. #endif /* QC_MSM_CAMSS_VFE_H */