Skip to content

Commit 3f588fd

Browse files
Laurent Pinchartsravnborg
authored andcommitted
drm: bridge: dw-hdmi: Split connector creation to a separate function
Isolate all the code related to connector creation to a new dw_hdmi_connector_create() function, to prepare for making connector creation optional. 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-20-laurent.pinchart+renesas@ideasonboard.com
1 parent 7be390d commit 3f588fd

File tree

1 file changed

+62
-45
lines changed

1 file changed

+62
-45
lines changed

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

Lines changed: 62 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2317,6 +2317,10 @@ static void dw_hdmi_update_phy_mask(struct dw_hdmi *hdmi)
23172317
hdmi->rxsense);
23182318
}
23192319

2320+
/* -----------------------------------------------------------------------------
2321+
* DRM Connector Operations
2322+
*/
2323+
23202324
static enum drm_connector_status
23212325
dw_hdmi_connector_detect(struct drm_connector *connector, bool force)
23222326
{
@@ -2438,6 +2442,59 @@ static const struct drm_connector_helper_funcs dw_hdmi_connector_helper_funcs =
24382442
.atomic_check = dw_hdmi_connector_atomic_check,
24392443
};
24402444

2445+
static int dw_hdmi_connector_create(struct dw_hdmi *hdmi)
2446+
{
2447+
struct drm_connector *connector = &hdmi->connector;
2448+
struct cec_connector_info conn_info;
2449+
struct cec_notifier *notifier;
2450+
2451+
if (hdmi->version >= 0x200a)
2452+
connector->ycbcr_420_allowed =
2453+
hdmi->plat_data->ycbcr_420_allowed;
2454+
else
2455+
connector->ycbcr_420_allowed = false;
2456+
2457+
connector->interlace_allowed = 1;
2458+
connector->polled = DRM_CONNECTOR_POLL_HPD;
2459+
2460+
drm_connector_helper_add(connector, &dw_hdmi_connector_helper_funcs);
2461+
2462+
drm_connector_init_with_ddc(hdmi->bridge.dev, connector,
2463+
&dw_hdmi_connector_funcs,
2464+
DRM_MODE_CONNECTOR_HDMIA,
2465+
hdmi->ddc);
2466+
2467+
/*
2468+
* drm_connector_attach_max_bpc_property() requires the
2469+
* connector to have a state.
2470+
*/
2471+
drm_atomic_helper_connector_reset(connector);
2472+
2473+
drm_connector_attach_max_bpc_property(connector, 8, 16);
2474+
2475+
if (hdmi->version >= 0x200a && hdmi->plat_data->use_drm_infoframe)
2476+
drm_object_attach_property(&connector->base,
2477+
connector->dev->mode_config.hdr_output_metadata_property, 0);
2478+
2479+
drm_connector_attach_encoder(connector, hdmi->bridge.encoder);
2480+
2481+
cec_fill_conn_info_from_drm(&conn_info, connector);
2482+
2483+
notifier = cec_notifier_conn_register(hdmi->dev, NULL, &conn_info);
2484+
if (!notifier)
2485+
return -ENOMEM;
2486+
2487+
mutex_lock(&hdmi->cec_notifier_mutex);
2488+
hdmi->cec_notifier = notifier;
2489+
mutex_unlock(&hdmi->cec_notifier_mutex);
2490+
2491+
return 0;
2492+
}
2493+
2494+
/* -----------------------------------------------------------------------------
2495+
* DRM Bridge Operations
2496+
*/
2497+
24412498
/*
24422499
* Possible output formats :
24432500
* - MEDIA_BUS_FMT_UYYVYY16_0_5X48,
@@ -2713,51 +2770,13 @@ static int dw_hdmi_bridge_attach(struct drm_bridge *bridge,
27132770
enum drm_bridge_attach_flags flags)
27142771
{
27152772
struct dw_hdmi *hdmi = bridge->driver_private;
2716-
struct drm_encoder *encoder = bridge->encoder;
2717-
struct drm_connector *connector = &hdmi->connector;
2718-
struct cec_connector_info conn_info;
2719-
struct cec_notifier *notifier;
27202773

27212774
if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) {
27222775
DRM_ERROR("Fix bridge driver to make connector optional!");
27232776
return -EINVAL;
27242777
}
27252778

2726-
connector->interlace_allowed = 1;
2727-
connector->polled = DRM_CONNECTOR_POLL_HPD;
2728-
2729-
drm_connector_helper_add(connector, &dw_hdmi_connector_helper_funcs);
2730-
2731-
drm_connector_init_with_ddc(bridge->dev, connector,
2732-
&dw_hdmi_connector_funcs,
2733-
DRM_MODE_CONNECTOR_HDMIA,
2734-
hdmi->ddc);
2735-
2736-
/*
2737-
* drm_connector_attach_max_bpc_property() requires the
2738-
* connector to have a state.
2739-
*/
2740-
drm_atomic_helper_connector_reset(connector);
2741-
2742-
drm_connector_attach_max_bpc_property(connector, 8, 16);
2743-
2744-
if (hdmi->version >= 0x200a && hdmi->plat_data->use_drm_infoframe)
2745-
drm_object_attach_property(&connector->base,
2746-
connector->dev->mode_config.hdr_output_metadata_property, 0);
2747-
2748-
drm_connector_attach_encoder(connector, encoder);
2749-
2750-
cec_fill_conn_info_from_drm(&conn_info, connector);
2751-
2752-
notifier = cec_notifier_conn_register(hdmi->dev, NULL, &conn_info);
2753-
if (!notifier)
2754-
return -ENOMEM;
2755-
2756-
mutex_lock(&hdmi->cec_notifier_mutex);
2757-
hdmi->cec_notifier = notifier;
2758-
mutex_unlock(&hdmi->cec_notifier_mutex);
2759-
2760-
return 0;
2779+
return dw_hdmi_connector_create(hdmi);
27612780
}
27622781

27632782
static void dw_hdmi_bridge_detach(struct drm_bridge *bridge)
@@ -2841,6 +2860,10 @@ static const struct drm_bridge_funcs dw_hdmi_bridge_funcs = {
28412860
.mode_valid = dw_hdmi_bridge_mode_valid,
28422861
};
28432862

2863+
/* -----------------------------------------------------------------------------
2864+
* IRQ Handling
2865+
*/
2866+
28442867
static irqreturn_t dw_hdmi_i2c_irq(struct dw_hdmi *hdmi)
28452868
{
28462869
struct dw_hdmi_i2c *i2c = hdmi->i2c;
@@ -3303,12 +3326,6 @@ __dw_hdmi_probe(struct platform_device *pdev,
33033326
hdmi->bridge.of_node = pdev->dev.of_node;
33043327
#endif
33053328

3306-
if (hdmi->version >= 0x200a)
3307-
hdmi->connector.ycbcr_420_allowed =
3308-
hdmi->plat_data->ycbcr_420_allowed;
3309-
else
3310-
hdmi->connector.ycbcr_420_allowed = false;
3311-
33123329
memset(&pdevinfo, 0, sizeof(pdevinfo));
33133330
pdevinfo.parent = dev;
33143331
pdevinfo.id = PLATFORM_DEVID_AUTO;

0 commit comments

Comments
 (0)