forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/drivers/gpu/drm/gma500/psb_irq.c
....@@ -1,34 +1,21 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /**************************************************************************
23 * Copyright (c) 2007, Intel Corporation.
34 * All Rights Reserved.
4
- *
5
- * This program is free software; you can redistribute it and/or modify it
6
- * under the terms and conditions of the GNU General Public License,
7
- * version 2, as published by the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope it will be useful, but WITHOUT
10
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
- * more details.
13
- *
14
- * You should have received a copy of the GNU General Public License along with
15
- * this program; if not, write to the Free Software Foundation, Inc.,
16
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
175 *
186 * Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
197 * develop this driver.
208 *
219 **************************************************************************/
22
-/*
23
- */
2410
25
-#include <drm/drmP.h>
26
-#include "psb_drv.h"
27
-#include "psb_reg.h"
28
-#include "psb_intel_reg.h"
29
-#include "power.h"
30
-#include "psb_irq.h"
11
+#include <drm/drm_vblank.h>
12
+
3113 #include "mdfld_output.h"
14
+#include "power.h"
15
+#include "psb_drv.h"
16
+#include "psb_intel_reg.h"
17
+#include "psb_irq.h"
18
+#include "psb_reg.h"
3219
3320 /*
3421 * inline functions
....@@ -178,11 +165,23 @@
178165 "%s, can't clear status bits for pipe %d, its value = 0x%x.\n",
179166 __func__, pipe, PSB_RVDC32(pipe_stat_reg));
180167
181
- if (pipe_stat_val & PIPE_VBLANK_STATUS)
168
+ if (pipe_stat_val & PIPE_VBLANK_STATUS ||
169
+ (IS_MFLD(dev) && pipe_stat_val & PIPE_TE_STATUS)) {
170
+ struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
171
+ struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
172
+ unsigned long flags;
173
+
182174 drm_handle_vblank(dev, pipe);
183175
184
- if (pipe_stat_val & PIPE_TE_STATUS)
185
- drm_handle_vblank(dev, pipe);
176
+ spin_lock_irqsave(&dev->event_lock, flags);
177
+ if (gma_crtc->page_flip_event) {
178
+ drm_crtc_send_vblank_event(crtc,
179
+ gma_crtc->page_flip_event);
180
+ gma_crtc->page_flip_event = NULL;
181
+ drm_crtc_vblank_put(crtc);
182
+ }
183
+ spin_unlock_irqrestore(&dev->event_lock, flags);
184
+ }
186185 }
187186
188187 /*
....@@ -207,7 +206,6 @@
207206 {
208207 struct drm_psb_private *dev_priv = dev->dev_private;
209208 u32 val, addr;
210
- int error = false;
211209
212210 if (stat_1 & _PSB_CE_TWOD_COMPLETE)
213211 val = PSB_RSGX32(PSB_CR_2D_BLIT_STATUS);
....@@ -242,7 +240,6 @@
242240
243241 DRM_ERROR("\tMMU failing address is 0x%08x.\n",
244242 (unsigned int)addr);
245
- error = true;
246243 }
247244 }
248245
....@@ -463,12 +460,11 @@
463460 {
464461 struct drm_psb_private *dev_priv =
465462 (struct drm_psb_private *) dev->dev_private;
466
- u32 hist_reg;
467463 u32 pwm_reg;
468464
469465 if (gma_power_begin(dev, false)) {
470466 PSB_WVDC32(0x00000000, HISTOGRAM_INT_CONTROL);
471
- hist_reg = PSB_RVDC32(HISTOGRAM_INT_CONTROL);
467
+ PSB_RVDC32(HISTOGRAM_INT_CONTROL);
472468
473469 psb_disable_pipestat(dev_priv, 0, PIPE_DPST_EVENT_ENABLE);
474470
....@@ -500,8 +496,10 @@
500496 /*
501497 * It is used to enable VBLANK interrupt
502498 */
503
-int psb_enable_vblank(struct drm_device *dev, unsigned int pipe)
499
+int psb_enable_vblank(struct drm_crtc *crtc)
504500 {
501
+ struct drm_device *dev = crtc->dev;
502
+ unsigned int pipe = crtc->index;
505503 struct drm_psb_private *dev_priv = dev->dev_private;
506504 unsigned long irqflags;
507505 uint32_t reg_val = 0;
....@@ -539,8 +537,10 @@
539537 /*
540538 * It is used to disable VBLANK interrupt
541539 */
542
-void psb_disable_vblank(struct drm_device *dev, unsigned int pipe)
540
+void psb_disable_vblank(struct drm_crtc *crtc)
543541 {
542
+ struct drm_device *dev = crtc->dev;
543
+ unsigned int pipe = crtc->index;
544544 struct drm_psb_private *dev_priv = dev->dev_private;
545545 unsigned long irqflags;
546546
....@@ -612,8 +612,10 @@
612612 /* Called from drm generic code, passed a 'crtc', which
613613 * we use as a pipe index
614614 */
615
-u32 psb_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
615
+u32 psb_get_vblank_counter(struct drm_crtc *crtc)
616616 {
617
+ struct drm_device *dev = crtc->dev;
618
+ unsigned int pipe = crtc->index;
617619 uint32_t high_frame = PIPEAFRAMEHIGH;
618620 uint32_t low_frame = PIPEAFRAMEPIXEL;
619621 uint32_t pipeconf_reg = PIPEACONF;