mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	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>
This commit is contained in:
		
							parent
							
								
									1afba39f93
								
							
						
					
					
						commit
						5d04b41889
					
				
					 5 changed files with 76 additions and 33 deletions
				
			
		| 
						 | 
					@ -1131,7 +1131,7 @@ static int lt9611_probe(struct i2c_client *client)
 | 
				
			||||||
	lt9611->bridge.of_node = client->dev.of_node;
 | 
						lt9611->bridge.of_node = client->dev.of_node;
 | 
				
			||||||
	lt9611->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID |
 | 
						lt9611->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID |
 | 
				
			||||||
			     DRM_BRIDGE_OP_HPD | DRM_BRIDGE_OP_MODES |
 | 
								     DRM_BRIDGE_OP_HPD | DRM_BRIDGE_OP_MODES |
 | 
				
			||||||
			     DRM_BRIDGE_OP_HDMI;
 | 
								     DRM_BRIDGE_OP_HDMI | DRM_BRIDGE_OP_HDMI_AUDIO;
 | 
				
			||||||
	lt9611->bridge.type = DRM_MODE_CONNECTOR_HDMIA;
 | 
						lt9611->bridge.type = DRM_MODE_CONNECTOR_HDMIA;
 | 
				
			||||||
	lt9611->bridge.vendor = "Lontium";
 | 
						lt9611->bridge.vendor = "Lontium";
 | 
				
			||||||
	lt9611->bridge.product = "LT9611";
 | 
						lt9611->bridge.product = "LT9611";
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1077,6 +1077,7 @@ struct dw_hdmi_qp *dw_hdmi_qp_bind(struct platform_device *pdev,
 | 
				
			||||||
	hdmi->bridge.ops = DRM_BRIDGE_OP_DETECT |
 | 
						hdmi->bridge.ops = DRM_BRIDGE_OP_DETECT |
 | 
				
			||||||
			   DRM_BRIDGE_OP_EDID |
 | 
								   DRM_BRIDGE_OP_EDID |
 | 
				
			||||||
			   DRM_BRIDGE_OP_HDMI |
 | 
								   DRM_BRIDGE_OP_HDMI |
 | 
				
			||||||
 | 
								   DRM_BRIDGE_OP_HDMI_AUDIO |
 | 
				
			||||||
			   DRM_BRIDGE_OP_HPD;
 | 
								   DRM_BRIDGE_OP_HPD;
 | 
				
			||||||
	hdmi->bridge.of_node = pdev->dev.of_node;
 | 
						hdmi->bridge.of_node = pdev->dev.of_node;
 | 
				
			||||||
	hdmi->bridge.type = DRM_MODE_CONNECTOR_HDMIA;
 | 
						hdmi->bridge.type = DRM_MODE_CONNECTOR_HDMIA;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -98,6 +98,13 @@ struct drm_bridge_connector {
 | 
				
			||||||
	 * HDMI connector infrastructure, if any (see &DRM_BRIDGE_OP_HDMI).
 | 
						 * HDMI connector infrastructure, if any (see &DRM_BRIDGE_OP_HDMI).
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	struct drm_bridge *bridge_hdmi;
 | 
						struct drm_bridge *bridge_hdmi;
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * @bridge_hdmi_audio:
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * The bridge in the chain that implements necessary support for the
 | 
				
			||||||
 | 
						 * HDMI Audio infrastructure, if any (see &DRM_BRIDGE_OP_HDMI_AUDIO).
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						struct drm_bridge *bridge_hdmi_audio;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define to_drm_bridge_connector(x) \
 | 
					#define to_drm_bridge_connector(x) \
 | 
				
			||||||
| 
						 | 
					@ -433,7 +440,7 @@ static int drm_bridge_connector_audio_startup(struct drm_connector *connector)
 | 
				
			||||||
		to_drm_bridge_connector(connector);
 | 
							to_drm_bridge_connector(connector);
 | 
				
			||||||
	struct drm_bridge *bridge;
 | 
						struct drm_bridge *bridge;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bridge = bridge_connector->bridge_hdmi;
 | 
						bridge = bridge_connector->bridge_hdmi_audio;
 | 
				
			||||||
	if (!bridge)
 | 
						if (!bridge)
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -451,7 +458,7 @@ static int drm_bridge_connector_audio_prepare(struct drm_connector *connector,
 | 
				
			||||||
		to_drm_bridge_connector(connector);
 | 
							to_drm_bridge_connector(connector);
 | 
				
			||||||
	struct drm_bridge *bridge;
 | 
						struct drm_bridge *bridge;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bridge = bridge_connector->bridge_hdmi;
 | 
						bridge = bridge_connector->bridge_hdmi_audio;
 | 
				
			||||||
	if (!bridge)
 | 
						if (!bridge)
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -464,7 +471,7 @@ static void drm_bridge_connector_audio_shutdown(struct drm_connector *connector)
 | 
				
			||||||
		to_drm_bridge_connector(connector);
 | 
							to_drm_bridge_connector(connector);
 | 
				
			||||||
	struct drm_bridge *bridge;
 | 
						struct drm_bridge *bridge;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bridge = bridge_connector->bridge_hdmi;
 | 
						bridge = bridge_connector->bridge_hdmi_audio;
 | 
				
			||||||
	if (!bridge)
 | 
						if (!bridge)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -478,7 +485,7 @@ static int drm_bridge_connector_audio_mute_stream(struct drm_connector *connecto
 | 
				
			||||||
		to_drm_bridge_connector(connector);
 | 
							to_drm_bridge_connector(connector);
 | 
				
			||||||
	struct drm_bridge *bridge;
 | 
						struct drm_bridge *bridge;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bridge = bridge_connector->bridge_hdmi;
 | 
						bridge = bridge_connector->bridge_hdmi_audio;
 | 
				
			||||||
	if (!bridge)
 | 
						if (!bridge)
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -576,6 +583,21 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm,
 | 
				
			||||||
				max_bpc = bridge->max_bpc;
 | 
									max_bpc = bridge->max_bpc;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (bridge->ops & DRM_BRIDGE_OP_HDMI_AUDIO) {
 | 
				
			||||||
 | 
								if (bridge_connector->bridge_hdmi_audio)
 | 
				
			||||||
 | 
									return ERR_PTR(-EBUSY);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (!bridge->hdmi_audio_max_i2s_playback_channels &&
 | 
				
			||||||
 | 
								    !bridge->hdmi_audio_spdif_playback)
 | 
				
			||||||
 | 
									return ERR_PTR(-EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (!bridge->funcs->hdmi_audio_prepare ||
 | 
				
			||||||
 | 
								    !bridge->funcs->hdmi_audio_shutdown)
 | 
				
			||||||
 | 
									return ERR_PTR(-EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								bridge_connector->bridge_hdmi_audio = bridge;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (!drm_bridge_get_next_bridge(bridge))
 | 
							if (!drm_bridge_get_next_bridge(bridge))
 | 
				
			||||||
			connector_type = bridge->type;
 | 
								connector_type = bridge->type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -611,22 +633,6 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm,
 | 
				
			||||||
					       max_bpc);
 | 
										       max_bpc);
 | 
				
			||||||
		if (ret)
 | 
							if (ret)
 | 
				
			||||||
			return ERR_PTR(ret);
 | 
								return ERR_PTR(ret);
 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (bridge->hdmi_audio_max_i2s_playback_channels ||
 | 
					 | 
				
			||||||
		    bridge->hdmi_audio_spdif_playback) {
 | 
					 | 
				
			||||||
			if (!bridge->funcs->hdmi_audio_prepare ||
 | 
					 | 
				
			||||||
			    !bridge->funcs->hdmi_audio_shutdown)
 | 
					 | 
				
			||||||
				return ERR_PTR(-EINVAL);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			ret = drm_connector_hdmi_audio_init(connector,
 | 
					 | 
				
			||||||
							    bridge->hdmi_audio_dev,
 | 
					 | 
				
			||||||
							    &drm_bridge_connector_hdmi_audio_funcs,
 | 
					 | 
				
			||||||
							    bridge->hdmi_audio_max_i2s_playback_channels,
 | 
					 | 
				
			||||||
							    bridge->hdmi_audio_spdif_playback,
 | 
					 | 
				
			||||||
							    bridge->hdmi_audio_dai_port);
 | 
					 | 
				
			||||||
			if (ret)
 | 
					 | 
				
			||||||
				return ERR_PTR(ret);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		ret = drmm_connector_init(drm, connector,
 | 
							ret = drmm_connector_init(drm, connector,
 | 
				
			||||||
					  &drm_bridge_connector_funcs,
 | 
										  &drm_bridge_connector_funcs,
 | 
				
			||||||
| 
						 | 
					@ -635,6 +641,19 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm,
 | 
				
			||||||
			return ERR_PTR(ret);
 | 
								return ERR_PTR(ret);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (bridge_connector->bridge_hdmi_audio) {
 | 
				
			||||||
 | 
							bridge = bridge_connector->bridge_hdmi_audio;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							ret = drm_connector_hdmi_audio_init(connector,
 | 
				
			||||||
 | 
											    bridge->hdmi_audio_dev,
 | 
				
			||||||
 | 
											    &drm_bridge_connector_hdmi_audio_funcs,
 | 
				
			||||||
 | 
											    bridge->hdmi_audio_max_i2s_playback_channels,
 | 
				
			||||||
 | 
											    bridge->hdmi_audio_spdif_playback,
 | 
				
			||||||
 | 
											    bridge->hdmi_audio_dai_port);
 | 
				
			||||||
 | 
							if (ret)
 | 
				
			||||||
 | 
								return ERR_PTR(ret);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	drm_connector_helper_add(connector, &drm_bridge_connector_helper_funcs);
 | 
						drm_connector_helper_add(connector, &drm_bridge_connector_helper_funcs);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (bridge_connector->bridge_hpd)
 | 
						if (bridge_connector->bridge_hpd)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -515,6 +515,7 @@ int msm_hdmi_bridge_init(struct hdmi *hdmi)
 | 
				
			||||||
	bridge->ops = DRM_BRIDGE_OP_HPD |
 | 
						bridge->ops = DRM_BRIDGE_OP_HPD |
 | 
				
			||||||
		DRM_BRIDGE_OP_DETECT |
 | 
							DRM_BRIDGE_OP_DETECT |
 | 
				
			||||||
		DRM_BRIDGE_OP_HDMI |
 | 
							DRM_BRIDGE_OP_HDMI |
 | 
				
			||||||
 | 
							DRM_BRIDGE_OP_HDMI_AUDIO |
 | 
				
			||||||
		DRM_BRIDGE_OP_EDID;
 | 
							DRM_BRIDGE_OP_EDID;
 | 
				
			||||||
	bridge->hdmi_audio_max_i2s_playback_channels = 8;
 | 
						bridge->hdmi_audio_max_i2s_playback_channels = 8;
 | 
				
			||||||
	bridge->hdmi_audio_dev = &hdmi->pdev->dev;
 | 
						bridge->hdmi_audio_dev = &hdmi->pdev->dev;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -681,8 +681,10 @@ struct drm_bridge_funcs {
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * @hdmi_audio_startup:
 | 
						 * @hdmi_audio_startup:
 | 
				
			||||||
	 *
 | 
						 *
 | 
				
			||||||
	 * Called when ASoC starts an audio stream setup. The
 | 
						 * Called when ASoC starts an audio stream setup.
 | 
				
			||||||
	 * @hdmi_audio_startup() is optional.
 | 
						 *
 | 
				
			||||||
 | 
						 * This callback is optional, it can be implemented by bridges that
 | 
				
			||||||
 | 
						 * set the @DRM_BRIDGE_OP_HDMI_AUDIO flag in their &drm_bridge->ops.
 | 
				
			||||||
	 *
 | 
						 *
 | 
				
			||||||
	 * Returns:
 | 
						 * Returns:
 | 
				
			||||||
	 * 0 on success, a negative error code otherwise
 | 
						 * 0 on success, a negative error code otherwise
 | 
				
			||||||
| 
						 | 
					@ -693,8 +695,10 @@ struct drm_bridge_funcs {
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * @hdmi_audio_prepare:
 | 
						 * @hdmi_audio_prepare:
 | 
				
			||||||
	 * Configures HDMI-encoder for audio stream. Can be called multiple
 | 
						 * Configures HDMI-encoder for audio stream. Can be called multiple
 | 
				
			||||||
	 * times for each setup. Mandatory if HDMI audio is enabled in the
 | 
						 * times for each setup.
 | 
				
			||||||
	 * bridge's configuration.
 | 
						 *
 | 
				
			||||||
 | 
						 * This callback is optional but it must be implemented by bridges that
 | 
				
			||||||
 | 
						 * set the @DRM_BRIDGE_OP_HDMI_AUDIO flag in their &drm_bridge->ops.
 | 
				
			||||||
	 *
 | 
						 *
 | 
				
			||||||
	 * Returns:
 | 
						 * Returns:
 | 
				
			||||||
	 * 0 on success, a negative error code otherwise
 | 
						 * 0 on success, a negative error code otherwise
 | 
				
			||||||
| 
						 | 
					@ -707,8 +711,10 @@ struct drm_bridge_funcs {
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * @hdmi_audio_shutdown:
 | 
						 * @hdmi_audio_shutdown:
 | 
				
			||||||
	 *
 | 
						 *
 | 
				
			||||||
	 * Shut down the audio stream. Mandatory if HDMI audio is enabled in
 | 
						 * Shut down the audio stream.
 | 
				
			||||||
	 * the bridge's configuration.
 | 
						 *
 | 
				
			||||||
 | 
						 * This callback is optional but it must be implemented by bridges that
 | 
				
			||||||
 | 
						 * set the @DRM_BRIDGE_OP_HDMI_AUDIO flag in their &drm_bridge->ops.
 | 
				
			||||||
	 *
 | 
						 *
 | 
				
			||||||
	 * Returns:
 | 
						 * Returns:
 | 
				
			||||||
	 * 0 on success, a negative error code otherwise
 | 
						 * 0 on success, a negative error code otherwise
 | 
				
			||||||
| 
						 | 
					@ -719,8 +725,10 @@ struct drm_bridge_funcs {
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * @hdmi_audio_mute_stream:
 | 
						 * @hdmi_audio_mute_stream:
 | 
				
			||||||
	 *
 | 
						 *
 | 
				
			||||||
	 * Mute/unmute HDMI audio stream. The @hdmi_audio_mute_stream callback
 | 
						 * Mute/unmute HDMI audio stream.
 | 
				
			||||||
	 * is optional.
 | 
						 *
 | 
				
			||||||
 | 
						 * This callback is optional, it can be implemented by bridges that
 | 
				
			||||||
 | 
						 * set the @DRM_BRIDGE_OP_HDMI_AUDIO flag in their &drm_bridge->ops.
 | 
				
			||||||
	 *
 | 
						 *
 | 
				
			||||||
	 * Returns:
 | 
						 * Returns:
 | 
				
			||||||
	 * 0 on success, a negative error code otherwise
 | 
						 * 0 on success, a negative error code otherwise
 | 
				
			||||||
| 
						 | 
					@ -814,6 +822,17 @@ enum drm_bridge_ops {
 | 
				
			||||||
	 * drivers.
 | 
						 * drivers.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	DRM_BRIDGE_OP_HDMI = BIT(4),
 | 
						DRM_BRIDGE_OP_HDMI = BIT(4),
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * @DRM_BRIDGE_OP_HDMI_AUDIO: The bridge provides HDMI audio operations.
 | 
				
			||||||
 | 
						 * Bridges that set this flag must implement the
 | 
				
			||||||
 | 
						 * &drm_bridge_funcs->hdmi_audio_prepare and
 | 
				
			||||||
 | 
						 * &drm_bridge_funcs->hdmi_audio_shutdown callbacks.
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * Note: currently there can be at most one bridge in a chain that sets
 | 
				
			||||||
 | 
						 * this bit. This is to simplify corresponding glue code in connector
 | 
				
			||||||
 | 
						 * drivers.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						DRM_BRIDGE_OP_HDMI_AUDIO = BIT(5),
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					@ -926,23 +945,26 @@ struct drm_bridge {
 | 
				
			||||||
	unsigned int max_bpc;
 | 
						unsigned int max_bpc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * @hdmi_audio_dev: device to be used as a parent for the HDMI Codec
 | 
						 * @hdmi_audio_dev: device to be used as a parent for the HDMI Codec if
 | 
				
			||||||
 | 
						 * @DRM_BRIDGE_OP_HDMI_AUDIO is set.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	struct device *hdmi_audio_dev;
 | 
						struct device *hdmi_audio_dev;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * @hdmi_audio_max_i2s_playback_channels: maximum number of playback
 | 
						 * @hdmi_audio_max_i2s_playback_channels: maximum number of playback
 | 
				
			||||||
	 * I2S channels for the HDMI codec
 | 
						 * I2S channels for the bridge that sets @DRM_BRIDGE_OP_HDMI_AUDIO.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	int hdmi_audio_max_i2s_playback_channels;
 | 
						int hdmi_audio_max_i2s_playback_channels;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * @hdmi_audio_spdif_playback: set if HDMI codec has S/PDIF playback port
 | 
						 * @hdmi_audio_spdif_playback: set if this bridge has S/PDIF playback
 | 
				
			||||||
 | 
						 * port for @DRM_BRIDGE_OP_HDMI_AUDIO
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	unsigned int hdmi_audio_spdif_playback : 1;
 | 
						unsigned int hdmi_audio_spdif_playback : 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * @hdmi_audio_dai_port: sound DAI port, -1 if it is not enabled
 | 
						 * @hdmi_audio_dai_port: sound DAI port for @DRM_BRIDGE_OP_HDMI_AUDIO,
 | 
				
			||||||
 | 
						 * -1 if it is not used.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	int hdmi_audio_dai_port;
 | 
						int hdmi_audio_dai_port;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue