[PATCH v2 07/14] v4l: vsp1: Add support for the BRS entity

2017-06-26 Thread Laurent Pinchart
The Blend/ROP Sub Unit (BRS) is a stripped-down version of the BRU found
in several VSP2 instances. Compared to a regular BRU, it supports two
inputs only, and thus has no ROP unit.

Add support for the BRS by modeling it as a new entity type, but reuse
the vsp1_bru object underneath. Chaining the BRU and BRS entities seems
to be supported by the hardware but isn't implemented yet as it isn't
the primary use case for the BRS.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/platform/vsp1/vsp1.h|  2 +
 drivers/media/platform/vsp1/vsp1_bru.c| 45 ++
 drivers/media/platform/vsp1/vsp1_bru.h|  4 +-
 drivers/media/platform/vsp1/vsp1_drv.c| 19 +-
 drivers/media/platform/vsp1/vsp1_entity.c | 13 ++-
 drivers/media/platform/vsp1/vsp1_entity.h |  1 +
 drivers/media/platform/vsp1/vsp1_pipe.c   |  7 ++--
 drivers/media/platform/vsp1/vsp1_regs.h   | 26 +
 drivers/media/platform/vsp1/vsp1_video.c  | 63 ---
 drivers/media/platform/vsp1/vsp1_wpf.c|  4 +-
 10 files changed, 130 insertions(+), 54 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1.h 
b/drivers/media/platform/vsp1/vsp1.h
index 847963b6e9eb..73858a0ed35c 100644
--- a/drivers/media/platform/vsp1/vsp1.h
+++ b/drivers/media/platform/vsp1/vsp1.h
@@ -54,6 +54,7 @@ struct vsp1_uds;
 #define VSP1_HAS_WPF_HFLIP (1 << 6)
 #define VSP1_HAS_HGO   (1 << 7)
 #define VSP1_HAS_HGT   (1 << 8)
+#define VSP1_HAS_BRS   (1 << 9)
 
 struct vsp1_device_info {
u32 version;
@@ -76,6 +77,7 @@ struct vsp1_device {
struct rcar_fcp_device *fcp;
struct device *bus_master;
 
+   struct vsp1_bru *brs;
struct vsp1_bru *bru;
struct vsp1_clu *clu;
struct vsp1_hgo *hgo;
diff --git a/drivers/media/platform/vsp1/vsp1_bru.c 
b/drivers/media/platform/vsp1/vsp1_bru.c
index 85362c5ef57a..e8fd2ae3b3eb 100644
--- a/drivers/media/platform/vsp1/vsp1_bru.c
+++ b/drivers/media/platform/vsp1/vsp1_bru.c
@@ -33,7 +33,7 @@
 static inline void vsp1_bru_write(struct vsp1_bru *bru, struct vsp1_dl_list 
*dl,
  u32 reg, u32 data)
 {
-   vsp1_dl_list_write(dl, reg, data);
+   vsp1_dl_list_write(dl, bru->base + reg, data);
 }
 
 /* 
-
@@ -332,11 +332,14 @@ static void bru_configure(struct vsp1_entity *entity,
/*
 * Route BRU input 1 as SRC input to the ROP unit and configure the ROP
 * unit with a NOP operation to make BRU input 1 available as the
-* Blend/ROP unit B SRC input.
+* Blend/ROP unit B SRC input. Only needed for BRU, the BRS has no ROP
+* unit.
 */
-   vsp1_bru_write(bru, dl, VI6_BRU_ROP, VI6_BRU_ROP_DSTSEL_BRUIN(1) |
-  VI6_BRU_ROP_CROP(VI6_ROP_NOP) |
-  VI6_BRU_ROP_AROP(VI6_ROP_NOP));
+   if (entity->type == VSP1_ENTITY_BRU)
+   vsp1_bru_write(bru, dl, VI6_BRU_ROP,
+  VI6_BRU_ROP_DSTSEL_BRUIN(1) |
+  VI6_BRU_ROP_CROP(VI6_ROP_NOP) |
+  VI6_BRU_ROP_AROP(VI6_ROP_NOP));
 
for (i = 0; i < bru->entity.source_pad; ++i) {
bool premultiplied = false;
@@ -366,12 +369,13 @@ static void bru_configure(struct vsp1_entity *entity,
ctrl |= VI6_BRU_CTRL_DSTSEL_VRPF;
 
/*
-* Route BRU inputs 0 to 3 as SRC inputs to Blend/ROP units A to
-* D in that order. The Blend/ROP unit B SRC is hardwired to the
-* ROP unit output, the corresponding register bits must be set
-* to 0.
+* Route inputs 0 to 3 as SRC inputs to Blend/ROP units A to D
+* in that order. In the BRU the Blend/ROP unit B SRC is
+* hardwired to the ROP unit output, the corresponding register
+* bits must be set to 0. The BRS has no ROP unit and doesn't
+* need any special processing.
 */
-   if (i != 1)
+   if (!(entity->type == VSP1_ENTITY_BRU && i == 1))
ctrl |= VI6_BRU_CTRL_SRCSEL_BRUIN(i);
 
vsp1_bru_write(bru, dl, VI6_BRU_CTRL(i), ctrl);
@@ -407,20 +411,31 @@ static const struct vsp1_entity_operations bru_entity_ops 
= {
  * Initialization and Cleanup
  */
 
-struct vsp1_bru *vsp1_bru_create(struct vsp1_device *vsp1)
+struct vsp1_bru *vsp1_bru_create(struct vsp1_device *vsp1,
+enum vsp1_entity_type type)
 {
struct vsp1_bru *bru;
+   unsigned int num_pads;
+   const char *name;
int ret;
 
bru = devm_kzalloc(vsp1->dev, sizeof(*bru), GFP_KERNEL);
if (bru == NULL)
return ERR_PTR(-ENOMEM);
 
+   bru->base = type == VSP1_ENTITY_BRU ? VI6_BRU_BASE : VI6_BRS_BASE;
bru->entity.ops = &bru_ent

Re: [PATCH v2 07/14] v4l: vsp1: Add support for the BRS entity

2017-07-13 Thread Kieran Bingham
On 26/06/17 19:12, Laurent Pinchart wrote:
> The Blend/ROP Sub Unit (BRS) is a stripped-down version of the BRU found
> in several VSP2 instances. Compared to a regular BRU, it supports two
> inputs only, and thus has no ROP unit.
> 
> Add support for the BRS by modeling it as a new entity type, but reuse

s/modeling/modelling/


> the vsp1_bru object underneath. Chaining the BRU and BRS entities seems
> to be supported by the hardware but isn't implemented yet as it isn't
> the primary use case for the BRS.
> 
> Signed-off-by: Laurent Pinchart 

Reviewed-by: Kieran Bingham 

> ---
>  drivers/media/platform/vsp1/vsp1.h|  2 +
>  drivers/media/platform/vsp1/vsp1_bru.c| 45 ++
>  drivers/media/platform/vsp1/vsp1_bru.h|  4 +-
>  drivers/media/platform/vsp1/vsp1_drv.c| 19 +-
>  drivers/media/platform/vsp1/vsp1_entity.c | 13 ++-
>  drivers/media/platform/vsp1/vsp1_entity.h |  1 +
>  drivers/media/platform/vsp1/vsp1_pipe.c   |  7 ++--
>  drivers/media/platform/vsp1/vsp1_regs.h   | 26 +
>  drivers/media/platform/vsp1/vsp1_video.c  | 63 
> ---
>  drivers/media/platform/vsp1/vsp1_wpf.c|  4 +-
>  10 files changed, 130 insertions(+), 54 deletions(-)
> 
> diff --git a/drivers/media/platform/vsp1/vsp1.h 
> b/drivers/media/platform/vsp1/vsp1.h
> index 847963b6e9eb..73858a0ed35c 100644
> --- a/drivers/media/platform/vsp1/vsp1.h
> +++ b/drivers/media/platform/vsp1/vsp1.h
> @@ -54,6 +54,7 @@ struct vsp1_uds;
>  #define VSP1_HAS_WPF_HFLIP   (1 << 6)
>  #define VSP1_HAS_HGO (1 << 7)
>  #define VSP1_HAS_HGT (1 << 8)
> +#define VSP1_HAS_BRS (1 << 9)
>  
>  struct vsp1_device_info {
>   u32 version;
> @@ -76,6 +77,7 @@ struct vsp1_device {
>   struct rcar_fcp_device *fcp;
>   struct device *bus_master;
>  
> + struct vsp1_bru *brs;
>   struct vsp1_bru *bru;
>   struct vsp1_clu *clu;
>   struct vsp1_hgo *hgo;
> diff --git a/drivers/media/platform/vsp1/vsp1_bru.c 
> b/drivers/media/platform/vsp1/vsp1_bru.c
> index 85362c5ef57a..e8fd2ae3b3eb 100644
> --- a/drivers/media/platform/vsp1/vsp1_bru.c
> +++ b/drivers/media/platform/vsp1/vsp1_bru.c
> @@ -33,7 +33,7 @@
>  static inline void vsp1_bru_write(struct vsp1_bru *bru, struct vsp1_dl_list 
> *dl,
> u32 reg, u32 data)
>  {
> - vsp1_dl_list_write(dl, reg, data);
> + vsp1_dl_list_write(dl, bru->base + reg, data);
>  }
>  
>  /* 
> -
> @@ -332,11 +332,14 @@ static void bru_configure(struct vsp1_entity *entity,
>   /*
>* Route BRU input 1 as SRC input to the ROP unit and configure the ROP
>* unit with a NOP operation to make BRU input 1 available as the
> -  * Blend/ROP unit B SRC input.
> +  * Blend/ROP unit B SRC input. Only needed for BRU, the BRS has no ROP
> +  * unit.
>*/
> - vsp1_bru_write(bru, dl, VI6_BRU_ROP, VI6_BRU_ROP_DSTSEL_BRUIN(1) |
> -VI6_BRU_ROP_CROP(VI6_ROP_NOP) |
> -VI6_BRU_ROP_AROP(VI6_ROP_NOP));
> + if (entity->type == VSP1_ENTITY_BRU)
> + vsp1_bru_write(bru, dl, VI6_BRU_ROP,
> +VI6_BRU_ROP_DSTSEL_BRUIN(1) |
> +VI6_BRU_ROP_CROP(VI6_ROP_NOP) |
> +VI6_BRU_ROP_AROP(VI6_ROP_NOP));
>  
>   for (i = 0; i < bru->entity.source_pad; ++i) {
>   bool premultiplied = false;
> @@ -366,12 +369,13 @@ static void bru_configure(struct vsp1_entity *entity,
>   ctrl |= VI6_BRU_CTRL_DSTSEL_VRPF;
>  
>   /*
> -  * Route BRU inputs 0 to 3 as SRC inputs to Blend/ROP units A to
> -  * D in that order. The Blend/ROP unit B SRC is hardwired to the
> -  * ROP unit output, the corresponding register bits must be set
> -  * to 0.
> +  * Route inputs 0 to 3 as SRC inputs to Blend/ROP units A to D
> +  * in that order. In the BRU the Blend/ROP unit B SRC is
> +  * hardwired to the ROP unit output, the corresponding register
> +  * bits must be set to 0. The BRS has no ROP unit and doesn't
> +  * need any special processing.
>*/
> - if (i != 1)
> + if (!(entity->type == VSP1_ENTITY_BRU && i == 1))

If we're using this module for both BRU and BRS, would an is_bru(entity) and
is_brs(entity) be cleaner here ?

Not required - just thinking outloud...

Actaully - it's only this line that would be affected so not really needed.  I
thought there would be more uses/differences.

>   ctrl |= VI6_BRU_CTRL_SRCSEL_BRUIN(i);
>  
>   vsp1_bru_write(bru, dl, VI6_BRU_CTRL(i), ctrl);
> @@ -407,20 +411,31 @@ static const struct vsp1_entity_operations 
> bru_entity_ops = {
>   * Initialization and Cleanup
>   */
>  
> -struct vsp1_bru *vsp1_bru_create(str

Re: [PATCH v2 07/14] v4l: vsp1: Add support for the BRS entity

2017-07-20 Thread Mauro Carvalho Chehab
Em Thu, 13 Jul 2017 14:38:40 +0100
Kieran Bingham  escreveu:

> On 26/06/17 19:12, Laurent Pinchart wrote:
> > The Blend/ROP Sub Unit (BRS) is a stripped-down version of the BRU found
> > in several VSP2 instances. Compared to a regular BRU, it supports two
> > inputs only, and thus has no ROP unit.
> > 
> > Add support for the BRS by modeling it as a new entity type, but reuse  
> 
> s/modeling/modelling/
> 
> 
> > the vsp1_bru object underneath. Chaining the BRU and BRS entities seems
> > to be supported by the hardware but isn't implemented yet as it isn't
> > the primary use case for the BRS.
> > 
> > Signed-off-by: Laurent Pinchart  
> >  
> 
> Reviewed-by: Kieran Bingham 

Acked-by: Mauro Carvalho Chehab 

Thanks,
Mauro