mpc.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. #ifndef __DC_MPCC_H__
  25. #define __DC_MPCC_H__
  26. #include "dc_hw_types.h"
  27. #include "hw_shared.h"
  28. #define MAX_MPCC 6
  29. #define MAX_OPP 6
  30. enum mpc_output_csc_mode {
  31. MPC_OUTPUT_CSC_DISABLE = 0,
  32. MPC_OUTPUT_CSC_COEF_A,
  33. MPC_OUTPUT_CSC_COEF_B
  34. };
  35. enum mpcc_blend_mode {
  36. MPCC_BLEND_MODE_BYPASS,
  37. MPCC_BLEND_MODE_TOP_LAYER_PASSTHROUGH,
  38. MPCC_BLEND_MODE_TOP_LAYER_ONLY,
  39. MPCC_BLEND_MODE_TOP_BOT_BLENDING
  40. };
  41. enum mpcc_alpha_blend_mode {
  42. MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA,
  43. MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA_COMBINED_GLOBAL_GAIN,
  44. MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA
  45. };
  46. /*
  47. * MPCC blending configuration
  48. */
  49. struct mpcc_blnd_cfg {
  50. struct tg_color black_color; /* background color */
  51. enum mpcc_alpha_blend_mode alpha_mode; /* alpha blend mode */
  52. bool pre_multiplied_alpha; /* alpha pre-multiplied mode flag */
  53. int global_gain;
  54. int global_alpha;
  55. bool overlap_only;
  56. };
  57. struct mpcc_sm_cfg {
  58. bool enable;
  59. /* 0-single plane,2-row subsampling,4-column subsampling,6-checkboard subsampling */
  60. int sm_mode;
  61. /* 0- disable frame alternate, 1- enable frame alternate */
  62. bool frame_alt;
  63. /* 0- disable field alternate, 1- enable field alternate */
  64. bool field_alt;
  65. /* 0-no force,2-force frame polarity from top,3-force frame polarity from bottom */
  66. int force_next_frame_porlarity;
  67. /* 0-no force,2-force field polarity from top,3-force field polarity from bottom */
  68. int force_next_field_polarity;
  69. };
  70. /*
  71. * MPCC connection and blending configuration for a single MPCC instance.
  72. * This struct is used as a node in an MPC tree.
  73. */
  74. struct mpcc {
  75. int mpcc_id; /* MPCC physical instance */
  76. int dpp_id; /* DPP input to this MPCC */
  77. struct mpcc *mpcc_bot; /* pointer to bottom layer MPCC. NULL when not connected */
  78. struct mpcc_blnd_cfg blnd_cfg; /* The blending configuration for this MPCC */
  79. struct mpcc_sm_cfg sm_cfg; /* stereo mix setting for this MPCC */
  80. };
  81. /*
  82. * MPC tree represents all MPCC connections for a pipe.
  83. */
  84. struct mpc_tree {
  85. int opp_id; /* The OPP instance that owns this MPC tree */
  86. struct mpcc *opp_list; /* The top MPCC layer of the MPC tree that outputs to OPP endpoint */
  87. };
  88. struct mpc {
  89. const struct mpc_funcs *funcs;
  90. struct dc_context *ctx;
  91. struct mpcc mpcc_array[MAX_MPCC];
  92. };
  93. struct mpc_funcs {
  94. /*
  95. * Insert DPP into MPC tree based on specified blending position.
  96. * Only used for planes that are part of blending chain for OPP output
  97. *
  98. * Parameters:
  99. * [in/out] mpc - MPC context.
  100. * [in/out] tree - MPC tree structure that plane will be added to.
  101. * [in] blnd_cfg - MPCC blending configuration for the new blending layer.
  102. * [in] sm_cfg - MPCC stereo mix configuration for the new blending layer.
  103. * stereo mix must disable for the very bottom layer of the tree config.
  104. * [in] insert_above_mpcc - Insert new plane above this MPCC. If NULL, insert as bottom plane.
  105. * [in] dpp_id - DPP instance for the plane to be added.
  106. * [in] mpcc_id - The MPCC physical instance to use for blending.
  107. *
  108. * Return: struct mpcc* - MPCC that was added.
  109. */
  110. struct mpcc* (*insert_plane)(
  111. struct mpc *mpc,
  112. struct mpc_tree *tree,
  113. struct mpcc_blnd_cfg *blnd_cfg,
  114. struct mpcc_sm_cfg *sm_cfg,
  115. struct mpcc *insert_above_mpcc,
  116. int dpp_id,
  117. int mpcc_id);
  118. /*
  119. * Remove a specified MPCC from the MPC tree.
  120. *
  121. * Parameters:
  122. * [in/out] mpc - MPC context.
  123. * [in/out] tree - MPC tree structure that plane will be removed from.
  124. * [in/out] mpcc - MPCC to be removed from tree.
  125. *
  126. * Return: void
  127. */
  128. void (*remove_mpcc)(
  129. struct mpc *mpc,
  130. struct mpc_tree *tree,
  131. struct mpcc *mpcc);
  132. /*
  133. * Reset the MPCC HW status by disconnecting all muxes.
  134. *
  135. * Parameters:
  136. * [in/out] mpc - MPC context.
  137. *
  138. * Return: void
  139. */
  140. void (*mpc_init)(struct mpc *mpc);
  141. /*
  142. * Update the blending configuration for a specified MPCC.
  143. *
  144. * Parameters:
  145. * [in/out] mpc - MPC context.
  146. * [in] blnd_cfg - MPCC blending configuration.
  147. * [in] mpcc_id - The MPCC physical instance.
  148. *
  149. * Return: void
  150. */
  151. void (*update_blending)(
  152. struct mpc *mpc,
  153. struct mpcc_blnd_cfg *blnd_cfg,
  154. int mpcc_id);
  155. struct mpcc* (*get_mpcc_for_dpp)(
  156. struct mpc_tree *tree,
  157. int dpp_id);
  158. void (*wait_for_idle)(struct mpc *mpc, int id);
  159. void (*assert_mpcc_idle_before_connect)(struct mpc *mpc, int mpcc_id);
  160. void (*init_mpcc_list_from_hw)(
  161. struct mpc *mpc,
  162. struct mpc_tree *tree);
  163. };
  164. #endif