GNU Linux-libre 4.14.266-gnu1
[releases.git] / drivers / gpu / drm / rcar-du / rcar_du_crtc.h
1 /*
2  * rcar_du_crtc.h  --  R-Car Display Unit CRTCs
3  *
4  * Copyright (C) 2013-2015 Renesas Electronics Corporation
5  *
6  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  */
13
14 #ifndef __RCAR_DU_CRTC_H__
15 #define __RCAR_DU_CRTC_H__
16
17 #include <linux/mutex.h>
18 #include <linux/spinlock.h>
19 #include <linux/wait.h>
20
21 #include <drm/drmP.h>
22 #include <drm/drm_crtc.h>
23
24 struct rcar_du_group;
25 struct rcar_du_vsp;
26
27 /**
28  * struct rcar_du_crtc - the CRTC, representing a DU superposition processor
29  * @crtc: base DRM CRTC
30  * @clock: the CRTC functional clock
31  * @extclock: external pixel dot clock (optional)
32  * @mmio_offset: offset of the CRTC registers in the DU MMIO block
33  * @index: CRTC software and hardware index
34  * @initialized: whether the CRTC has been initialized and clocks enabled
35  * @vblank_enable: whether vblank events are enabled on this CRTC
36  * @event: event to post when the pending page flip completes
37  * @flip_wait: wait queue used to signal page flip completion
38  * @vblank_lock: protects vblank_wait and vblank_count
39  * @vblank_wait: wait queue used to signal vertical blanking
40  * @vblank_count: number of vertical blanking interrupts to wait for
41  * @outputs: bitmask of the outputs (enum rcar_du_output) driven by this CRTC
42  * @group: CRTC group this CRTC belongs to
43  * @vsp: VSP feeding video to this CRTC
44  * @vsp_pipe: index of the VSP pipeline feeding video to this CRTC
45  */
46 struct rcar_du_crtc {
47         struct drm_crtc crtc;
48
49         struct clk *clock;
50         struct clk *extclock;
51         unsigned int mmio_offset;
52         unsigned int index;
53         bool initialized;
54
55         bool vblank_enable;
56         struct drm_pending_vblank_event *event;
57         wait_queue_head_t flip_wait;
58
59         spinlock_t vblank_lock;
60         wait_queue_head_t vblank_wait;
61         unsigned int vblank_count;
62
63         unsigned int outputs;
64
65         struct rcar_du_group *group;
66         struct rcar_du_vsp *vsp;
67         unsigned int vsp_pipe;
68 };
69
70 #define to_rcar_crtc(c) container_of(c, struct rcar_du_crtc, crtc)
71
72 enum rcar_du_output {
73         RCAR_DU_OUTPUT_DPAD0,
74         RCAR_DU_OUTPUT_DPAD1,
75         RCAR_DU_OUTPUT_LVDS0,
76         RCAR_DU_OUTPUT_LVDS1,
77         RCAR_DU_OUTPUT_HDMI0,
78         RCAR_DU_OUTPUT_HDMI1,
79         RCAR_DU_OUTPUT_TCON,
80         RCAR_DU_OUTPUT_MAX,
81 };
82
83 int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int index);
84 void rcar_du_crtc_suspend(struct rcar_du_crtc *rcrtc);
85 void rcar_du_crtc_resume(struct rcar_du_crtc *rcrtc);
86
87 void rcar_du_crtc_route_output(struct drm_crtc *crtc,
88                                enum rcar_du_output output);
89 void rcar_du_crtc_finish_page_flip(struct rcar_du_crtc *rcrtc);
90
91 #endif /* __RCAR_DU_CRTC_H__ */