Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / gpu / drm / arc / arcpgu_hdmi.c
blob52839934f2fb52304d92a63fe0670a8e2f2f1e1a
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * ARC PGU DRM driver.
5 * Copyright (C) 2016 Synopsys, Inc. (www.synopsys.com)
6 */
8 #include <drm/drm_bridge.h>
9 #include <drm/drm_crtc.h>
10 #include <drm/drm_encoder.h>
11 #include <drm/drm_device.h>
13 #include "arcpgu.h"
15 static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = {
16 .destroy = drm_encoder_cleanup,
19 int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np)
21 struct drm_encoder *encoder;
22 struct drm_bridge *bridge;
24 int ret = 0;
26 encoder = devm_kzalloc(drm->dev, sizeof(*encoder), GFP_KERNEL);
27 if (encoder == NULL)
28 return -ENOMEM;
30 /* Locate drm bridge from the hdmi encoder DT node */
31 bridge = of_drm_find_bridge(np);
32 if (!bridge)
33 return -EPROBE_DEFER;
35 encoder->possible_crtcs = 1;
36 encoder->possible_clones = 0;
37 ret = drm_encoder_init(drm, encoder, &arcpgu_drm_encoder_funcs,
38 DRM_MODE_ENCODER_TMDS, NULL);
39 if (ret)
40 return ret;
42 /* Link drm_bridge to encoder */
43 ret = drm_bridge_attach(encoder, bridge, NULL, 0);
44 if (ret)
45 drm_encoder_cleanup(encoder);
47 return ret;