1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Copyright (C) 2009 Nokia Corporation
4 * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
5 *
6 * Some code and ideas taken from drivers/video/omap/ driver
7 * by Imre Deak.
8 */
9
10 #define DSS_SUBSYS_NAME "DISPLAY"
11
12 #include <linux/kernel.h>
13 #include <linux/of.h>
14
15 #include <drm/drm_connector.h>
16 #include <drm/drm_modes.h>
17
18 #include "omapdss.h"
19
20 static int disp_num_counter;
21
omapdss_display_init(struct omap_dss_device * dssdev)22 void omapdss_display_init(struct omap_dss_device *dssdev)
23 {
24 int id;
25
26 /*
27 * Note: this presumes that all displays either have an DT alias, or
28 * none has.
29 */
30 id = of_alias_get_id(dssdev->dev->of_node, "display");
31 if (id < 0)
32 id = disp_num_counter++;
33
34 /* Use 'label' property for name, if it exists */
35 of_property_read_string(dssdev->dev->of_node, "label", &dssdev->name);
36
37 if (dssdev->name == NULL)
38 dssdev->name = devm_kasprintf(dssdev->dev, GFP_KERNEL,
39 "display%u", id);
40 }
41 EXPORT_SYMBOL_GPL(omapdss_display_init);
42
omapdss_display_get_modes(struct drm_connector * connector,const struct videomode * vm)43 int omapdss_display_get_modes(struct drm_connector *connector,
44 const struct videomode *vm)
45 {
46 struct drm_display_mode *mode;
47
48 mode = drm_mode_create(connector->dev);
49 if (!mode)
50 return 0;
51
52 drm_display_mode_from_videomode(vm, mode);
53
54 mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
55 drm_mode_set_name(mode);
56 drm_mode_probed_add(connector, mode);
57
58 return 1;
59 }
60 EXPORT_SYMBOL_GPL(omapdss_display_get_modes);
61