forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/gpu/drm/gma500/gma_display.c
....@@ -1,30 +1,24 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright © 2006-2011 Intel Corporation
3
- *
4
- * This program is free software; you can redistribute it and/or modify it
5
- * under the terms and conditions of the GNU General Public License,
6
- * version 2, as published by the Free Software Foundation.
7
- *
8
- * This program is distributed in the hope it will be useful, but WITHOUT
9
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11
- * more details.
12
- *
13
- * You should have received a copy of the GNU General Public License along with
14
- * this program; if not, write to the Free Software Foundation, Inc.,
15
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
164 *
175 * Authors:
186 * Eric Anholt <eric@anholt.net>
197 * Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
208 */
219
22
-#include <drm/drmP.h>
10
+#include <linux/delay.h>
11
+#include <linux/highmem.h>
12
+
13
+#include <drm/drm_crtc.h>
14
+#include <drm/drm_fourcc.h>
15
+#include <drm/drm_vblank.h>
16
+
17
+#include "framebuffer.h"
2318 #include "gma_display.h"
19
+#include "psb_drv.h"
2420 #include "psb_intel_drv.h"
2521 #include "psb_intel_reg.h"
26
-#include "psb_drv.h"
27
-#include "framebuffer.h"
2822
2923 /**
3024 * Returns whether any output on the specified pipe is of the specified type
....@@ -261,6 +255,8 @@
261255 /* Give the overlay scaler a chance to enable
262256 * if it's on this pipe */
263257 /* psb_intel_crtc_dpms_video(crtc, true); TODO */
258
+
259
+ drm_crtc_vblank_on(crtc);
264260 break;
265261 case DRM_MODE_DPMS_OFF:
266262 if (!gma_crtc->active)
....@@ -355,7 +351,7 @@
355351 gt = container_of(gma_crtc->cursor_obj,
356352 struct gtt_range, gem);
357353 psb_gtt_unpin(gt);
358
- drm_gem_object_put_unlocked(gma_crtc->cursor_obj);
354
+ drm_gem_object_put(gma_crtc->cursor_obj);
359355 gma_crtc->cursor_obj = NULL;
360356 }
361357 return 0;
....@@ -431,7 +427,7 @@
431427 if (gma_crtc->cursor_obj) {
432428 gt = container_of(gma_crtc->cursor_obj, struct gtt_range, gem);
433429 psb_gtt_unpin(gt);
434
- drm_gem_object_put_unlocked(gma_crtc->cursor_obj);
430
+ drm_gem_object_put(gma_crtc->cursor_obj);
435431 }
436432
437433 gma_crtc->cursor_obj = obj;
....@@ -439,7 +435,7 @@
439435 return ret;
440436
441437 unref_cursor:
442
- drm_gem_object_put_unlocked(obj);
438
+ drm_gem_object_put(obj);
443439 return ret;
444440 }
445441
....@@ -507,6 +503,55 @@
507503 kfree(gma_crtc);
508504 }
509505
506
+int gma_crtc_page_flip(struct drm_crtc *crtc,
507
+ struct drm_framebuffer *fb,
508
+ struct drm_pending_vblank_event *event,
509
+ uint32_t page_flip_flags,
510
+ struct drm_modeset_acquire_ctx *ctx)
511
+{
512
+ struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
513
+ struct drm_framebuffer *current_fb = crtc->primary->fb;
514
+ struct drm_framebuffer *old_fb = crtc->primary->old_fb;
515
+ const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
516
+ struct drm_device *dev = crtc->dev;
517
+ unsigned long flags;
518
+ int ret;
519
+
520
+ if (!crtc_funcs->mode_set_base)
521
+ return -EINVAL;
522
+
523
+ /* Using mode_set_base requires the new fb to be set already. */
524
+ crtc->primary->fb = fb;
525
+
526
+ if (event) {
527
+ spin_lock_irqsave(&dev->event_lock, flags);
528
+
529
+ WARN_ON(drm_crtc_vblank_get(crtc) != 0);
530
+
531
+ gma_crtc->page_flip_event = event;
532
+ spin_unlock_irqrestore(&dev->event_lock, flags);
533
+
534
+ /* Call this locked if we want an event at vblank interrupt. */
535
+ ret = crtc_funcs->mode_set_base(crtc, crtc->x, crtc->y, old_fb);
536
+ if (ret) {
537
+ spin_lock_irqsave(&dev->event_lock, flags);
538
+ if (gma_crtc->page_flip_event) {
539
+ gma_crtc->page_flip_event = NULL;
540
+ drm_crtc_vblank_put(crtc);
541
+ }
542
+ spin_unlock_irqrestore(&dev->event_lock, flags);
543
+ }
544
+ } else {
545
+ ret = crtc_funcs->mode_set_base(crtc, crtc->x, crtc->y, old_fb);
546
+ }
547
+
548
+ /* Restore previous fb in case of failure. */
549
+ if (ret)
550
+ crtc->primary->fb = current_fb;
551
+
552
+ return ret;
553
+}
554
+
510555 int gma_crtc_set_config(struct drm_mode_set *set,
511556 struct drm_modeset_acquire_ctx *ctx)
512557 {