Linux Audio

Check our new training course

Loading...
v6.9.4
  1/* Copyright 2012-15 Advanced Micro Devices, Inc.
  2 *
  3 * Permission is hereby granted, free of charge, to any person obtaining a
  4 * copy of this software and associated documentation files (the "Software"),
  5 * to deal in the Software without restriction, including without limitation
  6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  7 * and/or sell copies of the Software, and to permit persons to whom the
  8 * Software is furnished to do so, subject to the following conditions:
  9 *
 10 * The above copyright notice and this permission notice shall be included in
 11 * all copies or substantial portions of the Software.
 12 *
 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 16 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
 17 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 18 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 19 * OTHER DEALINGS IN THE SOFTWARE.
 20 *
 21 * Authors: AMD
 22 *
 23 */
 24
 25/**
 26 * DOC: overview
 27 *
 28 * Multiple Pipe/Plane Combiner (MPC) is a component in the hardware pipeline
 29 * that performs blending of multiple planes, using global and per-pixel alpha.
 30 * It also performs post-blending color correction operations according to the
 31 * hardware capabilities, such as color transformation matrix and gamma 1D and
 32 * 3D LUT.
 33 *
 34 * MPC receives output from all DPP pipes and combines them to multiple outputs
 35 * supporting "M MPC inputs -> N MPC outputs" flexible composition
 36 * architecture. It features:
 37 *
 38 * - Programmable blending structure to allow software controlled blending and
 39 *   cascading;
 40 * - Programmable window location of each DPP in active region of display;
 41 * - Combining multiple DPP pipes in one active region when a single DPP pipe
 42 *   cannot process very large surface;
 43 * - Combining multiple DPP from different SLS with blending;
 44 * - Stereo formats from single DPP in top-bottom or side-by-side modes;
 45 * - Stereo formats from 2 DPPs;
 46 * - Alpha blending of multiple layers from different DPP pipes;
 47 * - Programmable background color;
 48 */
 49
 50#ifndef __DC_MPCC_H__
 51#define __DC_MPCC_H__
 52
 53#include "dc_hw_types.h"
 54#include "hw_shared.h"
 55#include "transform.h"
 56
 57#define MAX_MPCC 6
 58#define MAX_OPP 6
 59
 60#define MAX_DWB		2
 61
 62enum mpc_output_csc_mode {
 63	MPC_OUTPUT_CSC_DISABLE = 0,
 64	MPC_OUTPUT_CSC_COEF_A,
 65	MPC_OUTPUT_CSC_COEF_B
 66};
 67
 68
 69enum mpcc_blend_mode {
 70	MPCC_BLEND_MODE_BYPASS,
 71	MPCC_BLEND_MODE_TOP_LAYER_PASSTHROUGH,
 72	MPCC_BLEND_MODE_TOP_LAYER_ONLY,
 73	MPCC_BLEND_MODE_TOP_BOT_BLENDING
 74};
 75
 76/**
 77 * enum mpcc_alpha_blend_mode - define the alpha blend mode regarding pixel
 78 * alpha and plane alpha values
 79 */
 80enum mpcc_alpha_blend_mode {
 81	/**
 82	 * @MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA: per pixel alpha using DPP
 83	 * alpha value
 84	 */
 85	MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA,
 86	/**
 87	 * @MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA_COMBINED_GLOBAL_GAIN: per
 88	 * pixel alpha using DPP alpha value multiplied by a global gain (plane
 89	 * alpha)
 90	 */
 91	MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA_COMBINED_GLOBAL_GAIN,
 92	/**
 93	 * @MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA: global alpha value, ignores
 94	 * pixel alpha and consider only plane alpha
 95	 */
 96	MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA
 97};
 98
 99/**
100 * struct mpcc_blnd_cfg - MPCC blending configuration
 
 
 
 
 
 
 
 
101 */
102struct mpcc_blnd_cfg {
103	/**
104	 * @black_color: background color.
105	 */
106	struct tg_color black_color;
107
108	/**
109	 * @alpha_mode: alpha blend mode (MPCC_ALPHA_BLND_MODE).
110	 */
111	enum mpcc_alpha_blend_mode alpha_mode;
112
113	/**
114	 * @pre_multiplied_alpha:
115	 * Whether pixel color values were pre-multiplied by the alpha channel
116	 * (MPCC_ALPHA_MULTIPLIED_MODE).
117	 */
118	bool pre_multiplied_alpha;
119
120	/**
121	 * @global_gain: Used when blend mode considers both pixel alpha and plane.
122	 */
123	int global_gain;
124
125	/**
126	 * @global_alpha: Plane alpha value.
127	 */
128	int global_alpha;
129
130	/**
131	 * @overlap_only: Whether overlapping of different planes is allowed.
132	 */
133	bool overlap_only;
134
135	/* MPCC top/bottom gain settings */
136
137	/**
138	 * @bottom_gain_mode: Blend mode for bottom gain setting.
139	 */
140	int bottom_gain_mode;
141
142	/**
143	 * @background_color_bpc: Background color for bpc.
144	 */
145	int background_color_bpc;
146
147	/**
148	 * @top_gain: Top gain setting.
149	 */
150	int top_gain;
151
152	/**
153	 * @bottom_inside_gain: Blend mode for bottom inside.
154	 */
155	int bottom_inside_gain;
156
157	/**
158	 * @bottom_outside_gain: Blend mode for bottom outside.
159	 */
160	int bottom_outside_gain;
161};
162
163struct mpc_grph_gamut_adjustment {
164	struct fixed31_32 temperature_matrix[CSC_TEMPERATURE_MATRIX_SIZE];
165	enum graphics_gamut_adjust_type gamut_adjust_type;
166};
167
168struct mpcc_sm_cfg {
169	bool enable;
170	/* 0-single plane,2-row subsampling,4-column subsampling,6-checkboard subsampling */
171	int sm_mode;
172	/* 0- disable frame alternate, 1- enable frame alternate */
173	bool frame_alt;
174	/* 0- disable field alternate, 1- enable field alternate */
175	bool field_alt;
176	/* 0-no force,2-force frame polarity from top,3-force frame polarity from bottom */
177	int force_next_frame_porlarity;
178	/* 0-no force,2-force field polarity from top,3-force field polarity from bottom */
179	int force_next_field_polarity;
180};
181
182struct mpc_denorm_clamp {
183	int clamp_max_r_cr;
184	int clamp_min_r_cr;
185	int clamp_max_g_y;
186	int clamp_min_g_y;
187	int clamp_max_b_cb;
188	int clamp_min_b_cb;
189};
190
191struct mpc_dwb_flow_control {
192	int flow_ctrl_mode;
193	int flow_ctrl_cnt0;
194	int flow_ctrl_cnt1;
195};
196
197/**
198 * struct mpcc - MPCC connection and blending configuration for a single MPCC instance.
 
 
 
 
 
 
199 *
200 * This struct is used as a node in an MPC tree.
201 */
202struct mpcc {
203	/**
204	 * @mpcc_id: MPCC physical instance.
205	 */
206	int mpcc_id;
207
208	/**
209	 * @dpp_id: DPP input to this MPCC
210	 */
211	int dpp_id;
212
213	/**
214	 * @mpcc_bot: Pointer to bottom layer MPCC. NULL when not connected.
215	 */
216	struct mpcc *mpcc_bot;
217
218	/**
219	 * @blnd_cfg: The blending configuration for this MPCC.
220	 */
221	struct mpcc_blnd_cfg blnd_cfg;
222
223	/**
224	 * @sm_cfg: stereo mix setting for this MPCC
225	 */
226	struct mpcc_sm_cfg sm_cfg;
227
228	/**
229	 * @shared_bottom:
230	 *
231	 * If MPCC output to both OPP and DWB endpoints, true. Otherwise, false.
232	 */
233	bool shared_bottom;
234};
235
236/**
237 * struct mpc_tree - MPC tree represents all MPCC connections for a pipe.
238 *
 
 
239 *
240 */
241struct mpc_tree {
242	/**
243	 * @opp_id: The OPP instance that owns this MPC tree.
244	 */
245	int opp_id;
246
247	/**
248	 * @opp_list: the top MPCC layer of the MPC tree that outputs to OPP endpoint
249	 */
250	struct mpcc *opp_list;
251};
252
253struct mpc {
254	const struct mpc_funcs *funcs;
255	struct dc_context *ctx;
256
257	struct mpcc mpcc_array[MAX_MPCC];
258	struct pwl_params blender_params;
259	bool cm_bypass_mode;
260};
261
262struct mpcc_state {
263	uint32_t opp_id;
264	uint32_t dpp_id;
265	uint32_t bot_mpcc_id;
266	uint32_t mode;
267	uint32_t alpha_mode;
268	uint32_t pre_multiplied_alpha;
269	uint32_t overlap_only;
270	uint32_t idle;
271	uint32_t busy;
272	uint32_t shaper_lut_mode;
273	uint32_t lut3d_mode;
274	uint32_t lut3d_bit_depth;
275	uint32_t lut3d_size;
276	uint32_t rgam_mode;
277	uint32_t rgam_lut;
278	struct mpc_grph_gamut_adjustment gamut_remap;
279};
280
281/**
282 * struct mpc_funcs - funcs
283 */
284struct mpc_funcs {
285	void (*read_mpcc_state)(
286			struct mpc *mpc,
287			int mpcc_inst,
288			struct mpcc_state *s);
289
290	/**
291	 * @insert_plane:
292	 *
293	 * Insert DPP into MPC tree based on specified blending position.
294	 * Only used for planes that are part of blending chain for OPP output
295	 *
296	 * Parameters:
 
 
 
 
 
 
 
 
297	 *
298	 * - [in/out] mpc  - MPC context.
299	 * - [in/out] tree - MPC tree structure that plane will be added to.
300	 * - [in] blnd_cfg - MPCC blending configuration for the new blending layer.
301	 * - [in] sm_cfg   - MPCC stereo mix configuration for the new blending layer.
302	 *                   stereo mix must disable for the very bottom layer of the tree config.
303	 * - [in] insert_above_mpcc - Insert new plane above this MPCC.
304	 *                          If NULL, insert as bottom plane.
305	 * - [in] dpp_id  - DPP instance for the plane to be added.
306	 * - [in] mpcc_id - The MPCC physical instance to use for blending.
307	 *
308	 * Return:
309	 *
310	 * struct mpcc* - MPCC that was added.
311	 */
312	struct mpcc* (*insert_plane)(
313			struct mpc *mpc,
314			struct mpc_tree *tree,
315			struct mpcc_blnd_cfg *blnd_cfg,
316			struct mpcc_sm_cfg *sm_cfg,
317			struct mpcc *insert_above_mpcc,
318			int dpp_id,
319			int mpcc_id);
320
321	/**
322	 * @remove_mpcc:
323	 *
324	 * Remove a specified MPCC from the MPC tree.
325	 *
326	 * Parameters:
 
 
 
327	 *
328	 * - [in/out] mpc   - MPC context.
329	 * - [in/out] tree  - MPC tree structure that plane will be removed from.
330	 * - [in/out] mpcc  - MPCC to be removed from tree.
331	 *
332	 * Return:
333	 *
334	 * void
335	 */
336	void (*remove_mpcc)(
337			struct mpc *mpc,
338			struct mpc_tree *tree,
339			struct mpcc *mpcc);
340
341	/**
342	 * @mpc_init:
343	 *
344	 * Reset the MPCC HW status by disconnecting all muxes.
345	 *
346	 * Parameters:
 
347	 *
348	 * - [in/out] mpc - MPC context.
349	 *
350	 * Return:
351	 *
352	 * void
353	 */
354	void (*mpc_init)(struct mpc *mpc);
355	void (*mpc_init_single_inst)(
356			struct mpc *mpc,
357			unsigned int mpcc_id);
358
359	/**
360	 * @update_blending:
361	 *
362	 * Update the blending configuration for a specified MPCC.
363	 *
364	 * Parameters:
 
 
 
365	 *
366	 * - [in/out] mpc - MPC context.
367	 * - [in] blnd_cfg - MPCC blending configuration.
368	 * - [in] mpcc_id  - The MPCC physical instance.
369	 *
370	 * Return:
371	 *
372	 * void
373	 */
374	void (*update_blending)(
375		struct mpc *mpc,
376		struct mpcc_blnd_cfg *blnd_cfg,
377		int mpcc_id);
378
379	/**
380	 * @cursor_lock:
381	 *
382	 * Lock cursor updates for the specified OPP. OPP defines the set of
383	 * MPCC that are locked together for cursor.
384	 *
385	 * Parameters:
 
 
 
386	 *
387	 * - [in] mpc - MPC context.
388	 * - [in] opp_id  - The OPP to lock cursor updates on
389	 * - [in] lock - lock/unlock the OPP
390	 *
391	 * Return:
392	 *
393	 * void
394	 */
395	void (*cursor_lock)(
396			struct mpc *mpc,
397			int opp_id,
398			bool lock);
399
400	/**
401	 * @insert_plane_to_secondary:
402	 *
403	 * Add DPP into secondary MPC tree based on specified blending
404	 * position.  Only used for planes that are part of blending chain for
405	 * DWB output
406	 *
407	 * Parameters:
 
 
 
 
 
 
 
 
408	 *
409	 * - [in/out] mpc  - MPC context.
410	 * - [in/out] tree - MPC tree structure that plane will be added to.
411	 * - [in] blnd_cfg - MPCC blending configuration for the new blending layer.
412	 * - [in] sm_cfg   - MPCC stereo mix configuration for the new blending layer.
413	 *	    stereo mix must disable for the very bottom layer of the tree config.
414	 * - [in] insert_above_mpcc - Insert new plane above this MPCC.  If
415	 *          NULL, insert as bottom plane.
416	 * - [in] dpp_id - DPP instance for the plane to be added.
417	 * - [in] mpcc_id - The MPCC physical instance to use for blending.
418	 *
419	 * Return:
420	 *
421	 * struct mpcc* - MPCC that was added.
422	 */
423	struct mpcc* (*insert_plane_to_secondary)(
424			struct mpc *mpc,
425			struct mpc_tree *tree,
426			struct mpcc_blnd_cfg *blnd_cfg,
427			struct mpcc_sm_cfg *sm_cfg,
428			struct mpcc *insert_above_mpcc,
429			int dpp_id,
430			int mpcc_id);
431
432	/**
433	 * @remove_mpcc_from_secondary:
434	 *
435	 * Remove a specified DPP from the 'secondary' MPC tree.
436	 *
437	 * Parameters:
438	 *
439	 * - [in/out] mpc  - MPC context.
440	 * - [in/out] tree - MPC tree structure that plane will be removed from.
441	 * - [in]     mpcc - MPCC to be removed from tree.
442	 *
443	 * Return:
444	 *
445	 * void
446	 */
447	void (*remove_mpcc_from_secondary)(
448			struct mpc *mpc,
449			struct mpc_tree *tree,
450			struct mpcc *mpcc);
451
452	struct mpcc* (*get_mpcc_for_dpp_from_secondary)(
453			struct mpc_tree *tree,
454			int dpp_id);
455
456	struct mpcc* (*get_mpcc_for_dpp)(
457			struct mpc_tree *tree,
458			int dpp_id);
459
460	void (*wait_for_idle)(struct mpc *mpc, int id);
461
462	void (*assert_mpcc_idle_before_connect)(struct mpc *mpc, int mpcc_id);
463
464	void (*init_mpcc_list_from_hw)(
465		struct mpc *mpc,
466		struct mpc_tree *tree);
467
468	void (*set_denorm)(struct mpc *mpc,
469			int opp_id,
470			enum dc_color_depth output_depth);
471
472	void (*set_denorm_clamp)(
473			struct mpc *mpc,
474			int opp_id,
475			struct mpc_denorm_clamp denorm_clamp);
476
477	void (*set_output_csc)(struct mpc *mpc,
478			int opp_id,
479			const uint16_t *regval,
480			enum mpc_output_csc_mode ocsc_mode);
481
482	void (*set_ocsc_default)(struct mpc *mpc,
483			int opp_id,
484			enum dc_color_space color_space,
485			enum mpc_output_csc_mode ocsc_mode);
486
487	void (*set_output_gamma)(
488			struct mpc *mpc,
489			int mpcc_id,
490			const struct pwl_params *params);
491	void (*power_on_mpc_mem_pwr)(
492			struct mpc *mpc,
493			int mpcc_id,
494			bool power_on);
495	void (*set_dwb_mux)(
496			struct mpc *mpc,
497			int dwb_id,
498			int mpcc_id);
499
500	void (*disable_dwb_mux)(
501		struct mpc *mpc,
502		int dwb_id);
503
504	bool (*is_dwb_idle)(
505		struct mpc *mpc,
506		int dwb_id);
507
508	void (*set_out_rate_control)(
509		struct mpc *mpc,
510		int opp_id,
511		bool enable,
512		bool rate_2x_mode,
513		struct mpc_dwb_flow_control *flow_control);
514
515	void (*set_gamut_remap)(
516			struct mpc *mpc,
517			int mpcc_id,
518			const struct mpc_grph_gamut_adjustment *adjust);
519
520	bool (*program_1dlut)(
521			struct mpc *mpc,
522			const struct pwl_params *params,
523			uint32_t rmu_idx);
524
525	bool (*program_shaper)(
526			struct mpc *mpc,
527			const struct pwl_params *params,
528			uint32_t rmu_idx);
529
530	uint32_t (*acquire_rmu)(struct mpc *mpc, int mpcc_id, int rmu_idx);
531
532	bool (*program_3dlut)(
533			struct mpc *mpc,
534			const struct tetrahedral_params *params,
535			int rmu_idx);
536
537	int (*release_rmu)(struct mpc *mpc, int mpcc_id);
538
539	unsigned int (*get_mpc_out_mux)(
540			struct mpc *mpc,
541			int opp_id);
542
543	void (*set_bg_color)(struct mpc *mpc,
544			struct tg_color *bg_color,
545			int mpcc_id);
546	void (*set_mpc_mem_lp_mode)(struct mpc *mpc);
547};
548
549#endif
v6.2
  1/* Copyright 2012-15 Advanced Micro Devices, Inc.
  2 *
  3 * Permission is hereby granted, free of charge, to any person obtaining a
  4 * copy of this software and associated documentation files (the "Software"),
  5 * to deal in the Software without restriction, including without limitation
  6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  7 * and/or sell copies of the Software, and to permit persons to whom the
  8 * Software is furnished to do so, subject to the following conditions:
  9 *
 10 * The above copyright notice and this permission notice shall be included in
 11 * all copies or substantial portions of the Software.
 12 *
 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 16 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
 17 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 18 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 19 * OTHER DEALINGS IN THE SOFTWARE.
 20 *
 21 * Authors: AMD
 22 *
 23 */
 24
 25/**
 26 * DOC: mpc-overview
 27 *
 28 * Multiple Pipe/Plane Combined (MPC) is a component in the hardware pipeline
 29 * that performs blending of multiple planes, using global and per-pixel alpha.
 30 * It also performs post-blending color correction operations according to the
 31 * hardware capabilities, such as color transformation matrix and gamma 1D and
 32 * 3D LUT.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 33 */
 34
 35#ifndef __DC_MPCC_H__
 36#define __DC_MPCC_H__
 37
 38#include "dc_hw_types.h"
 39#include "hw_shared.h"
 40#include "transform.h"
 41
 42#define MAX_MPCC 6
 43#define MAX_OPP 6
 44
 45#define MAX_DWB		2
 46
 47enum mpc_output_csc_mode {
 48	MPC_OUTPUT_CSC_DISABLE = 0,
 49	MPC_OUTPUT_CSC_COEF_A,
 50	MPC_OUTPUT_CSC_COEF_B
 51};
 52
 53
 54enum mpcc_blend_mode {
 55	MPCC_BLEND_MODE_BYPASS,
 56	MPCC_BLEND_MODE_TOP_LAYER_PASSTHROUGH,
 57	MPCC_BLEND_MODE_TOP_LAYER_ONLY,
 58	MPCC_BLEND_MODE_TOP_BOT_BLENDING
 59};
 60
 61/**
 62 * enum mpcc_alpha_blend_mode - define the alpha blend mode regarding pixel
 63 * alpha and plane alpha values
 64 */
 65enum mpcc_alpha_blend_mode {
 66	/**
 67	 * @MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA: per pixel alpha using DPP
 68	 * alpha value
 69	 */
 70	MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA,
 71	/**
 72	 * @MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA_COMBINED_GLOBAL_GAIN: per
 73	 * pixel alpha using DPP alpha value multiplied by a global gain (plane
 74	 * alpha)
 75	 */
 76	MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA_COMBINED_GLOBAL_GAIN,
 77	/**
 78	 * @MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA: global alpha value, ignores
 79	 * pixel alpha and consider only plane alpha
 80	 */
 81	MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA
 82};
 83
 84/**
 85 * struct mpcc_blnd_cfg - MPCC blending configuration
 86 *
 87 * @black_color: background color
 88 * @alpha_mode: alpha blend mode (MPCC_ALPHA_BLND_MODE)
 89 * @pre_multiplied_alpha: whether pixel color values were pre-multiplied by the
 90 * alpha channel (MPCC_ALPHA_MULTIPLIED_MODE)
 91 * @global_gain: used when blend mode considers both pixel alpha and plane
 92 * alpha value and assumes the global alpha value.
 93 * @global_alpha: plane alpha value
 94 */
 95struct mpcc_blnd_cfg {
 96	struct tg_color black_color;	/* background color */
 97	enum mpcc_alpha_blend_mode alpha_mode;	/* alpha blend mode */
 98	bool pre_multiplied_alpha;	/* alpha pre-multiplied mode flag */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 99	int global_gain;
 
 
 
 
100	int global_alpha;
 
 
 
 
101	bool overlap_only;
102
103	/* MPCC top/bottom gain settings */
 
 
 
 
104	int bottom_gain_mode;
 
 
 
 
105	int background_color_bpc;
 
 
 
 
106	int top_gain;
 
 
 
 
107	int bottom_inside_gain;
 
 
 
 
108	int bottom_outside_gain;
109};
110
111struct mpc_grph_gamut_adjustment {
112	struct fixed31_32 temperature_matrix[CSC_TEMPERATURE_MATRIX_SIZE];
113	enum graphics_gamut_adjust_type gamut_adjust_type;
114};
115
116struct mpcc_sm_cfg {
117	bool enable;
118	/* 0-single plane,2-row subsampling,4-column subsampling,6-checkboard subsampling */
119	int sm_mode;
120	/* 0- disable frame alternate, 1- enable frame alternate */
121	bool frame_alt;
122	/* 0- disable field alternate, 1- enable field alternate */
123	bool field_alt;
124	/* 0-no force,2-force frame polarity from top,3-force frame polarity from bottom */
125	int force_next_frame_porlarity;
126	/* 0-no force,2-force field polarity from top,3-force field polarity from bottom */
127	int force_next_field_polarity;
128};
129
130struct mpc_denorm_clamp {
131	int clamp_max_r_cr;
132	int clamp_min_r_cr;
133	int clamp_max_g_y;
134	int clamp_min_g_y;
135	int clamp_max_b_cb;
136	int clamp_min_b_cb;
137};
138
139struct mpc_dwb_flow_control {
140	int flow_ctrl_mode;
141	int flow_ctrl_cnt0;
142	int flow_ctrl_cnt1;
143};
144
145/**
146 * struct mpcc - MPCC connection and blending configuration for a single MPCC instance.
147 * @mpcc_id: MPCC physical instance
148 * @dpp_id: DPP input to this MPCC
149 * @mpcc_bot: pointer to bottom layer MPCC. NULL when not connected.
150 * @blnd_cfg: the blending configuration for this MPCC
151 * @sm_cfg: stereo mix setting for this MPCC
152 * @shared_bottom: if MPCC output to both OPP and DWB endpoints, true. Otherwise, false.
153 *
154 * This struct is used as a node in an MPC tree.
155 */
156struct mpcc {
157	int mpcc_id;			/* MPCC physical instance */
158	int dpp_id;			/* DPP input to this MPCC */
159	struct mpcc *mpcc_bot;		/* pointer to bottom layer MPCC.  NULL when not connected */
160	struct mpcc_blnd_cfg blnd_cfg;	/* The blending configuration for this MPCC */
161	struct mpcc_sm_cfg sm_cfg;	/* stereo mix setting for this MPCC */
162	bool shared_bottom;		/* TRUE if MPCC output to both OPP and DWB endpoints, else FALSE */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163};
164
165/**
166 * struct mpc_tree - MPC tree represents all MPCC connections for a pipe.
167 *
168 * @opp_id: the OPP instance that owns this MPC tree
169 * @opp_list: the top MPCC layer of the MPC tree that outputs to OPP endpoint
170 *
171 */
172struct mpc_tree {
173	int opp_id;			/* The OPP instance that owns this MPC tree */
174	struct mpcc *opp_list;		/* The top MPCC layer of the MPC tree that outputs to OPP endpoint */
 
 
 
 
 
 
 
175};
176
177struct mpc {
178	const struct mpc_funcs *funcs;
179	struct dc_context *ctx;
180
181	struct mpcc mpcc_array[MAX_MPCC];
182	struct pwl_params blender_params;
183	bool cm_bypass_mode;
184};
185
186struct mpcc_state {
187	uint32_t opp_id;
188	uint32_t dpp_id;
189	uint32_t bot_mpcc_id;
190	uint32_t mode;
191	uint32_t alpha_mode;
192	uint32_t pre_multiplied_alpha;
193	uint32_t overlap_only;
194	uint32_t idle;
195	uint32_t busy;
 
 
 
 
 
 
 
196};
197
198/**
199 * struct mpc_funcs - funcs
200 */
201struct mpc_funcs {
202	void (*read_mpcc_state)(
203			struct mpc *mpc,
204			int mpcc_inst,
205			struct mpcc_state *s);
206
207	/**
208	 * @insert_plane:
209	 *
210	 * Insert DPP into MPC tree based on specified blending position.
211	 * Only used for planes that are part of blending chain for OPP output
212	 *
213	 * Parameters:
214	 * [in/out] mpc		- MPC context.
215	 * [in/out] tree	- MPC tree structure that plane will be added to.
216	 * [in]	blnd_cfg	- MPCC blending configuration for the new blending layer.
217	 * [in]	sm_cfg		- MPCC stereo mix configuration for the new blending layer.
218	 *			  stereo mix must disable for the very bottom layer of the tree config.
219	 * [in]	insert_above_mpcc - Insert new plane above this MPCC.  If NULL, insert as bottom plane.
220	 * [in]	dpp_id		 - DPP instance for the plane to be added.
221	 * [in]	mpcc_id		 - The MPCC physical instance to use for blending.
222	 *
223	 * Return:  struct mpcc* - MPCC that was added.
 
 
 
 
 
 
 
 
 
 
 
 
224	 */
225	struct mpcc* (*insert_plane)(
226			struct mpc *mpc,
227			struct mpc_tree *tree,
228			struct mpcc_blnd_cfg *blnd_cfg,
229			struct mpcc_sm_cfg *sm_cfg,
230			struct mpcc *insert_above_mpcc,
231			int dpp_id,
232			int mpcc_id);
233
234	/**
235	 * @remove_mpcc:
236	 *
237	 * Remove a specified MPCC from the MPC tree.
238	 *
239	 * Parameters:
240	 * [in/out] mpc		- MPC context.
241	 * [in/out] tree	- MPC tree structure that plane will be removed from.
242	 * [in/out] mpcc	- MPCC to be removed from tree.
243	 *
244	 * Return:  void
 
 
 
 
 
 
245	 */
246	void (*remove_mpcc)(
247			struct mpc *mpc,
248			struct mpc_tree *tree,
249			struct mpcc *mpcc);
250
251	/**
252	 * @mpc_init:
253	 *
254	 * Reset the MPCC HW status by disconnecting all muxes.
255	 *
256	 * Parameters:
257	 * [in/out] mpc		- MPC context.
258	 *
259	 * Return:  void
 
 
 
 
260	 */
261	void (*mpc_init)(struct mpc *mpc);
262	void (*mpc_init_single_inst)(
263			struct mpc *mpc,
264			unsigned int mpcc_id);
265
266	/**
267	 * @update_blending:
268	 *
269	 * Update the blending configuration for a specified MPCC.
270	 *
271	 * Parameters:
272	 * [in/out] mpc		- MPC context.
273	 * [in]     blnd_cfg	- MPCC blending configuration.
274	 * [in]     mpcc_id	- The MPCC physical instance.
275	 *
276	 * Return:  void
 
 
 
 
 
 
277	 */
278	void (*update_blending)(
279		struct mpc *mpc,
280		struct mpcc_blnd_cfg *blnd_cfg,
281		int mpcc_id);
282
283	/**
284	 * @cursor_lock:
285	 *
286	 * Lock cursor updates for the specified OPP.
287	 * OPP defines the set of MPCC that are locked together for cursor.
288	 *
289	 * Parameters:
290	 * [in] 	mpc		- MPC context.
291	 * [in]     opp_id	- The OPP to lock cursor updates on
292	 * [in]		lock	- lock/unlock the OPP
293	 *
294	 * Return:  void
 
 
 
 
 
 
295	 */
296	void (*cursor_lock)(
297			struct mpc *mpc,
298			int opp_id,
299			bool lock);
300
301	/**
302	 * @insert_plane_to_secondary:
303	 *
304	 * Add DPP into secondary MPC tree based on specified blending position.
305	 * Only used for planes that are part of blending chain for DWB output
 
306	 *
307	 * Parameters:
308	 * [in/out] mpc		- MPC context.
309	 * [in/out] tree		- MPC tree structure that plane will be added to.
310	 * [in]	blnd_cfg	- MPCC blending configuration for the new blending layer.
311	 * [in]	sm_cfg		- MPCC stereo mix configuration for the new blending layer.
312	 *			  stereo mix must disable for the very bottom layer of the tree config.
313	 * [in]	insert_above_mpcc - Insert new plane above this MPCC.  If NULL, insert as bottom plane.
314	 * [in]	dpp_id		- DPP instance for the plane to be added.
315	 * [in]	mpcc_id		- The MPCC physical instance to use for blending.
316	 *
317	 * Return:  struct mpcc* - MPCC that was added.
 
 
 
 
 
 
 
 
 
 
 
 
318	 */
319	struct mpcc* (*insert_plane_to_secondary)(
320			struct mpc *mpc,
321			struct mpc_tree *tree,
322			struct mpcc_blnd_cfg *blnd_cfg,
323			struct mpcc_sm_cfg *sm_cfg,
324			struct mpcc *insert_above_mpcc,
325			int dpp_id,
326			int mpcc_id);
327
328	/**
329	 * @remove_mpcc_from_secondary:
330	 *
331	 * Remove a specified DPP from the 'secondary' MPC tree.
332	 *
333	 * Parameters:
334	 * [in/out] mpc		- MPC context.
335	 * [in/out] tree	- MPC tree structure that plane will be removed from.
336	 * [in]     mpcc	- MPCC to be removed from tree.
337	 * Return:  void
 
 
 
 
338	 */
339	void (*remove_mpcc_from_secondary)(
340			struct mpc *mpc,
341			struct mpc_tree *tree,
342			struct mpcc *mpcc);
343
344	struct mpcc* (*get_mpcc_for_dpp_from_secondary)(
345			struct mpc_tree *tree,
346			int dpp_id);
347
348	struct mpcc* (*get_mpcc_for_dpp)(
349			struct mpc_tree *tree,
350			int dpp_id);
351
352	void (*wait_for_idle)(struct mpc *mpc, int id);
353
354	void (*assert_mpcc_idle_before_connect)(struct mpc *mpc, int mpcc_id);
355
356	void (*init_mpcc_list_from_hw)(
357		struct mpc *mpc,
358		struct mpc_tree *tree);
359
360	void (*set_denorm)(struct mpc *mpc,
361			int opp_id,
362			enum dc_color_depth output_depth);
363
364	void (*set_denorm_clamp)(
365			struct mpc *mpc,
366			int opp_id,
367			struct mpc_denorm_clamp denorm_clamp);
368
369	void (*set_output_csc)(struct mpc *mpc,
370			int opp_id,
371			const uint16_t *regval,
372			enum mpc_output_csc_mode ocsc_mode);
373
374	void (*set_ocsc_default)(struct mpc *mpc,
375			int opp_id,
376			enum dc_color_space color_space,
377			enum mpc_output_csc_mode ocsc_mode);
378
379	void (*set_output_gamma)(
380			struct mpc *mpc,
381			int mpcc_id,
382			const struct pwl_params *params);
383	void (*power_on_mpc_mem_pwr)(
384			struct mpc *mpc,
385			int mpcc_id,
386			bool power_on);
387	void (*set_dwb_mux)(
388			struct mpc *mpc,
389			int dwb_id,
390			int mpcc_id);
391
392	void (*disable_dwb_mux)(
393		struct mpc *mpc,
394		int dwb_id);
395
396	bool (*is_dwb_idle)(
397		struct mpc *mpc,
398		int dwb_id);
399
400	void (*set_out_rate_control)(
401		struct mpc *mpc,
402		int opp_id,
403		bool enable,
404		bool rate_2x_mode,
405		struct mpc_dwb_flow_control *flow_control);
406
407	void (*set_gamut_remap)(
408			struct mpc *mpc,
409			int mpcc_id,
410			const struct mpc_grph_gamut_adjustment *adjust);
411
412	bool (*program_1dlut)(
413			struct mpc *mpc,
414			const struct pwl_params *params,
415			uint32_t rmu_idx);
416
417	bool (*program_shaper)(
418			struct mpc *mpc,
419			const struct pwl_params *params,
420			uint32_t rmu_idx);
421
422	uint32_t (*acquire_rmu)(struct mpc *mpc, int mpcc_id, int rmu_idx);
423
424	bool (*program_3dlut)(
425			struct mpc *mpc,
426			const struct tetrahedral_params *params,
427			int rmu_idx);
428
429	int (*release_rmu)(struct mpc *mpc, int mpcc_id);
430
431	unsigned int (*get_mpc_out_mux)(
432			struct mpc *mpc,
433			int opp_id);
434
435	void (*set_bg_color)(struct mpc *mpc,
436			struct tg_color *bg_color,
437			int mpcc_id);
438	void (*set_mpc_mem_lp_mode)(struct mpc *mpc);
439};
440
441#endif