v4l2-of.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 <media/v4l2-mediabus.h>
  20. struct device_node;
  21. /**
  22. * struct v4l2_of_bus_mipi_csi2 - MIPI CSI-2 bus data structure
  23. * @flags: media bus (V4L2_MBUS_*) flags
  24. * @data_lanes: an array of physical data lane indexes
  25. * @clock_lane: physical lane index of the clock lane
  26. * @num_data_lanes: number of data lanes
  27. */
  28. struct v4l2_of_bus_mipi_csi2 {
  29. unsigned int flags;
  30. unsigned char data_lanes[4];
  31. unsigned char clock_lane;
  32. unsigned short num_data_lanes;
  33. };
  34. /**
  35. * struct v4l2_of_bus_parallel - parallel data bus data structure
  36. * @flags: media bus (V4L2_MBUS_*) flags
  37. * @bus_width: bus width in bits
  38. * @data_shift: data shift in bits
  39. */
  40. struct v4l2_of_bus_parallel {
  41. unsigned int flags;
  42. unsigned char bus_width;
  43. unsigned char data_shift;
  44. };
  45. /**
  46. * struct v4l2_of_endpoint - the endpoint data structure
  47. * @port: identifier (value of reg property) of a port this endpoint belongs to
  48. * @id: identifier (value of reg property) of this endpoint
  49. * @local_node: pointer to device_node of this endpoint
  50. * @remote: phandle to remote endpoint node
  51. * @bus_type: bus type
  52. * @bus: bus configuration data structure
  53. * @head: list head for this structure
  54. */
  55. struct v4l2_of_endpoint {
  56. unsigned int port;
  57. unsigned int id;
  58. const struct device_node *local_node;
  59. const __be32 *remote;
  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. struct list_head head;
  66. };
  67. #ifdef CONFIG_OF
  68. void v4l2_of_parse_endpoint(const struct device_node *node,
  69. struct v4l2_of_endpoint *link);
  70. struct device_node *v4l2_of_get_next_endpoint(const struct device_node *parent,
  71. struct device_node *previous);
  72. struct device_node *v4l2_of_get_remote_port_parent(
  73. const struct device_node *node);
  74. struct device_node *v4l2_of_get_remote_port(const struct device_node *node);
  75. #else /* CONFIG_OF */
  76. static inline int v4l2_of_parse_endpoint(const struct device_node *node,
  77. struct v4l2_of_endpoint *link)
  78. {
  79. return -ENOSYS;
  80. }
  81. static inline struct device_node *v4l2_of_get_next_endpoint(
  82. const struct device_node *parent,
  83. struct device_node *previous)
  84. {
  85. return NULL;
  86. }
  87. static inline struct device_node *v4l2_of_get_remote_port_parent(
  88. const struct device_node *node)
  89. {
  90. return NULL;
  91. }
  92. static inline struct device_node *v4l2_of_get_remote_port(
  93. const struct device_node *node)
  94. {
  95. return NULL;
  96. }
  97. #endif /* CONFIG_OF */
  98. #endif /* _V4L2_OF_H */