197bda032SHarry Wentland
297bda032SHarry Wentland /*
397bda032SHarry Wentland * Copyright 2017 Advanced Micro Devices, Inc.
497bda032SHarry Wentland *
597bda032SHarry Wentland * Permission is hereby granted, free of charge, to any person obtaining a
697bda032SHarry Wentland * copy of this software and associated documentation files (the "Software"),
797bda032SHarry Wentland * to deal in the Software without restriction, including without limitation
897bda032SHarry Wentland * the rights to use, copy, modify, merge, publish, distribute, sublicense,
997bda032SHarry Wentland * and/or sell copies of the Software, and to permit persons to whom the
1097bda032SHarry Wentland * Software is furnished to do so, subject to the following conditions:
1197bda032SHarry Wentland *
1297bda032SHarry Wentland * The above copyright notice and this permission notice shall be included in
1397bda032SHarry Wentland * all copies or substantial portions of the Software.
1497bda032SHarry Wentland *
1597bda032SHarry Wentland * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1697bda032SHarry Wentland * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1797bda032SHarry Wentland * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1897bda032SHarry Wentland * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
1997bda032SHarry Wentland * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
2097bda032SHarry Wentland * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2197bda032SHarry Wentland * OTHER DEALINGS IN THE SOFTWARE.
2297bda032SHarry Wentland *
2397bda032SHarry Wentland * Authors: AMD
2497bda032SHarry Wentland *
2597bda032SHarry Wentland */
2697bda032SHarry Wentland #include "rc_calc.h"
271e5d05ecSRodrigo Siqueira
281e5d05ecSRodrigo Siqueira /**
291e5d05ecSRodrigo Siqueira * calc_rc_params - reads the user's cmdline mode
301e5d05ecSRodrigo Siqueira * @rc: DC internal DSC parameters
311e5d05ecSRodrigo Siqueira * @pps: DRM struct with all required DSC values
321e5d05ecSRodrigo Siqueira *
331e5d05ecSRodrigo Siqueira * This function expects a drm_dsc_config data struct with all the required DSC
341e5d05ecSRodrigo Siqueira * values previously filled out by our driver and based on this information it
351e5d05ecSRodrigo Siqueira * computes some of the DSC values.
361e5d05ecSRodrigo Siqueira *
371e5d05ecSRodrigo Siqueira * @note This calculation requires float point operation, most of it executes
381e5d05ecSRodrigo Siqueira * under kernel_fpu_{begin,end}.
391e5d05ecSRodrigo Siqueira */
calc_rc_params(struct rc_params * rc,const struct drm_dsc_config * pps)401e5d05ecSRodrigo Siqueira void calc_rc_params(struct rc_params *rc, const struct drm_dsc_config *pps)
411e5d05ecSRodrigo Siqueira {
42*4652ae7aSHarry Wentland #if defined(CONFIG_DRM_AMD_DC_FP)
431e5d05ecSRodrigo Siqueira enum colour_mode mode;
441e5d05ecSRodrigo Siqueira enum bits_per_comp bpc;
451e5d05ecSRodrigo Siqueira bool is_navite_422_or_420;
46ca8e2084SNicholas Kazlauskas u16 drm_bpp = pps->bits_per_pixel;
471e5d05ecSRodrigo Siqueira int slice_width = pps->slice_width;
481e5d05ecSRodrigo Siqueira int slice_height = pps->slice_height;
491e5d05ecSRodrigo Siqueira
501e5d05ecSRodrigo Siqueira mode = pps->convert_rgb ? CM_RGB : (pps->simple_422 ? CM_444 :
511e5d05ecSRodrigo Siqueira (pps->native_422 ? CM_422 :
521e5d05ecSRodrigo Siqueira pps->native_420 ? CM_420 : CM_444));
531e5d05ecSRodrigo Siqueira bpc = (pps->bits_per_component == 8) ? BPC_8 : (pps->bits_per_component == 10)
541e5d05ecSRodrigo Siqueira ? BPC_10 : BPC_12;
551e5d05ecSRodrigo Siqueira
561e5d05ecSRodrigo Siqueira is_navite_422_or_420 = pps->native_422 || pps->native_420;
571e5d05ecSRodrigo Siqueira
581e5d05ecSRodrigo Siqueira DC_FP_START();
591e5d05ecSRodrigo Siqueira _do_calc_rc_params(rc, mode, bpc, drm_bpp, is_navite_422_or_420,
601e5d05ecSRodrigo Siqueira slice_width, slice_height,
611e5d05ecSRodrigo Siqueira pps->dsc_version_minor);
621e5d05ecSRodrigo Siqueira DC_FP_END();
6384c03df5SHarry Wentland #endif
641e5d05ecSRodrigo Siqueira }
65