devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: CK Hu <ck.hu@mediatek.com>
To: Jitao Shi <jitao.shi@mediatek.com>
Cc: Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Daniel Vetter <daniel@ffwll.ch>, David Airlie <airlied@linux.ie>,
	<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>,
	<linux-mediatek@lists.infradead.org>,
	<devicetree@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<srv_heupstream@mediatek.com>, <yingjoe.chen@mediatek.com>,
	<eddie.huang@mediatek.com>, <cawa.cheng@mediatek.com>,
	<bibby.hsieh@mediatek.com>, <stonea168@163.com>,
	<huijuan.xie@mediatek.com>, <rex-bc.chen@mediatek.com>
Subject: Re: [PATCH 3/3] drm/mediatek: dpi: add bus format negociation
Date: Thu, 1 Apr 2021 10:08:12 +0800	[thread overview]
Message-ID: <1617242892.14305.5.camel@mtksdaap41> (raw)
In-Reply-To: <20210330155330.28759-4-jitao.shi@mediatek.com>

Hi, Jitao:

On Tue, 2021-03-30 at 23:53 +0800, Jitao Shi wrote:
> Add the atomic_get_output_bus_fmts, atomic_get_input_bus_fmts to negociate
> 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 <jitao.shi@mediatek.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_dpi.c | 96 ++++++++++++++++++++++++++++++++++++--
>  1 file changed, 91 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c
> index 87bb27649c4c..4e45d1b01b0c 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dpi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c
> @@ -81,6 +81,8 @@ struct mtk_dpi {
>  	struct pinctrl *pinctrl;
>  	struct pinctrl_state *pins_gpio;
>  	struct pinctrl_state *pins_dpi;
> +	unsigned int in_bus_format;
> +	unsigned int out_bus_format;

Why do you keep these two value? You does not use them.

>  	bool ddr_edge_sel;
>  	int refcount;
>  };
> @@ -534,6 +536,92 @@ 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_state,
> +					struct drm_crtc_state *crtc_state,
> +					struct drm_connector_state *conn_state,
> +					unsigned int *num_output_fmts)
> +{
> +	struct drm_display_mode *mode = &crtc_state->mode;
> +	u32 *output_fmts;
> +	struct mtk_dpi *dpi = bridge_to_dpi(bridge);
> +
> +	*num_output_fmts = 0;
> +
> +	output_fmts = kcalloc(MAX_OUTPUT_SEL_FORMATS, sizeof(*output_fmts),
> +			      GFP_KERNEL);
> +	if (!output_fmts)
> +		return NULL;
> +
> +	/* Default 8bit RGB fallback */
> +	if (dpi->conf->dual_edge) {
> +		output_fmts[0] =  MEDIA_BUS_FMT_RGB888_2X12_LE;
> +		output_fmts[1] =  MEDIA_BUS_FMT_RGB888_2X12_BE;

So mt8183 does not support MEDIA_BUS_FMT_RGB888_1X24?

> +		*num_output_fmts = 2;
> +	} else {
> +		output_fmts[0] =  MEDIA_BUS_FMT_RGB888_1X24;
> +		*num_output_fmts = 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_state,
> +					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 = 0;
> +
> +	input_fmts = kcalloc(MAX_INPUT_SEL_FORMATS, sizeof(*input_fmts),
> +			     GFP_KERNEL);
> +	if (!input_fmts)
> +		return NULL;
> +
> +	*num_input_fmts = 1;
> +	input_fmts[0] = MEDIA_BUS_FMT_RGB888_1X24;
> +
> +	return input_fmts;
> +}
> +
> +static int mtk_dpi_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 mtk_dpi *dpi = bridge->driver_private;
> +
> +	dpi->out_bus_format = bridge_state->output_bus_cfg.format;
> +
> +	dpi->in_bus_format = bridge_state->input_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);
> +
> +	if (dpi->out_bus_format == MEDIA_BUS_FMT_RGB888_2X12_LE ||
> +	    dpi->out_bus_format == MEDIA_BUS_FMT_RGB888_2X12_BE) {

I think you could remove this 'if' checking.

Regards,
CK.

> +		dpi->ddr_edge_sel =
> +			(dpi->out_bus_format == MEDIA_BUS_FMT_RGB888_2X12_LE) ?
> +			 true : false;
> +	}
> +
> +	dpi->bit_num = MTK_DPI_OUT_BIT_NUM_8BITS;
> +	dpi->channel_swap = MTK_DPI_OUT_CHANNEL_SWAP_RGB;
> +	dpi->yc_map = MTK_DPI_OUT_YC_MAP_RGB;
> +	dpi->color_format = MTK_DPI_COLOR_FORMAT_RGB;
> +
> +	return 0;
> +}
> +
>  static int mtk_dpi_bridge_attach(struct drm_bridge *bridge,
>  				 enum drm_bridge_attach_flags flags)
>  {
> @@ -572,6 +660,9 @@ static const struct drm_bridge_funcs mtk_dpi_bridge_funcs = {
>  	.mode_set = mtk_dpi_bridge_mode_set,
>  	.disable = mtk_dpi_bridge_disable,
>  	.enable = mtk_dpi_bridge_enable,
> +	.atomic_check = mtk_dpi_bridge_atomic_check,
> +	.atomic_get_output_bus_fmts = mtk_dpi_bridge_atomic_get_output_bus_fmts,
> +	.atomic_get_input_bus_fmts = mtk_dpi_bridge_atomic_get_input_bus_fmts,
>  };
>  
>  static void mtk_dpi_start(struct mtk_ddp_comp *comp)
> @@ -621,11 +712,6 @@ static int mtk_dpi_bind(struct device *dev, struct device *master, void *data)
>  		goto err_cleanup;
>  	}
>  
> -	dpi->bit_num = MTK_DPI_OUT_BIT_NUM_8BITS;
> -	dpi->channel_swap = MTK_DPI_OUT_CHANNEL_SWAP_RGB;
> -	dpi->yc_map = MTK_DPI_OUT_YC_MAP_RGB;
> -	dpi->color_format = MTK_DPI_COLOR_FORMAT_RGB;
> -
>  	return 0;
>  
>  err_cleanup:


      reply	other threads:[~2021-04-01  2:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-30 15:53 [PATCH 0/3] mt8183 dpi supports dual edge Jitao Shi
2021-03-30 15:53 ` [PATCH 1/3] drm/mediatek: dpi dual edge sample mode support Jitao Shi
2021-03-30 15:53 ` [PATCH 2/3] drm/mediatek: config mt8183 driver data to support dual edge sample Jitao Shi
2021-03-30 15:53 ` [PATCH 3/3] drm/mediatek: dpi: add bus format negociation Jitao Shi
2021-04-01  2:08   ` CK Hu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1617242892.14305.5.camel@mtksdaap41 \
    --to=ck.hu@mediatek.com \
    --cc=airlied@linux.ie \
    --cc=bibby.hsieh@mediatek.com \
    --cc=cawa.cheng@mediatek.com \
    --cc=daniel@ffwll.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=eddie.huang@mediatek.com \
    --cc=huijuan.xie@mediatek.com \
    --cc=jitao.shi@mediatek.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=matthias.bgg@gmail.com \
    --cc=rex-bc.chen@mediatek.com \
    --cc=robh+dt@kernel.org \
    --cc=srv_heupstream@mediatek.com \
    --cc=stonea168@163.com \
    --cc=yingjoe.chen@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).