soc_mediabus.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * SoC-camera Media Bus API extensions
  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 SOC_MEDIABUS_H
  11. #define SOC_MEDIABUS_H
  12. #include <linux/videodev2.h>
  13. #include <linux/v4l2-mediabus.h>
  14. /**
  15. * enum soc_mbus_packing - data packing types on the media-bus
  16. * @SOC_MBUS_PACKING_NONE: no packing, bit-for-bit transfer to RAM, one
  17. * sample represents one pixel
  18. * @SOC_MBUS_PACKING_2X8_PADHI: 16 bits transferred in 2 8-bit samples, in the
  19. * possibly incomplete byte high bits are padding
  20. * @SOC_MBUS_PACKING_2X8_PADLO: as above, but low bits are padding
  21. * @SOC_MBUS_PACKING_EXTEND16: sample width (e.g., 10 bits) has to be extended
  22. * to 16 bits
  23. * @SOC_MBUS_PACKING_VARIABLE: compressed formats with variable packing
  24. * @SOC_MBUS_PACKING_1_5X8: used for packed YUV 4:2:0 formats, where 4
  25. * pixels occupy 6 bytes in RAM
  26. * @SOC_MBUS_PACKING_EXTEND32: sample width (e.g., 24 bits) has to be extended
  27. * to 32 bits
  28. */
  29. enum soc_mbus_packing {
  30. SOC_MBUS_PACKING_NONE,
  31. SOC_MBUS_PACKING_2X8_PADHI,
  32. SOC_MBUS_PACKING_2X8_PADLO,
  33. SOC_MBUS_PACKING_EXTEND16,
  34. SOC_MBUS_PACKING_VARIABLE,
  35. SOC_MBUS_PACKING_1_5X8,
  36. SOC_MBUS_PACKING_EXTEND32,
  37. };
  38. /**
  39. * enum soc_mbus_order - sample order on the media bus
  40. * @SOC_MBUS_ORDER_LE: least significant sample first
  41. * @SOC_MBUS_ORDER_BE: most significant sample first
  42. */
  43. enum soc_mbus_order {
  44. SOC_MBUS_ORDER_LE,
  45. SOC_MBUS_ORDER_BE,
  46. };
  47. /**
  48. * enum soc_mbus_layout - planes layout in memory
  49. * @SOC_MBUS_LAYOUT_PACKED: color components packed
  50. * @SOC_MBUS_LAYOUT_PLANAR_2Y_U_V: YUV components stored in 3 planes (4:2:2)
  51. * @SOC_MBUS_LAYOUT_PLANAR_2Y_C: YUV components stored in a luma and a
  52. * chroma plane (C plane is half the size
  53. * of Y plane)
  54. * @SOC_MBUS_LAYOUT_PLANAR_Y_C: YUV components stored in a luma and a
  55. * chroma plane (C plane is the same size
  56. * as Y plane)
  57. */
  58. enum soc_mbus_layout {
  59. SOC_MBUS_LAYOUT_PACKED = 0,
  60. SOC_MBUS_LAYOUT_PLANAR_2Y_U_V,
  61. SOC_MBUS_LAYOUT_PLANAR_2Y_C,
  62. SOC_MBUS_LAYOUT_PLANAR_Y_C,
  63. };
  64. /**
  65. * struct soc_mbus_pixelfmt - Data format on the media bus
  66. * @name: Name of the format
  67. * @fourcc: Fourcc code, that will be obtained if the data is
  68. * stored in memory in the following way:
  69. * @packing: Type of sample-packing, that has to be used
  70. * @order: Sample order when storing in memory
  71. * @bits_per_sample: How many bits the bridge has to sample
  72. */
  73. struct soc_mbus_pixelfmt {
  74. const char *name;
  75. u32 fourcc;
  76. enum soc_mbus_packing packing;
  77. enum soc_mbus_order order;
  78. enum soc_mbus_layout layout;
  79. u8 bits_per_sample;
  80. };
  81. /**
  82. * struct soc_mbus_lookup - Lookup FOURCC IDs by mediabus codes for pass-through
  83. * @code: mediabus pixel-code
  84. * @fmt: pixel format description
  85. */
  86. struct soc_mbus_lookup {
  87. u32 code;
  88. struct soc_mbus_pixelfmt fmt;
  89. };
  90. const struct soc_mbus_pixelfmt *soc_mbus_find_fmtdesc(
  91. u32 code,
  92. const struct soc_mbus_lookup *lookup,
  93. int n);
  94. const struct soc_mbus_pixelfmt *soc_mbus_get_fmtdesc(
  95. u32 code);
  96. s32 soc_mbus_bytes_per_line(u32 width, const struct soc_mbus_pixelfmt *mf);
  97. s32 soc_mbus_image_size(const struct soc_mbus_pixelfmt *mf,
  98. u32 bytes_per_line, u32 height);
  99. int soc_mbus_samples_per_pixel(const struct soc_mbus_pixelfmt *mf,
  100. unsigned int *numerator, unsigned int *denominator);
  101. unsigned int soc_mbus_config_compatible(const struct v4l2_mbus_config *cfg,
  102. unsigned int flags);
  103. #endif