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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * Copyright (C) 2009 Francisco Jerez.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Permission is hereby granted, free of charge, to any person obtaining
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * a copy of this software and associated documentation files (the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * "Software"), to deal in the Software without restriction, including
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * without limitation the rights to use, copy, modify, merge, publish,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * distribute, sublicense, and/or sell copies of the Software, and to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * permit persons to whom the Software is furnished to do so, subject to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * the following conditions:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  * The above copyright notice and this permission notice (including the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  * next paragraph) shall be included in all copies or substantial
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  * portions of the Software.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #ifndef __DRM_ENCODER_SLAVE_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #define __DRM_ENCODER_SLAVE_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #include <drm/drm_crtc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #include <drm/drm_encoder.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * struct drm_encoder_slave_funcs - Entry points exposed by a slave encoder driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  * @set_config:	Initialize any encoder-specific modesetting parameters.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  *		The meaning of the @params parameter is implementation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  *		dependent. It will usually be a structure with DVO port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  *		data format settings or timings. It's not required for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  *		the new parameters to take effect until the next mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  *		is set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  * Most of its members are analogous to the function pointers in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  * &drm_encoder_helper_funcs and they can optionally be used to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  * initialize the latter. Connector-like methods (e.g. @get_modes and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  * @set_property) will typically be wrapped around and only be called
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  * if the encoder is the currently selected one for the connector.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) struct drm_encoder_slave_funcs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	void (*set_config)(struct drm_encoder *encoder,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 			   void *params);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	void (*destroy)(struct drm_encoder *encoder);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	void (*dpms)(struct drm_encoder *encoder, int mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	void (*save)(struct drm_encoder *encoder);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	void (*restore)(struct drm_encoder *encoder);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	bool (*mode_fixup)(struct drm_encoder *encoder,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 			   const struct drm_display_mode *mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 			   struct drm_display_mode *adjusted_mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	int (*mode_valid)(struct drm_encoder *encoder,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 			  struct drm_display_mode *mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	void (*mode_set)(struct drm_encoder *encoder,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 			 struct drm_display_mode *mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 			 struct drm_display_mode *adjusted_mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	enum drm_connector_status (*detect)(struct drm_encoder *encoder,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 					    struct drm_connector *connector);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	int (*get_modes)(struct drm_encoder *encoder,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 			 struct drm_connector *connector);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	int (*create_resources)(struct drm_encoder *encoder,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 				 struct drm_connector *connector);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	int (*set_property)(struct drm_encoder *encoder,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 			    struct drm_connector *connector,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 			    struct drm_property *property,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 			    uint64_t val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  * struct drm_encoder_slave - Slave encoder struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  * @base: DRM encoder object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  * @slave_funcs: Slave encoder callbacks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  * @slave_priv: Slave encoder private data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  * @bus_priv: Bus specific data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)  * A &drm_encoder_slave has two sets of callbacks, @slave_funcs and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)  * ones in @base. The former are never actually called by the common
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)  * CRTC code, it's just a convenience for splitting the encoder
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)  * functions in an upper, GPU-specific layer and a (hopefully)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)  * GPU-agnostic lower layer: It's the GPU driver responsibility to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)  * call the slave methods when appropriate.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)  * drm_i2c_encoder_init() provides a way to get an implementation of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)  * this.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) struct drm_encoder_slave {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	struct drm_encoder base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	const struct drm_encoder_slave_funcs *slave_funcs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	void *slave_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	void *bus_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #define to_encoder_slave(x) container_of((x), struct drm_encoder_slave, base)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) int drm_i2c_encoder_init(struct drm_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 			 struct drm_encoder_slave *encoder,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 			 struct i2c_adapter *adap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 			 const struct i2c_board_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)  * struct drm_i2c_encoder_driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)  * Describes a device driver for an encoder connected to the GPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)  * through an I2C bus. In addition to the entry points in @i2c_driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  * an @encoder_init function should be provided. It will be called to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)  * give the driver an opportunity to allocate any per-encoder data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)  * structures and to initialize the @slave_funcs and (optionally)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)  * @slave_priv members of @encoder.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) struct drm_i2c_encoder_driver {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	struct i2c_driver i2c_driver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	int (*encoder_init)(struct i2c_client *client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 			    struct drm_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 			    struct drm_encoder_slave *encoder);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) #define to_drm_i2c_encoder_driver(x) container_of((x),			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 						  struct drm_i2c_encoder_driver, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 						  i2c_driver)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)  * drm_i2c_encoder_get_client - Get the I2C client corresponding to an encoder
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) static inline struct i2c_client *drm_i2c_encoder_get_client(struct drm_encoder *encoder)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	return (struct i2c_client *)to_encoder_slave(encoder)->bus_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) }
^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)  * drm_i2c_encoder_register - Register an I2C encoder driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)  * @owner:	Module containing the driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)  * @driver:	Driver to be registered.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) static inline int drm_i2c_encoder_register(struct module *owner,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 					   struct drm_i2c_encoder_driver *driver)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	return i2c_register_driver(owner, &driver->i2c_driver);
^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) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)  * drm_i2c_encoder_unregister - Unregister an I2C encoder driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)  * @driver:	Driver to be unregistered.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) static inline void drm_i2c_encoder_unregister(struct drm_i2c_encoder_driver *driver)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	i2c_del_driver(&driver->i2c_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) void drm_i2c_encoder_destroy(struct drm_encoder *encoder);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)  * Wrapper fxns which can be plugged in to drm_encoder_helper_funcs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) void drm_i2c_encoder_dpms(struct drm_encoder *encoder, int mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) bool drm_i2c_encoder_mode_fixup(struct drm_encoder *encoder,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		const struct drm_display_mode *mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		struct drm_display_mode *adjusted_mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) void drm_i2c_encoder_prepare(struct drm_encoder *encoder);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) void drm_i2c_encoder_commit(struct drm_encoder *encoder);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) void drm_i2c_encoder_mode_set(struct drm_encoder *encoder,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		struct drm_display_mode *mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		struct drm_display_mode *adjusted_mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) enum drm_connector_status drm_i2c_encoder_detect(struct drm_encoder *encoder,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	    struct drm_connector *connector);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) void drm_i2c_encoder_save(struct drm_encoder *encoder);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) void drm_i2c_encoder_restore(struct drm_encoder *encoder);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) #endif