Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (C) 2009 Francisco Jerez.
0003  * All Rights Reserved.
0004  *
0005  * Permission is hereby granted, free of charge, to any person obtaining
0006  * a copy of this software and associated documentation files (the
0007  * "Software"), to deal in the Software without restriction, including
0008  * without limitation the rights to use, copy, modify, merge, publish,
0009  * distribute, sublicense, and/or sell copies of the Software, and to
0010  * permit persons to whom the Software is furnished to do so, subject to
0011  * the following conditions:
0012  *
0013  * The above copyright notice and this permission notice (including the
0014  * next paragraph) shall be included in all copies or substantial
0015  * portions of the Software.
0016  *
0017  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0018  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0019  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
0020  * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
0021  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
0022  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
0023  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0024  *
0025  */
0026 
0027 #ifndef __DRM_ENCODER_SLAVE_H__
0028 #define __DRM_ENCODER_SLAVE_H__
0029 
0030 #include <linux/i2c.h>
0031 
0032 #include <drm/drm_crtc.h>
0033 #include <drm/drm_encoder.h>
0034 
0035 /**
0036  * struct drm_encoder_slave_funcs - Entry points exposed by a slave encoder driver
0037  * @set_config: Initialize any encoder-specific modesetting parameters.
0038  *      The meaning of the @params parameter is implementation
0039  *      dependent. It will usually be a structure with DVO port
0040  *      data format settings or timings. It's not required for
0041  *      the new parameters to take effect until the next mode
0042  *      is set.
0043  *
0044  * Most of its members are analogous to the function pointers in
0045  * &drm_encoder_helper_funcs and they can optionally be used to
0046  * initialize the latter. Connector-like methods (e.g. @get_modes and
0047  * @set_property) will typically be wrapped around and only be called
0048  * if the encoder is the currently selected one for the connector.
0049  */
0050 struct drm_encoder_slave_funcs {
0051     void (*set_config)(struct drm_encoder *encoder,
0052                void *params);
0053 
0054     void (*destroy)(struct drm_encoder *encoder);
0055     void (*dpms)(struct drm_encoder *encoder, int mode);
0056     void (*save)(struct drm_encoder *encoder);
0057     void (*restore)(struct drm_encoder *encoder);
0058     bool (*mode_fixup)(struct drm_encoder *encoder,
0059                const struct drm_display_mode *mode,
0060                struct drm_display_mode *adjusted_mode);
0061     int (*mode_valid)(struct drm_encoder *encoder,
0062               struct drm_display_mode *mode);
0063     void (*mode_set)(struct drm_encoder *encoder,
0064              struct drm_display_mode *mode,
0065              struct drm_display_mode *adjusted_mode);
0066 
0067     enum drm_connector_status (*detect)(struct drm_encoder *encoder,
0068                         struct drm_connector *connector);
0069     int (*get_modes)(struct drm_encoder *encoder,
0070              struct drm_connector *connector);
0071     int (*create_resources)(struct drm_encoder *encoder,
0072                  struct drm_connector *connector);
0073     int (*set_property)(struct drm_encoder *encoder,
0074                 struct drm_connector *connector,
0075                 struct drm_property *property,
0076                 uint64_t val);
0077 
0078 };
0079 
0080 /**
0081  * struct drm_encoder_slave - Slave encoder struct
0082  * @base: DRM encoder object.
0083  * @slave_funcs: Slave encoder callbacks.
0084  * @slave_priv: Slave encoder private data.
0085  * @bus_priv: Bus specific data.
0086  *
0087  * A &drm_encoder_slave has two sets of callbacks, @slave_funcs and the
0088  * ones in @base. The former are never actually called by the common
0089  * CRTC code, it's just a convenience for splitting the encoder
0090  * functions in an upper, GPU-specific layer and a (hopefully)
0091  * GPU-agnostic lower layer: It's the GPU driver responsibility to
0092  * call the slave methods when appropriate.
0093  *
0094  * drm_i2c_encoder_init() provides a way to get an implementation of
0095  * this.
0096  */
0097 struct drm_encoder_slave {
0098     struct drm_encoder base;
0099 
0100     const struct drm_encoder_slave_funcs *slave_funcs;
0101     void *slave_priv;
0102     void *bus_priv;
0103 };
0104 #define to_encoder_slave(x) container_of((x), struct drm_encoder_slave, base)
0105 
0106 int drm_i2c_encoder_init(struct drm_device *dev,
0107              struct drm_encoder_slave *encoder,
0108              struct i2c_adapter *adap,
0109              const struct i2c_board_info *info);
0110 
0111 
0112 /**
0113  * struct drm_i2c_encoder_driver
0114  *
0115  * Describes a device driver for an encoder connected to the GPU
0116  * through an I2C bus. In addition to the entry points in @i2c_driver
0117  * an @encoder_init function should be provided. It will be called to
0118  * give the driver an opportunity to allocate any per-encoder data
0119  * structures and to initialize the @slave_funcs and (optionally)
0120  * @slave_priv members of @encoder.
0121  */
0122 struct drm_i2c_encoder_driver {
0123     struct i2c_driver i2c_driver;
0124 
0125     int (*encoder_init)(struct i2c_client *client,
0126                 struct drm_device *dev,
0127                 struct drm_encoder_slave *encoder);
0128 
0129 };
0130 #define to_drm_i2c_encoder_driver(x) container_of((x),          \
0131                           struct drm_i2c_encoder_driver, \
0132                           i2c_driver)
0133 
0134 /**
0135  * drm_i2c_encoder_get_client - Get the I2C client corresponding to an encoder
0136  */
0137 static inline struct i2c_client *drm_i2c_encoder_get_client(struct drm_encoder *encoder)
0138 {
0139     return (struct i2c_client *)to_encoder_slave(encoder)->bus_priv;
0140 }
0141 
0142 /**
0143  * drm_i2c_encoder_register - Register an I2C encoder driver
0144  * @owner:  Module containing the driver.
0145  * @driver: Driver to be registered.
0146  */
0147 static inline int drm_i2c_encoder_register(struct module *owner,
0148                        struct drm_i2c_encoder_driver *driver)
0149 {
0150     return i2c_register_driver(owner, &driver->i2c_driver);
0151 }
0152 
0153 /**
0154  * drm_i2c_encoder_unregister - Unregister an I2C encoder driver
0155  * @driver: Driver to be unregistered.
0156  */
0157 static inline void drm_i2c_encoder_unregister(struct drm_i2c_encoder_driver *driver)
0158 {
0159     i2c_del_driver(&driver->i2c_driver);
0160 }
0161 
0162 void drm_i2c_encoder_destroy(struct drm_encoder *encoder);
0163 
0164 
0165 /*
0166  * Wrapper fxns which can be plugged in to drm_encoder_helper_funcs:
0167  */
0168 
0169 void drm_i2c_encoder_dpms(struct drm_encoder *encoder, int mode);
0170 bool drm_i2c_encoder_mode_fixup(struct drm_encoder *encoder,
0171         const struct drm_display_mode *mode,
0172         struct drm_display_mode *adjusted_mode);
0173 void drm_i2c_encoder_prepare(struct drm_encoder *encoder);
0174 void drm_i2c_encoder_commit(struct drm_encoder *encoder);
0175 void drm_i2c_encoder_mode_set(struct drm_encoder *encoder,
0176         struct drm_display_mode *mode,
0177         struct drm_display_mode *adjusted_mode);
0178 enum drm_connector_status drm_i2c_encoder_detect(struct drm_encoder *encoder,
0179         struct drm_connector *connector);
0180 void drm_i2c_encoder_save(struct drm_encoder *encoder);
0181 void drm_i2c_encoder_restore(struct drm_encoder *encoder);
0182 
0183 
0184 #endif