hc
2023-11-06 9df731a176aab8e03b984b681b1bea01ccff6644
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
/*
 * (C) Copyright 2008-2017 Fuzhou Rockchip Electronics Co., Ltd
 *
 * SPDX-License-Identifier:    GPL-2.0+
 */
 
#ifndef _ROCKCHIP_CONNECTOR_H_
#define _ROCKCHIP_CONNECTOR_H_
 
#ifdef CONFIG_SPL_BUILD
struct rockchip_connector {
   struct rockchip_phy *phy;
   int id;
   int type;
   bool hpd;
 
   const struct rockchip_connector_funcs *funcs;
   void *data;
};
#else
#include "rockchip_bridge.h"
#include "rockchip_panel.h"
 
struct rockchip_connector {
   struct udevice *dev;
   struct rockchip_bridge *bridge;
   struct rockchip_panel *panel;
   struct rockchip_phy *phy;
   struct list_head head;
   int id;
   int type;
   bool hpd;
 
   const struct rockchip_connector_funcs *funcs;
   void *data;
};
#endif
 
/**
 * enum drm_bus_flags - bus_flags info for &drm_display_info
 *
 * This enum defines signal polarities and clock edge information for signals on
 * a bus as bitmask flags.
 *
 * The clock edge information is conveyed by two sets of symbols,
 * DRM_BUS_FLAGS_*_DRIVE_\* and DRM_BUS_FLAGS_*_SAMPLE_\*. When this enum is
 * used to describe a bus from the point of view of the transmitter, the
 * \*_DRIVE_\* flags should be used. When used from the point of view of the
 * receiver, the \*_SAMPLE_\* flags should be used. The \*_DRIVE_\* and
 * \*_SAMPLE_\* flags alias each other, with the \*_SAMPLE_POSEDGE and
 * \*_SAMPLE_NEGEDGE flags being equal to \*_DRIVE_NEGEDGE and \*_DRIVE_POSEDGE
 * respectively. This simplifies code as signals are usually sampled on the
 * opposite edge of the driving edge. Transmitters and receivers may however
 * need to take other signal timings into account to convert between driving
 * and sample edges.
 */
enum drm_bus_flags {
   /**
    * @DRM_BUS_FLAG_DE_LOW:
    *
    * The Data Enable signal is active low
    */
   DRM_BUS_FLAG_DE_LOW = BIT(0),
 
   /**
    * @DRM_BUS_FLAG_DE_HIGH:
    *
    * The Data Enable signal is active high
    */
   DRM_BUS_FLAG_DE_HIGH = BIT(1),
 
   /**
    * @DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE:
    *
    * Data is driven on the rising edge of the pixel clock
    */
   DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE = BIT(2),
 
   /**
    * @DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE:
    *
    * Data is driven on the falling edge of the pixel clock
    */
   DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE = BIT(3),
 
   /**
    * @DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE:
    *
    * Data is sampled on the rising edge of the pixel clock
    */
   DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE = DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE,
 
   /**
    * @DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE:
    *
    * Data is sampled on the falling edge of the pixel clock
    */
   DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE = DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE,
 
   /**
    * @DRM_BUS_FLAG_DATA_MSB_TO_LSB:
    *
    * Data is transmitted MSB to LSB on the bus
    */
   DRM_BUS_FLAG_DATA_MSB_TO_LSB = BIT(4),
 
   /**
    * @DRM_BUS_FLAG_DATA_LSB_TO_MSB:
    *
    * Data is transmitted LSB to MSB on the bus
    */
   DRM_BUS_FLAG_DATA_LSB_TO_MSB = BIT(5),
 
   /**
    * @DRM_BUS_FLAG_SYNC_DRIVE_POSEDGE:
    *
    * Sync signals are driven on the rising edge of the pixel clock
    */
   DRM_BUS_FLAG_SYNC_DRIVE_POSEDGE = BIT(6),
 
   /**
    * @DRM_BUS_FLAG_SYNC_DRIVE_NEGEDGE:
    *
    * Sync signals are driven on the falling edge of the pixel clock
    */
   DRM_BUS_FLAG_SYNC_DRIVE_NEGEDGE = BIT(7),
 
   /**
    * @DRM_BUS_FLAG_SYNC_SAMPLE_POSEDGE:
    *
    * Sync signals are sampled on the rising edge of the pixel clock
    */
   DRM_BUS_FLAG_SYNC_SAMPLE_POSEDGE = DRM_BUS_FLAG_SYNC_DRIVE_NEGEDGE,
 
   /**
    * @DRM_BUS_FLAG_SYNC_SAMPLE_NEGEDGE:
    *
    * Sync signals are sampled on the falling edge of the pixel clock
    */
   DRM_BUS_FLAG_SYNC_SAMPLE_NEGEDGE = DRM_BUS_FLAG_SYNC_DRIVE_POSEDGE,
 
   /**
    * @DRM_BUS_FLAG_SHARP_SIGNALS:
    *
    *  Set if the Sharp-specific signals (SPL, CLS, PS, REV) must be used
    */
   DRM_BUS_FLAG_SHARP_SIGNALS = BIT(8),
};
 
struct rockchip_connector_funcs {
   /*
    * pre init connector, prepare some parameter out_if, this will be
    * used by rockchip_display.c and vop
    */
   int (*pre_init)(struct rockchip_connector *connector, struct display_state *state);
 
   /*
    * init connector, prepare resource to ensure
    * detect and get_timing can works
    */
   int (*init)(struct rockchip_connector *connector, struct display_state *state);
 
   void (*deinit)(struct rockchip_connector *connector, struct display_state *state);
   /*
    * Optional, if connector not support hotplug,
    * Returns:
    *   0 means disconnected, else means connected
    */
   int (*detect)(struct rockchip_connector *connector, struct display_state *state);
   /*
    * Optional, if implement it, need fill the timing data:
    *     state->conn_state->mode
    * you can refer to the rockchip_display: display_get_timing(),
    * Returns:
    *   0 means success, else means failed
    */
   int (*get_timing)(struct rockchip_connector *connector, struct display_state *state);
   /*
    * Optional, if implement it, need fill the edid data:
    *     state->conn_state->edid
    * Returns:
    *   0 means success, else means failed
    */
   int (*get_edid)(struct rockchip_connector *connector, struct display_state *state);
   /*
    * call before crtc enable.
    */
   int (*prepare)(struct rockchip_connector *connector, struct display_state *state);
   /*
    * call after crtc enable
    */
   int (*enable)(struct rockchip_connector *connector, struct display_state *state);
   int (*disable)(struct rockchip_connector *connector, struct display_state *state);
   void (*unprepare)(struct rockchip_connector *connector, struct display_state *state);
 
   int (*check)(struct rockchip_connector *connector, struct display_state *state);
   int (*mode_valid)(struct rockchip_connector *connector, struct display_state *state);
};
 
const struct rockchip_connector *
rockchip_get_connector(const void *blob, int connector_node);
int rockchip_connector_bind(struct rockchip_connector *connector, struct udevice *dev, int id,
               const struct rockchip_connector_funcs *funcs, void *data, int type);
struct rockchip_connector *get_rockchip_connector_by_device(struct udevice *dev);
int rockchip_connector_pre_init(struct display_state *state);
int rockchip_connector_init(struct display_state *state);
int rockchip_connector_deinit(struct display_state *state);
bool rockchip_connector_detect(struct display_state *state);
int rockchip_connector_get_timing(struct display_state *state);
int rockchip_connector_get_edid(struct display_state *state);
int rockchip_connector_pre_enable(struct display_state *state);
int rockchip_connector_enable(struct display_state *state);
int rockchip_connector_disable(struct display_state *state);
int rockchip_connector_post_disable(struct display_state *state);
 
#ifdef CONFIG_DRM_ROCKCHIP_ANALOGIX_DP
struct rockchip_dp_chip_data;
extern const struct rockchip_connector_funcs rockchip_analogix_dp_funcs;
extern const struct rockchip_dp_chip_data rk3399_analogix_edp_drv_data;
extern const struct rockchip_dp_chip_data rk3368_analogix_edp_drv_data;
extern const struct rockchip_dp_chip_data rk3288_analogix_dp_drv_data;
#endif
#endif