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