Re: [PATCH v2 11/22] drm: mxsfb: Stop using DRM simple display pipeline helper

2020-07-27 Thread Stefan Agner
On 2020-07-26 20:28, Laurent Pinchart wrote:
> Hi Stefan,
> 
> On Fri, Jul 17, 2020 at 05:06:55AM +0300, Laurent Pinchart wrote:
>> On Thu, Jul 09, 2020 at 12:25:42PM +0200, Stefan Agner wrote:
>> > On 2020-06-16 03:50, Laurent Pinchart wrote:
>> >> On Thu, Jun 11, 2020 at 09:33:11PM +0200, Stefan Agner wrote:
>> >>> On 2020-05-30 05:10, Laurent Pinchart wrote:
>>  The DRM simple display pipeline helper only supports a single plane. In
>>  order to prepare for support of the alpha plane on i.MX6SX and i.MX7,
>>  move away from the helper. No new feature is added.
>> 
>>  Signed-off-by: Laurent Pinchart 
>>  ---
>>  Changes since v1:
>> 
>>  - Move after mxsfb_crtc.c rename to mxsfb_kms.c
>>  ---
>>   drivers/gpu/drm/mxsfb/mxsfb_drv.c | 108 +++---
>>   drivers/gpu/drm/mxsfb/mxsfb_drv.h |  23 ++--
>>   drivers/gpu/drm/mxsfb/mxsfb_kms.c | 184 +++---
>>   3 files changed, 197 insertions(+), 118 deletions(-)
>> 
>>  diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
>>  b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
>>  index 204c1e52e9aa..a8da92976d13 100644
>>  --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
>>  +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
>>  @@ -10,22 +10,23 @@
>> 
>>   #include 
>>   #include 
>>  +#include 
>>   #include 
>>   #include 
>>  +#include 
>>   #include 
>>  -#include 
>> 
>>  -#include 
>>   #include 
>>  -#include 
>>  +#include 
>>  +#include 
>>   #include 
>>   #include 
>>   #include 
>>   #include 
>>   #include 
>>  +#include 
>>   #include 
>>   #include 
>>  -#include 
>>   #include 
>> 
>>   #include "mxsfb_drv.h"
>>  @@ -57,17 +58,6 @@ static const struct mxsfb_devdata mxsfb_devdata[] = {
>>  },
>>   };
>> 
>>  -static const uint32_t mxsfb_formats[] = {
>>  -   DRM_FORMAT_XRGB,
>>  -   DRM_FORMAT_RGB565
>>  -};
>>  -
>>  -static struct mxsfb_drm_private *
>>  -drm_pipe_to_mxsfb_drm_private(struct drm_simple_display_pipe *pipe)
>>  -{
>>  -   return container_of(pipe, struct mxsfb_drm_private, pipe);
>>  -}
>>  -
>>   void mxsfb_enable_axi_clk(struct mxsfb_drm_private *mxsfb)
>>   {
>>  if (mxsfb->clk_axi)
>>  @@ -90,77 +80,6 @@ static const struct drm_mode_config_helper_funcs
>>  mxsfb_mode_config_helpers = {
>>  .atomic_commit_tail = drm_atomic_helper_commit_tail_rpm,
>>   };
>> 
>>  -static void mxsfb_pipe_enable(struct drm_simple_display_pipe *pipe,
>>  - struct drm_crtc_state *crtc_state,
>>  - struct drm_plane_state *plane_state)
>>  -{
>>  -   struct mxsfb_drm_private *mxsfb = 
>>  drm_pipe_to_mxsfb_drm_private(pipe);
>>  -   struct drm_device *drm = pipe->plane.dev;
>>  -
>>  -   pm_runtime_get_sync(drm->dev);
>>  -   mxsfb_crtc_enable(mxsfb);
>>  -}
>>  -
>>  -static void mxsfb_pipe_disable(struct drm_simple_display_pipe *pipe)
>>  -{
>>  -   struct mxsfb_drm_private *mxsfb = 
>>  drm_pipe_to_mxsfb_drm_private(pipe);
>>  -   struct drm_device *drm = pipe->plane.dev;
>>  -   struct drm_crtc *crtc = &pipe->crtc;
>>  -   struct drm_pending_vblank_event *event;
>>  -
>>  -   mxsfb_crtc_disable(mxsfb);
>>  -   pm_runtime_put_sync(drm->dev);
>>  -
>>  -   spin_lock_irq(&drm->event_lock);
>>  -   event = crtc->state->event;
>>  -   if (event) {
>>  -   crtc->state->event = NULL;
>>  -   drm_crtc_send_vblank_event(crtc, event);
>>  -   }
>>  -   spin_unlock_irq(&drm->event_lock);
>>  -}
>>  -
>>  -static void mxsfb_pipe_update(struct drm_simple_display_pipe *pipe,
>>  - struct drm_plane_state *plane_state)
>>  -{
>>  -   struct mxsfb_drm_private *mxsfb = 
>>  drm_pipe_to_mxsfb_drm_private(pipe);
>>  -
>>  -   mxsfb_plane_atomic_update(mxsfb, plane_state);
>>  -}
>>  -
>>  -static int mxsfb_pipe_enable_vblank(struct drm_simple_display_pipe 
>>  *pipe)
>>  -{
>>  -   struct mxsfb_drm_private *mxsfb = 
>>  drm_pipe_to_mxsfb_drm_private(pipe);
>>  -
>>  -   /* Clear and enable VBLANK IRQ */
>>  -   mxsfb_enable_axi_clk(mxsfb);
>>  -   writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + 
>>  REG_CLR);
>>  -   writel(CTRL1_CUR_FRAME_DONE_IRQ_EN, mxsfb->base + LCDC_CTRL1 + 
>>  REG_SET);
>>  -   mxsfb_disable_axi_clk(mxsfb);
>>  -
>>  -   return 0;
>>  -}
>>  -
>>  -static void mxsfb_pipe_disable_vblank(struct drm_simple_display_pipe 
>>  *pipe)
>>  -{
>>  -   struct mxsfb_drm_private *mxsfb

Re: [PATCH v2 11/22] drm: mxsfb: Stop using DRM simple display pipeline helper

2020-07-26 Thread Laurent Pinchart
Hi Stefan,

On Fri, Jul 17, 2020 at 05:06:55AM +0300, Laurent Pinchart wrote:
> On Thu, Jul 09, 2020 at 12:25:42PM +0200, Stefan Agner wrote:
> > On 2020-06-16 03:50, Laurent Pinchart wrote:
> >> On Thu, Jun 11, 2020 at 09:33:11PM +0200, Stefan Agner wrote:
> >>> On 2020-05-30 05:10, Laurent Pinchart wrote:
>  The DRM simple display pipeline helper only supports a single plane. In
>  order to prepare for support of the alpha plane on i.MX6SX and i.MX7,
>  move away from the helper. No new feature is added.
> 
>  Signed-off-by: Laurent Pinchart 
>  ---
>  Changes since v1:
> 
>  - Move after mxsfb_crtc.c rename to mxsfb_kms.c
>  ---
>   drivers/gpu/drm/mxsfb/mxsfb_drv.c | 108 +++---
>   drivers/gpu/drm/mxsfb/mxsfb_drv.h |  23 ++--
>   drivers/gpu/drm/mxsfb/mxsfb_kms.c | 184 +++---
>   3 files changed, 197 insertions(+), 118 deletions(-)
> 
>  diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
>  b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
>  index 204c1e52e9aa..a8da92976d13 100644
>  --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
>  +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
>  @@ -10,22 +10,23 @@
> 
>   #include 
>   #include 
>  +#include 
>   #include 
>   #include 
>  +#include 
>   #include 
>  -#include 
> 
>  -#include 
>   #include 
>  -#include 
>  +#include 
>  +#include 
>   #include 
>   #include 
>   #include 
>   #include 
>   #include 
>  +#include 
>   #include 
>   #include 
>  -#include 
>   #include 
> 
>   #include "mxsfb_drv.h"
>  @@ -57,17 +58,6 @@ static const struct mxsfb_devdata mxsfb_devdata[] = {
>   },
>   };
> 
>  -static const uint32_t mxsfb_formats[] = {
>  -DRM_FORMAT_XRGB,
>  -DRM_FORMAT_RGB565
>  -};
>  -
>  -static struct mxsfb_drm_private *
>  -drm_pipe_to_mxsfb_drm_private(struct drm_simple_display_pipe *pipe)
>  -{
>  -return container_of(pipe, struct mxsfb_drm_private, pipe);
>  -}
>  -
>   void mxsfb_enable_axi_clk(struct mxsfb_drm_private *mxsfb)
>   {
>   if (mxsfb->clk_axi)
>  @@ -90,77 +80,6 @@ static const struct drm_mode_config_helper_funcs
>  mxsfb_mode_config_helpers = {
>   .atomic_commit_tail = drm_atomic_helper_commit_tail_rpm,
>   };
> 
>  -static void mxsfb_pipe_enable(struct drm_simple_display_pipe *pipe,
>  -  struct drm_crtc_state *crtc_state,
>  -  struct drm_plane_state *plane_state)
>  -{
>  -struct mxsfb_drm_private *mxsfb = 
>  drm_pipe_to_mxsfb_drm_private(pipe);
>  -struct drm_device *drm = pipe->plane.dev;
>  -
>  -pm_runtime_get_sync(drm->dev);
>  -mxsfb_crtc_enable(mxsfb);
>  -}
>  -
>  -static void mxsfb_pipe_disable(struct drm_simple_display_pipe *pipe)
>  -{
>  -struct mxsfb_drm_private *mxsfb = 
>  drm_pipe_to_mxsfb_drm_private(pipe);
>  -struct drm_device *drm = pipe->plane.dev;
>  -struct drm_crtc *crtc = &pipe->crtc;
>  -struct drm_pending_vblank_event *event;
>  -
>  -mxsfb_crtc_disable(mxsfb);
>  -pm_runtime_put_sync(drm->dev);
>  -
>  -spin_lock_irq(&drm->event_lock);
>  -event = crtc->state->event;
>  -if (event) {
>  -crtc->state->event = NULL;
>  -drm_crtc_send_vblank_event(crtc, event);
>  -}
>  -spin_unlock_irq(&drm->event_lock);
>  -}
>  -
>  -static void mxsfb_pipe_update(struct drm_simple_display_pipe *pipe,
>  -  struct drm_plane_state *plane_state)
>  -{
>  -struct mxsfb_drm_private *mxsfb = 
>  drm_pipe_to_mxsfb_drm_private(pipe);
>  -
>  -mxsfb_plane_atomic_update(mxsfb, plane_state);
>  -}
>  -
>  -static int mxsfb_pipe_enable_vblank(struct drm_simple_display_pipe 
>  *pipe)
>  -{
>  -struct mxsfb_drm_private *mxsfb = 
>  drm_pipe_to_mxsfb_drm_private(pipe);
>  -
>  -/* Clear and enable VBLANK IRQ */
>  -mxsfb_enable_axi_clk(mxsfb);
>  -writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + 
>  REG_CLR);
>  -writel(CTRL1_CUR_FRAME_DONE_IRQ_EN, mxsfb->base + LCDC_CTRL1 + 
>  REG_SET);
>  -mxsfb_disable_axi_clk(mxsfb);
>  -
>  -return 0;
>  -}
>  -
>  -static void mxsfb_pipe_disable_vblank(struct drm_simple_display_pipe 
>  *pipe)
>  -{
>  -struct mxsfb_drm_private *mxsfb = 
>  drm_pipe_to_mxsfb_drm_private(pipe);
>  -
>  -/* Disable and clear VBLANK IRQ */
>  -mxsfb_enable_axi_clk(mxsfb);

Re: [PATCH v2 11/22] drm: mxsfb: Stop using DRM simple display pipeline helper

2020-07-16 Thread Laurent Pinchart
Hi Stefan,

On Thu, Jul 09, 2020 at 12:25:42PM +0200, Stefan Agner wrote:
> On 2020-06-16 03:50, Laurent Pinchart wrote:
> > On Thu, Jun 11, 2020 at 09:33:11PM +0200, Stefan Agner wrote:
> >> On 2020-05-30 05:10, Laurent Pinchart wrote:
> >> > The DRM simple display pipeline helper only supports a single plane. In
> >> > order to prepare for support of the alpha plane on i.MX6SX and i.MX7,
> >> > move away from the helper. No new feature is added.
> >> >
> >> > Signed-off-by: Laurent Pinchart 
> >> > ---
> >> > Changes since v1:
> >> >
> >> > - Move after mxsfb_crtc.c rename to mxsfb_kms.c
> >> > ---
> >> >  drivers/gpu/drm/mxsfb/mxsfb_drv.c | 108 +++---
> >> >  drivers/gpu/drm/mxsfb/mxsfb_drv.h |  23 ++--
> >> >  drivers/gpu/drm/mxsfb/mxsfb_kms.c | 184 +++---
> >> >  3 files changed, 197 insertions(+), 118 deletions(-)
> >> >
> >> > diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> >> > b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> >> > index 204c1e52e9aa..a8da92976d13 100644
> >> > --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> >> > +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> >> > @@ -10,22 +10,23 @@
> >> >
> >> >  #include 
> >> >  #include 
> >> > +#include 
> >> >  #include 
> >> >  #include 
> >> > +#include 
> >> >  #include 
> >> > -#include 
> >> >
> >> > -#include 
> >> >  #include 
> >> > -#include 
> >> > +#include 
> >> > +#include 
> >> >  #include 
> >> >  #include 
> >> >  #include 
> >> >  #include 
> >> >  #include 
> >> > +#include 
> >> >  #include 
> >> >  #include 
> >> > -#include 
> >> >  #include 
> >> >
> >> >  #include "mxsfb_drv.h"
> >> > @@ -57,17 +58,6 @@ static const struct mxsfb_devdata mxsfb_devdata[] = {
> >> >  },
> >> >  };
> >> >
> >> > -static const uint32_t mxsfb_formats[] = {
> >> > -DRM_FORMAT_XRGB,
> >> > -DRM_FORMAT_RGB565
> >> > -};
> >> > -
> >> > -static struct mxsfb_drm_private *
> >> > -drm_pipe_to_mxsfb_drm_private(struct drm_simple_display_pipe *pipe)
> >> > -{
> >> > -return container_of(pipe, struct mxsfb_drm_private, pipe);
> >> > -}
> >> > -
> >> >  void mxsfb_enable_axi_clk(struct mxsfb_drm_private *mxsfb)
> >> >  {
> >> >  if (mxsfb->clk_axi)
> >> > @@ -90,77 +80,6 @@ static const struct drm_mode_config_helper_funcs
> >> > mxsfb_mode_config_helpers = {
> >> >  .atomic_commit_tail = drm_atomic_helper_commit_tail_rpm,
> >> >  };
> >> >
> >> > -static void mxsfb_pipe_enable(struct drm_simple_display_pipe *pipe,
> >> > -  struct drm_crtc_state *crtc_state,
> >> > -  struct drm_plane_state *plane_state)
> >> > -{
> >> > -struct mxsfb_drm_private *mxsfb = 
> >> > drm_pipe_to_mxsfb_drm_private(pipe);
> >> > -struct drm_device *drm = pipe->plane.dev;
> >> > -
> >> > -pm_runtime_get_sync(drm->dev);
> >> > -mxsfb_crtc_enable(mxsfb);
> >> > -}
> >> > -
> >> > -static void mxsfb_pipe_disable(struct drm_simple_display_pipe *pipe)
> >> > -{
> >> > -struct mxsfb_drm_private *mxsfb = 
> >> > drm_pipe_to_mxsfb_drm_private(pipe);
> >> > -struct drm_device *drm = pipe->plane.dev;
> >> > -struct drm_crtc *crtc = &pipe->crtc;
> >> > -struct drm_pending_vblank_event *event;
> >> > -
> >> > -mxsfb_crtc_disable(mxsfb);
> >> > -pm_runtime_put_sync(drm->dev);
> >> > -
> >> > -spin_lock_irq(&drm->event_lock);
> >> > -event = crtc->state->event;
> >> > -if (event) {
> >> > -crtc->state->event = NULL;
> >> > -drm_crtc_send_vblank_event(crtc, event);
> >> > -}
> >> > -spin_unlock_irq(&drm->event_lock);
> >> > -}
> >> > -
> >> > -static void mxsfb_pipe_update(struct drm_simple_display_pipe *pipe,
> >> > -  struct drm_plane_state *plane_state)
> >> > -{
> >> > -struct mxsfb_drm_private *mxsfb = 
> >> > drm_pipe_to_mxsfb_drm_private(pipe);
> >> > -
> >> > -mxsfb_plane_atomic_update(mxsfb, plane_state);
> >> > -}
> >> > -
> >> > -static int mxsfb_pipe_enable_vblank(struct drm_simple_display_pipe 
> >> > *pipe)
> >> > -{
> >> > -struct mxsfb_drm_private *mxsfb = 
> >> > drm_pipe_to_mxsfb_drm_private(pipe);
> >> > -
> >> > -/* Clear and enable VBLANK IRQ */
> >> > -mxsfb_enable_axi_clk(mxsfb);
> >> > -writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + 
> >> > REG_CLR);
> >> > -writel(CTRL1_CUR_FRAME_DONE_IRQ_EN, mxsfb->base + LCDC_CTRL1 + 
> >> > REG_SET);
> >> > -mxsfb_disable_axi_clk(mxsfb);
> >> > -
> >> > -return 0;
> >> > -}
> >> > -
> >> > -static void mxsfb_pipe_disable_vblank(struct drm_simple_display_pipe 
> >> > *pipe)
> >> > -{
> >> > -struct mxsfb_drm_private *mxsfb = 
> >> > drm_pipe_to_mxsfb_drm_private(pipe);
> >> > -
> >> > -/* Disable and clear VBLANK IRQ */
> >> > -mxsfb_enable_axi_clk(mxsfb);
> >> > -writel(CTRL1_CUR_FRAME_DONE_IRQ_EN, mxsfb->base + LCDC_

Re: [PATCH v2 11/22] drm: mxsfb: Stop using DRM simple display pipeline helper

2020-07-09 Thread Stefan Agner
Hi Laurent,

On 2020-06-16 03:50, Laurent Pinchart wrote:
> Hi Stefan,
> 
> On Thu, Jun 11, 2020 at 09:33:11PM +0200, Stefan Agner wrote:
>> On 2020-05-30 05:10, Laurent Pinchart wrote:
>> > The DRM simple display pipeline helper only supports a single plane. In
>> > order to prepare for support of the alpha plane on i.MX6SX and i.MX7,
>> > move away from the helper. No new feature is added.
>> >
>> > Signed-off-by: Laurent Pinchart 
>> > ---
>> > Changes since v1:
>> >
>> > - Move after mxsfb_crtc.c rename to mxsfb_kms.c
>> > ---
>> >  drivers/gpu/drm/mxsfb/mxsfb_drv.c | 108 +++---
>> >  drivers/gpu/drm/mxsfb/mxsfb_drv.h |  23 ++--
>> >  drivers/gpu/drm/mxsfb/mxsfb_kms.c | 184 +++---
>> >  3 files changed, 197 insertions(+), 118 deletions(-)
>> >
>> > diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
>> > b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
>> > index 204c1e52e9aa..a8da92976d13 100644
>> > --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
>> > +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
>> > @@ -10,22 +10,23 @@
>> >
>> >  #include 
>> >  #include 
>> > +#include 
>> >  #include 
>> >  #include 
>> > +#include 
>> >  #include 
>> > -#include 
>> >
>> > -#include 
>> >  #include 
>> > -#include 
>> > +#include 
>> > +#include 
>> >  #include 
>> >  #include 
>> >  #include 
>> >  #include 
>> >  #include 
>> > +#include 
>> >  #include 
>> >  #include 
>> > -#include 
>> >  #include 
>> >
>> >  #include "mxsfb_drv.h"
>> > @@ -57,17 +58,6 @@ static const struct mxsfb_devdata mxsfb_devdata[] = {
>> >},
>> >  };
>> >
>> > -static const uint32_t mxsfb_formats[] = {
>> > -  DRM_FORMAT_XRGB,
>> > -  DRM_FORMAT_RGB565
>> > -};
>> > -
>> > -static struct mxsfb_drm_private *
>> > -drm_pipe_to_mxsfb_drm_private(struct drm_simple_display_pipe *pipe)
>> > -{
>> > -  return container_of(pipe, struct mxsfb_drm_private, pipe);
>> > -}
>> > -
>> >  void mxsfb_enable_axi_clk(struct mxsfb_drm_private *mxsfb)
>> >  {
>> >if (mxsfb->clk_axi)
>> > @@ -90,77 +80,6 @@ static const struct drm_mode_config_helper_funcs
>> > mxsfb_mode_config_helpers = {
>> >.atomic_commit_tail = drm_atomic_helper_commit_tail_rpm,
>> >  };
>> >
>> > -static void mxsfb_pipe_enable(struct drm_simple_display_pipe *pipe,
>> > -struct drm_crtc_state *crtc_state,
>> > -struct drm_plane_state *plane_state)
>> > -{
>> > -  struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe);
>> > -  struct drm_device *drm = pipe->plane.dev;
>> > -
>> > -  pm_runtime_get_sync(drm->dev);
>> > -  mxsfb_crtc_enable(mxsfb);
>> > -}
>> > -
>> > -static void mxsfb_pipe_disable(struct drm_simple_display_pipe *pipe)
>> > -{
>> > -  struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe);
>> > -  struct drm_device *drm = pipe->plane.dev;
>> > -  struct drm_crtc *crtc = &pipe->crtc;
>> > -  struct drm_pending_vblank_event *event;
>> > -
>> > -  mxsfb_crtc_disable(mxsfb);
>> > -  pm_runtime_put_sync(drm->dev);
>> > -
>> > -  spin_lock_irq(&drm->event_lock);
>> > -  event = crtc->state->event;
>> > -  if (event) {
>> > -  crtc->state->event = NULL;
>> > -  drm_crtc_send_vblank_event(crtc, event);
>> > -  }
>> > -  spin_unlock_irq(&drm->event_lock);
>> > -}
>> > -
>> > -static void mxsfb_pipe_update(struct drm_simple_display_pipe *pipe,
>> > -struct drm_plane_state *plane_state)
>> > -{
>> > -  struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe);
>> > -
>> > -  mxsfb_plane_atomic_update(mxsfb, plane_state);
>> > -}
>> > -
>> > -static int mxsfb_pipe_enable_vblank(struct drm_simple_display_pipe *pipe)
>> > -{
>> > -  struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe);
>> > -
>> > -  /* Clear and enable VBLANK IRQ */
>> > -  mxsfb_enable_axi_clk(mxsfb);
>> > -  writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + REG_CLR);
>> > -  writel(CTRL1_CUR_FRAME_DONE_IRQ_EN, mxsfb->base + LCDC_CTRL1 + REG_SET);
>> > -  mxsfb_disable_axi_clk(mxsfb);
>> > -
>> > -  return 0;
>> > -}
>> > -
>> > -static void mxsfb_pipe_disable_vblank(struct drm_simple_display_pipe 
>> > *pipe)
>> > -{
>> > -  struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe);
>> > -
>> > -  /* Disable and clear VBLANK IRQ */
>> > -  mxsfb_enable_axi_clk(mxsfb);
>> > -  writel(CTRL1_CUR_FRAME_DONE_IRQ_EN, mxsfb->base + LCDC_CTRL1 + REG_CLR);
>> > -  writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + REG_CLR);
>> > -  mxsfb_disable_axi_clk(mxsfb);
>> > -}
>> > -
>> > -static struct drm_simple_display_pipe_funcs mxsfb_funcs = {
>> > -  .enable = mxsfb_pipe_enable,
>> > -  .disable= mxsfb_pipe_disable,
>> > -  .update = mxsfb_pipe_update,
>> > -  .prepare_fb = drm_gem_fb_simple_display_pipe_prepare_fb,
>> > -  .enable_vblank  = mxsfb_pipe_enable_vblank,
>> > -  .disable_vblank = mxsfb_pipe_disable_vblank,
>> > -};
>> > -
>> >  static int mxsfb_attach_bridge(struct mxsfb_drm_private *mxsfb

Re: [PATCH v2 11/22] drm: mxsfb: Stop using DRM simple display pipeline helper

2020-06-15 Thread Laurent Pinchart
Hi Stefan,

On Thu, Jun 11, 2020 at 09:33:11PM +0200, Stefan Agner wrote:
> On 2020-05-30 05:10, Laurent Pinchart wrote:
> > The DRM simple display pipeline helper only supports a single plane. In
> > order to prepare for support of the alpha plane on i.MX6SX and i.MX7,
> > move away from the helper. No new feature is added.
> > 
> > Signed-off-by: Laurent Pinchart 
> > ---
> > Changes since v1:
> > 
> > - Move after mxsfb_crtc.c rename to mxsfb_kms.c
> > ---
> >  drivers/gpu/drm/mxsfb/mxsfb_drv.c | 108 +++---
> >  drivers/gpu/drm/mxsfb/mxsfb_drv.h |  23 ++--
> >  drivers/gpu/drm/mxsfb/mxsfb_kms.c | 184 +++---
> >  3 files changed, 197 insertions(+), 118 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> > b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> > index 204c1e52e9aa..a8da92976d13 100644
> > --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> > +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> > @@ -10,22 +10,23 @@
> >  
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> > -#include 
> >  
> > -#include 
> >  #include 
> > -#include 
> > +#include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> > -#include 
> >  #include 
> >  
> >  #include "mxsfb_drv.h"
> > @@ -57,17 +58,6 @@ static const struct mxsfb_devdata mxsfb_devdata[] = {
> > },
> >  };
> >  
> > -static const uint32_t mxsfb_formats[] = {
> > -   DRM_FORMAT_XRGB,
> > -   DRM_FORMAT_RGB565
> > -};
> > -
> > -static struct mxsfb_drm_private *
> > -drm_pipe_to_mxsfb_drm_private(struct drm_simple_display_pipe *pipe)
> > -{
> > -   return container_of(pipe, struct mxsfb_drm_private, pipe);
> > -}
> > -
> >  void mxsfb_enable_axi_clk(struct mxsfb_drm_private *mxsfb)
> >  {
> > if (mxsfb->clk_axi)
> > @@ -90,77 +80,6 @@ static const struct drm_mode_config_helper_funcs
> > mxsfb_mode_config_helpers = {
> > .atomic_commit_tail = drm_atomic_helper_commit_tail_rpm,
> >  };
> >  
> > -static void mxsfb_pipe_enable(struct drm_simple_display_pipe *pipe,
> > - struct drm_crtc_state *crtc_state,
> > - struct drm_plane_state *plane_state)
> > -{
> > -   struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe);
> > -   struct drm_device *drm = pipe->plane.dev;
> > -
> > -   pm_runtime_get_sync(drm->dev);
> > -   mxsfb_crtc_enable(mxsfb);
> > -}
> > -
> > -static void mxsfb_pipe_disable(struct drm_simple_display_pipe *pipe)
> > -{
> > -   struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe);
> > -   struct drm_device *drm = pipe->plane.dev;
> > -   struct drm_crtc *crtc = &pipe->crtc;
> > -   struct drm_pending_vblank_event *event;
> > -
> > -   mxsfb_crtc_disable(mxsfb);
> > -   pm_runtime_put_sync(drm->dev);
> > -
> > -   spin_lock_irq(&drm->event_lock);
> > -   event = crtc->state->event;
> > -   if (event) {
> > -   crtc->state->event = NULL;
> > -   drm_crtc_send_vblank_event(crtc, event);
> > -   }
> > -   spin_unlock_irq(&drm->event_lock);
> > -}
> > -
> > -static void mxsfb_pipe_update(struct drm_simple_display_pipe *pipe,
> > - struct drm_plane_state *plane_state)
> > -{
> > -   struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe);
> > -
> > -   mxsfb_plane_atomic_update(mxsfb, plane_state);
> > -}
> > -
> > -static int mxsfb_pipe_enable_vblank(struct drm_simple_display_pipe *pipe)
> > -{
> > -   struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe);
> > -
> > -   /* Clear and enable VBLANK IRQ */
> > -   mxsfb_enable_axi_clk(mxsfb);
> > -   writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + REG_CLR);
> > -   writel(CTRL1_CUR_FRAME_DONE_IRQ_EN, mxsfb->base + LCDC_CTRL1 + REG_SET);
> > -   mxsfb_disable_axi_clk(mxsfb);
> > -
> > -   return 0;
> > -}
> > -
> > -static void mxsfb_pipe_disable_vblank(struct drm_simple_display_pipe *pipe)
> > -{
> > -   struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe);
> > -
> > -   /* Disable and clear VBLANK IRQ */
> > -   mxsfb_enable_axi_clk(mxsfb);
> > -   writel(CTRL1_CUR_FRAME_DONE_IRQ_EN, mxsfb->base + LCDC_CTRL1 + REG_CLR);
> > -   writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + REG_CLR);
> > -   mxsfb_disable_axi_clk(mxsfb);
> > -}
> > -
> > -static struct drm_simple_display_pipe_funcs mxsfb_funcs = {
> > -   .enable = mxsfb_pipe_enable,
> > -   .disable= mxsfb_pipe_disable,
> > -   .update = mxsfb_pipe_update,
> > -   .prepare_fb = drm_gem_fb_simple_display_pipe_prepare_fb,
> > -   .enable_vblank  = mxsfb_pipe_enable_vblank,
> > -   .disable_vblank = mxsfb_pipe_disable_vblank,
> > -};
> > -
> >  static int mxsfb_attach_bridge(struct mxsfb_drm_private *mxsfb)
> >  {
> > struct drm_device *drm = mxsfb->drm;
> > @@ -183,7 +102,7 @@ static int mxsfb_attach_bridge(struct
> > mxsfb_drm_private *mxsfb)
> > 

Re: [PATCH v2 11/22] drm: mxsfb: Stop using DRM simple display pipeline helper

2020-06-11 Thread Stefan Agner
On 2020-05-30 05:10, Laurent Pinchart wrote:
> The DRM simple display pipeline helper only supports a single plane. In
> order to prepare for support of the alpha plane on i.MX6SX and i.MX7,
> move away from the helper. No new feature is added.
> 
> Signed-off-by: Laurent Pinchart 
> ---
> Changes since v1:
> 
> - Move after mxsfb_crtc.c rename to mxsfb_kms.c
> ---
>  drivers/gpu/drm/mxsfb/mxsfb_drv.c | 108 +++---
>  drivers/gpu/drm/mxsfb/mxsfb_drv.h |  23 ++--
>  drivers/gpu/drm/mxsfb/mxsfb_kms.c | 184 +++---
>  3 files changed, 197 insertions(+), 118 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> index 204c1e52e9aa..a8da92976d13 100644
> --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> @@ -10,22 +10,23 @@
>  
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
> +#include 
>  #include 
> -#include 
>  
> -#include 
>  #include 
> -#include 
> +#include 
> +#include 
>  #include 
>  #include 
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
> -#include 
>  #include 
>  
>  #include "mxsfb_drv.h"
> @@ -57,17 +58,6 @@ static const struct mxsfb_devdata mxsfb_devdata[] = {
>   },
>  };
>  
> -static const uint32_t mxsfb_formats[] = {
> - DRM_FORMAT_XRGB,
> - DRM_FORMAT_RGB565
> -};
> -
> -static struct mxsfb_drm_private *
> -drm_pipe_to_mxsfb_drm_private(struct drm_simple_display_pipe *pipe)
> -{
> - return container_of(pipe, struct mxsfb_drm_private, pipe);
> -}
> -
>  void mxsfb_enable_axi_clk(struct mxsfb_drm_private *mxsfb)
>  {
>   if (mxsfb->clk_axi)
> @@ -90,77 +80,6 @@ static const struct drm_mode_config_helper_funcs
> mxsfb_mode_config_helpers = {
>   .atomic_commit_tail = drm_atomic_helper_commit_tail_rpm,
>  };
>  
> -static void mxsfb_pipe_enable(struct drm_simple_display_pipe *pipe,
> -   struct drm_crtc_state *crtc_state,
> -   struct drm_plane_state *plane_state)
> -{
> - struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe);
> - struct drm_device *drm = pipe->plane.dev;
> -
> - pm_runtime_get_sync(drm->dev);
> - mxsfb_crtc_enable(mxsfb);
> -}
> -
> -static void mxsfb_pipe_disable(struct drm_simple_display_pipe *pipe)
> -{
> - struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe);
> - struct drm_device *drm = pipe->plane.dev;
> - struct drm_crtc *crtc = &pipe->crtc;
> - struct drm_pending_vblank_event *event;
> -
> - mxsfb_crtc_disable(mxsfb);
> - pm_runtime_put_sync(drm->dev);
> -
> - spin_lock_irq(&drm->event_lock);
> - event = crtc->state->event;
> - if (event) {
> - crtc->state->event = NULL;
> - drm_crtc_send_vblank_event(crtc, event);
> - }
> - spin_unlock_irq(&drm->event_lock);
> -}
> -
> -static void mxsfb_pipe_update(struct drm_simple_display_pipe *pipe,
> -   struct drm_plane_state *plane_state)
> -{
> - struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe);
> -
> - mxsfb_plane_atomic_update(mxsfb, plane_state);
> -}
> -
> -static int mxsfb_pipe_enable_vblank(struct drm_simple_display_pipe *pipe)
> -{
> - struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe);
> -
> - /* Clear and enable VBLANK IRQ */
> - mxsfb_enable_axi_clk(mxsfb);
> - writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + REG_CLR);
> - writel(CTRL1_CUR_FRAME_DONE_IRQ_EN, mxsfb->base + LCDC_CTRL1 + REG_SET);
> - mxsfb_disable_axi_clk(mxsfb);
> -
> - return 0;
> -}
> -
> -static void mxsfb_pipe_disable_vblank(struct drm_simple_display_pipe *pipe)
> -{
> - struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe);
> -
> - /* Disable and clear VBLANK IRQ */
> - mxsfb_enable_axi_clk(mxsfb);
> - writel(CTRL1_CUR_FRAME_DONE_IRQ_EN, mxsfb->base + LCDC_CTRL1 + REG_CLR);
> - writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + REG_CLR);
> - mxsfb_disable_axi_clk(mxsfb);
> -}
> -
> -static struct drm_simple_display_pipe_funcs mxsfb_funcs = {
> - .enable = mxsfb_pipe_enable,
> - .disable= mxsfb_pipe_disable,
> - .update = mxsfb_pipe_update,
> - .prepare_fb = drm_gem_fb_simple_display_pipe_prepare_fb,
> - .enable_vblank  = mxsfb_pipe_enable_vblank,
> - .disable_vblank = mxsfb_pipe_disable_vblank,
> -};
> -
>  static int mxsfb_attach_bridge(struct mxsfb_drm_private *mxsfb)
>  {
>   struct drm_device *drm = mxsfb->drm;
> @@ -183,7 +102,7 @@ static int mxsfb_attach_bridge(struct
> mxsfb_drm_private *mxsfb)
>   if (!bridge)
>   return -ENODEV;
>  
> - ret = drm_simple_display_pipe_attach_bridge(&mxsfb->pipe, bridge);
> + ret = drm_bridge_attach(&mxsfb->encoder, bridge, NULL, 0);
>   if (ret) {
>   DRM_DEV_ERROR(drm->dev,
>   

[PATCH v2 11/22] drm: mxsfb: Stop using DRM simple display pipeline helper

2020-05-29 Thread Laurent Pinchart
The DRM simple display pipeline helper only supports a single plane. In
order to prepare for support of the alpha plane on i.MX6SX and i.MX7,
move away from the helper. No new feature is added.

Signed-off-by: Laurent Pinchart 
---
Changes since v1:

- Move after mxsfb_crtc.c rename to mxsfb_kms.c
---
 drivers/gpu/drm/mxsfb/mxsfb_drv.c | 108 +++---
 drivers/gpu/drm/mxsfb/mxsfb_drv.h |  23 ++--
 drivers/gpu/drm/mxsfb/mxsfb_kms.c | 184 +++---
 3 files changed, 197 insertions(+), 118 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c 
b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
index 204c1e52e9aa..a8da92976d13 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
@@ -10,22 +10,23 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
+#include 
 #include 
-#include 
 
-#include 
 #include 
-#include 
+#include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
-#include 
 #include 
 
 #include "mxsfb_drv.h"
@@ -57,17 +58,6 @@ static const struct mxsfb_devdata mxsfb_devdata[] = {
},
 };
 
-static const uint32_t mxsfb_formats[] = {
-   DRM_FORMAT_XRGB,
-   DRM_FORMAT_RGB565
-};
-
-static struct mxsfb_drm_private *
-drm_pipe_to_mxsfb_drm_private(struct drm_simple_display_pipe *pipe)
-{
-   return container_of(pipe, struct mxsfb_drm_private, pipe);
-}
-
 void mxsfb_enable_axi_clk(struct mxsfb_drm_private *mxsfb)
 {
if (mxsfb->clk_axi)
@@ -90,77 +80,6 @@ static const struct drm_mode_config_helper_funcs 
mxsfb_mode_config_helpers = {
.atomic_commit_tail = drm_atomic_helper_commit_tail_rpm,
 };
 
-static void mxsfb_pipe_enable(struct drm_simple_display_pipe *pipe,
- struct drm_crtc_state *crtc_state,
- struct drm_plane_state *plane_state)
-{
-   struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe);
-   struct drm_device *drm = pipe->plane.dev;
-
-   pm_runtime_get_sync(drm->dev);
-   mxsfb_crtc_enable(mxsfb);
-}
-
-static void mxsfb_pipe_disable(struct drm_simple_display_pipe *pipe)
-{
-   struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe);
-   struct drm_device *drm = pipe->plane.dev;
-   struct drm_crtc *crtc = &pipe->crtc;
-   struct drm_pending_vblank_event *event;
-
-   mxsfb_crtc_disable(mxsfb);
-   pm_runtime_put_sync(drm->dev);
-
-   spin_lock_irq(&drm->event_lock);
-   event = crtc->state->event;
-   if (event) {
-   crtc->state->event = NULL;
-   drm_crtc_send_vblank_event(crtc, event);
-   }
-   spin_unlock_irq(&drm->event_lock);
-}
-
-static void mxsfb_pipe_update(struct drm_simple_display_pipe *pipe,
- struct drm_plane_state *plane_state)
-{
-   struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe);
-
-   mxsfb_plane_atomic_update(mxsfb, plane_state);
-}
-
-static int mxsfb_pipe_enable_vblank(struct drm_simple_display_pipe *pipe)
-{
-   struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe);
-
-   /* Clear and enable VBLANK IRQ */
-   mxsfb_enable_axi_clk(mxsfb);
-   writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + REG_CLR);
-   writel(CTRL1_CUR_FRAME_DONE_IRQ_EN, mxsfb->base + LCDC_CTRL1 + REG_SET);
-   mxsfb_disable_axi_clk(mxsfb);
-
-   return 0;
-}
-
-static void mxsfb_pipe_disable_vblank(struct drm_simple_display_pipe *pipe)
-{
-   struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe);
-
-   /* Disable and clear VBLANK IRQ */
-   mxsfb_enable_axi_clk(mxsfb);
-   writel(CTRL1_CUR_FRAME_DONE_IRQ_EN, mxsfb->base + LCDC_CTRL1 + REG_CLR);
-   writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + REG_CLR);
-   mxsfb_disable_axi_clk(mxsfb);
-}
-
-static struct drm_simple_display_pipe_funcs mxsfb_funcs = {
-   .enable = mxsfb_pipe_enable,
-   .disable= mxsfb_pipe_disable,
-   .update = mxsfb_pipe_update,
-   .prepare_fb = drm_gem_fb_simple_display_pipe_prepare_fb,
-   .enable_vblank  = mxsfb_pipe_enable_vblank,
-   .disable_vblank = mxsfb_pipe_disable_vblank,
-};
-
 static int mxsfb_attach_bridge(struct mxsfb_drm_private *mxsfb)
 {
struct drm_device *drm = mxsfb->drm;
@@ -183,7 +102,7 @@ static int mxsfb_attach_bridge(struct mxsfb_drm_private 
*mxsfb)
if (!bridge)
return -ENODEV;
 
-   ret = drm_simple_display_pipe_attach_bridge(&mxsfb->pipe, bridge);
+   ret = drm_bridge_attach(&mxsfb->encoder, bridge, NULL, 0);
if (ret) {
DRM_DEV_ERROR(drm->dev,
  "failed to attach bridge: %d\n", ret);
@@ -250,10 +169,9 @@ static int mxsfb_load(struct drm_device *drm, unsigned 
long flags)
/* Modeset init */
drm_mode_config_init(drm);
 
-   ret = drm_simple_display_pipe_init(d