-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'topic/drm-misc-2016-10-11' of git://anongit.freedesktop.or…
…g/drm-intel into drm-next Just flushing out my -misc queue. Slightly important are the prime refcount/unload fixes from Chris. There's also the reservation stuff from Chris still pending, and Sumits hasn't landed that yet. Might get another pull for that, but pls don't hold up the main pull for it ;-) * tag 'topic/drm-misc-2016-10-11' of git://anongit.freedesktop.org/drm-intel: drm/crtc: constify drm_crtc_index parameter drm: use the right function name in documentation drm: Release resources with a safer function drm: Fix up kerneldoc for new drm_gem_dmabuf_export() drm/bridge: Drop drm_connector_unregister and call drm_connector_cleanup directly drm/fb-helper: fix sphinx markup for DRM_FB_HELPER_DEFAULT_OPS drm/bridge: Add RGB to VGA bridge support drm/prime: Take a ref on the drm_dev when exporting a dma_buf drm/prime: Pass the right module owner through to dma_buf_export() drm/bridge: Call drm_connector_cleanup directly drm: simple_kms_helper: Add prepare_fb and cleanup_fb hooks drm: Release resources with a safer function
- Loading branch information
Showing
22 changed files
with
391 additions
and
63 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
Documentation/devicetree/bindings/display/bridge/dumb-vga-dac.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
Dumb RGB to VGA DAC bridge | ||
--------------------------- | ||
|
||
This binding is aimed for dumb RGB to VGA DAC based bridges that do not require | ||
any configuration. | ||
|
||
Required properties: | ||
|
||
- compatible: Must be "dumb-vga-dac" | ||
|
||
Required nodes: | ||
|
||
This device has two video ports. Their connections are modelled using the OF | ||
graph bindings specified in Documentation/devicetree/bindings/graph.txt. | ||
|
||
- Video port 0 for RGB input | ||
- Video port 1 for VGA output | ||
|
||
|
||
Example | ||
------- | ||
|
||
bridge { | ||
compatible = "dumb-vga-dac"; | ||
#address-cells = <1>; | ||
#size-cells = <0>; | ||
|
||
ports { | ||
#address-cells = <1>; | ||
#size-cells = <0>; | ||
|
||
port@0 { | ||
reg = <0>; | ||
|
||
vga_bridge_in: endpoint { | ||
remote-endpoint = <&tcon0_out_vga>; | ||
}; | ||
}; | ||
|
||
port@1 { | ||
reg = <1>; | ||
|
||
vga_bridge_out: endpoint { | ||
remote-endpoint = <&vga_con_in>; | ||
}; | ||
}; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,223 @@ | ||
/* | ||
* Copyright (C) 2015-2016 Free Electrons | ||
* Copyright (C) 2015-2016 NextThing Co | ||
* | ||
* Maxime Ripard <maxime.ripard@free-electrons.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/module.h> | ||
#include <linux/of_graph.h> | ||
|
||
#include <drm/drmP.h> | ||
#include <drm/drm_atomic_helper.h> | ||
#include <drm/drm_crtc.h> | ||
#include <drm/drm_crtc_helper.h> | ||
|
||
struct dumb_vga { | ||
struct drm_bridge bridge; | ||
struct drm_connector connector; | ||
|
||
struct i2c_adapter *ddc; | ||
}; | ||
|
||
static inline struct dumb_vga * | ||
drm_bridge_to_dumb_vga(struct drm_bridge *bridge) | ||
{ | ||
return container_of(bridge, struct dumb_vga, bridge); | ||
} | ||
|
||
static inline struct dumb_vga * | ||
drm_connector_to_dumb_vga(struct drm_connector *connector) | ||
{ | ||
return container_of(connector, struct dumb_vga, connector); | ||
} | ||
|
||
static int dumb_vga_get_modes(struct drm_connector *connector) | ||
{ | ||
struct dumb_vga *vga = drm_connector_to_dumb_vga(connector); | ||
struct edid *edid; | ||
int ret; | ||
|
||
if (IS_ERR(vga->ddc)) | ||
goto fallback; | ||
|
||
edid = drm_get_edid(connector, vga->ddc); | ||
if (!edid) { | ||
DRM_INFO("EDID readout failed, falling back to standard modes\n"); | ||
goto fallback; | ||
} | ||
|
||
drm_mode_connector_update_edid_property(connector, edid); | ||
return drm_add_edid_modes(connector, edid); | ||
|
||
fallback: | ||
/* | ||
* In case we cannot retrieve the EDIDs (broken or missing i2c | ||
* bus), fallback on the XGA standards | ||
*/ | ||
ret = drm_add_modes_noedid(connector, 1920, 1200); | ||
|
||
/* And prefer a mode pretty much anyone can handle */ | ||
drm_set_preferred_mode(connector, 1024, 768); | ||
|
||
return ret; | ||
} | ||
|
||
static const struct drm_connector_helper_funcs dumb_vga_con_helper_funcs = { | ||
.get_modes = dumb_vga_get_modes, | ||
}; | ||
|
||
static enum drm_connector_status | ||
dumb_vga_connector_detect(struct drm_connector *connector, bool force) | ||
{ | ||
struct dumb_vga *vga = drm_connector_to_dumb_vga(connector); | ||
|
||
/* | ||
* Even if we have an I2C bus, we can't assume that the cable | ||
* is disconnected if drm_probe_ddc fails. Some cables don't | ||
* wire the DDC pins, or the I2C bus might not be working at | ||
* all. | ||
*/ | ||
if (!IS_ERR(vga->ddc) && drm_probe_ddc(vga->ddc)) | ||
return connector_status_connected; | ||
|
||
return connector_status_unknown; | ||
} | ||
|
||
static const struct drm_connector_funcs dumb_vga_con_funcs = { | ||
.dpms = drm_atomic_helper_connector_dpms, | ||
.detect = dumb_vga_connector_detect, | ||
.fill_modes = drm_helper_probe_single_connector_modes, | ||
.destroy = drm_connector_cleanup, | ||
.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 int dumb_vga_attach(struct drm_bridge *bridge) | ||
{ | ||
struct dumb_vga *vga = drm_bridge_to_dumb_vga(bridge); | ||
int ret; | ||
|
||
if (!bridge->encoder) { | ||
DRM_ERROR("Missing encoder\n"); | ||
return -ENODEV; | ||
} | ||
|
||
drm_connector_helper_add(&vga->connector, | ||
&dumb_vga_con_helper_funcs); | ||
ret = drm_connector_init(bridge->dev, &vga->connector, | ||
&dumb_vga_con_funcs, DRM_MODE_CONNECTOR_VGA); | ||
if (ret) { | ||
DRM_ERROR("Failed to initialize connector\n"); | ||
return ret; | ||
} | ||
|
||
drm_mode_connector_attach_encoder(&vga->connector, | ||
bridge->encoder); | ||
|
||
return 0; | ||
} | ||
|
||
static const struct drm_bridge_funcs dumb_vga_bridge_funcs = { | ||
.attach = dumb_vga_attach, | ||
}; | ||
|
||
static struct i2c_adapter *dumb_vga_retrieve_ddc(struct device *dev) | ||
{ | ||
struct device_node *end_node, *phandle, *remote; | ||
struct i2c_adapter *ddc; | ||
|
||
end_node = of_graph_get_endpoint_by_regs(dev->of_node, 1, -1); | ||
if (!end_node) { | ||
dev_err(dev, "Missing connector endpoint\n"); | ||
return ERR_PTR(-ENODEV); | ||
} | ||
|
||
remote = of_graph_get_remote_port_parent(end_node); | ||
of_node_put(end_node); | ||
if (!remote) { | ||
dev_err(dev, "Enable to parse remote node\n"); | ||
return ERR_PTR(-EINVAL); | ||
} | ||
|
||
phandle = of_parse_phandle(remote, "ddc-i2c-bus", 0); | ||
of_node_put(remote); | ||
if (!phandle) | ||
return ERR_PTR(-ENODEV); | ||
|
||
ddc = of_get_i2c_adapter_by_node(phandle); | ||
of_node_put(phandle); | ||
if (!ddc) | ||
return ERR_PTR(-EPROBE_DEFER); | ||
|
||
return ddc; | ||
} | ||
|
||
static int dumb_vga_probe(struct platform_device *pdev) | ||
{ | ||
struct dumb_vga *vga; | ||
int ret; | ||
|
||
vga = devm_kzalloc(&pdev->dev, sizeof(*vga), GFP_KERNEL); | ||
if (!vga) | ||
return -ENOMEM; | ||
platform_set_drvdata(pdev, vga); | ||
|
||
vga->ddc = dumb_vga_retrieve_ddc(&pdev->dev); | ||
if (IS_ERR(vga->ddc)) { | ||
if (PTR_ERR(vga->ddc) == -ENODEV) { | ||
dev_dbg(&pdev->dev, | ||
"No i2c bus specified. Disabling EDID readout\n"); | ||
} else { | ||
dev_err(&pdev->dev, "Couldn't retrieve i2c bus\n"); | ||
return PTR_ERR(vga->ddc); | ||
} | ||
} | ||
|
||
vga->bridge.funcs = &dumb_vga_bridge_funcs; | ||
vga->bridge.of_node = pdev->dev.of_node; | ||
|
||
ret = drm_bridge_add(&vga->bridge); | ||
if (ret && !IS_ERR(vga->ddc)) | ||
i2c_put_adapter(vga->ddc); | ||
|
||
return ret; | ||
} | ||
|
||
static int dumb_vga_remove(struct platform_device *pdev) | ||
{ | ||
struct dumb_vga *vga = platform_get_drvdata(pdev); | ||
|
||
drm_bridge_remove(&vga->bridge); | ||
|
||
if (!IS_ERR(vga->ddc)) | ||
i2c_put_adapter(vga->ddc); | ||
|
||
return 0; | ||
} | ||
|
||
static const struct of_device_id dumb_vga_match[] = { | ||
{ .compatible = "dumb-vga-dac" }, | ||
{}, | ||
}; | ||
MODULE_DEVICE_TABLE(of, dumb_vga_match); | ||
|
||
static struct platform_driver dumb_vga_driver = { | ||
.probe = dumb_vga_probe, | ||
.remove = dumb_vga_remove, | ||
.driver = { | ||
.name = "dumb-vga-dac", | ||
.of_match_table = dumb_vga_match, | ||
}, | ||
}; | ||
module_platform_driver(dumb_vga_driver); | ||
|
||
MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>"); | ||
MODULE_DESCRIPTION("Dumb VGA DAC bridge driver"); | ||
MODULE_LICENSE("GPL"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.