/*1* Copyright (C) 2009 Francisco Jerez.2* All Rights Reserved.3*4* Permission is hereby granted, free of charge, to any person obtaining5* a copy of this software and associated documentation files (the6* "Software"), to deal in the Software without restriction, including7* without limitation the rights to use, copy, modify, merge, publish,8* distribute, sublicense, and/or sell copies of the Software, and to9* permit persons to whom the Software is furnished to do so, subject to10* the following conditions:11*12* The above copyright notice and this permission notice (including the13* next paragraph) shall be included in all copies or substantial14* portions of the Software.15*16* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,17* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF18* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.19* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE20* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION21* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION22* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.23*24*/2526#ifndef __DRM_ENCODER_SLAVE_H__27#define __DRM_ENCODER_SLAVE_H__2829#include "drmP.h"30#include "drm_crtc.h"3132/**33* struct drm_encoder_slave_funcs - Entry points exposed by a slave encoder driver34* @set_config: Initialize any encoder-specific modesetting parameters.35* The meaning of the @params parameter is implementation36* dependent. It will usually be a structure with DVO port37* data format settings or timings. It's not required for38* the new parameters to take effect until the next mode39* is set.40*41* Most of its members are analogous to the function pointers in42* &drm_encoder_helper_funcs and they can optionally be used to43* initialize the latter. Connector-like methods (e.g. @get_modes and44* @set_property) will typically be wrapped around and only be called45* if the encoder is the currently selected one for the connector.46*/47struct drm_encoder_slave_funcs {48void (*set_config)(struct drm_encoder *encoder,49void *params);5051void (*destroy)(struct drm_encoder *encoder);52void (*dpms)(struct drm_encoder *encoder, int mode);53void (*save)(struct drm_encoder *encoder);54void (*restore)(struct drm_encoder *encoder);55bool (*mode_fixup)(struct drm_encoder *encoder,56struct drm_display_mode *mode,57struct drm_display_mode *adjusted_mode);58int (*mode_valid)(struct drm_encoder *encoder,59struct drm_display_mode *mode);60void (*mode_set)(struct drm_encoder *encoder,61struct drm_display_mode *mode,62struct drm_display_mode *adjusted_mode);6364enum drm_connector_status (*detect)(struct drm_encoder *encoder,65struct drm_connector *connector);66int (*get_modes)(struct drm_encoder *encoder,67struct drm_connector *connector);68int (*create_resources)(struct drm_encoder *encoder,69struct drm_connector *connector);70int (*set_property)(struct drm_encoder *encoder,71struct drm_connector *connector,72struct drm_property *property,73uint64_t val);7475};7677/**78* struct drm_encoder_slave - Slave encoder struct79* @base: DRM encoder object.80* @slave_funcs: Slave encoder callbacks.81* @slave_priv: Slave encoder private data.82* @bus_priv: Bus specific data.83*84* A &drm_encoder_slave has two sets of callbacks, @slave_funcs and the85* ones in @base. The former are never actually called by the common86* CRTC code, it's just a convenience for splitting the encoder87* functions in an upper, GPU-specific layer and a (hopefully)88* GPU-agnostic lower layer: It's the GPU driver responsibility to89* call the slave methods when appropriate.90*91* drm_i2c_encoder_init() provides a way to get an implementation of92* this.93*/94struct drm_encoder_slave {95struct drm_encoder base;9697struct drm_encoder_slave_funcs *slave_funcs;98void *slave_priv;99void *bus_priv;100};101#define to_encoder_slave(x) container_of((x), struct drm_encoder_slave, base)102103int drm_i2c_encoder_init(struct drm_device *dev,104struct drm_encoder_slave *encoder,105struct i2c_adapter *adap,106const struct i2c_board_info *info);107108109/**110* struct drm_i2c_encoder_driver111*112* Describes a device driver for an encoder connected to the GPU113* through an I2C bus. In addition to the entry points in @i2c_driver114* an @encoder_init function should be provided. It will be called to115* give the driver an opportunity to allocate any per-encoder data116* structures and to initialize the @slave_funcs and (optionally)117* @slave_priv members of @encoder.118*/119struct drm_i2c_encoder_driver {120struct i2c_driver i2c_driver;121122int (*encoder_init)(struct i2c_client *client,123struct drm_device *dev,124struct drm_encoder_slave *encoder);125126};127#define to_drm_i2c_encoder_driver(x) container_of((x), \128struct drm_i2c_encoder_driver, \129i2c_driver)130131/**132* drm_i2c_encoder_get_client - Get the I2C client corresponding to an encoder133*/134static inline struct i2c_client *drm_i2c_encoder_get_client(struct drm_encoder *encoder)135{136return (struct i2c_client *)to_encoder_slave(encoder)->bus_priv;137}138139/**140* drm_i2c_encoder_register - Register an I2C encoder driver141* @owner: Module containing the driver.142* @driver: Driver to be registered.143*/144static inline int drm_i2c_encoder_register(struct module *owner,145struct drm_i2c_encoder_driver *driver)146{147return i2c_register_driver(owner, &driver->i2c_driver);148}149150/**151* drm_i2c_encoder_unregister - Unregister an I2C encoder driver152* @driver: Driver to be unregistered.153*/154static inline void drm_i2c_encoder_unregister(struct drm_i2c_encoder_driver *driver)155{156i2c_del_driver(&driver->i2c_driver);157}158159void drm_i2c_encoder_destroy(struct drm_encoder *encoder);160161#endif162163164