Merge tag 'for-4.15/dm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/device...
[sfrench/cifs-2.6.git] / drivers / gpu / drm / amd / display / dc / inc / hw / stream_encoder.h
1 /*
2  * Copyright 2017 Advanced Micro Devices, Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20  * OTHER DEALINGS IN THE SOFTWARE.
21  *
22  */
23 /*
24  * stream_encoder.h
25  *
26  */
27
28 #ifndef STREAM_ENCODER_H_
29 #define STREAM_ENCODER_H_
30
31 #include "audio_types.h"
32
33 struct dc_bios;
34 struct dc_context;
35 struct dc_crtc_timing;
36
37 struct encoder_info_packet {
38         bool valid;
39         uint8_t hb0;
40         uint8_t hb1;
41         uint8_t hb2;
42         uint8_t hb3;
43         uint8_t sb[32];
44 };
45
46 struct encoder_info_frame {
47         /* auxiliary video information */
48         struct encoder_info_packet avi;
49         struct encoder_info_packet gamut;
50         struct encoder_info_packet vendor;
51         /* source product description */
52         struct encoder_info_packet spd;
53         /* video stream configuration */
54         struct encoder_info_packet vsc;
55         /* HDR Static MetaData */
56         struct encoder_info_packet hdrsmd;
57 };
58
59 struct encoder_unblank_param {
60         struct dc_link_settings link_settings;
61         unsigned int pixel_clk_khz;
62 };
63
64 struct encoder_set_dp_phy_pattern_param {
65         enum dp_test_pattern dp_phy_pattern;
66         const uint8_t *custom_pattern;
67         uint32_t custom_pattern_size;
68         enum dp_panel_mode dp_panel_mode;
69 };
70
71 struct stream_encoder {
72         const struct stream_encoder_funcs *funcs;
73         struct dc_context *ctx;
74         struct dc_bios *bp;
75         enum engine_id id;
76 };
77
78 struct stream_encoder_funcs {
79         void (*dp_set_stream_attribute)(
80                 struct stream_encoder *enc,
81                 struct dc_crtc_timing *crtc_timing,
82                 enum dc_color_space output_color_space);
83
84         void (*hdmi_set_stream_attribute)(
85                 struct stream_encoder *enc,
86                 struct dc_crtc_timing *crtc_timing,
87                 int actual_pix_clk_khz,
88                 bool enable_audio);
89
90         void (*dvi_set_stream_attribute)(
91                 struct stream_encoder *enc,
92                 struct dc_crtc_timing *crtc_timing,
93                 bool is_dual_link);
94
95         void (*set_mst_bandwidth)(
96                 struct stream_encoder *enc,
97                 struct fixed31_32 avg_time_slots_per_mtp);
98
99         void (*update_hdmi_info_packets)(
100                 struct stream_encoder *enc,
101                 const struct encoder_info_frame *info_frame);
102
103         void (*stop_hdmi_info_packets)(
104                 struct stream_encoder *enc);
105
106         void (*update_dp_info_packets)(
107                 struct stream_encoder *enc,
108                 const struct encoder_info_frame *info_frame);
109
110         void (*stop_dp_info_packets)(
111                 struct stream_encoder *enc);
112
113         void (*dp_blank)(
114                 struct stream_encoder *enc);
115
116         void (*dp_unblank)(
117                 struct stream_encoder *enc,
118                 const struct encoder_unblank_param *param);
119
120         void (*audio_mute_control)(
121                 struct stream_encoder *enc, bool mute);
122
123         void (*dp_audio_setup)(
124                 struct stream_encoder *enc,
125                 unsigned int az_inst,
126                 struct audio_info *info);
127
128         void (*dp_audio_enable) (
129                         struct stream_encoder *enc);
130
131         void (*dp_audio_disable) (
132                         struct stream_encoder *enc);
133
134         void (*hdmi_audio_setup)(
135                 struct stream_encoder *enc,
136                 unsigned int az_inst,
137                 struct audio_info *info,
138                 struct audio_crtc_info *audio_crtc_info);
139
140         void (*hdmi_audio_disable) (
141                         struct stream_encoder *enc);
142
143         void (*setup_stereo_sync) (
144                         struct stream_encoder *enc,
145                         int tg_inst,
146                         bool enable);
147
148         void (*set_avmute)(
149                 struct stream_encoder *enc, bool enable);
150 };
151
152 #endif /* STREAM_ENCODER_H_ */