.. | .. |
---|
8 | 8 | * Author: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com> |
---|
9 | 9 | */ |
---|
10 | 10 | |
---|
11 | | -#include "xen_drm_front_kms.h" |
---|
12 | | - |
---|
13 | | -#include <drm/drmP.h> |
---|
14 | 11 | #include <drm/drm_atomic.h> |
---|
15 | 12 | #include <drm/drm_atomic_helper.h> |
---|
16 | | -#include <drm/drm_crtc_helper.h> |
---|
| 13 | +#include <drm/drm_drv.h> |
---|
| 14 | +#include <drm/drm_fourcc.h> |
---|
17 | 15 | #include <drm/drm_gem.h> |
---|
18 | 16 | #include <drm/drm_gem_framebuffer_helper.h> |
---|
| 17 | +#include <drm/drm_probe_helper.h> |
---|
| 18 | +#include <drm/drm_vblank.h> |
---|
19 | 19 | |
---|
20 | 20 | #include "xen_drm_front.h" |
---|
21 | 21 | #include "xen_drm_front_conn.h" |
---|
| 22 | +#include "xen_drm_front_kms.h" |
---|
22 | 23 | |
---|
23 | 24 | /* |
---|
24 | 25 | * Timeout in ms to wait for frame done event from the backend: |
---|
.. | .. |
---|
45 | 46 | drm_gem_fb_destroy(fb); |
---|
46 | 47 | } |
---|
47 | 48 | |
---|
48 | | -static struct drm_framebuffer_funcs fb_funcs = { |
---|
| 49 | +static const struct drm_framebuffer_funcs fb_funcs = { |
---|
49 | 50 | .destroy = fb_destroy, |
---|
50 | 51 | }; |
---|
51 | 52 | |
---|
.. | .. |
---|
54 | 55 | const struct drm_mode_fb_cmd2 *mode_cmd) |
---|
55 | 56 | { |
---|
56 | 57 | struct xen_drm_front_drm_info *drm_info = dev->dev_private; |
---|
57 | | - static struct drm_framebuffer *fb; |
---|
| 58 | + struct drm_framebuffer *fb; |
---|
58 | 59 | struct drm_gem_object *gem_obj; |
---|
59 | 60 | int ret; |
---|
60 | 61 | |
---|
.. | .. |
---|
62 | 63 | if (IS_ERR(fb)) |
---|
63 | 64 | return fb; |
---|
64 | 65 | |
---|
65 | | - gem_obj = drm_gem_object_lookup(filp, mode_cmd->handles[0]); |
---|
66 | | - if (!gem_obj) { |
---|
67 | | - DRM_ERROR("Failed to lookup GEM object\n"); |
---|
68 | | - ret = -ENOENT; |
---|
69 | | - goto fail; |
---|
70 | | - } |
---|
71 | | - |
---|
72 | | - drm_gem_object_put_unlocked(gem_obj); |
---|
| 66 | + gem_obj = fb->obj[0]; |
---|
73 | 67 | |
---|
74 | 68 | ret = xen_drm_front_fb_attach(drm_info->front_info, |
---|
75 | 69 | xen_drm_front_dbuf_to_cookie(gem_obj), |
---|
.. | .. |
---|
226 | 220 | return false; |
---|
227 | 221 | } |
---|
228 | 222 | |
---|
| 223 | +static int display_check(struct drm_simple_display_pipe *pipe, |
---|
| 224 | + struct drm_plane_state *plane_state, |
---|
| 225 | + struct drm_crtc_state *crtc_state) |
---|
| 226 | +{ |
---|
| 227 | + /* |
---|
| 228 | + * Xen doesn't initialize vblanking via drm_vblank_init(), so |
---|
| 229 | + * DRM helpers assume that it doesn't handle vblanking and start |
---|
| 230 | + * sending out fake VBLANK events automatically. |
---|
| 231 | + * |
---|
| 232 | + * As xen contains it's own logic for sending out VBLANK events |
---|
| 233 | + * in send_pending_event(), disable no_vblank (i.e., the xen |
---|
| 234 | + * driver has vblanking support). |
---|
| 235 | + */ |
---|
| 236 | + crtc_state->no_vblank = false; |
---|
| 237 | + |
---|
| 238 | + return 0; |
---|
| 239 | +} |
---|
| 240 | + |
---|
229 | 241 | static void display_update(struct drm_simple_display_pipe *pipe, |
---|
230 | 242 | struct drm_plane_state *old_plane_state) |
---|
231 | 243 | { |
---|
.. | .. |
---|
269 | 281 | } |
---|
270 | 282 | |
---|
271 | 283 | static enum drm_mode_status |
---|
272 | | -display_mode_valid(struct drm_crtc *crtc, const struct drm_display_mode *mode) |
---|
| 284 | +display_mode_valid(struct drm_simple_display_pipe *pipe, |
---|
| 285 | + const struct drm_display_mode *mode) |
---|
273 | 286 | { |
---|
274 | 287 | struct xen_drm_front_drm_pipeline *pipeline = |
---|
275 | | - container_of(crtc, struct xen_drm_front_drm_pipeline, |
---|
276 | | - pipe.crtc); |
---|
| 288 | + container_of(pipe, struct xen_drm_front_drm_pipeline, |
---|
| 289 | + pipe); |
---|
277 | 290 | |
---|
278 | 291 | if (mode->hdisplay != pipeline->width) |
---|
279 | 292 | return MODE_ERROR; |
---|
.. | .. |
---|
289 | 302 | .enable = display_enable, |
---|
290 | 303 | .disable = display_disable, |
---|
291 | 304 | .prepare_fb = drm_gem_fb_simple_display_pipe_prepare_fb, |
---|
| 305 | + .check = display_check, |
---|
292 | 306 | .update = display_update, |
---|
293 | 307 | }; |
---|
294 | 308 | |
---|