v2:
modify unused code
v1:
DPI can sample on falling, rising or both edge.
When DPI sample the data both rising and falling edge.
It can reduce half data io pins.
Rex-BC Chen (3):
drm/mediatek: dpi dual edge sample mode support
drm/mediatek: config mt8183 driver data to support dual edge sample
drm/mediatek: dpi: add bus format negotiation
drivers/gpu/drm/mediatek/mtk_dpi.c | 102 +++++++++++++++++++++++++++--
1 file changed, 97 insertions(+), 5 deletions(-)
--
2.18.0
DPI can sample on falling, rising or both edge.
When DPI sample the data both rising and falling edge.
It can reduce half data io pins.
Signed-off-by: Jitao Shi <[email protected]>
Signed-off-by: Rex-BC Chen <[email protected]>
---
drivers/gpu/drm/mediatek/mtk_dpi.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c
index b05f900d9322..21a3a7b78835 100644
--- a/drivers/gpu/drm/mediatek/mtk_dpi.c
+++ b/drivers/gpu/drm/mediatek/mtk_dpi.c
@@ -83,6 +83,7 @@ struct mtk_dpi {
struct pinctrl *pinctrl;
struct pinctrl_state *pins_gpio;
struct pinctrl_state *pins_dpi;
+ bool ddr_edge_sel;
int refcount;
};
@@ -121,6 +122,7 @@ struct mtk_dpi_conf {
unsigned int (*cal_factor)(int clock);
u32 reg_h_fre_con;
bool edge_sel_en;
+ bool dual_edge;
};
static void mtk_dpi_mask(struct mtk_dpi *dpi, u32 offset, u32 val, u32 mask)
@@ -380,6 +382,15 @@ static void mtk_dpi_config_color_format(struct mtk_dpi *dpi,
}
}
+static void mtk_dpi_dual_edge(struct mtk_dpi *dpi)
+{
+ if (dpi->conf->dual_edge) {
+ mtk_dpi_mask(dpi, DPI_DDR_SETTING, DDR_EN | DDR_4PHASE,
+ DDR_EN | DDR_4PHASE);
+ mtk_dpi_mask(dpi, DPI_OUTPUT_SETTING, dpi->ddr_edge_sel ? EDGE_SEL : 0, EDGE_SEL);
+ }
+}
+
static void mtk_dpi_power_off(struct mtk_dpi *dpi)
{
if (WARN_ON(dpi->refcount == 0))
@@ -518,6 +529,7 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi,
mtk_dpi_config_yc_map(dpi, dpi->yc_map);
mtk_dpi_config_color_format(dpi, dpi->color_format);
mtk_dpi_config_2n_h_fre(dpi);
+ mtk_dpi_dual_edge(dpi);
mtk_dpi_config_disable_edge(dpi);
mtk_dpi_sw_reset(dpi, false);
--
2.18.0
Hi,
On 14/04/2021 15:35, Rex-BC Chen wrote:
> DPI can sample on falling, rising or both edge.
> When DPI sample the data both rising and falling edge.
> It can reduce half data io pins.
>
> Signed-off-by: Jitao Shi <[email protected]>
> Signed-off-by: Rex-BC Chen <[email protected]>
> ---
> drivers/gpu/drm/mediatek/mtk_dpi.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c
> index b05f900d9322..21a3a7b78835 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dpi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c
> @@ -83,6 +83,7 @@ struct mtk_dpi {
> struct pinctrl *pinctrl;
> struct pinctrl_state *pins_gpio;
> struct pinctrl_state *pins_dpi;
> + bool ddr_edge_sel;
> int refcount;
> };
>
> @@ -121,6 +122,7 @@ struct mtk_dpi_conf {
> unsigned int (*cal_factor)(int clock);
> u32 reg_h_fre_con;
> bool edge_sel_en;
> + bool dual_edge;
> };
>
> static void mtk_dpi_mask(struct mtk_dpi *dpi, u32 offset, u32 val, u32 mask)
> @@ -380,6 +382,15 @@ static void mtk_dpi_config_color_format(struct mtk_dpi *dpi,
> }
> }
>
> +static void mtk_dpi_dual_edge(struct mtk_dpi *dpi)
> +{
> + if (dpi->conf->dual_edge) {
> + mtk_dpi_mask(dpi, DPI_DDR_SETTING, DDR_EN | DDR_4PHASE,
> + DDR_EN | DDR_4PHASE);
> + mtk_dpi_mask(dpi, DPI_OUTPUT_SETTING, dpi->ddr_edge_sel ? EDGE_SEL : 0, EDGE_SEL);
> + }
> +}
> +
By using the downstream code as reference:
- clk_set_rate(dpi->pixel_clk, vm.pixelclock);
+ clk_set_rate(dpi->pixel_clk, vm.pixelclock * (dpi->conf->dual_edge ? 2 : 1));
is missing in mtk_dpi_set_display_mode()
> static void mtk_dpi_power_off(struct mtk_dpi *dpi)
> {
> if (WARN_ON(dpi->refcount == 0))
> @@ -518,6 +529,7 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi,
> mtk_dpi_config_yc_map(dpi, dpi->yc_map);
> mtk_dpi_config_color_format(dpi, dpi->color_format);
> mtk_dpi_config_2n_h_fre(dpi);
> + mtk_dpi_dual_edge(dpi);
> mtk_dpi_config_disable_edge(dpi);
> mtk_dpi_sw_reset(dpi, false);
>
>
Neil
On Mon, 2021-04-19 at 09:36 +0200, Neil Armstrong wrote:
> Hi,
>
> On 14/04/2021 15:35, Rex-BC Chen wrote:
> > DPI can sample on falling, rising or both edge.
> > When DPI sample the data both rising and falling edge.
> > It can reduce half data io pins.
> >
> > Signed-off-by: Jitao Shi <[email protected]>
> > Signed-off-by: Rex-BC Chen <[email protected]>
> > ---
> > drivers/gpu/drm/mediatek/mtk_dpi.c | 12 ++++++++++++
> > 1 file changed, 12 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c
> > b/drivers/gpu/drm/mediatek/mtk_dpi.c
> > index b05f900d9322..21a3a7b78835 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_dpi.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c
> > @@ -83,6 +83,7 @@ struct mtk_dpi {
> > struct pinctrl *pinctrl;
> > struct pinctrl_state *pins_gpio;
> > struct pinctrl_state *pins_dpi;
> > + bool ddr_edge_sel;
> > int refcount;
> > };
> >
> > @@ -121,6 +122,7 @@ struct mtk_dpi_conf {
> > unsigned int (*cal_factor)(int clock);
> > u32 reg_h_fre_con;
> > bool edge_sel_en;
> > + bool dual_edge;
> > };
> >
> > static void mtk_dpi_mask(struct mtk_dpi *dpi, u32 offset, u32 val,
> > u32 mask)
> > @@ -380,6 +382,15 @@ static void mtk_dpi_config_color_format(struct
> > mtk_dpi *dpi,
> > }
> > }
> >
> > +static void mtk_dpi_dual_edge(struct mtk_dpi *dpi)
> > +{
> > + if (dpi->conf->dual_edge) {
> > + mtk_dpi_mask(dpi, DPI_DDR_SETTING, DDR_EN | DDR_4PHASE,
> > + DDR_EN | DDR_4PHASE);
> > + mtk_dpi_mask(dpi, DPI_OUTPUT_SETTING, dpi->ddr_edge_sel
> > ? EDGE_SEL : 0, EDGE_SEL);
> > + }
> > +}
> > +
>
> By using the downstream code as reference:
>
> - clk_set_rate(dpi->pixel_clk, vm.pixelclock);
> + clk_set_rate(dpi->pixel_clk, vm.pixelclock * (dpi->conf-
> >dual_edge ? 2 : 1));
>
> is missing in mtk_dpi_set_display_mode()
>
Hello Neil,
Thanks for helping checking this.
I will add this modification for next patch.
BRs,
Rex-BC Chen
> > static void mtk_dpi_power_off(struct mtk_dpi *dpi)
> > {
> > if (WARN_ON(dpi->refcount == 0))
> > @@ -518,6 +529,7 @@ static int mtk_dpi_set_display_mode(struct
> > mtk_dpi *dpi,
> > mtk_dpi_config_yc_map(dpi, dpi->yc_map);
> > mtk_dpi_config_color_format(dpi, dpi->color_format);
> > mtk_dpi_config_2n_h_fre(dpi);
> > + mtk_dpi_dual_edge(dpi);
> > mtk_dpi_config_disable_edge(dpi);
> > mtk_dpi_sw_reset(dpi, false);
> >
> >
>
> Neil