v4l2-mediabus.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. /* Serial flags */
  41. /* How many lanes the client can use */
  42. #define V4L2_MBUS_CSI2_1_LANE (1 << 0)
  43. #define V4L2_MBUS_CSI2_2_LANE (1 << 1)
  44. #define V4L2_MBUS_CSI2_3_LANE (1 << 2)
  45. #define V4L2_MBUS_CSI2_4_LANE (1 << 3)
  46. /* On which channels it can send video data */
  47. #define V4L2_MBUS_CSI2_CHANNEL_0 (1 << 4)
  48. #define V4L2_MBUS_CSI2_CHANNEL_1 (1 << 5)
  49. #define V4L2_MBUS_CSI2_CHANNEL_2 (1 << 6)
  50. #define V4L2_MBUS_CSI2_CHANNEL_3 (1 << 7)
  51. /* Does it support only continuous or also non-continuous clock mode */
  52. #define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK (1 << 8)
  53. #define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK (1 << 9)
  54. #define V4L2_MBUS_CSI2_LANES (V4L2_MBUS_CSI2_1_LANE | V4L2_MBUS_CSI2_2_LANE | \
  55. V4L2_MBUS_CSI2_3_LANE | V4L2_MBUS_CSI2_4_LANE)
  56. #define V4L2_MBUS_CSI2_CHANNELS (V4L2_MBUS_CSI2_CHANNEL_0 | V4L2_MBUS_CSI2_CHANNEL_1 | \
  57. V4L2_MBUS_CSI2_CHANNEL_2 | V4L2_MBUS_CSI2_CHANNEL_3)
  58. /**
  59. * v4l2_mbus_type - media bus type
  60. * @V4L2_MBUS_PARALLEL: parallel interface with hsync and vsync
  61. * @V4L2_MBUS_BT656: parallel interface with embedded synchronisation, can
  62. * also be used for BT.1120
  63. * @V4L2_MBUS_CSI2: MIPI CSI-2 serial interface
  64. */
  65. enum v4l2_mbus_type {
  66. V4L2_MBUS_PARALLEL,
  67. V4L2_MBUS_BT656,
  68. V4L2_MBUS_CSI2,
  69. };
  70. /**
  71. * v4l2_mbus_config - media bus configuration
  72. * @type: in: interface type
  73. * @flags: in / out: configuration flags, depending on @type
  74. */
  75. struct v4l2_mbus_config {
  76. enum v4l2_mbus_type type;
  77. unsigned int flags;
  78. };
  79. static inline void v4l2_fill_pix_format(struct v4l2_pix_format *pix_fmt,
  80. const struct v4l2_mbus_framefmt *mbus_fmt)
  81. {
  82. pix_fmt->width = mbus_fmt->width;
  83. pix_fmt->height = mbus_fmt->height;
  84. pix_fmt->field = mbus_fmt->field;
  85. pix_fmt->colorspace = mbus_fmt->colorspace;
  86. }
  87. static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt,
  88. const struct v4l2_pix_format *pix_fmt,
  89. enum v4l2_mbus_pixelcode code)
  90. {
  91. mbus_fmt->width = pix_fmt->width;
  92. mbus_fmt->height = pix_fmt->height;
  93. mbus_fmt->field = pix_fmt->field;
  94. mbus_fmt->colorspace = pix_fmt->colorspace;
  95. mbus_fmt->code = code;
  96. }
  97. #endif