v4l2-mediabus.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * Media Bus API header
  3. *
  4. * Copyright (C) 2009, Guennadi Liakhovetski <g.liakhovetski@gmx.de>
  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 V4L2_MEDIABUS_H
  11. #define V4L2_MEDIABUS_H
  12. #include <linux/v4l2-mediabus.h>
  13. /* Parallel flags */
  14. /*
  15. * Can the client run in master or in slave mode. By "Master mode" an operation
  16. * mode is meant, when the client (e.g., a camera sensor) is producing
  17. * horizontal and vertical synchronisation. In "Slave mode" the host is
  18. * providing these signals to the slave.
  19. */
  20. #define V4L2_MBUS_MASTER (1 << 0)
  21. #define V4L2_MBUS_SLAVE (1 << 1)
  22. /*
  23. * Signal polarity flags
  24. * Note: in BT.656 mode HSYNC, FIELD, and VSYNC are unused
  25. * V4L2_MBUS_[HV]SYNC* flags should be also used for specifying
  26. * configuration of hardware that uses [HV]REF signals
  27. */
  28. #define V4L2_MBUS_HSYNC_ACTIVE_HIGH (1 << 2)
  29. #define V4L2_MBUS_HSYNC_ACTIVE_LOW (1 << 3)
  30. #define V4L2_MBUS_VSYNC_ACTIVE_HIGH (1 << 4)
  31. #define V4L2_MBUS_VSYNC_ACTIVE_LOW (1 << 5)
  32. #define V4L2_MBUS_PCLK_SAMPLE_RISING (1 << 6)
  33. #define V4L2_MBUS_PCLK_SAMPLE_FALLING (1 << 7)
  34. #define V4L2_MBUS_DATA_ACTIVE_HIGH (1 << 8)
  35. #define V4L2_MBUS_DATA_ACTIVE_LOW (1 << 9)
  36. /* FIELD = 0/1 - Field1 (odd)/Field2 (even) */
  37. #define V4L2_MBUS_FIELD_EVEN_HIGH (1 << 10)
  38. /* FIELD = 1/0 - Field1 (odd)/Field2 (even) */
  39. #define V4L2_MBUS_FIELD_EVEN_LOW (1 << 11)
  40. /* Active state of Sync-on-green (SoG) signal, 0/1 for LOW/HIGH respectively. */
  41. #define V4L2_MBUS_VIDEO_SOG_ACTIVE_HIGH (1 << 12)
  42. #define V4L2_MBUS_VIDEO_SOG_ACTIVE_LOW (1 << 13)
  43. /* Serial flags */
  44. /* How many lanes the client can use */
  45. #define V4L2_MBUS_CSI2_1_LANE (1 << 0)
  46. #define V4L2_MBUS_CSI2_2_LANE (1 << 1)
  47. #define V4L2_MBUS_CSI2_3_LANE (1 << 2)
  48. #define V4L2_MBUS_CSI2_4_LANE (1 << 3)
  49. /* On which channels it can send video data */
  50. #define V4L2_MBUS_CSI2_CHANNEL_0 (1 << 4)
  51. #define V4L2_MBUS_CSI2_CHANNEL_1 (1 << 5)
  52. #define V4L2_MBUS_CSI2_CHANNEL_2 (1 << 6)
  53. #define V4L2_MBUS_CSI2_CHANNEL_3 (1 << 7)
  54. /* Does it support only continuous or also non-continuous clock mode */
  55. #define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK (1 << 8)
  56. #define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK (1 << 9)
  57. #define V4L2_MBUS_CSI2_LANES (V4L2_MBUS_CSI2_1_LANE | V4L2_MBUS_CSI2_2_LANE | \
  58. V4L2_MBUS_CSI2_3_LANE | V4L2_MBUS_CSI2_4_LANE)
  59. #define V4L2_MBUS_CSI2_CHANNELS (V4L2_MBUS_CSI2_CHANNEL_0 | V4L2_MBUS_CSI2_CHANNEL_1 | \
  60. V4L2_MBUS_CSI2_CHANNEL_2 | V4L2_MBUS_CSI2_CHANNEL_3)
  61. /**
  62. * enum v4l2_mbus_type - media bus type
  63. * @V4L2_MBUS_PARALLEL: parallel interface with hsync and vsync
  64. * @V4L2_MBUS_BT656: parallel interface with embedded synchronisation, can
  65. * also be used for BT.1120
  66. * @V4L2_MBUS_CSI2: MIPI CSI-2 serial interface
  67. */
  68. enum v4l2_mbus_type {
  69. V4L2_MBUS_PARALLEL,
  70. V4L2_MBUS_BT656,
  71. V4L2_MBUS_CSI2,
  72. };
  73. /**
  74. * struct v4l2_mbus_config - media bus configuration
  75. * @type: in: interface type
  76. * @flags: in / out: configuration flags, depending on @type
  77. */
  78. struct v4l2_mbus_config {
  79. enum v4l2_mbus_type type;
  80. unsigned int flags;
  81. };
  82. static inline void v4l2_fill_pix_format(struct v4l2_pix_format *pix_fmt,
  83. const struct v4l2_mbus_framefmt *mbus_fmt)
  84. {
  85. pix_fmt->width = mbus_fmt->width;
  86. pix_fmt->height = mbus_fmt->height;
  87. pix_fmt->field = mbus_fmt->field;
  88. pix_fmt->colorspace = mbus_fmt->colorspace;
  89. pix_fmt->ycbcr_enc = mbus_fmt->ycbcr_enc;
  90. pix_fmt->quantization = mbus_fmt->quantization;
  91. pix_fmt->xfer_func = mbus_fmt->xfer_func;
  92. }
  93. static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt,
  94. const struct v4l2_pix_format *pix_fmt,
  95. u32 code)
  96. {
  97. mbus_fmt->width = pix_fmt->width;
  98. mbus_fmt->height = pix_fmt->height;
  99. mbus_fmt->field = pix_fmt->field;
  100. mbus_fmt->colorspace = pix_fmt->colorspace;
  101. mbus_fmt->ycbcr_enc = pix_fmt->ycbcr_enc;
  102. mbus_fmt->quantization = pix_fmt->quantization;
  103. mbus_fmt->xfer_func = pix_fmt->xfer_func;
  104. mbus_fmt->code = code;
  105. }
  106. #endif