11.3Sriastrad/*	$NetBSD: drm_encoder_slave.h,v 1.3 2021/12/19 10:48:15 riastradh Exp $	*/
21.1Sriastrad
31.1Sriastrad/*-
41.1Sriastrad * Copyright (c) 2015 The NetBSD Foundation, Inc.
51.1Sriastrad * All rights reserved.
61.1Sriastrad *
71.1Sriastrad * This code is derived from software contributed to The NetBSD Foundation
81.1Sriastrad * by Taylor R. Campbell.
91.1Sriastrad *
101.1Sriastrad * Redistribution and use in source and binary forms, with or without
111.1Sriastrad * modification, are permitted provided that the following conditions
121.1Sriastrad * are met:
131.1Sriastrad * 1. Redistributions of source code must retain the above copyright
141.1Sriastrad *    notice, this list of conditions and the following disclaimer.
151.1Sriastrad * 2. Redistributions in binary form must reproduce the above copyright
161.1Sriastrad *    notice, this list of conditions and the following disclaimer in the
171.1Sriastrad *    documentation and/or other materials provided with the distribution.
181.1Sriastrad *
191.1Sriastrad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
201.1Sriastrad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
211.1Sriastrad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
221.1Sriastrad * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
231.1Sriastrad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
241.1Sriastrad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
251.1Sriastrad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
261.1Sriastrad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
271.1Sriastrad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
281.1Sriastrad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
291.1Sriastrad * POSSIBILITY OF SUCH DAMAGE.
301.1Sriastrad */
311.1Sriastrad
321.1Sriastrad#ifndef	_DRM_DRM_ENCODER_SLAVE_H_
331.1Sriastrad#define	_DRM_DRM_ENCODER_SLAVE_H_
341.1Sriastrad
351.1Sriastrad#include <sys/types.h>
361.1Sriastrad#include <sys/rbtree.h>
371.1Sriastrad
381.2Sriastrad#include <drm/drm_connector.h>
391.2Sriastrad#include <drm/drm_encoder.h>
401.2Sriastrad
411.2Sriastradstruct drm_connector;
421.2Sriastradstruct drm_device;
431.2Sriastradstruct drm_display_mode;
441.2Sriastradstruct drm_encoder;
451.2Sriastradstruct drm_property;
461.2Sriastradstruct i2c_client;
471.2Sriastradstruct module;
481.1Sriastrad
491.1Sriastradstruct drm_encoder_slave_funcs {
501.1Sriastrad	void	(*set_config)(struct drm_encoder *, void *);
511.1Sriastrad	void	(*destroy)(struct drm_encoder *);
521.1Sriastrad	void	(*dpms)(struct drm_encoder *, int mode);
531.1Sriastrad	void	(*save)(struct drm_encoder *);
541.1Sriastrad	void	(*restore)(struct drm_encoder *);
551.1Sriastrad	bool	(*mode_fixup)(struct drm_encoder *,
561.1Sriastrad		    const struct drm_display_mode *,
571.1Sriastrad		    struct drm_display_mode *);
581.1Sriastrad	int	(*mode_valid)(struct drm_encoder *, struct drm_display_mode *);
591.1Sriastrad	void	(*mode_set)(struct drm_encoder *,
601.1Sriastrad		    const struct drm_display_mode *,
611.1Sriastrad		    struct drm_display_mode *);
621.1Sriastrad	enum drm_connector_status
631.1Sriastrad		(*detect)(struct drm_encoder *, struct drm_connector *);
641.1Sriastrad	int	(*get_modes)(struct drm_encoder *, struct drm_connector *);
651.1Sriastrad	int	(*create_resources)(struct drm_encoder *,
661.1Sriastrad		    struct drm_connector *);
671.1Sriastrad	int	(*set_property)(struct drm_encoder *, struct drm_connector *,
681.1Sriastrad		    struct drm_property *, uint64_t);
691.1Sriastrad};
701.1Sriastrad
711.1Sriastradstruct drm_encoder_slave {
721.1Sriastrad	struct drm_encoder		base;
731.3Sriastrad	const struct drm_encoder_slave_funcs *slave_funcs;
741.1Sriastrad	void				*slave_priv;
751.1Sriastrad	void				*bus_priv;
761.1Sriastrad};
771.1Sriastrad
781.1Sriastradstatic inline struct drm_encoder_slave *
791.1Sriastradto_encoder_slave(struct drm_encoder *encoder)
801.1Sriastrad{
811.1Sriastrad
821.1Sriastrad	return container_of(encoder, struct drm_encoder_slave, base);
831.1Sriastrad}
841.1Sriastrad
851.1Sriastradstruct drm_i2c_encoder_driver {
861.1Sriastrad	struct i2c_driver	i2c_driver;
871.1Sriastrad	int			(*encoder_init)(struct i2c_client *,
881.1Sriastrad				    struct drm_device *,
891.1Sriastrad				    struct drm_encoder_slave *);
901.1Sriastrad	rb_node_t		rb_node;
911.1Sriastrad	volatile unsigned	refcnt;
921.1Sriastrad};
931.1Sriastrad
941.1Sriastradstruct module;
951.1Sriastrad
961.1Sriastradvoid	drm_i2c_encoders_init(void);
971.1Sriastradvoid	drm_i2c_encoders_fini(void);
981.1Sriastrad
991.1Sriastradint	drm_i2c_encoder_register(struct module *,
1001.1Sriastrad	    struct drm_i2c_encoder_driver *);
1011.1Sriastradvoid	drm_i2c_encoder_unregister(struct drm_i2c_encoder_driver *);
1021.1Sriastrad
1031.1Sriastradint	drm_i2c_encoder_init(struct drm_device *, struct drm_encoder_slave *,
1041.1Sriastrad	    struct i2c_adapter *, const struct i2c_board_info *);
1051.1Sriastradvoid	drm_i2c_encoder_destroy(struct drm_encoder *);
1061.1Sriastradstruct i2c_client *
1071.1Sriastrad	drm_i2c_encoder_get_client(struct drm_encoder *);
1081.1Sriastrad
1091.1Sriastradvoid	drm_i2c_encoder_dpms(struct drm_encoder *, int);
1101.1Sriastradbool	drm_i2c_encoder_mode_fixup(struct drm_encoder *,
1111.1Sriastrad	    const struct drm_display_mode *, struct drm_display_mode *);
1121.1Sriastradvoid	drm_i2c_encoder_prepare(struct drm_encoder *);
1131.1Sriastradvoid	drm_i2c_encoder_commit(struct drm_encoder *);
1141.1Sriastradvoid	drm_i2c_encoder_mode_set(struct drm_encoder *,
1151.1Sriastrad	    struct drm_display_mode *, struct drm_display_mode *);
1161.1Sriastradenum drm_connector_status
1171.1Sriastrad	drm_i2c_encoder_detect(struct drm_encoder *, struct drm_connector *);
1181.1Sriastradvoid	drm_i2c_encoder_save(struct drm_encoder *);
1191.1Sriastradvoid	drm_i2c_encoder_restore(struct drm_encoder *);
1201.1Sriastrad
1211.1Sriastrad#endif	/* _DRM_DRM_ENCODER_SLAVE_H_ */
122