LinuxTV Patchwork [v6,09/18] media: vsp1: drm: Split RPF format setting to separate function

login
register
mail settings
Submitter Laurent Pinchart
Date March 13, 2019, 12:05 a.m.
Message ID <20190313000532.7087-10-laurent.pinchart+renesas@ideasonboard.com>
Download mbox | patch
Permalink /patch/55023/
State New
Headers show

Comments

Laurent Pinchart - March 13, 2019, 12:05 a.m.
The code that initializes the RPF format-related fields for display
pipelines will also be useful for the WPF to implement writeback
support. Split it from vsp1_du_atomic_update() to a new
vsp1_du_pipeline_set_rwpf_format() function.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/media/platform/vsp1/vsp1_drm.c | 55 ++++++++++++++++----------
 1 file changed, 35 insertions(+), 20 deletions(-)
Kieran Bingham - March 13, 2019, 11:12 a.m.
Hi Laurent,

On 13/03/2019 00:05, Laurent Pinchart wrote:
> The code that initializes the RPF format-related fields for display
> pipelines will also be useful for the WPF to implement writeback
> support. Split it from vsp1_du_atomic_update() to a new
> vsp1_du_pipeline_set_rwpf_format() function.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>  drivers/media/platform/vsp1/vsp1_drm.c | 55 ++++++++++++++++----------
>  1 file changed, 35 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/media/platform/vsp1/vsp1_drm.c b/drivers/media/platform/vsp1/vsp1_drm.c
> index 4f1bc51d1ef4..5601a787688b 100644
> --- a/drivers/media/platform/vsp1/vsp1_drm.c
> +++ b/drivers/media/platform/vsp1/vsp1_drm.c
> @@ -566,6 +566,36 @@ static void vsp1_du_pipeline_configure(struct vsp1_pipeline *pipe)
>  	vsp1_dl_list_commit(dl, dl_flags);
>  }
>  
> +static int vsp1_du_pipeline_set_rwpf_format(struct vsp1_device *vsp1,
> +					    struct vsp1_rwpf *rwpf,
> +					    u32 pixelformat, unsigned int pitch)
> +{
> +	const struct vsp1_format_info *fmtinfo;
> +	unsigned int chroma_hsub;
> +
> +	fmtinfo = vsp1_get_format_info(vsp1, pixelformat);
> +	if (!fmtinfo) {
> +		dev_dbg(vsp1->dev, "Unsupported pixel format %08x for RPF\n",

Isn't this now a RWPF ?

Other than that

Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>


> +			pixelformat);
> +		return -EINVAL;
> +	}
> +
> +	/*
> +	 * Only formats with three planes can affect the chroma planes pitch.
> +	 * All formats with two planes have a horizontal subsampling value of 2,
> +	 * but combine U and V in a single chroma plane, which thus results in
> +	 * the luma plane and chroma plane having the same pitch.
> +	 */
> +	chroma_hsub = (fmtinfo->planes == 3) ? fmtinfo->hsub : 1;
> +
> +	rwpf->fmtinfo = fmtinfo;
> +	rwpf->format.num_planes = fmtinfo->planes;
> +	rwpf->format.plane_fmt[0].bytesperline = pitch;
> +	rwpf->format.plane_fmt[1].bytesperline = pitch / chroma_hsub;
> +
> +	return 0;
> +}
> +
>  /* -----------------------------------------------------------------------------
>   * DU Driver API
>   */
> @@ -773,9 +803,8 @@ int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index,
>  {
>  	struct vsp1_device *vsp1 = dev_get_drvdata(dev);
>  	struct vsp1_drm_pipeline *drm_pipe = &vsp1->drm->pipe[pipe_index];
> -	const struct vsp1_format_info *fmtinfo;
> -	unsigned int chroma_hsub;
>  	struct vsp1_rwpf *rpf;
> +	int ret;
>  
>  	if (rpf_index >= vsp1->info->rpf_count)
>  		return -EINVAL;
> @@ -808,25 +837,11 @@ int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index,
>  	 * Store the format, stride, memory buffer address, crop and compose
>  	 * rectangles and Z-order position and for the input.
>  	 */
> -	fmtinfo = vsp1_get_format_info(vsp1, cfg->pixelformat);
> -	if (!fmtinfo) {
> -		dev_dbg(vsp1->dev, "Unsupported pixel format %08x for RPF\n",
> -			cfg->pixelformat);
> -		return -EINVAL;
> -	}
> +	ret = vsp1_du_pipeline_set_rwpf_format(vsp1, rpf, cfg->pixelformat,
> +					       cfg->pitch);
> +	if (ret < 0)
> +		return ret;
>  
> -	/*
> -	 * Only formats with three planes can affect the chroma planes pitch.
> -	 * All formats with two planes have a horizontal subsampling value of 2,
> -	 * but combine U and V in a single chroma plane, which thus results in
> -	 * the luma plane and chroma plane having the same pitch.
> -	 */
> -	chroma_hsub = (fmtinfo->planes == 3) ? fmtinfo->hsub : 1;
> -
> -	rpf->fmtinfo = fmtinfo;
> -	rpf->format.num_planes = fmtinfo->planes;
> -	rpf->format.plane_fmt[0].bytesperline = cfg->pitch;
> -	rpf->format.plane_fmt[1].bytesperline = cfg->pitch / chroma_hsub;
>  	rpf->alpha = cfg->alpha;
>  
>  	rpf->mem.addr[0] = cfg->mem[0];
>
Laurent Pinchart - March 13, 2019, 11:17 a.m.
Hi Kieran,

On Wed, Mar 13, 2019 at 11:12:57AM +0000, Kieran Bingham wrote:
> On 13/03/2019 00:05, Laurent Pinchart wrote:
> > The code that initializes the RPF format-related fields for display
> > pipelines will also be useful for the WPF to implement writeback
> > support. Split it from vsp1_du_atomic_update() to a new
> > vsp1_du_pipeline_set_rwpf_format() function.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > ---
> >  drivers/media/platform/vsp1/vsp1_drm.c | 55 ++++++++++++++++----------
> >  1 file changed, 35 insertions(+), 20 deletions(-)
> > 
> > diff --git a/drivers/media/platform/vsp1/vsp1_drm.c b/drivers/media/platform/vsp1/vsp1_drm.c
> > index 4f1bc51d1ef4..5601a787688b 100644
> > --- a/drivers/media/platform/vsp1/vsp1_drm.c
> > +++ b/drivers/media/platform/vsp1/vsp1_drm.c
> > @@ -566,6 +566,36 @@ static void vsp1_du_pipeline_configure(struct vsp1_pipeline *pipe)
> >  	vsp1_dl_list_commit(dl, dl_flags);
> >  }
> >  
> > +static int vsp1_du_pipeline_set_rwpf_format(struct vsp1_device *vsp1,
> > +					    struct vsp1_rwpf *rwpf,
> > +					    u32 pixelformat, unsigned int pitch)
> > +{
> > +	const struct vsp1_format_info *fmtinfo;
> > +	unsigned int chroma_hsub;
> > +
> > +	fmtinfo = vsp1_get_format_info(vsp1, pixelformat);
> > +	if (!fmtinfo) {
> > +		dev_dbg(vsp1->dev, "Unsupported pixel format %08x for RPF\n",
> 
> Isn't this now a RWPF ?

It is. I'll drop the "for RPF" part.

> Other than that
> 
> Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> 
> > +			pixelformat);
> > +		return -EINVAL;
> > +	}
> > +
> > +	/*
> > +	 * Only formats with three planes can affect the chroma planes pitch.
> > +	 * All formats with two planes have a horizontal subsampling value of 2,
> > +	 * but combine U and V in a single chroma plane, which thus results in
> > +	 * the luma plane and chroma plane having the same pitch.
> > +	 */
> > +	chroma_hsub = (fmtinfo->planes == 3) ? fmtinfo->hsub : 1;
> > +
> > +	rwpf->fmtinfo = fmtinfo;
> > +	rwpf->format.num_planes = fmtinfo->planes;
> > +	rwpf->format.plane_fmt[0].bytesperline = pitch;
> > +	rwpf->format.plane_fmt[1].bytesperline = pitch / chroma_hsub;
> > +
> > +	return 0;
> > +}
> > +
> >  /* -----------------------------------------------------------------------------
> >   * DU Driver API
> >   */
> > @@ -773,9 +803,8 @@ int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index,
> >  {
> >  	struct vsp1_device *vsp1 = dev_get_drvdata(dev);
> >  	struct vsp1_drm_pipeline *drm_pipe = &vsp1->drm->pipe[pipe_index];
> > -	const struct vsp1_format_info *fmtinfo;
> > -	unsigned int chroma_hsub;
> >  	struct vsp1_rwpf *rpf;
> > +	int ret;
> >  
> >  	if (rpf_index >= vsp1->info->rpf_count)
> >  		return -EINVAL;
> > @@ -808,25 +837,11 @@ int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index,
> >  	 * Store the format, stride, memory buffer address, crop and compose
> >  	 * rectangles and Z-order position and for the input.
> >  	 */
> > -	fmtinfo = vsp1_get_format_info(vsp1, cfg->pixelformat);
> > -	if (!fmtinfo) {
> > -		dev_dbg(vsp1->dev, "Unsupported pixel format %08x for RPF\n",
> > -			cfg->pixelformat);
> > -		return -EINVAL;
> > -	}
> > +	ret = vsp1_du_pipeline_set_rwpf_format(vsp1, rpf, cfg->pixelformat,
> > +					       cfg->pitch);
> > +	if (ret < 0)
> > +		return ret;
> >  
> > -	/*
> > -	 * Only formats with three planes can affect the chroma planes pitch.
> > -	 * All formats with two planes have a horizontal subsampling value of 2,
> > -	 * but combine U and V in a single chroma plane, which thus results in
> > -	 * the luma plane and chroma plane having the same pitch.
> > -	 */
> > -	chroma_hsub = (fmtinfo->planes == 3) ? fmtinfo->hsub : 1;
> > -
> > -	rpf->fmtinfo = fmtinfo;
> > -	rpf->format.num_planes = fmtinfo->planes;
> > -	rpf->format.plane_fmt[0].bytesperline = cfg->pitch;
> > -	rpf->format.plane_fmt[1].bytesperline = cfg->pitch / chroma_hsub;
> >  	rpf->alpha = cfg->alpha;
> >  
> >  	rpf->mem.addr[0] = cfg->mem[0];

Patch

diff --git a/drivers/media/platform/vsp1/vsp1_drm.c b/drivers/media/platform/vsp1/vsp1_drm.c
index 4f1bc51d1ef4..5601a787688b 100644
--- a/drivers/media/platform/vsp1/vsp1_drm.c
+++ b/drivers/media/platform/vsp1/vsp1_drm.c
@@ -566,6 +566,36 @@  static void vsp1_du_pipeline_configure(struct vsp1_pipeline *pipe)
 	vsp1_dl_list_commit(dl, dl_flags);
 }
 
+static int vsp1_du_pipeline_set_rwpf_format(struct vsp1_device *vsp1,
+					    struct vsp1_rwpf *rwpf,
+					    u32 pixelformat, unsigned int pitch)
+{
+	const struct vsp1_format_info *fmtinfo;
+	unsigned int chroma_hsub;
+
+	fmtinfo = vsp1_get_format_info(vsp1, pixelformat);
+	if (!fmtinfo) {
+		dev_dbg(vsp1->dev, "Unsupported pixel format %08x for RPF\n",
+			pixelformat);
+		return -EINVAL;
+	}
+
+	/*
+	 * Only formats with three planes can affect the chroma planes pitch.
+	 * All formats with two planes have a horizontal subsampling value of 2,
+	 * but combine U and V in a single chroma plane, which thus results in
+	 * the luma plane and chroma plane having the same pitch.
+	 */
+	chroma_hsub = (fmtinfo->planes == 3) ? fmtinfo->hsub : 1;
+
+	rwpf->fmtinfo = fmtinfo;
+	rwpf->format.num_planes = fmtinfo->planes;
+	rwpf->format.plane_fmt[0].bytesperline = pitch;
+	rwpf->format.plane_fmt[1].bytesperline = pitch / chroma_hsub;
+
+	return 0;
+}
+
 /* -----------------------------------------------------------------------------
  * DU Driver API
  */
@@ -773,9 +803,8 @@  int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index,
 {
 	struct vsp1_device *vsp1 = dev_get_drvdata(dev);
 	struct vsp1_drm_pipeline *drm_pipe = &vsp1->drm->pipe[pipe_index];
-	const struct vsp1_format_info *fmtinfo;
-	unsigned int chroma_hsub;
 	struct vsp1_rwpf *rpf;
+	int ret;
 
 	if (rpf_index >= vsp1->info->rpf_count)
 		return -EINVAL;
@@ -808,25 +837,11 @@  int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index,
 	 * Store the format, stride, memory buffer address, crop and compose
 	 * rectangles and Z-order position and for the input.
 	 */
-	fmtinfo = vsp1_get_format_info(vsp1, cfg->pixelformat);
-	if (!fmtinfo) {
-		dev_dbg(vsp1->dev, "Unsupported pixel format %08x for RPF\n",
-			cfg->pixelformat);
-		return -EINVAL;
-	}
+	ret = vsp1_du_pipeline_set_rwpf_format(vsp1, rpf, cfg->pixelformat,
+					       cfg->pitch);
+	if (ret < 0)
+		return ret;
 
-	/*
-	 * Only formats with three planes can affect the chroma planes pitch.
-	 * All formats with two planes have a horizontal subsampling value of 2,
-	 * but combine U and V in a single chroma plane, which thus results in
-	 * the luma plane and chroma plane having the same pitch.
-	 */
-	chroma_hsub = (fmtinfo->planes == 3) ? fmtinfo->hsub : 1;
-
-	rpf->fmtinfo = fmtinfo;
-	rpf->format.num_planes = fmtinfo->planes;
-	rpf->format.plane_fmt[0].bytesperline = cfg->pitch;
-	rpf->format.plane_fmt[1].bytesperline = cfg->pitch / chroma_hsub;
 	rpf->alpha = cfg->alpha;
 
 	rpf->mem.addr[0] = cfg->mem[0];

Privacy Policy