]>
Commit | Line | Data |
---|---|---|
51dacf20 CP |
1 | /* |
2 | * ARC PGU DRM driver. | |
3 | * | |
4 | * Copyright (C) 2016 Synopsys, Inc. (www.synopsys.com) | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License version 2 as | |
8 | * published by the Free Software Foundation. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | */ | |
16 | ||
7bc61cc5 | 17 | #include <drm/drm_crtc.h> |
51dacf20 | 18 | #include <drm/drm_encoder_slave.h> |
51dacf20 CP |
19 | |
20 | #include "arcpgu.h" | |
21 | ||
51dacf20 CP |
22 | static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = { |
23 | .destroy = drm_encoder_cleanup, | |
24 | }; | |
25 | ||
26 | int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np) | |
27 | { | |
7bc61cc5 EP |
28 | struct drm_encoder *encoder; |
29 | struct drm_bridge *bridge; | |
30 | ||
31 | int ret = 0; | |
51dacf20 CP |
32 | |
33 | encoder = devm_kzalloc(drm->dev, sizeof(*encoder), GFP_KERNEL); | |
34 | if (encoder == NULL) | |
35 | return -ENOMEM; | |
36 | ||
7bc61cc5 EP |
37 | /* Locate drm bridge from the hdmi encoder DT node */ |
38 | bridge = of_drm_find_bridge(np); | |
39 | if (!bridge) | |
51dacf20 | 40 | return -EPROBE_DEFER; |
51dacf20 | 41 | |
7bc61cc5 EP |
42 | encoder->possible_crtcs = 1; |
43 | encoder->possible_clones = 0; | |
44 | ret = drm_encoder_init(drm, encoder, &arcpgu_drm_encoder_funcs, | |
51dacf20 CP |
45 | DRM_MODE_ENCODER_TMDS, NULL); |
46 | if (ret) | |
47 | return ret; | |
48 | ||
7bc61cc5 EP |
49 | /* Link drm_bridge to encoder */ |
50 | bridge->encoder = encoder; | |
51 | encoder->bridge = bridge; | |
51dacf20 | 52 | |
7bc61cc5 EP |
53 | ret = drm_bridge_attach(drm, bridge); |
54 | if (ret) | |
55 | drm_encoder_cleanup(encoder); | |
51dacf20 | 56 | |
51dacf20 CP |
57 | return ret; |
58 | } |