Linux Audio

Check our new training course

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