65 lines · c
1 2/*3 * Copyright 2017 Advanced Micro Devices, Inc.4 *5 * Permission is hereby granted, free of charge, to any person obtaining a6 * copy of this software and associated documentation files (the "Software"),7 * to deal in the Software without restriction, including without limitation8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,9 * and/or sell copies of the Software, and to permit persons to whom the10 * Software is furnished to do so, subject to the following conditions:11 *12 * The above copyright notice and this permission notice shall be included in13 * all copies or substantial portions of the Software.14 *15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL18 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR21 * OTHER DEALINGS IN THE SOFTWARE.22 *23 * Authors: AMD24 *25 */26#include "rc_calc.h"27 28/**29 * calc_rc_params - reads the user's cmdline mode30 * @rc: DC internal DSC parameters31 * @pps: DRM struct with all required DSC values32 *33 * This function expects a drm_dsc_config data struct with all the required DSC34 * values previously filled out by our driver and based on this information it35 * computes some of the DSC values.36 *37 * @note This calculation requires float point operation, most of it executes38 * under kernel_fpu_{begin,end}.39 */40void calc_rc_params(struct rc_params *rc, const struct drm_dsc_config *pps)41{42#if defined(CONFIG_DRM_AMD_DC_FP)43 enum colour_mode mode;44 enum bits_per_comp bpc;45 bool is_navite_422_or_420;46 u16 drm_bpp = pps->bits_per_pixel;47 int slice_width = pps->slice_width;48 int slice_height = pps->slice_height;49 50 mode = pps->convert_rgb ? CM_RGB : (pps->simple_422 ? CM_444 :51 (pps->native_422 ? CM_422 :52 pps->native_420 ? CM_420 : CM_444));53 bpc = (pps->bits_per_component == 8) ? BPC_8 : (pps->bits_per_component == 10)54 ? BPC_10 : BPC_12;55 56 is_navite_422_or_420 = pps->native_422 || pps->native_420;57 58 DC_FP_START();59 _do_calc_rc_params(rc, mode, bpc, drm_bpp, is_navite_422_or_420,60 slice_width, slice_height,61 pps->dsc_version_minor);62 DC_FP_END();63#endif64}65