xref: /OK3568_Linux_fs/kernel/include/drm/drm_dsc.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: MIT
2*4882a593Smuzhiyun  * Copyright (C) 2018 Intel Corp.
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Authors:
5*4882a593Smuzhiyun  * Manasi Navare <manasi.d.navare@intel.com>
6*4882a593Smuzhiyun  */
7*4882a593Smuzhiyun 
8*4882a593Smuzhiyun #ifndef DRM_DSC_H_
9*4882a593Smuzhiyun #define DRM_DSC_H_
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun #include <drm/drm_dp_helper.h>
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun /* VESA Display Stream Compression DSC 1.2 constants */
14*4882a593Smuzhiyun #define DSC_NUM_BUF_RANGES			15
15*4882a593Smuzhiyun #define DSC_MUX_WORD_SIZE_8_10_BPC		48
16*4882a593Smuzhiyun #define DSC_MUX_WORD_SIZE_12_BPC		64
17*4882a593Smuzhiyun #define DSC_RC_PIXELS_PER_GROUP			3
18*4882a593Smuzhiyun #define DSC_SCALE_DECREMENT_INTERVAL_MAX	4095
19*4882a593Smuzhiyun #define DSC_RANGE_BPG_OFFSET_MASK		0x3f
20*4882a593Smuzhiyun 
21*4882a593Smuzhiyun /* DSC Rate Control Constants */
22*4882a593Smuzhiyun #define DSC_RC_MODEL_SIZE_CONST		    8192
23*4882a593Smuzhiyun #define DSC_RC_EDGE_FACTOR_CONST	    6
24*4882a593Smuzhiyun #define DSC_RC_TGT_OFFSET_HI_CONST	    3
25*4882a593Smuzhiyun #define DSC_RC_TGT_OFFSET_LO_CONST	    3
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun /* DSC PPS constants and macros */
28*4882a593Smuzhiyun #define DSC_PPS_VERSION_MAJOR_SHIFT		4
29*4882a593Smuzhiyun #define DSC_PPS_BPC_SHIFT			4
30*4882a593Smuzhiyun #define DSC_PPS_MSB_SHIFT			8
31*4882a593Smuzhiyun #define DSC_PPS_LSB_MASK			(0xFF << 0)
32*4882a593Smuzhiyun #define DSC_PPS_BPP_HIGH_MASK			(0x3 << 8)
33*4882a593Smuzhiyun #define DSC_PPS_VBR_EN_SHIFT			2
34*4882a593Smuzhiyun #define DSC_PPS_SIMPLE422_SHIFT			3
35*4882a593Smuzhiyun #define DSC_PPS_CONVERT_RGB_SHIFT		4
36*4882a593Smuzhiyun #define DSC_PPS_BLOCK_PRED_EN_SHIFT		5
37*4882a593Smuzhiyun #define DSC_PPS_INIT_XMIT_DELAY_HIGH_MASK	(0x3 << 8)
38*4882a593Smuzhiyun #define DSC_PPS_SCALE_DEC_INT_HIGH_MASK		(0xF << 8)
39*4882a593Smuzhiyun #define DSC_PPS_RC_TGT_OFFSET_HI_SHIFT		4
40*4882a593Smuzhiyun #define DSC_PPS_RC_RANGE_MINQP_SHIFT		11
41*4882a593Smuzhiyun #define DSC_PPS_RC_RANGE_MAXQP_SHIFT		6
42*4882a593Smuzhiyun #define DSC_PPS_NATIVE_420_SHIFT		1
43*4882a593Smuzhiyun #define DSC_1_2_MAX_LINEBUF_DEPTH_BITS		16
44*4882a593Smuzhiyun #define DSC_1_2_MAX_LINEBUF_DEPTH_VAL		0
45*4882a593Smuzhiyun #define DSC_1_1_MAX_LINEBUF_DEPTH_BITS		13
46*4882a593Smuzhiyun 
47*4882a593Smuzhiyun /**
48*4882a593Smuzhiyun  * struct drm_dsc_rc_range_parameters - DSC Rate Control range parameters
49*4882a593Smuzhiyun  *
50*4882a593Smuzhiyun  * This defines different rate control parameters used by the DSC engine
51*4882a593Smuzhiyun  * to compress the frame.
52*4882a593Smuzhiyun  */
53*4882a593Smuzhiyun struct drm_dsc_rc_range_parameters {
54*4882a593Smuzhiyun 	/**
55*4882a593Smuzhiyun 	 * @range_min_qp: Min Quantization Parameters allowed for this range
56*4882a593Smuzhiyun 	 */
57*4882a593Smuzhiyun 	u8 range_min_qp;
58*4882a593Smuzhiyun 	/**
59*4882a593Smuzhiyun 	 * @range_max_qp: Max Quantization Parameters allowed for this range
60*4882a593Smuzhiyun 	 */
61*4882a593Smuzhiyun 	u8 range_max_qp;
62*4882a593Smuzhiyun 	/**
63*4882a593Smuzhiyun 	 * @range_bpg_offset:
64*4882a593Smuzhiyun 	 * Bits/group offset to apply to target for this group
65*4882a593Smuzhiyun 	 */
66*4882a593Smuzhiyun 	u8 range_bpg_offset;
67*4882a593Smuzhiyun };
68*4882a593Smuzhiyun 
69*4882a593Smuzhiyun /**
70*4882a593Smuzhiyun  * struct drm_dsc_config - Parameters required to configure DSC
71*4882a593Smuzhiyun  *
72*4882a593Smuzhiyun  * Driver populates this structure with all the parameters required
73*4882a593Smuzhiyun  * to configure the display stream compression on the source.
74*4882a593Smuzhiyun  */
75*4882a593Smuzhiyun struct drm_dsc_config {
76*4882a593Smuzhiyun 	/**
77*4882a593Smuzhiyun 	 * @line_buf_depth:
78*4882a593Smuzhiyun 	 * Bits per component for previous reconstructed line buffer
79*4882a593Smuzhiyun 	 */
80*4882a593Smuzhiyun 	u8 line_buf_depth;
81*4882a593Smuzhiyun 	/**
82*4882a593Smuzhiyun 	 * @bits_per_component: Bits per component to code (8/10/12)
83*4882a593Smuzhiyun 	 */
84*4882a593Smuzhiyun 	u8 bits_per_component;
85*4882a593Smuzhiyun 	/**
86*4882a593Smuzhiyun 	 * @convert_rgb:
87*4882a593Smuzhiyun 	 * Flag to indicate if RGB - YCoCg conversion is needed
88*4882a593Smuzhiyun 	 * True if RGB input, False if YCoCg input
89*4882a593Smuzhiyun 	 */
90*4882a593Smuzhiyun 	bool convert_rgb;
91*4882a593Smuzhiyun 	/**
92*4882a593Smuzhiyun 	 * @slice_count: Number fo slices per line used by the DSC encoder
93*4882a593Smuzhiyun 	 */
94*4882a593Smuzhiyun 	u8 slice_count;
95*4882a593Smuzhiyun 	/**
96*4882a593Smuzhiyun 	 *  @slice_width: Width of each slice in pixels
97*4882a593Smuzhiyun 	 */
98*4882a593Smuzhiyun 	u16 slice_width;
99*4882a593Smuzhiyun 	/**
100*4882a593Smuzhiyun 	 * @slice_height: Slice height in pixels
101*4882a593Smuzhiyun 	 */
102*4882a593Smuzhiyun 	u16 slice_height;
103*4882a593Smuzhiyun 	/**
104*4882a593Smuzhiyun 	 * @simple_422: True if simple 4_2_2 mode is enabled else False
105*4882a593Smuzhiyun 	 */
106*4882a593Smuzhiyun 	bool simple_422;
107*4882a593Smuzhiyun 	/**
108*4882a593Smuzhiyun 	 * @pic_width: Width of the input display frame in pixels
109*4882a593Smuzhiyun 	 */
110*4882a593Smuzhiyun 	u16 pic_width;
111*4882a593Smuzhiyun 	/**
112*4882a593Smuzhiyun 	 * @pic_height: Vertical height of the input display frame
113*4882a593Smuzhiyun 	 */
114*4882a593Smuzhiyun 	u16 pic_height;
115*4882a593Smuzhiyun 	/**
116*4882a593Smuzhiyun 	 * @rc_tgt_offset_high:
117*4882a593Smuzhiyun 	 * Offset to bits/group used by RC to determine QP adjustment
118*4882a593Smuzhiyun 	 */
119*4882a593Smuzhiyun 	u8 rc_tgt_offset_high;
120*4882a593Smuzhiyun 	/**
121*4882a593Smuzhiyun 	 * @rc_tgt_offset_low:
122*4882a593Smuzhiyun 	 * Offset to bits/group used by RC to determine QP adjustment
123*4882a593Smuzhiyun 	 */
124*4882a593Smuzhiyun 	u8 rc_tgt_offset_low;
125*4882a593Smuzhiyun 	/**
126*4882a593Smuzhiyun 	 * @bits_per_pixel:
127*4882a593Smuzhiyun 	 * Target bits per pixel with 4 fractional bits, bits_per_pixel << 4
128*4882a593Smuzhiyun 	 */
129*4882a593Smuzhiyun 	u16 bits_per_pixel;
130*4882a593Smuzhiyun 	/**
131*4882a593Smuzhiyun 	 * @rc_edge_factor:
132*4882a593Smuzhiyun 	 * Factor to determine if an edge is present based on the bits produced
133*4882a593Smuzhiyun 	 */
134*4882a593Smuzhiyun 	u8 rc_edge_factor;
135*4882a593Smuzhiyun 	/**
136*4882a593Smuzhiyun 	 * @rc_quant_incr_limit1:
137*4882a593Smuzhiyun 	 * Slow down incrementing once the range reaches this value
138*4882a593Smuzhiyun 	 */
139*4882a593Smuzhiyun 	u8 rc_quant_incr_limit1;
140*4882a593Smuzhiyun 	/**
141*4882a593Smuzhiyun 	 * @rc_quant_incr_limit0:
142*4882a593Smuzhiyun 	 * Slow down incrementing once the range reaches this value
143*4882a593Smuzhiyun 	 */
144*4882a593Smuzhiyun 	u8 rc_quant_incr_limit0;
145*4882a593Smuzhiyun 	/**
146*4882a593Smuzhiyun 	 * @initial_xmit_delay:
147*4882a593Smuzhiyun 	 * Number of pixels to delay the initial transmission
148*4882a593Smuzhiyun 	 */
149*4882a593Smuzhiyun 	u16 initial_xmit_delay;
150*4882a593Smuzhiyun 	/**
151*4882a593Smuzhiyun 	 * @initial_dec_delay:
152*4882a593Smuzhiyun 	 * Initial decoder delay, number of pixel times that the decoder
153*4882a593Smuzhiyun 	 * accumulates data in its rate buffer before starting to decode
154*4882a593Smuzhiyun 	 * and output pixels.
155*4882a593Smuzhiyun 	 */
156*4882a593Smuzhiyun 	u16  initial_dec_delay;
157*4882a593Smuzhiyun 	/**
158*4882a593Smuzhiyun 	 * @block_pred_enable:
159*4882a593Smuzhiyun 	 * True if block prediction is used to code any groups within the
160*4882a593Smuzhiyun 	 * picture. False if BP not used
161*4882a593Smuzhiyun 	 */
162*4882a593Smuzhiyun 	bool block_pred_enable;
163*4882a593Smuzhiyun 	/**
164*4882a593Smuzhiyun 	 * @first_line_bpg_offset:
165*4882a593Smuzhiyun 	 * Number of additional bits allocated for each group on the first
166*4882a593Smuzhiyun 	 * line of slice.
167*4882a593Smuzhiyun 	 */
168*4882a593Smuzhiyun 	u8 first_line_bpg_offset;
169*4882a593Smuzhiyun 	/**
170*4882a593Smuzhiyun 	 * @initial_offset: Value to use for RC model offset at slice start
171*4882a593Smuzhiyun 	 */
172*4882a593Smuzhiyun 	u16 initial_offset;
173*4882a593Smuzhiyun 	/**
174*4882a593Smuzhiyun 	 * @rc_buf_thresh: Thresholds defining each of the buffer ranges
175*4882a593Smuzhiyun 	 */
176*4882a593Smuzhiyun 	u16 rc_buf_thresh[DSC_NUM_BUF_RANGES - 1];
177*4882a593Smuzhiyun 	/**
178*4882a593Smuzhiyun 	 * @rc_range_params:
179*4882a593Smuzhiyun 	 * Parameters for each of the RC ranges defined in
180*4882a593Smuzhiyun 	 * &struct drm_dsc_rc_range_parameters
181*4882a593Smuzhiyun 	 */
182*4882a593Smuzhiyun 	struct drm_dsc_rc_range_parameters rc_range_params[DSC_NUM_BUF_RANGES];
183*4882a593Smuzhiyun 	/**
184*4882a593Smuzhiyun 	 * @rc_model_size: Total size of RC model
185*4882a593Smuzhiyun 	 */
186*4882a593Smuzhiyun 	u16 rc_model_size;
187*4882a593Smuzhiyun 	/**
188*4882a593Smuzhiyun 	 * @flatness_min_qp: Minimum QP where flatness information is sent
189*4882a593Smuzhiyun 	 */
190*4882a593Smuzhiyun 	u8 flatness_min_qp;
191*4882a593Smuzhiyun 	/**
192*4882a593Smuzhiyun 	 * @flatness_max_qp: Maximum QP where flatness information is sent
193*4882a593Smuzhiyun 	 */
194*4882a593Smuzhiyun 	u8 flatness_max_qp;
195*4882a593Smuzhiyun 	/**
196*4882a593Smuzhiyun 	 * @initial_scale_value: Initial value for the scale factor
197*4882a593Smuzhiyun 	 */
198*4882a593Smuzhiyun 	u8 initial_scale_value;
199*4882a593Smuzhiyun 	/**
200*4882a593Smuzhiyun 	 * @scale_decrement_interval:
201*4882a593Smuzhiyun 	 * Specifies number of group times between decrementing the scale factor
202*4882a593Smuzhiyun 	 * at beginning of a slice.
203*4882a593Smuzhiyun 	 */
204*4882a593Smuzhiyun 	u16 scale_decrement_interval;
205*4882a593Smuzhiyun 	/**
206*4882a593Smuzhiyun 	 * @scale_increment_interval:
207*4882a593Smuzhiyun 	 * Number of group times between incrementing the scale factor value
208*4882a593Smuzhiyun 	 * used at the beginning of a slice.
209*4882a593Smuzhiyun 	 */
210*4882a593Smuzhiyun 	u16 scale_increment_interval;
211*4882a593Smuzhiyun 	/**
212*4882a593Smuzhiyun 	 * @nfl_bpg_offset: Non first line BPG offset to be used
213*4882a593Smuzhiyun 	 */
214*4882a593Smuzhiyun 	u16 nfl_bpg_offset;
215*4882a593Smuzhiyun 	/**
216*4882a593Smuzhiyun 	 * @slice_bpg_offset: BPG offset used to enforce slice bit
217*4882a593Smuzhiyun 	 */
218*4882a593Smuzhiyun 	u16 slice_bpg_offset;
219*4882a593Smuzhiyun 	/**
220*4882a593Smuzhiyun 	 * @final_offset: Final RC linear transformation offset value
221*4882a593Smuzhiyun 	 */
222*4882a593Smuzhiyun 	u16 final_offset;
223*4882a593Smuzhiyun 	/**
224*4882a593Smuzhiyun 	 * @vbr_enable: True if VBR mode is enabled, false if disabled
225*4882a593Smuzhiyun 	 */
226*4882a593Smuzhiyun 	bool vbr_enable;
227*4882a593Smuzhiyun 	/**
228*4882a593Smuzhiyun 	 * @mux_word_size: Mux word size (in bits) for SSM mode
229*4882a593Smuzhiyun 	 */
230*4882a593Smuzhiyun 	u8 mux_word_size;
231*4882a593Smuzhiyun 	/**
232*4882a593Smuzhiyun 	 * @slice_chunk_size:
233*4882a593Smuzhiyun 	 * The (max) size in bytes of the "chunks" that are used in slice
234*4882a593Smuzhiyun 	 * multiplexing.
235*4882a593Smuzhiyun 	 */
236*4882a593Smuzhiyun 	u16 slice_chunk_size;
237*4882a593Smuzhiyun 	/**
238*4882a593Smuzhiyun 	 * @rc_bits: Rate control buffer size in bits
239*4882a593Smuzhiyun 	 */
240*4882a593Smuzhiyun 	u16 rc_bits;
241*4882a593Smuzhiyun 	/**
242*4882a593Smuzhiyun 	 * @dsc_version_minor: DSC minor version
243*4882a593Smuzhiyun 	 */
244*4882a593Smuzhiyun 	u8 dsc_version_minor;
245*4882a593Smuzhiyun 	/**
246*4882a593Smuzhiyun 	 * @dsc_version_major: DSC major version
247*4882a593Smuzhiyun 	 */
248*4882a593Smuzhiyun 	u8 dsc_version_major;
249*4882a593Smuzhiyun 	/**
250*4882a593Smuzhiyun 	 * @native_422: True if Native 4:2:2 supported, else false
251*4882a593Smuzhiyun 	 */
252*4882a593Smuzhiyun 	bool native_422;
253*4882a593Smuzhiyun 	/**
254*4882a593Smuzhiyun 	 * @native_420: True if Native 4:2:0 supported else false.
255*4882a593Smuzhiyun 	 */
256*4882a593Smuzhiyun 	bool native_420;
257*4882a593Smuzhiyun 	/**
258*4882a593Smuzhiyun 	 * @second_line_bpg_offset:
259*4882a593Smuzhiyun 	 * Additional bits/grp for seconnd line of slice for native 4:2:0
260*4882a593Smuzhiyun 	 */
261*4882a593Smuzhiyun 	u8 second_line_bpg_offset;
262*4882a593Smuzhiyun 	/**
263*4882a593Smuzhiyun 	 * @nsl_bpg_offset:
264*4882a593Smuzhiyun 	 * Num of bits deallocated for each grp that is not in second line of
265*4882a593Smuzhiyun 	 * slice
266*4882a593Smuzhiyun 	 */
267*4882a593Smuzhiyun 	u16 nsl_bpg_offset;
268*4882a593Smuzhiyun 	/**
269*4882a593Smuzhiyun 	 * @second_line_offset_adj:
270*4882a593Smuzhiyun 	 * Offset adjustment for second line in Native 4:2:0 mode
271*4882a593Smuzhiyun 	 */
272*4882a593Smuzhiyun 	u16 second_line_offset_adj;
273*4882a593Smuzhiyun };
274*4882a593Smuzhiyun 
275*4882a593Smuzhiyun /**
276*4882a593Smuzhiyun  * struct picture_parameter_set - Represents 128 bytes of Picture Parameter Set
277*4882a593Smuzhiyun  *
278*4882a593Smuzhiyun  * The VESA DSC standard defines picture parameter set (PPS) which display
279*4882a593Smuzhiyun  * stream compression encoders must communicate to decoders.
280*4882a593Smuzhiyun  * The PPS is encapsulated in 128 bytes (PPS 0 through PPS 127). The fields in
281*4882a593Smuzhiyun  * this structure are as per Table 4.1 in Vesa DSC specification v1.1/v1.2.
282*4882a593Smuzhiyun  * The PPS fields that span over more than a byte should be stored in Big Endian
283*4882a593Smuzhiyun  * format.
284*4882a593Smuzhiyun  */
285*4882a593Smuzhiyun struct drm_dsc_picture_parameter_set {
286*4882a593Smuzhiyun 	/**
287*4882a593Smuzhiyun 	 * @dsc_version:
288*4882a593Smuzhiyun 	 * PPS0[3:0] - dsc_version_minor: Contains Minor version of DSC
289*4882a593Smuzhiyun 	 * PPS0[7:4] - dsc_version_major: Contains major version of DSC
290*4882a593Smuzhiyun 	 */
291*4882a593Smuzhiyun 	u8 dsc_version;
292*4882a593Smuzhiyun 	/**
293*4882a593Smuzhiyun 	 * @pps_identifier:
294*4882a593Smuzhiyun 	 * PPS1[7:0] - Application specific identifier that can be
295*4882a593Smuzhiyun 	 * used to differentiate between different PPS tables.
296*4882a593Smuzhiyun 	 */
297*4882a593Smuzhiyun 	u8 pps_identifier;
298*4882a593Smuzhiyun 	/**
299*4882a593Smuzhiyun 	 * @pps_reserved:
300*4882a593Smuzhiyun 	 * PPS2[7:0]- RESERVED Byte
301*4882a593Smuzhiyun 	 */
302*4882a593Smuzhiyun 	u8 pps_reserved;
303*4882a593Smuzhiyun 	/**
304*4882a593Smuzhiyun 	 * @pps_3:
305*4882a593Smuzhiyun 	 * PPS3[3:0] - linebuf_depth: Contains linebuffer bit depth used to
306*4882a593Smuzhiyun 	 * generate the bitstream. (0x0 - 16 bits for DSC 1.2, 0x8 - 8 bits,
307*4882a593Smuzhiyun 	 * 0xA - 10 bits, 0xB - 11 bits, 0xC - 12 bits, 0xD - 13 bits,
308*4882a593Smuzhiyun 	 * 0xE - 14 bits for DSC1.2, 0xF - 14 bits for DSC 1.2.
309*4882a593Smuzhiyun 	 * PPS3[7:4] - bits_per_component: Bits per component for the original
310*4882a593Smuzhiyun 	 * pixels of the encoded picture.
311*4882a593Smuzhiyun 	 * 0x0 = 16bpc (allowed only when dsc_version_minor = 0x2)
312*4882a593Smuzhiyun 	 * 0x8 = 8bpc, 0xA = 10bpc, 0xC = 12bpc, 0xE = 14bpc (also
313*4882a593Smuzhiyun 	 * allowed only when dsc_minor_version = 0x2)
314*4882a593Smuzhiyun 	 */
315*4882a593Smuzhiyun 	u8 pps_3;
316*4882a593Smuzhiyun 	/**
317*4882a593Smuzhiyun 	 * @pps_4:
318*4882a593Smuzhiyun 	 * PPS4[1:0] -These are the most significant 2 bits of
319*4882a593Smuzhiyun 	 * compressed BPP bits_per_pixel[9:0] syntax element.
320*4882a593Smuzhiyun 	 * PPS4[2] - vbr_enable: 0 = VBR disabled, 1 = VBR enabled
321*4882a593Smuzhiyun 	 * PPS4[3] - simple_422: Indicates if decoder drops samples to
322*4882a593Smuzhiyun 	 * reconstruct the 4:2:2 picture.
323*4882a593Smuzhiyun 	 * PPS4[4] - Convert_rgb: Indicates if DSC color space conversion is
324*4882a593Smuzhiyun 	 * active.
325*4882a593Smuzhiyun 	 * PPS4[5] - blobk_pred_enable: Indicates if BP is used to code any
326*4882a593Smuzhiyun 	 * groups in picture
327*4882a593Smuzhiyun 	 * PPS4[7:6] - Reseved bits
328*4882a593Smuzhiyun 	 */
329*4882a593Smuzhiyun 	u8 pps_4;
330*4882a593Smuzhiyun 	/**
331*4882a593Smuzhiyun 	 * @bits_per_pixel_low:
332*4882a593Smuzhiyun 	 * PPS5[7:0] - This indicates the lower significant 8 bits of
333*4882a593Smuzhiyun 	 * the compressed BPP bits_per_pixel[9:0] element.
334*4882a593Smuzhiyun 	 */
335*4882a593Smuzhiyun 	u8 bits_per_pixel_low;
336*4882a593Smuzhiyun 	/**
337*4882a593Smuzhiyun 	 * @pic_height:
338*4882a593Smuzhiyun 	 * PPS6[7:0], PPS7[7:0] -pic_height: Specifies the number of pixel rows
339*4882a593Smuzhiyun 	 * within the raster.
340*4882a593Smuzhiyun 	 */
341*4882a593Smuzhiyun 	__be16 pic_height;
342*4882a593Smuzhiyun 	/**
343*4882a593Smuzhiyun 	 * @pic_width:
344*4882a593Smuzhiyun 	 * PPS8[7:0], PPS9[7:0] - pic_width: Number of pixel columns within
345*4882a593Smuzhiyun 	 * the raster.
346*4882a593Smuzhiyun 	 */
347*4882a593Smuzhiyun 	__be16 pic_width;
348*4882a593Smuzhiyun 	/**
349*4882a593Smuzhiyun 	 * @slice_height:
350*4882a593Smuzhiyun 	 * PPS10[7:0], PPS11[7:0] - Slice height in units of pixels.
351*4882a593Smuzhiyun 	 */
352*4882a593Smuzhiyun 	__be16 slice_height;
353*4882a593Smuzhiyun 	/**
354*4882a593Smuzhiyun 	 * @slice_width:
355*4882a593Smuzhiyun 	 * PPS12[7:0], PPS13[7:0] - Slice width in terms of pixels.
356*4882a593Smuzhiyun 	 */
357*4882a593Smuzhiyun 	__be16 slice_width;
358*4882a593Smuzhiyun 	/**
359*4882a593Smuzhiyun 	 * @chunk_size:
360*4882a593Smuzhiyun 	 * PPS14[7:0], PPS15[7:0] - Size in units of bytes of the chunks
361*4882a593Smuzhiyun 	 * that are used for slice multiplexing.
362*4882a593Smuzhiyun 	 */
363*4882a593Smuzhiyun 	__be16 chunk_size;
364*4882a593Smuzhiyun 	/**
365*4882a593Smuzhiyun 	 * @initial_xmit_delay_high:
366*4882a593Smuzhiyun 	 * PPS16[1:0] - Most Significant two bits of initial transmission delay.
367*4882a593Smuzhiyun 	 * It specifies the number of pixel times that the encoder waits before
368*4882a593Smuzhiyun 	 * transmitting data from its rate buffer.
369*4882a593Smuzhiyun 	 * PPS16[7:2] - Reserved
370*4882a593Smuzhiyun 	 */
371*4882a593Smuzhiyun 	u8 initial_xmit_delay_high;
372*4882a593Smuzhiyun 	/**
373*4882a593Smuzhiyun 	 * @initial_xmit_delay_low:
374*4882a593Smuzhiyun 	 * PPS17[7:0] - Least significant 8 bits of initial transmission delay.
375*4882a593Smuzhiyun 	 */
376*4882a593Smuzhiyun 	u8 initial_xmit_delay_low;
377*4882a593Smuzhiyun 	/**
378*4882a593Smuzhiyun 	 * @initial_dec_delay:
379*4882a593Smuzhiyun 	 *
380*4882a593Smuzhiyun 	 * PPS18[7:0], PPS19[7:0] - Initial decoding delay which is the number
381*4882a593Smuzhiyun 	 * of pixel times that the decoder accumulates data in its rate buffer
382*4882a593Smuzhiyun 	 * before starting to decode and output pixels.
383*4882a593Smuzhiyun 	 */
384*4882a593Smuzhiyun 	__be16 initial_dec_delay;
385*4882a593Smuzhiyun 	/**
386*4882a593Smuzhiyun 	 * @pps20_reserved:
387*4882a593Smuzhiyun 	 *
388*4882a593Smuzhiyun 	 * PPS20[7:0] - Reserved
389*4882a593Smuzhiyun 	 */
390*4882a593Smuzhiyun 	u8 pps20_reserved;
391*4882a593Smuzhiyun 	/**
392*4882a593Smuzhiyun 	 * @initial_scale_value:
393*4882a593Smuzhiyun 	 * PPS21[5:0] - Initial rcXformScale factor used at beginning
394*4882a593Smuzhiyun 	 * of a slice.
395*4882a593Smuzhiyun 	 * PPS21[7:6] - Reserved
396*4882a593Smuzhiyun 	 */
397*4882a593Smuzhiyun 	u8 initial_scale_value;
398*4882a593Smuzhiyun 	/**
399*4882a593Smuzhiyun 	 * @scale_increment_interval:
400*4882a593Smuzhiyun 	 * PPS22[7:0], PPS23[7:0] - Number of group times between incrementing
401*4882a593Smuzhiyun 	 * the rcXformScale factor at end of a slice.
402*4882a593Smuzhiyun 	 */
403*4882a593Smuzhiyun 	__be16 scale_increment_interval;
404*4882a593Smuzhiyun 	/**
405*4882a593Smuzhiyun 	 * @scale_decrement_interval_high:
406*4882a593Smuzhiyun 	 * PPS24[3:0] - Higher 4 bits indicating number of group times between
407*4882a593Smuzhiyun 	 * decrementing the rcXformScale factor at beginning of a slice.
408*4882a593Smuzhiyun 	 * PPS24[7:4] - Reserved
409*4882a593Smuzhiyun 	 */
410*4882a593Smuzhiyun 	u8 scale_decrement_interval_high;
411*4882a593Smuzhiyun 	/**
412*4882a593Smuzhiyun 	 * @scale_decrement_interval_low:
413*4882a593Smuzhiyun 	 * PPS25[7:0] - Lower 8 bits of scale decrement interval
414*4882a593Smuzhiyun 	 */
415*4882a593Smuzhiyun 	u8 scale_decrement_interval_low;
416*4882a593Smuzhiyun 	/**
417*4882a593Smuzhiyun 	 * @pps26_reserved:
418*4882a593Smuzhiyun 	 * PPS26[7:0]
419*4882a593Smuzhiyun 	 */
420*4882a593Smuzhiyun 	u8 pps26_reserved;
421*4882a593Smuzhiyun 	/**
422*4882a593Smuzhiyun 	 * @first_line_bpg_offset:
423*4882a593Smuzhiyun 	 * PPS27[4:0] - Number of additional bits that are allocated
424*4882a593Smuzhiyun 	 * for each group on first line of a slice.
425*4882a593Smuzhiyun 	 * PPS27[7:5] - Reserved
426*4882a593Smuzhiyun 	 */
427*4882a593Smuzhiyun 	u8 first_line_bpg_offset;
428*4882a593Smuzhiyun 	/**
429*4882a593Smuzhiyun 	 * @nfl_bpg_offset:
430*4882a593Smuzhiyun 	 * PPS28[7:0], PPS29[7:0] - Number of bits including frac bits
431*4882a593Smuzhiyun 	 * deallocated for each group for groups after the first line of slice.
432*4882a593Smuzhiyun 	 */
433*4882a593Smuzhiyun 	__be16 nfl_bpg_offset;
434*4882a593Smuzhiyun 	/**
435*4882a593Smuzhiyun 	 * @slice_bpg_offset:
436*4882a593Smuzhiyun 	 * PPS30, PPS31[7:0] - Number of bits that are deallocated for each
437*4882a593Smuzhiyun 	 * group to enforce the slice constraint.
438*4882a593Smuzhiyun 	 */
439*4882a593Smuzhiyun 	__be16 slice_bpg_offset;
440*4882a593Smuzhiyun 	/**
441*4882a593Smuzhiyun 	 * @initial_offset:
442*4882a593Smuzhiyun 	 * PPS32,33[7:0] - Initial value for rcXformOffset
443*4882a593Smuzhiyun 	 */
444*4882a593Smuzhiyun 	__be16 initial_offset;
445*4882a593Smuzhiyun 	/**
446*4882a593Smuzhiyun 	 * @final_offset:
447*4882a593Smuzhiyun 	 * PPS34,35[7:0] - Maximum end-of-slice value for rcXformOffset
448*4882a593Smuzhiyun 	 */
449*4882a593Smuzhiyun 	__be16 final_offset;
450*4882a593Smuzhiyun 	/**
451*4882a593Smuzhiyun 	 * @flatness_min_qp:
452*4882a593Smuzhiyun 	 * PPS36[4:0] - Minimum QP at which flatness is signaled and
453*4882a593Smuzhiyun 	 * flatness QP adjustment is made.
454*4882a593Smuzhiyun 	 * PPS36[7:5] - Reserved
455*4882a593Smuzhiyun 	 */
456*4882a593Smuzhiyun 	u8 flatness_min_qp;
457*4882a593Smuzhiyun 	/**
458*4882a593Smuzhiyun 	 * @flatness_max_qp:
459*4882a593Smuzhiyun 	 * PPS37[4:0] - Max QP at which flatness is signalled and
460*4882a593Smuzhiyun 	 * the flatness adjustment is made.
461*4882a593Smuzhiyun 	 * PPS37[7:5] - Reserved
462*4882a593Smuzhiyun 	 */
463*4882a593Smuzhiyun 	u8 flatness_max_qp;
464*4882a593Smuzhiyun 	/**
465*4882a593Smuzhiyun 	 * @rc_model_size:
466*4882a593Smuzhiyun 	 * PPS38,39[7:0] - Number of bits within RC Model.
467*4882a593Smuzhiyun 	 */
468*4882a593Smuzhiyun 	__be16 rc_model_size;
469*4882a593Smuzhiyun 	/**
470*4882a593Smuzhiyun 	 * @rc_edge_factor:
471*4882a593Smuzhiyun 	 * PPS40[3:0] - Ratio of current activity vs, previous
472*4882a593Smuzhiyun 	 * activity to determine presence of edge.
473*4882a593Smuzhiyun 	 * PPS40[7:4] - Reserved
474*4882a593Smuzhiyun 	 */
475*4882a593Smuzhiyun 	u8 rc_edge_factor;
476*4882a593Smuzhiyun 	/**
477*4882a593Smuzhiyun 	 * @rc_quant_incr_limit0:
478*4882a593Smuzhiyun 	 * PPS41[4:0] - QP threshold used in short term RC
479*4882a593Smuzhiyun 	 * PPS41[7:5] - Reserved
480*4882a593Smuzhiyun 	 */
481*4882a593Smuzhiyun 	u8 rc_quant_incr_limit0;
482*4882a593Smuzhiyun 	/**
483*4882a593Smuzhiyun 	 * @rc_quant_incr_limit1:
484*4882a593Smuzhiyun 	 * PPS42[4:0] - QP threshold used in short term RC
485*4882a593Smuzhiyun 	 * PPS42[7:5] - Reserved
486*4882a593Smuzhiyun 	 */
487*4882a593Smuzhiyun 	u8 rc_quant_incr_limit1;
488*4882a593Smuzhiyun 	/**
489*4882a593Smuzhiyun 	 * @rc_tgt_offset:
490*4882a593Smuzhiyun 	 * PPS43[3:0] - Lower end of the variability range around the target
491*4882a593Smuzhiyun 	 * bits per group that is allowed by short term RC.
492*4882a593Smuzhiyun 	 * PPS43[7:4]- Upper end of the variability range around the target
493*4882a593Smuzhiyun 	 * bits per group that i allowed by short term rc.
494*4882a593Smuzhiyun 	 */
495*4882a593Smuzhiyun 	u8 rc_tgt_offset;
496*4882a593Smuzhiyun 	/**
497*4882a593Smuzhiyun 	 * @rc_buf_thresh:
498*4882a593Smuzhiyun 	 * PPS44[7:0] - PPS57[7:0] - Specifies the thresholds in RC model for
499*4882a593Smuzhiyun 	 * the 15 ranges defined by 14 thresholds.
500*4882a593Smuzhiyun 	 */
501*4882a593Smuzhiyun 	u8 rc_buf_thresh[DSC_NUM_BUF_RANGES - 1];
502*4882a593Smuzhiyun 	/**
503*4882a593Smuzhiyun 	 * @rc_range_parameters:
504*4882a593Smuzhiyun 	 * PPS58[7:0] - PPS87[7:0]
505*4882a593Smuzhiyun 	 * Parameters that correspond to each of the 15 ranges.
506*4882a593Smuzhiyun 	 */
507*4882a593Smuzhiyun 	__be16 rc_range_parameters[DSC_NUM_BUF_RANGES];
508*4882a593Smuzhiyun 	/**
509*4882a593Smuzhiyun 	 * @native_422_420:
510*4882a593Smuzhiyun 	 * PPS88[0] - 0 = Native 4:2:2 not used
511*4882a593Smuzhiyun 	 * 1 = Native 4:2:2 used
512*4882a593Smuzhiyun 	 * PPS88[1] - 0 = Native 4:2:0 not use
513*4882a593Smuzhiyun 	 * 1 = Native 4:2:0 used
514*4882a593Smuzhiyun 	 * PPS88[7:2] - Reserved 6 bits
515*4882a593Smuzhiyun 	 */
516*4882a593Smuzhiyun 	u8 native_422_420;
517*4882a593Smuzhiyun 	/**
518*4882a593Smuzhiyun 	 * @second_line_bpg_offset:
519*4882a593Smuzhiyun 	 * PPS89[4:0] - Additional bits/group budget for the
520*4882a593Smuzhiyun 	 * second line of a slice in Native 4:2:0 mode.
521*4882a593Smuzhiyun 	 * Set to 0 if DSC minor version is 1 or native420 is 0.
522*4882a593Smuzhiyun 	 * PPS89[7:5] - Reserved
523*4882a593Smuzhiyun 	 */
524*4882a593Smuzhiyun 	u8 second_line_bpg_offset;
525*4882a593Smuzhiyun 	/**
526*4882a593Smuzhiyun 	 * @nsl_bpg_offset:
527*4882a593Smuzhiyun 	 * PPS90[7:0], PPS91[7:0] - Number of bits that are deallocated
528*4882a593Smuzhiyun 	 * for each group that is not in the second line of a slice.
529*4882a593Smuzhiyun 	 */
530*4882a593Smuzhiyun 	__be16 nsl_bpg_offset;
531*4882a593Smuzhiyun 	/**
532*4882a593Smuzhiyun 	 * @second_line_offset_adj:
533*4882a593Smuzhiyun 	 * PPS92[7:0], PPS93[7:0] - Used as offset adjustment for the second
534*4882a593Smuzhiyun 	 * line in Native 4:2:0 mode.
535*4882a593Smuzhiyun 	 */
536*4882a593Smuzhiyun 	__be16 second_line_offset_adj;
537*4882a593Smuzhiyun 	/**
538*4882a593Smuzhiyun 	 * @pps_long_94_reserved:
539*4882a593Smuzhiyun 	 * PPS 94, 95, 96, 97 - Reserved
540*4882a593Smuzhiyun 	 */
541*4882a593Smuzhiyun 	u32 pps_long_94_reserved;
542*4882a593Smuzhiyun 	/**
543*4882a593Smuzhiyun 	 * @pps_long_98_reserved:
544*4882a593Smuzhiyun 	 * PPS 98, 99, 100, 101 - Reserved
545*4882a593Smuzhiyun 	 */
546*4882a593Smuzhiyun 	u32 pps_long_98_reserved;
547*4882a593Smuzhiyun 	/**
548*4882a593Smuzhiyun 	 * @pps_long_102_reserved:
549*4882a593Smuzhiyun 	 * PPS 102, 103, 104, 105 - Reserved
550*4882a593Smuzhiyun 	 */
551*4882a593Smuzhiyun 	u32 pps_long_102_reserved;
552*4882a593Smuzhiyun 	/**
553*4882a593Smuzhiyun 	 * @pps_long_106_reserved:
554*4882a593Smuzhiyun 	 * PPS 106, 107, 108, 109 - reserved
555*4882a593Smuzhiyun 	 */
556*4882a593Smuzhiyun 	u32 pps_long_106_reserved;
557*4882a593Smuzhiyun 	/**
558*4882a593Smuzhiyun 	 * @pps_long_110_reserved:
559*4882a593Smuzhiyun 	 * PPS 110, 111, 112, 113 - reserved
560*4882a593Smuzhiyun 	 */
561*4882a593Smuzhiyun 	u32 pps_long_110_reserved;
562*4882a593Smuzhiyun 	/**
563*4882a593Smuzhiyun 	 * @pps_long_114_reserved:
564*4882a593Smuzhiyun 	 * PPS 114 - 117 - reserved
565*4882a593Smuzhiyun 	 */
566*4882a593Smuzhiyun 	u32 pps_long_114_reserved;
567*4882a593Smuzhiyun 	/**
568*4882a593Smuzhiyun 	 * @pps_long_118_reserved:
569*4882a593Smuzhiyun 	 * PPS 118 - 121 - reserved
570*4882a593Smuzhiyun 	 */
571*4882a593Smuzhiyun 	u32 pps_long_118_reserved;
572*4882a593Smuzhiyun 	/**
573*4882a593Smuzhiyun 	 * @pps_long_122_reserved:
574*4882a593Smuzhiyun 	 * PPS 122- 125 - reserved
575*4882a593Smuzhiyun 	 */
576*4882a593Smuzhiyun 	u32 pps_long_122_reserved;
577*4882a593Smuzhiyun 	/**
578*4882a593Smuzhiyun 	 * @pps_short_126_reserved:
579*4882a593Smuzhiyun 	 * PPS 126, 127 - reserved
580*4882a593Smuzhiyun 	 */
581*4882a593Smuzhiyun 	__be16 pps_short_126_reserved;
582*4882a593Smuzhiyun } __packed;
583*4882a593Smuzhiyun 
584*4882a593Smuzhiyun /**
585*4882a593Smuzhiyun  * struct drm_dsc_pps_infoframe - DSC infoframe carrying the Picture Parameter
586*4882a593Smuzhiyun  * Set Metadata
587*4882a593Smuzhiyun  *
588*4882a593Smuzhiyun  * This structure represents the DSC PPS infoframe required to send the Picture
589*4882a593Smuzhiyun  * Parameter Set metadata required before enabling VESA Display Stream
590*4882a593Smuzhiyun  * Compression. This is based on the DP Secondary Data Packet structure and
591*4882a593Smuzhiyun  * comprises of SDP Header as defined &struct dp_sdp_header in drm_dp_helper.h
592*4882a593Smuzhiyun  * and PPS payload defined in &struct drm_dsc_picture_parameter_set.
593*4882a593Smuzhiyun  *
594*4882a593Smuzhiyun  * @pps_header: Header for PPS as per DP SDP header format of type
595*4882a593Smuzhiyun  *              &struct dp_sdp_header
596*4882a593Smuzhiyun  * @pps_payload: PPS payload fields as per DSC specification Table 4-1
597*4882a593Smuzhiyun  *               as represented in &struct drm_dsc_picture_parameter_set
598*4882a593Smuzhiyun  */
599*4882a593Smuzhiyun struct drm_dsc_pps_infoframe {
600*4882a593Smuzhiyun 	struct dp_sdp_header pps_header;
601*4882a593Smuzhiyun 	struct drm_dsc_picture_parameter_set pps_payload;
602*4882a593Smuzhiyun } __packed;
603*4882a593Smuzhiyun 
604*4882a593Smuzhiyun void drm_dsc_dp_pps_header_init(struct dp_sdp_header *pps_header);
605*4882a593Smuzhiyun void drm_dsc_pps_payload_pack(struct drm_dsc_picture_parameter_set *pps_sdp,
606*4882a593Smuzhiyun 				const struct drm_dsc_config *dsc_cfg);
607*4882a593Smuzhiyun int drm_dsc_compute_rc_parameters(struct drm_dsc_config *vdsc_cfg);
608*4882a593Smuzhiyun 
609*4882a593Smuzhiyun #endif /* _DRM_DSC_H_ */
610