Message ID | 20230506123549.101727-5-angelogioacchino.delregno@collabora.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | MediaTek DDP GAMMA - 12-bit LUT support | expand |
Hi AngeloGioacchino, kernel test robot noticed the following build warnings: [auto build test WARNING on drm-misc/drm-misc-next] [cannot apply to pza/imx-drm/next mbgg-mediatek/for-next] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/AngeloGioacchino-Del-Regno/drm-mediatek-gamma-Adjust-mtk_drm_gamma_set_common-parameters/20230506-203713 base: git://anongit.freedesktop.org/drm/drm-misc drm-misc-next patch link: https://lore.kernel.org/r/20230506123549.101727-5-angelogioacchino.delregno%40collabora.com patch subject: [PATCH v3 04/11] drm/mediatek: gamma: Improve and simplify HW LUT calculation config: arm-allmodconfig (https://download.01.org/0day-ci/archive/20230506/202305062349.SFNFiiWv-lkp@intel.com/config) compiler: arm-linux-gnueabi-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/a933258d0ee5c49d54f70fe11d3b1d719d5b6087 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review AngeloGioacchino-Del-Regno/drm-mediatek-gamma-Adjust-mtk_drm_gamma_set_common-parameters/20230506-203713 git checkout a933258d0ee5c49d54f70fe11d3b1d719d5b6087 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/gpu/drm/mediatek/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> | Link: https://lore.kernel.org/oe-kbuild-all/202305062349.SFNFiiWv-lkp@intel.com/ All warnings (new ones prefixed by >>): drivers/gpu/drm/mediatek/mtk_disp_gamma.c: In function 'mtk_gamma_set_common': >> drivers/gpu/drm/mediatek/mtk_disp_gamma.c:106:48: warning: suggest parentheses around '+' inside '<<' [-Wparentheses] 106 | word = hwlut.red << 20 + | ~~~^ 107 | hwlut.green << 10 + | ~~~~~~~~~~~ drivers/gpu/drm/mediatek/mtk_disp_gamma.c:107:50: warning: suggest parentheses around '+' inside '<<' [-Wparentheses] 107 | hwlut.green << 10 + | ~~~^ 108 | hwlut.red; | ~~~~~~~~~ drivers/gpu/drm/mediatek/mtk_disp_gamma.c:119:48: warning: suggest parentheses around '+' inside '<<' [-Wparentheses] 119 | word = diff.blue << 20 + | ~~~^ 120 | diff.green << 10 + | ~~~~~~~~~~ drivers/gpu/drm/mediatek/mtk_disp_gamma.c:120:49: warning: suggest parentheses around '+' inside '<<' [-Wparentheses] 120 | diff.green << 10 + | ~~~^ 121 | diff.red; | ~~~~~~~~ vim +106 drivers/gpu/drm/mediatek/mtk_disp_gamma.c 70 71 void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crtc_state *state) 72 { 73 struct mtk_disp_gamma *gamma = dev_get_drvdata(dev); 74 unsigned int i, reg; 75 struct drm_color_lut *lut; 76 void __iomem *lut_base; 77 bool lut_diff; 78 u16 lut_size; 79 u32 word; 80 81 /* If there's no gamma lut there's nothing to do here. */ 82 if (!state->gamma_lut) 83 return; 84 85 if (gamma && gamma->data) { 86 lut_diff = gamma->data->lut_diff; 87 lut_size = gamma->data->lut_size; 88 } else { 89 lut_diff = false; 90 lut_size = LUT_SIZE_DEFAULT; 91 } 92 93 reg = readl(regs + DISP_GAMMA_CFG); 94 reg = reg | GAMMA_LUT_EN; 95 writel(reg, regs + DISP_GAMMA_CFG); 96 lut_base = regs + DISP_GAMMA_LUT; 97 lut = (struct drm_color_lut *)state->gamma_lut->data; 98 for (i = 0; i < lut_size; i++) { 99 struct drm_color_lut diff, hwlut; 100 101 hwlut.red = drm_color_lut_extract(lut[i].red, 10); 102 hwlut.green = drm_color_lut_extract(lut[i].green, 10); 103 hwlut.blue = drm_color_lut_extract(lut[i].blue, 10); 104 105 if (!lut_diff || (i % 2 == 0)) { > 106 word = hwlut.red << 20 + 107 hwlut.green << 10 + 108 hwlut.red; 109 } else { 110 diff.red = lut[i].red - lut[i - 1].red; 111 diff.red = drm_color_lut_extract(diff.red, 10); 112 113 diff.green = lut[i].green - lut[i - 1].green; 114 diff.green = drm_color_lut_extract(diff.green, 10); 115 116 diff.blue = lut[i].blue - lut[i - 1].blue; 117 diff.blue = drm_color_lut_extract(diff.blue, 10); 118 119 word = diff.blue << 20 + 120 diff.green << 10 + 121 diff.red; 122 } 123 writel(word, (lut_base + i * 4)); 124 } 125 } 126
diff --git a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c index d194d9bc2e2b..60ccea8c1e1a 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c @@ -77,7 +77,6 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt bool lut_diff; u16 lut_size; u32 word; - u32 diff[3] = {0}; /* If there's no gamma lut there's nothing to do here. */ if (!state->gamma_lut) @@ -97,18 +96,29 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt lut_base = regs + DISP_GAMMA_LUT; lut = (struct drm_color_lut *)state->gamma_lut->data; for (i = 0; i < lut_size; i++) { + struct drm_color_lut diff, hwlut; + + hwlut.red = drm_color_lut_extract(lut[i].red, 10); + hwlut.green = drm_color_lut_extract(lut[i].green, 10); + hwlut.blue = drm_color_lut_extract(lut[i].blue, 10); + if (!lut_diff || (i % 2 == 0)) { - word = (((lut[i].red >> 6) & LUT_10BIT_MASK) << 20) + - (((lut[i].green >> 6) & LUT_10BIT_MASK) << 10) + - ((lut[i].blue >> 6) & LUT_10BIT_MASK); + word = hwlut.red << 20 + + hwlut.green << 10 + + hwlut.red; } else { - diff[0] = (lut[i].red >> 6) - (lut[i - 1].red >> 6); - diff[1] = (lut[i].green >> 6) - (lut[i - 1].green >> 6); - diff[2] = (lut[i].blue >> 6) - (lut[i - 1].blue >> 6); + diff.red = lut[i].red - lut[i - 1].red; + diff.red = drm_color_lut_extract(diff.red, 10); + + diff.green = lut[i].green - lut[i - 1].green; + diff.green = drm_color_lut_extract(diff.green, 10); + + diff.blue = lut[i].blue - lut[i - 1].blue; + diff.blue = drm_color_lut_extract(diff.blue, 10); - word = ((diff[0] & LUT_10BIT_MASK) << 20) + - ((diff[1] & LUT_10BIT_MASK) << 10) + - (diff[2] & LUT_10BIT_MASK); + word = diff.blue << 20 + + diff.green << 10 + + diff.red; } writel(word, (lut_base + i * 4)); }
Use drm_color_lut_extract() to avoid open-coding the bits reduction calculations for each color channel and use a struct drm_color_lut to temporarily store the information instead of an array of u32. Also, slightly improve the precision of the HW LUT calculation in the LUT DIFF case by performing the subtractions on the 16-bits values and doing the 10 bits conversion later. Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> --- drivers/gpu/drm/mediatek/mtk_disp_gamma.c | 30 +++++++++++++++-------- 1 file changed, 20 insertions(+), 10 deletions(-)