drm: add support for Cadence MHDP DPI/DP bridge.
Subsystems (6)
v7 cover drm: add support for Cadence MHDP DPI/DP bridge.
Hello!
This is the series of patches that will add support for the Cadence's DPI/DP bridge. Please note that this is a preliminary version of the driver and there will be more patches in the future with updates, fixes and improvements. Please keep that in mind when looking at FIXME/TODO/XXX comments.
Initially, MHDP driver was developed as a DRM bridge driver and was planed to be placed in drivers/gpu/drm/bridge/mhdp.c. However, there was already a driver for Cadence's DP controller developed by RockChip, but that driver uses the different DRM framework and looks like a part of a bigger system. Both controllers (including firmware) are quite different internally (MST/FEC/DSC support, link training done by driver, additional commands, IRQ's etc.) but they have similar register map, except for Framer/Streamer (which is noticeably different), so they appear similar.
The following patches contain:
- Moving common code to drivers/gpu/drm/bridge/cdns-mhdp-common.* and modifying it a bit (mostly new prefixes for functions and data types) so it can be used by two, higher level, drivers.
- Modifying existing RockChip's DP driver to use the common code after changes made to it (use the new cdns_mhdp_device structure and new function names).
- Modifying DRM helpers a bit. Some are required for new driver, some are updates from DP 1.2 to 1.3 or 1.4.
- Adding documentation for device tree bindings.
- Adding preliminary Cadence DPI/DP bridge driver.
Some of the things that will be added later on include (but are not limited to):
- DSC support
- FEC support
- HDCP support
Changes in v7:
- Overal code cleanup
- Patched memory leak after EDID read
- Fixed SPDX-License-Identifier tags
- Sorted includes
- In patch 4/6:
Cleanup and fix in mhdp_transfer
Replaced byteshifts with {put|get}_unaligned_be{32|24|16} (added 24bit one)
- In patch 5/6:
Removed cdns_mhdp_mst_set_threshold (not needed anymore as HW does that) Updated cdns_mhdp_mst_set_rate_governing
Replaced request_irq with devm_request_irq
And then merged with 4/6 (as many changes in this patch altered the SST part)
- In patch 6/6:
Fix in checking devm_phy_get result
Updated bindings doc
And then merged with 4/6 (as this should be in the driver in the first place)
Changes in v6:
- Added Reviewed-bys for already reviewed patches
- Dropped patch v5-0003 (that made dp_get_lane_status helper public)
- Added patch with MST support
- Added patch with Cadence SD0801 PHY init
Changes in v5:
- Fixed Kconfig in drm/rockchip again
- Moved cdn-dp-reg.h (cdns-mhdp-common.h) to include/drm/bridge instead of drivers/gpu/drm/bridge/
- Updated the mhdp_validate_cr function
Changes in v4:
- Fixed Kconfig in drm/rockchip
- Fixed Signed-offs
- dp_link_status() is no longer public since it's used only in drm_dp_helper.c
- Replaced EXTRA_CFLAGS with ccflags-y in drm/rockchip Makefile
Changes in v3:
- Corrected dt-bindings document
- Enabled some clocks at startup (since FW doesn't do that anymore).
- Changed Firmware file name to match the file on Linux Firmware repo.
- Added SST audio support
- Made common functions (in cdns-mhdp-common.*) public.
Changes in v2:
- Added actual description of what the patch contains, what is it for and what's going on here in general.
- New structure. Now we have one common low level driver + two high level drivers - one for RockChip with minimum changes and one, more general, for Cadence.
- Dropped some changes made to DRM helpers.
- Updated the device tree bindings document.
Damian Kos (1):
drm/rockchip: prepare common code for cdns and rk dpi/dp driver
Quentin Schulz (3):
drm/dp: fix link probing for devices supporting DP 1.4+
dt-bindings: drm/bridge: Document Cadence MHDP bridge bindings
drm: bridge: add support for Cadence MHDP DPI/DP bridge
.../bindings/display/bridge/cdns,mhdp.txt | 47 + drivers/gpu/drm/bridge/Kconfig | 9 + drivers/gpu/drm/bridge/Makefile | 3 + drivers/gpu/drm/bridge/cdns-mhdp-common.c | 1103 ++++++++++++++ drivers/gpu/drm/bridge/cdns-mhdp-mst.c | 549 +++++++ drivers/gpu/drm/bridge/cdns-mhdp.c | 1349 +++++++++++++++++ drivers/gpu/drm/bridge/cdns-mhdp.h | 209 +++ drivers/gpu/drm/drm_dp_helper.c | 30 +- drivers/gpu/drm/rockchip/Kconfig | 4 +- drivers/gpu/drm/rockchip/Makefile | 2 +- drivers/gpu/drm/rockchip/cdn-dp-core.c | 234 +-- drivers/gpu/drm/rockchip/cdn-dp-core.h | 43 +- drivers/gpu/drm/rockchip/cdn-dp-reg.c | 969 ------------ include/drm/bridge/cdns-mhdp-cbs.h | 29 + .../drm/bridge/cdns-mhdp-common.h | 176 ++- 15 files changed, 3606 insertions(+), 1150 deletions(-) create mode 100644 Documentation/devicetree/bindings/display/bridge/cdns,mhdp.txt create mode 100644 drivers/gpu/drm/bridge/cdns-mhdp-common.c create mode 100644 drivers/gpu/drm/bridge/cdns-mhdp-mst.c create mode 100644 drivers/gpu/drm/bridge/cdns-mhdp.c create mode 100644 drivers/gpu/drm/bridge/cdns-mhdp.h delete mode 100644 drivers/gpu/drm/rockchip/cdn-dp-reg.c create mode 100644 include/drm/bridge/cdns-mhdp-cbs.h rename drivers/gpu/drm/rockchip/cdn-dp-reg.h => include/drm/bridge/cdns-mhdp-common.h (77%)
Signature · 1 line
2.17.1
PATCH v7 1/4 drm/rockchip: prepare common code for cdns and rk dpi/dp driver
- Extracted common fields from cdn_dp_device to a new cdns_mhdp_device structure which will be used by two separate drivers later on.
- Moved some datatypes (audio_format, audio_info, vic_pxl_encoding_format, video_info) from cdn-dp-core.c to cdn-dp-reg.h.
- Changed prefixes from cdn_dp to cdns_mhdp
cdn -> cdns to match the other Cadence's drivers
dp -> mhdp to distinguish it from a "just a DP" as the IP underneath
this registers map can be a HDMI (which is internally different, but the interface for commands, events is pretty much the same).
- Modified cdn-dp-core.c to use the new driver structure and new function names.
--- drivers/gpu/drm/rockchip/cdn-dp-core.c | 220 +++++++------ drivers/gpu/drm/rockchip/cdn-dp-core.h | 40 +-- drivers/gpu/drm/rockchip/cdn-dp-reg.c | 428 +++++++++++++------------ drivers/gpu/drm/rockchip/cdn-dp-reg.h | 114 +++++-- 4 files changed, 431 insertions(+), 371 deletions(-)
drivers/gpu/drm/rockchip/cdn-dp-core.c +117 -103
@@ -31,11 +31,10 @@#include <sound/hdmi-codec.h> #include "cdn-dp-core.h" -#include "cdn-dp-reg.h" #include "rockchip_drm_vop.h" #define connector_to_dp (c) \ - container_of(c, struct cdn_dp_device, connector) + container_of(c, struct cdn_dp_device, mhdp.connector)#define encoder_to_dp (c) \ container_of(c, struct cdn_dp_device, encoder)
@@ -70,17 +69,18 @@ MODULE_DEVICE_TABLE(of, cdn_dp_dt_ids);static int cdn_dp_grf_write (struct cdn_dp_device *dp,unsigned int reg,unsigned int val) { +struct device *dev = dp->mhdp.dev;int ret; ret =clk_prepare_enable (dp->grf_clk);if (ret) { -DRM_DEV_ERROR (dp->dev,"Failed to prepare_enable grf clock\n" ); +DRM_DEV_ERROR (dev,"Failed to prepare_enable grf clock\n" );return ret; } ret =regmap_write (dp->grf, reg, val);if (ret) { -DRM_DEV_ERROR (dp->dev,"Could not write to GRF: %d\n" , ret); +DRM_DEV_ERROR (dev,"Could not write to GRF: %d\n" , ret);return ret; }
@@ -91,24 +91,25 @@ static int cdn_dp_grf_write(struct cdn_dp_device *dp,static int cdn_dp_clk_enable (struct cdn_dp_device *dp) { +struct device *dev = dp->mhdp.dev;int ret;unsigned long rate; ret =clk_prepare_enable (dp->pclk);if (ret <0 ) { -DRM_DEV_ERROR (dp->dev,"cannot enable dp pclk %d\n" , ret); +DRM_DEV_ERROR (dev,"cannot enable dp pclk %d\n" , ret); goto err_pclk; } ret =clk_prepare_enable (dp->core_clk);if (ret <0 ) { -DRM_DEV_ERROR (dp->dev,"cannot enable core_clk %d\n" , ret); +DRM_DEV_ERROR (dev,"cannot enable core_clk %d\n" , ret); goto err_core_clk; } - ret =pm_runtime_get_sync (dp->dev); + ret =pm_runtime_get_sync (dev);if (ret <0 ) { -DRM_DEV_ERROR (dp->dev,"cannot get pm runtime %d\n" , ret); +DRM_DEV_ERROR (dev,"cannot get pm runtime %d\n" , ret); goto err_pm_runtime_get; }
@@ -121,18 +122,18 @@ static int cdn_dp_clk_enable(struct cdn_dp_device *dp) rate =clk_get_rate (dp->core_clk);if (!rate) { -DRM_DEV_ERROR (dp->dev,"get clk rate failed\n" ); +DRM_DEV_ERROR (dev,"get clk rate failed\n" ); ret = -EINVAL ; goto err_set_rate; } -cdn_dp_set_fw_clk (dp, rate); -cdn_dp_clock_reset (dp); +cdns_mhdp_set_fw_clk (&dp->mhdp, rate); +cdns_mhdp_clock_reset (&dp->mhdp);return 0 ; err_set_rate: -pm_runtime_put (dp->dev); +pm_runtime_put (dev); err_pm_runtime_get:clk_disable_unprepare (dp->core_clk); err_core_clk:
@@ -143,7 +144,7 @@ static int cdn_dp_clk_enable(struct cdn_dp_device *dp)static void cdn_dp_clk_disable (struct cdn_dp_device *dp) { -pm_runtime_put_sync (dp->dev); +pm_runtime_put_sync (dp->mhdp.dev);clk_disable_unprepare (dp->pclk);clk_disable_unprepare (dp->core_clk); }
@@ -176,7 +177,7 @@ static int cdn_dp_get_sink_count(struct cdn_dp_device *dp, u8 *sink_count)u8 value; *sink_count =0 ; - ret =cdn_dp_dpcd_read (dp,DP_SINK_COUNT , &value,1 ); + ret =cdns_mhdp_dpcd_read (&dp->mhdp,DP_SINK_COUNT , &value,1 );if (ret)return ret;
@@ -200,12 +201,13 @@ static struct cdn_dp_port *cdn_dp_connected_port(struct cdn_dp_device *dp)static bool cdn_dp_check_sink_connection (struct cdn_dp_device *dp) { +struct device *dev = dp->mhdp.dev;unsigned long timeout = jiffies +msecs_to_jiffies (CDN_DPCD_TIMEOUT_MS );struct cdn_dp_port *port;u8 sink_count =0 ;if (dp->active_port <0 || dp->active_port >= dp->ports) { -DRM_DEV_ERROR (dp->dev,"active_port is wrong!\n" ); +DRM_DEV_ERROR (dev,"active_port is wrong!\n" );return false; }
@@ -227,7 +229,7 @@ static bool cdn_dp_check_sink_connection(struct cdn_dp_device *dp)usleep_range (5000 ,10000 ); } -DRM_DEV_ERROR (dp->dev,"Get sink capability timed out\n" ); +DRM_DEV_ERROR (dev,"Get sink capability timed out\n" );return false; }
@@ -269,7 +271,8 @@ static int cdn_dp_connector_get_modes(struct drm_connector *connector)mutex_lock (&dp->lock); edid = dp->edid;if (edid) { -DRM_DEV_DEBUG_KMS (dp->dev,"got edid: width[%d] x height[%d]\n" , +DRM_DEV_DEBUG_KMS (dp->mhdp.dev, +"got edid: width[%d] x height[%d]\n" , edid->width_cm, edid->height_cm); dp->sink_has_audio =drm_detect_monitor_audio (edid);
@@ -287,7 +290,8 @@ static int cdn_dp_connector_mode_valid(struct drm_connector *connector, struct drm_display_mode *mode) {struct cdn_dp_device *dp =connector_to_dp (connector); -struct drm_display_info *display_info = &dp->connector.display_info; +struct drm_display_info *display_info = + &dp->mhdp.connector.display_info;u32 requested, actual, rate, sink_max, source_max =0 ;u8 lanes, bpc;
@@ -313,7 +317,7 @@ static int cdn_dp_connector_mode_valid(struct drm_connector *connector, sink_max =drm_dp_max_lane_count (dp->dpcd); lanes =min (source_max, sink_max); - source_max =drm_dp_bw_code_to_link_rate (CDN_DP_MAX_LINK_RATE ); + source_max =drm_dp_bw_code_to_link_rate (CDNS_DP_MAX_LINK_RATE ); sink_max =drm_dp_max_link_rate (dp->dpcd); rate =min (source_max, sink_max);
@@ -323,7 +327,7 @@ static int cdn_dp_connector_mode_valid(struct drm_connector *connector, actual = actual *8 /10 ;if (requested > actual) { -DRM_DEV_DEBUG_KMS (dp->dev, +DRM_DEV_DEBUG_KMS (dp->mhdp.dev,"requested=%d, actual=%d, clock=%d\n" , requested, actual, mode->clock);return MODE_CLOCK_HIGH ;
@@ -343,28 +347,29 @@ static int cdn_dp_firmware_init(struct cdn_dp_device *dp)const u32 *iram_data, *dram_data;const struct firmware *fw = dp->fw;const struct cdn_firmware_header *hdr; +struct device *dev = dp->mhdp.dev; hdr = (struct cdn_firmware_header *)fw->data;if (fw->size !=le32_to_cpu (hdr->size_bytes)) { -DRM_DEV_ERROR (dp->dev,"firmware is invalid\n" ); +DRM_DEV_ERROR (dev,"firmware is invalid\n" );return -EINVAL ; } iram_data = (const u32 *)(fw->data + hdr->header_size); dram_data = (const u32 *)(fw->data + hdr->header_size + hdr->iram_size); - ret =cdn_dp_load_firmware (dp, iram_data, hdr->iram_size, - dram_data, hdr->dram_size); + ret =cdns_mhdp_load_firmware (&dp->mhdp, iram_data, hdr->iram_size, + dram_data, hdr->dram_size);if (ret)return ret; - ret =cdn_dp_set_firmware_active (dp, true); + ret =cdns_mhdp_set_firmware_active (&dp->mhdp, true);if (ret) { -DRM_DEV_ERROR (dp->dev,"active ucpu failed: %d\n" , ret); +DRM_DEV_ERROR (dev,"active ucpu failed: %d\n" , ret);return ret; } -return cdn_dp_event_config (dp); +return cdns_mhdp_event_config (&dp->mhdp); }static int cdn_dp_get_sink_capability (struct cdn_dp_device *dp)
@@ -374,28 +379,29 @@ static int cdn_dp_get_sink_capability(struct cdn_dp_device *dp)if (!cdn_dp_check_sink_connection (dp))return -ENODEV ; - ret =cdn_dp_dpcd_read (dp,DP_DPCD_REV , dp->dpcd, -DP_RECEIVER_CAP_SIZE ); + ret =cdns_mhdp_dpcd_read (&dp->mhdp,DP_DPCD_REV , dp->dpcd, +DP_RECEIVER_CAP_SIZE );if (ret) { -DRM_DEV_ERROR (dp->dev,"Failed to get caps %d\n" , ret); +DRM_DEV_ERROR (dp->mhdp.dev,"Failed to get caps %d\n" , ret);return ret; }kfree (dp->edid); - dp->edid =drm_do_get_edid (&dp->connector, - cdn_dp_get_edid_block, dp); + dp->edid =drm_do_get_edid (&dp->mhdp.connector, + cdns_mhdp_get_edid_block, &dp->mhdp);return 0 ; }static int cdn_dp_enable_phy (struct cdn_dp_device *dp,struct cdn_dp_port *port) { +struct device *dev = dp->mhdp.dev;union extcon_property_value property;int ret;if (!port->phy_enabled) { ret =phy_power_on (port->phy);if (ret) { -DRM_DEV_ERROR (dp->dev,"phy power on failed: %d\n" , +DRM_DEV_ERROR (dev,"phy power on failed: %d\n" , ret); goto err_phy; }
@@ -405,28 +411,28 @@ static int cdn_dp_enable_phy(struct cdn_dp_device *dp, struct cdn_dp_port *port) ret =cdn_dp_grf_write (dp,GRF_SOC_CON26 ,DPTX_HPD_SEL_MASK |DPTX_HPD_SEL );if (ret) { -DRM_DEV_ERROR (dp->dev,"Failed to write HPD_SEL %d\n" , ret); +DRM_DEV_ERROR (dev,"Failed to write HPD_SEL %d\n" , ret); goto err_power_on; } - ret =cdn_dp_get_hpd_status (dp); + ret =cdns_mhdp_get_hpd_status (&dp->mhdp);if (ret <=0 ) {if (!ret) -DRM_DEV_ERROR (dp->dev,"hpd does not exist\n" ); +DRM_DEV_ERROR (dev,"hpd does not exist\n" ); goto err_power_on; } ret =extcon_get_property (port->extcon,EXTCON_DISP_DP ,EXTCON_PROP_USB_TYPEC_POLARITY , &property);if (ret) { -DRM_DEV_ERROR (dp->dev,"get property failed\n" ); +DRM_DEV_ERROR (dev,"get property failed\n" ); goto err_power_on; } port->lanes =cdn_dp_get_port_lanes (port); - ret =cdn_dp_set_host_cap (dp, port->lanes, property.intval); + ret =cdns_mhdp_set_host_cap (&dp->mhdp, port->lanes, property.intval);if (ret) { -DRM_DEV_ERROR (dp->dev,"set host capabilities failed: %d\n" , +DRM_DEV_ERROR (dev,"set host capabilities failed: %d\n" , ret); goto err_power_on; }
@@ -436,7 +442,7 @@ static int cdn_dp_enable_phy(struct cdn_dp_device *dp, struct cdn_dp_port *port) err_power_on:if (phy_power_off (port->phy)) -DRM_DEV_ERROR (dp->dev,"phy power off failed: %d" , ret); +DRM_DEV_ERROR (dev,"phy power off failed: %d" , ret);else port->phy_enabled = false;
@@ -454,7 +460,8 @@ static int cdn_dp_disable_phy(struct cdn_dp_device *dp,if (port->phy_enabled) { ret =phy_power_off (port->phy);if (ret) { -DRM_DEV_ERROR (dp->dev,"phy power off failed: %d" , ret); +DRM_DEV_ERROR (dp->mhdp.dev, +"phy power off failed: %d" , ret);return ret; } }
@@ -478,16 +485,16 @@ static int cdn_dp_disable(struct cdn_dp_device *dp) ret =cdn_dp_grf_write (dp,GRF_SOC_CON26 ,DPTX_HPD_SEL_MASK |DPTX_HPD_DEL );if (ret) { -DRM_DEV_ERROR (dp->dev,"Failed to clear hpd sel %d\n" , +DRM_DEV_ERROR (dp->mhdp.dev,"Failed to clear hpd sel %d\n" , ret);return ret; } -cdn_dp_set_firmware_active (dp, false); +cdns_mhdp_set_firmware_active (&dp->mhdp, false);cdn_dp_clk_disable (dp); dp->active = false; - dp->link.rate =0 ; - dp->link.num_lanes =0 ; + dp->mhdp.link.rate =0 ; + dp->mhdp.link.num_lanes =0 ;if (!dp->connected) {kfree (dp->edid); dp->edid =NULL ;
@@ -500,11 +507,11 @@ static int cdn_dp_enable(struct cdn_dp_device *dp) {int ret, i, lanes;struct cdn_dp_port *port; +struct device *dev = dp->mhdp.dev; port =cdn_dp_connected_port (dp);if (!port) { -DRM_DEV_ERROR (dp->dev, -"Can't enable without connection\n" ); +DRM_DEV_ERROR (dev,"Can't enable without connection\n" );return -ENODEV ; }
@@ -517,7 +524,7 @@ static int cdn_dp_enable(struct cdn_dp_device *dp) ret =cdn_dp_firmware_init (dp);if (ret) { -DRM_DEV_ERROR (dp->dev,"firmware init failed: %d" , ret); +DRM_DEV_ERROR (dp->mhdp.dev,"firmware init failed: %d" , ret); goto err_clk_disable; }
@@ -551,8 +558,9 @@ static void cdn_dp_encoder_mode_set(struct drm_encoder *encoder, struct drm_display_mode *adjusted) {struct cdn_dp_device *dp =encoder_to_dp (encoder); -struct drm_display_info *display_info = &dp->connector.display_info; -struct video_info *video = &dp->video_info; +struct drm_display_info *display_info = + &dp->mhdp.connector.display_info; +struct video_info *video = &dp->mhdp.video_info;switch (display_info->bpc) {case 10 :
@@ -570,7 +578,7 @@ static void cdn_dp_encoder_mode_set(struct drm_encoder *encoder, video->v_sync_polarity = !!(mode->flags &DRM_MODE_FLAG_NVSYNC ); video->h_sync_polarity = !!(mode->flags &DRM_MODE_FLAG_NHSYNC ); -memcpy (&dp->mode, adjusted,sizeof (*mode)); +memcpy (&dp->mhdp.mode, adjusted,sizeof (*mode)); }static bool cdn_dp_check_link_status (struct cdn_dp_device *dp)
@@ -579,11 +587,11 @@ static bool cdn_dp_check_link_status(struct cdn_dp_device *dp)struct cdn_dp_port *port =cdn_dp_connected_port (dp);u8 sink_lanes =drm_dp_max_lane_count (dp->dpcd); -if (!port || !dp->link.rate || !dp->link.num_lanes) +if (!port || !dp->mhdp.link.rate || !dp->mhdp.link.num_lanes)return false; -if (cdn_dp_dpcd_read (dp,DP_LANE0_1_STATUS , link_status, -DP_LINK_STATUS_SIZE )) { +if (cdns_mhdp_dpcd_read (&dp->mhdp,DP_LANE0_1_STATUS , link_status, +DP_LINK_STATUS_SIZE )) {DRM_ERROR ("Failed to get link status\n" );return false; }
@@ -595,15 +603,16 @@ static bool cdn_dp_check_link_status(struct cdn_dp_device *dp)static void cdn_dp_encoder_enable (struct drm_encoder *encoder) {struct cdn_dp_device *dp =encoder_to_dp (encoder); +struct device *dev = dp->mhdp.dev;int ret, val; - ret =drm_of_encoder_active_endpoint_id (dp->dev->of_node, encoder); + ret =drm_of_encoder_active_endpoint_id (dev->of_node, encoder);if (ret <0 ) { -DRM_DEV_ERROR (dp->dev,"Could not get vop id, %d" , ret); +DRM_DEV_ERROR (dev,"Could not get vop id, %d" , ret);return ; } -DRM_DEV_DEBUG_KMS (dp->dev,"vop %s output to cdn-dp\n" , +DRM_DEV_DEBUG_KMS (dev,"vop %s output to cdn-dp\n" , (ret) ?"LIT" :"BIG" );if (ret) val =DP_SEL_VOP_LIT | (DP_SEL_VOP_LIT <<16 );
@@ -618,33 +627,33 @@ static void cdn_dp_encoder_enable(struct drm_encoder *encoder) ret =cdn_dp_enable (dp);if (ret) { -DRM_DEV_ERROR (dp->dev,"Failed to enable encoder %d\n" , +DRM_DEV_ERROR (dev,"Failed to enable encoder %d\n" , ret); goto out; }if (!cdn_dp_check_link_status (dp)) { - ret =cdn_dp_train_link (dp); + ret =cdns_mhdp_train_link (&dp->mhdp);if (ret) { -DRM_DEV_ERROR (dp->dev,"Failed link train %d\n" , ret); +DRM_DEV_ERROR (dev,"Failed link train %d\n" , ret); goto out; } } - ret =cdn_dp_set_video_status (dp,CONTROL_VIDEO_IDLE ); + ret =cdns_mhdp_set_video_status (&dp->mhdp,CONTROL_VIDEO_IDLE );if (ret) { -DRM_DEV_ERROR (dp->dev,"Failed to idle video %d\n" , ret); +DRM_DEV_ERROR (dev,"Failed to idle video %d\n" , ret); goto out; } - ret =cdn_dp_config_video (dp); + ret =cdns_mhdp_config_video (&dp->mhdp);if (ret) { -DRM_DEV_ERROR (dp->dev,"Failed to config video %d\n" , ret); +DRM_DEV_ERROR (dev,"Failed to config video %d\n" , ret); goto out; } - ret =cdn_dp_set_video_status (dp,CONTROL_VIDEO_VALID ); + ret =cdns_mhdp_set_video_status (&dp->mhdp,CONTROL_VIDEO_VALID );if (ret) { -DRM_DEV_ERROR (dp->dev,"Failed to valid video %d\n" , ret); +DRM_DEV_ERROR (dev,"Failed to valid video %d\n" , ret); goto out; } out:
@@ -660,7 +669,8 @@ static void cdn_dp_encoder_disable(struct drm_encoder *encoder)if (dp->active) { ret =cdn_dp_disable (dp);if (ret) { -DRM_DEV_ERROR (dp->dev,"Failed to disable encoder %d\n" , +DRM_DEV_ERROR (dp->mhdp.dev, +"Failed to disable encoder %d\n" , ret); } }
@@ -704,7 +714,7 @@ static const struct drm_encoder_funcs cdn_dp_encoder_funcs = {static int cdn_dp_parse_dt (struct cdn_dp_device *dp) { -struct device *dev = dp->dev; +struct device *dev = dp->mhdp.dev;struct device_node *np = dev->of_node;struct platform_device *pdev =to_platform_device (dev);struct resource *res;
@@ -716,10 +726,10 @@ static int cdn_dp_parse_dt(struct cdn_dp_device *dp) } res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - dp->regs =devm_ioremap_resource (dev, res); -if (IS_ERR (dp->regs)) { + dp->mhdp.regs =devm_ioremap_resource (dev, res); +if (IS_ERR (dp->mhdp.regs)) {DRM_DEV_ERROR (dev,"ioremap reg failed\n" ); -return PTR_ERR (dp->regs); +return PTR_ERR (dp->mhdp.regs); } dp->core_clk =devm_clk_get (dev,"core-clk" );
@@ -734,10 +744,10 @@ static int cdn_dp_parse_dt(struct cdn_dp_device *dp)return PTR_ERR (dp->pclk); } - dp->spdif_clk =devm_clk_get (dev,"spdif" ); -if (IS_ERR (dp->spdif_clk)) { + dp->mhdp.spdif_clk =devm_clk_get (dev,"spdif" ); +if (IS_ERR (dp->mhdp.spdif_clk)) {DRM_DEV_ERROR (dev,"cannot get spdif_clk\n" ); -return PTR_ERR (dp->spdif_clk); +return PTR_ERR (dp->mhdp.spdif_clk); } dp->grf_clk =devm_clk_get (dev,"grf" );
@@ -746,10 +756,10 @@ static int cdn_dp_parse_dt(struct cdn_dp_device *dp)return PTR_ERR (dp->grf_clk); } - dp->spdif_rst =devm_reset_control_get (dev,"spdif" ); -if (IS_ERR (dp->spdif_rst)) { + dp->mhdp.spdif_rst =devm_reset_control_get (dev,"spdif" ); +if (IS_ERR (dp->mhdp.spdif_rst)) {DRM_DEV_ERROR (dev,"no spdif reset control found\n" ); -return PTR_ERR (dp->spdif_rst); +return PTR_ERR (dp->mhdp.spdif_rst); } dp->dptx_rst =devm_reset_control_get (dev,"dptx" );
@@ -804,7 +814,7 @@ static int cdn_dp_audio_hw_params(struct device *dev, void *data, goto out; } - ret =cdn_dp_audio_config (dp, &audio); + ret =cdns_mhdp_audio_config (&dp->mhdp, &audio);if (!ret) dp->audio_info = audio;
@@ -822,7 +832,7 @@ static void cdn_dp_audio_shutdown(struct device *dev, void *data)if (!dp->active) goto out; - ret =cdn_dp_audio_stop (dp, &dp->audio_info); + ret =cdns_mhdp_audio_stop (&dp->mhdp, &dp->audio_info);if (!ret) dp->audio_info.format =AFMT_UNUSED ; out:
@@ -841,7 +851,7 @@ static int cdn_dp_audio_digital_mute(struct device *dev, void *data, goto out; } - ret =cdn_dp_audio_mute (dp, enable); + ret =cdns_mhdp_audio_mute (&dp->mhdp, enable); out:mutex_unlock (&dp->lock);
@@ -853,7 +863,8 @@ static int cdn_dp_audio_get_eld(struct device *dev, void *data, {struct cdn_dp_device *dp =dev_get_drvdata (dev); -memcpy (buf, dp->connector.eld,min (sizeof (dp->connector.eld), len)); +memcpy (buf, dp->mhdp.connector.eld, +min (sizeof (dp->mhdp.connector.eld), len));return 0 ; }
@@ -887,6 +898,7 @@ static int cdn_dp_request_firmware(struct cdn_dp_device *dp)int ret;unsigned long timeout = jiffies +msecs_to_jiffies (CDN_FW_TIMEOUT_MS );unsigned long sleep =1000 ; +struct device *dev = dp->mhdp.dev;WARN_ON (!mutex_is_locked (&dp->lock));
@@ -897,13 +909,13 @@ static int cdn_dp_request_firmware(struct cdn_dp_device *dp)mutex_unlock (&dp->lock);while (time_before (jiffies, timeout)) { - ret =request_firmware (&dp->fw,CDN_DP_FIRMWARE , dp->dev); + ret =request_firmware (&dp->fw,CDN_DP_FIRMWARE , dev);if (ret == -ENOENT ) {msleep (sleep); sleep *=2 ;continue ; }else if (ret) { -DRM_DEV_ERROR (dp->dev, +DRM_DEV_ERROR (dev,"failed to request firmware: %d\n" , ret); goto out; }
@@ -913,7 +925,7 @@ static int cdn_dp_request_firmware(struct cdn_dp_device *dp) goto out; } -DRM_DEV_ERROR (dp->dev,"Timed out trying to load firmware\n" ); +DRM_DEV_ERROR (dev,"Timed out trying to load firmware\n" ); ret = -ETIMEDOUT ; out:mutex_lock (&dp->lock);
@@ -924,8 +936,9 @@ static void cdn_dp_pd_event_work(struct work_struct *work) { struct cdn_dp_device *dp = container_of(work, struct cdn_dp_device, event_work); -struct drm_connector *connector = &dp->connector; +struct drm_connector *connector = &dp->mhdp.connector;enum drm_connector_status old_status; +struct device *dev = dp->mhdp.dev;int ret;
@@ -942,44 +955,45 @@ static void cdn_dp_pd_event_work(struct work_struct *work)/* Not connected, notify userspace to disable the block */ if (!cdn_dp_connected_port (dp)) { -DRM_DEV_INFO (dp->dev,"Not connected. Disabling cdn\n" ); +DRM_DEV_INFO (dev,"Not connected. Disabling cdn\n" ); dp->connected = false;/* Connected but not enabled, enable the block */ }else if (!dp->active) { -DRM_DEV_INFO (dp->dev,"Connected, not enabled. Enabling cdn\n" ); +DRM_DEV_INFO (dev,"Connected, not enabled. Enabling cdn\n" ); ret =cdn_dp_enable (dp);if (ret) { -DRM_DEV_ERROR (dp->dev,"Enable dp failed %d\n" , ret); +DRM_DEV_ERROR (dev,"Enable dp failed %d\n" , ret); dp->connected = false; }/* Enabled and connected to a dongle without a sink, notify userspace */ }else if (!cdn_dp_check_sink_connection (dp)) { -DRM_DEV_INFO (dp->dev,"Connected without sink. Assert hpd\n" ); +DRM_DEV_INFO (dev,"Connected without sink. Assert hpd\n" ); dp->connected = false;/* Enabled and connected with a sink, re-train if requested */ }else if (!cdn_dp_check_link_status (dp)) { -unsigned int rate = dp->link.rate; -unsigned int lanes = dp->link.num_lanes; -struct drm_display_mode *mode = &dp->mode; +unsigned int rate = dp->mhdp.link.rate; +unsigned int lanes = dp->mhdp.link.num_lanes; +struct drm_display_mode *mode = &dp->mhdp.mode; -DRM_DEV_INFO (dp->dev,"Connected with sink. Re-train link\n" ); - ret =cdn_dp_train_link (dp); +DRM_DEV_INFO (dev,"Connected with sink. Re-train link\n" ); + ret =cdns_mhdp_train_link (&dp->mhdp);if (ret) { dp->connected = false; -DRM_DEV_ERROR (dp->dev,"Train link failed %d\n" , ret); +DRM_DEV_ERROR (dev,"Train link failed %d\n" , ret); goto out; }/* If training result is changed, update the video config */ if (mode->clock && - (rate != dp->link.rate || lanes != dp->link.num_lanes)) { - ret =cdn_dp_config_video (dp); + (rate != dp->mhdp.link.rate || + lanes != dp->mhdp.link.num_lanes)) { + ret =cdns_mhdp_config_video (&dp->mhdp);if (ret) { dp->connected = false; -DRM_DEV_ERROR (dp->dev, +DRM_DEV_ERROR (dev,"Failed to config video %d\n" , ret); }
@@ -1048,7 +1062,7 @@ static int cdn_dp_bind(struct device *dev, struct device *master, void *data)drm_encoder_helper_add (encoder, &cdn_dp_encoder_helper_funcs); - connector = &dp->connector; + connector = &dp->mhdp.connector; connector->polled =DRM_CONNECTOR_POLL_HPD ; connector->dpms =DRM_MODE_DPMS_OFF ;
@@ -1072,7 +1086,7 @@ static int cdn_dp_bind(struct device *dev, struct device *master, void *data) port = dp->port[i]; port->event_nb.notifier_call = cdn_dp_pd_event; - ret =devm_extcon_register_notifier (dp->dev, port->extcon, + ret =devm_extcon_register_notifier (dp->mhdp.dev, port->extcon,EXTCON_DISP_DP , &port->event_nb);if (ret) {
@@ -1099,7 +1113,7 @@ static void cdn_dp_unbind(struct device *dev, struct device *master, void *data) {struct cdn_dp_device *dp =dev_get_drvdata (dev);struct drm_encoder *encoder = &dp->encoder; -struct drm_connector *connector = &dp->connector; +struct drm_connector *connector = &dp->mhdp.connector;cancel_work_sync (&dp->event_work);cdn_dp_encoder_disable (encoder);
@@ -1159,7 +1173,7 @@ static int cdn_dp_probe(struct platform_device *pdev) dp =devm_kzalloc (dev,sizeof (*dp),GFP_KERNEL );if (!dp)return -ENOMEM ; - dp->dev = dev; + dp->mhdp.dev = dev; match =of_match_node (cdn_dp_dt_ids, pdev->dev.of_node); dp_data = (struct cdn_dp_data *)match->data;
@@ -1204,7 +1218,7 @@ static int cdn_dp_remove(struct platform_device *pdev)struct cdn_dp_device *dp =platform_get_drvdata (pdev);platform_device_unregister (dp->audio_pdev); -cdn_dp_suspend (dp->dev); +cdn_dp_suspend (dp->mhdp.dev);component_del (&pdev->dev, &cdn_dp_component_ops);return 0 ;
@@ -1214,7 +1228,7 @@ static void cdn_dp_shutdown(struct platform_device *pdev) {struct cdn_dp_device *dp =platform_get_drvdata (pdev); -cdn_dp_suspend (dp->dev); +cdn_dp_suspend (dp->mhdp.dev); }static const struct dev_pm_ops cdn_dp_pm_ops = {
drivers/gpu/drm/rockchip/cdn-dp-core.h +2 -38
@@ -20,38 +20,10 @@#include <drm/drm_panel.h> #include <drm/drm_probe_helper.h> #include "rockchip_drm_drv.h" +#include "cdn-dp-reg.h" #define MAX_PHY 2 -enum audio_format { -AFMT_I2S =0 , -AFMT_SPDIF =1 , -AFMT_UNUSED , -}; - -struct audio_info { -enum audio_format format; -int sample_rate; -int channels; -int sample_width; -}; - -enum vic_pxl_encoding_format { -PXL_RGB =0x1 , -YCBCR_4_4_4 =0x2 , -YCBCR_4_2_2 =0x4 , -YCBCR_4_2_0 =0x8 , -Y_ONLY =0x10 , -}; - -struct video_info { -bool h_sync_polarity; -bool v_sync_polarity; -bool interlaced; -int color_depth; -enum vic_pxl_encoding_format color_fmt; -}; -struct cdn_firmware_header {u32 size_bytes;/* size of the entire header+image(s) in bytes */ u32 header_size;/* size of just the header in bytes */
@@ -70,11 +42,9 @@ struct cdn_dp_port { };struct cdn_dp_device { -struct device *dev; +struct cdns_mhdp_device mhdp;struct drm_device *drm_dev; -struct drm_connector connector;struct drm_encoder encoder; -struct drm_display_mode mode;struct platform_device *audio_pdev;struct work_struct event_work;struct edid *edid;
@@ -85,22 +55,16 @@ struct cdn_dp_device {bool suspended;const struct firmware *fw;/* cdn dp firmware */ -unsigned int fw_version;/* cdn fw version */ bool fw_loaded; -void __iomem *regs;struct regmap *grf;struct clk *core_clk;struct clk *pclk; -struct clk *spdif_clk;struct clk *grf_clk; -struct reset_control *spdif_rst;struct reset_control *dptx_rst;struct reset_control *apb_rst;struct reset_control *core_rst;struct audio_info audio_info; -struct video_info video_info; -struct drm_dp_link link;struct cdn_dp_port *port[MAX_PHY ];u8 ports;u8 lanes;
drivers/gpu/drm/rockchip/cdn-dp-reg.c +219 -209
996 lines not on this page · raw message
drivers/gpu/drm/rockchip/cdn-dp-reg.h +93 -21
124 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v7 2/4 drm/dp: fix link probing for devices supporting DP 1.4+
In reply to Damian KosFrom: Quentin Schulz <[email protected]>
DP 1.4 introduced a DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT bit in DP_TRAINING_AUX_RD_INTERVAL register. If set, DPCD registers from DP_DPCD_REV to DP_ADAPTER_CAP should be retrieved starting from DP_DPCD_REV_EXTENDED. All registers are copied except DP_DPCD_REV, DP_MAX_LINK_RATE and DP_DOWNSTREAMPORT_PRESENT which represent the "true capabilities" of DPRX device.
Original DP_DPCD_REV, DP_MAX_LINK_RATE and DP_DOWNSTREAMPORT_PRESENT might falsely return lower capabilities to "avoid interoperability issues with some of the existing DP Source devices that malfunction when they discover the higher capabilities within those three registers.".
Before DP 1.4, DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT bit was reserved and read 0 so it's safe to check against it even if DP revision is <1.4
--- drivers/gpu/drm/drm_dp_helper.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_dp_helper.c +29 -1
@@ -372,10 +372,38 @@ int drm_dp_link_probe(struct drm_dp_aux *aux, struct drm_dp_link *link) {u8 values[3 ];int err; +unsigned int addr;memset (link,0 ,sizeof (*link)); - err =drm_dp_dpcd_read (aux,DP_DPCD_REV , values,sizeof (values)); +/* +* DP 1.4 introduced a DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT bit in +* DP_TRAINING_AUX_RD_INTERVAL register. If set, DPCD registers from +* DP_DPCD_REV to DP_ADAPTER_CAP should be retrieved starting from +* DP_DPCD_REV_EXTENDED. All registers are copied except DP_DPCD_REV, +* DP_MAX_LINK_RATE and DP_DOWNSTREAMPORT_PRESENT which represent the +* "true capabilities" of DPRX device. +* +* Original DP_DPCD_REV, DP_MAX_LINK_RATE and DP_DOWNSTREAMPORT_PRESENT +* might falsely return lower capabilities to "avoid interoperability +* issues with some of the existing DP Source devices that malfunction +* when they discover the higher capabilities within those three +* registers.". +* +* Before DP 1.4, DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT bit was +* reserved and read 0 so it's safe to check against it even if +* DP revision is <1.4 +*/ + err =drm_dp_dpcd_readb (aux,DP_TRAINING_AUX_RD_INTERVAL , values); +if (err <0 ) +return err; + +if (values[0 ] &DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT ) + addr =DP_DP13_DPCD_REV ; +else + addr =DP_DPCD_REV ; + + err =drm_dp_dpcd_read (aux, addr, values,sizeof (values));if (err <0 )return err;
Signature · 1 line
2.17.1
PATCH v7 3/4 dt-bindings: drm/bridge: Document Cadence MHDP bridge bindings
In reply to Damian KosFrom: Quentin Schulz <[email protected]>
Document the bindings used for the Cadence MHDP DPI/DP bridge.
--- .../bindings/display/bridge/cdns,mhdp.txt | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/bridge/cdns,mhdp.txt
Documentation/devicetree/bindings/display/bridge/cdns,mhdp.txt new file +47 -0
@@ -0,0 +1,47 @@ +Cadence MHDP bridge +========================== + +The Cadence MHDP bridge is a DPI to DP bridge. + +Required properties: +- compatible: should be "cdns,mhdp8546", +- reg: physical base address and length of the controller's registers, +- clocks: DP bridge clock, it's used by the IP to know how to translate + a number of clock cycles into a time (which is used to comply + with DP standard timings and delays), +- phys: see the Documentation/devicetree/bindings/phy/phy-cadence-dp.txt +- phy-names: must be "dpphy" + +Required subnodes: +- ports: Ports as described in Documentation/devictree/bindings/graph.txt + Port 0 - input port representing the DP bridge input + Port 1 - output port representing the DP bridge output + +Example: + + mhdp: dp-bridge@f0fb000000 { + compatible = "cdns,mhdp8546"; + reg = <0xf0 0xfb000000 0x0 0x1000000>; + clocks = <&mhdp_clock>; + phys = <&dp_phy>; + phy-names = "dpphy"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + dp_bridge_input: endpoint { + remote-endpoint = <&xxx_dpi_output>; + }; + }; + + port@1 { + reg = <1>; + dp_bridge_output: endpoint { + remote-endpoint = <&xxx_dp_connector_input>; + }; + }; + }; + };
Signature · 1 line
2.17.1
PATCH v7 4/4 drm: bridge: add support for Cadence MHDP DPI/DP bridge
In reply to Damian KosFrom: Quentin Schulz <[email protected]>
This adds support for Cadence MHDP DPI to DP bridge.
Basically, it takes a DPI stream as input and output it encoded in DP format. It supports SST and MST modes.
Changes made in the low level driver (cdn-dp-reg.*):
- moved it to from drivers/gpu/drm/rockchip to drivers/gpu/drm/bridge/cdns-mhdp-common.c and include/drm/bridge/cdns-mhdp-common.h
- functions for sending/receiving commands are now public
- added functions for reading registers and link training adjustment
Changes made in RK's driver (cdn-dp-core.*):
- Moved audio_info and audio_pdev fields from cdn_dp_device to cdns_mhdp_device structure.
---
drivers/gpu/drm/bridge/Kconfig | 9 +
drivers/gpu/drm/bridge/Makefile | 3 +
.../cdns-mhdp-common.c} | 186 ++-
drivers/gpu/drm/bridge/cdns-mhdp-mst.c | 549 +++++++
drivers/gpu/drm/bridge/cdns-mhdp.c | 1349 +++++++++++++++++
drivers/gpu/drm/bridge/cdns-mhdp.h | 209 +++
drivers/gpu/drm/rockchip/Kconfig | 4 +-
drivers/gpu/drm/rockchip/Makefile | 2 +-
drivers/gpu/drm/rockchip/cdn-dp-core.c | 34 +-
drivers/gpu/drm/rockchip/cdn-dp-core.h | 5 +-
include/drm/bridge/cdns-mhdp-cbs.h | 29 +
.../drm/bridge/cdns-mhdp-common.h | 68 +-
12 files changed, 2384 insertions(+), 63 deletions(-)
rename drivers/gpu/drm/{rockchip/cdn-dp-reg.c => bridge/cdns-mhdp-common.c} (85%)
create mode 100644 drivers/gpu/drm/bridge/cdns-mhdp-mst.c
create mode 100644 drivers/gpu/drm/bridge/cdns-mhdp.c
create mode 100644 drivers/gpu/drm/bridge/cdns-mhdp.h
create mode 100644 include/drm/bridge/cdns-mhdp-cbs.h
rename drivers/gpu/drm/rockchip/cdn-dp-reg.h => include/drm/bridge/cdns-mhdp-common.h (91%)drivers/gpu/drm/bridge/Kconfig +9 -0
@@ -35,6 +35,15 @@ config DRM_CDNS_DSI Support Cadence DPI to DSI bridge. This is an internal bridge and is meant to be directly embedded in a SoC. +config DRM_CDNS_MHDP + tristate "Cadence DPI/DP bridge" + select DRM_KMS_HELPER + select DRM_PANEL_BRIDGE + depends on OF + help + Support Cadence DPI to DP bridge. This is an internal + bridge and is meant to be directly embedded in a SoC. + config DRM_DUMB_VGA_DAC tristate "Dumb VGA DAC Bridge support" depends on OF
drivers/gpu/drm/bridge/Makefile +3 -0
@@ -16,4 +16,7 @@ obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix/ obj-$(CONFIG_DRM_I2C_ADV7511) += adv7511/ obj-$(CONFIG_DRM_TI_SN65DSI86) += ti-sn65dsi86.o obj-$(CONFIG_DRM_TI_TFP410) += ti-tfp410.o +obj-$(CONFIG_DRM_CDNS_MHDP) += mhdp8546.o obj-y += synopsys/ + +mhdp8546-objs := cdns-mhdp-common.o cdns-mhdp.o cdns-mhdp-mst.o
drivers/gpu/drm/bridge/cdns-mhdp-common.c renamed from drivers/gpu/drm/rockchip/cdn-dp-reg.c +155 -31
356 lines not on this page · raw message
drivers/gpu/drm/bridge/cdns-mhdp-mst.c new file +549 -0
549 lines not on this page · raw message
drivers/gpu/drm/bridge/cdns-mhdp.c new file +1349 -0
1,349 lines not on this page · raw message
drivers/gpu/drm/bridge/cdns-mhdp.h new file +209 -0
209 lines not on this page · raw message
drivers/gpu/drm/rockchip/Kconfig +3 -1
@@ -28,7 +28,9 @@ config ROCKCHIP_ANALOGIX_DP config ROCKCHIP_CDN_DP bool "Rockchip cdn DP" - depends on EXTCON=y || (EXTCON=m && DRM_ROCKCHIP=m) + depends on DRM_ROCKCHIP + select EXTCON + select DRM_CDNS_MHDP help This selects support for Rockchip SoC specific extensions for the cdn DP driver. If you want to enable Dp on
drivers/gpu/drm/rockchip/Makefile +1 -1
@@ -9,7 +9,7 @@ rockchipdrm-y := rockchip_drm_drv.o rockchip_drm_fb.o \ rockchipdrm-$(CONFIG_DRM_FBDEV_EMULATION) += rockchip_drm_fbdev.o rockchipdrm-$(CONFIG_ROCKCHIP_ANALOGIX_DP) += analogix_dp-rockchip.o -rockchipdrm-$(CONFIG_ROCKCHIP_CDN_DP) += cdn-dp-core.o cdn-dp-reg.o +rockchipdrm-$(CONFIG_ROCKCHIP_CDN_DP) += cdn-dp-core.o rockchipdrm-$(CONFIG_ROCKCHIP_DW_HDMI) += dw_hdmi-rockchip.o rockchipdrm-$(CONFIG_ROCKCHIP_DW_MIPI_DSI) += dw-mipi-dsi-rockchip.o rockchipdrm-$(CONFIG_ROCKCHIP_INNO_HDMI) += inno_hdmi.o
drivers/gpu/drm/rockchip/cdn-dp-core.c +17 -17
@@ -34,7 +34,7 @@#include "rockchip_drm_vop.h" #define connector_to_dp (c) \ - container_of(c, struct cdn_dp_device, mhdp.connector) + container_of(c, struct cdn_dp_device, mhdp.connector.base)#define encoder_to_dp (c) \ container_of(c, struct cdn_dp_device, encoder)
@@ -291,7 +291,7 @@ static int cdn_dp_connector_mode_valid(struct drm_connector *connector, {struct cdn_dp_device *dp =connector_to_dp (connector);struct drm_display_info *display_info = - &dp->mhdp.connector.display_info; + &dp->mhdp.connector.base.display_info;u32 requested, actual, rate, sink_max, source_max =0 ;u8 lanes, bpc;
@@ -387,7 +387,7 @@ static int cdn_dp_get_sink_capability(struct cdn_dp_device *dp) }kfree (dp->edid); - dp->edid =drm_do_get_edid (&dp->mhdp.connector, + dp->edid =drm_do_get_edid (&dp->mhdp.connector.base, cdns_mhdp_get_edid_block, &dp->mhdp);return 0 ; }
@@ -559,7 +559,7 @@ static void cdn_dp_encoder_mode_set(struct drm_encoder *encoder, {struct cdn_dp_device *dp =encoder_to_dp (encoder);struct drm_display_info *display_info = - &dp->mhdp.connector.display_info; + &dp->mhdp.connector.base.display_info;struct video_info *video = &dp->mhdp.video_info;switch (display_info->bpc) {
@@ -816,7 +816,7 @@ static int cdn_dp_audio_hw_params(struct device *dev, void *data, ret =cdns_mhdp_audio_config (&dp->mhdp, &audio);if (!ret) - dp->audio_info = audio; + dp->mhdp.audio_info = audio; out:mutex_unlock (&dp->lock);
@@ -832,9 +832,9 @@ static void cdn_dp_audio_shutdown(struct device *dev, void *data)if (!dp->active) goto out; - ret =cdns_mhdp_audio_stop (&dp->mhdp, &dp->audio_info); + ret =cdns_mhdp_audio_stop (&dp->mhdp, &dp->mhdp.audio_info);if (!ret) - dp->audio_info.format =AFMT_UNUSED ; + dp->mhdp.audio_info.format =AFMT_UNUSED ; out:mutex_unlock (&dp->lock); }
@@ -863,8 +863,8 @@ static int cdn_dp_audio_get_eld(struct device *dev, void *data, {struct cdn_dp_device *dp =dev_get_drvdata (dev); -memcpy (buf, dp->mhdp.connector.eld, -min (sizeof (dp->mhdp.connector.eld), len)); +memcpy (buf, dp->mhdp.connector.base.eld, +min (sizeof (dp->mhdp.connector.base.eld), len));return 0 ; }
@@ -886,11 +886,11 @@ static int cdn_dp_audio_codec_init(struct cdn_dp_device *dp, .max_i2s_channels = 8, }; - dp->audio_pdev =platform_device_register_data ( - dev,HDMI_CODEC_DRV_NAME ,PLATFORM_DEVID_AUTO , - &codec_data,sizeof (codec_data)); + dp->mhdp.audio_pdev =platform_device_register_data ( + dev,HDMI_CODEC_DRV_NAME ,PLATFORM_DEVID_AUTO , + &codec_data,sizeof (codec_data)); -return PTR_ERR_OR_ZERO (dp->audio_pdev); +return PTR_ERR_OR_ZERO (dp->mhdp.audio_pdev); }static int cdn_dp_request_firmware (struct cdn_dp_device *dp)
@@ -936,7 +936,7 @@ static void cdn_dp_pd_event_work(struct work_struct *work) { struct cdn_dp_device *dp = container_of(work, struct cdn_dp_device, event_work); -struct drm_connector *connector = &dp->mhdp.connector; +struct drm_connector *connector = &dp->mhdp.connector.base;enum drm_connector_status old_status;struct device *dev = dp->mhdp.dev;
@@ -1062,7 +1062,7 @@ static int cdn_dp_bind(struct device *dev, struct device *master, void *data)drm_encoder_helper_add (encoder, &cdn_dp_encoder_helper_funcs); - connector = &dp->mhdp.connector; + connector = &dp->mhdp.connector.base; connector->polled =DRM_CONNECTOR_POLL_HPD ; connector->dpms =DRM_MODE_DPMS_OFF ;
@@ -1113,7 +1113,7 @@ static void cdn_dp_unbind(struct device *dev, struct device *master, void *data) {struct cdn_dp_device *dp =dev_get_drvdata (dev);struct drm_encoder *encoder = &dp->encoder; -struct drm_connector *connector = &dp->mhdp.connector; +struct drm_connector *connector = &dp->mhdp.connector.base;cancel_work_sync (&dp->event_work);cdn_dp_encoder_disable (encoder);
@@ -1217,7 +1217,7 @@ static int cdn_dp_remove(struct platform_device *pdev) {struct cdn_dp_device *dp =platform_get_drvdata (pdev); -platform_device_unregister (dp->audio_pdev); +platform_device_unregister (dp->mhdp.audio_pdev);cdn_dp_suspend (dp->mhdp.dev);component_del (&pdev->dev, &cdn_dp_component_ops);
drivers/gpu/drm/rockchip/cdn-dp-core.h +2 -3
@@ -15,12 +15,13 @@#ifndef _CDN_DP_CORE_H#define _CDN_DP_CORE_H +#include <drm/bridge/cdns-mhdp-common.h> #include <drm/drmP.h> #include <drm/drm_dp_helper.h> #include <drm/drm_panel.h> #include <drm/drm_probe_helper.h> +#include "rockchip_drm_drv.h" -#include "cdn-dp-reg.h" #define MAX_PHY 2
@@ -45,7 +46,6 @@ struct cdn_dp_device {struct cdns_mhdp_device mhdp;struct drm_device *drm_dev;struct drm_encoder encoder; -struct platform_device *audio_pdev;struct work_struct event_work;struct edid *edid;
@@ -64,7 +64,6 @@ struct cdn_dp_device {struct reset_control *dptx_rst;struct reset_control *apb_rst;struct reset_control *core_rst; -struct audio_info audio_info;struct cdn_dp_port *port[MAX_PHY ];u8 ports;u8 lanes;
include/drm/bridge/cdns-mhdp-cbs.h new file +29 -0
@@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Cadence MHDP DP bridge callbacks. +* +* Copyright: 2018 Cadence Design Systems, Inc. +* +* Author: Piotr Sroka <[email protected]> +*/ + +#ifndef CDNS_MHDP_CBS_H +#define CDNS_MHDP_CBS_H + +#include <drm/drm_bridge.h> + +struct cdns_mhdp_mst_cbs_funcs { +struct drm_encoder *(*create_mst_encoder)(void *priv_data, +struct drm_bridge *bridge); +void (*destroy_mst_encoder)(void *priv_data,struct drm_bridge *bridge); +}; + +struct cdns_mhdp_mst_cbs { +struct cdns_mhdp_mst_cbs_funcs funcs; +void *priv_data; +}; + +int mhdp_bridge_attach_mst_cbs (struct drm_bridge *bridge, +struct cdns_mhdp_mst_cbs *cbs); + +#endif
include/drm/bridge/cdns-mhdp-common.h renamed from drivers/gpu/drm/rockchip/cdn-dp-reg.h +58 -10
115 lines not on this page · raw message
Signature · 1 line
2.17.1
Hi,
Quoted 27 lines · Damian Kos
Hello!
This is the series of patches that will add support for the Cadence's DPI/DP bridge. Please note that this is a preliminary version of the driver and there will be more patches in the future with updates, fixes and improvements. Please keep that in mind when looking at FIXME/TODO/XXX comments.
Initially, MHDP driver was developed as a DRM bridge driver and was planed to be placed in
drivers/gpu/drm/bridge/mhdp.c. However, there was already a driver for Cadence's DP controller developed by RockChip, but that driver uses the different DRM framework and looks like a part of a bigger system. Both controllers (including firmware) are quite different internally (MST/FEC/DSC support, link training done by driver, additional commands, IRQ's etc.) but they have similar register map, except for Framer/Streamer (which is noticeably different), so they appear similar.The following patches contain:
- Moving common code todrivers/gpu/drm/bridge/cdns-mhdp-common.*and modifying it a bit (mostly new prefixes for functions and data types) so it can be used by two, higher level, drivers.
- Modifying existing RockChip's DP driver to use the common code after changes made to it (use the newcdns_mhdp_devicestructure and new function names).
- Modifying DRM helpers a bit. Some are required for new driver, some are updates from DP 1.2 to 1.3 or 1.4.
- Adding documentation for device tree bindings.
- Adding preliminary Cadence DPI/DP bridge driver.
Quoted 5 lines
Some of the things that will be added later on include (but are not limited to):
- DSC support
- FEC support
- HDCP support
A few random comments/questions after a quick look at the patches.
The names of the source files and the kernel Kconfig are only about "Cadence DP". But the DT bindings is for cdns,mhdp8546, and the resulting module file is mhdp8546.ko. I think more consistency here would be good.
I presume the part number (or family? are there other similar parts with similar part numbers?) is relevant, so it should be in the Kconfig option and help text, and probably in the file names too. The module name should have "cdns" prefix there, similar to the source files and the cdns-dsi.ko.
Or maybe the same driver will handle all Cadence DP parts, in which case generic filenames are fine, but then the resulting kernel module should also be just "cdns-mhdp.ko".
I see some audio functions in the code, but it's not mentioned in the DT bindings. I'm not an audio guy, but the display bridges with audio support I have seen have had DT bindings for the audio source too. Is audio supported in the current driver?
Tomi
Signature · 6 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Damian, ping.
Quoted 60 lines · Tomi Valkeinen
Hi,
Quoted 27 lines · Damian Kos
Hello!
This is the series of patches that will add support for the Cadence's DPI/DP bridge. Please note that this is a preliminary version of the driver and there will be more patches in the future with updates, fixes and improvements. Please keep that in mind when looking at FIXME/TODO/XXX comments.
Initially, MHDP driver was developed as a DRM bridge driver and was planed to be placed in
drivers/gpu/drm/bridge/mhdp.c. However, there was already a driver for Cadence's DP controller developed by RockChip, but that driver uses the different DRM framework and looks like a part of a bigger system. Both controllers (including firmware) are quite different internally (MST/FEC/DSC support, link training done by driver, additional commands, IRQ's etc.) but they have similar register map, except for Framer/Streamer (which is noticeably different), so they appear similar.The following patches contain:
- Moving common code todrivers/gpu/drm/bridge/cdns-mhdp-common.*and modifying it a bit (mostly new prefixes for functions and data types) so it can be used by two, higher level, drivers.
- Modifying existing RockChip's DP driver to use the common code after changes made to it (use the newcdns_mhdp_devicestructure and new function names).
- Modifying DRM helpers a bit. Some are required for new driver, some are updates from DP 1.2 to 1.3 or 1.4.
- Adding documentation for device tree bindings.
- Adding preliminary Cadence DPI/DP bridge driver.Quoted 5 lines
Some of the things that will be added later on include (but are not limited to):
- DSC support
- FEC support
- HDCP supportA few random comments/questions after a quick look at the patches.
The names of the source files and the kernel
Kconfigare only about "Cadence DP". But the DT bindings is for cdns,mhdp8546, and the resulting module file is mhdp8546.ko. I think more consistency here would be good.I presume the part number (or family? are there other similar parts with similar part numbers?) is relevant, so it should be in the
Kconfigoption and help text, and probably in the file names too. The module name should have "cdns" prefix there, similar to the source files and the cdns-dsi.ko.Or maybe the same driver will handle all Cadence DP parts, in which case generic filenames are fine, but then the resulting kernel module should also be just "cdns-mhdp.ko".
I see some audio functions in the code, but it's not mentioned in the DT bindings. I'm not an audio guy, but the display bridges with audio support I have seen have had DT bindings for the audio source too. Is audio supported in the current driver?
Tomi
Signature · 6 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 55 lines
Damian, ping.
Quoted 52 lines · Tomi Valkeinen
Hi,
Quoted 27 lines · Damian Kos
Hello!
This is the series of patches that will add support for the Cadence's DPI/DP bridge. Please note that this is a preliminary version of the driver and there will be more patches in the future with updates, fixes and improvements. Please keep that in mind when looking at FIXME/TODO/XXX comments.
Initially, MHDP driver was developed as a DRM bridge driver and was planed to be placed in
drivers/gpu/drm/bridge/mhdp.c. However, there was already a driver for Cadence's DP controller developed by RockChip, but that driver uses the different DRM framework and looks like a part of a bigger system. Both controllers (including firmware) are quite different internally (MST/FEC/DSC support, link training done by driver, additional commands, IRQ's etc.) but they have similar register map, except for Framer/Streamer (which is noticeably different), so they appear similar.The following patches contain:
- Moving common code todrivers/gpu/drm/bridge/cdns-mhdp-common.*and modifying it a bit (mostly new prefixes for functions and data types) so it can be used by two, higher level, drivers.
- Modifying existing RockChip's DP driver to use the common code after changes made to it (use the newcdns_mhdp_devicestructure and new function names).
- Modifying DRM helpers a bit. Some are required for new driver, some are updates from DP 1.2 to 1.3 or 1.4.
- Adding documentation for device tree bindings.
- Adding preliminary Cadence DPI/DP bridge driver.Quoted 5 lines
Some of the things that will be added later on include (but are not limited to):
- DSC support
- FEC support
- HDCP supportA few random comments/questions after a quick look at the patches.
The names of the source files and the kernel
Kconfigare only about "Cadence DP". But the DT bindings is for cdns,mhdp8546, and the resulting module file is mhdp8546.ko. I think more consistency here would be good.I presume the part number (or family? are there other similar parts with similar part numbers?) is relevant, so it should be in the
Kconfigoption and help text, and probably in the file names too. The module name should have "cdns" prefix there, similar to the source files and the cdns-dsi.ko.Or maybe the same driver will handle all Cadence DP parts, in which case generic filenames are fine, but then the resulting kernel module should also be just "cdns-mhdp.ko".
We would be very happy to have a separate driver for mhdp8546 instead of mixing it with Rockchip's driver. Unfortunately we need to have one driver for both IP's, so I'll just change mhdp8546.ko to cdns-mhdp.ko. (Unless, maintainers give us a green light for the dedicated driver?)
Quoted 6 lines
Quoted 6 lines
I see some audio functions in the code, but it's not mentioned in the DT bindings. I'm not an audio guy, but the display bridges with audio support I have seen have had DT bindings for the audio source too. Is audio supported in the current driver?
As far as I know, audio is working, but I can't double check it right now due to heavy load on my back right now. I'll try to find time for that in the next week. But, like I've mentioned earlier I don't see a reason why audio code (that exists in the mainline) wouldn't work.
I'm not an audio guy myself. When updating dt bindings I took the dt bindings for other bridges as an example, but I did not see any bindings for audio in them. I didn't check all of them. Can you please let me know which bridges are you were referring to? In our test environment we didn't use any audio driver as audio generator is so simple that it is part of the register space of IP and we didn't even need to include this device in .dts file. Audio (like the video) is configured and enabled by code that is not included in the patch (for obvious reasons).
So, in short, yes, driver supports audio and we will include description for audio input port in the dt bindings.
Quoted 6 lines
Quoted 2 lines
Tomi
Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Regards,
Damian
-----Original Message-----
From: Tomi Valkeinen <[email protected]>
Sent: Wednesday, March 20, 2019 10:34
To: Damian Kos <[email protected]>
Cc: David Airlie <[email protected]>; Daniel Vetter <[email protected]>; Rob Herring <[email protected]>; Mark Rutland <[email protected]>; Andrzej Hajda <[email protected]>; Laurent Pinchart <[email protected]>; Maarten Lankhorst <[email protected]>; Maxime Ripard <[email protected]>; Sean Paul <[email protected]>; Sandy Huang <[email protected]>; Heiko Stübner <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Piotr Sroka <[email protected]>; Rafal Ciepiela <[email protected]>
Subject: Re: [PATCH v7 0/4] drm: add support for Cadence MHDP DPI/DP bridge.
EXTERNAL MAIL
Damian, ping.
Quoted 60 lines · Tomi Valkeinen
Hi,
Quoted 27 lines · Damian Kos
Hello!
This is the series of patches that will add support for the Cadence's DPI/DP bridge. Please note that this is a preliminary version of the driver and there will be more patches in the future with updates, fixes and improvements. Please keep that in mind when looking at FIXME/TODO/XXX comments.
Initially, MHDP driver was developed as a DRM bridge driver and was planed to be placed in
drivers/gpu/drm/bridge/mhdp.c. However, there was already a driver for Cadence's DP controller developed by RockChip, but that driver uses the different DRM framework and looks like a part of a bigger system. Both controllers (including firmware) are quite different internally (MST/FEC/DSC support, link training done by driver, additional commands, IRQ's etc.) but they have similar register map, except for Framer/Streamer (which is noticeably different), so they appear similar.The following patches contain:
- Moving common code todrivers/gpu/drm/bridge/cdns-mhdp-common.*and modifying it a bit (mostly new prefixes for functions and data types) so it can be used by two, higher level, drivers.
- Modifying existing RockChip's DP driver to use the common code after changes made to it (use the newcdns_mhdp_devicestructure and new function names).
- Modifying DRM helpers a bit. Some are required for new driver, some are updates from DP 1.2 to 1.3 or 1.4.
- Adding documentation for device tree bindings.
- Adding preliminary Cadence DPI/DP bridge driver.Quoted 5 lines
Some of the things that will be added later on include (but are not limited to):
- DSC support
- FEC support
- HDCP supportA few random comments/questions after a quick look at the patches.
The names of the source files and the kernel
Kconfigare only about "Cadence DP". But the DT bindings is for cdns,mhdp8546, and the resulting module file is mhdp8546.ko. I think more consistency here would be good.I presume the part number (or family? are there other similar parts with similar part numbers?) is relevant, so it should be in the
Kconfigoption and help text, and probably in the file names too. The module name should have "cdns" prefix there, similar to the source files and the cdns-dsi.ko.Or maybe the same driver will handle all Cadence DP parts, in which case generic filenames are fine, but then the resulting kernel module should also be just "cdns-mhdp.ko".
I see some audio functions in the code, but it's not mentioned in the DT bindings. I'm not an audio guy, but the display bridges with audio support I have seen have had DT bindings for the audio source too. Is audio supported in the current driver?
Tomi
Signature · 6 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 4 lines · Damian Kos
We would be very happy to have a separate driver for mhdp8546 instead of mixing it with Rockchip's driver. Unfortunately we need to have one driver for both IP's, so I'll just change mhdp8546.ko to cdns-mhdp.ko. (Unless, maintainers give us a green light for the dedicated driver?)
Ok. I don't know about the differences, so I can't say much here. But I do think that you shouldn't combine drivers for two different IPs unless they are very similar. And if two different IPs have a block that's the same/similar, the code for that block can be extracted to a "library" used by both drivers.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
I see some audio functions in the code, but it's not mentioned in the DT bindings. I'm not an audio guy, but the display bridges with audio support I have seen have had DT bindings for the audio source too. Is audio supported in the current driver?
Quoted 14 lines
As far as I know, audio is working, but I can't double check it right now due to heavy load on my back right now. I'll try to find time for that in the next week. But, like I've mentioned earlier I don't see a reason why audio code (that exists in the mainline) wouldn't work.
I'm not an audio guy myself. When updating dt bindings I took the dt bindings for other bridges as an example, but I did not see any bindings for audio in them. I didn't check all of them. Can you please let me know which bridges are you were referring to? In our test environment we didn't use any audio driver as audio generator is so simple that it is part of the register space of IP and we didn't even need to include this device in .dts file. Audio (like the video) is configured and enabled by code that is not included in the patch (for obvious reasons).
So, in short, yes, driver supports audio and we will include description for audio input port in the dt bindings.
Ok. Jyri Sarha <[email protected]> recently sent "drm/bridge: sii902x:
HDMI-audio support and some fixes" series, and I think tda998x_drv.c also has some audio support. But I'm no audio guy either =). I was just curious about the status of the audio.
Tomi
Signature · 6 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel