11.2Sriastrad/* $NetBSD: drm_encoder_slave.h,v 1.3 2021/12/18 23:45:45 riastradh Exp $ */ 21.2Sriastrad 31.1Sriastrad/* 41.1Sriastrad * Copyright (C) 2009 Francisco Jerez. 51.1Sriastrad * All Rights Reserved. 61.1Sriastrad * 71.1Sriastrad * Permission is hereby granted, free of charge, to any person obtaining 81.1Sriastrad * a copy of this software and associated documentation files (the 91.1Sriastrad * "Software"), to deal in the Software without restriction, including 101.1Sriastrad * without limitation the rights to use, copy, modify, merge, publish, 111.1Sriastrad * distribute, sublicense, and/or sell copies of the Software, and to 121.1Sriastrad * permit persons to whom the Software is furnished to do so, subject to 131.1Sriastrad * the following conditions: 141.1Sriastrad * 151.1Sriastrad * The above copyright notice and this permission notice (including the 161.1Sriastrad * next paragraph) shall be included in all copies or substantial 171.1Sriastrad * portions of the Software. 181.1Sriastrad * 191.1Sriastrad * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 201.1Sriastrad * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 211.1Sriastrad * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 221.1Sriastrad * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE 231.1Sriastrad * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 241.1Sriastrad * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 251.1Sriastrad * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 261.1Sriastrad * 271.1Sriastrad */ 281.1Sriastrad 291.1Sriastrad#ifndef __DRM_ENCODER_SLAVE_H__ 301.1Sriastrad#define __DRM_ENCODER_SLAVE_H__ 311.1Sriastrad 321.1Sriastrad#include <drm/drm_crtc.h> 331.3Sriastrad#include <drm/drm_encoder.h> 341.1Sriastrad 351.1Sriastrad/** 361.1Sriastrad * struct drm_encoder_slave_funcs - Entry points exposed by a slave encoder driver 371.1Sriastrad * @set_config: Initialize any encoder-specific modesetting parameters. 381.1Sriastrad * The meaning of the @params parameter is implementation 391.1Sriastrad * dependent. It will usually be a structure with DVO port 401.1Sriastrad * data format settings or timings. It's not required for 411.1Sriastrad * the new parameters to take effect until the next mode 421.1Sriastrad * is set. 431.1Sriastrad * 441.1Sriastrad * Most of its members are analogous to the function pointers in 451.1Sriastrad * &drm_encoder_helper_funcs and they can optionally be used to 461.1Sriastrad * initialize the latter. Connector-like methods (e.g. @get_modes and 471.1Sriastrad * @set_property) will typically be wrapped around and only be called 481.1Sriastrad * if the encoder is the currently selected one for the connector. 491.1Sriastrad */ 501.1Sriastradstruct drm_encoder_slave_funcs { 511.1Sriastrad void (*set_config)(struct drm_encoder *encoder, 521.1Sriastrad void *params); 531.1Sriastrad 541.1Sriastrad void (*destroy)(struct drm_encoder *encoder); 551.1Sriastrad void (*dpms)(struct drm_encoder *encoder, int mode); 561.1Sriastrad void (*save)(struct drm_encoder *encoder); 571.1Sriastrad void (*restore)(struct drm_encoder *encoder); 581.1Sriastrad bool (*mode_fixup)(struct drm_encoder *encoder, 591.1Sriastrad const struct drm_display_mode *mode, 601.1Sriastrad struct drm_display_mode *adjusted_mode); 611.1Sriastrad int (*mode_valid)(struct drm_encoder *encoder, 621.1Sriastrad struct drm_display_mode *mode); 631.1Sriastrad void (*mode_set)(struct drm_encoder *encoder, 641.1Sriastrad struct drm_display_mode *mode, 651.1Sriastrad struct drm_display_mode *adjusted_mode); 661.1Sriastrad 671.1Sriastrad enum drm_connector_status (*detect)(struct drm_encoder *encoder, 681.1Sriastrad struct drm_connector *connector); 691.1Sriastrad int (*get_modes)(struct drm_encoder *encoder, 701.1Sriastrad struct drm_connector *connector); 711.1Sriastrad int (*create_resources)(struct drm_encoder *encoder, 721.1Sriastrad struct drm_connector *connector); 731.1Sriastrad int (*set_property)(struct drm_encoder *encoder, 741.1Sriastrad struct drm_connector *connector, 751.1Sriastrad struct drm_property *property, 761.1Sriastrad uint64_t val); 771.1Sriastrad 781.1Sriastrad}; 791.1Sriastrad 801.1Sriastrad/** 811.1Sriastrad * struct drm_encoder_slave - Slave encoder struct 821.1Sriastrad * @base: DRM encoder object. 831.1Sriastrad * @slave_funcs: Slave encoder callbacks. 841.1Sriastrad * @slave_priv: Slave encoder private data. 851.1Sriastrad * @bus_priv: Bus specific data. 861.1Sriastrad * 871.1Sriastrad * A &drm_encoder_slave has two sets of callbacks, @slave_funcs and the 881.1Sriastrad * ones in @base. The former are never actually called by the common 891.1Sriastrad * CRTC code, it's just a convenience for splitting the encoder 901.1Sriastrad * functions in an upper, GPU-specific layer and a (hopefully) 911.1Sriastrad * GPU-agnostic lower layer: It's the GPU driver responsibility to 921.1Sriastrad * call the slave methods when appropriate. 931.1Sriastrad * 941.1Sriastrad * drm_i2c_encoder_init() provides a way to get an implementation of 951.1Sriastrad * this. 961.1Sriastrad */ 971.1Sriastradstruct drm_encoder_slave { 981.1Sriastrad struct drm_encoder base; 991.1Sriastrad 1001.3Sriastrad const struct drm_encoder_slave_funcs *slave_funcs; 1011.1Sriastrad void *slave_priv; 1021.1Sriastrad void *bus_priv; 1031.1Sriastrad}; 1041.1Sriastrad#define to_encoder_slave(x) container_of((x), struct drm_encoder_slave, base) 1051.1Sriastrad 1061.1Sriastradint drm_i2c_encoder_init(struct drm_device *dev, 1071.1Sriastrad struct drm_encoder_slave *encoder, 1081.1Sriastrad struct i2c_adapter *adap, 1091.1Sriastrad const struct i2c_board_info *info); 1101.1Sriastrad 1111.1Sriastrad 1121.1Sriastrad/** 1131.1Sriastrad * struct drm_i2c_encoder_driver 1141.1Sriastrad * 1151.1Sriastrad * Describes a device driver for an encoder connected to the GPU 1161.1Sriastrad * through an I2C bus. In addition to the entry points in @i2c_driver 1171.1Sriastrad * an @encoder_init function should be provided. It will be called to 1181.1Sriastrad * give the driver an opportunity to allocate any per-encoder data 1191.1Sriastrad * structures and to initialize the @slave_funcs and (optionally) 1201.1Sriastrad * @slave_priv members of @encoder. 1211.1Sriastrad */ 1221.1Sriastradstruct drm_i2c_encoder_driver { 1231.1Sriastrad struct i2c_driver i2c_driver; 1241.1Sriastrad 1251.1Sriastrad int (*encoder_init)(struct i2c_client *client, 1261.1Sriastrad struct drm_device *dev, 1271.1Sriastrad struct drm_encoder_slave *encoder); 1281.1Sriastrad 1291.1Sriastrad}; 1301.1Sriastrad#define to_drm_i2c_encoder_driver(x) container_of((x), \ 1311.1Sriastrad struct drm_i2c_encoder_driver, \ 1321.1Sriastrad i2c_driver) 1331.1Sriastrad 1341.1Sriastrad/** 1351.1Sriastrad * drm_i2c_encoder_get_client - Get the I2C client corresponding to an encoder 1361.1Sriastrad */ 1371.1Sriastradstatic inline struct i2c_client *drm_i2c_encoder_get_client(struct drm_encoder *encoder) 1381.1Sriastrad{ 1391.1Sriastrad return (struct i2c_client *)to_encoder_slave(encoder)->bus_priv; 1401.1Sriastrad} 1411.1Sriastrad 1421.1Sriastrad/** 1431.1Sriastrad * drm_i2c_encoder_register - Register an I2C encoder driver 1441.1Sriastrad * @owner: Module containing the driver. 1451.1Sriastrad * @driver: Driver to be registered. 1461.1Sriastrad */ 1471.1Sriastradstatic inline int drm_i2c_encoder_register(struct module *owner, 1481.1Sriastrad struct drm_i2c_encoder_driver *driver) 1491.1Sriastrad{ 1501.1Sriastrad return i2c_register_driver(owner, &driver->i2c_driver); 1511.1Sriastrad} 1521.1Sriastrad 1531.1Sriastrad/** 1541.1Sriastrad * drm_i2c_encoder_unregister - Unregister an I2C encoder driver 1551.1Sriastrad * @driver: Driver to be unregistered. 1561.1Sriastrad */ 1571.1Sriastradstatic inline void drm_i2c_encoder_unregister(struct drm_i2c_encoder_driver *driver) 1581.1Sriastrad{ 1591.1Sriastrad i2c_del_driver(&driver->i2c_driver); 1601.1Sriastrad} 1611.1Sriastrad 1621.1Sriastradvoid drm_i2c_encoder_destroy(struct drm_encoder *encoder); 1631.1Sriastrad 1641.2Sriastrad 1651.2Sriastrad/* 1661.2Sriastrad * Wrapper fxns which can be plugged in to drm_encoder_helper_funcs: 1671.2Sriastrad */ 1681.2Sriastrad 1691.2Sriastradvoid drm_i2c_encoder_dpms(struct drm_encoder *encoder, int mode); 1701.2Sriastradbool drm_i2c_encoder_mode_fixup(struct drm_encoder *encoder, 1711.2Sriastrad const struct drm_display_mode *mode, 1721.2Sriastrad struct drm_display_mode *adjusted_mode); 1731.2Sriastradvoid drm_i2c_encoder_prepare(struct drm_encoder *encoder); 1741.2Sriastradvoid drm_i2c_encoder_commit(struct drm_encoder *encoder); 1751.2Sriastradvoid drm_i2c_encoder_mode_set(struct drm_encoder *encoder, 1761.2Sriastrad struct drm_display_mode *mode, 1771.2Sriastrad struct drm_display_mode *adjusted_mode); 1781.2Sriastradenum drm_connector_status drm_i2c_encoder_detect(struct drm_encoder *encoder, 1791.2Sriastrad struct drm_connector *connector); 1801.2Sriastradvoid drm_i2c_encoder_save(struct drm_encoder *encoder); 1811.2Sriastradvoid drm_i2c_encoder_restore(struct drm_encoder *encoder); 1821.2Sriastrad 1831.2Sriastrad 1841.1Sriastrad#endif 185