Merge branch 'work.d_path' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[linux-2.6-microblaze.git] / drivers / gpu / drm / amd / display / dc / dc_types.h
1 /*
2  * Copyright 2012-15 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  * Authors: AMD
23  *
24  */
25 #ifndef DC_TYPES_H_
26 #define DC_TYPES_H_
27
28 /* AND EdidUtility only needs a portion
29  * of this file, including the rest only
30  * causes additional issues.
31  */
32 #include "os_types.h"
33 #include "fixed31_32.h"
34 #include "irq_types.h"
35 #include "dc_dp_types.h"
36 #include "dc_hw_types.h"
37 #include "dal_types.h"
38 #include "grph_object_defs.h"
39
40 #ifdef CONFIG_DRM_AMD_DC_HDCP
41 #include "dm_cp_psp.h"
42 #endif
43
44 /* forward declarations */
45 struct dc_plane_state;
46 struct dc_stream_state;
47 struct dc_link;
48 struct dc_sink;
49 struct dal;
50 struct dc_dmub_srv;
51
52 /********************************
53  * Environment definitions
54  ********************************/
55 enum dce_environment {
56         DCE_ENV_PRODUCTION_DRV = 0,
57         /* Emulation on FPGA, in "Maximus" System.
58          * This environment enforces that *only* DC registers accessed.
59          * (access to non-DC registers will hang FPGA) */
60         DCE_ENV_FPGA_MAXIMUS,
61         /* Emulation on real HW or on FPGA. Used by Diagnostics, enforces
62          * requirements of Diagnostics team. */
63         DCE_ENV_DIAG,
64         /*
65          * Guest VM system, DC HW may exist but is not virtualized and
66          * should not be used.  SW support for VDI only.
67          */
68         DCE_ENV_VIRTUAL_HW
69 };
70
71 /* Note: use these macro definitions instead of direct comparison! */
72 #define IS_FPGA_MAXIMUS_DC(dce_environment) \
73         (dce_environment == DCE_ENV_FPGA_MAXIMUS)
74
75 #define IS_DIAG_DC(dce_environment) \
76         (IS_FPGA_MAXIMUS_DC(dce_environment) || (dce_environment == DCE_ENV_DIAG))
77
78 struct hw_asic_id {
79         uint32_t chip_id;
80         uint32_t chip_family;
81         uint32_t pci_revision_id;
82         uint32_t hw_internal_rev;
83         uint32_t vram_type;
84         uint32_t vram_width;
85         uint32_t feature_flags;
86         uint32_t fake_paths_num;
87         void *atombios_base_address;
88 };
89
90 struct dc_perf_trace {
91         unsigned long read_count;
92         unsigned long write_count;
93         unsigned long last_entry_read;
94         unsigned long last_entry_write;
95 };
96
97 struct dc_context {
98         struct dc *dc;
99
100         void *driver_context; /* e.g. amdgpu_device */
101         struct dc_perf_trace *perf_trace;
102         void *cgs_device;
103
104         enum dce_environment dce_environment;
105         struct hw_asic_id asic_id;
106
107         /* todo: below should probably move to dc.  to facilitate removal
108          * of AS we will store these here
109          */
110         enum dce_version dce_version;
111         struct dc_bios *dc_bios;
112         bool created_bios;
113         struct gpio_service *gpio_service;
114         uint32_t dc_sink_id_count;
115         uint32_t dc_stream_id_count;
116         uint32_t dc_edp_id_count;
117         uint64_t fbc_gpu_addr;
118         struct dc_dmub_srv *dmub_srv;
119
120 #ifdef CONFIG_DRM_AMD_DC_HDCP
121         struct cp_psp cp_psp;
122 #endif
123 };
124
125
126 #define DC_MAX_EDID_BUFFER_SIZE 1280
127 #define DC_EDID_BLOCK_SIZE 128
128 #define MAX_SURFACE_NUM 4
129 #define NUM_PIXEL_FORMATS 10
130 #define MAX_REPEATER_CNT 8
131
132 #include "dc_ddc_types.h"
133
134 enum tiling_mode {
135         TILING_MODE_INVALID,
136         TILING_MODE_LINEAR,
137         TILING_MODE_TILED,
138         TILING_MODE_COUNT
139 };
140
141 enum view_3d_format {
142         VIEW_3D_FORMAT_NONE = 0,
143         VIEW_3D_FORMAT_FRAME_SEQUENTIAL,
144         VIEW_3D_FORMAT_SIDE_BY_SIDE,
145         VIEW_3D_FORMAT_TOP_AND_BOTTOM,
146         VIEW_3D_FORMAT_COUNT,
147         VIEW_3D_FORMAT_FIRST = VIEW_3D_FORMAT_FRAME_SEQUENTIAL
148 };
149
150 enum plane_stereo_format {
151         PLANE_STEREO_FORMAT_NONE = 0,
152         PLANE_STEREO_FORMAT_SIDE_BY_SIDE = 1,
153         PLANE_STEREO_FORMAT_TOP_AND_BOTTOM = 2,
154         PLANE_STEREO_FORMAT_FRAME_ALTERNATE = 3,
155         PLANE_STEREO_FORMAT_ROW_INTERLEAVED = 5,
156         PLANE_STEREO_FORMAT_COLUMN_INTERLEAVED = 6,
157         PLANE_STEREO_FORMAT_CHECKER_BOARD = 7
158 };
159
160 /* TODO: Find way to calculate number of bits
161  *  Please increase if pixel_format enum increases
162  * num  from  PIXEL_FORMAT_INDEX8 to PIXEL_FORMAT_444BPP32
163  */
164
165 enum dc_edid_connector_type {
166         DC_EDID_CONNECTOR_UNKNOWN = 0,
167         DC_EDID_CONNECTOR_ANALOG = 1,
168         DC_EDID_CONNECTOR_DIGITAL = 10,
169         DC_EDID_CONNECTOR_DVI = 11,
170         DC_EDID_CONNECTOR_HDMIA = 12,
171         DC_EDID_CONNECTOR_MDDI = 14,
172         DC_EDID_CONNECTOR_DISPLAYPORT = 15
173 };
174
175 enum dc_edid_status {
176         EDID_OK,
177         EDID_BAD_INPUT,
178         EDID_NO_RESPONSE,
179         EDID_BAD_CHECKSUM,
180         EDID_THE_SAME,
181         EDID_FALL_BACK,
182 };
183
184 enum act_return_status {
185         ACT_SUCCESS,
186         ACT_LINK_LOST,
187         ACT_FAILED
188 };
189
190 /* audio capability from EDID*/
191 struct dc_cea_audio_mode {
192         uint8_t format_code; /* ucData[0] [6:3]*/
193         uint8_t channel_count; /* ucData[0] [2:0]*/
194         uint8_t sample_rate; /* ucData[1]*/
195         union {
196                 uint8_t sample_size; /* for LPCM*/
197                 /*  for Audio Formats 2-8 (Max bit rate divided by 8 kHz)*/
198                 uint8_t max_bit_rate;
199                 uint8_t audio_codec_vendor_specific; /* for Audio Formats 9-15*/
200         };
201 };
202
203 struct dc_edid {
204         uint32_t length;
205         uint8_t raw_edid[DC_MAX_EDID_BUFFER_SIZE];
206 };
207
208 /* When speaker location data block is not available, DEFAULT_SPEAKER_LOCATION
209  * is used. In this case we assume speaker location are: front left, front
210  * right and front center. */
211 #define DEFAULT_SPEAKER_LOCATION 5
212
213 #define DC_MAX_AUDIO_DESC_COUNT 16
214
215 #define AUDIO_INFO_DISPLAY_NAME_SIZE_IN_CHARS 20
216
217 union display_content_support {
218         unsigned int raw;
219         struct {
220                 unsigned int valid_content_type :1;
221                 unsigned int game_content :1;
222                 unsigned int cinema_content :1;
223                 unsigned int photo_content :1;
224                 unsigned int graphics_content :1;
225                 unsigned int reserved :27;
226         } bits;
227 };
228
229 struct dc_panel_patch {
230         unsigned int dppowerup_delay;
231         unsigned int extra_t12_ms;
232         unsigned int extra_delay_backlight_off;
233         unsigned int extra_t7_ms;
234         unsigned int skip_scdc_overwrite;
235         unsigned int delay_ignore_msa;
236         unsigned int disable_fec;
237         unsigned int extra_t3_ms;
238         unsigned int max_dsc_target_bpp_limit;
239         unsigned int skip_avmute;
240 };
241
242 struct dc_edid_caps {
243         /* sink identification */
244         uint16_t manufacturer_id;
245         uint16_t product_id;
246         uint32_t serial_number;
247         uint8_t manufacture_week;
248         uint8_t manufacture_year;
249         uint8_t display_name[AUDIO_INFO_DISPLAY_NAME_SIZE_IN_CHARS];
250
251         /* audio caps */
252         uint8_t speaker_flags;
253         uint32_t audio_mode_count;
254         struct dc_cea_audio_mode audio_modes[DC_MAX_AUDIO_DESC_COUNT];
255         uint32_t audio_latency;
256         uint32_t video_latency;
257
258         union display_content_support content_support;
259
260         uint8_t qs_bit;
261         uint8_t qy_bit;
262
263         uint32_t max_tmds_clk_mhz;
264
265         /*HDMI 2.0 caps*/
266         bool lte_340mcsc_scramble;
267
268         bool edid_hdmi;
269         bool hdr_supported;
270
271         struct dc_panel_patch panel_patch;
272 };
273
274 struct dc_mode_flags {
275         /* note: part of refresh rate flag*/
276         uint32_t INTERLACE :1;
277         /* native display timing*/
278         uint32_t NATIVE :1;
279         /* preferred is the recommended mode, one per display */
280         uint32_t PREFERRED :1;
281         /* true if this mode should use reduced blanking timings
282          *_not_ related to the Reduced Blanking adjustment*/
283         uint32_t REDUCED_BLANKING :1;
284         /* note: part of refreshrate flag*/
285         uint32_t VIDEO_OPTIMIZED_RATE :1;
286         /* should be reported to upper layers as mode_flags*/
287         uint32_t PACKED_PIXEL_FORMAT :1;
288         /*< preferred view*/
289         uint32_t PREFERRED_VIEW :1;
290         /* this timing should be used only in tiled mode*/
291         uint32_t TILED_MODE :1;
292         uint32_t DSE_MODE :1;
293         /* Refresh rate divider when Miracast sink is using a
294          different rate than the output display device
295          Must be zero for wired displays and non-zero for
296          Miracast displays*/
297         uint32_t MIRACAST_REFRESH_DIVIDER;
298 };
299
300
301 enum dc_timing_source {
302         TIMING_SOURCE_UNDEFINED,
303
304         /* explicitly specifed by user, most important*/
305         TIMING_SOURCE_USER_FORCED,
306         TIMING_SOURCE_USER_OVERRIDE,
307         TIMING_SOURCE_CUSTOM,
308         TIMING_SOURCE_EXPLICIT,
309
310         /* explicitly specified by the display device, more important*/
311         TIMING_SOURCE_EDID_CEA_SVD_3D,
312         TIMING_SOURCE_EDID_CEA_SVD_PREFERRED,
313         TIMING_SOURCE_EDID_CEA_SVD_420,
314         TIMING_SOURCE_EDID_DETAILED,
315         TIMING_SOURCE_EDID_ESTABLISHED,
316         TIMING_SOURCE_EDID_STANDARD,
317         TIMING_SOURCE_EDID_CEA_SVD,
318         TIMING_SOURCE_EDID_CVT_3BYTE,
319         TIMING_SOURCE_EDID_4BYTE,
320         TIMING_SOURCE_VBIOS,
321         TIMING_SOURCE_CV,
322         TIMING_SOURCE_TV,
323         TIMING_SOURCE_HDMI_VIC,
324
325         /* implicitly specified by display device, still safe but less important*/
326         TIMING_SOURCE_DEFAULT,
327
328         /* only used for custom base modes */
329         TIMING_SOURCE_CUSTOM_BASE,
330
331         /* these timing might not work, least important*/
332         TIMING_SOURCE_RANGELIMIT,
333         TIMING_SOURCE_OS_FORCED,
334         TIMING_SOURCE_IMPLICIT,
335
336         /* only used by default mode list*/
337         TIMING_SOURCE_BASICMODE,
338
339         TIMING_SOURCE_COUNT
340 };
341
342
343 struct stereo_3d_features {
344         bool supported                  ;
345         bool allTimings                 ;
346         bool cloneMode                  ;
347         bool scaling                    ;
348         bool singleFrameSWPacked;
349 };
350
351 enum dc_timing_support_method {
352         TIMING_SUPPORT_METHOD_UNDEFINED,
353         TIMING_SUPPORT_METHOD_EXPLICIT,
354         TIMING_SUPPORT_METHOD_IMPLICIT,
355         TIMING_SUPPORT_METHOD_NATIVE
356 };
357
358 struct dc_mode_info {
359         uint32_t pixel_width;
360         uint32_t pixel_height;
361         uint32_t field_rate;
362         /* Vertical refresh rate for progressive modes.
363         * Field rate for interlaced modes.*/
364
365         enum dc_timing_standard timing_standard;
366         enum dc_timing_source timing_source;
367         struct dc_mode_flags flags;
368 };
369
370 enum dc_power_state {
371         DC_POWER_STATE_ON = 1,
372         DC_POWER_STATE_STANDBY,
373         DC_POWER_STATE_SUSPEND,
374         DC_POWER_STATE_OFF
375 };
376
377 /* DC PowerStates */
378 enum dc_video_power_state {
379         DC_VIDEO_POWER_UNSPECIFIED = 0,
380         DC_VIDEO_POWER_ON = 1,
381         DC_VIDEO_POWER_STANDBY,
382         DC_VIDEO_POWER_SUSPEND,
383         DC_VIDEO_POWER_OFF,
384         DC_VIDEO_POWER_HIBERNATE,
385         DC_VIDEO_POWER_SHUTDOWN,
386         DC_VIDEO_POWER_ULPS,    /* BACO or Ultra-Light-Power-State */
387         DC_VIDEO_POWER_AFTER_RESET,
388         DC_VIDEO_POWER_MAXIMUM
389 };
390
391 enum dc_acpi_cm_power_state {
392         DC_ACPI_CM_POWER_STATE_D0 = 1,
393         DC_ACPI_CM_POWER_STATE_D1 = 2,
394         DC_ACPI_CM_POWER_STATE_D2 = 4,
395         DC_ACPI_CM_POWER_STATE_D3 = 8
396 };
397
398 enum dc_connection_type {
399         dc_connection_none,
400         dc_connection_single,
401         dc_connection_mst_branch,
402         dc_connection_sst_branch
403 };
404
405 struct dc_csc_adjustments {
406         struct fixed31_32 contrast;
407         struct fixed31_32 saturation;
408         struct fixed31_32 brightness;
409         struct fixed31_32 hue;
410 };
411
412 enum dpcd_downstream_port_max_bpc {
413         DOWN_STREAM_MAX_8BPC = 0,
414         DOWN_STREAM_MAX_10BPC,
415         DOWN_STREAM_MAX_12BPC,
416         DOWN_STREAM_MAX_16BPC
417 };
418
419
420 enum link_training_offset {
421         DPRX                = 0,
422         LTTPR_PHY_REPEATER1 = 1,
423         LTTPR_PHY_REPEATER2 = 2,
424         LTTPR_PHY_REPEATER3 = 3,
425         LTTPR_PHY_REPEATER4 = 4,
426         LTTPR_PHY_REPEATER5 = 5,
427         LTTPR_PHY_REPEATER6 = 6,
428         LTTPR_PHY_REPEATER7 = 7,
429         LTTPR_PHY_REPEATER8 = 8
430 };
431
432 struct dc_lttpr_caps {
433         union dpcd_rev revision;
434         uint8_t mode;
435         uint8_t max_lane_count;
436         uint8_t max_link_rate;
437         uint8_t phy_repeater_cnt;
438         uint8_t max_ext_timeout;
439         uint8_t aux_rd_interval[MAX_REPEATER_CNT - 1];
440 };
441
442 struct dc_dongle_caps {
443         /* dongle type (DP converter, CV smart dongle) */
444         enum display_dongle_type dongle_type;
445         bool extendedCapValid;
446         /* If dongle_type == DISPLAY_DONGLE_DP_HDMI_CONVERTER,
447         indicates 'Frame Sequential-to-lllFrame Pack' conversion capability.*/
448         bool is_dp_hdmi_s3d_converter;
449         bool is_dp_hdmi_ycbcr422_pass_through;
450         bool is_dp_hdmi_ycbcr420_pass_through;
451         bool is_dp_hdmi_ycbcr422_converter;
452         bool is_dp_hdmi_ycbcr420_converter;
453         uint32_t dp_hdmi_max_bpc;
454         uint32_t dp_hdmi_max_pixel_clk_in_khz;
455 };
456 /* Scaling format */
457 enum scaling_transformation {
458         SCALING_TRANSFORMATION_UNINITIALIZED,
459         SCALING_TRANSFORMATION_IDENTITY = 0x0001,
460         SCALING_TRANSFORMATION_CENTER_TIMING = 0x0002,
461         SCALING_TRANSFORMATION_FULL_SCREEN_SCALE = 0x0004,
462         SCALING_TRANSFORMATION_PRESERVE_ASPECT_RATIO_SCALE = 0x0008,
463         SCALING_TRANSFORMATION_DAL_DECIDE = 0x0010,
464         SCALING_TRANSFORMATION_INVALID = 0x80000000,
465
466         /* Flag the first and last */
467         SCALING_TRANSFORMATION_BEGING = SCALING_TRANSFORMATION_IDENTITY,
468         SCALING_TRANSFORMATION_END =
469                 SCALING_TRANSFORMATION_PRESERVE_ASPECT_RATIO_SCALE
470 };
471
472 enum display_content_type {
473         DISPLAY_CONTENT_TYPE_NO_DATA = 0,
474         DISPLAY_CONTENT_TYPE_GRAPHICS = 1,
475         DISPLAY_CONTENT_TYPE_PHOTO = 2,
476         DISPLAY_CONTENT_TYPE_CINEMA = 4,
477         DISPLAY_CONTENT_TYPE_GAME = 8
478 };
479
480 enum cm_gamut_adjust_type {
481         CM_GAMUT_ADJUST_TYPE_BYPASS = 0,
482         CM_GAMUT_ADJUST_TYPE_HW, /* without adjustments */
483         CM_GAMUT_ADJUST_TYPE_SW /* use adjustments */
484 };
485
486 struct cm_grph_csc_adjustment {
487         struct fixed31_32 temperature_matrix[12];
488         enum cm_gamut_adjust_type gamut_adjust_type;
489         enum cm_gamut_coef_format gamut_coef_format;
490 };
491
492 /* writeback */
493 struct dwb_stereo_params {
494         bool                            stereo_enabled;         /* false: normal mode, true: 3D stereo */
495         enum dwb_stereo_type            stereo_type;            /* indicates stereo format */
496         bool                            stereo_polarity;        /* indicates left eye or right eye comes first in stereo mode */
497         enum dwb_stereo_eye_select      stereo_eye_select;      /* indicate which eye should be captured */
498 };
499
500 struct dc_dwb_cnv_params {
501         unsigned int            src_width;      /* input active width */
502         unsigned int            src_height;     /* input active height (half-active height in interlaced mode) */
503         unsigned int            crop_width;     /* cropped window width at cnv output */
504         bool                    crop_en;        /* window cropping enable in cnv */
505         unsigned int            crop_height;    /* cropped window height at cnv output */
506         unsigned int            crop_x;         /* cropped window start x value at cnv output */
507         unsigned int            crop_y;         /* cropped window start y value at cnv output */
508         enum dwb_cnv_out_bpc cnv_out_bpc;       /* cnv output pixel depth - 8bpc or 10bpc */
509         enum dwb_out_format     fc_out_format;  /* dwb output pixel format - 2101010 or 16161616 and ARGB or RGBA */
510         enum dwb_out_denorm     out_denorm_mode;/* dwb output denormalization mode */
511         unsigned int            out_max_pix_val;/* pixel values greater than out_max_pix_val are clamped to out_max_pix_val */
512         unsigned int            out_min_pix_val;/* pixel values less than out_min_pix_val are clamped to out_min_pix_val */
513 };
514
515 struct dc_dwb_params {
516         unsigned int                    dwbscl_black_color; /* must be in FP1.5.10 */
517         unsigned int                    hdr_mult;       /* must be in FP1.6.12 */
518         struct cm_grph_csc_adjustment   csc_params;
519         struct dwb_stereo_params        stereo_params;
520         struct dc_dwb_cnv_params        cnv_params;     /* CNV source size and cropping window parameters */
521         unsigned int                    dest_width;     /* Destination width */
522         unsigned int                    dest_height;    /* Destination height */
523         enum dwb_scaler_mode            out_format;     /* default = YUV420 - TODO: limit this to 0 and 1 on dcn3 */
524         enum dwb_output_depth           output_depth;   /* output pixel depth - 8bpc or 10bpc */
525         enum dwb_capture_rate           capture_rate;   /* controls the frame capture rate */
526         struct scaling_taps             scaler_taps;    /* Scaling taps */
527         enum dwb_subsample_position     subsample_position;
528         struct dc_transfer_func *out_transfer_func;
529 };
530
531 /* audio*/
532
533 union audio_sample_rates {
534         struct sample_rates {
535                 uint8_t RATE_32:1;
536                 uint8_t RATE_44_1:1;
537                 uint8_t RATE_48:1;
538                 uint8_t RATE_88_2:1;
539                 uint8_t RATE_96:1;
540                 uint8_t RATE_176_4:1;
541                 uint8_t RATE_192:1;
542         } rate;
543
544         uint8_t all;
545 };
546
547 struct audio_speaker_flags {
548         uint32_t FL_FR:1;
549         uint32_t LFE:1;
550         uint32_t FC:1;
551         uint32_t RL_RR:1;
552         uint32_t RC:1;
553         uint32_t FLC_FRC:1;
554         uint32_t RLC_RRC:1;
555         uint32_t SUPPORT_AI:1;
556 };
557
558 struct audio_speaker_info {
559         uint32_t ALLSPEAKERS:7;
560         uint32_t SUPPORT_AI:1;
561 };
562
563
564 struct audio_info_flags {
565
566         union {
567
568                 struct audio_speaker_flags speaker_flags;
569                 struct audio_speaker_info   info;
570
571                 uint8_t all;
572         };
573 };
574
575 enum audio_format_code {
576         AUDIO_FORMAT_CODE_FIRST = 1,
577         AUDIO_FORMAT_CODE_LINEARPCM = AUDIO_FORMAT_CODE_FIRST,
578
579         AUDIO_FORMAT_CODE_AC3,
580         /*Layers 1 & 2 */
581         AUDIO_FORMAT_CODE_MPEG1,
582         /*MPEG1 Layer 3 */
583         AUDIO_FORMAT_CODE_MP3,
584         /*multichannel */
585         AUDIO_FORMAT_CODE_MPEG2,
586         AUDIO_FORMAT_CODE_AAC,
587         AUDIO_FORMAT_CODE_DTS,
588         AUDIO_FORMAT_CODE_ATRAC,
589         AUDIO_FORMAT_CODE_1BITAUDIO,
590         AUDIO_FORMAT_CODE_DOLBYDIGITALPLUS,
591         AUDIO_FORMAT_CODE_DTS_HD,
592         AUDIO_FORMAT_CODE_MAT_MLP,
593         AUDIO_FORMAT_CODE_DST,
594         AUDIO_FORMAT_CODE_WMAPRO,
595         AUDIO_FORMAT_CODE_LAST,
596         AUDIO_FORMAT_CODE_COUNT =
597                 AUDIO_FORMAT_CODE_LAST - AUDIO_FORMAT_CODE_FIRST
598 };
599
600 struct audio_mode {
601          /* ucData[0] [6:3] */
602         enum audio_format_code format_code;
603         /* ucData[0] [2:0] */
604         uint8_t channel_count;
605         /* ucData[1] */
606         union audio_sample_rates sample_rates;
607         union {
608                 /* for LPCM */
609                 uint8_t sample_size;
610                 /* for Audio Formats 2-8 (Max bit rate divided by 8 kHz) */
611                 uint8_t max_bit_rate;
612                 /* for Audio Formats 9-15 */
613                 uint8_t vendor_specific;
614         };
615 };
616
617 struct audio_info {
618         struct audio_info_flags flags;
619         uint32_t video_latency;
620         uint32_t audio_latency;
621         uint32_t display_index;
622         uint8_t display_name[AUDIO_INFO_DISPLAY_NAME_SIZE_IN_CHARS];
623         uint32_t manufacture_id;
624         uint32_t product_id;
625         /* PortID used for ContainerID when defined */
626         uint32_t port_id[2];
627         uint32_t mode_count;
628         /* this field must be last in this struct */
629         struct audio_mode modes[DC_MAX_AUDIO_DESC_COUNT];
630 };
631 struct audio_check {
632         unsigned int audio_packet_type;
633         unsigned int max_audiosample_rate;
634         unsigned int acat;
635 };
636 enum dc_infoframe_type {
637         DC_HDMI_INFOFRAME_TYPE_VENDOR = 0x81,
638         DC_HDMI_INFOFRAME_TYPE_AVI = 0x82,
639         DC_HDMI_INFOFRAME_TYPE_SPD = 0x83,
640         DC_HDMI_INFOFRAME_TYPE_AUDIO = 0x84,
641         DC_DP_INFOFRAME_TYPE_PPS = 0x10,
642 };
643
644 struct dc_info_packet {
645         bool valid;
646         uint8_t hb0;
647         uint8_t hb1;
648         uint8_t hb2;
649         uint8_t hb3;
650         uint8_t sb[32];
651 };
652
653 struct dc_info_packet_128 {
654         bool valid;
655         uint8_t hb0;
656         uint8_t hb1;
657         uint8_t hb2;
658         uint8_t hb3;
659         uint8_t sb[128];
660 };
661
662 #define DC_PLANE_UPDATE_TIMES_MAX 10
663
664 struct dc_plane_flip_time {
665         unsigned int time_elapsed_in_us[DC_PLANE_UPDATE_TIMES_MAX];
666         unsigned int index;
667         unsigned int prev_update_time_in_us;
668 };
669
670 enum dc_psr_state {
671         PSR_STATE0 = 0x0,
672         PSR_STATE1,
673         PSR_STATE1a,
674         PSR_STATE2,
675         PSR_STATE2a,
676         PSR_STATE3,
677         PSR_STATE3Init,
678         PSR_STATE4,
679         PSR_STATE4a,
680         PSR_STATE4b,
681         PSR_STATE4c,
682         PSR_STATE4d,
683         PSR_STATE5,
684         PSR_STATE5a,
685         PSR_STATE5b,
686         PSR_STATE5c,
687         PSR_STATE_INVALID = 0xFF
688 };
689
690 struct psr_config {
691         unsigned char psr_version;
692         unsigned int psr_rfb_setup_time;
693         bool psr_exit_link_training_required;
694         bool psr_frame_capture_indication_req;
695         unsigned int psr_sdp_transmit_line_num_deadline;
696         bool allow_smu_optimizations;
697         bool allow_multi_disp_optimizations;
698 };
699
700 union dmcu_psr_level {
701         struct {
702                 unsigned int SKIP_CRC:1;
703                 unsigned int SKIP_DP_VID_STREAM_DISABLE:1;
704                 unsigned int SKIP_PHY_POWER_DOWN:1;
705                 unsigned int SKIP_AUX_ACK_CHECK:1;
706                 unsigned int SKIP_CRTC_DISABLE:1;
707                 unsigned int SKIP_AUX_RFB_CAPTURE_CHECK:1;
708                 unsigned int SKIP_SMU_NOTIFICATION:1;
709                 unsigned int SKIP_AUTO_STATE_ADVANCE:1;
710                 unsigned int DISABLE_PSR_ENTRY_ABORT:1;
711                 unsigned int SKIP_SINGLE_OTG_DISABLE:1;
712                 unsigned int RESERVED:22;
713         } bits;
714         unsigned int u32all;
715 };
716
717 enum physical_phy_id {
718         PHYLD_0,
719         PHYLD_1,
720         PHYLD_2,
721         PHYLD_3,
722         PHYLD_4,
723         PHYLD_5,
724         PHYLD_6,
725         PHYLD_7,
726         PHYLD_8,
727         PHYLD_9,
728         PHYLD_COUNT,
729         PHYLD_UNKNOWN = (-1L)
730 };
731
732 enum phy_type {
733         PHY_TYPE_UNKNOWN  = 1,
734         PHY_TYPE_PCIE_PHY = 2,
735         PHY_TYPE_UNIPHY = 3,
736 };
737
738 struct psr_context {
739         /* ddc line */
740         enum channel_id channel;
741         /* Transmitter id */
742         enum transmitter transmitterId;
743         /* Engine Id is used for Dig Be source select */
744         enum engine_id engineId;
745         /* Controller Id used for Dig Fe source select */
746         enum controller_id controllerId;
747         /* Pcie or Uniphy */
748         enum phy_type phyType;
749         /* Physical PHY Id used by SMU interpretation */
750         enum physical_phy_id smuPhyId;
751         /* Vertical total pixels from crtc timing.
752          * This is used for static screen detection.
753          * ie. If we want to detect half a frame,
754          * we use this to determine the hyst lines.
755          */
756         unsigned int crtcTimingVerticalTotal;
757         /* PSR supported from panel capabilities and
758          * current display configuration
759          */
760         bool psrSupportedDisplayConfig;
761         /* Whether fast link training is supported by the panel */
762         bool psrExitLinkTrainingRequired;
763         /* If RFB setup time is greater than the total VBLANK time,
764          * it is not possible for the sink to capture the video frame
765          * in the same frame the SDP is sent. In this case,
766          * the frame capture indication bit should be set and an extra
767          * static frame should be transmitted to the sink.
768          */
769         bool psrFrameCaptureIndicationReq;
770         /* Set the last possible line SDP may be transmitted without violating
771          * the RFB setup time or entering the active video frame.
772          */
773         unsigned int sdpTransmitLineNumDeadline;
774         /* The VSync rate in Hz used to calculate the
775          * step size for smooth brightness feature
776          */
777         unsigned int vsync_rate_hz;
778         unsigned int skipPsrWaitForPllLock;
779         unsigned int numberOfControllers;
780         /* Unused, for future use. To indicate that first changed frame from
781          * state3 shouldn't result in psr_inactive, but rather to perform
782          * an automatic single frame rfb_update.
783          */
784         bool rfb_update_auto_en;
785         /* Number of frame before entering static screen */
786         unsigned int timehyst_frames;
787         /* Partial frames before entering static screen */
788         unsigned int hyst_lines;
789         /* # of repeated AUX transaction attempts to make before
790          * indicating failure to the driver
791          */
792         unsigned int aux_repeats;
793         /* Controls hw blocks to power down during PSR active state */
794         union dmcu_psr_level psr_level;
795         /* Controls additional delay after remote frame capture before
796          * continuing powerd own
797          */
798         unsigned int frame_delay;
799         bool allow_smu_optimizations;
800         bool allow_multi_disp_optimizations;
801 };
802
803 struct colorspace_transform {
804         struct fixed31_32 matrix[12];
805         bool enable_remap;
806 };
807
808 enum i2c_mot_mode {
809         I2C_MOT_UNDEF,
810         I2C_MOT_TRUE,
811         I2C_MOT_FALSE
812 };
813
814 struct AsicStateEx {
815         unsigned int memoryClock;
816         unsigned int displayClock;
817         unsigned int engineClock;
818         unsigned int maxSupportedDppClock;
819         unsigned int dppClock;
820         unsigned int socClock;
821         unsigned int dcfClockDeepSleep;
822         unsigned int fClock;
823         unsigned int phyClock;
824 };
825
826
827 enum dc_clock_type {
828         DC_CLOCK_TYPE_DISPCLK = 0,
829         DC_CLOCK_TYPE_DPPCLK        = 1,
830 };
831
832 struct dc_clock_config {
833         uint32_t max_clock_khz;
834         uint32_t min_clock_khz;
835         uint32_t bw_requirequired_clock_khz;
836         uint32_t current_clock_khz;/*current clock in use*/
837 };
838
839 /* DSC DPCD capabilities */
840 union dsc_slice_caps1 {
841         struct {
842                 uint8_t NUM_SLICES_1 : 1;
843                 uint8_t NUM_SLICES_2 : 1;
844                 uint8_t RESERVED : 1;
845                 uint8_t NUM_SLICES_4 : 1;
846                 uint8_t NUM_SLICES_6 : 1;
847                 uint8_t NUM_SLICES_8 : 1;
848                 uint8_t NUM_SLICES_10 : 1;
849                 uint8_t NUM_SLICES_12 : 1;
850         } bits;
851         uint8_t raw;
852 };
853
854 union dsc_slice_caps2 {
855         struct {
856                 uint8_t NUM_SLICES_16 : 1;
857                 uint8_t NUM_SLICES_20 : 1;
858                 uint8_t NUM_SLICES_24 : 1;
859                 uint8_t RESERVED : 5;
860         } bits;
861         uint8_t raw;
862 };
863
864 union dsc_color_formats {
865         struct {
866                 uint8_t RGB : 1;
867                 uint8_t YCBCR_444 : 1;
868                 uint8_t YCBCR_SIMPLE_422 : 1;
869                 uint8_t YCBCR_NATIVE_422 : 1;
870                 uint8_t YCBCR_NATIVE_420 : 1;
871                 uint8_t RESERVED : 3;
872         } bits;
873         uint8_t raw;
874 };
875
876 union dsc_color_depth {
877         struct {
878                 uint8_t RESERVED1 : 1;
879                 uint8_t COLOR_DEPTH_8_BPC : 1;
880                 uint8_t COLOR_DEPTH_10_BPC : 1;
881                 uint8_t COLOR_DEPTH_12_BPC : 1;
882                 uint8_t RESERVED2 : 3;
883         } bits;
884         uint8_t raw;
885 };
886
887 struct dsc_dec_dpcd_caps {
888         bool is_dsc_supported;
889         uint8_t dsc_version;
890         int32_t rc_buffer_size; /* DSC RC buffer block size in bytes */
891         union dsc_slice_caps1 slice_caps1;
892         union dsc_slice_caps2 slice_caps2;
893         int32_t lb_bit_depth;
894         bool is_block_pred_supported;
895         int32_t edp_max_bits_per_pixel; /* Valid only in eDP */
896         union dsc_color_formats color_formats;
897         union dsc_color_depth color_depth;
898         int32_t throughput_mode_0_mps; /* In MPs */
899         int32_t throughput_mode_1_mps; /* In MPs */
900         int32_t max_slice_width;
901         uint32_t bpp_increment_div; /* bpp increment divisor, e.g. if 16, it's 1/16th of a bit */
902
903         /* Extended DSC caps */
904         uint32_t branch_overall_throughput_0_mps; /* In MPs */
905         uint32_t branch_overall_throughput_1_mps; /* In MPs */
906         uint32_t branch_max_line_width;
907         bool is_dp;
908 };
909
910 struct dc_golden_table {
911         uint16_t dc_golden_table_ver;
912         uint32_t aux_dphy_rx_control0_val;
913         uint32_t aux_dphy_tx_control_val;
914         uint32_t aux_dphy_rx_control1_val;
915         uint32_t dc_gpio_aux_ctrl_0_val;
916         uint32_t dc_gpio_aux_ctrl_1_val;
917         uint32_t dc_gpio_aux_ctrl_2_val;
918         uint32_t dc_gpio_aux_ctrl_3_val;
919         uint32_t dc_gpio_aux_ctrl_4_val;
920         uint32_t dc_gpio_aux_ctrl_5_val;
921 };
922
923 enum dc_gpu_mem_alloc_type {
924         DC_MEM_ALLOC_TYPE_GART,
925         DC_MEM_ALLOC_TYPE_FRAME_BUFFER,
926         DC_MEM_ALLOC_TYPE_INVISIBLE_FRAME_BUFFER,
927         DC_MEM_ALLOC_TYPE_AGP
928 };
929
930 enum dc_psr_version {
931         DC_PSR_VERSION_1                        = 0,
932         DC_PSR_VERSION_UNSUPPORTED              = 0xFFFFFFFF,
933 };
934
935 /* Possible values of display_endpoint_id.endpoint */
936 enum display_endpoint_type {
937         DISPLAY_ENDPOINT_PHY = 0, /* Physical connector. */
938         DISPLAY_ENDPOINT_UNKNOWN = -1
939 };
940
941 /* Extends graphics_object_id with an additional member 'ep_type' for
942  * distinguishing between physical endpoints (with entries in BIOS connector table) and
943  * logical endpoints.
944  */
945 struct display_endpoint_id {
946         struct graphics_object_id link_id;
947         enum display_endpoint_type ep_type;
948 };
949
950 #endif /* DC_TYPES_H_ */