Skip to content

Commit ec971aa

Browse files
Laurent Pinchartsravnborg
authored andcommitted
drm: bridge: dw-hdmi: Make connector creation optional
Implement the drm_bridge_funcs .detect() and .get_edid() operations, and call drm_bridge_hpd_notify() notify to report HPD. This provides the necessary API to support disabling connector creation, do so by accepting DRM_BRIDGE_ATTACH_NO_CONNECTOR in dw_hdmi_bridge_attach(). Signed-off-by: Laurent Pinchart <[email protected]> Reviewed-by: Neil Armstrong <[email protected]> Signed-off-by: Sam Ravnborg <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/20200526011505.31884-23-laurent.pinchart+renesas@ideasonboard.com
1 parent 8198003 commit ec971aa

File tree

1 file changed

+74
-30
lines changed

1 file changed

+74
-30
lines changed

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c

Lines changed: 74 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2323,15 +2323,8 @@ static void dw_hdmi_update_phy_mask(struct dw_hdmi *hdmi)
23232323
hdmi->rxsense);
23242324
}
23252325

2326-
/* -----------------------------------------------------------------------------
2327-
* DRM Connector Operations
2328-
*/
2329-
2330-
static enum drm_connector_status
2331-
dw_hdmi_connector_detect(struct drm_connector *connector, bool force)
2326+
static enum drm_connector_status dw_hdmi_detect(struct dw_hdmi *hdmi)
23322327
{
2333-
struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi,
2334-
connector);
23352328
enum drm_connector_status result;
23362329

23372330
mutex_lock(&hdmi->mutex);
@@ -2354,31 +2347,57 @@ dw_hdmi_connector_detect(struct drm_connector *connector, bool force)
23542347
return result;
23552348
}
23562349

2357-
static int dw_hdmi_connector_get_modes(struct drm_connector *connector)
2350+
static struct edid *dw_hdmi_get_edid(struct dw_hdmi *hdmi,
2351+
struct drm_connector *connector)
23582352
{
2359-
struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi,
2360-
connector);
23612353
struct edid *edid;
2362-
int ret = 0;
23632354

23642355
if (!hdmi->ddc)
2365-
return 0;
2356+
return NULL;
23662357

23672358
edid = drm_get_edid(connector, hdmi->ddc);
2368-
if (edid) {
2369-
dev_dbg(hdmi->dev, "got edid: width[%d] x height[%d]\n",
2370-
edid->width_cm, edid->height_cm);
2371-
2372-
hdmi->sink_is_hdmi = drm_detect_hdmi_monitor(edid);
2373-
hdmi->sink_has_audio = drm_detect_monitor_audio(edid);
2374-
drm_connector_update_edid_property(connector, edid);
2375-
cec_notifier_set_phys_addr_from_edid(hdmi->cec_notifier, edid);
2376-
ret = drm_add_edid_modes(connector, edid);
2377-
kfree(edid);
2378-
} else {
2359+
if (!edid) {
23792360
dev_dbg(hdmi->dev, "failed to get edid\n");
2361+
return NULL;
23802362
}
23812363

2364+
dev_dbg(hdmi->dev, "got edid: width[%d] x height[%d]\n",
2365+
edid->width_cm, edid->height_cm);
2366+
2367+
hdmi->sink_is_hdmi = drm_detect_hdmi_monitor(edid);
2368+
hdmi->sink_has_audio = drm_detect_monitor_audio(edid);
2369+
2370+
return edid;
2371+
}
2372+
2373+
/* -----------------------------------------------------------------------------
2374+
* DRM Connector Operations
2375+
*/
2376+
2377+
static enum drm_connector_status
2378+
dw_hdmi_connector_detect(struct drm_connector *connector, bool force)
2379+
{
2380+
struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi,
2381+
connector);
2382+
return dw_hdmi_detect(hdmi);
2383+
}
2384+
2385+
static int dw_hdmi_connector_get_modes(struct drm_connector *connector)
2386+
{
2387+
struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi,
2388+
connector);
2389+
struct edid *edid;
2390+
int ret;
2391+
2392+
edid = dw_hdmi_get_edid(hdmi, connector);
2393+
if (!edid)
2394+
return 0;
2395+
2396+
drm_connector_update_edid_property(connector, edid);
2397+
cec_notifier_set_phys_addr_from_edid(hdmi->cec_notifier, edid);
2398+
ret = drm_add_edid_modes(connector, edid);
2399+
kfree(edid);
2400+
23822401
return ret;
23832402
}
23842403

@@ -2777,10 +2796,8 @@ static int dw_hdmi_bridge_attach(struct drm_bridge *bridge,
27772796
{
27782797
struct dw_hdmi *hdmi = bridge->driver_private;
27792798

2780-
if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) {
2781-
DRM_ERROR("Fix bridge driver to make connector optional!");
2782-
return -EINVAL;
2783-
}
2799+
if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
2800+
return 0;
27842801

27852802
return dw_hdmi_connector_create(hdmi);
27862803
}
@@ -2860,6 +2877,21 @@ static void dw_hdmi_bridge_atomic_enable(struct drm_bridge *bridge,
28602877
mutex_unlock(&hdmi->mutex);
28612878
}
28622879

2880+
static enum drm_connector_status dw_hdmi_bridge_detect(struct drm_bridge *bridge)
2881+
{
2882+
struct dw_hdmi *hdmi = bridge->driver_private;
2883+
2884+
return dw_hdmi_detect(hdmi);
2885+
}
2886+
2887+
static struct edid *dw_hdmi_bridge_get_edid(struct drm_bridge *bridge,
2888+
struct drm_connector *connector)
2889+
{
2890+
struct dw_hdmi *hdmi = bridge->driver_private;
2891+
2892+
return dw_hdmi_get_edid(hdmi, connector);
2893+
}
2894+
28632895
static const struct drm_bridge_funcs dw_hdmi_bridge_funcs = {
28642896
.atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
28652897
.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
@@ -2873,6 +2905,8 @@ static const struct drm_bridge_funcs dw_hdmi_bridge_funcs = {
28732905
.atomic_disable = dw_hdmi_bridge_atomic_disable,
28742906
.mode_set = dw_hdmi_bridge_mode_set,
28752907
.mode_valid = dw_hdmi_bridge_mode_valid,
2908+
.detect = dw_hdmi_bridge_detect,
2909+
.get_edid = dw_hdmi_bridge_get_edid,
28762910
};
28772911

28782912
/* -----------------------------------------------------------------------------
@@ -2988,10 +3022,18 @@ static irqreturn_t dw_hdmi_irq(int irq, void *dev_id)
29883022
}
29893023

29903024
if (intr_stat & HDMI_IH_PHY_STAT0_HPD) {
3025+
enum drm_connector_status status = phy_int_pol & HDMI_PHY_HPD
3026+
? connector_status_connected
3027+
: connector_status_disconnected;
3028+
29913029
dev_dbg(hdmi->dev, "EVENT=%s\n",
2992-
phy_int_pol & HDMI_PHY_HPD ? "plugin" : "plugout");
2993-
if (hdmi->bridge.dev)
3030+
status == connector_status_connected ?
3031+
"plugin" : "plugout");
3032+
3033+
if (hdmi->bridge.dev) {
29943034
drm_helper_hpd_irq_event(hdmi->bridge.dev);
3035+
drm_bridge_hpd_notify(&hdmi->bridge, status);
3036+
}
29953037
}
29963038

29973039
hdmi_writeb(hdmi, intr_stat, HDMI_IH_PHY_STAT0);
@@ -3337,6 +3379,8 @@ __dw_hdmi_probe(struct platform_device *pdev,
33373379

33383380
hdmi->bridge.driver_private = hdmi;
33393381
hdmi->bridge.funcs = &dw_hdmi_bridge_funcs;
3382+
hdmi->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID
3383+
| DRM_BRIDGE_OP_HPD;
33403384
#ifdef CONFIG_OF
33413385
hdmi->bridge.of_node = pdev->dev.of_node;
33423386
#endif

0 commit comments

Comments
 (0)