dt-bindings: mtd: ingenic: Use standard ecc-engine property
[linux/fpc-iii.git] / drivers / gpu / drm / xen / xen_drm_front_conn.c
blob9f5f31f77f1e2ed4d1896536dc8e60c751c9186a
1 // SPDX-License-Identifier: GPL-2.0 OR MIT
3 /*
4 * Xen para-virtual DRM device
6 * Copyright (C) 2016-2018 EPAM Systems Inc.
8 * Author: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
9 */
11 #include <drm/drm_atomic_helper.h>
12 #include <drm/drm_probe_helper.h>
14 #include <video/videomode.h>
16 #include "xen_drm_front.h"
17 #include "xen_drm_front_conn.h"
18 #include "xen_drm_front_kms.h"
20 static struct xen_drm_front_drm_pipeline *
21 to_xen_drm_pipeline(struct drm_connector *connector)
23 return container_of(connector, struct xen_drm_front_drm_pipeline, conn);
26 static const u32 plane_formats[] = {
27 DRM_FORMAT_RGB565,
28 DRM_FORMAT_RGB888,
29 DRM_FORMAT_XRGB8888,
30 DRM_FORMAT_ARGB8888,
31 DRM_FORMAT_XRGB4444,
32 DRM_FORMAT_ARGB4444,
33 DRM_FORMAT_XRGB1555,
34 DRM_FORMAT_ARGB1555,
37 const u32 *xen_drm_front_conn_get_formats(int *format_count)
39 *format_count = ARRAY_SIZE(plane_formats);
40 return plane_formats;
43 static int connector_detect(struct drm_connector *connector,
44 struct drm_modeset_acquire_ctx *ctx,
45 bool force)
47 struct xen_drm_front_drm_pipeline *pipeline =
48 to_xen_drm_pipeline(connector);
50 if (drm_dev_is_unplugged(connector->dev))
51 pipeline->conn_connected = false;
53 return pipeline->conn_connected ? connector_status_connected :
54 connector_status_disconnected;
57 #define XEN_DRM_CRTC_VREFRESH_HZ 60
59 static int connector_get_modes(struct drm_connector *connector)
61 struct xen_drm_front_drm_pipeline *pipeline =
62 to_xen_drm_pipeline(connector);
63 struct drm_display_mode *mode;
64 struct videomode videomode;
65 int width, height;
67 mode = drm_mode_create(connector->dev);
68 if (!mode)
69 return 0;
71 memset(&videomode, 0, sizeof(videomode));
72 videomode.hactive = pipeline->width;
73 videomode.vactive = pipeline->height;
74 width = videomode.hactive + videomode.hfront_porch +
75 videomode.hback_porch + videomode.hsync_len;
76 height = videomode.vactive + videomode.vfront_porch +
77 videomode.vback_porch + videomode.vsync_len;
78 videomode.pixelclock = width * height * XEN_DRM_CRTC_VREFRESH_HZ;
79 mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER;
81 drm_display_mode_from_videomode(&videomode, mode);
82 drm_mode_probed_add(connector, mode);
83 return 1;
86 static const struct drm_connector_helper_funcs connector_helper_funcs = {
87 .get_modes = connector_get_modes,
88 .detect_ctx = connector_detect,
91 static const struct drm_connector_funcs connector_funcs = {
92 .fill_modes = drm_helper_probe_single_connector_modes,
93 .destroy = drm_connector_cleanup,
94 .reset = drm_atomic_helper_connector_reset,
95 .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
96 .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
99 int xen_drm_front_conn_init(struct xen_drm_front_drm_info *drm_info,
100 struct drm_connector *connector)
102 struct xen_drm_front_drm_pipeline *pipeline =
103 to_xen_drm_pipeline(connector);
105 drm_connector_helper_add(connector, &connector_helper_funcs);
107 pipeline->conn_connected = true;
109 connector->polled = DRM_CONNECTOR_POLL_CONNECT |
110 DRM_CONNECTOR_POLL_DISCONNECT;
112 return drm_connector_init(drm_info->drm_dev, connector,
113 &connector_funcs, DRM_MODE_CONNECTOR_VIRTUAL);