drm: sti: allow to change hdmi ddc i2c adapter
Depending of the board configuration i2c for ddc could change, this patch allow to use a phandle to specify which i2c controller to use. Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
This commit is contained in:
parent
f41c2581bc
commit
41a14623bd
3 changed files with 29 additions and 13 deletions
|
@ -69,6 +69,7 @@ STMicroelectronics stih4xx platforms
|
||||||
- clock-names: names of the clocks listed in clocks property in the same
|
- clock-names: names of the clocks listed in clocks property in the same
|
||||||
order.
|
order.
|
||||||
- hdmi,hpd-gpio: gpio id to detect if an hdmi cable is plugged or not.
|
- hdmi,hpd-gpio: gpio id to detect if an hdmi cable is plugged or not.
|
||||||
|
- ddc: phandle of an I2C controller used for DDC EDID probing
|
||||||
|
|
||||||
sti-hda:
|
sti-hda:
|
||||||
Required properties:
|
Required properties:
|
||||||
|
|
|
@ -480,17 +480,15 @@ static const struct drm_bridge_funcs sti_hdmi_bridge_funcs = {
|
||||||
|
|
||||||
static int sti_hdmi_connector_get_modes(struct drm_connector *connector)
|
static int sti_hdmi_connector_get_modes(struct drm_connector *connector)
|
||||||
{
|
{
|
||||||
struct i2c_adapter *i2c_adap;
|
struct sti_hdmi_connector *hdmi_connector
|
||||||
|
= to_sti_hdmi_connector(connector);
|
||||||
|
struct sti_hdmi *hdmi = hdmi_connector->hdmi;
|
||||||
struct edid *edid;
|
struct edid *edid;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
DRM_DEBUG_DRIVER("\n");
|
DRM_DEBUG_DRIVER("\n");
|
||||||
|
|
||||||
i2c_adap = i2c_get_adapter(1);
|
edid = drm_get_edid(connector, hdmi->ddc_adapt);
|
||||||
if (!i2c_adap)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
edid = drm_get_edid(connector, i2c_adap);
|
|
||||||
if (!edid)
|
if (!edid)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
@ -603,29 +601,38 @@ static int sti_hdmi_bind(struct device *dev, struct device *master, void *data)
|
||||||
struct sti_hdmi_connector *connector;
|
struct sti_hdmi_connector *connector;
|
||||||
struct drm_connector *drm_connector;
|
struct drm_connector *drm_connector;
|
||||||
struct drm_bridge *bridge;
|
struct drm_bridge *bridge;
|
||||||
struct i2c_adapter *i2c_adap;
|
struct device_node *ddc;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
i2c_adap = i2c_get_adapter(1);
|
ddc = of_parse_phandle(dev->of_node, "ddc", 0);
|
||||||
if (!i2c_adap)
|
if (ddc) {
|
||||||
return -EPROBE_DEFER;
|
hdmi->ddc_adapt = of_find_i2c_adapter_by_node(ddc);
|
||||||
|
if (!hdmi->ddc_adapt) {
|
||||||
|
err = -EPROBE_DEFER;
|
||||||
|
of_node_put(ddc);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
of_node_put(ddc);
|
||||||
|
}
|
||||||
|
|
||||||
/* Set the drm device handle */
|
/* Set the drm device handle */
|
||||||
hdmi->drm_dev = drm_dev;
|
hdmi->drm_dev = drm_dev;
|
||||||
|
|
||||||
encoder = sti_hdmi_find_encoder(drm_dev);
|
encoder = sti_hdmi_find_encoder(drm_dev);
|
||||||
if (!encoder)
|
if (!encoder)
|
||||||
return -ENOMEM;
|
goto err_adapt;
|
||||||
|
|
||||||
connector = devm_kzalloc(dev, sizeof(*connector), GFP_KERNEL);
|
connector = devm_kzalloc(dev, sizeof(*connector), GFP_KERNEL);
|
||||||
if (!connector)
|
if (!connector)
|
||||||
return -ENOMEM;
|
goto err_adapt;
|
||||||
|
|
||||||
|
|
||||||
connector->hdmi = hdmi;
|
connector->hdmi = hdmi;
|
||||||
|
|
||||||
bridge = devm_kzalloc(dev, sizeof(*bridge), GFP_KERNEL);
|
bridge = devm_kzalloc(dev, sizeof(*bridge), GFP_KERNEL);
|
||||||
if (!bridge)
|
if (!bridge)
|
||||||
return -ENOMEM;
|
goto err_adapt;
|
||||||
|
|
||||||
bridge->driver_private = hdmi;
|
bridge->driver_private = hdmi;
|
||||||
drm_bridge_init(drm_dev, bridge, &sti_hdmi_bridge_funcs);
|
drm_bridge_init(drm_dev, bridge, &sti_hdmi_bridge_funcs);
|
||||||
|
@ -662,6 +669,8 @@ err_sysfs:
|
||||||
err_connector:
|
err_connector:
|
||||||
drm_bridge_cleanup(bridge);
|
drm_bridge_cleanup(bridge);
|
||||||
drm_connector_cleanup(drm_connector);
|
drm_connector_cleanup(drm_connector);
|
||||||
|
err_adapt:
|
||||||
|
put_device(&hdmi->ddc_adapt->dev);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -788,6 +797,11 @@ static int sti_hdmi_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
static int sti_hdmi_remove(struct platform_device *pdev)
|
static int sti_hdmi_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
|
struct sti_hdmi *hdmi = dev_get_drvdata(&pdev->dev);
|
||||||
|
|
||||||
|
if (hdmi->ddc_adapt)
|
||||||
|
put_device(&hdmi->ddc_adapt->dev);
|
||||||
|
|
||||||
component_del(&pdev->dev, &sti_hdmi_ops);
|
component_del(&pdev->dev, &sti_hdmi_ops);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,7 @@ struct sti_hdmi {
|
||||||
wait_queue_head_t wait_event;
|
wait_queue_head_t wait_event;
|
||||||
bool event_received;
|
bool event_received;
|
||||||
struct reset_control *reset;
|
struct reset_control *reset;
|
||||||
|
struct i2c_adapter *ddc_adapt;
|
||||||
};
|
};
|
||||||
|
|
||||||
u32 hdmi_read(struct sti_hdmi *hdmi, int offset);
|
u32 hdmi_read(struct sti_hdmi *hdmi, int offset);
|
||||||
|
|
Loading…
Add table
Reference in a new issue