Release 4.11 drivers/gpu/drm/imx/parallel-display.c
/*
* i.MX drm driver - parallel display implementation
*
* Copyright (C) 2012 Sascha Hauer, Pengutronix
*
* 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.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/component.h>
#include <linux/module.h>
#include <drm/drmP.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_fb_helper.h>
#include <drm/drm_crtc_helper.h>
#include <drm/drm_panel.h>
#include <linux/videodev2.h>
#include <video/of_display_timing.h>
#include <linux/of_graph.h>
#include "imx-drm.h"
struct imx_parallel_display {
struct drm_connector connector;
struct drm_encoder encoder;
struct device *dev;
void *edid;
int edid_len;
u32 bus_format;
u32 bus_flags;
struct drm_display_mode mode;
struct drm_panel *panel;
struct drm_bridge *bridge;
};
static inline struct imx_parallel_display *con_to_imxpd(struct drm_connector *c)
{
return container_of(c, struct imx_parallel_display, connector);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Philipp Zabel | 25 | 100.00% | 1 | 100.00% |
Total | 25 | 100.00% | 1 | 100.00% |
static inline struct imx_parallel_display *enc_to_imxpd(struct drm_encoder *e)
{
return container_of(e, struct imx_parallel_display, encoder);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Philipp Zabel | 25 | 100.00% | 1 | 100.00% |
Total | 25 | 100.00% | 1 | 100.00% |
static int imx_pd_connector_get_modes(struct drm_connector *connector)
{
struct imx_parallel_display *imxpd = con_to_imxpd(connector);
struct device_node *np = imxpd->dev->of_node;
int num_modes = 0;
if (imxpd->panel && imxpd->panel->funcs &&
imxpd->panel->funcs->get_modes) {
num_modes = imxpd->panel->funcs->get_modes(imxpd->panel);
if (num_modes > 0)
return num_modes;
}
if (imxpd->edid) {
drm_mode_connector_update_edid_property(connector, imxpd->edid);
num_modes = drm_add_edid_modes(connector, imxpd->edid);
}
if (np) {
struct drm_display_mode *mode = drm_mode_create(connector->dev);
int ret;
if (!mode)
return -EINVAL;
ret = of_get_drm_display_mode(np, &imxpd->mode,
&imxpd->bus_flags,
OF_USE_NATIVE_MODE);
if (ret)
return ret;
drm_mode_copy(mode, &imxpd->mode);
mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
drm_mode_probed_add(connector, mode);
num_modes++;
}
return num_modes;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Sascha Hauer | 71 | 35.86% | 1 | 14.29% |
Marek Vašut | 54 | 27.27% | 1 | 14.29% |
Philipp Zabel | 46 | 23.23% | 1 | 14.29% |
Lothar Waßmann | 18 | 9.09% | 3 | 42.86% |
Fabio Estevam | 9 | 4.55% | 1 | 14.29% |
Total | 198 | 100.00% | 7 | 100.00% |
static struct drm_encoder *imx_pd_connector_best_encoder(
struct drm_connector *connector)
{
struct imx_parallel_display *imxpd = con_to_imxpd(connector);
return &imxpd->encoder;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Sascha Hauer | 29 | 100.00% | 1 | 100.00% |
Total | 29 | 100.00% | 1 | 100.00% |
static void imx_pd_encoder_enable(struct drm_encoder *encoder)
{
struct imx_parallel_display *imxpd = enc_to_imxpd(encoder);
drm_panel_prepare(imxpd->panel);
drm_panel_enable(imxpd->panel);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Philipp Zabel | 24 | 68.57% | 2 | 50.00% |
Sascha Hauer | 10 | 28.57% | 1 | 25.00% |
Liu Ying | 1 | 2.86% | 1 | 25.00% |
Total | 35 | 100.00% | 4 | 100.00% |
static void imx_pd_encoder_disable(struct drm_encoder *encoder)
{
struct imx_parallel_display *imxpd = enc_to_imxpd(encoder);
drm_panel_disable(imxpd->panel);
drm_panel_unprepare(imxpd->panel);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Philipp Zabel | 26 | 74.29% | 2 | 66.67% |
Sascha Hauer | 9 | 25.71% | 1 | 33.33% |
Total | 35 | 100.00% | 3 | 100.00% |
static int imx_pd_encoder_atomic_check(struct drm_encoder *encoder,
struct drm_crtc_state *crtc_state,
struct drm_connector_state *conn_state)
{
struct imx_crtc_state *imx_crtc_state = to_imx_crtc_state(crtc_state);
struct drm_display_info *di = &conn_state->connector->display_info;
struct imx_parallel_display *imxpd = enc_to_imxpd(encoder);
if (!imxpd->bus_format && di->num_bus_formats) {
imx_crtc_state->bus_flags = di->bus_flags;
imx_crtc_state->bus_format = di->bus_formats[0];
} else {
imx_crtc_state->bus_flags = imxpd->bus_flags;
imx_crtc_state->bus_format = imxpd->bus_format;
}
imx_crtc_state->di_hsync_pin = 2;
imx_crtc_state->di_vsync_pin = 3;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Philipp Zabel | 99 | 83.19% | 1 | 50.00% |
Lothar Waßmann | 20 | 16.81% | 1 | 50.00% |
Total | 119 | 100.00% | 2 | 100.00% |
static const struct drm_connector_funcs imx_pd_connector_funcs = {
.dpms = drm_atomic_helper_connector_dpms,
.fill_modes = drm_helper_probe_single_connector_modes,
.destroy = imx_drm_connector_destroy,
.reset = drm_atomic_helper_connector_reset,
.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
};
static const struct drm_connector_helper_funcs imx_pd_connector_helper_funcs = {
.get_modes = imx_pd_connector_get_modes,
.best_encoder = imx_pd_connector_best_encoder,
};
static const struct drm_encoder_funcs imx_pd_encoder_funcs = {
.destroy = imx_drm_encoder_destroy,
};
static const struct drm_encoder_helper_funcs imx_pd_encoder_helper_funcs = {
.enable = imx_pd_encoder_enable,
.disable = imx_pd_encoder_disable,
.atomic_check = imx_pd_encoder_atomic_check,
};
static int imx_pd_register(struct drm_device *drm,
struct imx_parallel_display *imxpd)
{
struct drm_encoder *encoder = &imxpd->encoder;
int ret;
ret = imx_drm_encoder_parse_of(drm, encoder, imxpd->dev->of_node);
if (ret)
return ret;
/* set the connector's dpms to OFF so that
* drm_helper_connector_dpms() won't return
* immediately since the current state is ON
* at this point.
*/
imxpd->connector.dpms = DRM_MODE_DPMS_OFF;
drm_encoder_helper_add(encoder, &imx_pd_encoder_helper_funcs);
drm_encoder_init(drm, encoder, &imx_pd_encoder_funcs,
DRM_MODE_ENCODER_NONE, NULL);
if (!imxpd->bridge) {
drm_connector_helper_add(&imxpd->connector,
&imx_pd_connector_helper_funcs);
drm_connector_init(drm, &imxpd->connector,
&imx_pd_connector_funcs,
DRM_MODE_CONNECTOR_VGA);
}
if (imxpd->panel)
drm_panel_attach(imxpd->panel, &imxpd->connector);
if (imxpd->bridge) {
ret = drm_bridge_attach(encoder, imxpd->bridge, NULL);
if (ret < 0) {
dev_err(imxpd->dev, "failed to attach bridge: %d\n",
ret);
return ret;
}
} else {
drm_mode_connector_attach_encoder(&imxpd->connector, encoder);
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Philipp Zabel | 80 | 41.24% | 3 | 37.50% |
Sascha Hauer | 65 | 33.51% | 1 | 12.50% |
Russell King | 35 | 18.04% | 1 | 12.50% |
Denis Carikli | 9 | 4.64% | 1 | 12.50% |
Laurent Pinchart | 3 | 1.55% | 1 | 12.50% |
Ville Syrjälä | 2 | 1.03% | 1 | 12.50% |
Total | 194 | 100.00% | 8 | 100.00% |
static int imx_pd_bind(struct device *dev, struct device *master, void *data)
{
struct drm_device *drm = data;
struct device_node *np = dev->of_node;
struct device_node *ep;
const u8 *edidp;
struct imx_parallel_display *imxpd;
int ret;
u32 bus_format = 0;
const char *fmt;
imxpd = devm_kzalloc(dev, sizeof(*imxpd), GFP_KERNEL);
if (!imxpd)
return -ENOMEM;
edidp = of_get_property(np, "edid", &imxpd->edid_len);
if (edidp)
imxpd->edid = kmemdup(edidp, imxpd->edid_len, GFP_KERNEL);
ret = of_property_read_string(np, "interface-pix-fmt", &fmt);
if (!ret) {
if (!strcmp(fmt, "rgb24"))
bus_format = MEDIA_BUS_FMT_RGB888_1X24;
else if (!strcmp(fmt, "rgb565"))
bus_format = MEDIA_BUS_FMT_RGB565_1X16;
else if (!strcmp(fmt, "bgr666"))
bus_format = MEDIA_BUS_FMT_RGB666_1X18;
else if (!strcmp(fmt, "lvds666"))
bus_format = MEDIA_BUS_FMT_RGB666_1X24_CPADHI;
}
imxpd->bus_format = bus_format;
/* port@1 is the output port */
ep = of_graph_get_endpoint_by_regs(np, 1, -1);
if (ep) {
struct device_node *remote;
remote = of_graph_get_remote_port_parent(ep);
if (!remote) {
dev_warn(dev, "endpoint %s not connected\n",
ep->full_name);
of_node_put(ep);
return -ENODEV;
}
of_node_put(ep);
imxpd->panel = of_drm_find_panel(remote);
if (imxpd->panel) {
dev_dbg(dev, "found panel %s\n", remote->full_name);
} else {
imxpd->bridge = of_drm_find_bridge(remote);
if (imxpd->bridge)
dev_dbg(dev, "found bridge %s\n",
remote->full_name);
}
if (!imxpd->panel && !imxpd->bridge) {
dev_dbg(dev, "waiting for panel or bridge %s\n",
remote->full_name);
of_node_put(remote);
return -EPROBE_DEFER;
}
of_node_put(remote);
}
imxpd->dev = dev;
ret = imx_pd_register(drm, imxpd);
if (ret)
return ret;
dev_set_drvdata(dev, imxpd);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Sascha Hauer | 163 | 41.16% | 1 | 7.69% |
Philipp Zabel | 160 | 40.40% | 6 | 46.15% |
Russell King | 24 | 6.06% | 2 | 15.38% |
Liu Ying | 23 | 5.81% | 2 | 15.38% |
Emil Renner Berthing | 13 | 3.28% | 1 | 7.69% |
Marek Vašut | 13 | 3.28% | 1 | 7.69% |
Total | 396 | 100.00% | 13 | 100.00% |
static void imx_pd_unbind(struct device *dev, struct device *master,
void *data)
{
struct imx_parallel_display *imxpd = dev_get_drvdata(dev);
if (imxpd->panel)
drm_panel_detach(imxpd->panel);
kfree(imxpd->edid);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Russell King | 16 | 32.00% | 1 | 25.00% |
Sascha Hauer | 14 | 28.00% | 1 | 25.00% |
Philipp Zabel | 13 | 26.00% | 1 | 25.00% |
Peter Seiderer | 7 | 14.00% | 1 | 25.00% |
Total | 50 | 100.00% | 4 | 100.00% |
static const struct component_ops imx_pd_ops = {
.bind = imx_pd_bind,
.unbind = imx_pd_unbind,
};
static int imx_pd_probe(struct platform_device *pdev)
{
return component_add(&pdev->dev, &imx_pd_ops);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Russell King | 23 | 100.00% | 1 | 100.00% |
Total | 23 | 100.00% | 1 | 100.00% |
static int imx_pd_remove(struct platform_device *pdev)
{
component_del(&pdev->dev, &imx_pd_ops);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Russell King | 21 | 84.00% | 1 | 50.00% |
Sascha Hauer | 4 | 16.00% | 1 | 50.00% |
Total | 25 | 100.00% | 2 | 100.00% |
static const struct of_device_id imx_pd_dt_ids[] = {
{ .compatible = "fsl,imx-parallel-display", },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, imx_pd_dt_ids);
static struct platform_driver imx_pd_driver = {
.probe = imx_pd_probe,
.remove = imx_pd_remove,
.driver = {
.of_match_table = imx_pd_dt_ids,
.name = "imx-parallel-display",
},
};
module_platform_driver(imx_pd_driver);
MODULE_DESCRIPTION("i.MX parallel display driver");
MODULE_AUTHOR("Sascha Hauer, Pengutronix");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:imx-parallel-display");
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Sascha Hauer | 545 | 38.19% | 1 | 3.12% |
Philipp Zabel | 525 | 36.79% | 11 | 34.38% |
Russell King | 142 | 9.95% | 2 | 6.25% |
Marek Vašut | 67 | 4.70% | 2 | 6.25% |
Liu Ying | 45 | 3.15% | 4 | 12.50% |
Lothar Waßmann | 44 | 3.08% | 3 | 9.38% |
Fabio Estevam | 14 | 0.98% | 2 | 6.25% |
Emil Renner Berthing | 13 | 0.91% | 1 | 3.12% |
Denis Carikli | 9 | 0.63% | 1 | 3.12% |
Jiada Wang | 7 | 0.49% | 1 | 3.12% |
Peter Seiderer | 7 | 0.49% | 1 | 3.12% |
Ville Syrjälä | 6 | 0.42% | 2 | 6.25% |
Laurent Pinchart | 3 | 0.21% | 1 | 3.12% |
Total | 1427 | 100.00% | 32 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.