summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/renesas/rz-du/rzg2l_du_crtc.h
blob: cbba38acc377e8402e6a276666ac220b195d8e5b (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
/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * RZ/G2L Display Unit CRTCs
 *
 * Copyright (C) 2023 Renesas Electronics Corporation
 *
 * Based on rcar_du_crtc.h
 */

#ifndef __RZG2L_DU_CRTC_H__
#define __RZG2L_DU_CRTC_H__

#include <linux/container_of.h>
#include <linux/mutex.h>
#include <linux/spinlock.h>
#include <linux/wait.h>

#include <drm/drm_crtc.h>
#include <drm/drm_writeback.h>

#include <media/vsp1.h>

struct clk;
struct reset_control;
struct rzg2l_du_vsp;
struct rzg2l_du_format_info;

/**
 * struct rzg2l_du_crtc - the CRTC, representing a DU superposition processor
 * @crtc: base DRM CRTC
 * @dev: the DU device
 * @initialized: whether the CRTC has been initialized and clocks enabled
 * @vblank_enable: whether vblank events are enabled on this CRTC
 * @event: event to post when the pending page flip completes
 * @flip_wait: wait queue used to signal page flip completion
 * @vsp: VSP feeding video to this CRTC
 * @vsp_pipe: index of the VSP pipeline feeding video to this CRTC
 * @rstc: reset controller
 * @rzg2l_clocks: the bus, main and video clock
 */
struct rzg2l_du_crtc {
	struct drm_crtc crtc;

	struct rzg2l_du_device *dev;
	bool initialized;

	bool vblank_enable;
	struct drm_pending_vblank_event *event;
	wait_queue_head_t flip_wait;

	struct rzg2l_du_vsp *vsp;
	unsigned int vsp_pipe;

	const char *const *sources;
	unsigned int sources_count;

	struct reset_control *rstc;
	struct {
		struct clk *aclk;
		struct clk *pclk;
		struct clk *dclk;
	} rzg2l_clocks;
};

static inline struct rzg2l_du_crtc *to_rzg2l_crtc(struct drm_crtc *c)
{
	return container_of(c, struct rzg2l_du_crtc, crtc);
}

/**
 * struct rzg2l_du_crtc_state - Driver-specific CRTC state
 * @state: base DRM CRTC state
 * @outputs: bitmask of the outputs (enum rzg2l_du_output) driven by this CRTC
 */
struct rzg2l_du_crtc_state {
	struct drm_crtc_state state;
	unsigned int outputs;
};

static inline struct rzg2l_du_crtc_state *to_rzg2l_crtc_state(struct drm_crtc_state *s)
{
	return container_of(s, struct rzg2l_du_crtc_state, state);
}

int rzg2l_du_crtc_create(struct rzg2l_du_device *rcdu);

void rzg2l_du_crtc_finish_page_flip(struct rzg2l_du_crtc *rcrtc);

#endif /* __RZG2L_DU_CRTC_H__ */