1 /* $NetBSD: drm_encoder_slave.h,v 1.1 2015/03/05 17:42:48 riastradh Exp $ */ 2 3 /*- 4 * Copyright (c) 2015 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Taylor R. Campbell. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 #ifndef _DRM_DRM_ENCODER_SLAVE_H_ 33 #define _DRM_DRM_ENCODER_SLAVE_H_ 34 35 #include <sys/types.h> 36 #include <sys/rbtree.h> 37 38 #include <drm/drm_crtc.h> 39 40 struct drm_encoder_slave_funcs { 41 void (*set_config)(struct drm_encoder *, void *); 42 void (*destroy)(struct drm_encoder *); 43 void (*dpms)(struct drm_encoder *, int mode); 44 void (*save)(struct drm_encoder *); 45 void (*restore)(struct drm_encoder *); 46 bool (*mode_fixup)(struct drm_encoder *, 47 const struct drm_display_mode *, 48 struct drm_display_mode *); 49 int (*mode_valid)(struct drm_encoder *, struct drm_display_mode *); 50 void (*mode_set)(struct drm_encoder *, 51 const struct drm_display_mode *, 52 struct drm_display_mode *); 53 enum drm_connector_status 54 (*detect)(struct drm_encoder *, struct drm_connector *); 55 int (*get_modes)(struct drm_encoder *, struct drm_connector *); 56 int (*create_resources)(struct drm_encoder *, 57 struct drm_connector *); 58 int (*set_property)(struct drm_encoder *, struct drm_connector *, 59 struct drm_property *, uint64_t); 60 }; 61 62 struct drm_encoder_slave { 63 struct drm_encoder base; 64 struct drm_encoder_slave_funcs *slave_funcs; 65 void *slave_priv; 66 void *bus_priv; 67 }; 68 69 static inline struct drm_encoder_slave * 70 to_encoder_slave(struct drm_encoder *encoder) 71 { 72 73 return container_of(encoder, struct drm_encoder_slave, base); 74 } 75 76 struct drm_i2c_encoder_driver { 77 struct i2c_driver i2c_driver; 78 int (*encoder_init)(struct i2c_client *, 79 struct drm_device *, 80 struct drm_encoder_slave *); 81 rb_node_t rb_node; 82 volatile unsigned refcnt; 83 }; 84 85 struct module; 86 87 void drm_i2c_encoders_init(void); 88 void drm_i2c_encoders_fini(void); 89 90 int drm_i2c_encoder_register(struct module *, 91 struct drm_i2c_encoder_driver *); 92 void drm_i2c_encoder_unregister(struct drm_i2c_encoder_driver *); 93 94 int drm_i2c_encoder_init(struct drm_device *, struct drm_encoder_slave *, 95 struct i2c_adapter *, const struct i2c_board_info *); 96 void drm_i2c_encoder_destroy(struct drm_encoder *); 97 struct i2c_client * 98 drm_i2c_encoder_get_client(struct drm_encoder *); 99 100 void drm_i2c_encoder_dpms(struct drm_encoder *, int); 101 bool drm_i2c_encoder_mode_fixup(struct drm_encoder *, 102 const struct drm_display_mode *, struct drm_display_mode *); 103 void drm_i2c_encoder_prepare(struct drm_encoder *); 104 void drm_i2c_encoder_commit(struct drm_encoder *); 105 void drm_i2c_encoder_mode_set(struct drm_encoder *, 106 struct drm_display_mode *, struct drm_display_mode *); 107 enum drm_connector_status 108 drm_i2c_encoder_detect(struct drm_encoder *, struct drm_connector *); 109 void drm_i2c_encoder_save(struct drm_encoder *); 110 void drm_i2c_encoder_restore(struct drm_encoder *); 111 112 #endif /* _DRM_DRM_ENCODER_SLAVE_H_ */ 113