Back to home page

OSCL-LXR

 
 

    


0001 /* Copyright 2012-15 Advanced Micro Devices, Inc.
0002  *
0003  * Permission is hereby granted, free of charge, to any person obtaining a
0004  * copy of this software and associated documentation files (the "Software"),
0005  * to deal in the Software without restriction, including without limitation
0006  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0007  * and/or sell copies of the Software, and to permit persons to whom the
0008  * Software is furnished to do so, subject to the following conditions:
0009  *
0010  * The above copyright notice and this permission notice shall be included in
0011  * all copies or substantial portions of the Software.
0012  *
0013  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0014  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0015  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0016  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0017  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0018  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0019  * OTHER DEALINGS IN THE SOFTWARE.
0020  *
0021  * Authors: AMD
0022  *
0023  */
0024 
0025 #ifndef __DC_MPCC_H__
0026 #define __DC_MPCC_H__
0027 
0028 #include "dc_hw_types.h"
0029 #include "hw_shared.h"
0030 #include "transform.h"
0031 
0032 #define MAX_MPCC 6
0033 #define MAX_OPP 6
0034 
0035 #define MAX_DWB     2
0036 
0037 enum mpc_output_csc_mode {
0038     MPC_OUTPUT_CSC_DISABLE = 0,
0039     MPC_OUTPUT_CSC_COEF_A,
0040     MPC_OUTPUT_CSC_COEF_B
0041 };
0042 
0043 
0044 enum mpcc_blend_mode {
0045     MPCC_BLEND_MODE_BYPASS,
0046     MPCC_BLEND_MODE_TOP_LAYER_PASSTHROUGH,
0047     MPCC_BLEND_MODE_TOP_LAYER_ONLY,
0048     MPCC_BLEND_MODE_TOP_BOT_BLENDING
0049 };
0050 
0051 enum mpcc_alpha_blend_mode {
0052     MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA,
0053     MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA_COMBINED_GLOBAL_GAIN,
0054     MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA
0055 };
0056 
0057 /*
0058  * MPCC blending configuration
0059  */
0060 struct mpcc_blnd_cfg {
0061     struct tg_color black_color;    /* background color */
0062     enum mpcc_alpha_blend_mode alpha_mode;  /* alpha blend mode */
0063     bool pre_multiplied_alpha;  /* alpha pre-multiplied mode flag */
0064     int global_gain;
0065     int global_alpha;
0066     bool overlap_only;
0067 
0068     /* MPCC top/bottom gain settings */
0069     int bottom_gain_mode;
0070     int background_color_bpc;
0071     int top_gain;
0072     int bottom_inside_gain;
0073     int bottom_outside_gain;
0074 };
0075 
0076 struct mpc_grph_gamut_adjustment {
0077     struct fixed31_32 temperature_matrix[CSC_TEMPERATURE_MATRIX_SIZE];
0078     enum graphics_gamut_adjust_type gamut_adjust_type;
0079 };
0080 
0081 struct mpcc_sm_cfg {
0082     bool enable;
0083     /* 0-single plane,2-row subsampling,4-column subsampling,6-checkboard subsampling */
0084     int sm_mode;
0085     /* 0- disable frame alternate, 1- enable frame alternate */
0086     bool frame_alt;
0087     /* 0- disable field alternate, 1- enable field alternate */
0088     bool field_alt;
0089     /* 0-no force,2-force frame polarity from top,3-force frame polarity from bottom */
0090     int force_next_frame_porlarity;
0091     /* 0-no force,2-force field polarity from top,3-force field polarity from bottom */
0092     int force_next_field_polarity;
0093 };
0094 
0095 struct mpc_denorm_clamp {
0096     int clamp_max_r_cr;
0097     int clamp_min_r_cr;
0098     int clamp_max_g_y;
0099     int clamp_min_g_y;
0100     int clamp_max_b_cb;
0101     int clamp_min_b_cb;
0102 };
0103 
0104 struct mpc_dwb_flow_control {
0105     int flow_ctrl_mode;
0106     int flow_ctrl_cnt0;
0107     int flow_ctrl_cnt1;
0108 };
0109 
0110 /*
0111  * MPCC connection and blending configuration for a single MPCC instance.
0112  * This struct is used as a node in an MPC tree.
0113  */
0114 struct mpcc {
0115     int mpcc_id;            /* MPCC physical instance */
0116     int dpp_id;         /* DPP input to this MPCC */
0117     struct mpcc *mpcc_bot;      /* pointer to bottom layer MPCC.  NULL when not connected */
0118     struct mpcc_blnd_cfg blnd_cfg;  /* The blending configuration for this MPCC */
0119     struct mpcc_sm_cfg sm_cfg;  /* stereo mix setting for this MPCC */
0120     bool shared_bottom;     /* TRUE if MPCC output to both OPP and DWB endpoints, else FALSE */
0121 };
0122 
0123 /*
0124  * MPC tree represents all MPCC connections for a pipe.
0125  */
0126 struct mpc_tree {
0127     int opp_id;         /* The OPP instance that owns this MPC tree */
0128     struct mpcc *opp_list;      /* The top MPCC layer of the MPC tree that outputs to OPP endpoint */
0129 };
0130 
0131 struct mpc {
0132     const struct mpc_funcs *funcs;
0133     struct dc_context *ctx;
0134 
0135     struct mpcc mpcc_array[MAX_MPCC];
0136     struct pwl_params blender_params;
0137     bool cm_bypass_mode;
0138 };
0139 
0140 struct mpcc_state {
0141     uint32_t opp_id;
0142     uint32_t dpp_id;
0143     uint32_t bot_mpcc_id;
0144     uint32_t mode;
0145     uint32_t alpha_mode;
0146     uint32_t pre_multiplied_alpha;
0147     uint32_t overlap_only;
0148     uint32_t idle;
0149     uint32_t busy;
0150 };
0151 
0152 struct mpc_funcs {
0153     void (*read_mpcc_state)(
0154             struct mpc *mpc,
0155             int mpcc_inst,
0156             struct mpcc_state *s);
0157 
0158     /*
0159      * Insert DPP into MPC tree based on specified blending position.
0160      * Only used for planes that are part of blending chain for OPP output
0161      *
0162      * Parameters:
0163      * [in/out] mpc     - MPC context.
0164      * [in/out] tree    - MPC tree structure that plane will be added to.
0165      * [in] blnd_cfg    - MPCC blending configuration for the new blending layer.
0166      * [in] sm_cfg      - MPCC stereo mix configuration for the new blending layer.
0167      *            stereo mix must disable for the very bottom layer of the tree config.
0168      * [in] insert_above_mpcc - Insert new plane above this MPCC.  If NULL, insert as bottom plane.
0169      * [in] dpp_id       - DPP instance for the plane to be added.
0170      * [in] mpcc_id      - The MPCC physical instance to use for blending.
0171      *
0172      * Return:  struct mpcc* - MPCC that was added.
0173      */
0174     struct mpcc* (*insert_plane)(
0175             struct mpc *mpc,
0176             struct mpc_tree *tree,
0177             struct mpcc_blnd_cfg *blnd_cfg,
0178             struct mpcc_sm_cfg *sm_cfg,
0179             struct mpcc *insert_above_mpcc,
0180             int dpp_id,
0181             int mpcc_id);
0182 
0183     /*
0184      * Remove a specified MPCC from the MPC tree.
0185      *
0186      * Parameters:
0187      * [in/out] mpc     - MPC context.
0188      * [in/out] tree    - MPC tree structure that plane will be removed from.
0189      * [in/out] mpcc    - MPCC to be removed from tree.
0190      *
0191      * Return:  void
0192      */
0193     void (*remove_mpcc)(
0194             struct mpc *mpc,
0195             struct mpc_tree *tree,
0196             struct mpcc *mpcc);
0197 
0198     /*
0199      * Reset the MPCC HW status by disconnecting all muxes.
0200      *
0201      * Parameters:
0202      * [in/out] mpc     - MPC context.
0203      *
0204      * Return:  void
0205      */
0206     void (*mpc_init)(struct mpc *mpc);
0207     void (*mpc_init_single_inst)(
0208             struct mpc *mpc,
0209             unsigned int mpcc_id);
0210 
0211     /*
0212      * Update the blending configuration for a specified MPCC.
0213      *
0214      * Parameters:
0215      * [in/out] mpc     - MPC context.
0216      * [in]     blnd_cfg    - MPCC blending configuration.
0217      * [in]     mpcc_id - The MPCC physical instance.
0218      *
0219      * Return:  void
0220      */
0221     void (*update_blending)(
0222         struct mpc *mpc,
0223         struct mpcc_blnd_cfg *blnd_cfg,
0224         int mpcc_id);
0225 
0226     /*
0227      * Lock cursor updates for the specified OPP.
0228      * OPP defines the set of MPCC that are locked together for cursor.
0229      *
0230      * Parameters:
0231      * [in]     mpc     - MPC context.
0232      * [in]     opp_id  - The OPP to lock cursor updates on
0233      * [in]     lock    - lock/unlock the OPP
0234      *
0235      * Return:  void
0236      */
0237     void (*cursor_lock)(
0238             struct mpc *mpc,
0239             int opp_id,
0240             bool lock);
0241 
0242     /*
0243      * Add DPP into 'secondary' MPC tree based on specified blending position.
0244      * Only used for planes that are part of blending chain for DWB output
0245      *
0246      * Parameters:
0247      * [in/out] mpc     - MPC context.
0248      * [in/out] tree        - MPC tree structure that plane will be added to.
0249      * [in] blnd_cfg    - MPCC blending configuration for the new blending layer.
0250      * [in] sm_cfg      - MPCC stereo mix configuration for the new blending layer.
0251      *            stereo mix must disable for the very bottom layer of the tree config.
0252      * [in] insert_above_mpcc - Insert new plane above this MPCC.  If NULL, insert as bottom plane.
0253      * [in] dpp_id      - DPP instance for the plane to be added.
0254      * [in] mpcc_id     - The MPCC physical instance to use for blending.
0255      *
0256      * Return:  struct mpcc* - MPCC that was added.
0257      */
0258     struct mpcc* (*insert_plane_to_secondary)(
0259             struct mpc *mpc,
0260             struct mpc_tree *tree,
0261             struct mpcc_blnd_cfg *blnd_cfg,
0262             struct mpcc_sm_cfg *sm_cfg,
0263             struct mpcc *insert_above_mpcc,
0264             int dpp_id,
0265             int mpcc_id);
0266 
0267     /*
0268      * Remove a specified DPP from the 'secondary' MPC tree.
0269      *
0270      * Parameters:
0271      * [in/out] mpc     - MPC context.
0272      * [in/out] tree    - MPC tree structure that plane will be removed from.
0273      * [in]     mpcc    - MPCC to be removed from tree.
0274      * Return:  void
0275      */
0276     void (*remove_mpcc_from_secondary)(
0277             struct mpc *mpc,
0278             struct mpc_tree *tree,
0279             struct mpcc *mpcc);
0280 
0281     struct mpcc* (*get_mpcc_for_dpp_from_secondary)(
0282             struct mpc_tree *tree,
0283             int dpp_id);
0284 
0285     struct mpcc* (*get_mpcc_for_dpp)(
0286             struct mpc_tree *tree,
0287             int dpp_id);
0288 
0289     void (*wait_for_idle)(struct mpc *mpc, int id);
0290 
0291     void (*assert_mpcc_idle_before_connect)(struct mpc *mpc, int mpcc_id);
0292 
0293     void (*init_mpcc_list_from_hw)(
0294         struct mpc *mpc,
0295         struct mpc_tree *tree);
0296 
0297     void (*set_denorm)(struct mpc *mpc,
0298             int opp_id,
0299             enum dc_color_depth output_depth);
0300 
0301     void (*set_denorm_clamp)(
0302             struct mpc *mpc,
0303             int opp_id,
0304             struct mpc_denorm_clamp denorm_clamp);
0305 
0306     void (*set_output_csc)(struct mpc *mpc,
0307             int opp_id,
0308             const uint16_t *regval,
0309             enum mpc_output_csc_mode ocsc_mode);
0310 
0311     void (*set_ocsc_default)(struct mpc *mpc,
0312             int opp_id,
0313             enum dc_color_space color_space,
0314             enum mpc_output_csc_mode ocsc_mode);
0315 
0316     void (*set_output_gamma)(
0317             struct mpc *mpc,
0318             int mpcc_id,
0319             const struct pwl_params *params);
0320     void (*power_on_mpc_mem_pwr)(
0321             struct mpc *mpc,
0322             int mpcc_id,
0323             bool power_on);
0324     void (*set_dwb_mux)(
0325             struct mpc *mpc,
0326             int dwb_id,
0327             int mpcc_id);
0328 
0329     void (*disable_dwb_mux)(
0330         struct mpc *mpc,
0331         int dwb_id);
0332 
0333     bool (*is_dwb_idle)(
0334         struct mpc *mpc,
0335         int dwb_id);
0336 
0337     void (*set_out_rate_control)(
0338         struct mpc *mpc,
0339         int opp_id,
0340         bool enable,
0341         bool rate_2x_mode,
0342         struct mpc_dwb_flow_control *flow_control);
0343 
0344     void (*set_gamut_remap)(
0345             struct mpc *mpc,
0346             int mpcc_id,
0347             const struct mpc_grph_gamut_adjustment *adjust);
0348 
0349     bool (*program_1dlut)(
0350             struct mpc *mpc,
0351             const struct pwl_params *params,
0352             uint32_t rmu_idx);
0353 
0354     bool (*program_shaper)(
0355             struct mpc *mpc,
0356             const struct pwl_params *params,
0357             uint32_t rmu_idx);
0358 
0359     uint32_t (*acquire_rmu)(struct mpc *mpc, int mpcc_id, int rmu_idx);
0360 
0361     bool (*program_3dlut)(
0362             struct mpc *mpc,
0363             const struct tetrahedral_params *params,
0364             int rmu_idx);
0365 
0366     int (*release_rmu)(struct mpc *mpc, int mpcc_id);
0367 
0368     unsigned int (*get_mpc_out_mux)(
0369             struct mpc *mpc,
0370             int opp_id);
0371 
0372     void (*set_bg_color)(struct mpc *mpc,
0373             struct tg_color *bg_color,
0374             int mpcc_id);
0375     void (*set_mpc_mem_lp_mode)(struct mpc *mpc);
0376 };
0377 
0378 #endif