soc_mediabus.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. */
  27. enum soc_mbus_packing {
  28. SOC_MBUS_PACKING_NONE,
  29. SOC_MBUS_PACKING_2X8_PADHI,
  30. SOC_MBUS_PACKING_2X8_PADLO,
  31. SOC_MBUS_PACKING_EXTEND16,
  32. SOC_MBUS_PACKING_VARIABLE,
  33. SOC_MBUS_PACKING_1_5X8,
  34. };
  35. /**
  36. * enum soc_mbus_order - sample order on the media bus
  37. * @SOC_MBUS_ORDER_LE: least significant sample first
  38. * @SOC_MBUS_ORDER_BE: most significant sample first
  39. */
  40. enum soc_mbus_order {
  41. SOC_MBUS_ORDER_LE,
  42. SOC_MBUS_ORDER_BE,
  43. };
  44. /**
  45. * struct soc_mbus_pixelfmt - Data format on the media bus
  46. * @name: Name of the format
  47. * @fourcc: Fourcc code, that will be obtained if the data is
  48. * stored in memory in the following way:
  49. * @packing: Type of sample-packing, that has to be used
  50. * @order: Sample order when storing in memory
  51. * @bits_per_sample: How many bits the bridge has to sample
  52. */
  53. struct soc_mbus_pixelfmt {
  54. const char *name;
  55. u32 fourcc;
  56. enum soc_mbus_packing packing;
  57. enum soc_mbus_order order;
  58. u8 bits_per_sample;
  59. };
  60. /**
  61. * struct soc_mbus_lookup - Lookup FOURCC IDs by mediabus codes for pass-through
  62. * @code: mediabus pixel-code
  63. * @fmt: pixel format description
  64. */
  65. struct soc_mbus_lookup {
  66. enum v4l2_mbus_pixelcode code;
  67. struct soc_mbus_pixelfmt fmt;
  68. };
  69. const struct soc_mbus_pixelfmt *soc_mbus_find_fmtdesc(
  70. enum v4l2_mbus_pixelcode code,
  71. const struct soc_mbus_lookup *lookup,
  72. int n);
  73. const struct soc_mbus_pixelfmt *soc_mbus_get_fmtdesc(
  74. enum v4l2_mbus_pixelcode code);
  75. s32 soc_mbus_bytes_per_line(u32 width, const struct soc_mbus_pixelfmt *mf);
  76. int soc_mbus_samples_per_pixel(const struct soc_mbus_pixelfmt *mf,
  77. unsigned int *numerator, unsigned int *denominator);
  78. unsigned int soc_mbus_config_compatible(const struct v4l2_mbus_config *cfg,
  79. unsigned int flags);
  80. #endif