Home | History | Annotate | Line # | Download | only in nouveau
      1  1.2  riastrad /*	$NetBSD: nouveau_encoder.h,v 1.3 2021/12/18 23:45:32 riastradh Exp $	*/
      2  1.2  riastrad 
      3  1.1  riastrad /*
      4  1.1  riastrad  * Copyright (C) 2008 Maarten Maathuis.
      5  1.1  riastrad  * All Rights Reserved.
      6  1.1  riastrad  *
      7  1.1  riastrad  * Permission is hereby granted, free of charge, to any person obtaining
      8  1.1  riastrad  * a copy of this software and associated documentation files (the
      9  1.1  riastrad  * "Software"), to deal in the Software without restriction, including
     10  1.1  riastrad  * without limitation the rights to use, copy, modify, merge, publish,
     11  1.1  riastrad  * distribute, sublicense, and/or sell copies of the Software, and to
     12  1.1  riastrad  * permit persons to whom the Software is furnished to do so, subject to
     13  1.1  riastrad  * the following conditions:
     14  1.1  riastrad  *
     15  1.1  riastrad  * The above copyright notice and this permission notice (including the
     16  1.1  riastrad  * next paragraph) shall be included in all copies or substantial
     17  1.1  riastrad  * portions of the Software.
     18  1.1  riastrad  *
     19  1.1  riastrad  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
     20  1.1  riastrad  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     21  1.1  riastrad  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
     22  1.1  riastrad  * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
     23  1.1  riastrad  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
     24  1.1  riastrad  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
     25  1.1  riastrad  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     26  1.1  riastrad  *
     27  1.1  riastrad  */
     28  1.1  riastrad 
     29  1.1  riastrad #ifndef __NOUVEAU_ENCODER_H__
     30  1.1  riastrad #define __NOUVEAU_ENCODER_H__
     31  1.1  riastrad 
     32  1.1  riastrad #include <subdev/bios/dcb.h>
     33  1.1  riastrad 
     34  1.1  riastrad #include <drm/drm_encoder_slave.h>
     35  1.3  riastrad #include <drm/drm_dp_mst_helper.h>
     36  1.1  riastrad #include "dispnv04/disp.h"
     37  1.3  riastrad struct nv50_head_atom;
     38  1.1  riastrad 
     39  1.1  riastrad #define NV_DPMS_CLEARED 0x80
     40  1.1  riastrad 
     41  1.2  riastrad struct nvkm_i2c_port;
     42  1.1  riastrad 
     43  1.1  riastrad struct nouveau_encoder {
     44  1.1  riastrad 	struct drm_encoder_slave base;
     45  1.1  riastrad 
     46  1.1  riastrad 	struct dcb_output *dcb;
     47  1.1  riastrad 	int or;
     48  1.3  riastrad 	int link;
     49  1.2  riastrad 
     50  1.2  riastrad 	struct i2c_adapter *i2c;
     51  1.2  riastrad 	struct nvkm_i2c_aux *aux;
     52  1.1  riastrad 
     53  1.1  riastrad 	/* different to drm_encoder.crtc, this reflects what's
     54  1.1  riastrad 	 * actually programmed on the hw, not the proposed crtc */
     55  1.1  riastrad 	struct drm_crtc *crtc;
     56  1.2  riastrad 	u32 ctrl;
     57  1.1  riastrad 
     58  1.1  riastrad 	struct drm_display_mode mode;
     59  1.1  riastrad 	int last_dpms;
     60  1.1  riastrad 
     61  1.1  riastrad 	struct nv04_output_reg restore;
     62  1.1  riastrad 
     63  1.1  riastrad 	union {
     64  1.1  riastrad 		struct {
     65  1.3  riastrad 			struct nv50_mstm *mstm;
     66  1.1  riastrad 			int link_nr;
     67  1.1  riastrad 			int link_bw;
     68  1.1  riastrad 		} dp;
     69  1.1  riastrad 	};
     70  1.3  riastrad 
     71  1.3  riastrad 	void (*enc_save)(struct drm_encoder *encoder);
     72  1.3  riastrad 	void (*enc_restore)(struct drm_encoder *encoder);
     73  1.3  riastrad 	void (*update)(struct nouveau_encoder *, u8 head,
     74  1.3  riastrad 		       struct nv50_head_atom *, u8 proto, u8 depth);
     75  1.1  riastrad };
     76  1.1  riastrad 
     77  1.1  riastrad struct nouveau_encoder *
     78  1.1  riastrad find_encoder(struct drm_connector *connector, int type);
     79  1.1  riastrad 
     80  1.1  riastrad static inline struct nouveau_encoder *nouveau_encoder(struct drm_encoder *enc)
     81  1.1  riastrad {
     82  1.1  riastrad 	struct drm_encoder_slave *slave = to_encoder_slave(enc);
     83  1.1  riastrad 
     84  1.1  riastrad 	return container_of(slave, struct nouveau_encoder, base);
     85  1.1  riastrad }
     86  1.1  riastrad 
     87  1.1  riastrad static inline struct drm_encoder *to_drm_encoder(struct nouveau_encoder *enc)
     88  1.1  riastrad {
     89  1.1  riastrad 	return &enc->base.base;
     90  1.1  riastrad }
     91  1.1  riastrad 
     92  1.3  riastrad static inline const struct drm_encoder_slave_funcs *
     93  1.1  riastrad get_slave_funcs(struct drm_encoder *enc)
     94  1.1  riastrad {
     95  1.1  riastrad 	return to_encoder_slave(enc)->slave_funcs;
     96  1.1  riastrad }
     97  1.1  riastrad 
     98  1.1  riastrad /* nouveau_dp.c */
     99  1.3  riastrad enum nouveau_dp_status {
    100  1.3  riastrad 	NOUVEAU_DP_SST,
    101  1.3  riastrad 	NOUVEAU_DP_MST,
    102  1.3  riastrad };
    103  1.3  riastrad 
    104  1.2  riastrad int nouveau_dp_detect(struct nouveau_encoder *);
    105  1.1  riastrad 
    106  1.1  riastrad struct nouveau_connector *
    107  1.1  riastrad nouveau_encoder_connector_get(struct nouveau_encoder *encoder);
    108  1.1  riastrad 
    109  1.3  riastrad int nv50_mstm_detect(struct nv50_mstm *, u8 dpcd[8], int allow);
    110  1.3  riastrad void nv50_mstm_remove(struct nv50_mstm *);
    111  1.3  riastrad void nv50_mstm_service(struct nv50_mstm *);
    112  1.1  riastrad #endif /* __NOUVEAU_ENCODER_H__ */
    113