Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3980654pxj; Tue, 11 May 2021 16:51:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+L2pMnfKUzYp8X6+inX6NfvShqC1QYHfZZUw86UJYZcbjd1FXmSrs0I/82TD1wa08hEYl X-Received: by 2002:aca:3684:: with SMTP id d126mr24187344oia.129.1620777103640; Tue, 11 May 2021 16:51:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620777103; cv=none; d=google.com; s=arc-20160816; b=OqsA5Dbnzoo1dwCCWhG9lYZg8sd9pGK1eVxO8pTmOPZj8YrSWqAwU+yem5dKP9cOnW bYd32Kv8gWyNDsZUzqAztYbBS+Nyis5cMVGqnBInxLC6mFIGl+TNTwi/+vU+ZGThoWj+ SKJ6OvrzW+5ZM31oDL1bmspFrKVza4vd3EtNbJPFMlrPI28Fg5oF1LQlxWbbDto1X1nf 3QVR7zVj9XJs1TwH30fgBdeyxKvlz00YJQMdzMmg67yXYPQTXC0V8Z8mcn0ChFls5AFr aUuaPAPayd0+ldqg/xtGl/c4cEiedAiMLNCqwUq0QUuu4fWarOF+joAuBSsEwi4hVE5O D8TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=AvKrF11WJBhR4b6nhMeG6zL8lSDRrC2m2z/2pEcVuAE=; b=Q6SuvBGUBxCgitwhTzj96XNxFmRNk+7Upj8DCbW4wH131PNu3n4lXU9rpDvL02niO2 FVwAONGM1gkITskt5+n0nWkwaxoV3vnIRTbWRdg3LmsAFSPt3JXiZhpxpMA7peVe2vwU JJSd9/3YfnJAJKVuK2aX0wXagjDQSua3rsqExK/YCE2c3+035dQvKhHDWOKXd8QNYUFk YtTujqMS4VqAIQRxvRAZ5IvmQ1CP5zr/uZq8vwuU0ih6p1mQUJZ+Ikv/+ORZuzWWHz/G Xev/x+aLCXCoNAzhzWNn+5tU5unCp35uAEtNftg9T+nN6zWu1uHwjhk2nMOeAX2+QmE1 GLLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="O7IBcM/j"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m15si7614048otp.46.2021.05.11.16.51.29; Tue, 11 May 2021 16:51:43 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="O7IBcM/j"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229925AbhEKXwF (ORCPT + 99 others); Tue, 11 May 2021 19:52:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:36120 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229637AbhEKXwF (ORCPT ); Tue, 11 May 2021 19:52:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1BA716187E; Tue, 11 May 2021 23:50:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620777058; bh=F5ZEQuF0H9iy+oscjWcT5j+fhCa3iygNB9Kp4e81/pE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=O7IBcM/jHmtJjTBZ+0nNpaPPz/f2AOYcSHLOnCwFuwfnef1H4EhcK7xVOe0CMGTSQ 6cLI9+89r+sqpvNuNRk5ajcgk6RqNLtB0LBTeebiFKfq4z/BBLiMmS0F6Bo8kq7yS5 8iI9+YVEITzMoWx1LYhTnaFAPVjGEGjp+J2zt9O21ZsfijQqmckUcNUMIX8OozvwyQ b1OsD/88PMWK6bz4Vn2HppEKMKaskLeBoFAZkCYYDU+h4tghUp6SGaMBjxPt2im7mu mSchn0VcimtB33HQ+UGH+J+igGbTz/zZAv9+3dsTh4OCE4oLvMIS8Zkq5S4zYotr4w YBLsXEmdx/Kbw== Received: by mail-ej1-f46.google.com with SMTP id m12so32323493eja.2; Tue, 11 May 2021 16:50:58 -0700 (PDT) X-Gm-Message-State: AOAM531wroLBjTy0TZGPsn8f+TyA1dhXZll/aVatrnX+Si0omHPn43vW htMdJGQ5S9cyz3+crHdnCCeZFEv34RKC6dggFw== X-Received: by 2002:a17:906:b0cb:: with SMTP id bk11mr34935753ejb.310.1620777056572; Tue, 11 May 2021 16:50:56 -0700 (PDT) MIME-Version: 1.0 References: <20210429041641.11077-1-rex-bc.chen@mediatek.com> <20210429041641.11077-4-rex-bc.chen@mediatek.com> In-Reply-To: <20210429041641.11077-4-rex-bc.chen@mediatek.com> From: Chun-Kuang Hu Date: Wed, 12 May 2021 07:50:45 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [v3 RESEND,PATCH 3/3] drm/mediatek: dpi: add bus format negotiation To: Rex-BC Chen Cc: Chun-Kuang Hu , Matthias Brugger , DTML , Linux ARM , "moderated list:ARM/Mediatek SoC support" , linux-kernel , Project_Global_Chrome_Upstream_Group@mediatek.com, Jitao Shi Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Rex: Rex-BC Chen =E6=96=BC 2021=E5=B9=B44=E6=9C=8829= =E6=97=A5 =E9=80=B1=E5=9B=9B =E4=B8=8B=E5=8D=8812:16=E5=AF=AB=E9=81=93=EF= =BC=9A > > Add the atomic_get_output_bus_fmts, atomic_get_input_bus_fmts to negotiat= e > the possible output and input formats for the current mode and monitor, > and use the negotiated formats in a basic atomic_check callback. > > Signed-off-by: Jitao Shi > Signed-off-by: Rex-BC Chen > --- > drivers/gpu/drm/mediatek/mtk_dpi.c | 92 ++++++++++++++++++++++++++++-- > 1 file changed, 87 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediate= k/mtk_dpi.c > index c548780dd3a5..8822d9448ae8 100644 > --- a/drivers/gpu/drm/mediatek/mtk_dpi.c > +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c > @@ -536,6 +536,87 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *= dpi, > return 0; > } > > +#define MAX_OUTPUT_SEL_FORMATS 2 > + > +static u32 *mtk_dpi_bridge_atomic_get_output_bus_fmts(struct drm_bridge = *bridge, > + struct drm_bridge_state *bridge_s= tate, > + struct drm_crtc_state *crtc_state= , > + struct drm_connector_state *conn_= state, > + unsigned int *num_output_fmts) > +{ > + u32 *output_fmts; > + struct mtk_dpi *dpi =3D bridge_to_dpi(bridge); > + > + *num_output_fmts =3D 0; > + > + output_fmts =3D kcalloc(MAX_OUTPUT_SEL_FORMATS, sizeof(*output_fm= ts), > + GFP_KERNEL); > + if (!output_fmts) > + return NULL; > + > + /* Default 8bit RGB fallback */ > + if (dpi->conf->dual_edge) { > + output_fmts[0] =3D MEDIA_BUS_FMT_RGB888_2X12_LE; > + output_fmts[1] =3D MEDIA_BUS_FMT_RGB888_2X12_BE; > + *num_output_fmts =3D 2; In the definition of dual_edge, it may imply that support MEDIA_BUS_FMT_BGR565_2X8_BE and MEDIA_BUS_FMT_BGR565_2X8_LE. So I would like dpi->conf to store output_fmts instead of dual_edge. The output_fmts could imply use dual_edge or not. Regards, Chun-Kuang. > + } else { > + output_fmts[0] =3D MEDIA_BUS_FMT_RGB888_1X24; > + *num_output_fmts =3D 1; > + } > + > + return output_fmts; > +} > + > +#define MAX_INPUT_SEL_FORMATS 1 > + > +static u32 *mtk_dpi_bridge_atomic_get_input_bus_fmts(struct drm_bridge *= bridge, > + struct drm_bridge_state *bridge_s= tate, > + struct drm_crtc_state *crtc_state= , > + struct drm_connector_state *conn_= state, > + u32 output_fmt, > + unsigned int *num_input_fmts) > +{ > + u32 *input_fmts; > + > + *num_input_fmts =3D 0; > + > + input_fmts =3D kcalloc(MAX_INPUT_SEL_FORMATS, sizeof(*input_fmts)= , > + GFP_KERNEL); > + if (!input_fmts) > + return NULL; > + > + *num_input_fmts =3D 1; > + input_fmts[0] =3D MEDIA_BUS_FMT_RGB888_1X24; > + > + return input_fmts; > +} > + > +static int mtk_dpi_bridge_atomic_check(struct drm_bridge *bridge, > + struct drm_bridge_state *bridge_st= ate, > + struct drm_crtc_state *crtc_state, > + struct drm_connector_state *conn_s= tate) > +{ > + struct mtk_dpi *dpi =3D bridge->driver_private; > + unsigned int out_bus_format; > + > + out_bus_format =3D bridge_state->output_bus_cfg.format; > + > + dev_dbg(dpi->dev, "input format 0x%04x, output format 0x%04x\n", > + bridge_state->input_bus_cfg.format, > + bridge_state->output_bus_cfg.format); > + > + dpi->ddr_edge_sel =3D (out_bus_format =3D=3D MEDIA_BUS_FMT_RGB888= _2X12_LE) ? > + true : false; > + > + dpi->bit_num =3D MTK_DPI_OUT_BIT_NUM_8BITS; > + dpi->channel_swap =3D MTK_DPI_OUT_CHANNEL_SWAP_RGB; > + dpi->yc_map =3D MTK_DPI_OUT_YC_MAP_RGB; > + dpi->color_format =3D MTK_DPI_COLOR_FORMAT_RGB; > + > + return 0; > +} > + > static int mtk_dpi_bridge_attach(struct drm_bridge *bridge, > enum drm_bridge_attach_flags flags) > { > > @@ -574,6 +655,12 @@ static const struct drm_bridge_funcs mtk_dpi_bridge_= funcs =3D { > .mode_set =3D mtk_dpi_bridge_mode_set, > .disable =3D mtk_dpi_bridge_disable, > .enable =3D mtk_dpi_bridge_enable, > + .atomic_check =3D mtk_dpi_bridge_atomic_check, > + .atomic_get_output_bus_fmts =3D mtk_dpi_bridge_atomic_get_output_= bus_fmts, > + .atomic_get_input_bus_fmts =3D mtk_dpi_bridge_atomic_get_input_bu= s_fmts, > + .atomic_duplicate_state =3D drm_atomic_helper_bridge_duplicate_st= ate, > + .atomic_destroy_state =3D drm_atomic_helper_bridge_destroy_state, > + .atomic_reset =3D drm_atomic_helper_bridge_reset, > }; > > void mtk_dpi_start(struct device *dev) > @@ -620,11 +707,6 @@ static int mtk_dpi_bind(struct device *dev, struct d= evice *master, void *data) > } > drm_connector_attach_encoder(dpi->connector, &dpi->encoder); > > - dpi->bit_num =3D MTK_DPI_OUT_BIT_NUM_8BITS; > - dpi->channel_swap =3D MTK_DPI_OUT_CHANNEL_SWAP_RGB; > - dpi->yc_map =3D MTK_DPI_OUT_YC_MAP_RGB; > - dpi->color_format =3D MTK_DPI_COLOR_FORMAT_RGB; > - > return 0; > > err_cleanup: > -- > 2.18.0 >