lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAAOTY__9Emac0Lc=afZMcJzCuO-myJDS--rshMkkrVZr9imSog@mail.gmail.com>
Date:   Wed, 26 May 2021 10:59:09 +0800
From:   Chun-Kuang Hu <chunkuang.hu@...nel.org>
To:     Rex-BC Chen <rex-bc.chen@...iatek.com>
Cc:     Chun-Kuang Hu <chunkuang.hu@...nel.org>,
        Matthias Brugger <matthias.bgg@...il.com>,
        DTML <devicetree@...r.kernel.org>,
        Linux ARM <linux-arm-kernel@...ts.infradead.org>,
        "moderated list:ARM/Mediatek SoC support" 
        <linux-mediatek@...ts.infradead.org>,
        linux-kernel <linux-kernel@...r.kernel.org>,
        Project_Global_Chrome_Upstream_Group@...iatek.com,
        Jitao Shi <jitao.shi@...iatek.com>
Subject: Re: [v4,PATCH 3/3] drm/mediatek: dpi: add bus format negotiation

Hi, Rex:

Rex-BC Chen <rex-bc.chen@...iatek.com> 於 2021年5月25日 週二 下午8:15寫道:
>
> Add the atomic_get_output_bus_fmts, atomic_get_input_bus_fmts to negotiate
> 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@...iatek.com>
> Signed-off-by: Rex-BC Chen <rex-bc.chen@...iatek.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_dpi.c | 78 ++++++++++++++++++++++++++++--
>  1 file changed, 73 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c
> index d6a422986efc..667a97470389 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dpi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c
> @@ -540,6 +540,73 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi,
>         return 0;
>  }
>
> +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 mtk_dpi *dpi = bridge_to_dpi(bridge);
> +
> +       *num_output_fmts = 0;
> +
> +       if (!dpi->conf->output_fmts)

print error here because this should not happen.

> +               return NULL;
> +
> +       *num_output_fmts = dpi->conf->num_output_fmts;
> +
> +       return (u32 *)dpi->conf->output_fmts;

I think you should allocate new buffer for output_fmts because the
caller would free it.

> +}
> +
> +#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;

it seems that MAX_INPUT_SEL_FORMATS has no influence here. Maybe just
remove MAX_INPUT_SEL_FORMATS, or you should have flexibility here for
different MAX_INPUT_SEL_FORMATS value.

> +
> +       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;
> +       unsigned int out_bus_format;
> +
> +       out_bus_format = 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 = (out_bus_format == MEDIA_BUS_FMT_RGB888_2X12_LE) ?
> +                          true : false;

dpi->output_fmt = out_bus_format;

Regards,
Chun-Kuang.

> +
> +       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)
>  {
> @@ -592,6 +659,12 @@ static const struct drm_bridge_funcs mtk_dpi_bridge_funcs = {
>         .mode_valid = mtk_dpi_bridge_mode_valid,
>         .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,
> +       .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
> +       .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
> +       .atomic_reset = drm_atomic_helper_bridge_reset,
>  };
>
>  void mtk_dpi_start(struct device *dev)
> @@ -638,11 +711,6 @@ static int mtk_dpi_bind(struct device *dev, struct device *master, void *data)
>         }
>         drm_connector_attach_encoder(dpi->connector, &dpi->encoder);
>
> -       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:
> --
> 2.18.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ