/* * Copyright 2016 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * Authors: AMD * */ #include "dm_services.h" #include "core_types.h" #include "reg_helper.h" #include "dcn401/dcn401_dpp.h" #include "basics/conversion.h" #define NUM_PHASES … #define HORZ_MAX_TAPS … #define VERT_MAX_TAPS … #define NUM_LEVELS … #define BLACK_OFFSET_RGB_Y … #define BLACK_OFFSET_CBCR … #define REG(reg) … #define CTX … #undef FN #define FN(reg_name, field_name) … enum dcn401_coef_filter_type_sel { … }; enum dscl_autocal_mode { … }; enum dscl_mode_sel { … }; static int dpp401_dscl_get_pixel_depth_val(enum lb_pixel_depth depth) { … } static bool dpp401_dscl_is_video_format(enum pixel_format format) { … } static bool dpp401_dscl_is_420_format(enum pixel_format format) { … } static enum dscl_mode_sel dpp401_dscl_get_dscl_mode( struct dpp *dpp_base, const struct scaler_data *data, bool dbg_always_scale) { … } static void dpp401_power_on_dscl( struct dpp *dpp_base, bool power_on) { … } static void dpp401_dscl_set_lb( struct dcn401_dpp *dpp, const struct line_buffer_params *lb_params, enum lb_memory_config mem_size_config) { … } static const uint16_t *dpp401_dscl_get_filter_coeffs_64p(int taps, struct fixed31_32 ratio) { … } static void dpp401_dscl_set_scaler_filter( struct dcn401_dpp *dpp, uint32_t taps, enum dcn401_coef_filter_type_sel filter_type, const uint16_t *filter) { … } static void dpp401_dscl_set_scl_filter( struct dcn401_dpp *dpp, const struct scaler_data *scl_data, bool chroma_coef_mode) { … } // TODO: Fix defined but not used error //static int dpp401_dscl_get_lb_depth_bpc(enum lb_pixel_depth depth) //{ // if (depth == LB_PIXEL_DEPTH_30BPP) // return 10; // else if (depth == LB_PIXEL_DEPTH_24BPP) // return 8; // else if (depth == LB_PIXEL_DEPTH_18BPP) // return 6; // else if (depth == LB_PIXEL_DEPTH_36BPP) // return 12; // else { // BREAK_TO_DEBUGGER(); // return -1; /* Unsupported */ // } //} // TODO: Fix defined but not used error //void dpp401_dscl_calc_lb_num_partitions( // const struct scaler_data *scl_data, // enum lb_memory_config lb_config, // int *num_part_y, // int *num_part_c) //{ // int lb_memory_size, lb_memory_size_c, lb_memory_size_a, num_partitions_a, // lb_bpc, memory_line_size_y, memory_line_size_c, memory_line_size_a; // // int line_size = scl_data->viewport.width < scl_data->recout.width ? // scl_data->viewport.width : scl_data->recout.width; // int line_size_c = scl_data->viewport_c.width < scl_data->recout.width ? // scl_data->viewport_c.width : scl_data->recout.width; // // if (line_size == 0) // line_size = 1; // // if (line_size_c == 0) // line_size_c = 1; // // // lb_bpc = dpp401_dscl_get_lb_depth_bpc(scl_data->lb_params.depth); // memory_line_size_y = (line_size * lb_bpc + 71) / 72; /* +71 to ceil */ // memory_line_size_c = (line_size_c * lb_bpc + 71) / 72; /* +71 to ceil */ // memory_line_size_a = (line_size + 5) / 6; /* +5 to ceil */ // // if (lb_config == LB_MEMORY_CONFIG_1) { // lb_memory_size = 816; // lb_memory_size_c = 816; // lb_memory_size_a = 984; // } else if (lb_config == LB_MEMORY_CONFIG_2) { // lb_memory_size = 1088; // lb_memory_size_c = 1088; // lb_memory_size_a = 1312; // } else if (lb_config == LB_MEMORY_CONFIG_3) { // /* 420 mode: using 3rd mem from Y, Cr and Cb */ // lb_memory_size = 816 + 1088 + 848 + 848 + 848; // lb_memory_size_c = 816 + 1088; // lb_memory_size_a = 984 + 1312 + 456; // } else { // lb_memory_size = 816 + 1088 + 848; // lb_memory_size_c = 816 + 1088 + 848; // lb_memory_size_a = 984 + 1312 + 456; // } // *num_part_y = lb_memory_size / memory_line_size_y; // *num_part_c = lb_memory_size_c / memory_line_size_c; // num_partitions_a = lb_memory_size_a / memory_line_size_a; // // if (scl_data->lb_params.alpha_en // && (num_partitions_a < *num_part_y)) // *num_part_y = num_partitions_a; // // if (*num_part_y > 64) // *num_part_y = 64; // if (*num_part_c > 64) // *num_part_c = 64; // //} static bool dpp401_dscl_is_lb_conf_valid(int ceil_vratio, int num_partitions, int vtaps) { … } /*find first match configuration which meets the min required lb size*/ static enum lb_memory_config dpp401_dscl_find_lb_memory_config(struct dcn401_dpp *dpp, const struct scaler_data *scl_data) { … } static void dpp401_dscl_set_manual_ratio_init( struct dcn401_dpp *dpp, const struct scaler_data *data) { … } /** * dpp401_dscl_set_recout - Set the first pixel of RECOUT in the OTG active area * * @dpp: DPP data struct * @recout: Rectangle information * * This function sets the MPC RECOUT_START and RECOUT_SIZE registers based on * the values specified in the recount parameter. * * Note: This function only have effect if AutoCal is disabled. */ static void dpp401_dscl_set_recout(struct dcn401_dpp *dpp, const struct rect *recout) { … } /** * dpp401_dscl_program_easf - Program EASF * * @dpp_base: High level DPP struct * @scl_data: scalaer_data info * * This is the primary function to program EASF * */ static void dpp401_dscl_program_easf(struct dpp *dpp_base, const struct scaler_data *scl_data) { … } /** * dpp401_dscl_disable_easf - Disable EASF when no scaling (1:1) * * @dpp_base: High level DPP struct * @scl_data: scalaer_data info * * When we have 1:1 scaling, we need to disable EASF * */ static void dpp401_dscl_disable_easf(struct dpp *dpp_base, const struct scaler_data *scl_data) { … } static void dpp401_dscl_set_isharp_filter( struct dcn401_dpp *dpp, const uint32_t *filter) { … } // dpp401_dscl_set_isharp_filter /** * dpp401_dscl_program_isharp - Program isharp * * @dpp_base: High level DPP struct * @scl_data: scalaer_data info * * This is the primary function to program isharp * */ static void dpp401_dscl_program_isharp(struct dpp *dpp_base, const struct scaler_data *scl_data) { … } // dpp401_dscl_program_isharp /** * dpp401_dscl_set_scaler_manual_scale - Manually program scaler and line buffer * * @dpp_base: High level DPP struct * @scl_data: scalaer_data info * * This is the primary function to program scaler and line buffer in manual * scaling mode. To execute the required operations for manual scale, we need * to disable AutoCal first. */ void dpp401_dscl_set_scaler_manual_scale(struct dpp *dpp_base, const struct scaler_data *scl_data) { … }