mpc.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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 mpcc_state {
  94. uint32_t opp_id;
  95. uint32_t dpp_id;
  96. uint32_t bot_mpcc_id;
  97. uint32_t mode;
  98. uint32_t alpha_mode;
  99. uint32_t pre_multiplied_alpha;
  100. uint32_t overlap_only;
  101. uint32_t idle;
  102. uint32_t busy;
  103. };
  104. struct mpc_funcs {
  105. void (*read_mpcc_state)(
  106. struct mpc *mpc,
  107. int mpcc_inst,
  108. struct mpcc_state *s);
  109. /*
  110. * Insert DPP into MPC tree based on specified blending position.
  111. * Only used for planes that are part of blending chain for OPP output
  112. *
  113. * Parameters:
  114. * [in/out] mpc - MPC context.
  115. * [in/out] tree - MPC tree structure that plane will be added to.
  116. * [in] blnd_cfg - MPCC blending configuration for the new blending layer.
  117. * [in] sm_cfg - MPCC stereo mix configuration for the new blending layer.
  118. * stereo mix must disable for the very bottom layer of the tree config.
  119. * [in] insert_above_mpcc - Insert new plane above this MPCC. If NULL, insert as bottom plane.
  120. * [in] dpp_id - DPP instance for the plane to be added.
  121. * [in] mpcc_id - The MPCC physical instance to use for blending.
  122. *
  123. * Return: struct mpcc* - MPCC that was added.
  124. */
  125. struct mpcc* (*insert_plane)(
  126. struct mpc *mpc,
  127. struct mpc_tree *tree,
  128. struct mpcc_blnd_cfg *blnd_cfg,
  129. struct mpcc_sm_cfg *sm_cfg,
  130. struct mpcc *insert_above_mpcc,
  131. int dpp_id,
  132. int mpcc_id);
  133. /*
  134. * Remove a specified MPCC from the MPC tree.
  135. *
  136. * Parameters:
  137. * [in/out] mpc - MPC context.
  138. * [in/out] tree - MPC tree structure that plane will be removed from.
  139. * [in/out] mpcc - MPCC to be removed from tree.
  140. *
  141. * Return: void
  142. */
  143. void (*remove_mpcc)(
  144. struct mpc *mpc,
  145. struct mpc_tree *tree,
  146. struct mpcc *mpcc);
  147. /*
  148. * Reset the MPCC HW status by disconnecting all muxes.
  149. *
  150. * Parameters:
  151. * [in/out] mpc - MPC context.
  152. *
  153. * Return: void
  154. */
  155. void (*mpc_init)(struct mpc *mpc);
  156. /*
  157. * Update the blending configuration for a specified MPCC.
  158. *
  159. * Parameters:
  160. * [in/out] mpc - MPC context.
  161. * [in] blnd_cfg - MPCC blending configuration.
  162. * [in] mpcc_id - The MPCC physical instance.
  163. *
  164. * Return: void
  165. */
  166. void (*update_blending)(
  167. struct mpc *mpc,
  168. struct mpcc_blnd_cfg *blnd_cfg,
  169. int mpcc_id);
  170. struct mpcc* (*get_mpcc_for_dpp)(
  171. struct mpc_tree *tree,
  172. int dpp_id);
  173. void (*wait_for_idle)(struct mpc *mpc, int id);
  174. void (*assert_mpcc_idle_before_connect)(struct mpc *mpc, int mpcc_id);
  175. void (*init_mpcc_list_from_hw)(
  176. struct mpc *mpc,
  177. struct mpc_tree *tree);
  178. };
  179. #endif