2014-03-31 03:55:38 +08:00
|
|
|
/*
|
|
|
|
* R-Car Display Unit HDMI Encoder
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 Renesas Electronics Corporation
|
|
|
|
*
|
|
|
|
* Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/slab.h>
|
|
|
|
|
|
|
|
#include <drm/drmP.h>
|
|
|
|
#include <drm/drm_crtc.h>
|
|
|
|
#include <drm/drm_crtc_helper.h>
|
|
|
|
|
|
|
|
#include "rcar_du_drv.h"
|
|
|
|
#include "rcar_du_encoder.h"
|
|
|
|
#include "rcar_du_hdmienc.h"
|
2014-10-26 06:14:27 +08:00
|
|
|
#include "rcar_du_lvdsenc.h"
|
2014-03-31 03:55:38 +08:00
|
|
|
|
|
|
|
struct rcar_du_hdmienc {
|
|
|
|
struct rcar_du_encoder *renc;
|
2015-02-20 20:05:21 +08:00
|
|
|
bool enabled;
|
2014-03-31 03:55:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define to_rcar_hdmienc(e) (to_rcar_encoder(e)->hdmi)
|
|
|
|
|
2015-02-20 20:05:21 +08:00
|
|
|
static void rcar_du_hdmienc_disable(struct drm_encoder *encoder)
|
2014-03-31 03:55:38 +08:00
|
|
|
{
|
|
|
|
struct rcar_du_hdmienc *hdmienc = to_rcar_hdmienc(encoder);
|
2014-12-09 19:19:10 +08:00
|
|
|
|
2015-02-20 20:05:21 +08:00
|
|
|
if (hdmienc->renc->lvds)
|
|
|
|
rcar_du_lvdsenc_enable(hdmienc->renc->lvds, encoder->crtc,
|
|
|
|
false);
|
|
|
|
|
|
|
|
hdmienc->enabled = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rcar_du_hdmienc_enable(struct drm_encoder *encoder)
|
|
|
|
{
|
|
|
|
struct rcar_du_hdmienc *hdmienc = to_rcar_hdmienc(encoder);
|
2014-03-31 03:55:38 +08:00
|
|
|
|
2015-02-20 20:05:21 +08:00
|
|
|
if (hdmienc->renc->lvds)
|
2015-02-20 20:59:58 +08:00
|
|
|
rcar_du_lvdsenc_enable(hdmienc->renc->lvds, encoder->crtc,
|
|
|
|
true);
|
2014-10-26 06:14:27 +08:00
|
|
|
|
2015-02-20 20:05:21 +08:00
|
|
|
hdmienc->enabled = true;
|
|
|
|
}
|
2014-10-26 06:14:27 +08:00
|
|
|
|
2015-02-23 03:02:39 +08:00
|
|
|
static int rcar_du_hdmienc_atomic_check(struct drm_encoder *encoder,
|
|
|
|
struct drm_crtc_state *crtc_state,
|
|
|
|
struct drm_connector_state *conn_state)
|
2014-03-31 03:55:38 +08:00
|
|
|
{
|
2014-10-26 06:14:27 +08:00
|
|
|
struct rcar_du_hdmienc *hdmienc = to_rcar_hdmienc(encoder);
|
2015-02-23 03:02:39 +08:00
|
|
|
struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode;
|
2014-03-31 03:55:38 +08:00
|
|
|
|
2014-10-26 06:14:27 +08:00
|
|
|
if (hdmienc->renc->lvds)
|
2015-09-07 20:44:44 +08:00
|
|
|
rcar_du_lvdsenc_atomic_check(hdmienc->renc->lvds,
|
|
|
|
adjusted_mode);
|
2014-10-26 06:14:27 +08:00
|
|
|
|
2016-07-18 11:14:04 +08:00
|
|
|
return 0;
|
2014-03-31 03:55:38 +08:00
|
|
|
}
|
|
|
|
|
2016-07-18 11:14:04 +08:00
|
|
|
|
2014-03-31 03:55:38 +08:00
|
|
|
static void rcar_du_hdmienc_mode_set(struct drm_encoder *encoder,
|
|
|
|
struct drm_display_mode *mode,
|
|
|
|
struct drm_display_mode *adjusted_mode)
|
|
|
|
{
|
|
|
|
struct rcar_du_hdmienc *hdmienc = to_rcar_hdmienc(encoder);
|
|
|
|
|
|
|
|
rcar_du_crtc_route_output(encoder->crtc, hdmienc->renc->output);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct drm_encoder_helper_funcs encoder_helper_funcs = {
|
|
|
|
.mode_set = rcar_du_hdmienc_mode_set,
|
2015-02-20 20:05:21 +08:00
|
|
|
.disable = rcar_du_hdmienc_disable,
|
|
|
|
.enable = rcar_du_hdmienc_enable,
|
2015-02-23 03:02:39 +08:00
|
|
|
.atomic_check = rcar_du_hdmienc_atomic_check,
|
2014-03-31 03:55:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static void rcar_du_hdmienc_cleanup(struct drm_encoder *encoder)
|
|
|
|
{
|
|
|
|
struct rcar_du_hdmienc *hdmienc = to_rcar_hdmienc(encoder);
|
|
|
|
|
2015-02-20 20:05:21 +08:00
|
|
|
if (hdmienc->enabled)
|
|
|
|
rcar_du_hdmienc_disable(encoder);
|
2014-03-31 03:55:38 +08:00
|
|
|
|
|
|
|
drm_encoder_cleanup(encoder);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct drm_encoder_funcs encoder_funcs = {
|
|
|
|
.destroy = rcar_du_hdmienc_cleanup,
|
|
|
|
};
|
|
|
|
|
|
|
|
int rcar_du_hdmienc_init(struct rcar_du_device *rcdu,
|
|
|
|
struct rcar_du_encoder *renc, struct device_node *np)
|
|
|
|
{
|
|
|
|
struct drm_encoder *encoder = rcar_encoder_to_drm_encoder(renc);
|
2016-07-18 11:14:04 +08:00
|
|
|
struct drm_bridge *bridge;
|
2014-03-31 03:55:38 +08:00
|
|
|
struct rcar_du_hdmienc *hdmienc;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
hdmienc = devm_kzalloc(rcdu->dev, sizeof(*hdmienc), GFP_KERNEL);
|
|
|
|
if (hdmienc == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2016-07-18 11:14:04 +08:00
|
|
|
/* Locate drm bridge from the hdmi encoder DT node */
|
|
|
|
bridge = of_drm_find_bridge(np);
|
|
|
|
if (!bridge)
|
2014-03-31 03:55:38 +08:00
|
|
|
return -EPROBE_DEFER;
|
|
|
|
|
|
|
|
ret = drm_encoder_init(rcdu->ddev, encoder, &encoder_funcs,
|
drm: Pass 'name' to drm_encoder_init()
Done with coccinelle for the most part. However, it thinks '...' is
part of the semantic patch, so I put an 'int DOTDOTDOT' placeholder
in its place and got rid of it with sed afterwards.
@@
identifier dev, encoder, funcs;
@@
int drm_encoder_init(struct drm_device *dev,
struct drm_encoder *encoder,
const struct drm_encoder_funcs *funcs,
int encoder_type
+ ,const char *name, int DOTDOTDOT
)
{ ... }
@@
identifier dev, encoder, funcs;
@@
int drm_encoder_init(struct drm_device *dev,
struct drm_encoder *encoder,
const struct drm_encoder_funcs *funcs,
int encoder_type
+ ,const char *name, int DOTDOTDOT
);
@@
expression E1, E2, E3, E4;
@@
drm_encoder_init(E1, E2, E3, E4
+ ,NULL
)
v2: Add ', or NULL...' to @name kernel doc (Jani)
Annotate the function with __printf() attribute (Jani)
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1449670818-2966-1-git-send-email-ville.syrjala@linux.intel.com
2015-12-09 22:20:18 +08:00
|
|
|
DRM_MODE_ENCODER_TMDS, NULL);
|
2014-03-31 03:55:38 +08:00
|
|
|
if (ret < 0)
|
2016-07-18 11:14:04 +08:00
|
|
|
return ret;
|
2014-03-31 03:55:38 +08:00
|
|
|
|
|
|
|
drm_encoder_helper_add(encoder, &encoder_helper_funcs);
|
|
|
|
|
|
|
|
renc->hdmi = hdmienc;
|
|
|
|
hdmienc->renc = renc;
|
|
|
|
|
2016-07-18 11:14:04 +08:00
|
|
|
/* Link drm_bridge to encoder */
|
|
|
|
bridge->encoder = encoder;
|
2016-08-04 04:31:36 +08:00
|
|
|
encoder->bridge = bridge;
|
2016-07-18 11:14:04 +08:00
|
|
|
|
|
|
|
ret = drm_bridge_attach(rcdu->ddev, bridge);
|
|
|
|
if (ret) {
|
|
|
|
drm_encoder_cleanup(encoder);
|
|
|
|
return ret;
|
|
|
|
}
|
2014-03-31 03:55:38 +08:00
|
|
|
|
2016-07-18 11:14:04 +08:00
|
|
|
return 0;
|
2014-03-31 03:55:38 +08:00
|
|
|
}
|