v4l2-mediabus.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. /* Which signal polarities it supports */
  23. /* Note: in BT.656 mode HSYNC and VSYNC are unused */
  24. #define V4L2_MBUS_HSYNC_ACTIVE_HIGH (1 << 2)
  25. #define V4L2_MBUS_HSYNC_ACTIVE_LOW (1 << 3)
  26. #define V4L2_MBUS_VSYNC_ACTIVE_HIGH (1 << 4)
  27. #define V4L2_MBUS_VSYNC_ACTIVE_LOW (1 << 5)
  28. #define V4L2_MBUS_PCLK_SAMPLE_RISING (1 << 6)
  29. #define V4L2_MBUS_PCLK_SAMPLE_FALLING (1 << 7)
  30. #define V4L2_MBUS_DATA_ACTIVE_HIGH (1 << 8)
  31. #define V4L2_MBUS_DATA_ACTIVE_LOW (1 << 9)
  32. /* Serial flags */
  33. /* How many lanes the client can use */
  34. #define V4L2_MBUS_CSI2_1_LANE (1 << 0)
  35. #define V4L2_MBUS_CSI2_2_LANE (1 << 1)
  36. #define V4L2_MBUS_CSI2_3_LANE (1 << 2)
  37. #define V4L2_MBUS_CSI2_4_LANE (1 << 3)
  38. /* On which channels it can send video data */
  39. #define V4L2_MBUS_CSI2_CHANNEL_0 (1 << 4)
  40. #define V4L2_MBUS_CSI2_CHANNEL_1 (1 << 5)
  41. #define V4L2_MBUS_CSI2_CHANNEL_2 (1 << 6)
  42. #define V4L2_MBUS_CSI2_CHANNEL_3 (1 << 7)
  43. /* Does it support only continuous or also non-continuous clock mode */
  44. #define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK (1 << 8)
  45. #define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK (1 << 9)
  46. #define V4L2_MBUS_CSI2_LANES (V4L2_MBUS_CSI2_1_LANE | V4L2_MBUS_CSI2_2_LANE | \
  47. V4L2_MBUS_CSI2_3_LANE | V4L2_MBUS_CSI2_4_LANE)
  48. #define V4L2_MBUS_CSI2_CHANNELS (V4L2_MBUS_CSI2_CHANNEL_0 | V4L2_MBUS_CSI2_CHANNEL_1 | \
  49. V4L2_MBUS_CSI2_CHANNEL_2 | V4L2_MBUS_CSI2_CHANNEL_3)
  50. /**
  51. * v4l2_mbus_type - media bus type
  52. * @V4L2_MBUS_PARALLEL: parallel interface with hsync and vsync
  53. * @V4L2_MBUS_BT656: parallel interface with embedded synchronisation, can
  54. * also be used for BT.1120
  55. * @V4L2_MBUS_CSI2: MIPI CSI-2 serial interface
  56. */
  57. enum v4l2_mbus_type {
  58. V4L2_MBUS_PARALLEL,
  59. V4L2_MBUS_BT656,
  60. V4L2_MBUS_CSI2,
  61. };
  62. /**
  63. * v4l2_mbus_config - media bus configuration
  64. * @type: in: interface type
  65. * @flags: in / out: configuration flags, depending on @type
  66. */
  67. struct v4l2_mbus_config {
  68. enum v4l2_mbus_type type;
  69. unsigned int flags;
  70. };
  71. static inline void v4l2_fill_pix_format(struct v4l2_pix_format *pix_fmt,
  72. const struct v4l2_mbus_framefmt *mbus_fmt)
  73. {
  74. pix_fmt->width = mbus_fmt->width;
  75. pix_fmt->height = mbus_fmt->height;
  76. pix_fmt->field = mbus_fmt->field;
  77. pix_fmt->colorspace = mbus_fmt->colorspace;
  78. }
  79. static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt,
  80. const struct v4l2_pix_format *pix_fmt,
  81. enum v4l2_mbus_pixelcode code)
  82. {
  83. mbus_fmt->width = pix_fmt->width;
  84. mbus_fmt->height = pix_fmt->height;
  85. mbus_fmt->field = pix_fmt->field;
  86. mbus_fmt->colorspace = pix_fmt->colorspace;
  87. mbus_fmt->code = code;
  88. }
  89. #endif