1 // SPDX-License-Identifier: GPL-2.0 OR MIT
4 * Xen para-virtual DRM device
6 * Copyright (C) 2016-2018 EPAM Systems Inc.
8 * Author: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
13 #include <linux/device.h>
15 #include <xen/interface/io/displif.h>
16 #include <xen/xenbus.h>
18 #include "xen_drm_front.h"
19 #include "xen_drm_front_cfg.h"
21 static int cfg_connector(struct xen_drm_front_info
*front_info
,
22 struct xen_drm_front_cfg_connector
*connector
,
23 const char *path
, int index
)
27 connector_path
= devm_kasprintf(&front_info
->xb_dev
->dev
,
28 GFP_KERNEL
, "%s/%d", path
, index
);
32 if (xenbus_scanf(XBT_NIL
, connector_path
, XENDISPL_FIELD_RESOLUTION
,
33 "%d" XENDISPL_RESOLUTION_SEPARATOR
"%d",
34 &connector
->width
, &connector
->height
) < 0) {
35 /* either no entry configured or wrong resolution set */
37 connector
->height
= 0;
41 connector
->xenstore_path
= connector_path
;
43 DRM_INFO("Connector %s: resolution %dx%d\n",
44 connector_path
, connector
->width
, connector
->height
);
48 int xen_drm_front_cfg_card(struct xen_drm_front_info
*front_info
,
49 struct xen_drm_front_cfg
*cfg
)
51 struct xenbus_device
*xb_dev
= front_info
->xb_dev
;
54 if (xenbus_read_unsigned(front_info
->xb_dev
->nodename
,
55 XENDISPL_FIELD_BE_ALLOC
, 0)) {
56 DRM_INFO("Backend can provide display buffers\n");
60 cfg
->num_connectors
= 0;
61 for (i
= 0; i
< ARRAY_SIZE(cfg
->connectors
); i
++) {
62 ret
= cfg_connector(front_info
, &cfg
->connectors
[i
],
66 cfg
->num_connectors
++;
69 if (!cfg
->num_connectors
) {
70 DRM_ERROR("No connector(s) configured at %s\n",