Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #ifndef __DRM_OF_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #define __DRM_OF_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <linux/of_graph.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_DRM_PANEL_BRIDGE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <drm/drm_bridge.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) struct component_master_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) struct component_match;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) struct device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) struct drm_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) struct drm_encoder;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) struct drm_panel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) struct drm_bridge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) struct device_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * enum drm_lvds_dual_link_pixels - Pixel order of an LVDS dual-link connection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * @DRM_LVDS_DUAL_LINK_EVEN_ODD_PIXELS: Even pixels are expected to be generated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  *    from the first port, odd pixels from the second port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * @DRM_LVDS_DUAL_LINK_ODD_EVEN_PIXELS: Odd pixels are expected to be generated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *    from the first port, even pixels from the second port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) enum drm_lvds_dual_link_pixels {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	DRM_LVDS_DUAL_LINK_EVEN_ODD_PIXELS = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	DRM_LVDS_DUAL_LINK_ODD_EVEN_PIXELS = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #ifdef CONFIG_OF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) uint32_t drm_of_crtc_port_mask(struct drm_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 			    struct device_node *port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 				    struct device_node *port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) void drm_of_component_match_add(struct device *master,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 				struct component_match **matchptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 				int (*compare)(struct device *, void *),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 				struct device_node *node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) int drm_of_component_probe(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 			   int (*compare_of)(struct device *, void *),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 			   const struct component_master_ops *m_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) int drm_of_encoder_active_endpoint(struct device_node *node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 				   struct drm_encoder *encoder,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 				   struct of_endpoint *endpoint);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) int drm_of_find_panel_or_bridge(const struct device_node *np,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 				int port, int endpoint,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 				struct drm_panel **panel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 				struct drm_bridge **bridge);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) int drm_of_lvds_get_dual_link_pixel_order(const struct device_node *port1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 					  const struct device_node *port2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) static inline uint32_t drm_of_crtc_port_mask(struct drm_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 					  struct device_node *port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 						  struct device_node *port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) drm_of_component_match_add(struct device *master,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 			   struct component_match **matchptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 			   int (*compare)(struct device *, void *),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 			   struct device_node *node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) static inline int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) drm_of_component_probe(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		       int (*compare_of)(struct device *, void *),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		       const struct component_master_ops *m_ops)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) static inline int drm_of_encoder_active_endpoint(struct device_node *node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 						 struct drm_encoder *encoder,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 						 struct of_endpoint *endpoint)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) static inline int drm_of_find_panel_or_bridge(const struct device_node *np,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 					      int port, int endpoint,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 					      struct drm_panel **panel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 					      struct drm_bridge **bridge)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) static inline int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) drm_of_lvds_get_dual_link_pixel_order(const struct device_node *port1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 				      const struct device_node *port2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  * drm_of_panel_bridge_remove - remove panel bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  * @np: device tree node containing panel bridge output ports
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  * Remove the panel bridge of a given DT node's port and endpoint number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)  * Returns zero if successful, or one of the standard error codes if it fails.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) static inline int drm_of_panel_bridge_remove(const struct device_node *np,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 					     int port, int endpoint)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_DRM_PANEL_BRIDGE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	struct drm_bridge *bridge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	struct device_node *remote;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	remote = of_graph_get_remote_node(np, port, endpoint);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	if (!remote)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	bridge = of_drm_find_bridge(remote);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	drm_panel_bridge_remove(bridge);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) static inline int drm_of_encoder_active_endpoint_id(struct device_node *node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 						    struct drm_encoder *encoder)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	struct of_endpoint endpoint;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	int ret = drm_of_encoder_active_endpoint(node, encoder,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 						 &endpoint);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	return ret ?: endpoint.id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) static inline int drm_of_encoder_active_port_id(struct device_node *node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 						struct drm_encoder *encoder)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	struct of_endpoint endpoint;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	int ret = drm_of_encoder_active_endpoint(node, encoder,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 						 &endpoint);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	return ret ?: endpoint.port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) #endif /* __DRM_OF_H__ */