[PATCH 2/2] media: st-hva: don't use GFP_DMA

2018-05-15 Thread Fabien Dessenne
Set the DMA_MASK and stop using the GFP_DMA flag

Signed-off-by: Fabien Dessenne <fabien.desse...@st.com>
---
 drivers/media/platform/sti/hva/hva-mem.c  | 2 +-
 drivers/media/platform/sti/hva/hva-v4l2.c | 4 
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/sti/hva/hva-mem.c 
b/drivers/media/platform/sti/hva/hva-mem.c
index caf50cd..68047b6 100644
--- a/drivers/media/platform/sti/hva/hva-mem.c
+++ b/drivers/media/platform/sti/hva/hva-mem.c
@@ -22,7 +22,7 @@ int hva_mem_alloc(struct hva_ctx *ctx, u32 size, const char 
*name,
return -ENOMEM;
}
 
-   base = dma_alloc_attrs(dev, size, , GFP_KERNEL | GFP_DMA,
+   base = dma_alloc_attrs(dev, size, , GFP_KERNEL,
   DMA_ATTR_WRITE_COMBINE);
if (!base) {
dev_err(dev, "%s %s : dma_alloc_attrs failed for %s 
(size=%d)\n",
diff --git a/drivers/media/platform/sti/hva/hva-v4l2.c 
b/drivers/media/platform/sti/hva/hva-v4l2.c
index 2ab0b5c..15080cb 100644
--- a/drivers/media/platform/sti/hva/hva-v4l2.c
+++ b/drivers/media/platform/sti/hva/hva-v4l2.c
@@ -1355,6 +1355,10 @@ static int hva_probe(struct platform_device *pdev)
goto err;
}
 
+   ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32));
+   if (ret)
+   return ret;
+
hva->dev = dev;
hva->pdev = pdev;
platform_set_drvdata(pdev, hva);
-- 
2.7.4



[PATCH 1/2] media: bdisp: don't use GFP_DMA

2018-05-15 Thread Fabien Dessenne
Set the DMA_MASK and stop using the GFP_DMA flag

Signed-off-by: Fabien Dessenne <fabien.desse...@st.com>
---
 drivers/media/platform/sti/bdisp/bdisp-hw.c   | 2 +-
 drivers/media/platform/sti/bdisp/bdisp-v4l2.c | 4 
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/sti/bdisp/bdisp-hw.c 
b/drivers/media/platform/sti/bdisp/bdisp-hw.c
index a5eb592..26d9fa7 100644
--- a/drivers/media/platform/sti/bdisp/bdisp-hw.c
+++ b/drivers/media/platform/sti/bdisp/bdisp-hw.c
@@ -455,7 +455,7 @@ int bdisp_hw_alloc_nodes(struct bdisp_ctx *ctx)
 
/* Allocate all the nodes within a single memory page */
base = dma_alloc_attrs(dev, node_size * MAX_NB_NODE, ,
-  GFP_KERNEL | GFP_DMA, DMA_ATTR_WRITE_COMBINE);
+  GFP_KERNEL, DMA_ATTR_WRITE_COMBINE);
if (!base) {
dev_err(dev, "%s no mem\n", __func__);
return -ENOMEM;
diff --git a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c 
b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
index bf4ca16..66b6409 100644
--- a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
+++ b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
@@ -1297,6 +1297,10 @@ static int bdisp_probe(struct platform_device *pdev)
if (!bdisp)
return -ENOMEM;
 
+   ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32));
+   if (ret)
+   return ret;
+
bdisp->pdev = pdev;
bdisp->dev = dev;
platform_set_drvdata(pdev, bdisp);
-- 
2.7.4



Re: Are media drivers abusing of GFP_DMA? - was: Re: [LSF/MM TOPIC NOTES] x86 ZONE_DMA love

2018-05-15 Thread Fabien DESSENNE


On 14/05/18 12:39, Mauro Carvalho Chehab wrote:
> Em Mon, 14 May 2018 07:35:03 -0300
> Mauro Carvalho Chehab <mchehab+sams...@kernel.org> escreveu:
>
>> Hi Fabien,
>>
>> Em Mon, 14 May 2018 08:00:37 +
>> Fabien DESSENNE <fabien.desse...@st.com> escreveu:
>>
>>> On 07/05/18 17:19, Mauro Carvalho Chehab wrote:
>>>> Em Mon, 07 May 2018 16:26:08 +0300
>>>> Laurent Pinchart <laurent.pinch...@ideasonboard.com> escreveu:
>>>>   
>>>>> Hi Mauro,
>>>>>
>>>>> On Saturday, 5 May 2018 19:08:15 EEST Mauro Carvalho Chehab wrote:
>>>>>> There was a recent discussion about the use/abuse of GFP_DMA flag when
>>>>>> allocating memories at LSF/MM 2018 (see Luis notes enclosed).
>>>>>>
>>>>>> The idea seems to be to remove it, using CMA instead. Before doing that,
>>>>>> better to check if what we have on media is are valid use cases for it, 
>>>>>> or
>>>>>> if it is there just due to some misunderstanding (or because it was
>>>>>> copied from some other code).
>>>>>>
>>>>>> Hans de Goede sent us today a patch stopping abuse at gspca, and I'm
>>>>>> also posting today two other patches meant to stop abuse of it on USB
>>>>>> drivers. Still, there are 4 platform drivers using it:
>>>>>>
>>>>>>  $ git grep -l -E "GFP_DMA\\b" drivers/media/
>>>>>>  drivers/media/platform/omap3isp/ispstat.c
>>>>>>  drivers/media/platform/sti/bdisp/bdisp-hw.c
>>>>>>  drivers/media/platform/sti/hva/hva-mem.c
>>> Hi Mauro,
>>>
>>> The two STI drivers (bdisp-hw.c and hva-mem.c) are only expected to run
>>> on ARM platforms, not on x86.
>>> Since this thread deals with x86 & DMA trouble, I am not sure that we
>>> actually have a problem for the sti drivers.
>>>
>>> There are some other sti drivers that make use of this GFP_DMA flag
>>> (drivers/gpu/drm/sti/sti_*.c) and it does not seem to be a problem.
>>>
>>> Nevertheless I can see that the media sti drivers depend on COMPILE_TEST
>>> (which is not the case for the DRM ones).
>>> Would it be an acceptable solution to remove the COMPILE_TEST dependency?
>> This has nothing to do with either x86 or COMPILE_TEST. The thing is
>> that there's a plan for removing GFP_DMA from the Kernel[1], as it was
>> originally meant to be used only by old PCs, where the DMA controllers
>> used only  on the bottom 16 MB memory address (24 bits). IMHO, it is
>> very unlikely that any ARM SoC have such limitation.
>>
>> [1] https://lwn.net/Articles/753273/ (article will be freely available
>> on May, 17)
> Btw, you can also read about that at:
>   https://lwn.net/Articles/753274/
>
>> Anyway, before the removal of GFP_DMA happens, I'd like to better
>> understand why we're using it at media, and if we can, instead,
>> set the DMA bit mask, just like almost all other media drivers
>> that require to confine DMA into a certain range do. In the case
>> of ARM, this is what we currently have:
>>
>> drivers/media/platform/exynos-gsc/gsc-core.c:   
>> vb2_dma_contig_set_max_seg_size(dev, DMA_BIT_MASK(32));
>> drivers/media/platform/exynos4-is/fimc-core.c:  
>> vb2_dma_contig_set_max_seg_size(dev, DMA_BIT_MASK(32));
>> drivers/media/platform/exynos4-is/fimc-is.c:
>> vb2_dma_contig_set_max_seg_size(dev, DMA_BIT_MASK(32));
>> drivers/media/platform/exynos4-is/fimc-lite.c:  
>> vb2_dma_contig_set_max_seg_size(dev, DMA_BIT_MASK(32));
>> drivers/media/platform/mtk-mdp/mtk_mdp_core.c:  
>> vb2_dma_contig_set_max_seg_size(>dev, DMA_BIT_MASK(32));
>> drivers/media/platform/omap3isp/isp.c:  ret = 
>> dma_coerce_mask_and_coherent(isp->dev, DMA_BIT_MASK(32));
>> drivers/media/platform/s5p-g2d/g2d.c:   
>> vb2_dma_contig_set_max_seg_size(>dev, DMA_BIT_MASK(32));
>> drivers/media/platform/s5p-jpeg/jpeg-core.c:
>> vb2_dma_contig_set_max_seg_size(>dev, DMA_BIT_MASK(32));
>> drivers/media/platform/s5p-mfc/s5p_mfc.c:
>>DMA_BIT_MASK(32));
>> drivers/media/platform/s5p-mfc/s5p_mfc.c:
>>DMA_BIT_MASK(32));
>> drivers/media/platform/s5p-mfc/s5p_mfc.c:   
>> vb2_dma_contig_set_max_seg_size(dev, DMA_BIT_MASK(32));
>>

That's clearer now, thank you for the clarification
I am about to send patches for the sti drivers (set the DMA bit mask)

BR,
Fabien

>>> BR
>>>
>>> Fabien
>>>
>>>>>>  drivers/media/spi/cxd2880-spi.c
>>>>>>
>>>>>> Could you please check if GFP_DMA is really needed there, or if it is
>>>>>> just because of some cut-and-paste from some other place?
>>>>> I started looking at that for the omap3isp driver but Sakari beat me at
>>>>> submitting a patch. GFP_DMA isn't needed for omap3isp.
>>>>>   
>>>> Thank you both for looking into it.
>>>>
>>>> Regards,
>>>> Mauro
>>>>
>>>>
>>>>
>>>> Thanks,
>>>> Mauro
>>
>>
>> Thanks,
>> Mauro
>
>
> Thanks,
> Mauro


Re: Are media drivers abusing of GFP_DMA? - was: Re: [LSF/MM TOPIC NOTES] x86 ZONE_DMA love

2018-05-14 Thread Fabien DESSENNE


On 07/05/18 17:19, Mauro Carvalho Chehab wrote:
> Em Mon, 07 May 2018 16:26:08 +0300
> Laurent Pinchart  escreveu:
>
>> Hi Mauro,
>>
>> On Saturday, 5 May 2018 19:08:15 EEST Mauro Carvalho Chehab wrote:
>>> There was a recent discussion about the use/abuse of GFP_DMA flag when
>>> allocating memories at LSF/MM 2018 (see Luis notes enclosed).
>>>
>>> The idea seems to be to remove it, using CMA instead. Before doing that,
>>> better to check if what we have on media is are valid use cases for it, or
>>> if it is there just due to some misunderstanding (or because it was
>>> copied from some other code).
>>>
>>> Hans de Goede sent us today a patch stopping abuse at gspca, and I'm
>>> also posting today two other patches meant to stop abuse of it on USB
>>> drivers. Still, there are 4 platform drivers using it:
>>>
>>> $ git grep -l -E "GFP_DMA\\b" drivers/media/
>>> drivers/media/platform/omap3isp/ispstat.c
>>> drivers/media/platform/sti/bdisp/bdisp-hw.c
>>> drivers/media/platform/sti/hva/hva-mem.c

Hi Mauro,

The two STI drivers (bdisp-hw.c and hva-mem.c) are only expected to run 
on ARM platforms, not on x86.
Since this thread deals with x86 & DMA trouble, I am not sure that we 
actually have a problem for the sti drivers.

There are some other sti drivers that make use of this GFP_DMA flag 
(drivers/gpu/drm/sti/sti_*.c) and it does not seem to be a problem.

Nevertheless I can see that the media sti drivers depend on COMPILE_TEST 
(which is not the case for the DRM ones).
Would it be an acceptable solution to remove the COMPILE_TEST dependency?

BR

Fabien

>>> drivers/media/spi/cxd2880-spi.c
>>>
>>> Could you please check if GFP_DMA is really needed there, or if it is
>>> just because of some cut-and-paste from some other place?
>> I started looking at that for the omap3isp driver but Sakari beat me at
>> submitting a patch. GFP_DMA isn't needed for omap3isp.
>>
> Thank you both for looking into it.
>
> Regards,
> Mauro
>
>
>
> Thanks,
> Mauro


Re: [PATCH V3 1/2] bdisp: Fix a possible sleep-in-atomic bug in bdisp_hw_reset

2017-12-19 Thread Fabien DESSENNE
Hi,


It's almost good!

You have to fix these checkpatch Warning/Check:

WARNING: Block comments use a trailing */ on a separate line
#36: FILE: drivers/media/platform/sti/bdisp/bdisp-hw.c:383:
+     * needing any delays */

CHECK: Alignment should match open parenthesis
#38: FILE: drivers/media/platform/sti/bdisp/bdisp-hw.c:385:
+    if (readl_poll_timeout_atomic(bdisp->regs + BLT_STA1, tmp,
+        (tmp & BLT_STA1_IDLE), POLL_RST_DELAY_MS,


 From kernel documentation in the "Posting patches" chapter:

"You should always run patches through scripts/checkpatch.pl and address 
the complaints it comes up with."

And, please use the --strict option

Thanks for your understanding.

BR

Fabien

On 19/12/17 14:57, Jia-Ju Bai wrote:
> The driver may sleep under a spinlock.
> The function call path is:
> bdisp_device_run (acquire the spinlock)
>bdisp_hw_reset
>  msleep --> may sleep
>
> To fix it, readl_poll_timeout_atomic is used to replace msleep.
>
> This bug is found by my static analysis tool(DSAC) and
> checked by my code review.
>
> Signed-off-by: Jia-Ju Bai 
> ---
>   drivers/media/platform/sti/bdisp/bdisp-hw.c |   23 ---
>   1 file changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/media/platform/sti/bdisp/bdisp-hw.c 
> b/drivers/media/platform/sti/bdisp/bdisp-hw.c
> index b7892f3..b63d9c9 100644
> --- a/drivers/media/platform/sti/bdisp/bdisp-hw.c
> +++ b/drivers/media/platform/sti/bdisp/bdisp-hw.c
> @@ -4,7 +4,7 @@
>* License terms:  GNU General Public License (GPL), version 2
>*/
>   
> -#include 
> +#include 
>   
>   #include "bdisp.h"
>   #include "bdisp-filter.h"
> @@ -15,7 +15,7 @@
>   
>   /* Reset & boot poll config */
>   #define POLL_RST_MAX50
> -#define POLL_RST_DELAY_MS   20
> +#define POLL_RST_DELAY_US   2
>   
>   enum bdisp_target_plan {
>   BDISP_RGB,
> @@ -366,7 +366,7 @@ struct bdisp_filter_addr {
>*/
>   int bdisp_hw_reset(struct bdisp_dev *bdisp)
>   {
> - unsigned int i;
> + u32 tmp;
>   
>   dev_dbg(bdisp->dev, "%s\n", __func__);
>   
> @@ -378,16 +378,17 @@ int bdisp_hw_reset(struct bdisp_dev *bdisp)
>  bdisp->regs + BLT_CTL);
>   writel(0, bdisp->regs + BLT_CTL);
>   
> - /* Wait for reset done */
> - for (i = 0; i < POLL_RST_MAX; i++) {
> - if (readl(bdisp->regs + BLT_STA1) & BLT_STA1_IDLE)
> - break;
> - msleep(POLL_RST_DELAY_MS);
> - }
> - if (i == POLL_RST_MAX)
> + /* Wait for reset done.
> +  * Despite the large timeout, most of the time the reset happens without
> +  * needing any delays */

shall be

+* needing any delays

+*/

> + if (readl_poll_timeout_atomic(bdisp->regs + BLT_STA1, tmp,
> + (tmp & BLT_STA1_IDLE), POLL_RST_DELAY_US,
> + POLL_RST_DELAY_US * POLL_RST_MAX)) {

shall be:

+   if (readl_poll_timeout_atomic(bdisp->regs + BLT_STA1, tmp,
+ tmp & BLT_STA1_IDLE, POLL_RST_DELAY_US,
+ POLL_RST_DELAY_US * POLL_RST_MAX)) {

>   dev_err(bdisp->dev, "Reset timeout\n");
> + return -EAGAIN;
> + }
>   
> - return (i == POLL_RST_MAX) ? -EAGAIN : 0;
> + return 0;
>   }
>   
>   /**


Re: [PATCH V2 1/2] bdisp: Fix a possible sleep-in-atomic bug in bdisp_hw_reset

2017-12-19 Thread Fabien DESSENNE
Hi,


On 16/12/17 12:54, Jia-Ju Bai wrote:
> The driver may sleep under a spinlock.
> The function call path is:
> bdisp_device_run (acquire the spinlock)
>bdisp_hw_reset
>  msleep --> may sleep
>
> To fix it, readl_poll_timeout_atomic is used to replace msleep.
>
> This bug is found by my static analysis tool(DSAC) and
> checked by my code review.
>
> Signed-off-by: Jia-Ju Bai 
> ---
>   drivers/media/platform/sti/bdisp/bdisp-hw.c |   16 
>   1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/media/platform/sti/bdisp/bdisp-hw.c 
> b/drivers/media/platform/sti/bdisp/bdisp-hw.c
> index b7892f3..e94a371 100644
> --- a/drivers/media/platform/sti/bdisp/bdisp-hw.c
> +++ b/drivers/media/platform/sti/bdisp/bdisp-hw.c
> @@ -5,6 +5,7 @@
>*/
>   
>   #include 

This delay.h include is no more needed, remove it.

> +#include 
>   
>   #include "bdisp.h"
>   #include "bdisp-filter.h"
> @@ -366,7 +367,7 @@ struct bdisp_filter_addr {
>*/
>   int bdisp_hw_reset(struct bdisp_dev *bdisp)
>   {
> - unsigned int i;
> + u32 tmp;
>   
>   dev_dbg(bdisp->dev, "%s\n", __func__);
>   
> @@ -379,15 +380,14 @@ int bdisp_hw_reset(struct bdisp_dev *bdisp)
>   writel(0, bdisp->regs + BLT_CTL);
>   
>   /* Wait for reset done */
> - for (i = 0; i < POLL_RST_MAX; i++) {
> - if (readl(bdisp->regs + BLT_STA1) & BLT_STA1_IDLE)
> - break;
> - msleep(POLL_RST_DELAY_MS);
> - }
> - if (i == POLL_RST_MAX)

As recommended by Mauro, please add this comment:
Despite the large timeout, most of the time the reset happens without 
needing any delays

> + if (readl_poll_timeout_atomic(bdisp->regs + BLT_STA1, tmp,
> + (tmp & BLT_STA1_IDLE), POLL_RST_DELAY_MS,
> + POLL_RST_DELAY_MS * POLL_RST_MAX)) {

read_poll_timeout expects US timings, not MS.

>   dev_err(bdisp->dev, "Reset timeout\n");
> + return -EAGAIN;
> + }
>   
> - return (i == POLL_RST_MAX) ? -EAGAIN : 0;
> + return 0;
>   }
>   
>   /**


Re: [PATCH 1/2] bdisp: Fix a possible sleep-in-atomic bug in bdisp_hw_reset

2017-12-19 Thread Fabien DESSENNE


On 16/12/17 15:14, Mauro Carvalho Chehab wrote:
> Em Sat, 16 Dec 2017 19:53:55 +0800
> Jia-Ju Bai <baijiaju1...@gmail.com> escreveu:
>
>> Hi,
>>
>> On 2017/12/15 22:51, Fabien DESSENNE wrote:
>>> Hi
>>>
>>> On 12/12/17 14:47, Jia-Ju Bai wrote:
>>>> The driver may sleep under a spinlock.
>>>> The function call path is:
>>>> bdisp_device_run (acquire the spinlock)
>>>>  bdisp_hw_reset
>>>>msleep --> may sleep
>>>>
>>>> To fix it, msleep is replaced with mdelay.
>>> May I suggest you to use readl_poll_timeout_atomic (instead of the whole
>>> "for" block): this fixes the problem and simplifies the code?
>> Okay, I have submitted a patch according to your advice.
>> You can have a look :)
> This can still be usind mdelay() to wait for a long time.
>
> It doesn't seem wise to do that, as it could cause system
> contention. Couldn't this be reworked in a way to avoid
> having the spin locked while sleeping?
>
> Once we had a similar issue on Siano, and it was solved by this
>
> commit 3cdadc50bbe8f04c1231c8af614cafd7ddd622bf
> Author: Richard Zidlicky <r...@linux-m68k.org>
> Date:   Tue Aug 24 09:52:36 2010 -0300
>
>  V4L/DVB: dvb: fix smscore_getbuffer() logic
>  
>  Drivers shouldn't sleep while holding a spinlock. A previous workaround
>  were to release the spinlock before callinc schedule().
>  
>  This patch uses a different approach: it just waits for the
>  siano hardware to answer.
>  
>  Signed-off-by: Richard Zidlicky <r...@linux-m68k.org>
>  Cc: sta...@kernel.org
>  Signed-off-by: Mauro Carvalho Chehab <mche...@redhat.com>
>
> The code as changed to use wait_event() at the kthread that was
> waiting for data to arrive. Only when the data is ready, the
> code with the spin lock is called.
>
> It made the driver a way more stable, and didn't add any penalties
> of needing to do long delays on a non-interruptible code.
>
> Thanks,
> Mauro
I have checked what was done there but I cannot see a simple way to do 
the same in bdisp where the context is a bit different (the lock is 
taken out in the central device_run, not locally in hw_reset) without 
taking the risk to have unexpected side effects

Moreover, the bdisp_hw_reset() function called from bdisp_device_run is 
not expected to last for a long time. The "one second" delay we are 
talking about is a very large timeout protection. From my past 
observations, the reset is applied instantly and we even never reach the 
msleep() call (not saying it never happens).

For those two reasons, using readl_poll_timeout_atomic() seems to be the 
best option.
BR

Fabien




Re: [PATCH 2/2] bdisp: Fix a possible sleep-in-atomic bug in bdisp_hw_save_request

2017-12-15 Thread Fabien DESSENNE
Hi


Thank you for the patch.


On 12/12/17 14:47, Jia-Ju Bai wrote:
> The driver may sleep under a spinlock.
> The function call path is:
> bdisp_device_run (acquire the spinlock)
>bdisp_hw_update
>  bdisp_hw_save_request
>devm_kzalloc(GFP_KERNEL) --> may sleep
>
> To fix it, GFP_KERNEL is replaced with GFP_ATOMIC.
>
> This bug is found by my static analysis tool(DSAC) and checked by my code 
> review.
>
> Signed-off-by: Jia-Ju Bai <baijiaju1...@gmail.com>
Reviewed-by: Fabien Dessenne <fabien.desse...@st.com>
> ---
>   drivers/media/platform/sti/bdisp/bdisp-hw.c |2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/sti/bdisp/bdisp-hw.c 
> b/drivers/media/platform/sti/bdisp/bdisp-hw.c
> index 4b62ceb..7b45b43 100644
> --- a/drivers/media/platform/sti/bdisp/bdisp-hw.c
> +++ b/drivers/media/platform/sti/bdisp/bdisp-hw.c
> @@ -1064,7 +1064,7 @@ static void bdisp_hw_save_request(struct bdisp_ctx *ctx)
>   if (!copy_node[i]) {
>   copy_node[i] = devm_kzalloc(ctx->bdisp_dev->dev,
>   sizeof(*copy_node[i]),
> - GFP_KERNEL);
> + GFP_ATOMIC);
>   if (!copy_node[i])
>   return;
>   }


Re: [PATCH 1/2] bdisp: Fix a possible sleep-in-atomic bug in bdisp_hw_reset

2017-12-15 Thread Fabien DESSENNE
Hi

On 12/12/17 14:47, Jia-Ju Bai wrote:
> The driver may sleep under a spinlock.
> The function call path is:
> bdisp_device_run (acquire the spinlock)
>bdisp_hw_reset
>  msleep --> may sleep
>
> To fix it, msleep is replaced with mdelay.

May I suggest you to use readl_poll_timeout_atomic (instead of the whole 
"for" block): this fixes the problem and simplifies the code?

>
> This bug is found by my static analysis tool(DSAC) and checked by my code 
> review.
>
> Signed-off-by: Jia-Ju Bai 
> ---
>   drivers/media/platform/sti/bdisp/bdisp-hw.c |2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/sti/bdisp/bdisp-hw.c 
> b/drivers/media/platform/sti/bdisp/bdisp-hw.c
> index b7892f3..4b62ceb 100644
> --- a/drivers/media/platform/sti/bdisp/bdisp-hw.c
> +++ b/drivers/media/platform/sti/bdisp/bdisp-hw.c
> @@ -382,7 +382,7 @@ int bdisp_hw_reset(struct bdisp_dev *bdisp)
>   for (i = 0; i < POLL_RST_MAX; i++) {
>   if (readl(bdisp->regs + BLT_STA1) & BLT_STA1_IDLE)
>   break;
> - msleep(POLL_RST_DELAY_MS);
> + mdelay(POLL_RST_DELAY_MS);
>   }
>   if (i == POLL_RST_MAX)
>   dev_err(bdisp->dev, "Reset timeout\n");


Re: [PATCH] media: platform: sti: Adopt SPDX identifier

2017-12-06 Thread Fabien DESSENNE


On 05/12/17 15:52, Benjamin Gaignard wrote:
> Add SPDX identifiers to files under sti directory
>
> Signed-off-by: Benjamin Gaignard <benjamin.gaign...@st.com>

For the bdisp part:
Reviewed-by: Fabien Dessenne <fabien.desse...@st.com>
> ---
>   drivers/media/platform/sti/bdisp/bdisp-debug.c   |  2 +-
>   drivers/media/platform/sti/bdisp/bdisp-filter.h  |  2 +-
>   drivers/media/platform/sti/bdisp/bdisp-hw.c  |  2 +-
>   drivers/media/platform/sti/bdisp/bdisp-reg.h |  2 +-
>   drivers/media/platform/sti/bdisp/bdisp-v4l2.c|  2 +-
>   drivers/media/platform/sti/bdisp/bdisp.h |  2 +-
>   drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c  |  5 +
>   drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.h  |  5 +
>   drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c|  5 +
>   drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.h|  5 +
>   drivers/media/platform/sti/c8sectpfe/c8sectpfe-debugfs.c |  9 +
>   drivers/media/platform/sti/c8sectpfe/c8sectpfe-debugfs.h |  9 +
>   drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c | 11 +--
>   drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.h |  5 +
>   drivers/media/platform/sti/cec/stih-cec.c|  5 +
>   drivers/media/platform/sti/delta/delta-cfg.h |  2 +-
>   drivers/media/platform/sti/delta/delta-debug.c   |  2 +-
>   drivers/media/platform/sti/delta/delta-debug.h   |  2 +-
>   drivers/media/platform/sti/delta/delta-ipc.c |  2 +-
>   drivers/media/platform/sti/delta/delta-ipc.h |  2 +-
>   drivers/media/platform/sti/delta/delta-mem.c |  2 +-
>   drivers/media/platform/sti/delta/delta-mem.h |  2 +-
>   drivers/media/platform/sti/delta/delta-mjpeg-dec.c   |  2 +-
>   drivers/media/platform/sti/delta/delta-mjpeg-fw.h|  2 +-
>   drivers/media/platform/sti/delta/delta-mjpeg-hdr.c   |  2 +-
>   drivers/media/platform/sti/delta/delta-mjpeg.h   |  2 +-
>   drivers/media/platform/sti/delta/delta-v4l2.c|  2 +-
>   drivers/media/platform/sti/delta/delta.h |  2 +-
>   drivers/media/platform/sti/hva/hva-debugfs.c |  2 +-
>   drivers/media/platform/sti/hva/hva-h264.c|  2 +-
>   drivers/media/platform/sti/hva/hva-hw.c  |  2 +-
>   drivers/media/platform/sti/hva/hva-hw.h  |  2 +-
>   drivers/media/platform/sti/hva/hva-mem.c |  2 +-
>   drivers/media/platform/sti/hva/hva-mem.h |  2 +-
>   drivers/media/platform/sti/hva/hva-v4l2.c|  2 +-
>   drivers/media/platform/sti/hva/hva.h |  2 +-
>   36 files changed, 36 insertions(+), 77 deletions(-)
>
> diff --git a/drivers/media/platform/sti/bdisp/bdisp-debug.c 
> b/drivers/media/platform/sti/bdisp/bdisp-debug.c
> index 2cc289e4dea1..c6a4e2de5c0c 100644
> --- a/drivers/media/platform/sti/bdisp/bdisp-debug.c
> +++ b/drivers/media/platform/sti/bdisp/bdisp-debug.c
> @@ -1,7 +1,7 @@
> +// SPDX-License-Identifier: GPL-2.0
>   /*
>* Copyright (C) STMicroelectronics SA 2014
>* Authors: Fabien Dessenne <fabien.desse...@st.com> for STMicroelectronics.
> - * License terms:  GNU General Public License (GPL), version 2
>*/
>   
>   #include 
> diff --git a/drivers/media/platform/sti/bdisp/bdisp-filter.h 
> b/drivers/media/platform/sti/bdisp/bdisp-filter.h
> index 53e52fb4127f..d25adb57e3d0 100644
> --- a/drivers/media/platform/sti/bdisp/bdisp-filter.h
> +++ b/drivers/media/platform/sti/bdisp/bdisp-filter.h
> @@ -1,7 +1,7 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
>   /*
>* Copyright (C) STMicroelectronics SA 2014
>* Authors: Fabien Dessenne <fabien.desse...@st.com> for STMicroelectronics.
> - * License terms:  GNU General Public License (GPL), version 2
>*/
>   
>   #define BDISP_HF_NB 64
> diff --git a/drivers/media/platform/sti/bdisp/bdisp-hw.c 
> b/drivers/media/platform/sti/bdisp/bdisp-hw.c
> index b7892f3efd98..e7836b307d21 100644
> --- a/drivers/media/platform/sti/bdisp/bdisp-hw.c
> +++ b/drivers/media/platform/sti/bdisp/bdisp-hw.c
> @@ -1,7 +1,7 @@
> +// SPDX-License-Identifier: GPL-2.0
>   /*
>* Copyright (C) STMicroelectronics SA 2014
>* Authors: Fabien Dessenne <fabien.desse...@st.com> for STMicroelectronics.
> - * License terms:  GNU General Public License (GPL), version 2
>*/
>   
>   #include 
> diff --git a/drivers/media/platform/sti/bdisp/bdisp-reg.h 
> b/drivers/media/platform/sti/bdisp/bdisp-reg.h
> index e7e1a425f65a..b07ecc903707 100644
> --- a/drivers/media/platform/sti/bdisp/bdisp-r

Re: [PATCH][V2] bdisp: remove redundant assignment to pix

2017-11-06 Thread Fabien DESSENNE
Hi Colin

Thank you for the patch.


On 29/10/17 14:43, Colin King wrote:
> From: Colin Ian King <colin.k...@canonical.com>
>
> Pointer pix is being initialized to a value and a little later
> being assigned the same value again. Remove the initial assignment to
> avoid a duplicate assignment. Cleans up the clang warning:
>
> drivers/media/platform/sti/bdisp/bdisp-v4l2.c:726:26: warning: Value
> stored to 'pix' during its initialization is never read
>
> Signed-off-by: Colin Ian King <colin.k...@canonical.com>
Reviewed-by: Fabien Dessenne <fabien.desse...@st.com>
> ---
>   drivers/media/platform/sti/bdisp/bdisp-v4l2.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c 
> b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
> index 939da6da7644..7e9ed9c7b3e1 100644
> --- a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
> +++ b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
> @@ -723,7 +723,7 @@ static int bdisp_enum_fmt(struct file *file, void *fh, 
> struct v4l2_fmtdesc *f)
>   static int bdisp_g_fmt(struct file *file, void *fh, struct v4l2_format *f)
>   {
>   struct bdisp_ctx *ctx = fh_to_ctx(fh);
> - struct v4l2_pix_format *pix = >fmt.pix;
> + struct v4l2_pix_format *pix;
>   struct bdisp_frame *frame  = ctx_get_frame(ctx, f->type);
>   
>   if (IS_ERR(frame)) {


Re: [PATCH v4 1/4] [media] exynos-gsc: Use 576p instead 720p as a threshold for colorspaces

2017-02-14 Thread Fabien DESSENNE
Hi Thibault


On 13/02/17 20:08, Thibault Saunier wrote:
> From: Javier Martinez Canillas 
>
> The media documentation says that the V4L2_COLORSPACE_SMPTE170M colorspace
> should be used for SDTV and V4L2_COLORSPACE_REC709 for HDTV. But drivers
> don't agree on the display resolution that should be used as a threshold.
>
>  From EIA CEA 861B about colorimetry for various resolutions:
>
>- 5.1 480p, 480i, 576p, 576i, 240p, and 288p
>  The color space used by the 480-line, 576-line, 240-line, and 288-line
>  formats will likely be based on SMPTE 170M [1].
>- 5.2 1080i, 1080p, and 720p
>  The color space used by the high definition formats will likely be
>  based on ITU-R BT.709-4
>
> This indicates that in the case that userspace does not specify what
> colorspace should be used, we should use 576p  as a threshold to set
> V4L2_COLORSPACE_REC709 instead of V4L2_COLORSPACE_REC709. Even if it is

typo -> "V4L2_COLORSPACE_REC709 instead of V4L2_COLORSPACE_SMPTE170M"


> only 'likely' and not a requirement it is the best guess we can make.
>
> The stream should have been encoded with the information and userspace
> has to pass it to the driver if it is not the case, otherwise we won't be
> able to handle it properly anyhow.
>
> Also, check for the resolution in G_FMT instead unconditionally setting
> the V4L2_COLORSPACE_REC709 colorspace.
>
> Signed-off-by: Javier Martinez Canillas 
> Signed-off-by: Thibault Saunier 
> Reviewed-by: Andrzej Hajda 
>
> ---
>
> Changes in v4:
> - Reword commit message to better back our assumptions on specifications
>
> Changes in v3:
> - Do not check values in the g_fmt functions as Andrzej explained in previous 
> review
> - Added 'Reviewed-by: Andrzej Hajda '
>
> Changes in v2: None
>
>   drivers/media/platform/exynos-gsc/gsc-core.c | 8 ++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c 
> b/drivers/media/platform/exynos-gsc/gsc-core.c
> index 59a634201830..db7d9883861b 100644
> --- a/drivers/media/platform/exynos-gsc/gsc-core.c
> +++ b/drivers/media/platform/exynos-gsc/gsc-core.c
> @@ -472,7 +472,7 @@ int gsc_try_fmt_mplane(struct gsc_ctx *ctx, struct 
> v4l2_format *f)
>   
>   pix_mp->num_planes = fmt->num_planes;
>   
> - if (pix_mp->width >= 1280) /* HD */
> + if (pix_mp->width > 720 && pix_mp->height > 576) /* HD */
>   pix_mp->colorspace = V4L2_COLORSPACE_REC709;
>   else /* SD */
>   pix_mp->colorspace = V4L2_COLORSPACE_SMPTE170M;
> @@ -519,9 +519,13 @@ int gsc_g_fmt_mplane(struct gsc_ctx *ctx, struct 
> v4l2_format *f)
>   pix_mp->height  = frame->f_height;
>   pix_mp->field   = V4L2_FIELD_NONE;
>   pix_mp->pixelformat = frame->fmt->pixelformat;
> - pix_mp->colorspace  = V4L2_COLORSPACE_REC709;
>   pix_mp->num_planes  = frame->fmt->num_planes;
>   
> + if (pix_mp->width > 720 && pix_mp->height > 576) /* HD */
> + pix_mp->colorspace = V4L2_COLORSPACE_REC709;
> + else /* SD */
> + pix_mp->colorspace = V4L2_COLORSPACE_SMPTE170M;
> +
>   for (i = 0; i < pix_mp->num_planes; ++i) {
>   pix_mp->plane_fmt[i].bytesperline = (frame->f_width *
>   frame->fmt->depth[i]) / 8;

BR
Fabien


Re: [PATCH] bdisp: Clean up file handle in open() error path.

2016-12-02 Thread Fabien DESSENNE
Hi Shailendra,
Thank you for the patch, it's good for me.


On 12/02/2016 05:48 AM, Shailendra Verma wrote:
> The File handle is not yet added in the vdev list.So no need to call
> v4l2_fh_del(>fh)if it fails to create control.
>
> Signed-off-by: Shailendra Verma <shailendr...@samsung.com>

Reviewed-by: Fabien Dessenne <fabien.desse...@st.com>

> ---
>   drivers/media/platform/sti/bdisp/bdisp-v4l2.c |2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c 
> b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
> index 45f82b5..fbf302f 100644
> --- a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
> +++ b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
> @@ -632,8 +632,8 @@ static int bdisp_open(struct file *file)
>   
>   error_ctrls:
>   bdisp_ctrls_delete(ctx);
> -error_fh:
>   v4l2_fh_del(>fh);
> +error_fh:
>   v4l2_fh_exit(>fh);
>   bdisp_hw_free_nodes(ctx);
>   mem_ctx:
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Platform: Sti: Bdisp: Clean up file handle in open() error path.

2016-12-01 Thread Fabien DESSENNE
Hi Shailendra


Thank you for the patch.


Could you please update the subject line (try to have it as short as 
possible):

- there is no need for the 'platform' keyword. This remark applies to 
your other patches.

- write all keywords in lower case (Bdisp -> bdisp). This remark applies 
also to your other patches.

- "sti" is not needed too

-> "bdisp: Clean up file handle in open() error path."

Sorry to bother you with such details, but I am sure this will not 
require a huge rework from you ;)


Fabien


On 12/01/2016 05:47 AM, Shailendra Verma wrote:
> The File handle is not yet added in the vdev list.So no need to call
> v4l2_fh_del(>fh)if it fails to create control.
>
> Signed-off-by: Shailendra Verma 
> ---
>   drivers/media/platform/sti/bdisp/bdisp-v4l2.c |2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c 
> b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
> index 45f82b5..fbf302f 100644
> --- a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
> +++ b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
> @@ -632,8 +632,8 @@ static int bdisp_open(struct file *file)
>   
>   error_ctrls:
>   bdisp_ctrls_delete(ctx);
> -error_fh:
>   v4l2_fh_del(>fh);
> +error_fh:
>   v4l2_fh_exit(>fh);
>   bdisp_hw_free_nodes(ctx);
>   mem_ctx:
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: YUV444 contradicting wikipedia

2016-11-02 Thread Fabien DESSENNE
Hi


"4:x:y" refers to chroma subsampling, details here: 
https://en.wikipedia.org/wiki/Chroma_subsampling. With "YUV 4:4:4" each 
pixel has 1 Luma information and 1 Chroma information: 1 Y + 1 Cb + 1 Cr 
= 24 bits per pixel.


In top of that, each of the three components (Y, Cb, Cr) can be stored 
in a single memory plane (packed format), just like usual RGB formats 
are. Or components can be stored in 2 (Y + Cb-Cr) or 3 (Y + Cb + Cr) 
memory planes.


The combination of the chroma subsampling and the number of planes, 
defines a pixel format. The problem is that each sub-system (DRM, V4L2, 
GStreamer, ...) uses its own constants with unfortunately unconsistent 
names across them.


Let's consider the YUV 4:4:4 with three planes format:

DRM =DRM_FORMAT_YUV444

V4L2 =   V4L2_PIX_FMT_YUV444M

GStreamer = GST_VIDEO_FORMAT_Y444

As you can see, although all of them specify the same pixel format, the 
names are quite different.

And regarding V4L2_PIX_FMT_YUV444 (not ending with "M"), it defines 
another format with the following specifications:

- YUV packed

- 4:4:4 chroma sampling

- Alpha (when supported by driver)

- 4 (not 8) bits per component

Very different from the "standard" YUV 4:4:4 pixel format.

I agree that its name is confusing, but since it is part of the API, we 
shall consider that it won't be updated.

 From what I have seen, DRM (maybe because it is a relatively recent 
'framework') has a clear definition of the pixel formats.


Fabien


On 10/27/2016 08:16 AM, Guennadi Liakhovetski wrote:
> Hi,
>
> Looks like the Linux definition of the (packed) YUV444 format contradicts
> wikipedia. According to
> https://linuxtv.org/downloads/v4l-dvb-apis-new/uapi/v4l/pixfmt-packed-yuv.html
> The Linux V4L2_PIX_FMT_YUV444 format takes 16 bits per pixel, whereas the
> wikipedia
> https://en.wikipedia.org/wiki/YUV#Converting_between_Y.E2.80.B2UV_and_RGB
> says it's 24 bits per pixel. I understand that the wikipedia doesn't have
> an absolute authority, but I also saw other sources using the same
> definition. So, looks like some confusion is possible.
>
> Thanks
> Guennadi
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH -next] [media] bdisp: fix error return code in bdisp_probe()

2016-09-22 Thread Fabien DESSENNE
Hi Wei,


Thank you for the patch.


On 09/21/2016 05:09 PM, Wei Yongjun wrote:
> From: Wei Yongjun <weiyongj...@huawei.com>
>
> Fix to return error code -EINVAL from the platform_get_resource() error
> handling case instead of 0, as done elsewhere in this function.
>
> Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>

Reviewed-by: Fabien Dessenne <fabien.desse...@st.com>

> ---
>   drivers/media/platform/sti/bdisp/bdisp-v4l2.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c 
> b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
> index 45f82b5..8236081 100644
> --- a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
> +++ b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
> @@ -1337,6 +1337,7 @@ static int bdisp_probe(struct platform_device *pdev)
>   res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
>   if (!res) {
>   dev_err(dev, "failed to get IRQ resource\n");
> + ret = -EINVAL;
>   goto err_clk;
>   }
>
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] [media] platform: constify vb2_ops structures

2016-09-09 Thread Fabien DESSENNE
Hi


On 09/09/2016 01:59 AM, Julia Lawall wrote:
> Check for vb2_ops structures that are only stored in the ops field of a
> vb2_queue structure.  That field is declared const, so vb2_ops structures
> that have this property can be declared as const also.
>
> The semantic patch that makes this change is as follows:
> (http://coccinelle.lip6.fr/)
>
> // 
> @r disable optional_qualifier@
> identifier i;
> position p;
> @@
> static struct vb2_ops i@p = { ... };
>
> @ok@
> identifier r.i;
> struct vb2_queue e;
> position p;
> @@
> e.ops = @p;
>
> @bad@
> position p != {r.p,ok.p};
> identifier r.i;
> struct vb2_ops e;
> @@
> e@i@p
>
> @depends on !bad disable optional_qualifier@
> identifier r.i;
> @@
> static
> +const
>   struct vb2_ops i = { ... };
> // 
>
> Signed-off-by: Julia Lawall <julia.law...@lip6.fr>
>
> ---
>   drivers/media/platform/exynos-gsc/gsc-m2m.c  |2 +-
>   drivers/media/platform/exynos4-is/fimc-capture.c |2 +-
>   drivers/media/platform/exynos4-is/fimc-m2m.c |2 +-
>   drivers/media/platform/m2m-deinterlace.c |2 +-
>   drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c   |2 +-
>   drivers/media/platform/mx2_emmaprp.c |2 +-
>   drivers/media/platform/rcar-vin/rcar-dma.c   |2 +-
>   drivers/media/platform/rcar_jpu.c|2 +-
>   drivers/media/platform/s5p-g2d/g2d.c |2 +-
>   drivers/media/platform/s5p-jpeg/jpeg-core.c  |2 +-
>   drivers/media/platform/sh_vou.c  |2 +-
>   drivers/media/platform/soc_camera/atmel-isi.c|2 +-
>   drivers/media/platform/soc_camera/rcar_vin.c |2 +-
>   drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c |2 +-

For this driver:
>   drivers/media/platform/sti/bdisp/bdisp-v4l2.c|2 +-
Reviewed-by: Fabien Dessenne <fabien.desse...@st.com>

>   drivers/media/platform/ti-vpe/cal.c  |2 +-
>   drivers/media/platform/ti-vpe/vpe.c  |2 +-
>   drivers/media/platform/vim2m.c   |2 +-
>   drivers/media/platform/xilinx/xilinx-dma.c   |2 +-
>   19 files changed, 19 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/media/platform/xilinx/xilinx-dma.c 
> b/drivers/media/platform/xilinx/xilinx-dma.c
> index 7ae1a13..1d5836c 100644
> --- a/drivers/media/platform/xilinx/xilinx-dma.c
> +++ b/drivers/media/platform/xilinx/xilinx-dma.c
> @@ -474,7 +474,7 @@ static void xvip_dma_stop_streaming(struct vb2_queue *vq)
>  spin_unlock_irq(>queued_lock);
>   }
>
> -static struct vb2_ops xvip_dma_queue_qops = {
> +static const struct vb2_ops xvip_dma_queue_qops = {
>  .queue_setup = xvip_dma_queue_setup,
>  .buf_prepare = xvip_dma_buffer_prepare,
>  .buf_queue = xvip_dma_buffer_queue,
> diff --git a/drivers/media/platform/soc_camera/atmel-isi.c 
> b/drivers/media/platform/soc_camera/atmel-isi.c
> index 30211f6..46de657 100644
> --- a/drivers/media/platform/soc_camera/atmel-isi.c
> +++ b/drivers/media/platform/soc_camera/atmel-isi.c
> @@ -536,7 +536,7 @@ static void stop_streaming(struct vb2_queue *vq)
>  pm_runtime_put(ici->v4l2_dev.dev);
>   }
>
> -static struct vb2_ops isi_video_qops = {
> +static const struct vb2_ops isi_video_qops = {
>  .queue_setup= queue_setup,
>  .buf_init   = buffer_init,
>  .buf_prepare= buffer_prepare,
> diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c 
> b/drivers/media/platform/s5p-jpeg/jpeg-core.c
> index 785e693..d9c07b8 100644
> --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
> +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
> @@ -2538,7 +2538,7 @@ static void s5p_jpeg_stop_streaming(struct vb2_queue *q)
>  pm_runtime_put(ctx->jpeg->dev);
>   }
>
> -static struct vb2_ops s5p_jpeg_qops = {
> +static const struct vb2_ops s5p_jpeg_qops = {
>  .queue_setup= s5p_jpeg_queue_setup,
>  .buf_prepare= s5p_jpeg_buf_prepare,
>  .buf_queue  = s5p_jpeg_buf_queue,
> diff --git a/drivers/media/platform/ti-vpe/cal.c 
> b/drivers/media/platform/ti-vpe/cal.c
> index e967fcf..44323cb 100644
> --- a/drivers/media/platform/ti-vpe/cal.c
> +++ b/drivers/media/platform/ti-vpe/cal.c
> @@ -1379,7 +1379,7 @@ static void cal_stop_streaming(struct vb2_queue *vq)
>  cal_runtime_put(ctx->dev);
>   }
>
> -static struct vb2_ops cal_video_qops = {
> +static const struct vb2_ops cal_video_qops = {
>   

Re: [PATCHv5 08/13] media/platform: convert drivers to use the new vb2_queue dev field

2016-06-27 Thread Fabien DESSENNE


On 06/27/2016 03:31 PM, Hans Verkuil wrote:
> From: Hans Verkuil <hans.verk...@cisco.com>
>
> Stop using alloc_ctx and just fill in the device pointer.
>
> Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
> Cc: Fabien Dessenne <fabien.desse...@st.com>
> Acked-by: Benoit Parrot <bpar...@ti.com>
> Reviewed-by: Laurent Pinchart <laurent.pinch...@ideasonboard.com>
> ---
>   drivers/media/platform/sti/bdisp/bdisp-v4l2.c | 18 --
>   drivers/media/platform/sti/bdisp/bdisp.h  |  2 --
>   drivers/media/platform/ti-vpe/cal.c   | 15 +--
>   drivers/media/platform/ti-vpe/vpe.c   | 20 
>   drivers/media/platform/vsp1/vsp1_video.c  | 14 ++
>   drivers/media/platform/vsp1/vsp1_video.h  |  1 -
>   drivers/media/platform/xilinx/xilinx-dma.c| 11 +--
>   drivers/media/platform/xilinx/xilinx-dma.h    |  2 --
>   8 files changed, 12 insertions(+), 71 deletions(-)

Acked-by: Fabien Dessenne<fabien.desse...@st.com>

>
> diff --git a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c 
> b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
> index d12a419..b3e8b5a 100644
> --- a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
> +++ b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
> @@ -439,7 +439,7 @@ static void bdisp_ctrls_delete(struct bdisp_ctx *ctx)
>
>   static int bdisp_queue_setup(struct vb2_queue *vq,
>   unsigned int *nb_buf, unsigned int *nb_planes,
> -unsigned int sizes[], void *allocators[])
> +unsigned int sizes[], void *alloc_ctxs[])
>   {
>  struct bdisp_ctx *ctx = vb2_get_drv_priv(vq);
>  struct bdisp_frame *frame = ctx_get_frame(ctx, vq->type);
> @@ -453,7 +453,6 @@ static int bdisp_queue_setup(struct vb2_queue *vq,
>  dev_err(ctx->bdisp_dev->dev, "Invalid format\n");
>  return -EINVAL;
>  }
> -   allocators[0] = ctx->bdisp_dev->alloc_ctx;
>
>  if (*nb_planes)
>  return sizes[0] < frame->sizeimage ? -EINVAL : 0;
> @@ -553,6 +552,7 @@ static int queue_init(void *priv,
>  src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
>  src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
>  src_vq->lock = >bdisp_dev->lock;
> +   src_vq->dev = ctx->bdisp_dev->v4l2_dev.dev;
>
>  ret = vb2_queue_init(src_vq);
>  if (ret)
> @@ -567,6 +567,7 @@ static int queue_init(void *priv,
>  dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
>  dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
>  dst_vq->lock = >bdisp_dev->lock;
> +   dst_vq->dev = ctx->bdisp_dev->v4l2_dev.dev;
>
>  return vb2_queue_init(dst_vq);
>   }
> @@ -1269,8 +1270,6 @@ static int bdisp_remove(struct platform_device *pdev)
>
>  bdisp_hw_free_filters(bdisp->dev);
>
> -   vb2_dma_contig_cleanup_ctx(bdisp->alloc_ctx);
> -
>  pm_runtime_disable(>dev);
>
>  bdisp_debugfs_remove(bdisp);
> @@ -1371,18 +1370,11 @@ static int bdisp_probe(struct platform_device *pdev)
>  goto err_dbg;
>  }
>
> -   /* Continuous memory allocator */
> -   bdisp->alloc_ctx = vb2_dma_contig_init_ctx(dev);
> -   if (IS_ERR(bdisp->alloc_ctx)) {
> -   ret = PTR_ERR(bdisp->alloc_ctx);
> -   goto err_pm;
> -   }
> -
>  /* Filters */
>  if (bdisp_hw_alloc_filters(bdisp->dev)) {
>  dev_err(bdisp->dev, "no memory for filters\n");
>  ret = -ENOMEM;
> -   goto err_vb2_dma;
> +   goto err_pm;
>  }
>
>  /* Register */
> @@ -1401,8 +1393,6 @@ static int bdisp_probe(struct platform_device *pdev)
>
>   err_filter:
>  bdisp_hw_free_filters(bdisp->dev);
> -err_vb2_dma:
> -   vb2_dma_contig_cleanup_ctx(bdisp->alloc_ctx);
>   err_pm:
>  pm_runtime_put(dev);
>   err_dbg:
> diff --git a/drivers/media/platform/sti/bdisp/bdisp.h 
> b/drivers/media/platform/sti/bdisp/bdisp.h
> index 0cf9857..b3fbf99 100644
> --- a/drivers/media/platform/sti/bdisp/bdisp.h
> +++ b/drivers/media/platform/sti/bdisp/bdisp.h
> @@ -175,7 +175,6 @@ struct bdisp_dbg {
>* @id: device index
>* @m2m:memory-to-memory V4L2 device information
>* @state:  flags used to synchronize m2m and capture mode operation
> - * @alloc_ctx:  videobuf2 memory allocator context
>* @clock:  IP clock
>* @re

Re: [PATCH 19/19] bdisp: move the V/H filter spec to bdisp-hw.c

2016-06-27 Thread Fabien DESSENNE


On 06/24/2016 05:32 PM, Mauro Carvalho Chehab wrote:
> Those structs are used only at bdisp-hw, so they shouldn't be
> there in a header file that it is used elsewhere.
>
> This fixes the following Gcc 6.1 warnings:
>
> In file included from drivers/media/platform/sti/bdisp/bdisp-debug.c:11:0:
> drivers/media/platform/sti/bdisp/bdisp-filter.h:207:65: warning: 
> ‘bdisp_v_spec’ defined but not used [-Wunused-const-variable=]
>   static const struct __maybe_unused bdisp_filter_v_spec bdisp_v_spec[] = {
>   ^
> In file included from drivers/media/platform/sti/bdisp/bdisp-debug.c:11:0:
> drivers/media/platform/sti/bdisp/bdisp-filter.h:23:65: warning: 
> ‘bdisp_h_spec’ defined but not used [-Wunused-const-variable=]
>   static const struct __maybe_unused bdisp_filter_h_spec bdisp_h_spec[] = {
>   ^
>
> Signed-off-by: Mauro Carvalho Chehab <mche...@s-opensource.com>

Acked-by: Fabien Dessenne <fabien.desse...@st.com>

> ---
>   drivers/media/platform/sti/bdisp/bdisp-filter.h | 304 
> ---
>   drivers/media/platform/sti/bdisp/bdisp-hw.c | 305 
> 
>   2 files changed, 305 insertions(+), 304 deletions(-)
>
> diff --git a/drivers/media/platform/sti/bdisp/bdisp-filter.h 
> b/drivers/media/platform/sti/bdisp/bdisp-filter.h
> index fc8c54f725ad..53e52fb4127f 100644
> --- a/drivers/media/platform/sti/bdisp/bdisp-filter.h
> +++ b/drivers/media/platform/sti/bdisp/bdisp-filter.h
> @@ -19,178 +19,6 @@ struct bdisp_filter_h_spec {
>  const u16 max;
>  const u8 coef[BDISP_HF_NB];
>   };
> -
> -static const struct bdisp_filter_h_spec bdisp_h_spec[] = {
> -   {
> -   .min = 0,
> -   .max = 921,
> -   .coef = {
> -   0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
> -   0x00, 0x00, 0xff, 0x07, 0x3d, 0xfc, 0x01, 0x00,
> -   0x00, 0x01, 0xfd, 0x11, 0x36, 0xf9, 0x02, 0x00,
> -   0x00, 0x01, 0xfb, 0x1b, 0x2e, 0xf9, 0x02, 0x00,
> -   0x00, 0x01, 0xf9, 0x26, 0x26, 0xf9, 0x01, 0x00,
> -   0x00, 0x02, 0xf9, 0x30, 0x19, 0xfb, 0x01, 0x00,
> -   0x00, 0x02, 0xf9, 0x39, 0x0e, 0xfd, 0x01, 0x00,
> -   0x00, 0x01, 0xfc, 0x3e, 0x06, 0xff, 0x00, 0x00
> -   }
> -   },
> -   {
> -   .min = 921,
> -   .max = 1024,
> -   .coef = {
> -   0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
> -   0xff, 0x03, 0xfd, 0x08, 0x3e, 0xf9, 0x04, 0xfe,
> -   0xfd, 0x06, 0xf8, 0x13, 0x3b, 0xf4, 0x07, 0xfc,
> -   0xfb, 0x08, 0xf5, 0x1f, 0x34, 0xf1, 0x09, 0xfb,
> -   0xfb, 0x09, 0xf2, 0x2b, 0x2a, 0xf1, 0x09, 0xfb,
> -   0xfb, 0x09, 0xf2, 0x35, 0x1e, 0xf4, 0x08, 0xfb,
> -   0xfc, 0x07, 0xf5, 0x3c, 0x12, 0xf7, 0x06, 0xfd,
> -   0xfe, 0x04, 0xfa, 0x3f, 0x07, 0xfc, 0x03, 0xff
> -   }
> -   },
> -   {
> -   .min = 1024,
> -   .max = 1126,
> -   .coef = {
> -   0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
> -   0xff, 0x03, 0xfd, 0x08, 0x3e, 0xf9, 0x04, 0xfe,
> -   0xfd, 0x06, 0xf8, 0x13, 0x3b, 0xf4, 0x07, 0xfc,
> -   0xfb, 0x08, 0xf5, 0x1f, 0x34, 0xf1, 0x09, 0xfb,
> -   0xfb, 0x09, 0xf2, 0x2b, 0x2a, 0xf1, 0x09, 0xfb,
> -   0xfb, 0x09, 0xf2, 0x35, 0x1e, 0xf4, 0x08, 0xfb,
> -   0xfc, 0x07, 0xf5, 0x3c, 0x12, 0xf7, 0x06, 0xfd,
> -   0xfe, 0x04, 0xfa, 0x3f, 0x07, 0xfc, 0x03, 0xff
> -   }
> -   },
> -   {
> -   .min = 1126,
> -   .max = 1228,
> -   .coef = {
> -   0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
> -   0xff, 0x03, 0xfd, 0x08, 0x3e, 0xf9, 0x04, 0xfe,
> -   0xfd, 0x06, 0xf8, 0x13, 0x3b, 0xf4, 0x07, 0xfc,
> -   0xfb, 0x08, 0xf5, 0x1f, 0x34, 0xf1, 0x09, 0xfb,
> -   0xfb, 0x09, 0xf2, 0x2b, 0x2a, 0xf1, 0x09, 0xfb,
> -   0xfb, 0x09, 0xf2, 0x35, 0x1e, 0xf4, 0x08, 0xfb,
> -   0xfc, 0x07, 0xf5, 0x3c, 0x12, 0xf7, 0x06, 0xfd,
> -   0xfe, 0x04, 0xfa, 0x3f, 0x07, 0xfc, 0x03, 0xff
> -   }
> -   },
> -   {
> -   .

Re: v4l2 kernel module debugging methods

2015-12-11 Thread Fabien DESSENNE
Hi Ran,

On 12/10/2015 10:46 PM, Ran Shalit wrote:
> On Sun, Dec 6, 2015 at 2:23 AM, Nicolas Dufresne
>  wrote:
>> Le dimanche 06 décembre 2015 à 00:00 +0200, Ran Shalit a écrit :
>>> Hello,
>>>
>>> I would like to ask a general question regarding methods to debug a
>>> v4l2 device driver.
>>> Since I assume that the kernel driver will probably won't work in
>>> first try after coding everything inside the device driver...
>>>
>>> 1. Do you think qemu/kgdb debugger is a good method for the device
>>> driver debugging , or is it plain printing ?
>>>
>>> 2. Is there a simple way to display the image of a YUV-like buffer in
>>> memory ?
>>
>> Most Linux distribution ships GStreamer. You can with GStreamer read
>> and display a raw YUV images (you need to know the specific format)
>> using videoparse element.
>>
>>gst-launch-1.0 filesrc location=my.yuv ! videoparse format=yuy2 width=320 
>> height=240 ! imagefreeze ! videoconvert ! autovideosink
>>
>> You could also encode and store to various formats, replacing the
>> imagefreeze ... section with an encoder and a filesink. Note that
>> videoparse unfortunatly does not allow passing strides array or
>> offsets. So it will work only if you set the width/height to padded
>> width/height.
>>
>> regards,
>> Nicolas
>
> Hi Nicolas,
>
> Thank you for the comment.
> As someone expreinced with v4l2 device driver, do you recommened using
> debugging technique such as qemu (or kgdb) or do you rather use plain
> printing ?
>
> Thank you very much,
> Ran


You can get several level of logs.
First, you can enable v4l2 core debug logs. Example:
  echo 3 > /sys/class/video4linux/video0/debug
More details: 
https://www.kernel.org/doc/Documentation/video4linux/v4l2-framework.txt

If the tested driver uses the v4l2_mem2mem framework you can get M2M 
logs with:
  echo Y > /sys/module/v4l2_mem2mem/parameters/debug

Get also internal vb2 logs with:
  echo 3 > /sys/module/videobuf2_core/parameters/debug

And optionally more logs using the dynamic debug feature: 
(https://www.kernel.org/doc/Documentation/dynamic-debug-howto.txt). Example:
  echo "module my_driver +p" > /sys/kernel/debug/dynamic_debug/control

FabienN�r��yb�X��ǧv�^�)޺{.n�+{���bj)w*jg����ݢj/���z�ޖ��2�ޙ&�)ߡ�a�����G���h��j:+v���w��٥

[PATCH] [media] bdisp: fix debug info memory access

2015-07-13 Thread Fabien Dessenne
bdisp_dev-dbg.copy_node shall be a copy of (and not point to)
bdisp_ctx-node, since this resource is freed upon driver release.

Signed-off-by: Fabien Dessenne fabien.desse...@st.com
---
 drivers/media/platform/sti/bdisp/bdisp-hw.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/sti/bdisp/bdisp-hw.c 
b/drivers/media/platform/sti/bdisp/bdisp-hw.c
index c83f9c2..052c932 100644
--- a/drivers/media/platform/sti/bdisp/bdisp-hw.c
+++ b/drivers/media/platform/sti/bdisp/bdisp-hw.c
@@ -768,12 +768,12 @@ static void bdisp_hw_save_request(struct bdisp_ctx *ctx)
/* Allocate memory if not done yet */
if (!copy_node[i]) {
copy_node[i] = devm_kzalloc(ctx-bdisp_dev-dev,
-   sizeof(*copy_node),
+   sizeof(*copy_node[i]),
GFP_KERNEL);
if (!copy_node[i])
return;
}
-   copy_node[i] = node[i];
+   *copy_node[i] = *node[i];
}
 }
 
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] [media] bdisp: composing support

2015-07-10 Thread Fabien Dessenne
Support the composing (at VIDEO_CAPTURE) with the _selection API.
v4l2-compliance successfully run (test Composing: OK)

Signed-off-by: Fabien Dessenne fabien.desse...@st.com
---
 drivers/media/platform/sti/bdisp/bdisp-hw.c   |  8 +--
 drivers/media/platform/sti/bdisp/bdisp-v4l2.c | 76 ++-
 2 files changed, 55 insertions(+), 29 deletions(-)

diff --git a/drivers/media/platform/sti/bdisp/bdisp-hw.c 
b/drivers/media/platform/sti/bdisp/bdisp-hw.c
index 465828e..c83f9c2 100644
--- a/drivers/media/platform/sti/bdisp/bdisp-hw.c
+++ b/drivers/media/platform/sti/bdisp/bdisp-hw.c
@@ -336,8 +336,8 @@ static int bdisp_hw_get_hv_inc(struct bdisp_ctx *ctx, u16 
*h_inc, u16 *v_inc)
 
src_w = ctx-src.crop.width;
src_h = ctx-src.crop.height;
-   dst_w = ctx-dst.width;
-   dst_h = ctx-dst.height;
+   dst_w = ctx-dst.crop.width;
+   dst_h = ctx-dst.crop.height;
 
if (bdisp_hw_get_inc(src_w, dst_w, h_inc) ||
bdisp_hw_get_inc(src_h, dst_h, v_inc)) {
@@ -483,9 +483,9 @@ static void bdisp_hw_build_node(struct bdisp_ctx *ctx,
src_rect.width -= src_x_offset;
src_rect.width = min_t(__s32, MAX_SRC_WIDTH, src_rect.width);
 
-   dst_x_offset = (src_x_offset * dst-width) / ctx-src.crop.width;
+   dst_x_offset = (src_x_offset * dst_width) / ctx-src.crop.width;
dst_rect.left += dst_x_offset;
-   dst_rect.width = (src_rect.width * dst-width) / ctx-src.crop.width;
+   dst_rect.width = (src_rect.width * dst_width) / ctx-src.crop.width;
 
/* General */
src_fmt = src-fmt-pixelformat;
diff --git a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c 
b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
index 9e782eb..df61355 100644
--- a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
+++ b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
@@ -851,33 +851,56 @@ static int bdisp_g_selection(struct file *file, void *fh,
struct bdisp_frame *frame;
struct bdisp_ctx *ctx = fh_to_ctx(fh);
 
-   if (s-type != V4L2_BUF_TYPE_VIDEO_OUTPUT) {
-   /* Composing  / capture is not supported */
-   dev_dbg(ctx-bdisp_dev-dev, Not supported for capture\n);
-   return -EINVAL;
-   }
-
frame = ctx_get_frame(ctx, s-type);
if (IS_ERR(frame)) {
dev_err(ctx-bdisp_dev-dev, Invalid frame (%p)\n, frame);
return PTR_ERR(frame);
}
 
-   switch (s-target) {
-   case V4L2_SEL_TGT_CROP:
-   /* cropped frame */
-   s-r = frame-crop;
+   switch (s-type) {
+   case V4L2_BUF_TYPE_VIDEO_OUTPUT:
+   switch (s-target) {
+   case V4L2_SEL_TGT_CROP:
+   /* cropped frame */
+   s-r = frame-crop;
+   break;
+   case V4L2_SEL_TGT_CROP_DEFAULT:
+   case V4L2_SEL_TGT_CROP_BOUNDS:
+   /* complete frame */
+   s-r.left = 0;
+   s-r.top = 0;
+   s-r.width = frame-width;
+   s-r.height = frame-height;
+   break;
+   default:
+   dev_err(ctx-bdisp_dev-dev, Invalid target\n);
+   return -EINVAL;
+   }
break;
-   case V4L2_SEL_TGT_CROP_DEFAULT:
-   case V4L2_SEL_TGT_CROP_BOUNDS:
-   /* complete frame */
-   s-r.left = 0;
-   s-r.top = 0;
-   s-r.width = frame-width;
-   s-r.height = frame-height;
+
+   case V4L2_BUF_TYPE_VIDEO_CAPTURE:
+   switch (s-target) {
+   case V4L2_SEL_TGT_COMPOSE:
+   case V4L2_SEL_TGT_COMPOSE_PADDED:
+   /* composed (cropped) frame */
+   s-r = frame-crop;
+   break;
+   case V4L2_SEL_TGT_COMPOSE_DEFAULT:
+   case V4L2_SEL_TGT_COMPOSE_BOUNDS:
+   /* complete frame */
+   s-r.left = 0;
+   s-r.top = 0;
+   s-r.width = frame-width;
+   s-r.height = frame-height;
+   break;
+   default:
+   dev_err(ctx-bdisp_dev-dev, Invalid target\n);
+   return -EINVAL;
+   }
break;
+
default:
-   dev_dbg(ctx-bdisp_dev-dev, Invalid target\n);
+   dev_err(ctx-bdisp_dev-dev, Invalid type\n);
return -EINVAL;
}
 
@@ -906,15 +929,18 @@ static int bdisp_s_selection(struct file *file, void *fh,
struct bdisp_frame *frame;
struct bdisp_ctx *ctx = fh_to_ctx(fh);
struct v4l2_rect *in, out;
+   bool valid = false;
 
-   if (s-type != V4L2_BUF_TYPE_VIDEO_OUTPUT) {
-   /* Composing  / capture is not supported */
-   dev_dbg(ctx-bdisp_dev

[PATCH 2/2] [media] bdisp: add debug info for RGB24 format

2015-07-10 Thread Fabien Dessenne
Add this missing debug information

Signed-off-by: Fabien Dessenne fabien.desse...@st.com
---
 drivers/media/platform/sti/bdisp/bdisp-debug.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/media/platform/sti/bdisp/bdisp-debug.c 
b/drivers/media/platform/sti/bdisp/bdisp-debug.c
index 18282a0..79c5635 100644
--- a/drivers/media/platform/sti/bdisp/bdisp-debug.c
+++ b/drivers/media/platform/sti/bdisp/bdisp-debug.c
@@ -116,6 +116,9 @@ static void bdisp_dbg_dump_tty(struct seq_file *s, u32 val)
case BDISP_RGB565:
seq_puts(s, RGB565 - );
break;
+   case BDISP_RGB888:
+   seq_puts(s, RGB888 - );
+   break;
case BDISP_XRGB:
seq_puts(s, xRGB888 - );
break;
@@ -185,6 +188,9 @@ static void bdisp_dbg_dump_sty(struct seq_file *s,
case BDISP_RGB565:
seq_puts(s, RGB565 - );
break;
+   case BDISP_RGB888:
+   seq_puts(s, RGB888 - );
+   break;
case BDISP_XRGB:
seq_puts(s, xRGB888 - );
break;
@@ -420,6 +426,8 @@ static const char *bdisp_fmt_to_str(struct bdisp_frame 
frame)
return NV12;
case V4L2_PIX_FMT_RGB565:
return RGB16;
+   case V4L2_PIX_FMT_RGB24:
+   return RGB24;
case V4L2_PIX_FMT_XBGR32:
return XRGB;
case V4L2_PIX_FMT_ABGR32:
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 2/2] [media] bdisp-debug: don't try to divide by s64

2015-06-11 Thread Fabien DESSENNE
Hi Mauro,

Please check my comments below.

 -Original Message-
 From: linux-media-ow...@vger.kernel.org [mailto:linux-media-
 ow...@vger.kernel.org] On Behalf Of Mauro Carvalho Chehab
 Sent: mercredi 10 juin 2015 22:59
 To: Linux Media Mailing List
 Cc: Mauro Carvalho Chehab; Mauro Carvalho Chehab; Fabien DESSENNE
 Subject: [PATCH 2/2] [media] bdisp-debug: don't try to divide by s64
 
 There are several warnings there, on some architectures, related to dividing
 a s32 by a s64 value:
 
 drivers/media/platform/sti/bdisp/bdisp-debug.c:594: warning: comparison
 of distinct pointer types lacks a cast
 drivers/media/platform/sti/bdisp/bdisp-debug.c:594: warning: right shift
 count = width of type
 drivers/media/platform/sti/bdisp/bdisp-debug.c:594: warning: passing
 argument 1 of '__div64_32' from incompatible pointer type
 drivers/media/platform/sti/bdisp/bdisp-debug.c:595: warning: comparison
 of distinct pointer types lacks a cast
 drivers/media/platform/sti/bdisp/bdisp-debug.c:595: warning: right shift
 count = width of type
 drivers/media/platform/sti/bdisp/bdisp-debug.c:595: warning: passing
 argument 1 of '__div64_32' from incompatible pointer type  CC [M]
 drivers/media/tuners/mt2060.o
 drivers/media/platform/sti/bdisp/bdisp-debug.c:596: warning: comparison
 of distinct pointer types lacks a cast
 drivers/media/platform/sti/bdisp/bdisp-debug.c:596: warning: right shift
 count = width of type
 drivers/media/platform/sti/bdisp/bdisp-debug.c:596: warning: passing
 argument 1 of '__div64_32' from incompatible pointer type
 drivers/media/platform/sti/bdisp/bdisp-debug.c:597: warning: comparison
 of distinct pointer types lacks a cast
 drivers/media/platform/sti/bdisp/bdisp-debug.c:597: warning: right shift
 count = width of type
 drivers/media/platform/sti/bdisp/bdisp-debug.c:597: warning: passing
 argument 1 of '__div64_32' from incompatible pointer type
 
 That doesn't make much sense. What the driver is actually trying to do is to
 divide one second by a value. So, check the range before dividing. That
 warrants the right result and will remove the warnings on non-64 bits archs.
 
 Also fixes this warning:
 drivers/media/platform/sti/bdisp/bdisp-debug.c:588: warning: comparison
 of distinct pointer types lacks a cast
 
 by using div64_s64() instead of calling do_div() directly.
 
 Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com
 
 diff --git a/drivers/media/platform/sti/bdisp/bdisp-debug.c
 b/drivers/media/platform/sti/bdisp/bdisp-debug.c
 index 7c3a632746ba..3f6f411aafdd 100644
 --- a/drivers/media/platform/sti/bdisp/bdisp-debug.c
 +++ b/drivers/media/platform/sti/bdisp/bdisp-debug.c
 @@ -572,6 +572,8 @@ static int bdisp_dbg_regs(struct seq_file *s, void
 *data)
   return 0;
  }
 
 +#define SECOND 100
 +
  static int bdisp_dbg_perf(struct seq_file *s, void *data)  {
   struct bdisp_dev *bdisp = s-private;
 @@ -585,16 +587,27 @@ static int bdisp_dbg_perf(struct seq_file *s, void
 *data)
   }
 
   avg_time_us = bdisp-dbg.tot_duration;

When using div64_s64 the above line can be deleted, see my next comment.

 - do_div(avg_time_us, request-nb_req);
 -
 - avg_fps = 100;
 - min_fps = 100;
 - max_fps = 100;
 - last_fps = 100;
 - do_div(avg_fps, avg_time_us);
 - do_div(min_fps, bdisp-dbg.min_duration);
 - do_div(max_fps, bdisp-dbg.max_duration);
 - do_div(last_fps, bdisp-dbg.last_duration);
 + div64_s64(avg_time_us, request-nb_req);

The operation result is returned by div64_s64(different from do_div that 
updates the 1st parameter).
The expected syntax is:
avg_time_us = div64_s64(bdisp-dbg.tot_duration, request-nb_req);

 +
 + if (avg_time_us  SECOND)
 + avg_fps = 0;
 + else
 + avg_fps = SECOND / (s32)avg_time_us;
 +
 + if (bdisp-dbg.min_duration  SECOND)
 + min_fps = 0;
 + else
 + min_fps = SECOND / (s32)bdisp-dbg.min_duration);

It probably builds better without the last unexpected parenthesis ;)

 +
 + if (bdisp-dbg.max_duration  SECOND)
 + max_fps = 0;
 + else
 + max_fps = SECOND / (s32)bdisp-dbg.max_duration;
 +
 + if (bdisp-dbg.last_duration  SECOND)
 + last_fps = 0;
 + else
 + last_fps = SECOND / (s32)bdisp-dbg.last_duration;
 
   seq_printf(s, HW processing (%d requests):\n, request-nb_req);
   seq_printf(s,  Average: %5lld us  (%3d fps)\n,
 --
 2.4.2
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-media in the
 body of a message to majord...@vger.kernel.org More majordomo info at
 http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 2/2] [media] bdisp-debug: don't try to divide by s64

2015-06-11 Thread Fabien DESSENNE
Acked-by: Fabien Dessenne fabien.desse...@st.com

 -Original Message-
 From: Mauro Carvalho Chehab [mailto:mche...@osg.samsung.com]
 Sent: jeudi 11 juin 2015 12:37
 To: Fabien DESSENNE
 Cc: Linux Media Mailing List; Mauro Carvalho Chehab
 Subject: Re: [PATCH 2/2] [media] bdisp-debug: don't try to divide by s64
 
 Hi Fabien,
 
 Em Thu, 11 Jun 2015 11:26:22 +0200
 Fabien DESSENNE fabien.desse...@st.com escreveu:
 
  Hi Mauro,
 
  Please check my comments below.
 
   -Original Message-
   From: linux-media-ow...@vger.kernel.org [mailto:linux-media-
   ow...@vger.kernel.org] On Behalf Of Mauro Carvalho Chehab
   Sent: mercredi 10 juin 2015 22:59
   To: Linux Media Mailing List
   Cc: Mauro Carvalho Chehab; Mauro Carvalho Chehab; Fabien DESSENNE
   Subject: [PATCH 2/2] [media] bdisp-debug: don't try to divide by s64
  
   There are several warnings there, on some architectures, related to
   dividing a s32 by a s64 value:
  
   drivers/media/platform/sti/bdisp/bdisp-debug.c:594: warning:
   comparison of distinct pointer types lacks a cast
   drivers/media/platform/sti/bdisp/bdisp-debug.c:594: warning: right
   shift count = width of type
   drivers/media/platform/sti/bdisp/bdisp-debug.c:594: warning: passing
   argument 1 of '__div64_32' from incompatible pointer type
   drivers/media/platform/sti/bdisp/bdisp-debug.c:595: warning:
   comparison of distinct pointer types lacks a cast
   drivers/media/platform/sti/bdisp/bdisp-debug.c:595: warning: right
   shift count = width of type
   drivers/media/platform/sti/bdisp/bdisp-debug.c:595: warning: passing
   argument 1 of '__div64_32' from incompatible pointer type  CC [M]
   drivers/media/tuners/mt2060.o
   drivers/media/platform/sti/bdisp/bdisp-debug.c:596: warning:
   comparison of distinct pointer types lacks a cast
   drivers/media/platform/sti/bdisp/bdisp-debug.c:596: warning: right
   shift count = width of type
   drivers/media/platform/sti/bdisp/bdisp-debug.c:596: warning: passing
   argument 1 of '__div64_32' from incompatible pointer type
   drivers/media/platform/sti/bdisp/bdisp-debug.c:597: warning:
   comparison of distinct pointer types lacks a cast
   drivers/media/platform/sti/bdisp/bdisp-debug.c:597: warning: right
   shift count = width of type
   drivers/media/platform/sti/bdisp/bdisp-debug.c:597: warning: passing
   argument 1 of '__div64_32' from incompatible pointer type
  
   That doesn't make much sense. What the driver is actually trying to
   do is to divide one second by a value. So, check the range before
   dividing. That warrants the right result and will remove the warnings on
 non-64 bits archs.
  
   Also fixes this warning:
   drivers/media/platform/sti/bdisp/bdisp-debug.c:588: warning:
   comparison of distinct pointer types lacks a cast
  
   by using div64_s64() instead of calling do_div() directly.
  
   Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com
  
   diff --git a/drivers/media/platform/sti/bdisp/bdisp-debug.c
   b/drivers/media/platform/sti/bdisp/bdisp-debug.c
   index 7c3a632746ba..3f6f411aafdd 100644
   --- a/drivers/media/platform/sti/bdisp/bdisp-debug.c
   +++ b/drivers/media/platform/sti/bdisp/bdisp-debug.c
   @@ -572,6 +572,8 @@ static int bdisp_dbg_regs(struct seq_file *s,
   void
   *data)
 return 0;
}
  
   +#define SECOND 100
   +
static int bdisp_dbg_perf(struct seq_file *s, void *data)  {
 struct bdisp_dev *bdisp = s-private; @@ -585,16 +587,27 @@ static
   int bdisp_dbg_perf(struct seq_file *s, void
   *data)
 }
  
 avg_time_us = bdisp-dbg.tot_duration;
 
  When using div64_s64 the above line can be deleted, see my next
 comment.
 
   - do_div(avg_time_us, request-nb_req);
   -
   - avg_fps = 100;
   - min_fps = 100;
   - max_fps = 100;
   - last_fps = 100;
   - do_div(avg_fps, avg_time_us);
   - do_div(min_fps, bdisp-dbg.min_duration);
   - do_div(max_fps, bdisp-dbg.max_duration);
   - do_div(last_fps, bdisp-dbg.last_duration);
   + div64_s64(avg_time_us, request-nb_req);
 
  The operation result is returned by div64_s64(different from do_div that
 updates the 1st parameter).
  The expected syntax is:
  avg_time_us = div64_s64(bdisp-dbg.tot_duration, request-nb_req);
 
   +
   + if (avg_time_us  SECOND)
   + avg_fps = 0;
   + else
   + avg_fps = SECOND / (s32)avg_time_us;
   +
   + if (bdisp-dbg.min_duration  SECOND)
   + min_fps = 0;
   + else
   + min_fps = SECOND / (s32)bdisp-dbg.min_duration);
 
  It probably builds better without the last unexpected parenthesis ;)
 
 Gah, a left-over... I did a first version using a different syntax.
 
 See version 2 below.
 
   +
   + if (bdisp-dbg.max_duration  SECOND)
   + max_fps = 0;
   + else
   + max_fps = SECOND / (s32)bdisp-dbg.max_duration;
   +
   + if (bdisp-dbg.last_duration  SECOND)
   + last_fps = 0;
   + else
   + last_fps = SECOND / (s32)bdisp-dbg.last_duration;
  
 seq_printf(s, HW processing (%d requests):\n

RE: [PATCH] [media] bdisp: remove unused var

2015-06-11 Thread Fabien DESSENNE
Acked-by: Fabien Dessenne fabien.desse...@st.com

 -Original Message-
 From: linux-media-ow...@vger.kernel.org [mailto:linux-media-
 ow...@vger.kernel.org] On Behalf Of Mauro Carvalho Chehab
 Sent: mercredi 10 juin 2015 17:35
 To: Linux Media Mailing List
 Cc: Mauro Carvalho Chehab; Mauro Carvalho Chehab
 Subject: [PATCH] [media] bdisp: remove unused var
 
 Fix the following warning:
 
 drivers/media/platform/sti/bdisp/bdisp-v4l2.c: In function
 'bdisp_register_device':
 drivers/media/platform/sti/bdisp/bdisp-v4l2.c:1024:26: warning: variable
 'pdev' set but not used [-Wunused-but-set-variable]
   struct platform_device *pdev;
 
 Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com
 ---
  drivers/media/platform/sti/bdisp/bdisp-v4l2.c | 3 ---
  1 file changed, 3 deletions(-)
 
 diff --git a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
 b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
 index 9a8405cd5216..9e782ebe18da 100644
 --- a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
 +++ b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
 @@ -1021,14 +1021,11 @@ static const struct v4l2_ioctl_ops bdisp_ioctl_ops
 = {
 
  static int bdisp_register_device(struct bdisp_dev *bdisp)  {
 - struct platform_device *pdev;
   int ret;
 
   if (!bdisp)
   return -ENODEV;
 
 - pdev = bdisp-pdev;
 -
   bdisp-vdev.fops= bdisp_fops;
   bdisp-vdev.ioctl_ops   = bdisp_ioctl_ops;
   bdisp-vdev.release = video_device_release_empty;
 --
 2.4.2
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-media in the
 body of a message to majord...@vger.kernel.org More majordomo info at
 http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] bdisp: remove needless check

2015-06-10 Thread Fabien Dessenne
As reported by smatch:
drivers/media/platform/sti/bdisp/bdisp-v4l2.c:947 bdisp_s_selection() 
warn: unsigned 'out.width' is never less than zero.
drivers/media/platform/sti/bdisp/bdisp-v4l2.c:947 bdisp_s_selection() 
warn: unsigned 'out.height' is never less than zero.
Indeed, width and height are unsigned.

Signed-off-by: Fabien Dessenne fabien.desse...@st.com
---
 drivers/media/platform/sti/bdisp/bdisp-v4l2.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c 
b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
index 89d7a22..9a8405c 100644
--- a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
+++ b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
@@ -944,8 +944,7 @@ static int bdisp_s_selection(struct file *file, void *fh,
out.width = ALIGN(in-width, frame-fmt-w_align);
out.height = ALIGN(in-height, frame-fmt-w_align);
 
-   if ((out.width  0) || (out.height  0) ||
-   ((out.left + out.width)  frame-width) ||
+   if (((out.left + out.width)  frame-width) ||
((out.top + out.height)  frame-height)) {
dev_err(ctx-bdisp_dev-dev,
Invalid crop: %dx%d@(%d,%d) vs frame: %dx%d\n,
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH v3 2/3] [media] bdisp: 2D blitter driver using v4l2 mem2mem framework

2015-06-08 Thread Fabien DESSENNE
 From: Mauro Carvalho Chehab [mailto:mche...@osg.samsung.com]
 Sent: samedi 6 juin 2015 12:43
 To: Fabien DESSENNE
 Cc: linux-media@vger.kernel.org; Benjamin Gaignard; Hugues FRUCHET
 Subject: Re: [PATCH v3 2/3] [media] bdisp: 2D blitter driver using v4l2
 mem2mem framework

 Em Tue, 12 May 2015 18:02:10 +0200
 Fabien Dessenne fabien.desse...@st.com escreveu:

  This v4l2 mem2mem driver is a 2D blitter for STMicroelectronics SoC.
  It uses the v4l2 mem2mem framework.
 
  The following features are supported and tested:
  - Color format conversion (RGB32, RGB24, RGB16, NV12, YUV420P)
  - Copy
  - Scale
  - Flip
  - Deinterlace
  - Wide (4K) picture support
  - Crop
 
  Signed-off-by: Fabien Dessenne fabien.desse...@st.com

 Hmm...

 WARNING: added, moved or deleted file(s), does MAINTAINERS need
 updating?
 #77:
 new file mode 100644


 Who will maintain this driver? Please add the maintainers name at the
 MAINTAINERS file.

 Thanks,
 Mauro

I will take care of it [fabien.desse...@st.com]
As I am not comfortable with the maintainer list update procedure, may I ask 
you to update the MAINTAINERS file?

Thanks,
Fabien



  ---
   drivers/media/platform/Kconfig  |   10 +
   drivers/media/platform/Makefile |2 +
   drivers/media/platform/sti/bdisp/Kconfig|9 +
   drivers/media/platform/sti/bdisp/Makefile   |3 +
   drivers/media/platform/sti/bdisp/bdisp-filter.h |  346 ++
   drivers/media/platform/sti/bdisp/bdisp-hw.c |  783 +
   drivers/media/platform/sti/bdisp/bdisp-reg.h|  235 
   drivers/media/platform/sti/bdisp/bdisp-v4l2.c   | 1404
 +++
   drivers/media/platform/sti/bdisp/bdisp.h|  186 +++
   9 files changed, 2978 insertions(+)
   create mode 100644 drivers/media/platform/sti/bdisp/Kconfig
   create mode 100644 drivers/media/platform/sti/bdisp/Makefile
   create mode 100644 drivers/media/platform/sti/bdisp/bdisp-filter.h
   create mode 100644 drivers/media/platform/sti/bdisp/bdisp-hw.c
   create mode 100644 drivers/media/platform/sti/bdisp/bdisp-reg.h
   create mode 100644 drivers/media/platform/sti/bdisp/bdisp-v4l2.c
   create mode 100644 drivers/media/platform/sti/bdisp/bdisp.h
 
  diff --git a/drivers/media/platform/Kconfig
 b/drivers/media/platform/Kconfig
  index 2e30be5..005be89 100644
  --- a/drivers/media/platform/Kconfig
  +++ b/drivers/media/platform/Kconfig
  @@ -210,6 +210,16 @@ config VIDEO_SAMSUNG_EXYNOS_GSC
  help
This is a v4l2 driver for Samsung EXYNOS5 SoC G-Scaler.
 
  +config VIDEO_STI_BDISP
  +   tristate STMicroelectronics BDISP 2D blitter driver
  +   depends on VIDEO_DEV  VIDEO_V4L2
  +   depends on ARCH_STI || COMPILE_TEST
  +   depends on HAS_DMA
  +   select VIDEOBUF2_DMA_CONTIG
  +   select V4L2_MEM2MEM_DEV
  +   help
  + This v4l2 mem2mem driver is a 2D blitter for STMicroelectronics SoC.
  +
   config VIDEO_SH_VEU
  tristate SuperH VEU mem2mem video processing driver
  depends on VIDEO_DEV  VIDEO_V4L2  HAS_DMA
  diff --git a/drivers/media/platform/Makefile
 b/drivers/media/platform/Makefile
  index 3ec1547..b1fc862 100644
  --- a/drivers/media/platform/Makefile
  +++ b/drivers/media/platform/Makefile
  @@ -34,6 +34,8 @@ obj-$(CONFIG_VIDEO_SAMSUNG_S5P_TV)+= s5p-
 tv/
   obj-$(CONFIG_VIDEO_SAMSUNG_S5P_G2D)+= s5p-g2d/
   obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS_GSC) += exynos-gsc/
 
  +obj-$(CONFIG_VIDEO_STI_BDISP)  += sti/bdisp/
  +
   obj-$(CONFIG_BLACKFIN)  += blackfin/
 
   obj-$(CONFIG_ARCH_DAVINCI) += davinci/
  diff --git a/drivers/media/platform/sti/bdisp/Kconfig
 b/drivers/media/platform/sti/bdisp/Kconfig
  new file mode 100644
  index 000..afaf4a6
  --- /dev/null
  +++ b/drivers/media/platform/sti/bdisp/Kconfig
  @@ -0,0 +1,9 @@
  +config VIDEO_STI_BDISP
  +   tristate STMicroelectronics BDISP 2D blitter driver
  +   depends on VIDEO_DEV  VIDEO_V4L2
  +   select VIDEOBUF2_DMA_CONTIG
  +   select V4L2_MEM2MEM_DEV
  +   help
  +This v4l2 mem2mem driver is a 2D blitter for STMicroelectronics SoC.
  +To compile this driver as a module, choose M here: the module will
  +be called bdisp.ko.
  diff --git a/drivers/media/platform/sti/bdisp/Makefile
 b/drivers/media/platform/sti/bdisp/Makefile
  new file mode 100644
  index 000..2605094
  --- /dev/null
  +++ b/drivers/media/platform/sti/bdisp/Makefile
  @@ -0,0 +1,3 @@
  +obj-$(CONFIG_VIDEO_STI_BDISP) := bdisp.o
  +
  +bdisp-objs := bdisp-v4l2.o bdisp-hw.o
  diff --git a/drivers/media/platform/sti/bdisp/bdisp-filter.h
 b/drivers/media/platform/sti/bdisp/bdisp-filter.h
  new file mode 100644
  index 000..fc8c54f
  --- /dev/null
  +++ b/drivers/media/platform/sti/bdisp/bdisp-filter.h
  @@ -0,0 +1,346 @@
  +/*
  + * Copyright (C) STMicroelectronics SA 2014
  + * Authors: Fabien Dessenne fabien.desse...@st.com for
 STMicroelectronics.
  + * License terms:  GNU General Public License (GPL), version 2
  + */
  +
  +#define

RE: [PATCH] bdisp: update MAINTAINERS

2015-06-08 Thread Fabien DESSENNE
OK, I will take care of this new driver.

 -Original Message-
 From: Hans Verkuil [mailto:hverk...@xs4all.nl]
 Sent: lundi 8 juin 2015 14:24
 To: Linux Media Mailing List; Fabien DESSENNE
 Subject: [PATCH] bdisp: update MAINTAINERS
 
 Add entry for the bdisp driver to the MAINTAINERS file.
 
 Signed-off-by: Hans Verkuil hans.verk...@cisco.com
 
 diff --git a/MAINTAINERS b/MAINTAINERS
 index 3cfb979..de3cf29 100644
 --- a/MAINTAINERS
 +++ b/MAINTAINERS
 @@ -1964,6 +1964,14 @@ W: http://bcache.evilpiepirate.org
  S:   Maintained:
  F:   drivers/md/bcache/
 
 +BDISP ST MEDIA DRIVER
 +M:   Fabien Dessenne fabien.desse...@st.com
 +L:   linux-media@vger.kernel.org
 +T:   git git://linuxtv.org/media_tree.git
 +W:   http://linuxtv.org
 +S:   Supported
 +F:   drivers/media/platform/sti/bdisp
 +
  BEFS FILE SYSTEM
  S:   Orphan
  F:   Documentation/filesystems/befs.txt
N�r��yb�X��ǧv�^�)޺{.n�+{���bj)w*jg����ݢj/���z�ޖ��2�ޙ�)ߡ�a�����G���h��j:+v���w��٥

RE: [PATCH] bdisp: update MAINTAINERS

2015-06-08 Thread Fabien DESSENNE
OK,

Acked-by: Fabien Dessenne fabien.desse...@st.com

 -Original Message-
 From: Hans Verkuil [mailto:hverk...@xs4all.nl]
 Sent: lundi 8 juin 2015 16:33
 To: Fabien DESSENNE; Linux Media Mailing List
 Subject: Re: [PATCH] bdisp: update MAINTAINERS
 
 On 06/08/2015 03:36 PM, Fabien DESSENNE wrote:
  OK, I will take care of this new driver.
 
 Sorry, but I need your Acked-by before I can merge this.
 
 Regards,
 
   Hans
 
 
  -Original Message-
  From: Hans Verkuil [mailto:hverk...@xs4all.nl]
  Sent: lundi 8 juin 2015 14:24
  To: Linux Media Mailing List; Fabien DESSENNE
  Subject: [PATCH] bdisp: update MAINTAINERS
 
  Add entry for the bdisp driver to the MAINTAINERS file.
 
  Signed-off-by: Hans Verkuil hans.verk...@cisco.com
 
  diff --git a/MAINTAINERS b/MAINTAINERS index 3cfb979..de3cf29 100644
  --- a/MAINTAINERS
  +++ b/MAINTAINERS
  @@ -1964,6 +1964,14 @@ W:  http://bcache.evilpiepirate.org
   S:Maintained:
   F:drivers/md/bcache/
 
  +BDISP ST MEDIA DRIVER
  +M:Fabien Dessenne fabien.desse...@st.com
  +L:linux-media@vger.kernel.org
  +T:git git://linuxtv.org/media_tree.git
  +W:http://linuxtv.org
  +S:Supported
  +F:drivers/media/platform/sti/bdisp
  +
   BEFS FILE SYSTEM
   S:Orphan
   F:Documentation/filesystems/befs.txt

N�r��yb�X��ǧv�^�)޺{.n�+{���bj)w*jg����ݢj/���z�ޖ��2�ޙ�)ߡ�a�����G���h��j:+v���w��٥

[PATCH v3 1/3] [media] bdisp: add DT bindings documentation

2015-05-12 Thread Fabien Dessenne
This adds DT binding documentation for STMicroelectronics bdisp driver.

Signed-off-by: Fabien Dessenne fabien.desse...@st.com
---
 .../devicetree/bindings/media/st,stih4xx.txt   | 32 ++
 1 file changed, 32 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/st,stih4xx.txt

diff --git a/Documentation/devicetree/bindings/media/st,stih4xx.txt 
b/Documentation/devicetree/bindings/media/st,stih4xx.txt
new file mode 100644
index 000..df655cd
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/st,stih4xx.txt
@@ -0,0 +1,32 @@
+STMicroelectronics stih4xx platforms
+
+bdisp: 2D blitter for STMicroelectronics SoC.
+
+Required properties:
+- compatible: should be st,stih407-bdisp.
+- reg: BDISP physical address location and length.
+- interrupts: BDISP interrupt number.
+- clocks: from common clock binding: handle hardware IP needed clocks, the
+  number of clocks may depend on the SoC type.
+  See ../clocks/clock-bindings.txt for details.
+- clock-names: names of the clocks listed in clocks property in the same order.
+
+Example:
+
+   bdisp0:bdisp@9f1 {
+   compatible = st,stih407-bdisp;
+   reg = 0x9f1 0x1000;
+   interrupts = GIC_SPI 38 IRQ_TYPE_NONE;
+   clock-names = bdisp;
+   clocks = clk_s_c0_flexgen CLK_IC_BDISP_0;
+   };
+
+Aliases:
+Each BDISP should have a numbered alias in the aliases node, in the form of
+bdispN, N = 0 or 1.
+
+Example:
+
+   aliases {
+   bdisp0 = bdisp0;
+   };
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 3/3] [media] bdisp: add debug file system

2015-05-12 Thread Fabien Dessenne
Creates 5 debugfs entries to dump the last HW request, the last HW node
(=command), the HW registers and the recent HW performance (time  fps)

Signed-off-by: Fabien Dessenne fabien.desse...@st.com
---
 drivers/media/platform/sti/bdisp/Makefile  |   2 +-
 drivers/media/platform/sti/bdisp/bdisp-debug.c | 668 +
 drivers/media/platform/sti/bdisp/bdisp-hw.c|  40 ++
 drivers/media/platform/sti/bdisp/bdisp-v4l2.c  |  17 +-
 drivers/media/platform/sti/bdisp/bdisp.h   |  30 ++
 5 files changed, 755 insertions(+), 2 deletions(-)
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp-debug.c

diff --git a/drivers/media/platform/sti/bdisp/Makefile 
b/drivers/media/platform/sti/bdisp/Makefile
index 2605094..bc53496 100644
--- a/drivers/media/platform/sti/bdisp/Makefile
+++ b/drivers/media/platform/sti/bdisp/Makefile
@@ -1,3 +1,3 @@
 obj-$(CONFIG_VIDEO_STI_BDISP) := bdisp.o
 
-bdisp-objs := bdisp-v4l2.o bdisp-hw.o
+bdisp-objs := bdisp-v4l2.o bdisp-hw.o bdisp-debug.o
diff --git a/drivers/media/platform/sti/bdisp/bdisp-debug.c 
b/drivers/media/platform/sti/bdisp/bdisp-debug.c
new file mode 100644
index 000..7c3a632
--- /dev/null
+++ b/drivers/media/platform/sti/bdisp/bdisp-debug.c
@@ -0,0 +1,668 @@
+/*
+ * Copyright (C) STMicroelectronics SA 2014
+ * Authors: Fabien Dessenne fabien.desse...@st.com for STMicroelectronics.
+ * License terms:  GNU General Public License (GPL), version 2
+ */
+
+#include linux/debugfs.h
+#include linux/pm_runtime.h
+
+#include bdisp.h
+#include bdisp-filter.h
+#include bdisp-reg.h
+
+void bdisp_dbg_perf_begin(struct bdisp_dev *bdisp)
+{
+   bdisp-dbg.hw_start = ktime_get();
+}
+
+void bdisp_dbg_perf_end(struct bdisp_dev *bdisp)
+{
+   s64 time_us;
+
+   time_us = ktime_us_delta(ktime_get(), bdisp-dbg.hw_start);
+
+   if (!bdisp-dbg.min_duration)
+   bdisp-dbg.min_duration = time_us;
+   else
+   bdisp-dbg.min_duration = min(time_us, bdisp-dbg.min_duration);
+
+   bdisp-dbg.last_duration = time_us;
+   bdisp-dbg.max_duration = max(time_us, bdisp-dbg.max_duration);
+   bdisp-dbg.tot_duration += time_us;
+}
+
+static void bdisp_dbg_dump_ins(struct seq_file *s, u32 val)
+{
+   seq_printf(s, INS\t0x%08X\t, val);
+
+   switch (val  BLT_INS_S1_MASK) {
+   case BLT_INS_S1_OFF:
+   break;
+   case BLT_INS_S1_MEM:
+   seq_puts(s, SRC1=mem - );
+   break;
+   case BLT_INS_S1_CF:
+   seq_puts(s, SRC1=ColorFill - );
+   break;
+   case BLT_INS_S1_COPY:
+   seq_puts(s, SRC1=copy - );
+   break;
+   case BLT_INS_S1_FILL:
+   seq_puts(s, SRC1=fil - );
+   break;
+   default:
+   seq_puts(s, SRC1=??? - );
+   break;
+   }
+
+   switch (val  BLT_INS_S2_MASK) {
+   case BLT_INS_S2_OFF:
+   break;
+   case BLT_INS_S2_MEM:
+   seq_puts(s, SRC2=mem - );
+   break;
+   case BLT_INS_S2_CF:
+   seq_puts(s, SRC2=ColorFill - );
+   break;
+   default:
+   seq_puts(s, SRC2=??? - );
+   break;
+   }
+
+   if ((val  BLT_INS_S3_MASK) == BLT_INS_S3_MEM)
+   seq_puts(s, SRC3=mem - );
+
+   if (val  BLT_INS_IVMX)
+   seq_puts(s, IVMX - );
+   if (val  BLT_INS_CLUT)
+   seq_puts(s, CLUT - );
+   if (val  BLT_INS_SCALE)
+   seq_puts(s, Scale - );
+   if (val  BLT_INS_FLICK)
+   seq_puts(s, Flicker - );
+   if (val  BLT_INS_CLIP)
+   seq_puts(s, Clip - );
+   if (val  BLT_INS_CKEY)
+   seq_puts(s, ColorKey - );
+   if (val  BLT_INS_OVMX)
+   seq_puts(s, OVMX - );
+   if (val  BLT_INS_DEI)
+   seq_puts(s, Deint - );
+   if (val  BLT_INS_PMASK)
+   seq_puts(s, PlaneMask - );
+   if (val  BLT_INS_VC1R)
+   seq_puts(s, VC1R - );
+   if (val  BLT_INS_ROTATE)
+   seq_puts(s, Rotate - );
+   if (val  BLT_INS_GRAD)
+   seq_puts(s, GradFill - );
+   if (val  BLT_INS_AQLOCK)
+   seq_puts(s, AQLock - );
+   if (val  BLT_INS_PACE)
+   seq_puts(s, Pace - );
+   if (val  BLT_INS_IRQ)
+   seq_puts(s, IRQ - );
+
+   seq_puts(s, \n);
+}
+
+static void bdisp_dbg_dump_tty(struct seq_file *s, u32 val)
+{
+   seq_printf(s, TTY\t0x%08X\t, val);
+   seq_printf(s, Pitch=%d - , val  0x);
+
+   switch ((val  BLT_TTY_COL_MASK)  BLT_TTY_COL_SHIFT) {
+   case BDISP_RGB565:
+   seq_puts(s, RGB565 - );
+   break;
+   case BDISP_XRGB:
+   seq_puts(s, xRGB888 - );
+   break;
+   case BDISP_ARGB:
+   seq_puts(s, ARGB - );
+   break;
+   case BDISP_NV12:
+   seq_puts(s, NV12 - );
+   break

[PATCH v3 0/3] Add media bdisp driver for stihxxx platforms

2015-05-12 Thread Fabien Dessenne
 VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
test VIDIOC_G/S_PARM: OK (Not Supported)
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
warn: 
/local/frq07368/view/opensdk-0.31/sources/v4l-utils/utils/v4l2-compliance/v4l2-test-formats.cpp(707):
 TRY_FMT cannot handle an invalid pixelformat.
warn: 
/local/frq07368/view/opensdk-0.31/sources/v4l-utils/utils/v4l2-compliance/v4l2-test-formats.cpp(708):
 This may or may not be a problem. For more information see:
warn: 
/local/frq07368/view/opensdk-0.31/sources/v4l-utils/utils/v4l2-compliance/v4l2-test-formats.cpp(709):
 http://www.mail-archive.com/linux-media@vger.kernel.org/msg56550.html
warn: 
/local/frq07368/view/opensdk-0.31/sources/v4l-utils/utils/v4l2-compliance/v4l2-test-formats.cpp(707):
 TRY_FMT cannot handle an invalid pixelformat.
warn: 
/local/frq07368/view/opensdk-0.31/sources/v4l-utils/utils/v4l2-compliance/v4l2-test-formats.cpp(708):
 This may or may not be a problem. For more information see:
warn: 
/local/frq07368/view/opensdk-0.31/sources/v4l-utils/utils/v4l2-compliance/v4l2-test-formats.cpp(709):
 http://www.mail-archive.com/linux-media@vger.kernel.org/msg56550.html
test VIDIOC_TRY_FMT: OK
warn: 
/local/frq07368/view/opensdk-0.31/sources/v4l-utils/utils/v4l2-compliance/v4l2-test-formats.cpp(923):
 S_FMT cannot handle an invalid pixelformat.
warn: 
/local/frq07368/view/opensdk-0.31/sources/v4l-utils/utils/v4l2-compliance/v4l2-test-formats.cpp(924):
 This may or may not be a problem. For more information see:
warn: 
/local/frq07368/view/opensdk-0.31/sources/v4l-utils/utils/v4l2-compliance/v4l2-test-formats.cpp(925):
 http://www.mail-archive.com/linux-media@vger.kernel.org/msg56550.html
warn: 
/local/frq07368/view/opensdk-0.31/sources/v4l-utils/utils/v4l2-compliance/v4l2-test-formats.cpp(923):
 S_FMT cannot handle an invalid pixelformat.
warn: 
/local/frq07368/view/opensdk-0.31/sources/v4l-utils/utils/v4l2-compliance/v4l2-test-formats.cpp(924):
 This may or may not be a problem. For more information see:
warn: 
/local/frq07368/view/opensdk-0.31/sources/v4l-utils/utils/v4l2-compliance/v4l2-test-formats.cpp(925):
 http://www.mail-archive.com/linux-media@vger.kernel.org/msg56550.html
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK
test Composing: OK (Not Supported)
test Scaling: OK

Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
test VIDIOC_EXPBUF: OK

Test input 0:

Stream using all formats:
Not supported for M2M devices

Total: 42, Succeeded: 42, Failed: 0, Warnings: 12
root@st:~# 




Fabien Dessenne (3):
  [media] bdisp: add DT bindings documentation
  [media] bdisp: 2D blitter driver using v4l2 mem2mem framework
  [media] bdisp: add debug file system

 .../devicetree/bindings/media/st,stih4xx.txt   |   32 +
 drivers/media/platform/Kconfig |   10 +
 drivers/media/platform/Makefile|2 +
 drivers/media/platform/sti/bdisp/Kconfig   |9 +
 drivers/media/platform/sti/bdisp/Makefile  |3 +
 drivers/media/platform/sti/bdisp/bdisp-debug.c |  668 +
 drivers/media/platform/sti/bdisp/bdisp-filter.h|  346 +
 drivers/media/platform/sti/bdisp/bdisp-hw.c|  823 
 drivers/media/platform/sti/bdisp/bdisp-reg.h   |  235 
 drivers/media/platform/sti/bdisp/bdisp-v4l2.c  | 1419 
 drivers/media/platform/sti/bdisp/bdisp.h   |  216 +++
 11 files changed, 3763 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/st,stih4xx.txt
 create mode 100644 drivers/media/platform/sti/bdisp/Kconfig
 create mode 100644 drivers/media/platform/sti/bdisp/Makefile
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp-debug.c
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp-filter.h
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp-hw.c
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp-reg.h
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp-v4l2.c
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp.h

-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 2/3] [media] bdisp: 2D blitter driver using v4l2 mem2mem framework

2015-05-12 Thread Fabien Dessenne
This v4l2 mem2mem driver is a 2D blitter for STMicroelectronics SoC.
It uses the v4l2 mem2mem framework.

The following features are supported and tested:
- Color format conversion (RGB32, RGB24, RGB16, NV12, YUV420P)
- Copy
- Scale
- Flip
- Deinterlace
- Wide (4K) picture support
- Crop

Signed-off-by: Fabien Dessenne fabien.desse...@st.com
---
 drivers/media/platform/Kconfig  |   10 +
 drivers/media/platform/Makefile |2 +
 drivers/media/platform/sti/bdisp/Kconfig|9 +
 drivers/media/platform/sti/bdisp/Makefile   |3 +
 drivers/media/platform/sti/bdisp/bdisp-filter.h |  346 ++
 drivers/media/platform/sti/bdisp/bdisp-hw.c |  783 +
 drivers/media/platform/sti/bdisp/bdisp-reg.h|  235 
 drivers/media/platform/sti/bdisp/bdisp-v4l2.c   | 1404 +++
 drivers/media/platform/sti/bdisp/bdisp.h|  186 +++
 9 files changed, 2978 insertions(+)
 create mode 100644 drivers/media/platform/sti/bdisp/Kconfig
 create mode 100644 drivers/media/platform/sti/bdisp/Makefile
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp-filter.h
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp-hw.c
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp-reg.h
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp-v4l2.c
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp.h

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 2e30be5..005be89 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -210,6 +210,16 @@ config VIDEO_SAMSUNG_EXYNOS_GSC
help
  This is a v4l2 driver for Samsung EXYNOS5 SoC G-Scaler.
 
+config VIDEO_STI_BDISP
+   tristate STMicroelectronics BDISP 2D blitter driver
+   depends on VIDEO_DEV  VIDEO_V4L2
+   depends on ARCH_STI || COMPILE_TEST
+   depends on HAS_DMA
+   select VIDEOBUF2_DMA_CONTIG
+   select V4L2_MEM2MEM_DEV
+   help
+ This v4l2 mem2mem driver is a 2D blitter for STMicroelectronics SoC.
+
 config VIDEO_SH_VEU
tristate SuperH VEU mem2mem video processing driver
depends on VIDEO_DEV  VIDEO_V4L2  HAS_DMA
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 3ec1547..b1fc862 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -34,6 +34,8 @@ obj-$(CONFIG_VIDEO_SAMSUNG_S5P_TV)+= s5p-tv/
 obj-$(CONFIG_VIDEO_SAMSUNG_S5P_G2D)+= s5p-g2d/
 obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS_GSC) += exynos-gsc/
 
+obj-$(CONFIG_VIDEO_STI_BDISP)  += sti/bdisp/
+
 obj-$(CONFIG_BLACKFIN)  += blackfin/
 
 obj-$(CONFIG_ARCH_DAVINCI) += davinci/
diff --git a/drivers/media/platform/sti/bdisp/Kconfig 
b/drivers/media/platform/sti/bdisp/Kconfig
new file mode 100644
index 000..afaf4a6
--- /dev/null
+++ b/drivers/media/platform/sti/bdisp/Kconfig
@@ -0,0 +1,9 @@
+config VIDEO_STI_BDISP
+   tristate STMicroelectronics BDISP 2D blitter driver
+   depends on VIDEO_DEV  VIDEO_V4L2
+   select VIDEOBUF2_DMA_CONTIG
+   select V4L2_MEM2MEM_DEV
+   help
+This v4l2 mem2mem driver is a 2D blitter for STMicroelectronics SoC.
+To compile this driver as a module, choose M here: the module will
+be called bdisp.ko.
diff --git a/drivers/media/platform/sti/bdisp/Makefile 
b/drivers/media/platform/sti/bdisp/Makefile
new file mode 100644
index 000..2605094
--- /dev/null
+++ b/drivers/media/platform/sti/bdisp/Makefile
@@ -0,0 +1,3 @@
+obj-$(CONFIG_VIDEO_STI_BDISP) := bdisp.o
+
+bdisp-objs := bdisp-v4l2.o bdisp-hw.o
diff --git a/drivers/media/platform/sti/bdisp/bdisp-filter.h 
b/drivers/media/platform/sti/bdisp/bdisp-filter.h
new file mode 100644
index 000..fc8c54f
--- /dev/null
+++ b/drivers/media/platform/sti/bdisp/bdisp-filter.h
@@ -0,0 +1,346 @@
+/*
+ * Copyright (C) STMicroelectronics SA 2014
+ * Authors: Fabien Dessenne fabien.desse...@st.com for STMicroelectronics.
+ * License terms:  GNU General Public License (GPL), version 2
+ */
+
+#define BDISP_HF_NB 64
+#define BDISP_VF_NB 40
+
+/**
+ * struct bdisp_filter_h_spec - Horizontal filter specification
+ *
+ * @min:min scale factor for this filter (6.10 fixed point)
+ * @max:max scale factor for this filter (6.10 fixed point)
+ * coef:filter coefficients
+ */
+struct bdisp_filter_h_spec {
+   const u16 min;
+   const u16 max;
+   const u8 coef[BDISP_HF_NB];
+};
+
+static const struct bdisp_filter_h_spec bdisp_h_spec[] = {
+   {
+   .min = 0,
+   .max = 921,
+   .coef = {
+   0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0xff, 0x07, 0x3d, 0xfc, 0x01, 0x00,
+   0x00, 0x01, 0xfd, 0x11, 0x36, 0xf9, 0x02, 0x00,
+   0x00, 0x01, 0xfb, 0x1b, 0x2e, 0xf9, 0x02, 0x00,
+   0x00, 0x01

[PATCH] v4l2-compliance: test SELECTION only for the supported buf_type

2015-05-12 Thread Fabien Dessenne
testBasicSelection defines which of capture and output supports crop
(resp. compose).
testBasicCrop (resp. testBasicCompose) shall be run only for the
supported buf_type.

Change-Id: I0a81e826eb7bc8a318a9d833426d802fedce46c9
Signed-off-by: Fabien Dessenne fabien.desse...@st.com
---
 utils/v4l2-compliance/v4l2-test-formats.cpp | 40 +
 1 file changed, 24 insertions(+), 16 deletions(-)

diff --git a/utils/v4l2-compliance/v4l2-test-formats.cpp 
b/utils/v4l2-compliance/v4l2-test-formats.cpp
index 1cffd65..23107c3 100644
--- a/utils/v4l2-compliance/v4l2-test-formats.cpp
+++ b/utils/v4l2-compliance/v4l2-test-formats.cpp
@@ -1251,13 +1251,16 @@ static int testLegacyCrop(struct node *node)
 
 int testCropping(struct node *node)
 {
-   int ret = ENOTTY;
+   int retCap, retOut;
+
+   retCap = ENOTTY;
+   retOut = ENOTTY;
 
fail_on_test(testLegacyCrop(node));
if (node-can_capture  node-is_video)
-   ret = testBasicSelection(node, V4L2_BUF_TYPE_VIDEO_CAPTURE, 
V4L2_SEL_TGT_CROP);
+   retCap = testBasicSelection(node, V4L2_BUF_TYPE_VIDEO_CAPTURE, 
V4L2_SEL_TGT_CROP);
if (node-can_output  node-is_video)
-   ret = testBasicSelection(node, V4L2_BUF_TYPE_VIDEO_OUTPUT, 
V4L2_SEL_TGT_CROP);
+   retOut = testBasicSelection(node, V4L2_BUF_TYPE_VIDEO_OUTPUT, 
V4L2_SEL_TGT_CROP);
if ((!node-can_capture  !node-can_output) || !node-is_video) {
struct v4l2_selection sel = {
V4L2_BUF_TYPE_VIDEO_CAPTURE,
@@ -1269,14 +1272,15 @@ int testCropping(struct node *node)
fail_on_test(doioctl(node, VIDIOC_G_SELECTION, sel) != ENOTTY);
fail_on_test(doioctl(node, VIDIOC_S_SELECTION, sel) != ENOTTY);
}
-   if (ret)
-   return ret;
+   if (retCap  retOut)
+   return retCap;
 
-   if (node-can_capture)
+   if (!retCap)
fail_on_test(testBasicCrop(node, V4L2_BUF_TYPE_VIDEO_CAPTURE));
-   if (node-can_output)
+   if (!retOut)
fail_on_test(testBasicCrop(node, V4L2_BUF_TYPE_VIDEO_OUTPUT));
-   return ret;
+
+   return 0;
 }
 
 static int testBasicCompose(struct node *node, unsigned type)
@@ -1321,12 +1325,15 @@ static int testBasicCompose(struct node *node, unsigned 
type)
 
 int testComposing(struct node *node)
 {
-   int ret = ENOTTY;
+   int retCap, retOut;
+
+   retCap = ENOTTY;
+   retOut = ENOTTY;
 
if (node-can_capture  node-is_video)
-   ret = testBasicSelection(node, V4L2_BUF_TYPE_VIDEO_CAPTURE, 
V4L2_SEL_TGT_COMPOSE);
+   retCap = testBasicSelection(node, V4L2_BUF_TYPE_VIDEO_CAPTURE, 
V4L2_SEL_TGT_COMPOSE);
if (node-can_output  node-is_video)
-   ret = testBasicSelection(node, V4L2_BUF_TYPE_VIDEO_OUTPUT, 
V4L2_SEL_TGT_COMPOSE);
+   retOut = testBasicSelection(node, V4L2_BUF_TYPE_VIDEO_OUTPUT, 
V4L2_SEL_TGT_COMPOSE);
if ((!node-can_capture  !node-can_output) || !node-is_video) {
struct v4l2_selection sel = {
V4L2_BUF_TYPE_VIDEO_OUTPUT,
@@ -1338,14 +1345,15 @@ int testComposing(struct node *node)
fail_on_test(doioctl(node, VIDIOC_G_SELECTION, sel) != ENOTTY);
fail_on_test(doioctl(node, VIDIOC_S_SELECTION, sel) != ENOTTY);
}
-   if (ret)
-   return ret;
+   if (retCap  retOut)
+   return retCap;
 
-   if (node-can_capture)
+   if (retCap)
fail_on_test(testBasicCompose(node, 
V4L2_BUF_TYPE_VIDEO_CAPTURE));
-   if (node-can_output)
+   if (retOut)
fail_on_test(testBasicCompose(node, 
V4L2_BUF_TYPE_VIDEO_OUTPUT));
-   return ret;
+
+   return 0;
 }
 
 static int testBasicScaling(struct node *node, const struct v4l2_format cur)
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 0/3] Add media bdisp driver for stihxxx platforms

2015-05-04 Thread Fabien Dessenne
This series of patches adds the support of v4l2 2D blitter driver for
STMicroelectronics SOC.

version 2:
- Renamed to STI_BDISP, inserted the sti directory.
- Reworked the cropping vs selection API.
- Used additional v4l2_m2m helpers and fops.
- Dropped pixel format description.
- Fixed memory release issue.

version 1:
- Initial submission.

The following features are supported and tested:
- Color format conversion (RGB32, RGB24, RGB16, NV12, YUV420P)
- Copy
- Scale
- Flip
- Deinterlace
- Wide (4K) picture support
- Crop

This driver uses the v4l2 mem2mem framework and its implementation was largely
inspired by the Exynos G-Scaler (exynos-gsc) driver.

The driver is mainly implemented across two files:
- bdisp-v4l2.c
- bdisp-hw.c
bdisp-v4l2.c uses v4l2_m2m to manage the V4L2 interface with the userland.
It calls the HW services that are implemented in bdisp-hw.c.

The additional bdisp-debug.c file manages some debugfs entries.

Fabien Dessenne (3):
  [media] bdisp: add DT bindings documentation
  [media] bdisp: 2D blitter driver using v4l2 mem2mem framework
  [media] bdisp: add debug file system

 .../devicetree/bindings/media/st,stih4xx.txt   |   32 +
 drivers/media/platform/Kconfig |   10 +
 drivers/media/platform/Makefile|2 +
 drivers/media/platform/sti/bdisp/Kconfig   |9 +
 drivers/media/platform/sti/bdisp/Makefile  |3 +
 drivers/media/platform/sti/bdisp/bdisp-debug.c |  668 ++
 drivers/media/platform/sti/bdisp/bdisp-filter.h|  346 +
 drivers/media/platform/sti/bdisp/bdisp-hw.c|  823 
 drivers/media/platform/sti/bdisp/bdisp-reg.h   |  235 
 drivers/media/platform/sti/bdisp/bdisp-v4l2.c  | 1408 
 drivers/media/platform/sti/bdisp/bdisp.h   |  216 +++
 11 files changed, 3752 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/st,stih4xx.txt
 create mode 100644 drivers/media/platform/sti/bdisp/Kconfig
 create mode 100644 drivers/media/platform/sti/bdisp/Makefile
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp-debug.c
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp-filter.h
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp-hw.c
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp-reg.h
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp-v4l2.c
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp.h

-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/3] [media] bdisp: add DT bindings documentation

2015-05-04 Thread Fabien Dessenne
This adds DT binding documentation for STMicroelectronics bdisp driver.

Signed-off-by: Fabien Dessenne fabien.desse...@st.com
---
 .../devicetree/bindings/media/st,stih4xx.txt   | 32 ++
 1 file changed, 32 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/st,stih4xx.txt

diff --git a/Documentation/devicetree/bindings/media/st,stih4xx.txt 
b/Documentation/devicetree/bindings/media/st,stih4xx.txt
new file mode 100644
index 000..df655cd
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/st,stih4xx.txt
@@ -0,0 +1,32 @@
+STMicroelectronics stih4xx platforms
+
+bdisp: 2D blitter for STMicroelectronics SoC.
+
+Required properties:
+- compatible: should be st,stih407-bdisp.
+- reg: BDISP physical address location and length.
+- interrupts: BDISP interrupt number.
+- clocks: from common clock binding: handle hardware IP needed clocks, the
+  number of clocks may depend on the SoC type.
+  See ../clocks/clock-bindings.txt for details.
+- clock-names: names of the clocks listed in clocks property in the same order.
+
+Example:
+
+   bdisp0:bdisp@9f1 {
+   compatible = st,stih407-bdisp;
+   reg = 0x9f1 0x1000;
+   interrupts = GIC_SPI 38 IRQ_TYPE_NONE;
+   clock-names = bdisp;
+   clocks = clk_s_c0_flexgen CLK_IC_BDISP_0;
+   };
+
+Aliases:
+Each BDISP should have a numbered alias in the aliases node, in the form of
+bdispN, N = 0 or 1.
+
+Example:
+
+   aliases {
+   bdisp0 = bdisp0;
+   };
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 3/3] [media] bdisp: add debug file system

2015-05-04 Thread Fabien Dessenne
Creates 5 debugfs entries to dump the last HW request, the last HW node
(=command), the HW registers and the recent HW performance (time  fps)

Signed-off-by: Fabien Dessenne fabien.desse...@st.com
---
 drivers/media/platform/sti/bdisp/Makefile  |   2 +-
 drivers/media/platform/sti/bdisp/bdisp-debug.c | 668 +
 drivers/media/platform/sti/bdisp/bdisp-hw.c|  40 ++
 drivers/media/platform/sti/bdisp/bdisp-v4l2.c  |  17 +-
 drivers/media/platform/sti/bdisp/bdisp.h   |  30 ++
 5 files changed, 755 insertions(+), 2 deletions(-)
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp-debug.c

diff --git a/drivers/media/platform/sti/bdisp/Makefile 
b/drivers/media/platform/sti/bdisp/Makefile
index 2605094..bc53496 100644
--- a/drivers/media/platform/sti/bdisp/Makefile
+++ b/drivers/media/platform/sti/bdisp/Makefile
@@ -1,3 +1,3 @@
 obj-$(CONFIG_VIDEO_STI_BDISP) := bdisp.o
 
-bdisp-objs := bdisp-v4l2.o bdisp-hw.o
+bdisp-objs := bdisp-v4l2.o bdisp-hw.o bdisp-debug.o
diff --git a/drivers/media/platform/sti/bdisp/bdisp-debug.c 
b/drivers/media/platform/sti/bdisp/bdisp-debug.c
new file mode 100644
index 000..7c3a632
--- /dev/null
+++ b/drivers/media/platform/sti/bdisp/bdisp-debug.c
@@ -0,0 +1,668 @@
+/*
+ * Copyright (C) STMicroelectronics SA 2014
+ * Authors: Fabien Dessenne fabien.desse...@st.com for STMicroelectronics.
+ * License terms:  GNU General Public License (GPL), version 2
+ */
+
+#include linux/debugfs.h
+#include linux/pm_runtime.h
+
+#include bdisp.h
+#include bdisp-filter.h
+#include bdisp-reg.h
+
+void bdisp_dbg_perf_begin(struct bdisp_dev *bdisp)
+{
+   bdisp-dbg.hw_start = ktime_get();
+}
+
+void bdisp_dbg_perf_end(struct bdisp_dev *bdisp)
+{
+   s64 time_us;
+
+   time_us = ktime_us_delta(ktime_get(), bdisp-dbg.hw_start);
+
+   if (!bdisp-dbg.min_duration)
+   bdisp-dbg.min_duration = time_us;
+   else
+   bdisp-dbg.min_duration = min(time_us, bdisp-dbg.min_duration);
+
+   bdisp-dbg.last_duration = time_us;
+   bdisp-dbg.max_duration = max(time_us, bdisp-dbg.max_duration);
+   bdisp-dbg.tot_duration += time_us;
+}
+
+static void bdisp_dbg_dump_ins(struct seq_file *s, u32 val)
+{
+   seq_printf(s, INS\t0x%08X\t, val);
+
+   switch (val  BLT_INS_S1_MASK) {
+   case BLT_INS_S1_OFF:
+   break;
+   case BLT_INS_S1_MEM:
+   seq_puts(s, SRC1=mem - );
+   break;
+   case BLT_INS_S1_CF:
+   seq_puts(s, SRC1=ColorFill - );
+   break;
+   case BLT_INS_S1_COPY:
+   seq_puts(s, SRC1=copy - );
+   break;
+   case BLT_INS_S1_FILL:
+   seq_puts(s, SRC1=fil - );
+   break;
+   default:
+   seq_puts(s, SRC1=??? - );
+   break;
+   }
+
+   switch (val  BLT_INS_S2_MASK) {
+   case BLT_INS_S2_OFF:
+   break;
+   case BLT_INS_S2_MEM:
+   seq_puts(s, SRC2=mem - );
+   break;
+   case BLT_INS_S2_CF:
+   seq_puts(s, SRC2=ColorFill - );
+   break;
+   default:
+   seq_puts(s, SRC2=??? - );
+   break;
+   }
+
+   if ((val  BLT_INS_S3_MASK) == BLT_INS_S3_MEM)
+   seq_puts(s, SRC3=mem - );
+
+   if (val  BLT_INS_IVMX)
+   seq_puts(s, IVMX - );
+   if (val  BLT_INS_CLUT)
+   seq_puts(s, CLUT - );
+   if (val  BLT_INS_SCALE)
+   seq_puts(s, Scale - );
+   if (val  BLT_INS_FLICK)
+   seq_puts(s, Flicker - );
+   if (val  BLT_INS_CLIP)
+   seq_puts(s, Clip - );
+   if (val  BLT_INS_CKEY)
+   seq_puts(s, ColorKey - );
+   if (val  BLT_INS_OVMX)
+   seq_puts(s, OVMX - );
+   if (val  BLT_INS_DEI)
+   seq_puts(s, Deint - );
+   if (val  BLT_INS_PMASK)
+   seq_puts(s, PlaneMask - );
+   if (val  BLT_INS_VC1R)
+   seq_puts(s, VC1R - );
+   if (val  BLT_INS_ROTATE)
+   seq_puts(s, Rotate - );
+   if (val  BLT_INS_GRAD)
+   seq_puts(s, GradFill - );
+   if (val  BLT_INS_AQLOCK)
+   seq_puts(s, AQLock - );
+   if (val  BLT_INS_PACE)
+   seq_puts(s, Pace - );
+   if (val  BLT_INS_IRQ)
+   seq_puts(s, IRQ - );
+
+   seq_puts(s, \n);
+}
+
+static void bdisp_dbg_dump_tty(struct seq_file *s, u32 val)
+{
+   seq_printf(s, TTY\t0x%08X\t, val);
+   seq_printf(s, Pitch=%d - , val  0x);
+
+   switch ((val  BLT_TTY_COL_MASK)  BLT_TTY_COL_SHIFT) {
+   case BDISP_RGB565:
+   seq_puts(s, RGB565 - );
+   break;
+   case BDISP_XRGB:
+   seq_puts(s, xRGB888 - );
+   break;
+   case BDISP_ARGB:
+   seq_puts(s, ARGB - );
+   break;
+   case BDISP_NV12:
+   seq_puts(s, NV12 - );
+   break

[PATCH v2 2/3] [media] bdisp: 2D blitter driver using v4l2 mem2mem framework

2015-05-04 Thread Fabien Dessenne
This v4l2 mem2mem driver is a 2D blitter for STMicroelectronics SoC.
It uses the v4l2 mem2mem framework.

The following features are supported and tested:
- Color format conversion (RGB32, RGB24, RGB16, NV12, YUV420P)
- Copy
- Scale
- Flip
- Deinterlace
- Wide (4K) picture support
- Crop

Signed-off-by: Fabien Dessenne fabien.desse...@st.com
---
 drivers/media/platform/Kconfig  |   10 +
 drivers/media/platform/Makefile |2 +
 drivers/media/platform/sti/bdisp/Kconfig|9 +
 drivers/media/platform/sti/bdisp/Makefile   |3 +
 drivers/media/platform/sti/bdisp/bdisp-filter.h |  346 ++
 drivers/media/platform/sti/bdisp/bdisp-hw.c |  783 +
 drivers/media/platform/sti/bdisp/bdisp-reg.h|  235 
 drivers/media/platform/sti/bdisp/bdisp-v4l2.c   | 1393 +++
 drivers/media/platform/sti/bdisp/bdisp.h|  186 +++
 9 files changed, 2967 insertions(+)
 create mode 100644 drivers/media/platform/sti/bdisp/Kconfig
 create mode 100644 drivers/media/platform/sti/bdisp/Makefile
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp-filter.h
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp-hw.c
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp-reg.h
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp-v4l2.c
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp.h

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 2e30be5..005be89 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -210,6 +210,16 @@ config VIDEO_SAMSUNG_EXYNOS_GSC
help
  This is a v4l2 driver for Samsung EXYNOS5 SoC G-Scaler.
 
+config VIDEO_STI_BDISP
+   tristate STMicroelectronics BDISP 2D blitter driver
+   depends on VIDEO_DEV  VIDEO_V4L2
+   depends on ARCH_STI || COMPILE_TEST
+   depends on HAS_DMA
+   select VIDEOBUF2_DMA_CONTIG
+   select V4L2_MEM2MEM_DEV
+   help
+ This v4l2 mem2mem driver is a 2D blitter for STMicroelectronics SoC.
+
 config VIDEO_SH_VEU
tristate SuperH VEU mem2mem video processing driver
depends on VIDEO_DEV  VIDEO_V4L2  HAS_DMA
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 3ec1547..b1fc862 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -34,6 +34,8 @@ obj-$(CONFIG_VIDEO_SAMSUNG_S5P_TV)+= s5p-tv/
 obj-$(CONFIG_VIDEO_SAMSUNG_S5P_G2D)+= s5p-g2d/
 obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS_GSC) += exynos-gsc/
 
+obj-$(CONFIG_VIDEO_STI_BDISP)  += sti/bdisp/
+
 obj-$(CONFIG_BLACKFIN)  += blackfin/
 
 obj-$(CONFIG_ARCH_DAVINCI) += davinci/
diff --git a/drivers/media/platform/sti/bdisp/Kconfig 
b/drivers/media/platform/sti/bdisp/Kconfig
new file mode 100644
index 000..afaf4a6
--- /dev/null
+++ b/drivers/media/platform/sti/bdisp/Kconfig
@@ -0,0 +1,9 @@
+config VIDEO_STI_BDISP
+   tristate STMicroelectronics BDISP 2D blitter driver
+   depends on VIDEO_DEV  VIDEO_V4L2
+   select VIDEOBUF2_DMA_CONTIG
+   select V4L2_MEM2MEM_DEV
+   help
+This v4l2 mem2mem driver is a 2D blitter for STMicroelectronics SoC.
+To compile this driver as a module, choose M here: the module will
+be called bdisp.ko.
diff --git a/drivers/media/platform/sti/bdisp/Makefile 
b/drivers/media/platform/sti/bdisp/Makefile
new file mode 100644
index 000..2605094
--- /dev/null
+++ b/drivers/media/platform/sti/bdisp/Makefile
@@ -0,0 +1,3 @@
+obj-$(CONFIG_VIDEO_STI_BDISP) := bdisp.o
+
+bdisp-objs := bdisp-v4l2.o bdisp-hw.o
diff --git a/drivers/media/platform/sti/bdisp/bdisp-filter.h 
b/drivers/media/platform/sti/bdisp/bdisp-filter.h
new file mode 100644
index 000..fc8c54f
--- /dev/null
+++ b/drivers/media/platform/sti/bdisp/bdisp-filter.h
@@ -0,0 +1,346 @@
+/*
+ * Copyright (C) STMicroelectronics SA 2014
+ * Authors: Fabien Dessenne fabien.desse...@st.com for STMicroelectronics.
+ * License terms:  GNU General Public License (GPL), version 2
+ */
+
+#define BDISP_HF_NB 64
+#define BDISP_VF_NB 40
+
+/**
+ * struct bdisp_filter_h_spec - Horizontal filter specification
+ *
+ * @min:min scale factor for this filter (6.10 fixed point)
+ * @max:max scale factor for this filter (6.10 fixed point)
+ * coef:filter coefficients
+ */
+struct bdisp_filter_h_spec {
+   const u16 min;
+   const u16 max;
+   const u8 coef[BDISP_HF_NB];
+};
+
+static const struct bdisp_filter_h_spec bdisp_h_spec[] = {
+   {
+   .min = 0,
+   .max = 921,
+   .coef = {
+   0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0xff, 0x07, 0x3d, 0xfc, 0x01, 0x00,
+   0x00, 0x01, 0xfd, 0x11, 0x36, 0xf9, 0x02, 0x00,
+   0x00, 0x01, 0xfb, 0x1b, 0x2e, 0xf9, 0x02, 0x00,
+   0x00, 0x01

RE: [PATCH 0/3] Add media bdisp driver for stihxxx platforms

2015-04-28 Thread Fabien DESSENNE
Hi Hans,

Thank you for your quick feedback.
I have read your remarks and I shall be able to take care of all of them.
I need some rework days now.

Regarding v4l2-compliance (latest), here is the current status summary.
v4l2-compliance (no option) returns:
Total: 42, Succeeded: 42, Failed: 0, Warnings: 12.
The 12 warnings are all about the same which is highlighted here:
http://www.mail-archive.com/linux-media@vger.kernel.org/msg56550.html
I do not think this is really an issue so I do not plan to fix it.
If you disagree, please let me know!

Running v4l2-compliance -s returns 1 Failed TC (querybuf). I will investigate
this.

Running v4l2-compliance -f returns:
Total: 42, Succeeded: 42, Failed: 0, Warnings: 12.
(Stream using all formats: Not supported for M2M devices)

Anyway, I will run again v4l2-compliance with the reworked driver and
let you know about the detailed status.

BR
Fabien

 -Original Message-
 From: Hans Verkuil [mailto:hverk...@xs4all.nl]
 Sent: lundi 27 avril 2015 18:26
 To: Fabien DESSENNE; linux-media@vger.kernel.org
 Cc: Benjamin Gaignard
 Subject: Re: [PATCH 0/3] Add media bdisp driver for stihxxx platforms
 
 Hi Fabien,
 
 Thank you for this driver! Good to see V4L2 support for this SoC.
 
 I did a quick initial scan over the driver and there are a few things that 
 need
 to be addressed:
 
 - I think bdisp as the driver name is a bit generic, perhaps something like
   stih4xx-bdisp might be more appropriate. Similar to the exynos-* drivers.
 
 - Replace cropcap/g_crop/s_crop by the g/s_selection ioctls. The old ioctls
   are no longer supported for new drivers (the v4l2 core will automatically
   add support for those ioctls if g/s_selection is implemented in the driver).
   Read careful how crop and compose rectangles are used in a m2m device. I
   would expect that you implement cropping for the
 BUF_TYPE_VIDEO_OUTPUT side
   (i.e. memory to hardware) and implement composing for the
 BUF_TYPE_VIDEO_CAPTURE
   side (i.e. hardware to memory).
 
   If the hardware also support composition for output or cropping for capture,
   then let me know: in that case you will likely have to implement support for
   V4L2_SEL_TGT_NATIVE_SIZE as well.
 
 - Several ioctl and fop helpers were added to media/v4l2-mem2mem.h (e.g.
   v4l2_m2m_ioctl_reqbufs, v4l2_m2m_fop_mmap, etc.). Use these instead
 of
   rolling your own.
 
 - I would like to see the output of these v4l2-compliance commands:
 
   v4l2-compliance
   v4l2-compliance -s
   v4l2-compliance -f
 
   In all fairness: mem2mem devices are not often tested using v4l2-
 compliance
   and there may be problems testing this (-f will likely fail), but I still
   like to see the output so I know what works and what doesn't.
 
   Please use the latest v4l2-compliance code from the v4l-utils.git 
 repository.
   I won't accept the driver unless I see the results of these compliance 
 tests:
   running this is required for new drivers since it is a great way of 
 verifying
   the completeness of your driver.
 
 Regards,
 
   Hans
 
 On 04/27/2015 05:56 PM, Fabien Dessenne wrote:
  This series of patches adds the support of v4l2 2D blitter driver for
  STMicroelectronics SOC.
 
  The following features are supported and tested:
  - Color format conversion (RGB32, RGB24, RGB16, NV12, YUV420P)
  - Copy
  - Scale
  - Flip
  - Deinterlace
  - Wide (4K) picture support
  - Crop
 
  This driver uses the v4l2 mem2mem framework and its implementation
 was
  largely inspired by the Exynos G-Scaler (exynos-gsc) driver.
 
  The driver is mainly implemented across two files:
  - bdisp-v4l2.c
  - bdisp-hw.c
  bdisp-v4l2.c uses v4l2_m2m to manage the V4L2 interface with the
  userland. It calls the HW services that are implemented in bdisp-hw.c.
 
  The additional bdisp-debug.c file manages some debugfs entries.
 
  Fabien Dessenne (3):
[media] bdisp: add DT bindings documentation
[media] bdisp: 2D blitter driver using v4l2 mem2mem framework
[media] bdisp: add debug file system
 
   .../devicetree/bindings/media/st,stih4xx.txt   |   32 +
   drivers/media/platform/Kconfig |   10 +
   drivers/media/platform/Makefile|2 +
   drivers/media/platform/bdisp/Kconfig   |9 +
   drivers/media/platform/bdisp/Makefile  |3 +
   drivers/media/platform/bdisp/bdisp-debug.c |  668 +
   drivers/media/platform/bdisp/bdisp-filter.h|  346 +
   drivers/media/platform/bdisp/bdisp-hw.c|  823 +++
   drivers/media/platform/bdisp/bdisp-reg.h   |  235 +++
   drivers/media/platform/bdisp/bdisp-v4l2.c  | 1492
 
   drivers/media/platform/bdisp/bdisp.h   |  220 +++
   11 files changed, 3840 insertions(+)
   create mode 100644
  Documentation/devicetree/bindings/media/st,stih4xx.txt
   create mode 100644 drivers/media/platform/bdisp/Kconfig
   create mode 100644 drivers/media/platform

[PATCH 1/3] [media] bdisp: add DT bindings documentation

2015-04-27 Thread Fabien Dessenne
This adds DT binding documentation for STMicroelectronics bdisp driver.

Signed-off-by: Fabien Dessenne fabien.desse...@st.com
---
 .../devicetree/bindings/media/st,stih4xx.txt   | 32 ++
 1 file changed, 32 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/st,stih4xx.txt

diff --git a/Documentation/devicetree/bindings/media/st,stih4xx.txt 
b/Documentation/devicetree/bindings/media/st,stih4xx.txt
new file mode 100644
index 000..df655cd
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/st,stih4xx.txt
@@ -0,0 +1,32 @@
+STMicroelectronics stih4xx platforms
+
+bdisp: 2D blitter for STMicroelectronics SoC.
+
+Required properties:
+- compatible: should be st,stih407-bdisp.
+- reg: BDISP physical address location and length.
+- interrupts: BDISP interrupt number.
+- clocks: from common clock binding: handle hardware IP needed clocks, the
+  number of clocks may depend on the SoC type.
+  See ../clocks/clock-bindings.txt for details.
+- clock-names: names of the clocks listed in clocks property in the same order.
+
+Example:
+
+   bdisp0:bdisp@9f1 {
+   compatible = st,stih407-bdisp;
+   reg = 0x9f1 0x1000;
+   interrupts = GIC_SPI 38 IRQ_TYPE_NONE;
+   clock-names = bdisp;
+   clocks = clk_s_c0_flexgen CLK_IC_BDISP_0;
+   };
+
+Aliases:
+Each BDISP should have a numbered alias in the aliases node, in the form of
+bdispN, N = 0 or 1.
+
+Example:
+
+   aliases {
+   bdisp0 = bdisp0;
+   };
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] [media] bdisp: add debug file system

2015-04-27 Thread Fabien Dessenne
Creates 5 debugfs entries to dump the last HW request, the last HW node
(=command), the HW registers and the recent HW performance (time  fps)

Signed-off-by: Fabien Dessenne fabien.desse...@st.com
---
 drivers/media/platform/bdisp/Makefile  |   2 +-
 drivers/media/platform/bdisp/bdisp-debug.c | 668 +
 drivers/media/platform/bdisp/bdisp-hw.c|  40 ++
 drivers/media/platform/bdisp/bdisp-v4l2.c  |  17 +-
 drivers/media/platform/bdisp/bdisp.h   |  30 ++
 5 files changed, 755 insertions(+), 2 deletions(-)
 create mode 100644 drivers/media/platform/bdisp/bdisp-debug.c

diff --git a/drivers/media/platform/bdisp/Makefile 
b/drivers/media/platform/bdisp/Makefile
index ae347a4..2cc2e67 100644
--- a/drivers/media/platform/bdisp/Makefile
+++ b/drivers/media/platform/bdisp/Makefile
@@ -1,3 +1,3 @@
 obj-$(CONFIG_VIDEO_BDISP) := bdisp.o
 
-bdisp-objs := bdisp-v4l2.o bdisp-hw.o
+bdisp-objs := bdisp-v4l2.o bdisp-hw.o bdisp-debug.o
diff --git a/drivers/media/platform/bdisp/bdisp-debug.c 
b/drivers/media/platform/bdisp/bdisp-debug.c
new file mode 100644
index 000..7c3a632
--- /dev/null
+++ b/drivers/media/platform/bdisp/bdisp-debug.c
@@ -0,0 +1,668 @@
+/*
+ * Copyright (C) STMicroelectronics SA 2014
+ * Authors: Fabien Dessenne fabien.desse...@st.com for STMicroelectronics.
+ * License terms:  GNU General Public License (GPL), version 2
+ */
+
+#include linux/debugfs.h
+#include linux/pm_runtime.h
+
+#include bdisp.h
+#include bdisp-filter.h
+#include bdisp-reg.h
+
+void bdisp_dbg_perf_begin(struct bdisp_dev *bdisp)
+{
+   bdisp-dbg.hw_start = ktime_get();
+}
+
+void bdisp_dbg_perf_end(struct bdisp_dev *bdisp)
+{
+   s64 time_us;
+
+   time_us = ktime_us_delta(ktime_get(), bdisp-dbg.hw_start);
+
+   if (!bdisp-dbg.min_duration)
+   bdisp-dbg.min_duration = time_us;
+   else
+   bdisp-dbg.min_duration = min(time_us, bdisp-dbg.min_duration);
+
+   bdisp-dbg.last_duration = time_us;
+   bdisp-dbg.max_duration = max(time_us, bdisp-dbg.max_duration);
+   bdisp-dbg.tot_duration += time_us;
+}
+
+static void bdisp_dbg_dump_ins(struct seq_file *s, u32 val)
+{
+   seq_printf(s, INS\t0x%08X\t, val);
+
+   switch (val  BLT_INS_S1_MASK) {
+   case BLT_INS_S1_OFF:
+   break;
+   case BLT_INS_S1_MEM:
+   seq_puts(s, SRC1=mem - );
+   break;
+   case BLT_INS_S1_CF:
+   seq_puts(s, SRC1=ColorFill - );
+   break;
+   case BLT_INS_S1_COPY:
+   seq_puts(s, SRC1=copy - );
+   break;
+   case BLT_INS_S1_FILL:
+   seq_puts(s, SRC1=fil - );
+   break;
+   default:
+   seq_puts(s, SRC1=??? - );
+   break;
+   }
+
+   switch (val  BLT_INS_S2_MASK) {
+   case BLT_INS_S2_OFF:
+   break;
+   case BLT_INS_S2_MEM:
+   seq_puts(s, SRC2=mem - );
+   break;
+   case BLT_INS_S2_CF:
+   seq_puts(s, SRC2=ColorFill - );
+   break;
+   default:
+   seq_puts(s, SRC2=??? - );
+   break;
+   }
+
+   if ((val  BLT_INS_S3_MASK) == BLT_INS_S3_MEM)
+   seq_puts(s, SRC3=mem - );
+
+   if (val  BLT_INS_IVMX)
+   seq_puts(s, IVMX - );
+   if (val  BLT_INS_CLUT)
+   seq_puts(s, CLUT - );
+   if (val  BLT_INS_SCALE)
+   seq_puts(s, Scale - );
+   if (val  BLT_INS_FLICK)
+   seq_puts(s, Flicker - );
+   if (val  BLT_INS_CLIP)
+   seq_puts(s, Clip - );
+   if (val  BLT_INS_CKEY)
+   seq_puts(s, ColorKey - );
+   if (val  BLT_INS_OVMX)
+   seq_puts(s, OVMX - );
+   if (val  BLT_INS_DEI)
+   seq_puts(s, Deint - );
+   if (val  BLT_INS_PMASK)
+   seq_puts(s, PlaneMask - );
+   if (val  BLT_INS_VC1R)
+   seq_puts(s, VC1R - );
+   if (val  BLT_INS_ROTATE)
+   seq_puts(s, Rotate - );
+   if (val  BLT_INS_GRAD)
+   seq_puts(s, GradFill - );
+   if (val  BLT_INS_AQLOCK)
+   seq_puts(s, AQLock - );
+   if (val  BLT_INS_PACE)
+   seq_puts(s, Pace - );
+   if (val  BLT_INS_IRQ)
+   seq_puts(s, IRQ - );
+
+   seq_puts(s, \n);
+}
+
+static void bdisp_dbg_dump_tty(struct seq_file *s, u32 val)
+{
+   seq_printf(s, TTY\t0x%08X\t, val);
+   seq_printf(s, Pitch=%d - , val  0x);
+
+   switch ((val  BLT_TTY_COL_MASK)  BLT_TTY_COL_SHIFT) {
+   case BDISP_RGB565:
+   seq_puts(s, RGB565 - );
+   break;
+   case BDISP_XRGB:
+   seq_puts(s, xRGB888 - );
+   break;
+   case BDISP_ARGB:
+   seq_puts(s, ARGB - );
+   break;
+   case BDISP_NV12:
+   seq_puts(s, NV12 - );
+   break;
+   case BDISP_YUV_3B:
+   seq_puts(s

[PATCH 2/3] [media] bdisp: 2D blitter driver using v4l2 mem2mem framework

2015-04-27 Thread Fabien Dessenne
This v4l2 mem2mem driver is a 2D blitter for STMicroelectronics SoC.
It uses the v4l2 mem2mem framework.

The following features are supported and tested:
- Color format conversion (RGB32, RGB24, RGB16, NV12, YUV420P)
- Copy
- Scale
- Flip
- Deinterlace
- Wide (4K) picture support
- Crop

Signed-off-by: Fabien Dessenne fabien.desse...@st.com
---
 drivers/media/platform/Kconfig  |   10 +
 drivers/media/platform/Makefile |2 +
 drivers/media/platform/bdisp/Kconfig|9 +
 drivers/media/platform/bdisp/Makefile   |3 +
 drivers/media/platform/bdisp/bdisp-filter.h |  346 +++
 drivers/media/platform/bdisp/bdisp-hw.c |  783 ++
 drivers/media/platform/bdisp/bdisp-reg.h|  235 +
 drivers/media/platform/bdisp/bdisp-v4l2.c   | 1477 +++
 drivers/media/platform/bdisp/bdisp.h|  190 
 9 files changed, 3055 insertions(+)
 create mode 100644 drivers/media/platform/bdisp/Kconfig
 create mode 100644 drivers/media/platform/bdisp/Makefile
 create mode 100644 drivers/media/platform/bdisp/bdisp-filter.h
 create mode 100644 drivers/media/platform/bdisp/bdisp-hw.c
 create mode 100644 drivers/media/platform/bdisp/bdisp-reg.h
 create mode 100644 drivers/media/platform/bdisp/bdisp-v4l2.c
 create mode 100644 drivers/media/platform/bdisp/bdisp.h

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 2e30be5..bf149c2 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -210,6 +210,16 @@ config VIDEO_SAMSUNG_EXYNOS_GSC
help
  This is a v4l2 driver for Samsung EXYNOS5 SoC G-Scaler.
 
+config VIDEO_BDISP
+   tristate STMicroelectronics BDISP 2D blitter driver
+   depends on VIDEO_DEV  VIDEO_V4L2
+   depends on ARCH_STI || COMPILE_TEST
+   depends on HAS_DMA
+   select VIDEOBUF2_DMA_CONTIG
+   select V4L2_MEM2MEM_DEV
+   help
+ This v4l2 mem2mem driver is a 2D blitter for STMicroelectronics SoC.
+
 config VIDEO_SH_VEU
tristate SuperH VEU mem2mem video processing driver
depends on VIDEO_DEV  VIDEO_V4L2  HAS_DMA
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 3ec1547..cad3c0f 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -34,6 +34,8 @@ obj-$(CONFIG_VIDEO_SAMSUNG_S5P_TV)+= s5p-tv/
 obj-$(CONFIG_VIDEO_SAMSUNG_S5P_G2D)+= s5p-g2d/
 obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS_GSC) += exynos-gsc/
 
+obj-$(CONFIG_VIDEO_BDISP)  += bdisp/
+
 obj-$(CONFIG_BLACKFIN)  += blackfin/
 
 obj-$(CONFIG_ARCH_DAVINCI) += davinci/
diff --git a/drivers/media/platform/bdisp/Kconfig 
b/drivers/media/platform/bdisp/Kconfig
new file mode 100644
index 000..3f6de4f
--- /dev/null
+++ b/drivers/media/platform/bdisp/Kconfig
@@ -0,0 +1,9 @@
+config VIDEO_BDISP
+   tristate STMicroelectronics BDISP 2D blitter driver
+   depends on VIDEO_DEV  VIDEO_V4L2
+   select VIDEOBUF2_DMA_CONTIG
+   select V4L2_MEM2MEM_DEV
+   help
+This v4l2 mem2mem driver is a 2D blitter for STMicroelectronics SoC.
+To compile this driver as a module, choose M here: the module will
+be called bdisp.ko.
diff --git a/drivers/media/platform/bdisp/Makefile 
b/drivers/media/platform/bdisp/Makefile
new file mode 100644
index 000..ae347a4
--- /dev/null
+++ b/drivers/media/platform/bdisp/Makefile
@@ -0,0 +1,3 @@
+obj-$(CONFIG_VIDEO_BDISP) := bdisp.o
+
+bdisp-objs := bdisp-v4l2.o bdisp-hw.o
diff --git a/drivers/media/platform/bdisp/bdisp-filter.h 
b/drivers/media/platform/bdisp/bdisp-filter.h
new file mode 100644
index 000..fc8c54f
--- /dev/null
+++ b/drivers/media/platform/bdisp/bdisp-filter.h
@@ -0,0 +1,346 @@
+/*
+ * Copyright (C) STMicroelectronics SA 2014
+ * Authors: Fabien Dessenne fabien.desse...@st.com for STMicroelectronics.
+ * License terms:  GNU General Public License (GPL), version 2
+ */
+
+#define BDISP_HF_NB 64
+#define BDISP_VF_NB 40
+
+/**
+ * struct bdisp_filter_h_spec - Horizontal filter specification
+ *
+ * @min:min scale factor for this filter (6.10 fixed point)
+ * @max:max scale factor for this filter (6.10 fixed point)
+ * coef:filter coefficients
+ */
+struct bdisp_filter_h_spec {
+   const u16 min;
+   const u16 max;
+   const u8 coef[BDISP_HF_NB];
+};
+
+static const struct bdisp_filter_h_spec bdisp_h_spec[] = {
+   {
+   .min = 0,
+   .max = 921,
+   .coef = {
+   0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0xff, 0x07, 0x3d, 0xfc, 0x01, 0x00,
+   0x00, 0x01, 0xfd, 0x11, 0x36, 0xf9, 0x02, 0x00,
+   0x00, 0x01, 0xfb, 0x1b, 0x2e, 0xf9, 0x02, 0x00,
+   0x00, 0x01, 0xf9, 0x26, 0x26, 0xf9, 0x01, 0x00,
+   0x00, 0x02, 0xf9, 0x30, 0x19, 0xfb, 0x01, 0x00

[PATCH 0/3] Add media bdisp driver for stihxxx platforms

2015-04-27 Thread Fabien Dessenne
This series of patches adds the support of v4l2 2D blitter driver for
STMicroelectronics SOC.

The following features are supported and tested:
- Color format conversion (RGB32, RGB24, RGB16, NV12, YUV420P)
- Copy
- Scale
- Flip
- Deinterlace
- Wide (4K) picture support
- Crop

This driver uses the v4l2 mem2mem framework and its implementation was largely
inspired by the Exynos G-Scaler (exynos-gsc) driver.

The driver is mainly implemented across two files:
- bdisp-v4l2.c
- bdisp-hw.c
bdisp-v4l2.c uses v4l2_m2m to manage the V4L2 interface with the userland. It
calls the HW services that are implemented in bdisp-hw.c.

The additional bdisp-debug.c file manages some debugfs entries.

Fabien Dessenne (3):
  [media] bdisp: add DT bindings documentation
  [media] bdisp: 2D blitter driver using v4l2 mem2mem framework
  [media] bdisp: add debug file system

 .../devicetree/bindings/media/st,stih4xx.txt   |   32 +
 drivers/media/platform/Kconfig |   10 +
 drivers/media/platform/Makefile|2 +
 drivers/media/platform/bdisp/Kconfig   |9 +
 drivers/media/platform/bdisp/Makefile  |3 +
 drivers/media/platform/bdisp/bdisp-debug.c |  668 +
 drivers/media/platform/bdisp/bdisp-filter.h|  346 +
 drivers/media/platform/bdisp/bdisp-hw.c|  823 +++
 drivers/media/platform/bdisp/bdisp-reg.h   |  235 +++
 drivers/media/platform/bdisp/bdisp-v4l2.c  | 1492 
 drivers/media/platform/bdisp/bdisp.h   |  220 +++
 11 files changed, 3840 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/st,stih4xx.txt
 create mode 100644 drivers/media/platform/bdisp/Kconfig
 create mode 100644 drivers/media/platform/bdisp/Makefile
 create mode 100644 drivers/media/platform/bdisp/bdisp-debug.c
 create mode 100644 drivers/media/platform/bdisp/bdisp-filter.h
 create mode 100644 drivers/media/platform/bdisp/bdisp-hw.c
 create mode 100644 drivers/media/platform/bdisp/bdisp-reg.h
 create mode 100644 drivers/media/platform/bdisp/bdisp-v4l2.c
 create mode 100644 drivers/media/platform/bdisp/bdisp.h

-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html