v4l2-of.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * V4L2 OF binding parsing library
  3. *
  4. * Copyright (C) 2012 - 2013 Samsung Electronics Co., Ltd.
  5. * Author: Sylwester Nawrocki <s.nawrocki@samsung.com>
  6. *
  7. * Copyright (C) 2012 Renesas Electronics Corp.
  8. * Author: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of version 2 of the GNU General Public License as
  12. * published by the Free Software Foundation.
  13. */
  14. #ifndef _V4L2_OF_H
  15. #define _V4L2_OF_H
  16. #include <linux/list.h>
  17. #include <linux/types.h>
  18. #include <linux/errno.h>
  19. #include <linux/of_graph.h>
  20. #include <media/v4l2-mediabus.h>
  21. struct device_node;
  22. /**
  23. * struct v4l2_of_bus_mipi_csi2 - MIPI CSI-2 bus data structure
  24. * @flags: media bus (V4L2_MBUS_*) flags
  25. * @data_lanes: an array of physical data lane indexes
  26. * @clock_lane: physical lane index of the clock lane
  27. * @num_data_lanes: number of data lanes
  28. * @lane_polarities: polarity of the lanes. The order is the same of
  29. * the physical lanes.
  30. */
  31. struct v4l2_of_bus_mipi_csi2 {
  32. unsigned int flags;
  33. unsigned char data_lanes[4];
  34. unsigned char clock_lane;
  35. unsigned short num_data_lanes;
  36. bool lane_polarities[5];
  37. };
  38. /**
  39. * struct v4l2_of_bus_parallel - parallel data bus data structure
  40. * @flags: media bus (V4L2_MBUS_*) flags
  41. * @bus_width: bus width in bits
  42. * @data_shift: data shift in bits
  43. */
  44. struct v4l2_of_bus_parallel {
  45. unsigned int flags;
  46. unsigned char bus_width;
  47. unsigned char data_shift;
  48. };
  49. /**
  50. * struct v4l2_of_endpoint - the endpoint data structure
  51. * @base: struct of_endpoint containing port, id, and local of_node
  52. * @bus_type: bus type
  53. * @bus: bus configuration data structure
  54. * @link_frequencies: array of supported link frequencies
  55. * @nr_of_link_frequencies: number of elements in link_frequenccies array
  56. */
  57. struct v4l2_of_endpoint {
  58. struct of_endpoint base;
  59. /* Fields below this line will be zeroed by v4l2_of_parse_endpoint() */
  60. enum v4l2_mbus_type bus_type;
  61. union {
  62. struct v4l2_of_bus_parallel parallel;
  63. struct v4l2_of_bus_mipi_csi2 mipi_csi2;
  64. } bus;
  65. u64 *link_frequencies;
  66. unsigned int nr_of_link_frequencies;
  67. };
  68. /**
  69. * struct v4l2_of_link - a link between two endpoints
  70. * @local_node: pointer to device_node of this endpoint
  71. * @local_port: identifier of the port this endpoint belongs to
  72. * @remote_node: pointer to device_node of the remote endpoint
  73. * @remote_port: identifier of the port the remote endpoint belongs to
  74. */
  75. struct v4l2_of_link {
  76. struct device_node *local_node;
  77. unsigned int local_port;
  78. struct device_node *remote_node;
  79. unsigned int remote_port;
  80. };
  81. #ifdef CONFIG_OF
  82. int v4l2_of_parse_endpoint(const struct device_node *node,
  83. struct v4l2_of_endpoint *endpoint);
  84. struct v4l2_of_endpoint *v4l2_of_alloc_parse_endpoint(
  85. const struct device_node *node);
  86. void v4l2_of_free_endpoint(struct v4l2_of_endpoint *endpoint);
  87. int v4l2_of_parse_link(const struct device_node *node,
  88. struct v4l2_of_link *link);
  89. void v4l2_of_put_link(struct v4l2_of_link *link);
  90. #else /* CONFIG_OF */
  91. static inline int v4l2_of_parse_endpoint(const struct device_node *node,
  92. struct v4l2_of_endpoint *link)
  93. {
  94. return -ENOSYS;
  95. }
  96. static inline struct v4l2_of_endpoint *v4l2_of_alloc_parse_endpoint(
  97. const struct device_node *node)
  98. {
  99. return NULL;
  100. }
  101. static inline void v4l2_of_free_endpoint(struct v4l2_of_endpoint *endpoint)
  102. {
  103. }
  104. static inline int v4l2_of_parse_link(const struct device_node *node,
  105. struct v4l2_of_link *link)
  106. {
  107. return -ENOSYS;
  108. }
  109. static inline void v4l2_of_put_link(struct v4l2_of_link *link)
  110. {
  111. }
  112. #endif /* CONFIG_OF */
  113. #endif /* _V4L2_OF_H */