blob: 0ce7f398bcff150fee7ff1b9d5b2e975b72b458f [file] [log] [blame]
Carlos Palminha51dacf22016-02-19 15:30:26 +03001/*
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
Eugeniy Paltsev7bc61cc2016-10-19 10:46:18 +030017#include <drm/drm_crtc.h>
Carlos Palminha51dacf22016-02-19 15:30:26 +030018#include <drm/drm_encoder_slave.h>
Carlos Palminha51dacf22016-02-19 15:30:26 +030019
20#include "arcpgu.h"
21
Carlos Palminha51dacf22016-02-19 15:30:26 +030022static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = {
23 .destroy = drm_encoder_cleanup,
24};
25
26int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np)
27{
Eugeniy Paltsev7bc61cc2016-10-19 10:46:18 +030028 struct drm_encoder *encoder;
29 struct drm_bridge *bridge;
30
31 int ret = 0;
Carlos Palminha51dacf22016-02-19 15:30:26 +030032
33 encoder = devm_kzalloc(drm->dev, sizeof(*encoder), GFP_KERNEL);
34 if (encoder == NULL)
35 return -ENOMEM;
36
Eugeniy Paltsev7bc61cc2016-10-19 10:46:18 +030037 /* Locate drm bridge from the hdmi encoder DT node */
38 bridge = of_drm_find_bridge(np);
39 if (!bridge)
Carlos Palminha51dacf22016-02-19 15:30:26 +030040 return -EPROBE_DEFER;
Carlos Palminha51dacf22016-02-19 15:30:26 +030041
Eugeniy Paltsev7bc61cc2016-10-19 10:46:18 +030042 encoder->possible_crtcs = 1;
43 encoder->possible_clones = 0;
44 ret = drm_encoder_init(drm, encoder, &arcpgu_drm_encoder_funcs,
Carlos Palminha51dacf22016-02-19 15:30:26 +030045 DRM_MODE_ENCODER_TMDS, NULL);
46 if (ret)
47 return ret;
48
Eugeniy Paltsev7bc61cc2016-10-19 10:46:18 +030049 /* Link drm_bridge to encoder */
Laurent Pinchart3bb80f22016-11-28 17:59:08 +020050 ret = drm_bridge_attach(encoder, bridge, NULL);
Eugeniy Paltsev7bc61cc2016-10-19 10:46:18 +030051 if (ret)
52 drm_encoder_cleanup(encoder);
Carlos Palminha51dacf22016-02-19 15:30:26 +030053
Carlos Palminha51dacf22016-02-19 15:30:26 +030054 return ret;
55}