forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 072de836f53be56a70cecf70b43ae43b7ce17376
kernel/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
....@@ -1,22 +1,14 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2014-2015 The Linux Foundation. All rights reserved.
34 * Copyright (C) 2013 Red Hat
45 * Author: Rob Clark <robdclark@gmail.com>
5
- *
6
- * This program is free software; you can redistribute it and/or modify it
7
- * under the terms of the GNU General Public License version 2 as published by
8
- * the Free Software Foundation.
9
- *
10
- * This program is distributed in the hope that it will be useful, but WITHOUT
11
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13
- * more details.
14
- *
15
- * You should have received a copy of the GNU General Public License along with
16
- * this program. If not, see <http://www.gnu.org/licenses/>.
176 */
187
8
+#include <drm/drm_damage_helper.h>
9
+#include <drm/drm_fourcc.h>
1910 #include <drm/drm_print.h>
11
+
2012 #include "mdp5_kms.h"
2113
2214 struct mdp5_plane {
....@@ -46,7 +38,6 @@
4638 {
4739 struct mdp5_plane *mdp5_plane = to_mdp5_plane(plane);
4840
49
- drm_plane_helper_disable(plane, NULL);
5041 drm_plane_cleanup(plane);
5142
5243 kfree(mdp5_plane);
....@@ -126,7 +117,7 @@
126117
127118 SET_PROPERTY(zpos, ZPOS, uint8_t);
128119
129
- dev_err(dev->dev, "Invalid property\n");
120
+ DRM_DEV_ERROR(dev->dev, "Invalid property\n");
130121 ret = -EINVAL;
131122 done:
132123 return ret;
....@@ -154,7 +145,7 @@
154145
155146 GET_PROPERTY(zpos, ZPOS, uint8_t);
156147
157
- dev_err(dev->dev, "Invalid property\n");
148
+ DRM_DEV_ERROR(dev->dev, "Invalid property\n");
158149 ret = -EINVAL;
159150 done:
160151 return ret;
....@@ -185,10 +176,13 @@
185176 struct mdp5_plane_state *mdp5_state;
186177
187178 if (plane->state && plane->state->fb)
188
- drm_framebuffer_unreference(plane->state->fb);
179
+ drm_framebuffer_put(plane->state->fb);
189180
190181 kfree(to_mdp5_plane_state(plane->state));
182
+ plane->state = NULL;
191183 mdp5_state = kzalloc(sizeof(*mdp5_state), GFP_KERNEL);
184
+ if (!mdp5_state)
185
+ return;
192186
193187 /* assign default blend parameters */
194188 mdp5_state->alpha = 255;
....@@ -228,7 +222,7 @@
228222 struct mdp5_plane_state *pstate = to_mdp5_plane_state(state);
229223
230224 if (state->fb)
231
- drm_framebuffer_unreference(state->fb);
225
+ drm_framebuffer_put(state->fb);
232226
233227 kfree(pstate);
234228 }
....@@ -399,12 +393,24 @@
399393 mdp5_state->r_hwpipe = NULL;
400394
401395
402
- mdp5_pipe_release(state->state, old_hwpipe);
403
- mdp5_pipe_release(state->state, old_right_hwpipe);
396
+ ret = mdp5_pipe_release(state->state, old_hwpipe);
397
+ if (ret)
398
+ return ret;
399
+
400
+ ret = mdp5_pipe_release(state->state, old_right_hwpipe);
401
+ if (ret)
402
+ return ret;
403
+
404404 }
405405 } else {
406
- mdp5_pipe_release(state->state, mdp5_state->hwpipe);
407
- mdp5_pipe_release(state->state, mdp5_state->r_hwpipe);
406
+ ret = mdp5_pipe_release(state->state, mdp5_state->hwpipe);
407
+ if (ret)
408
+ return ret;
409
+
410
+ ret = mdp5_pipe_release(state->state, mdp5_state->r_hwpipe);
411
+ if (ret)
412
+ return ret;
413
+
408414 mdp5_state->hwpipe = mdp5_state->r_hwpipe = NULL;
409415 }
410416
....@@ -655,23 +661,21 @@
655661 uint32_t pixel_format, uint32_t src, uint32_t dest,
656662 uint32_t phasex_steps[COMP_MAX])
657663 {
664
+ const struct drm_format_info *info = drm_format_info(pixel_format);
658665 struct mdp5_kms *mdp5_kms = get_kms(plane);
659666 struct device *dev = mdp5_kms->dev->dev;
660667 uint32_t phasex_step;
661
- unsigned int hsub;
662668 int ret;
663669
664670 ret = calc_phase_step(src, dest, &phasex_step);
665671 if (ret) {
666
- dev_err(dev, "X scaling (%d->%d) failed: %d\n", src, dest, ret);
672
+ DRM_DEV_ERROR(dev, "X scaling (%d->%d) failed: %d\n", src, dest, ret);
667673 return ret;
668674 }
669675
670
- hsub = drm_format_horz_chroma_subsampling(pixel_format);
671
-
672676 phasex_steps[COMP_0] = phasex_step;
673677 phasex_steps[COMP_3] = phasex_step;
674
- phasex_steps[COMP_1_2] = phasex_step / hsub;
678
+ phasex_steps[COMP_1_2] = phasex_step / info->hsub;
675679
676680 return 0;
677681 }
....@@ -680,23 +684,21 @@
680684 uint32_t pixel_format, uint32_t src, uint32_t dest,
681685 uint32_t phasey_steps[COMP_MAX])
682686 {
687
+ const struct drm_format_info *info = drm_format_info(pixel_format);
683688 struct mdp5_kms *mdp5_kms = get_kms(plane);
684689 struct device *dev = mdp5_kms->dev->dev;
685690 uint32_t phasey_step;
686
- unsigned int vsub;
687691 int ret;
688692
689693 ret = calc_phase_step(src, dest, &phasey_step);
690694 if (ret) {
691
- dev_err(dev, "Y scaling (%d->%d) failed: %d\n", src, dest, ret);
695
+ DRM_DEV_ERROR(dev, "Y scaling (%d->%d) failed: %d\n", src, dest, ret);
692696 return ret;
693697 }
694698
695
- vsub = drm_format_vert_chroma_subsampling(pixel_format);
696
-
697699 phasey_steps[COMP_0] = phasey_step;
698700 phasey_steps[COMP_3] = phasey_step;
699
- phasey_steps[COMP_1_2] = phasey_step / vsub;
701
+ phasey_steps[COMP_1_2] = phasey_step / info->vsub;
700702
701703 return 0;
702704 }
....@@ -704,8 +706,9 @@
704706 static uint32_t get_scale_config(const struct mdp_format *format,
705707 uint32_t src, uint32_t dst, bool horz)
706708 {
709
+ const struct drm_format_info *info = drm_format_info(format->base.pixel_format);
707710 bool scaling = format->is_yuv ? true : (src != dst);
708
- uint32_t sub, pix_fmt = format->base.pixel_format;
711
+ uint32_t sub;
709712 uint32_t ya_filter, uv_filter;
710713 bool yuv = format->is_yuv;
711714
....@@ -713,8 +716,7 @@
713716 return 0;
714717
715718 if (yuv) {
716
- sub = horz ? drm_format_horz_chroma_subsampling(pix_fmt) :
717
- drm_format_vert_chroma_subsampling(pix_fmt);
719
+ sub = horz ? info->hsub : info->vsub;
718720 uv_filter = ((src / sub) <= dst) ?
719721 SCALE_FILTER_BIL : SCALE_FILTER_PCMN;
720722 }
....@@ -759,7 +761,7 @@
759761 uint32_t src_w, int pe_left[COMP_MAX], int pe_right[COMP_MAX],
760762 uint32_t src_h, int pe_top[COMP_MAX], int pe_bottom[COMP_MAX])
761763 {
762
- uint32_t pix_fmt = format->base.pixel_format;
764
+ const struct drm_format_info *info = drm_format_info(format->base.pixel_format);
763765 uint32_t lr, tb, req;
764766 int i;
765767
....@@ -768,8 +770,8 @@
768770 uint32_t roi_h = src_h;
769771
770772 if (format->is_yuv && i == COMP_1_2) {
771
- roi_w /= drm_format_horz_chroma_subsampling(pix_fmt);
772
- roi_h /= drm_format_vert_chroma_subsampling(pix_fmt);
773
+ roi_w /= info->hsub;
774
+ roi_h /= info->vsub;
773775 }
774776
775777 lr = (pe_left[i] >= 0) ?
....@@ -1104,6 +1106,8 @@
11041106
11051107 mdp5_plane_install_properties(plane, &plane->base);
11061108
1109
+ drm_plane_enable_fb_damage_clips(plane);
1110
+
11071111 return plane;
11081112
11091113 fail: