v4l2-of.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. unsigned char num_channels;
  49. unsigned char pixmux;
  50. unsigned char channels[16];
  51. };
  52. /**
  53. * struct v4l2_of_endpoint - the endpoint data structure
  54. * @base: struct of_endpoint containing port, id, and local of_node
  55. * @bus_type: bus type
  56. * @bus: bus configuration data structure
  57. * @link_frequencies: array of supported link frequencies
  58. * @nr_of_link_frequencies: number of elements in link_frequenccies array
  59. */
  60. struct v4l2_of_endpoint {
  61. struct of_endpoint base;
  62. /* Fields below this line will be zeroed by v4l2_of_parse_endpoint() */
  63. enum v4l2_mbus_type bus_type;
  64. union {
  65. struct v4l2_of_bus_parallel parallel;
  66. struct v4l2_of_bus_mipi_csi2 mipi_csi2;
  67. } bus;
  68. u64 *link_frequencies;
  69. unsigned int nr_of_link_frequencies;
  70. };
  71. /**
  72. * struct v4l2_of_link - a link between two endpoints
  73. * @local_node: pointer to device_node of this endpoint
  74. * @local_port: identifier of the port this endpoint belongs to
  75. * @remote_node: pointer to device_node of the remote endpoint
  76. * @remote_port: identifier of the port the remote endpoint belongs to
  77. */
  78. struct v4l2_of_link {
  79. struct device_node *local_node;
  80. unsigned int local_port;
  81. struct device_node *remote_node;
  82. unsigned int remote_port;
  83. };
  84. #ifdef CONFIG_OF
  85. int v4l2_of_parse_endpoint(const struct device_node *node,
  86. struct v4l2_of_endpoint *endpoint);
  87. struct v4l2_of_endpoint *v4l2_of_alloc_parse_endpoint(
  88. const struct device_node *node);
  89. void v4l2_of_free_endpoint(struct v4l2_of_endpoint *endpoint);
  90. int v4l2_of_parse_link(const struct device_node *node,
  91. struct v4l2_of_link *link);
  92. void v4l2_of_put_link(struct v4l2_of_link *link);
  93. #else /* CONFIG_OF */
  94. static inline int v4l2_of_parse_endpoint(const struct device_node *node,
  95. struct v4l2_of_endpoint *link)
  96. {
  97. return -ENOSYS;
  98. }
  99. static inline struct v4l2_of_endpoint *v4l2_of_alloc_parse_endpoint(
  100. const struct device_node *node)
  101. {
  102. return NULL;
  103. }
  104. static inline void v4l2_of_free_endpoint(struct v4l2_of_endpoint *endpoint)
  105. {
  106. }
  107. static inline int v4l2_of_parse_link(const struct device_node *node,
  108. struct v4l2_of_link *link)
  109. {
  110. return -ENOSYS;
  111. }
  112. static inline void v4l2_of_put_link(struct v4l2_of_link *link)
  113. {
  114. }
  115. #endif /* CONFIG_OF */
  116. #endif /* _V4L2_OF_H */