summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/imx/dpu/dpu-crtc.h
blob: 423fe1339cf278a5961cd5236ccd2f531203a9d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
 * Copyright 2017-2020 NXP
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 */

#ifndef _DPU_CRTC_H_
#define _DPU_CRTC_H_

#include <drm/drm_vblank.h>
#include <video/dpu.h>
#include "dpu-plane.h"
#include "../imx-drm.h"

struct dpu_crtc {
	struct device		*dev;
	struct drm_crtc		base;
	struct imx_drm_crtc	*imx_crtc;
	struct dpu_constframe	*pa_cf;
	struct dpu_constframe	*sa_cf;
	struct dpu_disengcfg	*dec;
	struct dpu_extdst	*ed;
	struct dpu_framegen	*fg;
	struct dpu_signature	*sig;
	struct dpu_tcon		*tcon;
	struct dpu_store	*st;
	struct dpu_constframe	*aux_pa_cf;
	struct dpu_constframe	*aux_sa_cf;
	struct dpu_disengcfg	*aux_dec;
	struct dpu_extdst	*aux_ed;
	struct dpu_framegen	*aux_fg;
	struct dpu_signature	*aux_sig;
	struct dpu_tcon		*aux_tcon;
	/* master */
	struct dpu_constframe	*m_pa_cf;
	struct dpu_constframe	*m_sa_cf;
	struct dpu_disengcfg	*m_dec;
	struct dpu_extdst	*m_ed;
	struct dpu_framegen	*m_fg;
	struct dpu_tcon		*m_tcon;
	/* slave */
	struct dpu_constframe	*s_pa_cf;
	struct dpu_constframe	*s_sa_cf;
	struct dpu_disengcfg	*s_dec;
	struct dpu_extdst	*s_ed;
	struct dpu_framegen	*s_fg;
	struct dpu_tcon		*s_tcon;
	struct dpu_plane	**plane;
	unsigned int		hw_plane_num;
	unsigned int		stream_id;
	unsigned int		crtc_grp_id;
	unsigned int		syncmode_min_prate;
	unsigned int		singlemode_max_width;
	unsigned int		master_stream_id;
	int			vbl_irq;
	int			safety_shdld_irq;
	int			content_shdld_irq;
	int			dec_shdld_irq;
	int			crc_valid_irq;
	int			crc_shdld_irq;

	bool			aux_is_master;
	bool			use_dual_crc;
	bool			crc_is_enabled;

	struct completion	safety_shdld_done;
	struct completion	content_shdld_done;
	struct completion	dec_shdld_done;
	struct completion	crc_shdld_done;
	struct completion	aux_crc_done;

	struct drm_pending_vblank_event *event;

	u32			crc_red;
	u32			crc_green;
	u32			crc_blue;
	u32			dual_crc_flag;
};

struct dpu_crc {
	enum dpu_crc_source	source;
	struct drm_rect		roi;
};

struct dpu_crtc_state {
	struct imx_crtc_state	imx_crtc_state;
	struct dpu_plane_state	**dpu_plane_states;
	struct dpu_crc		crc;
	bool			use_pc;
};

static inline struct dpu_crtc_state *to_dpu_crtc_state(struct imx_crtc_state *s)
{
	return container_of(s, struct dpu_crtc_state, imx_crtc_state);
}

static inline struct dpu_crtc *to_dpu_crtc(struct drm_crtc *crtc)
{
	return container_of(crtc, struct dpu_crtc, base);
}

struct dpu_plane_state **
crtc_state_get_dpu_plane_states(struct drm_crtc_state *state);

struct dpu_crtc *dpu_crtc_get_aux_dpu_crtc(struct dpu_crtc *dpu_crtc);

#endif