mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-21 14:38:02 +07:00
0bbce9eb77
Kconfig doesn't have license line, thus, it is GPL-2.0 as default. rcar_du_regs.h, rcar_lvds_regs.h are GPL-2.0, and all other files are GPL-2.0+ as original license. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Simon Horman <horms+renesas@verge.net.au> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
95 lines
2.2 KiB
C
95 lines
2.2 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* rcar_du_encoder.c -- R-Car Display Unit Encoder
|
|
*
|
|
* Copyright (C) 2013-2014 Renesas Electronics Corporation
|
|
*
|
|
* Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
|
|
*/
|
|
|
|
#include <linux/export.h>
|
|
|
|
#include <drm/drmP.h>
|
|
#include <drm/drm_crtc.h>
|
|
#include <drm/drm_crtc_helper.h>
|
|
#include <drm/drm_panel.h>
|
|
|
|
#include "rcar_du_drv.h"
|
|
#include "rcar_du_encoder.h"
|
|
#include "rcar_du_kms.h"
|
|
|
|
/* -----------------------------------------------------------------------------
|
|
* Encoder
|
|
*/
|
|
|
|
static void rcar_du_encoder_mode_set(struct drm_encoder *encoder,
|
|
struct drm_crtc_state *crtc_state,
|
|
struct drm_connector_state *conn_state)
|
|
{
|
|
struct rcar_du_encoder *renc = to_rcar_encoder(encoder);
|
|
|
|
rcar_du_crtc_route_output(crtc_state->crtc, renc->output);
|
|
}
|
|
|
|
static const struct drm_encoder_helper_funcs encoder_helper_funcs = {
|
|
.atomic_mode_set = rcar_du_encoder_mode_set,
|
|
};
|
|
|
|
static const struct drm_encoder_funcs encoder_funcs = {
|
|
.destroy = drm_encoder_cleanup,
|
|
};
|
|
|
|
int rcar_du_encoder_init(struct rcar_du_device *rcdu,
|
|
enum rcar_du_output output,
|
|
struct device_node *enc_node,
|
|
struct device_node *con_node)
|
|
{
|
|
struct rcar_du_encoder *renc;
|
|
struct drm_encoder *encoder;
|
|
struct drm_bridge *bridge = NULL;
|
|
int ret;
|
|
|
|
renc = devm_kzalloc(rcdu->dev, sizeof(*renc), GFP_KERNEL);
|
|
if (renc == NULL)
|
|
return -ENOMEM;
|
|
|
|
renc->output = output;
|
|
encoder = rcar_encoder_to_drm_encoder(renc);
|
|
|
|
dev_dbg(rcdu->dev, "initializing encoder %pOF for output %u\n",
|
|
enc_node, output);
|
|
|
|
/* Locate the DRM bridge from the encoder DT node. */
|
|
bridge = of_drm_find_bridge(enc_node);
|
|
if (!bridge) {
|
|
ret = -EPROBE_DEFER;
|
|
goto done;
|
|
}
|
|
|
|
ret = drm_encoder_init(rcdu->ddev, encoder, &encoder_funcs,
|
|
DRM_MODE_ENCODER_NONE, NULL);
|
|
if (ret < 0)
|
|
goto done;
|
|
|
|
drm_encoder_helper_add(encoder, &encoder_helper_funcs);
|
|
|
|
/*
|
|
* Attach the bridge to the encoder. The bridge will create the
|
|
* connector.
|
|
*/
|
|
ret = drm_bridge_attach(encoder, bridge, NULL);
|
|
if (ret) {
|
|
drm_encoder_cleanup(encoder);
|
|
return ret;
|
|
}
|
|
|
|
done:
|
|
if (ret < 0) {
|
|
if (encoder->name)
|
|
encoder->funcs->destroy(encoder);
|
|
devm_kfree(rcdu->dev, renc);
|
|
}
|
|
|
|
return ret;
|
|
}
|