This source file includes following definitions.
- komeda_wb_init_data_flow
- komeda_wb_encoder_atomic_check
- komeda_wb_connector_get_modes
- komeda_wb_connector_mode_valid
- komeda_wb_connector_detect
- komeda_wb_connector_fill_modes
- komeda_wb_connector_destroy
- komeda_wb_connector_add
- komeda_kms_add_wb_connectors
1
2
3
4
5
6
7 #include "komeda_dev.h"
8 #include "komeda_kms.h"
9
10 static int
11 komeda_wb_init_data_flow(struct komeda_layer *wb_layer,
12 struct drm_connector_state *conn_st,
13 struct komeda_crtc_state *kcrtc_st,
14 struct komeda_data_flow_cfg *dflow)
15 {
16 struct drm_framebuffer *fb = conn_st->writeback_job->fb;
17
18 memset(dflow, 0, sizeof(*dflow));
19
20 dflow->out_w = fb->width;
21 dflow->out_h = fb->height;
22
23
24 pipeline_composition_size(kcrtc_st, &dflow->in_w, &dflow->in_h);
25 dflow->input.component = &wb_layer->base.pipeline->compiz->base;
26
27 dflow->pixel_blend_mode = DRM_MODE_BLEND_PIXEL_NONE;
28 dflow->rot = DRM_MODE_ROTATE_0;
29
30 komeda_complete_data_flow_cfg(wb_layer, dflow, fb);
31
32 return 0;
33 }
34
35 static int
36 komeda_wb_encoder_atomic_check(struct drm_encoder *encoder,
37 struct drm_crtc_state *crtc_st,
38 struct drm_connector_state *conn_st)
39 {
40 struct komeda_crtc_state *kcrtc_st = to_kcrtc_st(crtc_st);
41 struct drm_writeback_job *writeback_job = conn_st->writeback_job;
42 struct komeda_layer *wb_layer;
43 struct komeda_data_flow_cfg dflow;
44 int err;
45
46 if (!writeback_job)
47 return 0;
48
49 if (!crtc_st->active) {
50 DRM_DEBUG_ATOMIC("Cannot write the composition result out on a inactive CRTC.\n");
51 return -EINVAL;
52 }
53
54 wb_layer = to_kconn(to_wb_conn(conn_st->connector))->wb_layer;
55
56
57
58
59
60 if (crtc_st->connectors_changed &&
61 is_only_changed_connector(crtc_st, conn_st->connector))
62 crtc_st->connectors_changed = false;
63
64 err = komeda_wb_init_data_flow(wb_layer, conn_st, kcrtc_st, &dflow);
65 if (err)
66 return err;
67
68 if (dflow.en_split)
69 err = komeda_build_wb_split_data_flow(wb_layer,
70 conn_st, kcrtc_st, &dflow);
71 else
72 err = komeda_build_wb_data_flow(wb_layer,
73 conn_st, kcrtc_st, &dflow);
74
75 return err;
76 }
77
78 static const struct drm_encoder_helper_funcs komeda_wb_encoder_helper_funcs = {
79 .atomic_check = komeda_wb_encoder_atomic_check,
80 };
81
82 static int
83 komeda_wb_connector_get_modes(struct drm_connector *connector)
84 {
85 return 0;
86 }
87
88 static enum drm_mode_status
89 komeda_wb_connector_mode_valid(struct drm_connector *connector,
90 struct drm_display_mode *mode)
91 {
92 struct drm_device *dev = connector->dev;
93 struct drm_mode_config *mode_config = &dev->mode_config;
94 int w = mode->hdisplay, h = mode->vdisplay;
95
96 if ((w < mode_config->min_width) || (w > mode_config->max_width))
97 return MODE_BAD_HVALUE;
98
99 if ((h < mode_config->min_height) || (h > mode_config->max_height))
100 return MODE_BAD_VVALUE;
101
102 return MODE_OK;
103 }
104
105 static const struct drm_connector_helper_funcs komeda_wb_conn_helper_funcs = {
106 .get_modes = komeda_wb_connector_get_modes,
107 .mode_valid = komeda_wb_connector_mode_valid,
108 };
109
110 static enum drm_connector_status
111 komeda_wb_connector_detect(struct drm_connector *connector, bool force)
112 {
113 return connector_status_connected;
114 }
115
116 static int
117 komeda_wb_connector_fill_modes(struct drm_connector *connector,
118 uint32_t maxX, uint32_t maxY)
119 {
120 return 0;
121 }
122
123 static void komeda_wb_connector_destroy(struct drm_connector *connector)
124 {
125 drm_connector_cleanup(connector);
126 kfree(to_kconn(to_wb_conn(connector)));
127 }
128
129 static const struct drm_connector_funcs komeda_wb_connector_funcs = {
130 .reset = drm_atomic_helper_connector_reset,
131 .detect = komeda_wb_connector_detect,
132 .fill_modes = komeda_wb_connector_fill_modes,
133 .destroy = komeda_wb_connector_destroy,
134 .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
135 .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
136 };
137
138 static int komeda_wb_connector_add(struct komeda_kms_dev *kms,
139 struct komeda_crtc *kcrtc)
140 {
141 struct komeda_dev *mdev = kms->base.dev_private;
142 struct komeda_wb_connector *kwb_conn;
143 struct drm_writeback_connector *wb_conn;
144 u32 *formats, n_formats = 0;
145 int err;
146
147 if (!kcrtc->master->wb_layer)
148 return 0;
149
150 kwb_conn = kzalloc(sizeof(*kwb_conn), GFP_KERNEL);
151 if (!kwb_conn)
152 return -ENOMEM;
153
154 kwb_conn->wb_layer = kcrtc->master->wb_layer;
155
156 wb_conn = &kwb_conn->base;
157 wb_conn->encoder.possible_crtcs = BIT(drm_crtc_index(&kcrtc->base));
158
159 formats = komeda_get_layer_fourcc_list(&mdev->fmt_tbl,
160 kwb_conn->wb_layer->layer_type,
161 &n_formats);
162
163 err = drm_writeback_connector_init(&kms->base, wb_conn,
164 &komeda_wb_connector_funcs,
165 &komeda_wb_encoder_helper_funcs,
166 formats, n_formats);
167 komeda_put_fourcc_list(formats);
168 if (err) {
169 kfree(kwb_conn);
170 return err;
171 }
172
173 drm_connector_helper_add(&wb_conn->base, &komeda_wb_conn_helper_funcs);
174
175 kcrtc->wb_conn = kwb_conn;
176
177 return 0;
178 }
179
180 int komeda_kms_add_wb_connectors(struct komeda_kms_dev *kms,
181 struct komeda_dev *mdev)
182 {
183 int i, err;
184
185 for (i = 0; i < kms->n_crtcs; i++) {
186 err = komeda_wb_connector_add(kms, &kms->crtcs[i]);
187 if (err)
188 return err;
189 }
190
191 return 0;
192 }