Skip to content

Commit 5d04b41

Browse files
committed
drm/bridge: split HDMI Audio from DRM_BRIDGE_OP_HDMI
As pointed out by Laurent, OP bits are supposed to describe operations. Split DRM_BRIDGE_OP_HDMI_AUDIO from DRM_BRIDGE_OP_HDMI instead of overloading DRM_BRIDGE_OP_HDMI. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Reviewed-by: Maxime Ripard <mripard@kernel.org> Link: https://lore.kernel.org/r/20250314-dp-hdmi-audio-v6-1-dbd228fa73d7@oss.qualcomm.com Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
1 parent 1afba39 commit 5d04b41

File tree

5 files changed

+76
-33
lines changed

5 files changed

+76
-33
lines changed

drivers/gpu/drm/bridge/lontium-lt9611.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,7 @@ static int lt9611_probe(struct i2c_client *client)
11311131
lt9611->bridge.of_node = client->dev.of_node;
11321132
lt9611->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID |
11331133
DRM_BRIDGE_OP_HPD | DRM_BRIDGE_OP_MODES |
1134-
DRM_BRIDGE_OP_HDMI;
1134+
DRM_BRIDGE_OP_HDMI | DRM_BRIDGE_OP_HDMI_AUDIO;
11351135
lt9611->bridge.type = DRM_MODE_CONNECTOR_HDMIA;
11361136
lt9611->bridge.vendor = "Lontium";
11371137
lt9611->bridge.product = "LT9611";

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,7 @@ struct dw_hdmi_qp *dw_hdmi_qp_bind(struct platform_device *pdev,
10771077
hdmi->bridge.ops = DRM_BRIDGE_OP_DETECT |
10781078
DRM_BRIDGE_OP_EDID |
10791079
DRM_BRIDGE_OP_HDMI |
1080+
DRM_BRIDGE_OP_HDMI_AUDIO |
10801081
DRM_BRIDGE_OP_HPD;
10811082
hdmi->bridge.of_node = pdev->dev.of_node;
10821083
hdmi->bridge.type = DRM_MODE_CONNECTOR_HDMIA;

drivers/gpu/drm/display/drm_bridge_connector.c

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ struct drm_bridge_connector {
9898
* HDMI connector infrastructure, if any (see &DRM_BRIDGE_OP_HDMI).
9999
*/
100100
struct drm_bridge *bridge_hdmi;
101+
/**
102+
* @bridge_hdmi_audio:
103+
*
104+
* The bridge in the chain that implements necessary support for the
105+
* HDMI Audio infrastructure, if any (see &DRM_BRIDGE_OP_HDMI_AUDIO).
106+
*/
107+
struct drm_bridge *bridge_hdmi_audio;
101108
};
102109

103110
#define to_drm_bridge_connector(x) \
@@ -433,7 +440,7 @@ static int drm_bridge_connector_audio_startup(struct drm_connector *connector)
433440
to_drm_bridge_connector(connector);
434441
struct drm_bridge *bridge;
435442

436-
bridge = bridge_connector->bridge_hdmi;
443+
bridge = bridge_connector->bridge_hdmi_audio;
437444
if (!bridge)
438445
return -EINVAL;
439446

@@ -451,7 +458,7 @@ static int drm_bridge_connector_audio_prepare(struct drm_connector *connector,
451458
to_drm_bridge_connector(connector);
452459
struct drm_bridge *bridge;
453460

454-
bridge = bridge_connector->bridge_hdmi;
461+
bridge = bridge_connector->bridge_hdmi_audio;
455462
if (!bridge)
456463
return -EINVAL;
457464

@@ -464,7 +471,7 @@ static void drm_bridge_connector_audio_shutdown(struct drm_connector *connector)
464471
to_drm_bridge_connector(connector);
465472
struct drm_bridge *bridge;
466473

467-
bridge = bridge_connector->bridge_hdmi;
474+
bridge = bridge_connector->bridge_hdmi_audio;
468475
if (!bridge)
469476
return;
470477

@@ -478,7 +485,7 @@ static int drm_bridge_connector_audio_mute_stream(struct drm_connector *connecto
478485
to_drm_bridge_connector(connector);
479486
struct drm_bridge *bridge;
480487

481-
bridge = bridge_connector->bridge_hdmi;
488+
bridge = bridge_connector->bridge_hdmi_audio;
482489
if (!bridge)
483490
return -EINVAL;
484491

@@ -576,6 +583,21 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm,
576583
max_bpc = bridge->max_bpc;
577584
}
578585

586+
if (bridge->ops & DRM_BRIDGE_OP_HDMI_AUDIO) {
587+
if (bridge_connector->bridge_hdmi_audio)
588+
return ERR_PTR(-EBUSY);
589+
590+
if (!bridge->hdmi_audio_max_i2s_playback_channels &&
591+
!bridge->hdmi_audio_spdif_playback)
592+
return ERR_PTR(-EINVAL);
593+
594+
if (!bridge->funcs->hdmi_audio_prepare ||
595+
!bridge->funcs->hdmi_audio_shutdown)
596+
return ERR_PTR(-EINVAL);
597+
598+
bridge_connector->bridge_hdmi_audio = bridge;
599+
}
600+
579601
if (!drm_bridge_get_next_bridge(bridge))
580602
connector_type = bridge->type;
581603

@@ -611,22 +633,6 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm,
611633
max_bpc);
612634
if (ret)
613635
return ERR_PTR(ret);
614-
615-
if (bridge->hdmi_audio_max_i2s_playback_channels ||
616-
bridge->hdmi_audio_spdif_playback) {
617-
if (!bridge->funcs->hdmi_audio_prepare ||
618-
!bridge->funcs->hdmi_audio_shutdown)
619-
return ERR_PTR(-EINVAL);
620-
621-
ret = drm_connector_hdmi_audio_init(connector,
622-
bridge->hdmi_audio_dev,
623-
&drm_bridge_connector_hdmi_audio_funcs,
624-
bridge->hdmi_audio_max_i2s_playback_channels,
625-
bridge->hdmi_audio_spdif_playback,
626-
bridge->hdmi_audio_dai_port);
627-
if (ret)
628-
return ERR_PTR(ret);
629-
}
630636
} else {
631637
ret = drmm_connector_init(drm, connector,
632638
&drm_bridge_connector_funcs,
@@ -635,6 +641,19 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm,
635641
return ERR_PTR(ret);
636642
}
637643

644+
if (bridge_connector->bridge_hdmi_audio) {
645+
bridge = bridge_connector->bridge_hdmi_audio;
646+
647+
ret = drm_connector_hdmi_audio_init(connector,
648+
bridge->hdmi_audio_dev,
649+
&drm_bridge_connector_hdmi_audio_funcs,
650+
bridge->hdmi_audio_max_i2s_playback_channels,
651+
bridge->hdmi_audio_spdif_playback,
652+
bridge->hdmi_audio_dai_port);
653+
if (ret)
654+
return ERR_PTR(ret);
655+
}
656+
638657
drm_connector_helper_add(connector, &drm_bridge_connector_helper_funcs);
639658

640659
if (bridge_connector->bridge_hpd)

drivers/gpu/drm/msm/hdmi/hdmi_bridge.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ int msm_hdmi_bridge_init(struct hdmi *hdmi)
515515
bridge->ops = DRM_BRIDGE_OP_HPD |
516516
DRM_BRIDGE_OP_DETECT |
517517
DRM_BRIDGE_OP_HDMI |
518+
DRM_BRIDGE_OP_HDMI_AUDIO |
518519
DRM_BRIDGE_OP_EDID;
519520
bridge->hdmi_audio_max_i2s_playback_channels = 8;
520521
bridge->hdmi_audio_dev = &hdmi->pdev->dev;

include/drm/drm_bridge.h

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -681,8 +681,10 @@ struct drm_bridge_funcs {
681681
/**
682682
* @hdmi_audio_startup:
683683
*
684-
* Called when ASoC starts an audio stream setup. The
685-
* @hdmi_audio_startup() is optional.
684+
* Called when ASoC starts an audio stream setup.
685+
*
686+
* This callback is optional, it can be implemented by bridges that
687+
* set the @DRM_BRIDGE_OP_HDMI_AUDIO flag in their &drm_bridge->ops.
686688
*
687689
* Returns:
688690
* 0 on success, a negative error code otherwise
@@ -693,8 +695,10 @@ struct drm_bridge_funcs {
693695
/**
694696
* @hdmi_audio_prepare:
695697
* Configures HDMI-encoder for audio stream. Can be called multiple
696-
* times for each setup. Mandatory if HDMI audio is enabled in the
697-
* bridge's configuration.
698+
* times for each setup.
699+
*
700+
* This callback is optional but it must be implemented by bridges that
701+
* set the @DRM_BRIDGE_OP_HDMI_AUDIO flag in their &drm_bridge->ops.
698702
*
699703
* Returns:
700704
* 0 on success, a negative error code otherwise
@@ -707,8 +711,10 @@ struct drm_bridge_funcs {
707711
/**
708712
* @hdmi_audio_shutdown:
709713
*
710-
* Shut down the audio stream. Mandatory if HDMI audio is enabled in
711-
* the bridge's configuration.
714+
* Shut down the audio stream.
715+
*
716+
* This callback is optional but it must be implemented by bridges that
717+
* set the @DRM_BRIDGE_OP_HDMI_AUDIO flag in their &drm_bridge->ops.
712718
*
713719
* Returns:
714720
* 0 on success, a negative error code otherwise
@@ -719,8 +725,10 @@ struct drm_bridge_funcs {
719725
/**
720726
* @hdmi_audio_mute_stream:
721727
*
722-
* Mute/unmute HDMI audio stream. The @hdmi_audio_mute_stream callback
723-
* is optional.
728+
* Mute/unmute HDMI audio stream.
729+
*
730+
* This callback is optional, it can be implemented by bridges that
731+
* set the @DRM_BRIDGE_OP_HDMI_AUDIO flag in their &drm_bridge->ops.
724732
*
725733
* Returns:
726734
* 0 on success, a negative error code otherwise
@@ -814,6 +822,17 @@ enum drm_bridge_ops {
814822
* drivers.
815823
*/
816824
DRM_BRIDGE_OP_HDMI = BIT(4),
825+
/**
826+
* @DRM_BRIDGE_OP_HDMI_AUDIO: The bridge provides HDMI audio operations.
827+
* Bridges that set this flag must implement the
828+
* &drm_bridge_funcs->hdmi_audio_prepare and
829+
* &drm_bridge_funcs->hdmi_audio_shutdown callbacks.
830+
*
831+
* Note: currently there can be at most one bridge in a chain that sets
832+
* this bit. This is to simplify corresponding glue code in connector
833+
* drivers.
834+
*/
835+
DRM_BRIDGE_OP_HDMI_AUDIO = BIT(5),
817836
};
818837

819838
/**
@@ -926,23 +945,26 @@ struct drm_bridge {
926945
unsigned int max_bpc;
927946

928947
/**
929-
* @hdmi_audio_dev: device to be used as a parent for the HDMI Codec
948+
* @hdmi_audio_dev: device to be used as a parent for the HDMI Codec if
949+
* @DRM_BRIDGE_OP_HDMI_AUDIO is set.
930950
*/
931951
struct device *hdmi_audio_dev;
932952

933953
/**
934954
* @hdmi_audio_max_i2s_playback_channels: maximum number of playback
935-
* I2S channels for the HDMI codec
955+
* I2S channels for the bridge that sets @DRM_BRIDGE_OP_HDMI_AUDIO.
936956
*/
937957
int hdmi_audio_max_i2s_playback_channels;
938958

939959
/**
940-
* @hdmi_audio_spdif_playback: set if HDMI codec has S/PDIF playback port
960+
* @hdmi_audio_spdif_playback: set if this bridge has S/PDIF playback
961+
* port for @DRM_BRIDGE_OP_HDMI_AUDIO
941962
*/
942963
unsigned int hdmi_audio_spdif_playback : 1;
943964

944965
/**
945-
* @hdmi_audio_dai_port: sound DAI port, -1 if it is not enabled
966+
* @hdmi_audio_dai_port: sound DAI port for @DRM_BRIDGE_OP_HDMI_AUDIO,
967+
* -1 if it is not used.
946968
*/
947969
int hdmi_audio_dai_port;
948970
};

0 commit comments

Comments
 (0)