GNU Linux-libre 4.19.286-gnu1
[releases.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 #include "hw_shared.h"
33
34 struct dc_bios;
35 struct dc_context;
36 struct dc_crtc_timing;
37
38 enum dp_pixel_encoding_type {
39         DP_PIXEL_ENCODING_TYPE_RGB444           = 0x00000000,
40         DP_PIXEL_ENCODING_TYPE_YCBCR422         = 0x00000001,
41         DP_PIXEL_ENCODING_TYPE_YCBCR444         = 0x00000002,
42         DP_PIXEL_ENCODING_TYPE_RGB_WIDE_GAMUT   = 0x00000003,
43         DP_PIXEL_ENCODING_TYPE_Y_ONLY           = 0x00000004,
44         DP_PIXEL_ENCODING_TYPE_YCBCR420         = 0x00000005
45 };
46
47 enum dp_component_depth {
48         DP_COMPONENT_PIXEL_DEPTH_6BPC           = 0x00000000,
49         DP_COMPONENT_PIXEL_DEPTH_8BPC           = 0x00000001,
50         DP_COMPONENT_PIXEL_DEPTH_10BPC          = 0x00000002,
51         DP_COMPONENT_PIXEL_DEPTH_12BPC          = 0x00000003,
52         DP_COMPONENT_PIXEL_DEPTH_16BPC          = 0x00000004
53 };
54
55 struct encoder_info_frame {
56         /* auxiliary video information */
57         struct dc_info_packet avi;
58         struct dc_info_packet gamut;
59         struct dc_info_packet vendor;
60         /* source product description */
61         struct dc_info_packet spd;
62         /* video stream configuration */
63         struct dc_info_packet vsc;
64         /* HDR Static MetaData */
65         struct dc_info_packet hdrsmd;
66 };
67
68 struct encoder_unblank_param {
69         struct dc_link_settings link_settings;
70         unsigned int pixel_clk_khz;
71 };
72
73 struct encoder_set_dp_phy_pattern_param {
74         enum dp_test_pattern dp_phy_pattern;
75         const uint8_t *custom_pattern;
76         uint32_t custom_pattern_size;
77         enum dp_panel_mode dp_panel_mode;
78 };
79
80 struct stream_encoder {
81         const struct stream_encoder_funcs *funcs;
82         struct dc_context *ctx;
83         struct dc_bios *bp;
84         enum engine_id id;
85 };
86
87 struct stream_encoder_funcs {
88         void (*dp_set_stream_attribute)(
89                 struct stream_encoder *enc,
90                 struct dc_crtc_timing *crtc_timing,
91                 enum dc_color_space output_color_space);
92
93         void (*hdmi_set_stream_attribute)(
94                 struct stream_encoder *enc,
95                 struct dc_crtc_timing *crtc_timing,
96                 int actual_pix_clk_khz,
97                 bool enable_audio);
98
99         void (*dvi_set_stream_attribute)(
100                 struct stream_encoder *enc,
101                 struct dc_crtc_timing *crtc_timing,
102                 bool is_dual_link);
103
104         void (*set_mst_bandwidth)(
105                 struct stream_encoder *enc,
106                 struct fixed31_32 avg_time_slots_per_mtp);
107
108         void (*update_hdmi_info_packets)(
109                 struct stream_encoder *enc,
110                 const struct encoder_info_frame *info_frame);
111
112         void (*stop_hdmi_info_packets)(
113                 struct stream_encoder *enc);
114
115         void (*update_dp_info_packets)(
116                 struct stream_encoder *enc,
117                 const struct encoder_info_frame *info_frame);
118
119         void (*stop_dp_info_packets)(
120                 struct stream_encoder *enc);
121
122         void (*dp_blank)(
123                 struct stream_encoder *enc);
124
125         void (*dp_unblank)(
126                 struct stream_encoder *enc,
127                 const struct encoder_unblank_param *param);
128
129         void (*audio_mute_control)(
130                 struct stream_encoder *enc, bool mute);
131
132         void (*dp_audio_setup)(
133                 struct stream_encoder *enc,
134                 unsigned int az_inst,
135                 struct audio_info *info);
136
137         void (*dp_audio_enable) (
138                         struct stream_encoder *enc);
139
140         void (*dp_audio_disable) (
141                         struct stream_encoder *enc);
142
143         void (*hdmi_audio_setup)(
144                 struct stream_encoder *enc,
145                 unsigned int az_inst,
146                 struct audio_info *info,
147                 struct audio_crtc_info *audio_crtc_info);
148
149         void (*hdmi_audio_disable) (
150                         struct stream_encoder *enc);
151
152         void (*setup_stereo_sync) (
153                         struct stream_encoder *enc,
154                         int tg_inst,
155                         bool enable);
156
157         void (*set_avmute)(
158                 struct stream_encoder *enc, bool enable);
159
160 };
161
162 #endif /* STREAM_ENCODER_H_ */