iss_csi2.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. * TI OMAP4 ISS V4L2 Driver - CSI2 module
  3. *
  4. * Copyright (C) 2012 Texas Instruments, Inc.
  5. *
  6. * Author: Sergio Aguirre <sergio.a.aguirre@gmail.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. */
  13. #ifndef OMAP4_ISS_CSI2_H
  14. #define OMAP4_ISS_CSI2_H
  15. #include <linux/types.h>
  16. #include <linux/videodev2.h>
  17. #include "iss_video.h"
  18. struct iss_csiphy;
  19. /* This is not an exhaustive list */
  20. enum iss_csi2_pix_formats {
  21. CSI2_PIX_FMT_OTHERS = 0,
  22. CSI2_PIX_FMT_YUV422_8BIT = 0x1e,
  23. CSI2_PIX_FMT_YUV422_8BIT_VP = 0x9e,
  24. CSI2_PIX_FMT_YUV422_8BIT_VP16 = 0xde,
  25. CSI2_PIX_FMT_RAW10_EXP16 = 0xab,
  26. CSI2_PIX_FMT_RAW10_EXP16_VP = 0x12f,
  27. CSI2_PIX_FMT_RAW8 = 0x2a,
  28. CSI2_PIX_FMT_RAW8_DPCM10_EXP16 = 0x2aa,
  29. CSI2_PIX_FMT_RAW8_DPCM10_VP = 0x32a,
  30. CSI2_PIX_FMT_RAW8_VP = 0x12a,
  31. CSI2_USERDEF_8BIT_DATA1_DPCM10_VP = 0x340,
  32. CSI2_USERDEF_8BIT_DATA1_DPCM10 = 0x2c0,
  33. CSI2_USERDEF_8BIT_DATA1 = 0x40,
  34. };
  35. enum iss_csi2_irqevents {
  36. OCP_ERR_IRQ = 0x4000,
  37. SHORT_PACKET_IRQ = 0x2000,
  38. ECC_CORRECTION_IRQ = 0x1000,
  39. ECC_NO_CORRECTION_IRQ = 0x800,
  40. COMPLEXIO2_ERR_IRQ = 0x400,
  41. COMPLEXIO1_ERR_IRQ = 0x200,
  42. FIFO_OVF_IRQ = 0x100,
  43. CONTEXT7 = 0x80,
  44. CONTEXT6 = 0x40,
  45. CONTEXT5 = 0x20,
  46. CONTEXT4 = 0x10,
  47. CONTEXT3 = 0x8,
  48. CONTEXT2 = 0x4,
  49. CONTEXT1 = 0x2,
  50. CONTEXT0 = 0x1,
  51. };
  52. enum iss_csi2_ctx_irqevents {
  53. CTX_ECC_CORRECTION = 0x100,
  54. CTX_LINE_NUMBER = 0x80,
  55. CTX_FRAME_NUMBER = 0x40,
  56. CTX_CS = 0x20,
  57. CTX_LE = 0x8,
  58. CTX_LS = 0x4,
  59. CTX_FE = 0x2,
  60. CTX_FS = 0x1,
  61. };
  62. enum iss_csi2_frame_mode {
  63. ISS_CSI2_FRAME_IMMEDIATE,
  64. ISS_CSI2_FRAME_AFTERFEC,
  65. };
  66. #define ISS_CSI2_MAX_CTX_NUM 7
  67. struct iss_csi2_ctx_cfg {
  68. u8 ctxnum; /* context number 0 - 7 */
  69. u8 dpcm_decompress;
  70. /* Fields in CSI2_CTx_CTRL2 - locked by CSI2_CTx_CTRL1.CTX_EN */
  71. u8 virtual_id;
  72. u16 format_id; /* as in CSI2_CTx_CTRL2[9:0] */
  73. u8 dpcm_predictor; /* 1: simple, 0: advanced */
  74. u16 frame;
  75. /* Fields in CSI2_CTx_CTRL1/3 - Shadowed */
  76. u16 alpha;
  77. u16 data_offset;
  78. u32 ping_addr;
  79. u32 pong_addr;
  80. u8 eof_enabled;
  81. u8 eol_enabled;
  82. u8 checksum_enabled;
  83. u8 enabled;
  84. };
  85. struct iss_csi2_timing_cfg {
  86. u8 ionum; /* IO1 or IO2 as in CSI2_TIMING */
  87. unsigned force_rx_mode:1;
  88. unsigned stop_state_16x:1;
  89. unsigned stop_state_4x:1;
  90. u16 stop_state_counter;
  91. };
  92. struct iss_csi2_ctrl_cfg {
  93. bool vp_clk_enable;
  94. bool vp_only_enable;
  95. u8 vp_out_ctrl;
  96. enum iss_csi2_frame_mode frame_mode;
  97. bool ecc_enable;
  98. bool if_enable;
  99. };
  100. #define CSI2_PAD_SINK 0
  101. #define CSI2_PAD_SOURCE 1
  102. #define CSI2_PADS_NUM 2
  103. #define CSI2_OUTPUT_IPIPEIF BIT(0)
  104. #define CSI2_OUTPUT_MEMORY BIT(1)
  105. struct iss_csi2_device {
  106. struct v4l2_subdev subdev;
  107. struct media_pad pads[CSI2_PADS_NUM];
  108. struct v4l2_mbus_framefmt formats[CSI2_PADS_NUM];
  109. struct iss_video video_out;
  110. struct iss_device *iss;
  111. u8 available; /* Is the IP present on the silicon? */
  112. /* memory resources, as defined in enum iss_mem_resources */
  113. unsigned int regs1;
  114. unsigned int regs2;
  115. /* ISP subclock, as defined in enum iss_isp_subclk_resource */
  116. unsigned int subclk;
  117. u32 output; /* output to IPIPEIF, memory or both? */
  118. bool dpcm_decompress;
  119. unsigned int frame_skip;
  120. struct iss_csiphy *phy;
  121. struct iss_csi2_ctx_cfg contexts[ISS_CSI2_MAX_CTX_NUM + 1];
  122. struct iss_csi2_timing_cfg timing[2];
  123. struct iss_csi2_ctrl_cfg ctrl;
  124. enum iss_pipeline_stream_state state;
  125. wait_queue_head_t wait;
  126. atomic_t stopping;
  127. };
  128. void omap4iss_csi2_isr(struct iss_csi2_device *csi2);
  129. int omap4iss_csi2_reset(struct iss_csi2_device *csi2);
  130. int omap4iss_csi2_init(struct iss_device *iss);
  131. void omap4iss_csi2_cleanup(struct iss_device *iss);
  132. void omap4iss_csi2_unregister_entities(struct iss_csi2_device *csi2);
  133. int omap4iss_csi2_register_entities(struct iss_csi2_device *csi2,
  134. struct v4l2_device *vdev);
  135. #endif /* OMAP4_ISS_CSI2_H */