Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 206 lines 5.7 kB view raw
1/* SPDX-License-Identifier: GPL-2.0 */ 2#ifndef __DRM_OF_H__ 3#define __DRM_OF_H__ 4 5#include <linux/err.h> 6#include <linux/of_graph.h> 7#if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_DRM_PANEL_BRIDGE) 8#include <linux/of.h> 9#include <drm/drm_bridge.h> 10#endif 11 12struct component_master_ops; 13struct component_match; 14struct device; 15struct drm_device; 16struct drm_encoder; 17struct drm_panel; 18struct drm_bridge; 19struct device_node; 20struct mipi_dsi_device_info; 21struct mipi_dsi_host; 22 23/** 24 * enum drm_lvds_dual_link_pixels - Pixel order of an LVDS dual-link connection 25 * @DRM_LVDS_DUAL_LINK_EVEN_ODD_PIXELS: Even pixels are expected to be generated 26 * from the first port, odd pixels from the second port 27 * @DRM_LVDS_DUAL_LINK_ODD_EVEN_PIXELS: Odd pixels are expected to be generated 28 * from the first port, even pixels from the second port 29 */ 30enum drm_lvds_dual_link_pixels { 31 DRM_LVDS_DUAL_LINK_EVEN_ODD_PIXELS = 0, 32 DRM_LVDS_DUAL_LINK_ODD_EVEN_PIXELS = 1, 33}; 34 35#ifdef CONFIG_OF 36uint32_t drm_of_crtc_port_mask(struct drm_device *dev, 37 struct device_node *port); 38uint32_t drm_of_find_possible_crtcs(struct drm_device *dev, 39 struct device_node *port); 40void drm_of_component_match_add(struct device *master, 41 struct component_match **matchptr, 42 int (*compare)(struct device *, void *), 43 struct device_node *node); 44int drm_of_component_probe(struct device *dev, 45 int (*compare_of)(struct device *, void *), 46 const struct component_master_ops *m_ops); 47int drm_of_encoder_active_endpoint(struct device_node *node, 48 struct drm_encoder *encoder, 49 struct of_endpoint *endpoint); 50int drm_of_find_panel_or_bridge(const struct device_node *np, 51 int port, int endpoint, 52 struct drm_panel **panel, 53 struct drm_bridge **bridge); 54int drm_of_lvds_get_dual_link_pixel_order(const struct device_node *port1, 55 const struct device_node *port2); 56int drm_of_lvds_get_dual_link_pixel_order_sink(struct device_node *port1, 57 struct device_node *port2); 58int drm_of_lvds_get_data_mapping(const struct device_node *port); 59int drm_of_get_data_lanes_count(const struct device_node *endpoint, 60 const unsigned int min, const unsigned int max); 61int drm_of_get_data_lanes_count_ep(const struct device_node *port, 62 int port_reg, int reg, 63 const unsigned int min, 64 const unsigned int max); 65#else 66static inline uint32_t drm_of_crtc_port_mask(struct drm_device *dev, 67 struct device_node *port) 68{ 69 return 0; 70} 71 72static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev, 73 struct device_node *port) 74{ 75 return 0; 76} 77 78static inline void 79drm_of_component_match_add(struct device *master, 80 struct component_match **matchptr, 81 int (*compare)(struct device *, void *), 82 struct device_node *node) 83{ 84} 85 86static inline int 87drm_of_component_probe(struct device *dev, 88 int (*compare_of)(struct device *, void *), 89 const struct component_master_ops *m_ops) 90{ 91 return -EINVAL; 92} 93 94static inline int drm_of_encoder_active_endpoint(struct device_node *node, 95 struct drm_encoder *encoder, 96 struct of_endpoint *endpoint) 97{ 98 return -EINVAL; 99} 100static inline int drm_of_find_panel_or_bridge(const struct device_node *np, 101 int port, int endpoint, 102 struct drm_panel **panel, 103 struct drm_bridge **bridge) 104{ 105 return -EINVAL; 106} 107 108static inline int 109drm_of_lvds_get_dual_link_pixel_order(const struct device_node *port1, 110 const struct device_node *port2) 111{ 112 return -EINVAL; 113} 114 115static inline int 116drm_of_lvds_get_dual_link_pixel_order_sink(struct device_node *port1, 117 struct device_node *port2) 118{ 119 return -EINVAL; 120} 121 122static inline int 123drm_of_lvds_get_data_mapping(const struct device_node *port) 124{ 125 return -EINVAL; 126} 127 128static inline int 129drm_of_get_data_lanes_count(const struct device_node *endpoint, 130 const unsigned int min, const unsigned int max) 131{ 132 return -EINVAL; 133} 134 135static inline int 136drm_of_get_data_lanes_count_ep(const struct device_node *port, 137 int port_reg, int reg, 138 const unsigned int min, 139 const unsigned int max) 140{ 141 return -EINVAL; 142} 143#endif 144 145#if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_DRM_MIPI_DSI) 146struct mipi_dsi_host *drm_of_get_dsi_bus(struct device *dev); 147#else 148static inline struct 149mipi_dsi_host *drm_of_get_dsi_bus(struct device *dev) 150{ 151 return ERR_PTR(-EINVAL); 152} 153#endif /* CONFIG_OF && CONFIG_DRM_MIPI_DSI */ 154 155/* 156 * drm_of_panel_bridge_remove - remove panel bridge 157 * @np: device tree node containing panel bridge output ports 158 * 159 * Remove the panel bridge of a given DT node's port and endpoint number 160 * 161 * Returns zero if successful, or one of the standard error codes if it fails. 162 */ 163static inline int drm_of_panel_bridge_remove(const struct device_node *np, 164 int port, int endpoint) 165{ 166#if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_DRM_PANEL_BRIDGE) 167 struct drm_bridge *bridge; 168 struct device_node *remote; 169 170 remote = of_graph_get_remote_node(np, port, endpoint); 171 if (!remote) 172 return -ENODEV; 173 174 bridge = of_drm_find_and_get_bridge(remote); 175 drm_panel_bridge_remove(bridge); 176 177 drm_bridge_put(bridge); 178 of_node_put(remote); 179 180 return 0; 181#else 182 return -EINVAL; 183#endif 184} 185 186static inline int drm_of_encoder_active_endpoint_id(struct device_node *node, 187 struct drm_encoder *encoder) 188{ 189 struct of_endpoint endpoint; 190 int ret = drm_of_encoder_active_endpoint(node, encoder, 191 &endpoint); 192 193 return ret ?: endpoint.id; 194} 195 196static inline int drm_of_encoder_active_port_id(struct device_node *node, 197 struct drm_encoder *encoder) 198{ 199 struct of_endpoint endpoint; 200 int ret = drm_of_encoder_active_endpoint(node, encoder, 201 &endpoint); 202 203 return ret ?: endpoint.port; 204} 205 206#endif /* __DRM_OF_H__ */