From: YT Shen <yt.shen@mediatek.com>
To: Daniel Kurtz <djkurtz@chromium.org>
Cc: "Daniel Vetter" <daniel.vetter@ffwll.ch>,
dri-devel <dri-devel@lists.freedesktop.org>,
"Jie Qiu" <jie.qiu@mediatek.com>,
"Mao Huang" <littlecvr@chromium.org>,
"Yingjoe Chen (陳英洲)" <Yingjoe.Chen@mediatek.com>,
"Dan Carpenter" <dan.carpenter@oracle.com>,
"Jitao Shi (石记涛)" <jitao.shi@mediatek.com>,
"Sascha Hauer" <kernel@pengutronix.de>,
"moderated list:ARM/Mediatek SoC support"
<linux-mediatek@lists.infradead.org>,
"Matthias Brugger" <matthias.bgg@gmail.com>,
"Shaoming Chen (陈绍明)" <shaoming.chen@mediatek.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
srv_heupstream <srv_heupstream@mediatek.com>,
"Emil Velikov" <emil.l.velikov@gmail.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Maxime Ripard" <maxime.ripard@free-e>
Subject: Re: [PATCH v9 02/10] drm/mediatek: add *driver_data for different hardware settings
Date: Mon, 21 Nov 2016 22:28:48 +0800 [thread overview]
Message-ID: <1479738528.15207.51.camel@mtksdaap41> (raw)
In-Reply-To: <CAGS+omAa_SLg8WKfXXvZ-UT6-Mdep28FQVJuuwfskNqP2x50eg@mail.gmail.com>
Hi Daniel,
On Fri, 2016-11-18 at 12:56 +0800, Daniel Kurtz wrote:
> Hi YT,
>
> I don't see a reason to handle device_data in such a generic way at
> the generic mtk_ddp_comp layer.
> The device data is very component specific, so just define different
> structs for different comp types, ie:
>
> struct mtk_disp_ovl_driver_data {
> unsigned int reg_ovl_addr;
> unsigned int fmt_rgb565;
> unsigned int fmt_rgb888;
> };
>
> struct mtk_disp_rdma_driver_data {
> unsigned int fifo_pseudo_size;
> };
>
> struct mtk_disp_color_driver_data {
> unsigned int color_offset;
> };
>
> Then add typed pointers to the local structs that use them, for example:
>
> struct mtk_disp_ovl {
> struct mtk_ddp_comp ddp_comp;
> struct drm_crtc *crtc;
> const struct mtk_disp_ovl_driver_data *data;
> };
>
> And fetch the device specific driver data directly in .probe, as you
> are already doing:
>
> static int mtk_disp_ovl_probe(struct platform_device *pdev) {
> ...
> priv->data = of_device_get_match_data(dev);
> ...
> }
These suggestions make code more readable. We will change ovl and rdma
part, and keep mtk_disp_color_driver_data in its original place.
Because ovl and rdma have its files, other modules share
mtk_drm_ddp_comp.c.
>
> More comments in-line...
>
> On Fri, Nov 11, 2016 at 7:55 PM, YT Shen <yt.shen@mediatek.com> wrote:
> > There are some hardware settings changed, between MT8173 & MT2701:
> > DISP_OVL address offset changed, color format definition changed.
> > DISP_RDMA fifo size changed.
> > DISP_COLOR offset changed.
> > MIPI_TX pll setting changed.
> > And add prefix for mtk_ddp_main & mtk_ddp_ext & mutex_mod.
>
> Nit: I think it would make sense to combine this patch with
> drm/mediatek: rename macros, add chip prefix
Will do.
>
> >
> > Signed-off-by: YT Shen <yt.shen@mediatek.com>
> > ---
> > drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 27 ++++++++++++++++-----------
> > drivers/gpu/drm/mediatek/mtk_disp_rdma.c | 11 +++++++++--
> > drivers/gpu/drm/mediatek/mtk_drm_ddp.c | 11 +++++++----
> > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 27 +++++++++++++++++++++------
> > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 13 +++++++++++++
> > drivers/gpu/drm/mediatek/mtk_drm_drv.c | 25 ++++++++++++++++++-------
> > drivers/gpu/drm/mediatek/mtk_drm_drv.h | 8 ++++++++
> > drivers/gpu/drm/mediatek/mtk_mipi_tx.c | 24 +++++++++++++++++++++++-
> > 8 files changed, 115 insertions(+), 31 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> > index 019b7ca..1139834 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> > @@ -35,13 +35,10 @@
> > #define DISP_REG_OVL_PITCH(n) (0x0044 + 0x20 * (n))
> > #define DISP_REG_OVL_RDMA_CTRL(n) (0x00c0 + 0x20 * (n))
> > #define DISP_REG_OVL_RDMA_GMC(n) (0x00c8 + 0x20 * (n))
> > -#define DISP_REG_OVL_ADDR(n) (0x0f40 + 0x20 * (n))
>
> Also, I would still use the "#define macros", for example
> "DISP_REG_OVL_ADDR offsets, and use the named constant in the
> driver_data:
>
> #define DISP_REG_OVL_ADDR_MT8173 0x0f40
>
> (and in a later patch:
> #define DISP_REG_OVL_ADDR_MT2701 0x0040
> )
>
> Also, I would still use the macro rather than open coding the "0x20 *
> (n)", and just pass 'ovl' to the overlay macros that depend on
> hardware type.
> Something like the following:
>
> #define DISP_REG_OVL_ADDR(ovl, n) ((ovl)->data->ovl_addr + 0x20 * (n))
Will use the "#define macros" here.
>
> >
> > #define OVL_RDMA_MEM_GMC 0x40402020
> >
> > #define OVL_CON_BYTE_SWAP BIT(24)
> > -#define OVL_CON_CLRFMT_RGB565 (0 << 12)
> > -#define OVL_CON_CLRFMT_RGB888 (1 << 12)
>
> This seems like a really random and unnecessary hardware change.
> Why chip designers, why!!?!?
There are many reasons for software bugs. Unnecessary hardware change
should be one of them...
>
> For this one, it seems the polarity is either one way or the other, so
> we can just use a bool to distinguish:
>
> bool fmt_rgb565_is_0;
>
> > +static const struct mtk_ddp_comp_driver_data mt8173_ovl_driver_data = {
> > + .ovl = { DISP_REG_OVL_ADDR_MT8173, .fmt_rgb565_is_0 = true }
> > +};
>
> For use at runtime, the defines could become:
>
> #define OVL_CON_CLRFMT_RGB565(ovl) ((ovl)->data->fmt_rgb565_is_0 ? 0
> : OVL_CON_CLRFMT_RGB888)
> #define OVL_CON_CLRFMT_RGB888(ovl) ((ovl)->data->fmt_rgb565_is_0 ?
> OVL_CON_CLRFMT_RGB888 : 0)
OK, will do.
>
> > #define OVL_CON_CLRFMT_RGBA8888 (2 << 12)
> > #define OVL_CON_CLRFMT_ARGB8888 (3 << 12)
> > #define OVL_CON_AEN BIT(8)
> > @@ -137,18 +134,18 @@ static void mtk_ovl_layer_off(struct mtk_ddp_comp *comp, unsigned int idx)
> > writel(0x0, comp->regs + DISP_REG_OVL_RDMA_CTRL(idx));
> > }
> >
> > -static unsigned int ovl_fmt_convert(unsigned int fmt)
> > +static unsigned int ovl_fmt_convert(struct mtk_ddp_comp *comp, unsigned int fmt)
> > {
> > switch (fmt) {
> > default:
> > case DRM_FORMAT_RGB565:
> > - return OVL_CON_CLRFMT_RGB565;
> > + return comp->data->ovl.fmt_rgb565;
>
> It will be nice to define a helper function for converting from the
> generic 'mtk_ddp_comp' to the specific 'mtk_disp_ovl':
>
> static inline struct mtk_disp_ovl *comp_to_ovl(struct mtk_ddp_comp *comp) {
> return container_of(comp, struct mtk_disp_ovl, ddp_comp);
> }
>
> Then these could become:
> return OVL_CON_CLRFMT_RGB565(comp_to_ovl(comp));
>
> Or maybe cleaner, do the conversion once at the top of the function:
> struct mtk_disp_ovl *ovl = comp_to_ovl(comp);
>
> And then just:
> return OVL_CON_CLRFMT_RGB565(ovl);
>
>
Will use a helper function for the converting.
> > case DRM_FORMAT_BGR565:
> > - return OVL_CON_CLRFMT_RGB565 | OVL_CON_BYTE_SWAP;
> > + return comp->data->ovl.fmt_rgb565 | OVL_CON_BYTE_SWAP;
> > case DRM_FORMAT_RGB888:
> > - return OVL_CON_CLRFMT_RGB888;
> > + return comp->data->ovl.fmt_rgb888;
> > case DRM_FORMAT_BGR888:
> > - return OVL_CON_CLRFMT_RGB888 | OVL_CON_BYTE_SWAP;
> > + return comp->data->ovl.fmt_rgb888 | OVL_CON_BYTE_SWAP;
> > case DRM_FORMAT_RGBX8888:
> > case DRM_FORMAT_RGBA8888:
> > return OVL_CON_CLRFMT_ARGB8888;
>
> [snip]
>
>
> > diff --git a/drivers/gpu/drm/mediatek/mtk_mipi_tx.c b/drivers/gpu/drm/mediatek/mtk_mipi_tx.c
> > index 1c366f8..935a8ef 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_mipi_tx.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_mipi_tx.c
> > @@ -16,6 +16,7 @@
> > #include <linux/delay.h>
> > #include <linux/io.h>
> > #include <linux/module.h>
> > +#include <linux/of_device.h>
> > #include <linux/platform_device.h>
> > #include <linux/phy/phy.h>
> >
> > @@ -87,6 +88,9 @@
> >
> > #define MIPITX_DSI_PLL_CON2 0x58
> >
> > +#define MIPITX_DSI_PLL_TOP 0x64
> > +#define RG_DSI_MPPLL_PRESERVE (0xff << 8)
> > +
> > #define MIPITX_DSI_PLL_PWR 0x68
> > #define RG_DSI_MPPLL_SDM_PWR_ON BIT(0)
> > #define RG_DSI_MPPLL_SDM_ISO_EN BIT(1)
> > @@ -123,10 +127,15 @@
> > #define SW_LNT2_HSTX_PRE_OE BIT(24)
> > #define SW_LNT2_HSTX_OE BIT(25)
> >
> > +struct mtk_mipitx_data {
> > + const u32 data;
>
> Use a better name, like "mppll_preserve".
OK.
Regards,
yt.shen
>
> Ok, that's it for now.
> Actually, the patch set in general looks pretty good.
>
> -Dan
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2016-11-21 14:28 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-11 11:55 [PATCH v9 00/10] MT2701 DRM support YT Shen
[not found] ` <1478865346-19043-1-git-send-email-yt.shen-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2016-11-11 11:55 ` [PATCH v9 01/10] drm/mediatek: rename macros, add chip prefix YT Shen
2016-11-11 11:55 ` [PATCH v9 02/10] drm/mediatek: add *driver_data for different hardware settings YT Shen
2016-11-18 4:56 ` Daniel Kurtz
2016-11-21 14:28 ` YT Shen [this message]
2016-11-11 11:55 ` [PATCH v9 03/10] drm/mediatek: add shadow register support YT Shen
2016-11-11 11:55 ` [PATCH v9 04/10] drm/mediatek: add BLS component YT Shen
2016-11-11 11:55 ` [PATCH v9 05/10] drm/mediatek: update display module connections YT Shen
2016-11-11 11:55 ` [PATCH v9 06/10] drm/mediatek: cleaning up and refine YT Shen
2016-11-11 11:55 ` [PATCH v9 07/10] drm/mediatek: add dsi interrupt control YT Shen
2016-11-11 11:55 ` [PATCH v9 08/10] drm/mediatek: add dsi transfer function YT Shen
2016-11-11 11:55 ` [PATCH v9 09/10] drm/mediatek: update DSI sub driver flow for sending commands to panel YT Shen
2016-11-18 3:21 ` Daniel Kurtz
2016-11-21 13:59 ` YT Shen
2016-11-11 11:55 ` [PATCH v9 10/10] drm/mediatek: add support for Mediatek SoC MT2701 YT Shen
2016-11-14 7:14 ` [PATCH v9 00/10] MT2701 DRM support CK Hu
2016-11-14 7:45 ` Bibby Hsieh
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=1479738528.15207.51.camel@mtksdaap41 \
--to=yt.shen@mediatek.com \
--cc=Yingjoe.Chen@mediatek.com \
--cc=dan.carpenter@oracle.com \
--cc=daniel.vetter@ffwll.ch \
--cc=djkurtz@chromium.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=emil.l.velikov@gmail.com \
--cc=jie.qiu@mediatek.com \
--cc=jitao.shi@mediatek.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=littlecvr@chromium.org \
--cc=matthias.bgg@gmail.com \
--cc=maxime.ripard@free-e \
--cc=shaoming.chen@mediatek.com \
--cc=srv_heupstream@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).