Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp2126435pxt; Sun, 8 Aug 2021 12:29:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIWXs+RDXmeI2gCMs/essbJIyHAa0McsQNTwTuD0rskeMsybJB71cTINa4cjp2I2sW/ivW X-Received: by 2002:a05:6602:2199:: with SMTP id b25mr61761iob.75.1628450982912; Sun, 08 Aug 2021 12:29:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628450982; cv=none; d=google.com; s=arc-20160816; b=zvuZArW/Q4hJaCz6K5vp6M44LdjcrBrnBx3o4F/HuEzg0cNL8h5LUgx9mOU77BzSpe N71WyCZx/8QxgvNOxX7GnHPrRXXM5WIBm68H/VB694IHJZfNJG/DXn/BJ3ePkzKYB4P8 3Oysc8BMK2/2WXuDhFbVKhp/hEmVt62LY7owAGv31I3cO/opzKNtpfCpynbCBP1T13qh 0acLpF9CaGoOt3HfsD56nIlLniV2x0iPawaz06vq+UWURCgfDhxtSCGvI17Fqn3GpTJE nNL8DE4754zOBFLsxp9q/Wxe/17KSWBcycN7vjHlA7W+OmcDff/VFtDKQ89nCc92ZtxZ Pjaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:cc:to:subject:from:date; bh=8RdELrrwxdNh61vZYhDO8Ylu4x9UriY6mZNo35iJQH8=; b=M8e+36VFPQ7r0SB8BlH+7PAS/6cO3XvgpS2pMec5EPO95/Pl8IpBgTkoCdJR9XtVcd hfnKHvn4pEXVtVTDbXvK2bTsszmtmahhsv8xwXj5+R245/3bV0VSUzH47vHiuGVzMRoj ETbxgCMUZGbtoOAqCfm39qA4V4b6TOvMCPu9umJhaJpECSrBIXFyybMIVvYdnGpqqM5W TrTvrGFdPi5P2PWUfa4sLFBHjSWghOr8sxsQE4TRm8YkU/ENVsIOIpWb4eHXDcsPRIBr Zwsz1Mg7eIF5LA6y40Q58HpaDobaamsuI/7wnnaJXZf4sHCvNuMxyr8d8YrCAsWoEdUV lI1A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a5si15643616ioo.37.2021.08.08.12.29.32; Sun, 08 Aug 2021 12:29:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232387AbhHHTFU convert rfc822-to-8bit (ORCPT + 99 others); Sun, 8 Aug 2021 15:05:20 -0400 Received: from aposti.net ([89.234.176.197]:45774 "EHLO aposti.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232260AbhHHTFT (ORCPT ); Sun, 8 Aug 2021 15:05:19 -0400 Date: Sun, 08 Aug 2021 21:04:52 +0200 From: Paul Cercueil Subject: Re: [PATCH 8/8] drm/ingenic: Attach bridge chain to encoders To: "H. Nikolaus Schaller" Cc: David Airlie , Daniel Vetter , Paul Boddie , list@opendingux.net, Sam Ravnborg , linux-mips , dri-devel , linux-kernel , Discussions about the Letux Kernel Message-Id: <4OBJXQ.DA6PDYNSVNYV1@crapouillou.net> In-Reply-To: <2AEC5953-FE54-4DD5-88B7-783C4D9E23B2@goldelico.com> References: <20210808134526.119198-1-paul@crapouillou.net> <20210808134526.119198-9-paul@crapouillou.net> <2AEC5953-FE54-4DD5-88B7-783C4D9E23B2@goldelico.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Nikolaus, Le dim., ao?t 8 2021 at 20:57:09 +0200, H. Nikolaus Schaller a ?crit : > Hi Paul, > all other patches apply cleanly but this one fails on top of > v5.14-rc4. > What base are you using? > BR and thanks, > Nikolaus The base is drm-misc (https://cgit.freedesktop.org/drm/drm-misc), branch drm-misc-next. Cheers, -Paul >> Am 08.08.2021 um 15:45 schrieb Paul Cercueil : >> >> Attach a top-level bridge to each encoder, which will be used for >> negociating the bus format and flags. >> >> All the bridges are now attached with >> DRM_BRIDGE_ATTACH_NO_CONNECTOR. >> >> Signed-off-by: Paul Cercueil >> --- >> drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 92 >> +++++++++++++++++------ >> 1 file changed, 70 insertions(+), 22 deletions(-) >> >> diff --git a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c >> b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c >> index 7ae48ead3ab6..09d5dd298078 100644 >> --- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c >> +++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c >> @@ -21,6 +21,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -107,6 +108,19 @@ struct ingenic_drm { >> struct drm_private_obj private_obj; >> }; >> >> +struct ingenic_drm_bridge { >> + struct drm_encoder encoder; >> + struct drm_bridge bridge, *next_bridge; >> + >> + struct drm_bus_cfg bus_cfg; >> +}; >> + >> +static inline struct ingenic_drm_bridge * >> +to_ingenic_drm_bridge(struct drm_encoder *encoder) >> +{ >> + return container_of(encoder, struct ingenic_drm_bridge, encoder); >> +} >> + >> static inline struct ingenic_drm_private_state * >> to_ingenic_drm_priv_state(struct drm_private_state *state) >> { >> @@ -679,11 +693,10 @@ static void >> ingenic_drm_encoder_atomic_mode_set(struct drm_encoder *encoder, >> { >> struct ingenic_drm *priv = drm_device_get_priv(encoder->dev); >> struct drm_display_mode *mode = &crtc_state->adjusted_mode; >> - struct drm_connector *conn = conn_state->connector; >> - struct drm_display_info *info = &conn->display_info; >> + struct ingenic_drm_bridge *bridge = >> to_ingenic_drm_bridge(encoder); >> unsigned int cfg, rgbcfg = 0; >> >> - priv->panel_is_sharp = info->bus_flags & >> DRM_BUS_FLAG_SHARP_SIGNALS; >> + priv->panel_is_sharp = bridge->bus_cfg.flags & >> DRM_BUS_FLAG_SHARP_SIGNALS; >> >> if (priv->panel_is_sharp) { >> cfg = JZ_LCD_CFG_MODE_SPECIAL_TFT_1 | JZ_LCD_CFG_REV_POLARITY; >> @@ -696,19 +709,19 @@ static void >> ingenic_drm_encoder_atomic_mode_set(struct drm_encoder *encoder, >> cfg |= JZ_LCD_CFG_HSYNC_ACTIVE_LOW; >> if (mode->flags & DRM_MODE_FLAG_NVSYNC) >> cfg |= JZ_LCD_CFG_VSYNC_ACTIVE_LOW; >> - if (info->bus_flags & DRM_BUS_FLAG_DE_LOW) >> + if (bridge->bus_cfg.flags & DRM_BUS_FLAG_DE_LOW) >> cfg |= JZ_LCD_CFG_DE_ACTIVE_LOW; >> - if (info->bus_flags & DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE) >> + if (bridge->bus_cfg.flags & DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE) >> cfg |= JZ_LCD_CFG_PCLK_FALLING_EDGE; >> >> if (!priv->panel_is_sharp) { >> - if (conn->connector_type == DRM_MODE_CONNECTOR_TV) { >> + if (conn_state->connector->connector_type == >> DRM_MODE_CONNECTOR_TV) { >> if (mode->flags & DRM_MODE_FLAG_INTERLACE) >> cfg |= JZ_LCD_CFG_MODE_TV_OUT_I; >> else >> cfg |= JZ_LCD_CFG_MODE_TV_OUT_P; >> } else { >> - switch (*info->bus_formats) { >> + switch (bridge->bus_cfg.format) { >> case MEDIA_BUS_FMT_RGB565_1X16: >> cfg |= JZ_LCD_CFG_MODE_GENERIC_16BIT; >> break; >> @@ -734,20 +747,29 @@ static void >> ingenic_drm_encoder_atomic_mode_set(struct drm_encoder *encoder, >> regmap_write(priv->map, JZ_REG_LCD_RGBC, rgbcfg); >> } >> >> -static int ingenic_drm_encoder_atomic_check(struct drm_encoder >> *encoder, >> - struct drm_crtc_state *crtc_state, >> - struct drm_connector_state *conn_state) >> +static int ingenic_drm_bridge_attach(struct drm_bridge *bridge, >> + enum drm_bridge_attach_flags flags) >> +{ >> + struct ingenic_drm_bridge *ib = >> to_ingenic_drm_bridge(bridge->encoder); >> + >> + return drm_bridge_attach(bridge->encoder, ib->next_bridge, >> + &ib->bridge, flags); >> +} >> + >> +static int ingenic_drm_bridge_atomic_check(struct drm_bridge >> *bridge, >> + struct drm_bridge_state *bridge_state, >> + struct drm_crtc_state *crtc_state, >> + struct drm_connector_state *conn_state) >> { >> - struct drm_display_info *info = >> &conn_state->connector->display_info; >> struct drm_display_mode *mode = &crtc_state->adjusted_mode; >> + struct ingenic_drm_bridge *ib = >> to_ingenic_drm_bridge(bridge->encoder); >> >> - if (info->num_bus_formats != 1) >> - return -EINVAL; >> + ib->bus_cfg = bridge_state->output_bus_cfg; >> >> if (conn_state->connector->connector_type == DRM_MODE_CONNECTOR_TV) >> return 0; >> >> - switch (*info->bus_formats) { >> + switch (bridge_state->output_bus_cfg.format) { >> case MEDIA_BUS_FMT_RGB888_3X8: >> case MEDIA_BUS_FMT_RGB888_3X8_DELTA: >> /* >> @@ -911,8 +933,16 @@ static const struct drm_crtc_helper_funcs >> ingenic_drm_crtc_helper_funcs = { >> }; >> >> static const struct drm_encoder_helper_funcs >> ingenic_drm_encoder_helper_funcs = { >> - .atomic_mode_set = ingenic_drm_encoder_atomic_mode_set, >> - .atomic_check = ingenic_drm_encoder_atomic_check, >> + .atomic_mode_set = ingenic_drm_encoder_atomic_mode_set, >> +}; >> + >> +static const struct drm_bridge_funcs ingenic_drm_bridge_funcs = { >> + .attach = ingenic_drm_bridge_attach, >> + .atomic_check = ingenic_drm_bridge_atomic_check, >> + .atomic_reset = drm_atomic_helper_bridge_reset, >> + .atomic_duplicate_state = >> drm_atomic_helper_bridge_duplicate_state, >> + .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, >> + .atomic_get_input_bus_fmts = >> drm_atomic_helper_bridge_propagate_bus_fmt, >> }; >> >> static const struct drm_mode_config_funcs >> ingenic_drm_mode_config_funcs = { >> @@ -958,7 +988,9 @@ static int ingenic_drm_bind(struct device *dev, >> bool has_components) >> struct drm_plane *primary; >> struct drm_bridge *bridge; >> struct drm_panel *panel; >> + struct drm_connector *connector; >> struct drm_encoder *encoder; >> + struct ingenic_drm_bridge *ib; >> struct drm_device *drm; >> void __iomem *base; >> long parent_rate; >> @@ -1146,20 +1178,36 @@ static int ingenic_drm_bind(struct device >> *dev, bool has_components) >> bridge = devm_drm_panel_bridge_add_typed(dev, panel, >> DRM_MODE_CONNECTOR_DPI); >> >> - encoder = drmm_plain_encoder_alloc(drm, NULL, >> DRM_MODE_ENCODER_DPI, NULL); >> - if (IS_ERR(encoder)) { >> - ret = PTR_ERR(encoder); >> + ib = drmm_encoder_alloc(drm, struct ingenic_drm_bridge, encoder, >> + NULL, DRM_MODE_ENCODER_DPI, NULL); >> + if (IS_ERR(ib)) { >> + ret = PTR_ERR(ib); >> dev_err(dev, "Failed to init encoder: %d\n", ret); >> return ret; >> } >> >> - encoder->possible_crtcs = 1; >> + encoder = &ib->encoder; >> + encoder->possible_crtcs = drm_crtc_mask(&priv->crtc); >> >> drm_encoder_helper_add(encoder, >> &ingenic_drm_encoder_helper_funcs); >> >> - ret = drm_bridge_attach(encoder, bridge, NULL, 0); >> - if (ret) >> + ib->bridge.funcs = &ingenic_drm_bridge_funcs; >> + ib->next_bridge = bridge; >> + >> + ret = drm_bridge_attach(encoder, &ib->bridge, NULL, >> + DRM_BRIDGE_ATTACH_NO_CONNECTOR); >> + if (ret) { >> + dev_err(dev, "Unable to attach bridge\n"); >> return ret; >> + } >> + >> + connector = drm_bridge_connector_init(drm, encoder); >> + if (IS_ERR(connector)) { >> + dev_err(dev, "Unable to init connector\n"); >> + return PTR_ERR(connector); >> + } >> + >> + drm_connector_attach_encoder(connector, encoder); >> } >> >> drm_for_each_encoder(encoder, drm) { >> -- >> 2.30.2 >> >