summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/msm/sde/sde_shd.h
blob: a3334ccd51d20a5d89222e7832e1b31f9cd7c1d7 (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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/*
 * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * 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 _SDE_SHD_H_
#define _SDE_SHD_H_

#include <linux/types.h>
#include <drm/drmP.h>
#include <drm/drm_crtc.h>
#include <drm/drm_crtc_helper.h>
#include "msm_drv.h"

struct shd_mode_info {
	int x_offset;
	int y_offset;
	int width;
	int height;
};

struct shd_stage_range {
	u32 start;
	u32 size;
};

struct shd_display_base {
	struct mutex           base_mutex;
	struct drm_display_mode mode;
	struct drm_crtc       *crtc;
	struct drm_encoder    *encoder;
	struct drm_connector  *connector;
	struct list_head       head;
	struct list_head       disp_list;
	struct device_node    *of_node;
	struct sde_connector_ops ops;

	int intf_idx;
	int connector_type;
	bool enabled;
};

struct shd_display {
	struct drm_device *drm_dev;
	const char *name;
	const char *display_type;

	struct shd_display_base *base;
	struct drm_bridge *bridge;
	struct drm_connector *connector;

	struct device_node *base_of;
	struct sde_rect src;
	struct sde_rect roi;
	struct shd_stage_range stage_range;

	struct platform_device *pdev;
	struct completion vsync_comp;
	struct list_head head;

	bool enabled;
	bool cont_splash_enabled;
};

#ifdef CONFIG_DRM_SDE_SHD
int shd_display_get_num_of_displays(void);
int shd_display_get_displays(void **displays, int count);
int shd_display_post_init(struct sde_kms *sde_kms);
void shd_display_prepare_commit(struct sde_kms *sde_kms,
		struct drm_atomic_state *state);
void shd_display_complete_commit(struct sde_kms *sde_kms,
		struct drm_atomic_state *state);

/**
 * shd_connector_post_init - callback to perform additional initialization steps
 * @connector: Pointer to drm connector structure
 * @display: Pointer to private display handle
 * Returns: Zero on success
 */
int shd_connector_post_init(struct drm_connector *connector,
		void *info,
		void *display);

/**
 * shd_connector_detect - callback to determine if connector is connected
 * @connector: Pointer to drm connector structure
 * @force: Force detect setting from drm framework
 * @display: Pointer to private display handle
 * Returns: Connector 'is connected' status
 */
enum drm_connector_status shd_connector_detect(struct drm_connector *conn,
		bool force,
		void *display);

/**
 * shd_connector_get_modes - callback to add drm modes via drm_mode_probed_add()
 * @connector: Pointer to drm connector structure
 * @display: Pointer to private display handle
 * Returns: Number of modes added
 */
int shd_connector_get_modes(struct drm_connector *connector,
		void *display);

/**
 * shd_connector_mode_valid - callback to determine if specified mode is valid
 * @connector: Pointer to drm connector structure
 * @mode: Pointer to drm mode structure
 * @display: Pointer to private display handle
 * Returns: Validity status for specified mode
 */
enum drm_mode_status shd_connector_mode_valid(struct drm_connector *connector,
		struct drm_display_mode *mode,
		void *display);

/**
 * shd_connector_get_info - retrieve connector display info
 * @connector: Pointer to drm connector structure
 * @info: Out parameter. Information of the connected display
 * @display: Pointer to private display structure
 * Returns: zero on success
 */
int shd_connector_get_info(struct msm_display_info *info, void *display);

/**
 * shd_display_drm_bridge_init() - initializes DRM bridge object
 * for shared display
 * @display:            Handle to the display.
 * @encoder:            Pointer to the encoder object which is connected to the
 *			display.
 * Return: error code.
 */
int shd_drm_bridge_init(void *display,
	struct drm_encoder *encoder);

/**
 * shd_display_drm_bridge_deinit() - destroys DRM bridge for the display
 * @display:        Handle to the display.
 * Return: error code.
 */
void shd_drm_bridge_deinit(void *display);
#else
static inline
int shd_display_get_num_of_displays(void)
{
	return 0;
}

static inline
int shd_display_get_displays(void **displays, int count)
{
	return 0;
}

static inline
int shd_display_post_init(struct sde_kms *sde_kms)
{
	return 0;
}

static inline
void shd_display_prepare_commit(struct sde_kms *sde_kms,
		struct drm_atomic_state *state)
{
}

static inline
void shd_display_complete_commit(struct sde_kms *sde_kms,
		struct drm_atomic_state *state)
{
}

static inline
int shd_connector_post_init(struct drm_connector *connector,
		void *info,
		void *display)
{
	return 0;
}

static inline
enum drm_connector_status shd_connector_detect(struct drm_connector *conn,
		bool force,
		void *display)
{
	return connector_status_unknown;
}

static inline
int shd_connector_get_modes(struct drm_connector *connector,
		void *display)
{
	return 0;
}

static inline
enum drm_mode_status shd_connector_mode_valid(struct drm_connector *connector,
		struct drm_display_mode *mode,
		void *display)
{
	return MODE_ERROR;
}

static inline
int shd_connector_get_info(struct msm_display_info *info, void *display)
{
	return -EINVAL;
}

static inline
int shd_drm_bridge_init(void *display,
	struct drm_encoder *encoder)
{
	return 0;
}

static inline
void shd_drm_bridge_deinit(void *display)
{
}
#endif

#endif /* _SDE_SHD_H_ */