hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
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;
....@@ -227,8 +221,7 @@
227221 {
228222 struct mdp5_plane_state *pstate = to_mdp5_plane_state(state);
229223
230
- if (state->fb)
231
- drm_framebuffer_unreference(state->fb);
224
+ __drm_atomic_helper_plane_destroy_state(state);
232225
233226 kfree(pstate);
234227 }
....@@ -399,12 +392,24 @@
399392 mdp5_state->r_hwpipe = NULL;
400393
401394
402
- mdp5_pipe_release(state->state, old_hwpipe);
403
- mdp5_pipe_release(state->state, old_right_hwpipe);
395
+ ret = mdp5_pipe_release(state->state, old_hwpipe);
396
+ if (ret)
397
+ return ret;
398
+
399
+ ret = mdp5_pipe_release(state->state, old_right_hwpipe);
400
+ if (ret)
401
+ return ret;
402
+
404403 }
405404 } else {
406
- mdp5_pipe_release(state->state, mdp5_state->hwpipe);
407
- mdp5_pipe_release(state->state, mdp5_state->r_hwpipe);
405
+ ret = mdp5_pipe_release(state->state, mdp5_state->hwpipe);
406
+ if (ret)
407
+ return ret;
408
+
409
+ ret = mdp5_pipe_release(state->state, mdp5_state->r_hwpipe);
410
+ if (ret)
411
+ return ret;
412
+
408413 mdp5_state->hwpipe = mdp5_state->r_hwpipe = NULL;
409414 }
410415
....@@ -655,23 +660,21 @@
655660 uint32_t pixel_format, uint32_t src, uint32_t dest,
656661 uint32_t phasex_steps[COMP_MAX])
657662 {
663
+ const struct drm_format_info *info = drm_format_info(pixel_format);
658664 struct mdp5_kms *mdp5_kms = get_kms(plane);
659665 struct device *dev = mdp5_kms->dev->dev;
660666 uint32_t phasex_step;
661
- unsigned int hsub;
662667 int ret;
663668
664669 ret = calc_phase_step(src, dest, &phasex_step);
665670 if (ret) {
666
- dev_err(dev, "X scaling (%d->%d) failed: %d\n", src, dest, ret);
671
+ DRM_DEV_ERROR(dev, "X scaling (%d->%d) failed: %d\n", src, dest, ret);
667672 return ret;
668673 }
669674
670
- hsub = drm_format_horz_chroma_subsampling(pixel_format);
671
-
672675 phasex_steps[COMP_0] = phasex_step;
673676 phasex_steps[COMP_3] = phasex_step;
674
- phasex_steps[COMP_1_2] = phasex_step / hsub;
677
+ phasex_steps[COMP_1_2] = phasex_step / info->hsub;
675678
676679 return 0;
677680 }
....@@ -680,23 +683,21 @@
680683 uint32_t pixel_format, uint32_t src, uint32_t dest,
681684 uint32_t phasey_steps[COMP_MAX])
682685 {
686
+ const struct drm_format_info *info = drm_format_info(pixel_format);
683687 struct mdp5_kms *mdp5_kms = get_kms(plane);
684688 struct device *dev = mdp5_kms->dev->dev;
685689 uint32_t phasey_step;
686
- unsigned int vsub;
687690 int ret;
688691
689692 ret = calc_phase_step(src, dest, &phasey_step);
690693 if (ret) {
691
- dev_err(dev, "Y scaling (%d->%d) failed: %d\n", src, dest, ret);
694
+ DRM_DEV_ERROR(dev, "Y scaling (%d->%d) failed: %d\n", src, dest, ret);
692695 return ret;
693696 }
694697
695
- vsub = drm_format_vert_chroma_subsampling(pixel_format);
696
-
697698 phasey_steps[COMP_0] = phasey_step;
698699 phasey_steps[COMP_3] = phasey_step;
699
- phasey_steps[COMP_1_2] = phasey_step / vsub;
700
+ phasey_steps[COMP_1_2] = phasey_step / info->vsub;
700701
701702 return 0;
702703 }
....@@ -704,8 +705,9 @@
704705 static uint32_t get_scale_config(const struct mdp_format *format,
705706 uint32_t src, uint32_t dst, bool horz)
706707 {
708
+ const struct drm_format_info *info = drm_format_info(format->base.pixel_format);
707709 bool scaling = format->is_yuv ? true : (src != dst);
708
- uint32_t sub, pix_fmt = format->base.pixel_format;
710
+ uint32_t sub;
709711 uint32_t ya_filter, uv_filter;
710712 bool yuv = format->is_yuv;
711713
....@@ -713,8 +715,7 @@
713715 return 0;
714716
715717 if (yuv) {
716
- sub = horz ? drm_format_horz_chroma_subsampling(pix_fmt) :
717
- drm_format_vert_chroma_subsampling(pix_fmt);
718
+ sub = horz ? info->hsub : info->vsub;
718719 uv_filter = ((src / sub) <= dst) ?
719720 SCALE_FILTER_BIL : SCALE_FILTER_PCMN;
720721 }
....@@ -759,7 +760,7 @@
759760 uint32_t src_w, int pe_left[COMP_MAX], int pe_right[COMP_MAX],
760761 uint32_t src_h, int pe_top[COMP_MAX], int pe_bottom[COMP_MAX])
761762 {
762
- uint32_t pix_fmt = format->base.pixel_format;
763
+ const struct drm_format_info *info = drm_format_info(format->base.pixel_format);
763764 uint32_t lr, tb, req;
764765 int i;
765766
....@@ -768,8 +769,8 @@
768769 uint32_t roi_h = src_h;
769770
770771 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);
772
+ roi_w /= info->hsub;
773
+ roi_h /= info->vsub;
773774 }
774775
775776 lr = (pe_left[i] >= 0) ?
....@@ -1104,6 +1105,8 @@
11041105
11051106 mdp5_plane_install_properties(plane, &plane->base);
11061107
1108
+ drm_plane_enable_fb_damage_clips(plane);
1109
+
11071110 return plane;
11081111
11091112 fail: