Re: [PATCH v2] [media] mtk-mdp: Fix g_/s_selection capture/compose logic

2017-06-20 Thread Minghsiu Tsai
On Mon, 2017-06-19 at 12:10 +0200, Hans Verkuil wrote:
> On 06/19/2017 12:03 PM, Minghsiu Tsai wrote:
> > Hi, Hans,
> > 
> > On Fri, 2017-06-16 at 12:42 +0200, Hans Verkuil wrote:
> >> On 05/12/17 04:42, Minghsiu Tsai wrote:
> >>> From: Daniel Kurtz <djku...@chromium.org>
> >>>
> >>> Experiments show that the:
> >>>   (1) mtk-mdp uses the _MPLANE form of CAPTURE/OUTPUT
> >>
> >> Please drop this, since this no longer applies to this patch.
> >>
> > 
> > I will remove it next version
> > 
> > 
> >>>   (2) CAPTURE types use CROP targets, and OUTPUT types use COMPOSE targets
> >>
> >> Are you really certain about this?
> >>
> >> For m2m devices the output (i.e. memory to hardware) typically crops from 
> >> memory
> >> and the capture side (hardware to memory) composes into memory.
> >>
> >> I.e.: for the output side you crop the part of the memory buffer that you 
> >> want
> >> to process and on the capture side you compose the result into a memory 
> >> buffer:
> >> i.e. the memory buffer might be 1920x1080, but you compose the decoder 
> >> output
> >> into a rectangle of 640x480 at offset 128x128 within that buffer (just an 
> >> example).
> >>
> >> CAPTURE using crop would be if, before the data is DMAed, the hardware 
> >> decoder
> >> output is cropped. E.g. if the stream fed to the decoder is 1920x1080, but 
> >> you
> >> want to only DMA a subselection of that, then that would be cropping, and 
> >> it
> >> would go to a memory buffer of the size of the crop selection.
> >>
> >> OUTPUT using compose is highly unlikely: that means that the frame you give
> >> is composed in a larger internal buffer with generated border data around 
> >> it.
> >> Very rare and really only something that a compositor of some sort would 
> >> do.
> >>
> > 
> > That's strange. In v4l2-ioctl.c, v4l_g_crop()
> > OUTPUT is using COMPOSE
> > CAPTURE is using CROP
> 
> The old crop API can't be used with most (all?) codec drivers. Codec drivers 
> do
> exactly the opposite of what the old crop API did.
> 
> It is the reason the selection API was created.
> 
> The old crop API was written for SDTV receivers where the hardware would crop
> the received video. For output (rarely used) the hardware would compose the
> image into a larger (PAL or NTSC sizes) frame.
> 
> Applications have to use the selection API to work with codec drivers. Just
> ignore the old crop ioctls, they are not suitable for such hardware.
> 

Hi, Hans,
  Thanks for your review and comment. 
  Conclusion is application uses wrong ioctls, g/s_crop.

> > 
> > static int v4l_g_crop(const struct v4l2_ioctl_ops *ops,
> > struct file *file, void *fh, void *arg)
> > ...
> > /* crop means compose for output devices */
> > if (V4L2_TYPE_IS_OUTPUT(p->type))
> > s.target = V4L2_SEL_TGT_COMPOSE_ACTIVE;
> > else
> > s.target = V4L2_SEL_TGT_CROP_ACTIVE;
> > 
> > ret = ops->vidioc_g_selection(file, fh, );
> > 
> > 
> >> What exactly does the hardware do? Both for the encoder and for the decoder
> >> case. Perhaps if I knew exactly what that is, then I can advise.
> >>
> > 
> > NV12M/YUV420M/MT21 -> MDP -> NV12M/YUV420M
> > 
> > The usage would be like this:
> > For decoder:
> > decoder -> MT21 -> MDP -> NV12M/YUV420M
> > 
> > For encoder:
> > NV12M/YUV420M -> MDP -> NV12M/YUV420M -> encoder
> 
> That doesn't help. Where in these two chains does the cropping (encoder) or
> composing (decoder) take place? I assume it is the DMA engine that read from
> a rectangle in the source buffer (encoder) or writes to a rectangle in the
> destination buffer (decoder).
> 

 Yes. they are only buffer transfer between decoder, mdp and encoder.


> And in that case the current driver is correct.

 Next step, we will try to refine framework in userspace code.


> I wonder if the g/s_crop description in the V4L2 Specification should get a
> big fat warning that it doesn't apply to codec drivers and that the selection
> API should be used instead. A patch for that is welcome!
>
> Regards,
> 
>   Hans




Re: [PATCH v2] [media] mtk-mdp: Fix g_/s_selection capture/compose logic

2017-06-19 Thread Minghsiu Tsai
Hi, Hans,

On Fri, 2017-06-16 at 12:42 +0200, Hans Verkuil wrote:
> On 05/12/17 04:42, Minghsiu Tsai wrote:
> > From: Daniel Kurtz <djku...@chromium.org>
> > 
> > Experiments show that the:
> >  (1) mtk-mdp uses the _MPLANE form of CAPTURE/OUTPUT
> 
> Please drop this, since this no longer applies to this patch.
> 

I will remove it next version


> >  (2) CAPTURE types use CROP targets, and OUTPUT types use COMPOSE targets
> 
> Are you really certain about this?
> 
> For m2m devices the output (i.e. memory to hardware) typically crops from 
> memory
> and the capture side (hardware to memory) composes into memory.
> 
> I.e.: for the output side you crop the part of the memory buffer that you want
> to process and on the capture side you compose the result into a memory 
> buffer:
> i.e. the memory buffer might be 1920x1080, but you compose the decoder output
> into a rectangle of 640x480 at offset 128x128 within that buffer (just an 
> example).
> 
> CAPTURE using crop would be if, before the data is DMAed, the hardware decoder
> output is cropped. E.g. if the stream fed to the decoder is 1920x1080, but you
> want to only DMA a subselection of that, then that would be cropping, and it
> would go to a memory buffer of the size of the crop selection.
> 
> OUTPUT using compose is highly unlikely: that means that the frame you give
> is composed in a larger internal buffer with generated border data around it.
> Very rare and really only something that a compositor of some sort would do.
> 

That's strange. In v4l2-ioctl.c, v4l_g_crop()
OUTPUT is using COMPOSE
CAPTURE is using CROP

static int v4l_g_crop(const struct v4l2_ioctl_ops *ops,
struct file *file, void *fh, void *arg)
...
/* crop means compose for output devices */
if (V4L2_TYPE_IS_OUTPUT(p->type))
s.target = V4L2_SEL_TGT_COMPOSE_ACTIVE;
else
s.target = V4L2_SEL_TGT_CROP_ACTIVE;

ret = ops->vidioc_g_selection(file, fh, );


> What exactly does the hardware do? Both for the encoder and for the decoder
> case. Perhaps if I knew exactly what that is, then I can advise.
> 

NV12M/YUV420M/MT21 -> MDP -> NV12M/YUV420M

The usage would be like this:
For decoder:
decoder -> MT21 -> MDP -> NV12M/YUV420M

For encoder:
NV12M/YUV420M -> MDP -> NV12M/YUV420M -> encoder



> Regards,
> 
>   Hans
> 







Re: [PATCH v2] [media] mtk-mdp: Fix g_/s_selection capture/compose logic

2017-06-15 Thread Minghsiu Tsai
Hi, Hans,

Would you have time to review this patch v2?
The patch v1 violates v4l2 spec. I have fixed it in v2.


Sincerely,
Ming Hsiu

On Fri, 2017-05-12 at 10:42 +0800, Minghsiu Tsai wrote:
> From: Daniel Kurtz <djku...@chromium.org>
> 
> Experiments show that the:
>  (1) mtk-mdp uses the _MPLANE form of CAPTURE/OUTPUT
>  (2) CAPTURE types use CROP targets, and OUTPUT types use COMPOSE targets
> 
> Signed-off-by: Daniel Kurtz <djku...@chromium.org>
> Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
> Signed-off-by: Houlong Wei <houlong@mediatek.com>
> 
> ---
> Changes in v2:
> . Can not use *_MPLANE type in g_/s_selection 
> ---
>  drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c 
> b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
> index 13afe48..e18ac626 100644
> --- a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
> +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
> @@ -838,10 +838,10 @@ static int mtk_mdp_m2m_g_selection(struct file *file, 
> void *fh,
>   bool valid = false;
>  
>   if (s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
> - if (mtk_mdp_is_target_compose(s->target))
> + if (mtk_mdp_is_target_crop(s->target))
>   valid = true;
>   } else if (s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
> - if (mtk_mdp_is_target_crop(s->target))
> + if (mtk_mdp_is_target_compose(s->target))
>   valid = true;
>   }
>   if (!valid) {
> @@ -908,10 +908,10 @@ static int mtk_mdp_m2m_s_selection(struct file *file, 
> void *fh,
>   bool valid = false;
>  
>   if (s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
> - if (s->target == V4L2_SEL_TGT_COMPOSE)
> + if (s->target == V4L2_SEL_TGT_CROP)
>   valid = true;
>   } else if (s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
> - if (s->target == V4L2_SEL_TGT_CROP)
> + if (s->target == V4L2_SEL_TGT_COMPOSE)
>   valid = true;
>   }
>   if (!valid) {
> @@ -925,7 +925,7 @@ static int mtk_mdp_m2m_s_selection(struct file *file, 
> void *fh,
>   if (ret)
>   return ret;
>  
> - if (mtk_mdp_is_target_crop(s->target))
> + if (mtk_mdp_is_target_compose(s->target))
>   frame = >s_frame;
>   else
>   frame = >d_frame;




Re: [PATCH] [media] mtk-mdp: Fix g_/s_selection capture/compose logic

2017-06-07 Thread Minghsiu Tsai
Hi, Stanimir Varbanov,

I have upload patch v2. 
https://patchwork.kernel.org/patch/9723463/

Could you review it? Thanks


On Thu, 2017-04-27 at 17:42 +0300, Stanimir Varbanov wrote:
> Hi,
> 
> On 04/13/2017 07:18 AM, Minghsiu Tsai wrote:
> > From: Daniel Kurtz <djku...@chromium.org>
> > 
> > Experiments show that the:
> >  (1) mtk-mdp uses the _MPLANE form of CAPTURE/OUTPUT
> >  (2) CAPTURE types use CROP targets, and OUTPUT types use COMPOSE targets
> > 
> > Signed-off-by: Daniel Kurtz <djku...@chromium.org>
> > Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
> > 
> > ---
> >  drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c | 18 +-
> >  1 file changed, 9 insertions(+), 9 deletions(-)
> > 
> > diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c 
> > b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
> > index 13afe48..8ab7ca0 100644
> > --- a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
> > +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
> > @@ -837,12 +837,12 @@ static int mtk_mdp_m2m_g_selection(struct file *file, 
> > void *fh,
> > struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
> > bool valid = false;
> >  
> > -   if (s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
> > -   if (mtk_mdp_is_target_compose(s->target))
> > -   valid = true;
> > -   } else if (s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
> > +   if (s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
> > if (mtk_mdp_is_target_crop(s->target))
> > valid = true;
> > +   } else if (s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
> > +   if (mtk_mdp_is_target_compose(s->target))
> > +   valid = true;
> > }
> 
> Using MPLANE formats in g/s_selection violates the v4l2 spec. See [1].
> 
> 
> 




Re: [PATCH v3 0/3] Fix mdp device tree

2017-05-22 Thread Minghsiu Tsai
On Mon, 2017-05-22 at 16:16 +0200, Hans Verkuil wrote:
> On 05/22/2017 04:14 PM, Matthias Brugger wrote:
> > 
> > 
> > On 22/05/17 11:09, Hans Verkuil wrote:
> >> On 05/12/2017 05:22 AM, Minghsiu Tsai wrote:
> >>
> >> Who should take care of the dtsi changes? I'm not sure who maintains the 
> >> mdp dts.
> > 
> > I will take care of the dtsi patches.
> > 
> >>
> >> The driver change and the dtsi change need to be in sync, so it is 
> >> probably easiest
> >> to merge this via one tree.
> >>
> >> Here is my Acked-by for these three patches:
> >>
> >> Acked-by: Hans Verkuil <hans.verk...@cisco.com>
> >>
> >> I can take all three, provided I have the Ack of the mdp dts maintainer. 
> >> Or it can
> >> go through him with my Ack.
> >>
> > 
> > I think we should provide backwards compability instead, as proposed here:
> > http://lists.infradead.org/pipermail/linux-mediatek/2017-May/008811.html
> > 
> > If this change is ok for you, please let Minghsiu know so that he can 
> > provide a v4.
> 
> That's a lot better. In that case I can take the media patches and you the 
> dts.
> 
> I'll wait for the v4.
> 

Hi Hans, Matthias,

I have uploaded v4, thanks.


> Regards,
> 
>   Hans
> 
> > 
> > Regards,
> > Matthias
> > 
> >> Regards,
> >>
> >>Hans
> >>
> >>> Changes in v3:
> >>> - Upload patches again because forget to add v2 in title
> >>>
> >>> Changes in v2:
> >>> - Update commit message
> >>>
> >>> If the mdp_* nodes are under an mdp sub-node, their corresponding
> >>> platform device does not automatically get its iommu assigned properly.
> >>>
> >>> Fix this by moving the mdp component nodes up a level such that they are
> >>> siblings of mdp and all other SoC subsystems.  This also simplifies the
> >>> device tree.
> >>>
> >>> Although it fixes iommu assignment issue, it also break compatibility
> >>> with old device tree. So, the patch in driver is needed to iterate over
> >>> sibling mdp device nodes, not child ones, to keep driver work properly.
> >>>
> >>> Daniel Kurtz (2):
> >>>arm64: dts: mt8173: Fix mdp device tree
> >>>media: mtk-mdp: Fix mdp device tree
> >>>
> >>> Minghsiu Tsai (1):
> >>>dt-bindings: mt8173: Fix mdp device tree
> >>>
> >>>   .../devicetree/bindings/media/mediatek-mdp.txt |  12 +-
> >>>   arch/arm64/boot/dts/mediatek/mt8173.dtsi   | 126 
> >>> ++---
> >>>   drivers/media/platform/mtk-mdp/mtk_mdp_core.c  |   2 +-
> >>>   3 files changed, 64 insertions(+), 76 deletions(-)
> >>>
> >>
> 




[PATCH v4 3/3] media: mtk-mdp: Fix mdp device tree

2017-05-22 Thread Minghsiu Tsai
From: Daniel Kurtz <djku...@chromium.org>

If the mdp_* nodes are under an mdp sub-node, their corresponding
platform device does not automatically get its iommu assigned properly.

Fix this by moving the mdp component nodes up a level such that they are
siblings of mdp and all other SoC subsystems.  This also simplifies the
device tree.

Although it fixes iommu assignment issue, it also break compatibility
with old device tree. So, the patch in driver is needed to iterate over
sibling mdp device nodes, not child ones, to keep driver work properly.

Signed-off-by: Daniel Kurtz <djku...@chromium.org>
Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
Signed-off-by: Matthias Brugger <matthias@gmail.com>

---
 drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c 
b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
index 9e4eb7d..8134755 100644
--- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
@@ -103,7 +103,7 @@ static int mtk_mdp_probe(struct platform_device *pdev)
 {
struct mtk_mdp_dev *mdp;
struct device *dev = >dev;
-   struct device_node *node;
+   struct device_node *node, *parent;
int i, ret = 0;
 
mdp = devm_kzalloc(dev, sizeof(*mdp), GFP_KERNEL);
@@ -117,8 +117,16 @@ static int mtk_mdp_probe(struct platform_device *pdev)
mutex_init(>lock);
mutex_init(>vpulock);
 
+   /* Old dts had the components as child nodes */
+   if (of_get_next_child(dev->of_node, NULL)) {
+   parent = dev->of_node;
+   dev_warn(dev, "device tree is out of date\n");
+   } else {
+   parent = dev->of_node->parent;
+   }
+
/* Iterate over sibling MDP function blocks */
-   for_each_child_of_node(dev->of_node, node) {
+   for_each_child_of_node(parent, node) {
const struct of_device_id *of_id;
enum mtk_mdp_comp_type comp_type;
int comp_id;
-- 
1.9.1



[PATCH v4 0/3] Fix mdp device tree

2017-05-22 Thread Minghsiu Tsai
Changes in v4:
- Add backwards compability if dts is out-of-date

Changes in v3:
- Upload patches again because forget to add v2 in title

Changes in v2:
- Update commit message

If the mdp_* nodes are under an mdp sub-node, their corresponding
platform device does not automatically get its iommu assigned properly.

Fix this by moving the mdp component nodes up a level such that they are
siblings of mdp and all other SoC subsystems.  This also simplifies the
device tree.

Although it fixes iommu assignment issue, it also break compatibility
with old device tree. So, the patch in driver is needed to iterate over
sibling mdp device nodes, not child ones, to keep driver work properly.

Daniel Kurtz (2):
  arm64: dts: mt8173: Fix mdp device tree
  media: mtk-mdp: Fix mdp device tree

Minghsiu Tsai (1):
  dt-bindings: mt8173: Fix mdp device tree

 .../devicetree/bindings/media/mediatek-mdp.txt |  12 +-
 arch/arm64/boot/dts/mediatek/mt8173.dtsi   | 126 ++---
 drivers/media/platform/mtk-mdp/mtk_mdp_core.c  |  12 +-
 3 files changed, 73 insertions(+), 77 deletions(-)

-- 
1.9.1



[PATCH v4 2/3] arm64: dts: mt8173: Fix mdp device tree

2017-05-22 Thread Minghsiu Tsai
From: Daniel Kurtz <djku...@chromium.org>

If the mdp_* nodes are under an mdp sub-node, their corresponding
platform device does not automatically get its iommu assigned properly.

Fix this by moving the mdp component nodes up a level such that they are
siblings of mdp and all other SoC subsystems.  This also simplifies the
device tree.

Although it fixes iommu assignment issue, it also break compatibility
with old device tree. So, the patch in driver is needed to iterate over
sibling mdp device nodes, not child ones, to keep driver work properly.

Signed-off-by: Daniel Kurtz <djku...@chromium.org>
Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
Acked-by: Hans Verkuil <hans.verk...@cisco.com>

---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi | 126 +++
 1 file changed, 60 insertions(+), 66 deletions(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 6922252..d28a363 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -792,80 +792,74 @@
#clock-cells = <1>;
};
 
-   mdp {
-   compatible = "mediatek,mt8173-mdp";
-   #address-cells = <2>;
-   #size-cells = <2>;
-   ranges;
+   mdp_rdma0: rdma@14001000 {
+   compatible = "mediatek,mt8173-mdp-rdma",
+"mediatek,mt8173-mdp";
+   reg = <0 0x14001000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA0>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA0>;
+   mediatek,larb = <>;
mediatek,vpu = <>;
+   };
 
-   mdp_rdma0: rdma@14001000 {
-   compatible = "mediatek,mt8173-mdp-rdma";
-   reg = <0 0x14001000 0 0x1000>;
-   clocks = < CLK_MM_MDP_RDMA0>,
-< CLK_MM_MUTEX_32K>;
-   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
-   iommus = < M4U_PORT_MDP_RDMA0>;
-   mediatek,larb = <>;
-   };
-
-   mdp_rdma1: rdma@14002000 {
-   compatible = "mediatek,mt8173-mdp-rdma";
-   reg = <0 0x14002000 0 0x1000>;
-   clocks = < CLK_MM_MDP_RDMA1>,
-< CLK_MM_MUTEX_32K>;
-   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
-   iommus = < M4U_PORT_MDP_RDMA1>;
-   mediatek,larb = <>;
-   };
+   mdp_rdma1: rdma@14002000 {
+   compatible = "mediatek,mt8173-mdp-rdma";
+   reg = <0 0x14002000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA1>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA1>;
+   mediatek,larb = <>;
+   };
 
-   mdp_rsz0: rsz@14003000 {
-   compatible = "mediatek,mt8173-mdp-rsz";
-   reg = <0 0x14003000 0 0x1000>;
-   clocks = < CLK_MM_MDP_RSZ0>;
-   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
-   };
+   mdp_rsz0: rsz@14003000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14003000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ0>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
 
-   mdp_rsz1: rsz@14004000 {
-   compatible = "mediatek,mt8173-mdp-rsz";
-   reg = <0 0x14004000 0 0x1000>;
-   clocks = < CLK_MM_MDP_RSZ1>;
-   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
-   };
+   mdp_rsz1: rsz@14004000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14004000 0 0x1000>;
+   clocks 

[PATCH v4 1/3] dt-bindings: mt8173: Fix mdp device tree

2017-05-22 Thread Minghsiu Tsai
If the mdp_* nodes are under an mdp sub-node, their corresponding
platform device does not automatically get its iommu assigned properly.

Fix this by moving the mdp component nodes up a level such that they are
siblings of mdp and all other SoC subsystems.  This also simplifies the
device tree.

Although it fixes iommu assignment issue, it also break compatibility
with old device tree. So, the patch in driver is needed to iterate over
sibling mdp device nodes, not child ones, to keep driver work properly.

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
Acked-by: Rob Herring <r...@kernel.org>
Acked-by: Hans Verkuil <hans.verk...@cisco.com>

---
 Documentation/devicetree/bindings/media/mediatek-mdp.txt | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/Documentation/devicetree/bindings/media/mediatek-mdp.txt 
b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
index 4182063..0d03e3a 100644
--- a/Documentation/devicetree/bindings/media/mediatek-mdp.txt
+++ b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
@@ -2,7 +2,7 @@
 
 Media Data Path is used for scaling and color space conversion.
 
-Required properties (controller (parent) node):
+Required properties (controller node):
 - compatible: "mediatek,mt8173-mdp"
 - mediatek,vpu: the node of video processor unit, see
   Documentation/devicetree/bindings/media/mediatek-vpu.txt for details.
@@ -32,21 +32,16 @@ Required properties (DMA function blocks, child node):
   for details.
 
 Example:
-mdp {
-   compatible = "mediatek,mt8173-mdp";
-   #address-cells = <2>;
-   #size-cells = <2>;
-   ranges;
-   mediatek,vpu = <>;
-
mdp_rdma0: rdma@14001000 {
compatible = "mediatek,mt8173-mdp-rdma";
+"mediatek,mt8173-mdp";
reg = <0 0x14001000 0 0x1000>;
clocks = < CLK_MM_MDP_RDMA0>,
 < CLK_MM_MUTEX_32K>;
power-domains = < MT8173_POWER_DOMAIN_MM>;
iommus = < M4U_PORT_MDP_RDMA0>;
mediatek,larb = <>;
+   mediatek,vpu = <>;
};
 
mdp_rdma1: rdma@14002000 {
@@ -106,4 +101,3 @@ mdp {
iommus = < M4U_PORT_MDP_WROT1>;
mediatek,larb = <>;
};
-};
-- 
1.9.1



Re: [PATCH v3 3/3] media: mtk-mdp: Fix mdp device tree

2017-05-14 Thread Minghsiu Tsai
On Fri, 2017-05-12 at 17:05 +0200, Matthias Brugger wrote:
> 
> On 12/05/17 05:22, Minghsiu Tsai wrote:
> > From: Daniel Kurtz <djku...@chromium.org>
> > 
> > If the mdp_* nodes are under an mdp sub-node, their corresponding
> > platform device does not automatically get its iommu assigned properly.
> > 
> > Fix this by moving the mdp component nodes up a level such that they are
> > siblings of mdp and all other SoC subsystems.  This also simplifies the
> > device tree.
> > 
> > Although it fixes iommu assignment issue, it also break compatibility
> > with old device tree. So, the patch in driver is needed to iterate over
> > sibling mdp device nodes, not child ones, to keep driver work properly.
> > 
> 
> Couldn't we preserve backwards compatibility by doing something like this:
> diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c 
> b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
> index 9e4eb7dcc424..277d8fe6eb76 100644
> --- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
> +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
> @@ -103,7 +103,7 @@ static int mtk_mdp_probe(struct platform_device *pdev)
>   {
>   struct mtk_mdp_dev *mdp;
>   struct device *dev = >dev;
> - struct device_node *node;
> + struct device_node *node, *parent;
>   int i, ret = 0;
> 
>   mdp = devm_kzalloc(dev, sizeof(*mdp), GFP_KERNEL);
> @@ -117,8 +117,14 @@ static int mtk_mdp_probe(struct platform_device *pdev)
>   mutex_init(>lock);
>   mutex_init(>vpulock);
> 
> + /* Old dts had the components as child nodes */
> + if (of_get_next_child(dev->of_node, NULL))
> + parent = dev->of_node;
> + else
> + parent = dev->of_node->parent;
> +
>   /* Iterate over sibling MDP function blocks */
> - for_each_child_of_node(dev->of_node, node) {
> + for_each_child_of_node(parent, node) {
>   const struct of_device_id *of_id;
>   enum mtk_mdp_comp_type comp_type;
>   int comp_id;
> 
> Maybe even by putting a warning in the if branch to make sure, people 
> are aware of their out-of-date device tree blobs.
> 
> Regards,
> Matthias
> 

Hi Matthias,

It is a good idea to do compatible in such a way and put a warning the
device tree is out of date. People can find out cause soon if device
tree is old.

I modify the code as below:

+   /* Old dts had the components as child nodes */
+   if (of_get_next_child(dev->of_node, NULL)) {
+   parent = dev->of_node;
+   dev_warn(dev, "device tree is out of date\n");
+   } else {
+   parent = dev->of_node->parent;
+   }

Will you upload it in a separate patch? 
If not, I can merge it in my patch series and upload v4.


Best Regards,

Ming Hsiu

> > Signed-off-by: Daniel Kurtz <djku...@chromium.org>
> > Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
> > 
> > ---
> >   drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c 
> > b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
> > index 9e4eb7d..a5ad586 100644
> > --- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
> > +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
> > @@ -118,7 +118,7 @@ static int mtk_mdp_probe(struct platform_device *pdev)
> > mutex_init(>vpulock);
> >   
> > /* Iterate over sibling MDP function blocks */
> > -   for_each_child_of_node(dev->of_node, node) {
> > +   for_each_child_of_node(dev->of_node->parent, node) {
> > const struct of_device_id *of_id;
> > enum mtk_mdp_comp_type comp_type;
> > int comp_id;
> > 




[PATCH v3 2/3] arm64: dts: mt8173: Fix mdp device tree

2017-05-11 Thread Minghsiu Tsai
From: Daniel Kurtz <djku...@chromium.org>

If the mdp_* nodes are under an mdp sub-node, their corresponding
platform device does not automatically get its iommu assigned properly.

Fix this by moving the mdp component nodes up a level such that they are
siblings of mdp and all other SoC subsystems.  This also simplifies the
device tree.

Although it fixes iommu assignment issue, it also break compatibility
with old device tree. So, the patch in driver is needed to iterate over
sibling mdp device nodes, not child ones, to keep driver work properly.

Signed-off-by: Daniel Kurtz <djku...@chromium.org>
Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>

---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi | 126 +++
 1 file changed, 60 insertions(+), 66 deletions(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 6922252..d28a363 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -792,80 +792,74 @@
#clock-cells = <1>;
};
 
-   mdp {
-   compatible = "mediatek,mt8173-mdp";
-   #address-cells = <2>;
-   #size-cells = <2>;
-   ranges;
+   mdp_rdma0: rdma@14001000 {
+   compatible = "mediatek,mt8173-mdp-rdma",
+"mediatek,mt8173-mdp";
+   reg = <0 0x14001000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA0>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA0>;
+   mediatek,larb = <>;
mediatek,vpu = <>;
+   };
 
-   mdp_rdma0: rdma@14001000 {
-   compatible = "mediatek,mt8173-mdp-rdma";
-   reg = <0 0x14001000 0 0x1000>;
-   clocks = < CLK_MM_MDP_RDMA0>,
-< CLK_MM_MUTEX_32K>;
-   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
-   iommus = < M4U_PORT_MDP_RDMA0>;
-   mediatek,larb = <>;
-   };
-
-   mdp_rdma1: rdma@14002000 {
-   compatible = "mediatek,mt8173-mdp-rdma";
-   reg = <0 0x14002000 0 0x1000>;
-   clocks = < CLK_MM_MDP_RDMA1>,
-< CLK_MM_MUTEX_32K>;
-   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
-   iommus = < M4U_PORT_MDP_RDMA1>;
-   mediatek,larb = <>;
-   };
+   mdp_rdma1: rdma@14002000 {
+   compatible = "mediatek,mt8173-mdp-rdma";
+   reg = <0 0x14002000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA1>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA1>;
+   mediatek,larb = <>;
+   };
 
-   mdp_rsz0: rsz@14003000 {
-   compatible = "mediatek,mt8173-mdp-rsz";
-   reg = <0 0x14003000 0 0x1000>;
-   clocks = < CLK_MM_MDP_RSZ0>;
-   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
-   };
+   mdp_rsz0: rsz@14003000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14003000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ0>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
 
-   mdp_rsz1: rsz@14004000 {
-   compatible = "mediatek,mt8173-mdp-rsz";
-   reg = <0 0x14004000 0 0x1000>;
-   clocks = < CLK_MM_MDP_RSZ1>;
-   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
-   };
+   mdp_rsz1: rsz@14004000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14004000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ1>;
+   po

[PATCH v3 1/3] dt-bindings: mt8173: Fix mdp device tree

2017-05-11 Thread Minghsiu Tsai
If the mdp_* nodes are under an mdp sub-node, their corresponding
platform device does not automatically get its iommu assigned properly.

Fix this by moving the mdp component nodes up a level such that they are
siblings of mdp and all other SoC subsystems.  This also simplifies the
device tree.

Although it fixes iommu assignment issue, it also break compatibility
with old device tree. So, the patch in driver is needed to iterate over
sibling mdp device nodes, not child ones, to keep driver work properly.

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>

---
 Documentation/devicetree/bindings/media/mediatek-mdp.txt | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/Documentation/devicetree/bindings/media/mediatek-mdp.txt 
b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
index 4182063..0d03e3a 100644
--- a/Documentation/devicetree/bindings/media/mediatek-mdp.txt
+++ b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
@@ -2,7 +2,7 @@
 
 Media Data Path is used for scaling and color space conversion.
 
-Required properties (controller (parent) node):
+Required properties (controller node):
 - compatible: "mediatek,mt8173-mdp"
 - mediatek,vpu: the node of video processor unit, see
   Documentation/devicetree/bindings/media/mediatek-vpu.txt for details.
@@ -32,21 +32,16 @@ Required properties (DMA function blocks, child node):
   for details.
 
 Example:
-mdp {
-   compatible = "mediatek,mt8173-mdp";
-   #address-cells = <2>;
-   #size-cells = <2>;
-   ranges;
-   mediatek,vpu = <>;
-
mdp_rdma0: rdma@14001000 {
compatible = "mediatek,mt8173-mdp-rdma";
+"mediatek,mt8173-mdp";
reg = <0 0x14001000 0 0x1000>;
clocks = < CLK_MM_MDP_RDMA0>,
 < CLK_MM_MUTEX_32K>;
power-domains = < MT8173_POWER_DOMAIN_MM>;
iommus = < M4U_PORT_MDP_RDMA0>;
mediatek,larb = <>;
+   mediatek,vpu = <>;
};
 
mdp_rdma1: rdma@14002000 {
@@ -106,4 +101,3 @@ mdp {
iommus = < M4U_PORT_MDP_WROT1>;
mediatek,larb = <>;
};
-};
-- 
1.9.1



[PATCH v3 0/3] Fix mdp device tree

2017-05-11 Thread Minghsiu Tsai
Changes in v3:
- Upload patches again because forget to add v2 in title

Changes in v2:
- Update commit message

If the mdp_* nodes are under an mdp sub-node, their corresponding
platform device does not automatically get its iommu assigned properly.

Fix this by moving the mdp component nodes up a level such that they are
siblings of mdp and all other SoC subsystems.  This also simplifies the
device tree.

Although it fixes iommu assignment issue, it also break compatibility
with old device tree. So, the patch in driver is needed to iterate over
sibling mdp device nodes, not child ones, to keep driver work properly.

Daniel Kurtz (2):
  arm64: dts: mt8173: Fix mdp device tree
  media: mtk-mdp: Fix mdp device tree

Minghsiu Tsai (1):
  dt-bindings: mt8173: Fix mdp device tree

 .../devicetree/bindings/media/mediatek-mdp.txt |  12 +-
 arch/arm64/boot/dts/mediatek/mt8173.dtsi   | 126 ++---
 drivers/media/platform/mtk-mdp/mtk_mdp_core.c  |   2 +-
 3 files changed, 64 insertions(+), 76 deletions(-)

-- 
1.9.1



[PATCH v3 3/3] media: mtk-mdp: Fix mdp device tree

2017-05-11 Thread Minghsiu Tsai
From: Daniel Kurtz <djku...@chromium.org>

If the mdp_* nodes are under an mdp sub-node, their corresponding
platform device does not automatically get its iommu assigned properly.

Fix this by moving the mdp component nodes up a level such that they are
siblings of mdp and all other SoC subsystems.  This also simplifies the
device tree.

Although it fixes iommu assignment issue, it also break compatibility
with old device tree. So, the patch in driver is needed to iterate over
sibling mdp device nodes, not child ones, to keep driver work properly.

Signed-off-by: Daniel Kurtz <djku...@chromium.org>
Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>

---
 drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c 
b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
index 9e4eb7d..a5ad586 100644
--- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
@@ -118,7 +118,7 @@ static int mtk_mdp_probe(struct platform_device *pdev)
mutex_init(>vpulock);
 
/* Iterate over sibling MDP function blocks */
-   for_each_child_of_node(dev->of_node, node) {
+   for_each_child_of_node(dev->of_node->parent, node) {
const struct of_device_id *of_id;
enum mtk_mdp_comp_type comp_type;
int comp_id;
-- 
1.9.1



[PATCH 1/3] dt-bindings: mt8173: Fix mdp device tree

2017-05-11 Thread Minghsiu Tsai
If the mdp_* nodes are under an mdp sub-node, their corresponding
platform device does not automatically get its iommu assigned properly.

Fix this by moving the mdp component nodes up a level such that they are
siblings of mdp and all other SoC subsystems.  This also simplifies the
device tree.

Although it fixes iommu assignment issue, it also break compatibility
with old device tree. So, the patch in driver is needed to iterate over
sibling mdp device nodes, not child ones, to keep driver work properly.

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>

---
 Documentation/devicetree/bindings/media/mediatek-mdp.txt | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/Documentation/devicetree/bindings/media/mediatek-mdp.txt 
b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
index 4182063..0d03e3a 100644
--- a/Documentation/devicetree/bindings/media/mediatek-mdp.txt
+++ b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
@@ -2,7 +2,7 @@
 
 Media Data Path is used for scaling and color space conversion.
 
-Required properties (controller (parent) node):
+Required properties (controller node):
 - compatible: "mediatek,mt8173-mdp"
 - mediatek,vpu: the node of video processor unit, see
   Documentation/devicetree/bindings/media/mediatek-vpu.txt for details.
@@ -32,21 +32,16 @@ Required properties (DMA function blocks, child node):
   for details.
 
 Example:
-mdp {
-   compatible = "mediatek,mt8173-mdp";
-   #address-cells = <2>;
-   #size-cells = <2>;
-   ranges;
-   mediatek,vpu = <>;
-
mdp_rdma0: rdma@14001000 {
compatible = "mediatek,mt8173-mdp-rdma";
+"mediatek,mt8173-mdp";
reg = <0 0x14001000 0 0x1000>;
clocks = < CLK_MM_MDP_RDMA0>,
 < CLK_MM_MUTEX_32K>;
power-domains = < MT8173_POWER_DOMAIN_MM>;
iommus = < M4U_PORT_MDP_RDMA0>;
mediatek,larb = <>;
+   mediatek,vpu = <>;
};
 
mdp_rdma1: rdma@14002000 {
@@ -106,4 +101,3 @@ mdp {
iommus = < M4U_PORT_MDP_WROT1>;
mediatek,larb = <>;
};
-};
-- 
1.9.1



[PATCH 3/3] media: mtk-mdp: Fix mdp device tree

2017-05-11 Thread Minghsiu Tsai
From: Daniel Kurtz <djku...@chromium.org>

If the mdp_* nodes are under an mdp sub-node, their corresponding
platform device does not automatically get its iommu assigned properly.

Fix this by moving the mdp component nodes up a level such that they are
siblings of mdp and all other SoC subsystems.  This also simplifies the
device tree.

Although it fixes iommu assignment issue, it also break compatibility
with old device tree. So, the patch in driver is needed to iterate over
sibling mdp device nodes, not child ones, to keep driver work properly.

Signed-off-by: Daniel Kurtz <djku...@chromium.org>
Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>

---
 drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c 
b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
index 9e4eb7d..a5ad586 100644
--- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
@@ -118,7 +118,7 @@ static int mtk_mdp_probe(struct platform_device *pdev)
mutex_init(>vpulock);
 
/* Iterate over sibling MDP function blocks */
-   for_each_child_of_node(dev->of_node, node) {
+   for_each_child_of_node(dev->of_node->parent, node) {
const struct of_device_id *of_id;
enum mtk_mdp_comp_type comp_type;
int comp_id;
-- 
1.9.1



[PATCH v2 0/3] Fix mdp device tree

2017-05-11 Thread Minghsiu Tsai
If the mdp_* nodes are under an mdp sub-node, their corresponding
platform device does not automatically get its iommu assigned properly.

Fix this by moving the mdp component nodes up a level such that they are
siblings of mdp and all other SoC subsystems.  This also simplifies the
device tree.

Although it fixes iommu assignment issue, it also break compatibility
with old device tree. So, the patch in driver is needed to iterate over
sibling mdp device nodes, not child ones, to keep driver work properly.

Daniel Kurtz (2):
  arm64: dts: mt8173: Fix mdp device tree
  media: mtk-mdp: Fix mdp device tree

Minghsiu Tsai (1):
  dt-bindings: mt8173: Fix mdp device tree

 .../devicetree/bindings/media/mediatek-mdp.txt |  12 +-
 arch/arm64/boot/dts/mediatek/mt8173.dtsi   | 126 ++---
 drivers/media/platform/mtk-mdp/mtk_mdp_core.c  |   2 +-
 3 files changed, 64 insertions(+), 76 deletions(-)

-- 
1.9.1



[PATCH 2/3] arm64: dts: mt8173: Fix mdp device tree

2017-05-11 Thread Minghsiu Tsai
From: Daniel Kurtz <djku...@chromium.org>

If the mdp_* nodes are under an mdp sub-node, their corresponding
platform device does not automatically get its iommu assigned properly.

Fix this by moving the mdp component nodes up a level such that they are
siblings of mdp and all other SoC subsystems.  This also simplifies the
device tree.

Although it fixes iommu assignment issue, it also break compatibility
with old device tree. So, the patch in driver is needed to iterate over
sibling mdp device nodes, not child ones, to keep driver work properly.

Signed-off-by: Daniel Kurtz <djku...@chromium.org>
Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>

---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi | 126 +++
 1 file changed, 60 insertions(+), 66 deletions(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 6922252..d28a363 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -792,80 +792,74 @@
#clock-cells = <1>;
};
 
-   mdp {
-   compatible = "mediatek,mt8173-mdp";
-   #address-cells = <2>;
-   #size-cells = <2>;
-   ranges;
+   mdp_rdma0: rdma@14001000 {
+   compatible = "mediatek,mt8173-mdp-rdma",
+"mediatek,mt8173-mdp";
+   reg = <0 0x14001000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA0>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA0>;
+   mediatek,larb = <>;
mediatek,vpu = <>;
+   };
 
-   mdp_rdma0: rdma@14001000 {
-   compatible = "mediatek,mt8173-mdp-rdma";
-   reg = <0 0x14001000 0 0x1000>;
-   clocks = < CLK_MM_MDP_RDMA0>,
-< CLK_MM_MUTEX_32K>;
-   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
-   iommus = < M4U_PORT_MDP_RDMA0>;
-   mediatek,larb = <>;
-   };
-
-   mdp_rdma1: rdma@14002000 {
-   compatible = "mediatek,mt8173-mdp-rdma";
-   reg = <0 0x14002000 0 0x1000>;
-   clocks = < CLK_MM_MDP_RDMA1>,
-< CLK_MM_MUTEX_32K>;
-   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
-   iommus = < M4U_PORT_MDP_RDMA1>;
-   mediatek,larb = <>;
-   };
+   mdp_rdma1: rdma@14002000 {
+   compatible = "mediatek,mt8173-mdp-rdma";
+   reg = <0 0x14002000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA1>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA1>;
+   mediatek,larb = <>;
+   };
 
-   mdp_rsz0: rsz@14003000 {
-   compatible = "mediatek,mt8173-mdp-rsz";
-   reg = <0 0x14003000 0 0x1000>;
-   clocks = < CLK_MM_MDP_RSZ0>;
-   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
-   };
+   mdp_rsz0: rsz@14003000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14003000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ0>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
 
-   mdp_rsz1: rsz@14004000 {
-   compatible = "mediatek,mt8173-mdp-rsz";
-   reg = <0 0x14004000 0 0x1000>;
-   clocks = < CLK_MM_MDP_RSZ1>;
-   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
-   };
+   mdp_rsz1: rsz@14004000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14004000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ1>;
+   po

[PATCH v2] [media] mtk-mdp: Fix g_/s_selection capture/compose logic

2017-05-11 Thread Minghsiu Tsai
From: Daniel Kurtz <djku...@chromium.org>

Experiments show that the:
 (1) mtk-mdp uses the _MPLANE form of CAPTURE/OUTPUT
 (2) CAPTURE types use CROP targets, and OUTPUT types use COMPOSE targets

Signed-off-by: Daniel Kurtz <djku...@chromium.org>
Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
Signed-off-by: Houlong Wei <houlong@mediatek.com>

---
Changes in v2:
. Can not use *_MPLANE type in g_/s_selection 
---
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c 
b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
index 13afe48..e18ac626 100644
--- a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
@@ -838,10 +838,10 @@ static int mtk_mdp_m2m_g_selection(struct file *file, 
void *fh,
bool valid = false;
 
if (s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
-   if (mtk_mdp_is_target_compose(s->target))
+   if (mtk_mdp_is_target_crop(s->target))
valid = true;
} else if (s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
-   if (mtk_mdp_is_target_crop(s->target))
+   if (mtk_mdp_is_target_compose(s->target))
valid = true;
}
if (!valid) {
@@ -908,10 +908,10 @@ static int mtk_mdp_m2m_s_selection(struct file *file, 
void *fh,
bool valid = false;
 
if (s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
-   if (s->target == V4L2_SEL_TGT_COMPOSE)
+   if (s->target == V4L2_SEL_TGT_CROP)
valid = true;
} else if (s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
-   if (s->target == V4L2_SEL_TGT_CROP)
+   if (s->target == V4L2_SEL_TGT_COMPOSE)
valid = true;
}
if (!valid) {
@@ -925,7 +925,7 @@ static int mtk_mdp_m2m_s_selection(struct file *file, void 
*fh,
if (ret)
return ret;
 
-   if (mtk_mdp_is_target_crop(s->target))
+   if (mtk_mdp_is_target_compose(s->target))
frame = >s_frame;
else
frame = >d_frame;
-- 
1.9.1



Re: [PATCH 1/3] dt-bindings: mt8173: Fix mdp device tree

2017-04-20 Thread Minghsiu Tsai
On Wed, 2017-04-19 at 16:35 -0500, Rob Herring wrote:
> On Thu, Apr 13, 2017 at 03:33:05PM +0800, Minghsiu Tsai wrote:
> > If the mdp_* nodes are under an mdp sub-node, their corresponding
> > platform device does not automatically get its iommu assigned properly.
> > 
> > Fix this by moving the mdp component nodes up a level such that they are
> > siblings of mdp and all other SoC subsystems.  This also simplifies the
> > device tree.
> 
> It may simplify the DT, but it also breaks compatibility with old DT. 
> Not sure if that's a problem on Mediatek platforms, but please be 
> explicit here that you are breaking compatibility and why that is okay.
> 

I will add the following description for more information.
"
Although it fixes iommu assignment issue, it also break compatibility
with old device tree, so driver patch[1] is needed to iterate over
sibling mdp device nodes, not child ones, to keep driver work properly.
In mtk_mdp_probe()
Old: for_each_child_of_node(dev->of_node, node)
New: for_each_child_of_node(dev->of_node->parent, node)

[1]https://patchwork.kernel.org/patch/9678833/
"

> > 
> > Signed-off-by: Daniel Kurtz <djku...@chromium.org>
> > Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
> 
> Should this have Daniel as the author?

This patch is provided by Daniel, so I keep he is the author.
I just split his patch into two parts. One is dts only, and the other is
for driver. I also provide another patch to modify dts bindings
according to this patch.


> 
> > 
> > ---
> >  Documentation/devicetree/bindings/media/mediatek-mdp.txt | 12 +++-
> >  1 file changed, 3 insertions(+), 9 deletions(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/media/mediatek-mdp.txt 
> > b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
> > index 4182063..0d03e3a 100644
> > --- a/Documentation/devicetree/bindings/media/mediatek-mdp.txt
> > +++ b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
> > @@ -2,7 +2,7 @@
> >  
> >  Media Data Path is used for scaling and color space conversion.
> >  
> > -Required properties (controller (parent) node):
> > +Required properties (controller node):
> >  - compatible: "mediatek,mt8173-mdp"
> >  - mediatek,vpu: the node of video processor unit, see
> >Documentation/devicetree/bindings/media/mediatek-vpu.txt for details.
> > @@ -32,21 +32,16 @@ Required properties (DMA function blocks, child node):
> >for details.
> >  
> >  Example:
> > -mdp {
> > -   compatible = "mediatek,mt8173-mdp";
> > -   #address-cells = <2>;
> > -   #size-cells = <2>;
> > -   ranges;
> > -   mediatek,vpu = <>;
> > -
> > mdp_rdma0: rdma@14001000 {
> > compatible = "mediatek,mt8173-mdp-rdma";
> > +"mediatek,mt8173-mdp";
> > reg = <0 0x14001000 0 0x1000>;
> > clocks = < CLK_MM_MDP_RDMA0>,
> >  < CLK_MM_MUTEX_32K>;
> > power-domains = < MT8173_POWER_DOMAIN_MM>;
> > iommus = < M4U_PORT_MDP_RDMA0>;
> > mediatek,larb = <>;
> > +   mediatek,vpu = <>;
> > };
> >  
> > mdp_rdma1: rdma@14002000 {
> > @@ -106,4 +101,3 @@ mdp {
> > iommus = < M4U_PORT_MDP_WROT1>;
> > mediatek,larb = <>;
> > };
> > -};
> > -- 
> > 1.9.1
> > 




[PATCH 1/3] dt-bindings: mt8173: Fix mdp device tree

2017-04-13 Thread Minghsiu Tsai
If the mdp_* nodes are under an mdp sub-node, their corresponding
platform device does not automatically get its iommu assigned properly.

Fix this by moving the mdp component nodes up a level such that they are
siblings of mdp and all other SoC subsystems.  This also simplifies the
device tree.

Signed-off-by: Daniel Kurtz <djku...@chromium.org>
Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>

---
 Documentation/devicetree/bindings/media/mediatek-mdp.txt | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/Documentation/devicetree/bindings/media/mediatek-mdp.txt 
b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
index 4182063..0d03e3a 100644
--- a/Documentation/devicetree/bindings/media/mediatek-mdp.txt
+++ b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
@@ -2,7 +2,7 @@
 
 Media Data Path is used for scaling and color space conversion.
 
-Required properties (controller (parent) node):
+Required properties (controller node):
 - compatible: "mediatek,mt8173-mdp"
 - mediatek,vpu: the node of video processor unit, see
   Documentation/devicetree/bindings/media/mediatek-vpu.txt for details.
@@ -32,21 +32,16 @@ Required properties (DMA function blocks, child node):
   for details.
 
 Example:
-mdp {
-   compatible = "mediatek,mt8173-mdp";
-   #address-cells = <2>;
-   #size-cells = <2>;
-   ranges;
-   mediatek,vpu = <>;
-
mdp_rdma0: rdma@14001000 {
compatible = "mediatek,mt8173-mdp-rdma";
+"mediatek,mt8173-mdp";
reg = <0 0x14001000 0 0x1000>;
clocks = < CLK_MM_MDP_RDMA0>,
 < CLK_MM_MUTEX_32K>;
power-domains = < MT8173_POWER_DOMAIN_MM>;
iommus = < M4U_PORT_MDP_RDMA0>;
mediatek,larb = <>;
+   mediatek,vpu = <>;
};
 
mdp_rdma1: rdma@14002000 {
@@ -106,4 +101,3 @@ mdp {
iommus = < M4U_PORT_MDP_WROT1>;
mediatek,larb = <>;
};
-};
-- 
1.9.1



[PATCH 0/3] Fix mdp device tree

2017-04-13 Thread Minghsiu Tsai
Fix this by moving the mdp component nodes up a level such that they are
siblings of mdp and all other SoC subsystems.  This also simplifies the
device tree.

Daniel Kurtz (2):
  arm64: dts: mt8173: Fix mdp device tree
  media: mtk-mdp: Fix mdp device tree

Minghsiu Tsai (1):
  dt-bindings: mt8173: Fix mdp device tree

 .../devicetree/bindings/media/mediatek-mdp.txt |  12 +-
 arch/arm64/boot/dts/mediatek/mt8173.dtsi   | 126 ++---
 drivers/media/platform/mtk-mdp/mtk_mdp_core.c  |   2 +-
 3 files changed, 64 insertions(+), 76 deletions(-)

-- 
1.9.1



[PATCH 2/3] arm64: dts: mt8173: Fix mdp device tree

2017-04-13 Thread Minghsiu Tsai
From: Daniel Kurtz <djku...@chromium.org>

If the mdp_* nodes are under an mdp sub-node, their corresponding
platform device does not automatically get its iommu assigned properly.

Fix this by moving the mdp component nodes up a level such that they are
siblings of mdp and all other SoC subsystems.  This also simplifies the
device tree.

Signed-off-by: Daniel Kurtz <djku...@chromium.org>
Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>

---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi | 126 +++
 1 file changed, 60 insertions(+), 66 deletions(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 6922252..d28a363 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -792,80 +792,74 @@
#clock-cells = <1>;
};
 
-   mdp {
-   compatible = "mediatek,mt8173-mdp";
-   #address-cells = <2>;
-   #size-cells = <2>;
-   ranges;
+   mdp_rdma0: rdma@14001000 {
+   compatible = "mediatek,mt8173-mdp-rdma",
+"mediatek,mt8173-mdp";
+   reg = <0 0x14001000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA0>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA0>;
+   mediatek,larb = <>;
mediatek,vpu = <>;
+   };
 
-   mdp_rdma0: rdma@14001000 {
-   compatible = "mediatek,mt8173-mdp-rdma";
-   reg = <0 0x14001000 0 0x1000>;
-   clocks = < CLK_MM_MDP_RDMA0>,
-< CLK_MM_MUTEX_32K>;
-   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
-   iommus = < M4U_PORT_MDP_RDMA0>;
-   mediatek,larb = <>;
-   };
-
-   mdp_rdma1: rdma@14002000 {
-   compatible = "mediatek,mt8173-mdp-rdma";
-   reg = <0 0x14002000 0 0x1000>;
-   clocks = < CLK_MM_MDP_RDMA1>,
-< CLK_MM_MUTEX_32K>;
-   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
-   iommus = < M4U_PORT_MDP_RDMA1>;
-   mediatek,larb = <>;
-   };
+   mdp_rdma1: rdma@14002000 {
+   compatible = "mediatek,mt8173-mdp-rdma";
+   reg = <0 0x14002000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA1>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA1>;
+   mediatek,larb = <>;
+   };
 
-   mdp_rsz0: rsz@14003000 {
-   compatible = "mediatek,mt8173-mdp-rsz";
-   reg = <0 0x14003000 0 0x1000>;
-   clocks = < CLK_MM_MDP_RSZ0>;
-   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
-   };
+   mdp_rsz0: rsz@14003000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14003000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ0>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
 
-   mdp_rsz1: rsz@14004000 {
-   compatible = "mediatek,mt8173-mdp-rsz";
-   reg = <0 0x14004000 0 0x1000>;
-   clocks = < CLK_MM_MDP_RSZ1>;
-   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
-   };
+   mdp_rsz1: rsz@14004000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14004000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ1>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
 
-   mdp_rsz2: rsz@14005000 {
-   compatible = "mediatek,mt8173-mdp-rsz";
-   

[PATCH 3/3] media: mtk-mdp: Fix mdp device tree

2017-04-13 Thread Minghsiu Tsai
From: Daniel Kurtz <djku...@chromium.org>

If the mdp_* nodes are under an mdp sub-node, their corresponding
platform device does not automatically get its iommu assigned properly.

Fix this by moving the mdp component nodes up a level such that they are
siblings of mdp and all other SoC subsystems.  This also simplifies the
device tree.

Signed-off-by: Daniel Kurtz <djku...@chromium.org>
Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>

---
 drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c 
b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
index 9e4eb7d..a5ad586 100644
--- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
@@ -118,7 +118,7 @@ static int mtk_mdp_probe(struct platform_device *pdev)
mutex_init(>vpulock);
 
/* Iterate over sibling MDP function blocks */
-   for_each_child_of_node(dev->of_node, node) {
+   for_each_child_of_node(dev->of_node->parent, node) {
const struct of_device_id *of_id;
enum mtk_mdp_comp_type comp_type;
int comp_id;
-- 
1.9.1



[PATCH] [media] mtk-mdp: Fix g_/s_selection capture/compose logic

2017-04-12 Thread Minghsiu Tsai
From: Daniel Kurtz <djku...@chromium.org>

Experiments show that the:
 (1) mtk-mdp uses the _MPLANE form of CAPTURE/OUTPUT
 (2) CAPTURE types use CROP targets, and OUTPUT types use COMPOSE targets

Signed-off-by: Daniel Kurtz <djku...@chromium.org>
Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>

---
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c 
b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
index 13afe48..8ab7ca0 100644
--- a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
@@ -837,12 +837,12 @@ static int mtk_mdp_m2m_g_selection(struct file *file, 
void *fh,
struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
bool valid = false;
 
-   if (s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
-   if (mtk_mdp_is_target_compose(s->target))
-   valid = true;
-   } else if (s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
+   if (s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
if (mtk_mdp_is_target_crop(s->target))
valid = true;
+   } else if (s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
+   if (mtk_mdp_is_target_compose(s->target))
+   valid = true;
}
if (!valid) {
mtk_mdp_dbg(1, "[%d] invalid type:%d,%u", ctx->id, s->type,
@@ -907,12 +907,12 @@ static int mtk_mdp_m2m_s_selection(struct file *file, 
void *fh,
int ret;
bool valid = false;
 
-   if (s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
-   if (s->target == V4L2_SEL_TGT_COMPOSE)
-   valid = true;
-   } else if (s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
+   if (s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
if (s->target == V4L2_SEL_TGT_CROP)
valid = true;
+   } else if (s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
+   if (s->target == V4L2_SEL_TGT_COMPOSE)
+   valid = true;
}
if (!valid) {
mtk_mdp_dbg(1, "[%d] invalid type:%d,%u", ctx->id, s->type,
@@ -925,7 +925,7 @@ static int mtk_mdp_m2m_s_selection(struct file *file, void 
*fh,
if (ret)
return ret;
 
-   if (mtk_mdp_is_target_crop(s->target))
+   if (mtk_mdp_is_target_compose(s->target))
frame = >s_frame;
else
frame = >d_frame;
-- 
1.9.1



[PATCH] media: mtk-vcodec: remove informative log

2017-04-05 Thread Minghsiu Tsai
Driver is stable. Remove DEBUG definition from driver.

There are debug message in /var/log/messages if DEBUG is defined,
such as:
[MTK_V4L2] level=0 fops_vcodec_open(),170: decoder capability 0
[MTK_V4L2] level=0 fops_vcodec_open(),177: 1600.vcodec decoder [0]
[MTK_V4L2] level=0 fops_vcodec_release(),200: [0] decoder

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
index 7d55975..1248083 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
@@ -31,7 +31,6 @@ struct mtk_vcodec_mem {
 extern int mtk_v4l2_dbg_level;
 extern bool mtk_vcodec_dbg;
 
-#define DEBUG  1
 
 #if defined(DEBUG)
 
-- 
1.9.1



[PATCH] media: mtk-jpeg: fix continuous log "Context is NULL"

2017-03-14 Thread Minghsiu Tsai
The symptom is continuous log "mtk-jpeg 18004000.jpegdec: Context is NULL"
in kernel log. It is becauese the error handling in irq doesn't clear
interrupt.

The calling flow like as below when issue happen
mtk_jpeg_device_run()
mtk_jpeg_job_abort()
  v4l2_m2m_job_finish() -> m2m_dev->curr_ctx = NULL;
mtk_jpeg_dec_irq()
  v4l2_m2m_get_curr_priv()
 -> m2m_dev->curr_ctx == NULL
 -> return NULL
log "Context is NULL"

There is race condition between job_abort() and irq. In order to simplify
code, don't want to add extra flag to maintain state, empty job_abort() and
clear interrupt before v4l2_m2m_get_curr_priv() in irq.

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c | 14 ++
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c 
b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
index b10183f..c02bc7f 100644
--- a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
+++ b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
@@ -862,15 +862,6 @@ static int mtk_jpeg_job_ready(void *priv)
 
 static void mtk_jpeg_job_abort(void *priv)
 {
-   struct mtk_jpeg_ctx *ctx = priv;
-   struct mtk_jpeg_dev *jpeg = ctx->jpeg;
-   struct vb2_buffer *src_buf, *dst_buf;
-
-   src_buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
-   dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
-   v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf), VB2_BUF_STATE_ERROR);
-   v4l2_m2m_buf_done(to_vb2_v4l2_buffer(dst_buf), VB2_BUF_STATE_ERROR);
-   v4l2_m2m_job_finish(jpeg->m2m_dev, ctx->fh.m2m_ctx);
 }
 
 static struct v4l2_m2m_ops mtk_jpeg_m2m_ops = {
@@ -941,6 +932,8 @@ static irqreturn_t mtk_jpeg_dec_irq(int irq, void *priv)
u32 dec_ret;
int i;
 
+   dec_ret = mtk_jpeg_dec_get_int_status(jpeg->dec_reg_base);
+   dec_irq_ret = mtk_jpeg_dec_enum_result(dec_ret);
ctx = v4l2_m2m_get_curr_priv(jpeg->m2m_dev);
if (!ctx) {
v4l2_err(>v4l2_dev, "Context is NULL\n");
@@ -951,9 +944,6 @@ static irqreturn_t mtk_jpeg_dec_irq(int irq, void *priv)
dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
jpeg_src_buf = mtk_jpeg_vb2_to_srcbuf(src_buf);
 
-   dec_ret = mtk_jpeg_dec_get_int_status(jpeg->dec_reg_base);
-   dec_irq_ret = mtk_jpeg_dec_enum_result(dec_ret);
-
if (dec_irq_ret >= MTK_JPEG_DEC_RESULT_UNDERFLOW)
mtk_jpeg_dec_reset(jpeg->dec_reg_base);
 
-- 
1.9.1



[PATCH v2] [media] mtk-vcodec: fix build errors without DEBUG

2017-02-07 Thread Minghsiu Tsai
After removing DEBUG from mtk_vcodec_util.h, some build errors are
generated as the following:
.../drivers/media/platform/mtk-vcodec/vdec_vpu_if.c: In function 
'vcodec_vpu_send_msg':
.../drivers/media/platform/mtk-vcodec/vdec_vpu_if.c:73:11: warning: unused 
variable 'msg_id' [-Wunused-variable]
  uint32_t msg_id = *(uint32_t *)msg;
   ^
.../drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c: In function 
'vb2ops_vdec_buf_queue':
.../drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c:1129:7: warning: unused 
variable 'log_level' [-Wunused-variable]
   int log_level = ret ? 0 : 1;
   ^
.../drivers/media/platform/mtk-vcodec/venc_vpu_if.c: In function 
'vpu_enc_send_msg':
.../drivers/media/platform/mtk-vcodec/venc_vpu_if.c:82:12: warning: unused 
variable 'msg_id' [-Wunused-variable]
   uint32_t msg_id = *(uint32_t *)msg;
^

It is because mtk_vcodec_debug() and mtk_vcodec_err() are defined as empty
macros. Without DEBUG definition, the variable for debugging is not used
anymore. Fixing build errors is just by moving the assignment of the
variable to the argument of mtk_vcodec_debug() and mtk_vcodec_err().
Within the patch, build pass with/without DEBUG definition, and functions
still work fine.

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
Reviewed-by: Daniel Kurtz <djku...@chromium.org>
---
Changes in v2:
. Update commit message
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 9 -
 drivers/media/platform/mtk-vcodec/vdec_vpu_if.c| 5 ++---
 drivers/media/platform/mtk-vcodec/venc_vpu_if.c| 4 +---
 3 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
index 0746592..6219c7d 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
@@ -1126,15 +1126,14 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer *vb)
 * if there is no SPS header or picture info
 * in bs
 */
-   int log_level = ret ? 0 : 1;
 
src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf),
VB2_BUF_STATE_DONE);
-   mtk_v4l2_debug(log_level,
-   "[%d] vdec_if_decode() src_buf=%d, size=%zu, 
fail=%d, res_chg=%d",
-   ctx->id, src_buf->index,
-   src_mem.size, ret, res_chg);
+   mtk_v4l2_debug(ret ? 0 : 1,
+  "[%d] vdec_if_decode() src_buf=%d, size=%zu, 
fail=%d, res_chg=%d",
+  ctx->id, src_buf->index,
+  src_mem.size, ret, res_chg);
return;
}
 
diff --git a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c 
b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
index 5a24c51..1abd14e 100644
--- a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
@@ -70,9 +70,8 @@ void vpu_dec_ipi_handler(void *data, unsigned int len, void 
*priv)
 static int vcodec_vpu_send_msg(struct vdec_vpu_inst *vpu, void *msg, int len)
 {
int err;
-   uint32_t msg_id = *(uint32_t *)msg;
 
-   mtk_vcodec_debug(vpu, "id=%X", msg_id);
+   mtk_vcodec_debug(vpu, "id=%X", *(uint32_t *)msg);
 
vpu->failure = 0;
vpu->signaled = 0;
@@ -80,7 +79,7 @@ static int vcodec_vpu_send_msg(struct vdec_vpu_inst *vpu, 
void *msg, int len)
err = vpu_ipi_send(vpu->dev, vpu->id, msg, len);
if (err) {
mtk_vcodec_err(vpu, "send fail vpu_id=%d msg_id=%X status=%d",
-  vpu->id, msg_id, err);
+  vpu->id, *(uint32_t *)msg, err);
return err;
}
 
diff --git a/drivers/media/platform/mtk-vcodec/venc_vpu_if.c 
b/drivers/media/platform/mtk-vcodec/venc_vpu_if.c
index a01c759..0d882ac 100644
--- a/drivers/media/platform/mtk-vcodec/venc_vpu_if.c
+++ b/drivers/media/platform/mtk-vcodec/venc_vpu_if.c
@@ -79,10 +79,8 @@ static int vpu_enc_send_msg(struct venc_vpu_inst *vpu, void 
*msg,
 
status = vpu_ipi_send(vpu->dev, vpu->id, msg, len);
if (status) {
-   uint32_t msg_id = *(uint32_t *)msg;
-
mtk_vcodec_err(vpu, "vpu_ipi_send msg_id %x len %d fail %d",
-  msg_id, len, status);
+  *(uint32_t *)msg, len, status);
return -EINVAL;
}
if (vpu->failure)
-- 
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] [media] mtk-vcodec: fix build errors without DEBUG

2017-02-07 Thread Minghsiu Tsai
On Tue, 2017-02-07 at 20:17 +0800, Daniel Kurtz wrote:
> On Tue, Feb 7, 2017 at 3:40 PM, Minghsiu Tsai
> <minghsiu.t...@mediatek.com> wrote:
> > Fix build errors after removing DEBUG definition.
> 
> It would be useful to specify which build errors were fixed by this
> patch, and a brief description of why - namely because when DEBUG is
> not defined, mtk_v4l2_debug() is an empty macros, and therefore the
> arguments are unused.
> 
> With an updated commit message, this patch is:
> 
> Reviewed-by: Daniel Kurtz <djku...@chromium.org>
> 

Hi Daniel,
Thanks for your review and comment. I will update it soon.

> >
> > Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
> > ---
> >  drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 9 -
> >  drivers/media/platform/mtk-vcodec/vdec_vpu_if.c| 5 ++---
> >  drivers/media/platform/mtk-vcodec/venc_vpu_if.c| 4 +---
> >  3 files changed, 7 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
> > b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> > index 0746592..6219c7d 100644
> > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
> > @@ -1126,15 +1126,14 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer 
> > *vb)
> >  * if there is no SPS header or picture info
> >  * in bs
> >  */
> > -   int log_level = ret ? 0 : 1;
> >
> > src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
> > v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf),
> > VB2_BUF_STATE_DONE);
> > -   mtk_v4l2_debug(log_level,
> > -   "[%d] vdec_if_decode() src_buf=%d, 
> > size=%zu, fail=%d, res_chg=%d",
> > -   ctx->id, src_buf->index,
> > -   src_mem.size, ret, res_chg);
> > +   mtk_v4l2_debug(ret ? 0 : 1,
> > +  "[%d] vdec_if_decode() src_buf=%d, size=%zu, 
> > fail=%d, res_chg=%d",
> > +  ctx->id, src_buf->index,
> > +  src_mem.size, ret, res_chg);
> > return;
> > }
> >
> > diff --git a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c 
> > b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
> > index 5a24c51..1abd14e 100644
> > --- a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
> > +++ b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
> > @@ -70,9 +70,8 @@ void vpu_dec_ipi_handler(void *data, unsigned int len, 
> > void *priv)
> >  static int vcodec_vpu_send_msg(struct vdec_vpu_inst *vpu, void *msg, int 
> > len)
> >  {
> > int err;
> > -   uint32_t msg_id = *(uint32_t *)msg;
> >
> > -   mtk_vcodec_debug(vpu, "id=%X", msg_id);
> > +   mtk_vcodec_debug(vpu, "id=%X", *(uint32_t *)msg);
> >
> > vpu->failure = 0;
> > vpu->signaled = 0;
> > @@ -80,7 +79,7 @@ static int vcodec_vpu_send_msg(struct vdec_vpu_inst *vpu, 
> > void *msg, int len)
> > err = vpu_ipi_send(vpu->dev, vpu->id, msg, len);
> > if (err) {
> > mtk_vcodec_err(vpu, "send fail vpu_id=%d msg_id=%X 
> > status=%d",
> > -  vpu->id, msg_id, err);
> > +  vpu->id, *(uint32_t *)msg, err);
> > return err;
> > }
> >
> > diff --git a/drivers/media/platform/mtk-vcodec/venc_vpu_if.c 
> > b/drivers/media/platform/mtk-vcodec/venc_vpu_if.c
> > index a01c759..0d882ac 100644
> > --- a/drivers/media/platform/mtk-vcodec/venc_vpu_if.c
> > +++ b/drivers/media/platform/mtk-vcodec/venc_vpu_if.c
> > @@ -79,10 +79,8 @@ static int vpu_enc_send_msg(struct venc_vpu_inst *vpu, 
> > void *msg,
> >
> > status = vpu_ipi_send(vpu->dev, vpu->id, msg, len);
> > if (status) {
> > -   uint32_t msg_id = *(uint32_t *)msg;
> > -
> > mtk_vcodec_err(vpu, "vpu_ipi_send msg_id %x len %d fail %d",
> > -  msg_id, len, status);
> > +  *(uint32_t *)msg, len, status);
> > return -EINVAL;
> > }
> > if (vpu->failure)
> > --
> > 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] [media] mtk-vcodec: fix build errors without DEBUG

2017-02-06 Thread Minghsiu Tsai
Fix build errors after removing DEBUG definition.

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 9 -
 drivers/media/platform/mtk-vcodec/vdec_vpu_if.c| 5 ++---
 drivers/media/platform/mtk-vcodec/venc_vpu_if.c| 4 +---
 3 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
index 0746592..6219c7d 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
@@ -1126,15 +1126,14 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer *vb)
 * if there is no SPS header or picture info
 * in bs
 */
-   int log_level = ret ? 0 : 1;
 
src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf),
VB2_BUF_STATE_DONE);
-   mtk_v4l2_debug(log_level,
-   "[%d] vdec_if_decode() src_buf=%d, size=%zu, 
fail=%d, res_chg=%d",
-   ctx->id, src_buf->index,
-   src_mem.size, ret, res_chg);
+   mtk_v4l2_debug(ret ? 0 : 1,
+  "[%d] vdec_if_decode() src_buf=%d, size=%zu, 
fail=%d, res_chg=%d",
+  ctx->id, src_buf->index,
+  src_mem.size, ret, res_chg);
return;
}
 
diff --git a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c 
b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
index 5a24c51..1abd14e 100644
--- a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
@@ -70,9 +70,8 @@ void vpu_dec_ipi_handler(void *data, unsigned int len, void 
*priv)
 static int vcodec_vpu_send_msg(struct vdec_vpu_inst *vpu, void *msg, int len)
 {
int err;
-   uint32_t msg_id = *(uint32_t *)msg;
 
-   mtk_vcodec_debug(vpu, "id=%X", msg_id);
+   mtk_vcodec_debug(vpu, "id=%X", *(uint32_t *)msg);
 
vpu->failure = 0;
vpu->signaled = 0;
@@ -80,7 +79,7 @@ static int vcodec_vpu_send_msg(struct vdec_vpu_inst *vpu, 
void *msg, int len)
err = vpu_ipi_send(vpu->dev, vpu->id, msg, len);
if (err) {
mtk_vcodec_err(vpu, "send fail vpu_id=%d msg_id=%X status=%d",
-  vpu->id, msg_id, err);
+  vpu->id, *(uint32_t *)msg, err);
return err;
}
 
diff --git a/drivers/media/platform/mtk-vcodec/venc_vpu_if.c 
b/drivers/media/platform/mtk-vcodec/venc_vpu_if.c
index a01c759..0d882ac 100644
--- a/drivers/media/platform/mtk-vcodec/venc_vpu_if.c
+++ b/drivers/media/platform/mtk-vcodec/venc_vpu_if.c
@@ -79,10 +79,8 @@ static int vpu_enc_send_msg(struct venc_vpu_inst *vpu, void 
*msg,
 
status = vpu_ipi_send(vpu->dev, vpu->id, msg, len);
if (status) {
-   uint32_t msg_id = *(uint32_t *)msg;
-
mtk_vcodec_err(vpu, "vpu_ipi_send msg_id %x len %d fail %d",
-  msg_id, len, status);
+  *(uint32_t *)msg, len, status);
return -EINVAL;
}
if (vpu->failure)
-- 
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] [media] mtk-mdp: allocate video_device dynamically

2016-11-14 Thread Minghsiu Tsai
On Fri, 2016-11-11 at 11:51 +0100, Hans Verkuil wrote:
> Almost correct:
> 
> On 11/07/2016 01:42 PM, Minghsiu Tsai wrote:
> > It can fix known problems with embedded video_device structs.
> > 
> > Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
> > ---
> >  drivers/media/platform/mtk-mdp/mtk_mdp_core.h |  2 +-
> >  drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c  | 33 
> > ---
> >  2 files changed, 21 insertions(+), 14 deletions(-)
> > 
> > diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.h 
> > b/drivers/media/platform/mtk-mdp/mtk_mdp_core.h
> > index 848569d..ad1cff3 100644
> > --- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.h
> > +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.h
> > @@ -167,7 +167,7 @@ struct mtk_mdp_dev {
> > struct mtk_mdp_comp *comp[MTK_MDP_COMP_ID_MAX];
> > struct v4l2_m2m_dev *m2m_dev;
> > struct list_headctx_list;
> > -   struct video_device vdev;
> > +   struct video_device *vdev;
> > struct v4l2_device  v4l2_dev;
> > struct workqueue_struct *job_wq;
> > struct platform_device  *vpu_dev;
> > diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c 
> > b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
> > index 9a747e7..b8dee1c 100644
> > --- a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
> > +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
> > @@ -1236,16 +1236,22 @@ int mtk_mdp_register_m2m_device(struct mtk_mdp_dev 
> > *mdp)
> > int ret;
> >  
> > mdp->variant = _mdp_default_variant;
> > -   mdp->vdev.device_caps = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING;
> > -   mdp->vdev.fops = _mdp_m2m_fops;
> > -   mdp->vdev.ioctl_ops = _mdp_m2m_ioctl_ops;
> > -   mdp->vdev.release = video_device_release_empty;
> > -   mdp->vdev.lock = >lock;
> > -   mdp->vdev.vfl_dir = VFL_DIR_M2M;
> > -   mdp->vdev.v4l2_dev = >v4l2_dev;
> > -   snprintf(mdp->vdev.name, sizeof(mdp->vdev.name), "%s:m2m",
> > +   mdp->vdev = video_device_alloc();
> > +   if (!mdp->vdev) {
> > +   dev_err(dev, "failed to allocate video device\n");
> > +   ret = -ENOMEM;
> > +   goto err_video_alloc;
> > +   }
> > +   mdp->vdev->device_caps = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING;
> > +   mdp->vdev->fops = _mdp_m2m_fops;
> > +   mdp->vdev->ioctl_ops = _mdp_m2m_ioctl_ops;
> > +   mdp->vdev->release = video_device_release;
> > +   mdp->vdev->lock = >lock;
> > +   mdp->vdev->vfl_dir = VFL_DIR_M2M;
> > +   mdp->vdev->v4l2_dev = >v4l2_dev;
> > +   snprintf(mdp->vdev->name, sizeof(mdp->vdev->name), "%s:m2m",
> >  MTK_MDP_MODULE_NAME);
> > -   video_set_drvdata(>vdev, mdp);
> > +   video_set_drvdata(mdp->vdev, mdp);
> >  
> > mdp->m2m_dev = v4l2_m2m_init(_mdp_m2m_ops);
> > if (IS_ERR(mdp->m2m_dev)) {
> > @@ -1254,26 +1260,27 @@ int mtk_mdp_register_m2m_device(struct mtk_mdp_dev 
> > *mdp)
> > goto err_m2m_init;
> > }
> >  
> > -   ret = video_register_device(>vdev, VFL_TYPE_GRABBER, 2);
> > +   ret = video_register_device(mdp->vdev, VFL_TYPE_GRABBER, 2);
> > if (ret) {
> > dev_err(dev, "failed to register video device\n");
> > goto err_vdev_register;
> > }
> >  
> > v4l2_info(>v4l2_dev, "driver registered as /dev/video%d",
> > - mdp->vdev.num);
> > + mdp->vdev->num);
> > return 0;
> >  
> >  err_vdev_register:
> > v4l2_m2m_release(mdp->m2m_dev);
> >  err_m2m_init:
> > -   video_device_release(>vdev);
> > +   video_unregister_device(mdp->vdev);
> 
> This should remain video_device_release: the video_register_device call 
> failed, so
> the device hasn't been registered. In that case just release the device (i.e.
> free the allocated memory).
> 
Hi Hans,

I have uploaded patch v2 for this. Thanks for your review.


Best regards,
Ming Hsiu

> > +err_video_alloc:
> >  
> > return ret;
> >  }
> >  
> >  void mtk_mdp_unregister_m2m_device(struct mtk_mdp_dev *mdp)
> >  {
> > -   video_device_release(>vdev);
> > +   video_unregister_device(mdp->vdev);
> > v4l2_m2m_release(mdp->m2m_dev);
> >  }
> > 
> 
> Regards,
> 
>   Hans


--
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] [media] mtk-mdp: allocate video_device dynamically

2016-11-14 Thread Minghsiu Tsai
It can fix known problems with embedded video_device structs.

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>

---
Changes in v2:
. Call video_device_release() instead of video_unregister_device()
  in mtk_mdp_register_m2m_device()


---
 drivers/media/platform/mtk-mdp/mtk_mdp_core.h |  2 +-
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c  | 33 ---
 2 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.h 
b/drivers/media/platform/mtk-mdp/mtk_mdp_core.h
index 848569d..ad1cff3 100644
--- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.h
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.h
@@ -167,7 +167,7 @@ struct mtk_mdp_dev {
struct mtk_mdp_comp *comp[MTK_MDP_COMP_ID_MAX];
struct v4l2_m2m_dev *m2m_dev;
struct list_headctx_list;
-   struct video_device vdev;
+   struct video_device *vdev;
struct v4l2_device  v4l2_dev;
struct workqueue_struct *job_wq;
struct platform_device  *vpu_dev;
diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c 
b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
index 9a747e7..13afe48 100644
--- a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
@@ -1236,16 +1236,22 @@ int mtk_mdp_register_m2m_device(struct mtk_mdp_dev *mdp)
int ret;
 
mdp->variant = _mdp_default_variant;
-   mdp->vdev.device_caps = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING;
-   mdp->vdev.fops = _mdp_m2m_fops;
-   mdp->vdev.ioctl_ops = _mdp_m2m_ioctl_ops;
-   mdp->vdev.release = video_device_release_empty;
-   mdp->vdev.lock = >lock;
-   mdp->vdev.vfl_dir = VFL_DIR_M2M;
-   mdp->vdev.v4l2_dev = >v4l2_dev;
-   snprintf(mdp->vdev.name, sizeof(mdp->vdev.name), "%s:m2m",
+   mdp->vdev = video_device_alloc();
+   if (!mdp->vdev) {
+   dev_err(dev, "failed to allocate video device\n");
+   ret = -ENOMEM;
+   goto err_video_alloc;
+   }
+   mdp->vdev->device_caps = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING;
+   mdp->vdev->fops = _mdp_m2m_fops;
+   mdp->vdev->ioctl_ops = _mdp_m2m_ioctl_ops;
+   mdp->vdev->release = video_device_release;
+   mdp->vdev->lock = >lock;
+   mdp->vdev->vfl_dir = VFL_DIR_M2M;
+   mdp->vdev->v4l2_dev = >v4l2_dev;
+   snprintf(mdp->vdev->name, sizeof(mdp->vdev->name), "%s:m2m",
 MTK_MDP_MODULE_NAME);
-   video_set_drvdata(>vdev, mdp);
+   video_set_drvdata(mdp->vdev, mdp);
 
mdp->m2m_dev = v4l2_m2m_init(_mdp_m2m_ops);
if (IS_ERR(mdp->m2m_dev)) {
@@ -1254,26 +1260,27 @@ int mtk_mdp_register_m2m_device(struct mtk_mdp_dev *mdp)
goto err_m2m_init;
}
 
-   ret = video_register_device(>vdev, VFL_TYPE_GRABBER, 2);
+   ret = video_register_device(mdp->vdev, VFL_TYPE_GRABBER, 2);
if (ret) {
dev_err(dev, "failed to register video device\n");
goto err_vdev_register;
}
 
v4l2_info(>v4l2_dev, "driver registered as /dev/video%d",
- mdp->vdev.num);
+ mdp->vdev->num);
return 0;
 
 err_vdev_register:
v4l2_m2m_release(mdp->m2m_dev);
 err_m2m_init:
-   video_device_release(>vdev);
+   video_device_release(mdp->vdev);
+err_video_alloc:
 
return ret;
 }
 
 void mtk_mdp_unregister_m2m_device(struct mtk_mdp_dev *mdp)
 {
-   video_device_release(>vdev);
+   video_unregister_device(mdp->vdev);
v4l2_m2m_release(mdp->m2m_dev);
 }
-- 
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 next 1/2] media: mtk-mdp: fix video_device_release argument

2016-11-07 Thread Minghsiu Tsai
On Thu, 2016-11-03 at 13:47 +0100, Hans Verkuil wrote:
> Hi Vincent,
> 
> On 28/10/16 09:52, Vincent Stehlé wrote:
> > On Thu, Oct 27, 2016 at 10:23:24PM +0200, Vincent Stehlé wrote:
> >> video_device_release() takes a pointer to struct video_device as argument.
> >> Fix two call sites where the address of the pointer is passed instead.
> >
> > Sorry, I messed up: please ignore that "fix". The 0day robot made me
> > realize this is indeed not a proper fix.
> >
> > The issue remains, though: we cannot call video_device_release() on the
> > vdev structure member, as this will in turn call kfree(). Most probably,
> > vdev needs to be dynamically allocated, or the call to
> > video_device_release() dropped completely.
> 
> I prefer that vdev is dynamically allocated. There are known problems with
> embedded video_device structs, so allocating it is preferred.
> 
> Minghsiu, can you do that?
> 

Hi Hans,

I just send the patch for this.
https://patchwork.kernel.org/patch/9415007/


> Regards,
> 
>   Hans
> 
> >
> > Sorry for the bad patch.
> >
> > Best regards,
> >
> > Vincent.
> > --
> > 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: mtk-mdp: allocate video_device dynamically

2016-11-07 Thread Minghsiu Tsai
v4l2-compliance test output:
v4l2-compliance SHA   : abc1453dfe89f244dccd3460d8e1a2e3091cbadb

Driver Info:
Driver name   : mtk-mdp
Card type : soc:mdp
Bus info  : platform:mt8173
Driver version: 4.9.0
Capabilities  : 0x84204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format
Device Capabilities
Device Caps   : 0x04204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format

Compliance test for device /dev/image-proc0 (not using libv4l2):

Required ioctls:
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second video open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK

Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK (Not Supported)

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK (Not Supported)
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)

Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 5 Private Controls: 0

Format ioctls:
test 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
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK
test Composing: OK
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:


Total: 43, Succeeded: 43, Failed: 0, Warnings: 0

Minghsiu Tsai (1):
  [media] mtk-mdp: allocate video_device dynamically

 drivers/media/platform/mtk-mdp/mtk_mdp_core.h |  2 +-
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c  | 33 ---
 2 files changed, 21 insertions(+), 14 deletions(-)

-- 
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] [media] mtk-mdp: allocate video_device dynamically

2016-11-07 Thread Minghsiu Tsai
It can fix known problems with embedded video_device structs.

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 drivers/media/platform/mtk-mdp/mtk_mdp_core.h |  2 +-
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c  | 33 ---
 2 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.h 
b/drivers/media/platform/mtk-mdp/mtk_mdp_core.h
index 848569d..ad1cff3 100644
--- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.h
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.h
@@ -167,7 +167,7 @@ struct mtk_mdp_dev {
struct mtk_mdp_comp *comp[MTK_MDP_COMP_ID_MAX];
struct v4l2_m2m_dev *m2m_dev;
struct list_headctx_list;
-   struct video_device vdev;
+   struct video_device *vdev;
struct v4l2_device  v4l2_dev;
struct workqueue_struct *job_wq;
struct platform_device  *vpu_dev;
diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c 
b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
index 9a747e7..b8dee1c 100644
--- a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
@@ -1236,16 +1236,22 @@ int mtk_mdp_register_m2m_device(struct mtk_mdp_dev *mdp)
int ret;
 
mdp->variant = _mdp_default_variant;
-   mdp->vdev.device_caps = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING;
-   mdp->vdev.fops = _mdp_m2m_fops;
-   mdp->vdev.ioctl_ops = _mdp_m2m_ioctl_ops;
-   mdp->vdev.release = video_device_release_empty;
-   mdp->vdev.lock = >lock;
-   mdp->vdev.vfl_dir = VFL_DIR_M2M;
-   mdp->vdev.v4l2_dev = >v4l2_dev;
-   snprintf(mdp->vdev.name, sizeof(mdp->vdev.name), "%s:m2m",
+   mdp->vdev = video_device_alloc();
+   if (!mdp->vdev) {
+   dev_err(dev, "failed to allocate video device\n");
+   ret = -ENOMEM;
+   goto err_video_alloc;
+   }
+   mdp->vdev->device_caps = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING;
+   mdp->vdev->fops = _mdp_m2m_fops;
+   mdp->vdev->ioctl_ops = _mdp_m2m_ioctl_ops;
+   mdp->vdev->release = video_device_release;
+   mdp->vdev->lock = >lock;
+   mdp->vdev->vfl_dir = VFL_DIR_M2M;
+   mdp->vdev->v4l2_dev = >v4l2_dev;
+   snprintf(mdp->vdev->name, sizeof(mdp->vdev->name), "%s:m2m",
 MTK_MDP_MODULE_NAME);
-   video_set_drvdata(>vdev, mdp);
+   video_set_drvdata(mdp->vdev, mdp);
 
mdp->m2m_dev = v4l2_m2m_init(_mdp_m2m_ops);
if (IS_ERR(mdp->m2m_dev)) {
@@ -1254,26 +1260,27 @@ int mtk_mdp_register_m2m_device(struct mtk_mdp_dev *mdp)
goto err_m2m_init;
}
 
-   ret = video_register_device(>vdev, VFL_TYPE_GRABBER, 2);
+   ret = video_register_device(mdp->vdev, VFL_TYPE_GRABBER, 2);
if (ret) {
dev_err(dev, "failed to register video device\n");
goto err_vdev_register;
}
 
v4l2_info(>v4l2_dev, "driver registered as /dev/video%d",
- mdp->vdev.num);
+ mdp->vdev->num);
return 0;
 
 err_vdev_register:
v4l2_m2m_release(mdp->m2m_dev);
 err_m2m_init:
-   video_device_release(>vdev);
+   video_unregister_device(mdp->vdev);
+err_video_alloc:
 
return ret;
 }
 
 void mtk_mdp_unregister_m2m_device(struct mtk_mdp_dev *mdp)
 {
-   video_device_release(>vdev);
+   video_unregister_device(mdp->vdev);
v4l2_m2m_release(mdp->m2m_dev);
 }
-- 
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/4] mtk_mdp_vpu: remove a double unlock at the error path

2016-10-24 Thread Minghsiu Tsai
On Fri, 2016-10-21 at 11:59 -0200, Mauro Carvalho Chehab wrote:
> As warned by smatch:
>   drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c:98 mtk_mdp_vpu_send_msg() 
> error: double unlock 'mutex:>mdp_dev->vpulock'
> 
> Signed-off-by: Mauro Carvalho Chehab 
> ---
>  drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c 
> b/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c
> index b38d29e99f7a..5c8caa864e32 100644
> --- a/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c
> +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c
> @@ -91,7 +91,6 @@ static int mtk_mdp_vpu_send_msg(void *msg, int len, struct 
> mtk_mdp_vpu *vpu,
>   mutex_lock(>mdp_dev->vpulock);
>   err = vpu_ipi_send(vpu->pdev, (enum ipi_id)id, msg, len);
>   if (err) {
> - mutex_unlock(>mdp_dev->vpulock);

Hi Mauro,

It has been fixed by Hans in the later patch.

Author: Hans Verkuil 
Date:   Mon Sep 19 05:00:34 2016 -0300

[media] mtk-mdp: fix double mutex_unlock

Fix smatch error:

media-git/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c:100
mtk_mdp_vpu_send_msg() error: double unlock 'mutex:>

Signed-off-by: Hans Verkuil 
Signed-off-by: Mauro Carvalho Chehab 



minghsiu

>   dev_err(>mdp_dev->pdev->dev,
>   "vpu_ipi_send fail status %d\n", err);
>   }


--
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 3/4] mtk_mdp_m2m: remove an unused struct

2016-10-24 Thread Minghsiu Tsai
On Fri, 2016-10-21 at 11:59 -0200, Mauro Carvalho Chehab wrote:
> drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c:48:33: warning: 
> ‘mtk_mdp_size_align’ defined but not used [-Wunused-variable]
>  static struct mtk_mdp_pix_align mtk_mdp_size_align = {
>  ^~
> 
> Signed-off-by: Mauro Carvalho Chehab 
> ---
>  drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c | 7 ---
>  1 file changed, 7 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c 
> b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
> index 065502757133..33124a6c9951 100644
> --- a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
> +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
> @@ -45,13 +45,6 @@ struct mtk_mdp_pix_limit {
>   u16 target_rot_en_h;
>  };
>  
> -static struct mtk_mdp_pix_align mtk_mdp_size_align = {
> - .org_w  = 16,
> - .org_h  = 16,
> - .target_w   = 2,
> - .target_h   = 2,
> -};
> -

Hi Mauro,

The structure is used for the format V4L2_PIX_FMT_MT21C which is added
in the later patch.
"[media] media: mtk-mdp: support pixelformat V4L2_PIX_FMT_MT21C"

I just know checkpatch should be run patch by patch, so this warning
message will be generated without the MT21C patch.

I found all mtk-mdp patches have been merged in media tree, so is this
patch still needed?

If yes, remove 'mtk_mdp_size_align' in this patch, and re-added it in
the MT21C patch. 


minghsiu

>  static const struct mtk_mdp_fmt mtk_mdp_formats[] = {
>   {
>   .pixelformat= V4L2_PIX_FMT_NV12M,


--
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 4/4] mtk-mdp: fix compilation warnings if !DEBUG

2016-10-24 Thread Minghsiu Tsai
On Fri, 2016-10-21 at 11:59 -0200, Mauro Carvalho Chehab wrote:
> The mtk_mdp_dbg() is empty if !DEBUG. This causes the following
> warnings:
> 
>   drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c: In function 
> ‘mtk_mdp_try_fmt_mplane’:
>   drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c:231:52: warning: suggest 
> braces around empty body in an ‘if’ statement [-Wempty-body]
>   org_w, org_h, pix_mp->width, pix_mp->height);
> ^
>   drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c: In function 
> ‘mtk_mdp_m2m_start_streaming’:
>   drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c:414:21: warning: suggest 
> braces around empty body in an ‘if’ statement [-Wempty-body]
>   ctx->id, ret);
>^
> 
> With could actually make the code to do something wrong. So,
> add an empty block to make it be parsed ok.
> 
> Signed-off-by: Mauro Carvalho Chehab <mche...@s-opensource.com>
> ---
>  drivers/media/platform/mtk-mdp/mtk_mdp_core.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.h 
> b/drivers/media/platform/mtk-mdp/mtk_mdp_core.h
> index 2e979f97d1df..848569d4ab90 100644
> --- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.h
> +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.h
> @@ -250,7 +250,7 @@ extern int mtk_mdp_dbg_level;
>  
>  #else
>  
> -#define mtk_mdp_dbg(level, fmt, args...)
> +#define mtk_mdp_dbg(level, fmt, args...) {}
>  

Acked-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>


> #define mtk_mdp_err(fmt, args...)
>  #define mtk_mdp_dbg_enter()
>  #define mtk_mdp_dbg_leave()




--
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 1/4] mtk_mdp_vpu: fix build with COMPILE_TEST for 32 bits

2016-10-24 Thread Minghsiu Tsai
Hi Mauro,

This issue has been fixed by the patch below and merged in media tree,
and also signed by you.

Is it duplicate?

commit 37bf7e34ecc817ce6b8278588aeb22aab5635e1c
Author: Minghsiu Tsai <minghsiu.t...@mediatek.com>
Date:   Mon Sep 19 03:34:42 2016 -0300

[media] media: mtk-mdp: fix build warning in arch x86

This patch fix build warning in arch x86

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mche...@s-opensource.com>



On Fri, 2016-10-21 at 11:59 -0200, Mauro Carvalho Chehab wrote:
> When building on i386 in 32 bits, several new warnings appear:
> 
> drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c: In function 
> 'mtk_mdp_vpu_handle_init_ack':
> drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c:28:28: warning: cast to pointer 
> from integer of different size [-Wint-to-pointer-cast]
>   struct mtk_mdp_vpu *vpu = (struct mtk_mdp_vpu *)msg->ap_inst;
> ^
> drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c: In function 
> 'mtk_mdp_vpu_ipi_handler':
> drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c:40:28: warning: cast to pointer 
> from integer of different size [-Wint-to-pointer-cast]
>   struct mtk_mdp_vpu *vpu = (struct mtk_mdp_vpu *)msg->ap_inst;
> ^
> drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c: In function 
> 'mtk_mdp_vpu_send_ap_ipi':
> drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c:111:16: warning: cast from 
> pointer to integer of different size [-Wpointer-to-int-cast]
>   msg.ap_inst = (uint64_t)vpu;
> ^
> drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c: In function 'mtk_mdp_vpu_init':
> drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c:129:16: warning: cast from 
> pointer to integer of different size [-Wpointer-to-int-cast]
>   msg.ap_inst = (uint64_t)vpu;
> ^
> 
> That's because the driver assumes that it will be built only on
> 64 bits. As we don't want extra warnings when building with 32
> bits, we need to double-cast.
> 
> Signed-off-by: Mauro Carvalho Chehab <mche...@s-opensource.com>
> ---
>  drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c 
> b/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c
> index fb07bf3dbd8b..b38d29e99f7a 100644
> --- a/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c
> +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c
> @@ -25,7 +25,7 @@ static inline struct mtk_mdp_ctx *vpu_to_ctx(struct 
> mtk_mdp_vpu *vpu)
>  
>  static void mtk_mdp_vpu_handle_init_ack(struct mdp_ipi_comm_ack *msg)
>  {
> - struct mtk_mdp_vpu *vpu = (struct mtk_mdp_vpu *)msg->ap_inst;
> + struct mtk_mdp_vpu *vpu = (struct mtk_mdp_vpu *)(long)msg->ap_inst;
>  
>   /* mapping VPU address to kernel virtual address */
>   vpu->vsi = (struct mdp_process_vsi *)
> @@ -37,7 +37,7 @@ static void mtk_mdp_vpu_ipi_handler(void *data, unsigned 
> int len, void *priv)
>  {
>   unsigned int msg_id = *(unsigned int *)data;
>   struct mdp_ipi_comm_ack *msg = (struct mdp_ipi_comm_ack *)data;
> - struct mtk_mdp_vpu *vpu = (struct mtk_mdp_vpu *)msg->ap_inst;
> + struct mtk_mdp_vpu *vpu = (struct mtk_mdp_vpu *)(long)msg->ap_inst;
>   struct mtk_mdp_ctx *ctx;
>  
>   vpu->failure = msg->status;
> @@ -108,7 +108,7 @@ static int mtk_mdp_vpu_send_ap_ipi(struct mtk_mdp_vpu 
> *vpu, uint32_t msg_id)
>   msg.msg_id = msg_id;
>   msg.ipi_id = IPI_MDP;
>   msg.vpu_inst_addr = vpu->inst_addr;
> - msg.ap_inst = (uint64_t)vpu;
> + msg.ap_inst = (uint64_t)(long)vpu;
>   err = mtk_mdp_vpu_send_msg((void *), sizeof(msg), vpu, IPI_MDP);
>   if (!err && vpu->failure)
>   err = -EINVAL;
> @@ -126,7 +126,7 @@ int mtk_mdp_vpu_init(struct mtk_mdp_vpu *vpu)
>  
>   msg.msg_id = AP_MDP_INIT;
>   msg.ipi_id = IPI_MDP;
> - msg.ap_inst = (uint64_t)vpu;
> + msg.ap_inst = (uint64_t)(long)vpu;
>   err = mtk_mdp_vpu_send_msg((void *), sizeof(msg), vpu, IPI_MDP);
>   if (!err && vpu->failure)
>   err = -EINVAL;


--
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] mtk-mdp: fix double mutex_unlock

2016-09-19 Thread Minghsiu Tsai
On Mon, 2016-09-19 at 10:00 +0200, Hans Verkuil wrote:
> Fix smatch error:
> 
> media-git/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c:100 
> mtk_mdp_vpu_send_msg() error: double unlock 'mutex:>mdp_dev->vpulock'
> 
> Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>


Reviewed-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>

> ---
> diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c 
> b/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c
> index 39188e5..4893825 100644
> --- a/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c
> +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c
> @@ -92,11 +92,9 @@ static int mtk_mdp_vpu_send_msg(void *msg, int len, struct 
> mtk_mdp_vpu *vpu,
> 
>   mutex_lock(>mdp_dev->vpulock);
>   err = vpu_ipi_send(vpu->pdev, (enum ipi_id)id, msg, len);
> - if (err) {
> - mutex_unlock(>mdp_dev->vpulock);
> + if (err)
>   dev_err(>mdp_dev->pdev->dev,
>   "vpu_ipi_send fail status %d\n", err);
> - }
>   mutex_unlock(>mdp_dev->vpulock);
> 
>   return err;
> 


--
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 2/2] media: mtk-mdp: fix build error

2016-09-19 Thread Minghsiu Tsai
This patch fix build error without CONFIG_PM_RUNTIME
and CONFIG_PM_SLEEP

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 drivers/media/platform/mtk-mdp/mtk_mdp_core.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c 
b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
index b0c421e..f4424064 100644
--- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
@@ -233,7 +233,7 @@ static int mtk_mdp_remove(struct platform_device *pdev)
return 0;
 }
 
-#if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP)
+#ifdef CONFIG_PM
 static int mtk_mdp_pm_suspend(struct device *dev)
 {
struct mtk_mdp_dev *mdp = dev_get_drvdata(dev);
@@ -251,7 +251,7 @@ static int mtk_mdp_pm_resume(struct device *dev)
 
return 0;
 }
-#endif /* CONFIG_PM_RUNTIME || CONFIG_PM_SLEEP */
+#endif /* CONFIG_PM */
 
 #ifdef CONFIG_PM_SLEEP
 static int mtk_mdp_suspend(struct device *dev)
-- 
1.7.9.5

--
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: mtk-mdp: fix build warning in arch x86

2016-09-19 Thread Minghsiu Tsai
This patch fix build warning in arch x86

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c |1 +
 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c |   10 ++
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c 
b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
index a90972e..9a747e7 100644
--- a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c 
b/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c
index fb07bf3..39188e5 100644
--- a/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c
@@ -25,7 +25,8 @@ static inline struct mtk_mdp_ctx *vpu_to_ctx(struct 
mtk_mdp_vpu *vpu)
 
 static void mtk_mdp_vpu_handle_init_ack(struct mdp_ipi_comm_ack *msg)
 {
-   struct mtk_mdp_vpu *vpu = (struct mtk_mdp_vpu *)msg->ap_inst;
+   struct mtk_mdp_vpu *vpu = (struct mtk_mdp_vpu *)
+   (unsigned long)msg->ap_inst;
 
/* mapping VPU address to kernel virtual address */
vpu->vsi = (struct mdp_process_vsi *)
@@ -37,7 +38,8 @@ static void mtk_mdp_vpu_ipi_handler(void *data, unsigned int 
len, void *priv)
 {
unsigned int msg_id = *(unsigned int *)data;
struct mdp_ipi_comm_ack *msg = (struct mdp_ipi_comm_ack *)data;
-   struct mtk_mdp_vpu *vpu = (struct mtk_mdp_vpu *)msg->ap_inst;
+   struct mtk_mdp_vpu *vpu = (struct mtk_mdp_vpu *)
+   (unsigned long)msg->ap_inst;
struct mtk_mdp_ctx *ctx;
 
vpu->failure = msg->status;
@@ -108,7 +110,7 @@ static int mtk_mdp_vpu_send_ap_ipi(struct mtk_mdp_vpu *vpu, 
uint32_t msg_id)
msg.msg_id = msg_id;
msg.ipi_id = IPI_MDP;
msg.vpu_inst_addr = vpu->inst_addr;
-   msg.ap_inst = (uint64_t)vpu;
+   msg.ap_inst = (unsigned long)vpu;
err = mtk_mdp_vpu_send_msg((void *), sizeof(msg), vpu, IPI_MDP);
if (!err && vpu->failure)
err = -EINVAL;
@@ -126,7 +128,7 @@ int mtk_mdp_vpu_init(struct mtk_mdp_vpu *vpu)
 
msg.msg_id = AP_MDP_INIT;
msg.ipi_id = IPI_MDP;
-   msg.ap_inst = (uint64_t)vpu;
+   msg.ap_inst = (unsigned long)vpu;
err = mtk_mdp_vpu_send_msg((void *), sizeof(msg), vpu, IPI_MDP);
if (!err && vpu->failure)
err = -EINVAL;
-- 
1.7.9.5

--
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 0/2] Fix build warning and error in Mediatek MDP driver

2016-09-19 Thread Minghsiu Tsai
- Fix build warning in arch x86 
- Fix build warning in kzalloc() and kfree() in arch x86 
- Fix build error without CONFIG_PM_RUNTIME and CONFIG_PM_SLEEP

v4l2-compliance test output:
v4l2-compliance SHA   : abc1453dfe89f244dccd3460d8e1a2e3091cbadb

Driver Info:
Driver name   : mtk-mdp
Card type : soc:mdp
Bus info  : platform:mt8173
Driver version: 4.8.0
Capabilities  : 0x84204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format
Device Capabilities
Device Caps   : 0x04204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format

Compliance test for device /dev/image-proc0 (not using libv4l2):

Required ioctls:
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second video open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK

Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK (Not Supported)

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK (Not Supported)
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)

Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 5 Private Controls: 0

Format ioctls:
test 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
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK
test Composing: OK
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:


Total: 43, Succeeded: 43, Failed: 0, Warnings: 0

Minghsiu Tsai (2):
  media: mtk-mdp: fix build warning in arch x86
  media: mtk-mdp: fix build error

 drivers/media/platform/mtk-mdp/mtk_mdp_core.c |4 ++--
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c  |1 +
 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c  |   10 ++
 3 files changed, 9 insertions(+), 6 deletions(-)

-- 
1.7.9.5

--
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 v6 0/6] Add MT8173 MDP Driver

2016-09-18 Thread Minghsiu Tsai
On Wed, 2016-09-14 at 14:43 +0200, Hans Verkuil wrote:
> Hi Minghsiu,
> 
> v6 looks good, but I get these warnings when compiling it for i686:
> 
> linux-git-i686: WARNINGS
> 
> /home/hans/work/build/media-git/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c: 
> In function 'mtk_mdp_vpu_handle_init_ack':
> /home/hans/work/build/media-git/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c:28:28:
>  warning: cast to pointer from integer of different size 
> [-Wint-to-pointer-cast]
>   struct mtk_mdp_vpu *vpu = (struct mtk_mdp_vpu *)msg->ap_inst;
> ^
> /home/hans/work/build/media-git/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c: 
> In function 'mtk_mdp_vpu_ipi_handler':
> /home/hans/work/build/media-git/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c:40:28:
>  warning: cast to pointer from integer of different size 
> [-Wint-to-pointer-cast]
>   struct mtk_mdp_vpu *vpu = (struct mtk_mdp_vpu *)msg->ap_inst;
> ^
> /home/hans/work/build/media-git/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c: 
> In function 'mtk_mdp_vpu_send_ap_ipi':
> /home/hans/work/build/media-git/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c:111:16:
>  warning: cast from pointer to integer of different size 
> [-Wpointer-to-int-cast]
>   msg.ap_inst = (uint64_t)vpu;
> ^
> /home/hans/work/build/media-git/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c: 
> In function 'mtk_mdp_vpu_init':
> /home/hans/work/build/media-git/drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c:129:16:
>  warning: cast from pointer to integer of different size 
> [-Wpointer-to-int-cast]
>   msg.ap_inst = (uint64_t)vpu;
> ^
> 
> This is not blocking, but if you can post a follow-up patch for this, then 
> that
> would be helpful.
> 

Hi Hans,

I have duplicated this warning message in arch x86. 
I also got the report from kbuild robot. There are build errors in
mtk_mdp_pm_suspend().
Besides, in arch x86, I also have build warning messages in kzalloc()
and kfree() used in mtk_mdp_m2m.c. It can be fixed by including
linux/slab.h
I will upload the patches today.
Thanks


Ming Hsiu

> Regards,
> 
>   Hans
> 
> 
> On 09/08/2016 03:09 PM, Minghsiu Tsai wrote:
> > Changes in v6:
> > - s_selection() can't set the _DEFAULT and _BOUNDS targets
> > - Add Maintainers entry
> > 
> > Changes in v5:
> > - Add ack in the comment of dts patch
> > - Fix s/g_selection()
> > - Separate format V4L2_PIX_FMT_MT21C into new patch  
> > 
> > Changes in v4:
> > - Add "depends on HAS_DMA" in Kconfig.
> > - Fix s/g_selection()
> > - Replace struct v4l2_crop with u32 and struct v4l2_rect
> > - Remove VB2_USERPTR
> > - Move mutex lock after ctx allocation in mtk_mdp_m2m_open()
> > - Add new format V4L2_PIX_FMT_YVU420 to support software on Android 
> > platform.
> > - Only width/height of image in format V4L2_PIX_FMT_MT21 is aligned to 
> > 16/16,
> >   other ones are aligned to 2/2 by default
> > 
> > Changes in v3:
> > - Modify device ndoe as structured one.
> > - Fix conflict in dts on Linux 4.8-rc1
> > 
> > Changes in v2:
> > - Add section to describe blocks function in dts-bindings
> > - Remove the assignment of device_caps in querycap()
> > - Remove format's name assignment
> > - Copy colorspace-related parameters from OUTPUT to CAPTURE
> > - Use m2m helper functions
> > - Fix DMA allocation failure
> > - Initialize lazily vpu instance in streamon()
> > 
> > ==
> >  Introduction
> > ==
> > 
> > The purpose of this series is to add the driver for Media Data Path HW 
> > embedded in the Mediatek's MT8173 SoC.
> > MDP is used for scaling and color space conversion.
> > 
> > It could convert V4L2_PIX_FMT_MT21 to V4L2_PIX_FMT_NV12M or 
> > V4L2_PIX_FMT_YUV420M.
> > 
> > NV12M/YUV420M/MT21 -> MDP -> NV12M/YUV420M
> > 
> > This patch series rely on MTK VPU driver in patch series "Add MT8173 Video 
> > Encoder Driver and VPU Driver"[1] and "Add MT8173 Video Decoder Driver"[2].
> > MDP driver rely on VPU driver to load, communicate with VPU.
> > 
> > Internally the driver uses videobuf2 framework and MTK IOMMU and MTK SMI 
> > both have been merged in v4.6-rc1.
> > 
> > [1]https://patchwork.kernel.org/patch/9002171/
> > [2]https://patchwork.kernel.org/patch/9141245/
> > 
> > ==
> >  Device interface
> > ==
> > 
> > In principle the driver bases on v4l2 memory-to-memory framework:
> > it provides a single video node

[PATCH v6 0/6] Add MT8173 MDP Driver

2016-09-08 Thread Minghsiu Tsai
(Not Supported)
test Cropping: OK
test Composing: OK
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:


Total: 43, Succeeded: 43, Failed: 0, Warnings: 0

Minghsiu Tsai (6):
  VPU: mediatek: Add mdp support
  dt-bindings: Add a binding for Mediatek MDP
  media: Add Mediatek MDP Driver
  arm64: dts: mediatek: Add MDP for MT8173
  media: mtk-mdp: support pixelformat V4L2_PIX_FMT_MT21C
  media: mtk-mdp: add Maintainers entry for Mediatek MDP driver

 .../devicetree/bindings/media/mediatek-mdp.txt |  109 ++
 MAINTAINERS|9 +
 arch/arm64/boot/dts/mediatek/mt8173.dtsi   |   84 ++
 drivers/media/platform/Kconfig |   17 +
 drivers/media/platform/Makefile|2 +
 drivers/media/platform/mtk-mdp/Makefile|9 +
 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c  |  159 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_comp.h  |   72 ++
 drivers/media/platform/mtk-mdp/mtk_mdp_core.c  |  294 +
 drivers/media/platform/mtk-mdp/mtk_mdp_core.h  |  260 
 drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h   |  126 ++
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c   | 1278 
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h   |   22 +
 drivers/media/platform/mtk-mdp/mtk_mdp_regs.c  |  156 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_regs.h  |   31 +
 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c   |  145 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h   |   41 +
 drivers/media/platform/mtk-vpu/mtk_vpu.h   |5 +
 18 files changed, 2819 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/mediatek-mdp.txt
 create mode 100644 drivers/media/platform/mtk-mdp/Makefile
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_comp.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_core.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_core.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_regs.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_regs.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h

-- 
1.7.9.5

--
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 v6 1/6] VPU: mediatek: Add mdp support

2016-09-08 Thread Minghsiu Tsai
VPU driver add mdp support

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 drivers/media/platform/mtk-vpu/mtk_vpu.h |5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/media/platform/mtk-vpu/mtk_vpu.h 
b/drivers/media/platform/mtk-vpu/mtk_vpu.h
index f457479..291ae46 100644
--- a/drivers/media/platform/mtk-vpu/mtk_vpu.h
+++ b/drivers/media/platform/mtk-vpu/mtk_vpu.h
@@ -53,6 +53,8 @@ typedef void (*ipi_handler_t) (void *data,
 handle H264 video encoder job, and vice versa.
  * @IPI_VENC_VP8:   The interrupt fro vpu is to notify kernel to
 handle VP8 video encoder job,, and vice versa.
+ * @IPI_MDP:The interrupt from vpu is to notify kernel to
+handle MDP (Media Data Path) job, and vice versa.
  * @IPI_MAX:The maximum IPI number
  */
 
@@ -63,6 +65,7 @@ enum ipi_id {
IPI_VDEC_VP9,
IPI_VENC_H264,
IPI_VENC_VP8,
+   IPI_MDP,
IPI_MAX,
 };
 
@@ -71,11 +74,13 @@ enum ipi_id {
  *
  * @VPU_RST_ENC: encoder reset id
  * @VPU_RST_DEC: decoder reset id
+ * @VPU_RST_MDP: MDP (Media Data Path) reset id
  * @VPU_RST_MAX: maximum reset id
  */
 enum rst_id {
VPU_RST_ENC,
VPU_RST_DEC,
+   VPU_RST_MDP,
VPU_RST_MAX,
 };
 
-- 
1.7.9.5

--
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 v6 4/6] arm64: dts: mediatek: Add MDP for MT8173

2016-09-08 Thread Minghsiu Tsai
Add MDP node for MT8173

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   84 ++
 1 file changed, 84 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 10f638f..cd93228 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -41,6 +41,14 @@
dpi0 = 
dsi0 = 
dsi1 = 
+   mdp_rdma0 = _rdma0;
+   mdp_rdma1 = _rdma1;
+   mdp_rsz0 = _rsz0;
+   mdp_rsz1 = _rsz1;
+   mdp_rsz2 = _rsz2;
+   mdp_wdma0 = _wdma0;
+   mdp_wrot0 = _wrot0;
+   mdp_wrot1 = _wrot1;
};
 
cpus {
@@ -716,6 +724,82 @@
#clock-cells = <1>;
};
 
+   mdp {
+   compatible = "mediatek,mt8173-mdp";
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+   mediatek,vpu = <>;
+
+   mdp_rdma0: rdma@14001000 {
+   compatible = "mediatek,mt8173-mdp-rdma";
+   reg = <0 0x14001000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA0>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA0>;
+   mediatek,larb = <>;
+   };
+
+   mdp_rdma1: rdma@14002000 {
+   compatible = "mediatek,mt8173-mdp-rdma";
+   reg = <0 0x14002000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA1>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA1>;
+   mediatek,larb = <>;
+   };
+
+   mdp_rsz0: rsz@14003000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14003000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ0>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_rsz1: rsz@14004000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14004000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ1>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_rsz2: rsz@14005000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14005000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ2>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_wdma0: wdma@14006000 {
+   compatible = "mediatek,mt8173-mdp-wdma";
+   reg = <0 0x14006000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WDMA>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WDMA>;
+   mediatek,larb = <>;
+   };
+
+   mdp_wrot0: wrot@14007000 {
+   compatible = "mediatek,mt8173-mdp-wrot";
+   reg = <0 0x14007000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WROT0>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WROT0>;
+   mediatek,larb = <>;
+   };
+
+   mdp_wrot1: wrot@14008000 {
+   compatible = "mediatek,mt8173-mdp-wrot";
+   reg = <0 0x14008000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WROT1>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WROT1>;
+   mediatek,larb = <>;
+

[PATCH v6 2/6] dt-bindings: Add a binding for Mediatek MDP

2016-09-08 Thread Minghsiu Tsai
Add a DT binding documentation of MDP for the MT8173 SoC
from Mediatek

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
Acked-by: Rob Herring <r...@kernel.org>
---
 .../devicetree/bindings/media/mediatek-mdp.txt |  109 
 1 file changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/mediatek-mdp.txt

diff --git a/Documentation/devicetree/bindings/media/mediatek-mdp.txt 
b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
new file mode 100644
index 000..4182063
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
@@ -0,0 +1,109 @@
+* Mediatek Media Data Path
+
+Media Data Path is used for scaling and color space conversion.
+
+Required properties (controller (parent) node):
+- compatible: "mediatek,mt8173-mdp"
+- mediatek,vpu: the node of video processor unit, see
+  Documentation/devicetree/bindings/media/mediatek-vpu.txt for details.
+
+Required properties (all function blocks, child node):
+- compatible: Should be one of
+"mediatek,mt8173-mdp-rdma"  - read DMA
+"mediatek,mt8173-mdp-rsz"   - resizer
+"mediatek,mt8173-mdp-wdma"  - write DMA
+"mediatek,mt8173-mdp-wrot"  - write DMA with rotation
+- reg: Physical base address and length of the function block register space
+- clocks: device clocks, see
+  Documentation/devicetree/bindings/clock/clock-bindings.txt for details.
+- power-domains: a phandle to the power domain, see
+  Documentation/devicetree/bindings/power/power_domain.txt for details.
+
+Required properties (DMA function blocks, child node):
+- compatible: Should be one of
+"mediatek,mt8173-mdp-rdma"
+"mediatek,mt8173-mdp-wdma"
+"mediatek,mt8173-mdp-wrot"
+- iommus: should point to the respective IOMMU block with master port as
+  argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt
+  for details.
+- mediatek,larb: must contain the local arbiters in the current Socs, see
+  Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.txt
+  for details.
+
+Example:
+mdp {
+   compatible = "mediatek,mt8173-mdp";
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+   mediatek,vpu = <>;
+
+   mdp_rdma0: rdma@14001000 {
+   compatible = "mediatek,mt8173-mdp-rdma";
+   reg = <0 0x14001000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA0>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA0>;
+   mediatek,larb = <>;
+   };
+
+   mdp_rdma1: rdma@14002000 {
+   compatible = "mediatek,mt8173-mdp-rdma";
+   reg = <0 0x14002000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA1>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA1>;
+   mediatek,larb = <>;
+   };
+
+   mdp_rsz0: rsz@14003000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14003000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ0>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_rsz1: rsz@14004000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14004000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ1>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_rsz2: rsz@14005000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14005000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ2>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_wdma0: wdma@14006000 {
+   compatible = "mediatek,mt8173-mdp-wdma";
+   reg = <0 0x14006000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WDMA>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WDMA>;
+   mediatek,larb = <>;
+   };
+
+   mdp_wrot0: wrot@14007000 {
+   compatible = "mediatek,mt8173-mdp-wrot";
+   reg = <0 0x14007000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WROT0>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WROT0>;
+   mediatek,larb = <>;
+   };
+
+   mdp_wrot1: wrot@14008000 {
+   compatible = "mediatek,mt8173-mdp-wrot";
+   reg = <0 0x14008000 0 0x1000>;

[PATCH v6 3/6] media: Add Mediatek MDP Driver

2016-09-08 Thread Minghsiu Tsai
Add MDP driver for MT8173

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 drivers/media/platform/Kconfig|   17 +
 drivers/media/platform/Makefile   |2 +
 drivers/media/platform/mtk-mdp/Makefile   |9 +
 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c |  159 
 drivers/media/platform/mtk-mdp/mtk_mdp_comp.h |   72 ++
 drivers/media/platform/mtk-mdp/mtk_mdp_core.c |  294 ++
 drivers/media/platform/mtk-mdp/mtk_mdp_core.h |  260 +
 drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h  |  126 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c  | 1270 +
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h  |   22 +
 drivers/media/platform/mtk-mdp/mtk_mdp_regs.c |  152 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_regs.h |   31 +
 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c  |  145 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h  |   41 +
 14 files changed, 2600 insertions(+)
 create mode 100644 drivers/media/platform/mtk-mdp/Makefile
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_comp.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_core.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_core.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_regs.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_regs.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index f25344b..0c88532 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -166,6 +166,23 @@ config VIDEO_MEDIATEK_VPU
To compile this driver as a module, choose M here: the
module will be called mtk-vpu.
 
+config VIDEO_MEDIATEK_MDP
+   tristate "Mediatek MDP driver"
+   depends on MTK_IOMMU || COMPILE_TEST
+   depends on VIDEO_DEV && VIDEO_V4L2
+   depends on ARCH_MEDIATEK || COMPILE_TEST
+   depends on HAS_DMA
+   select VIDEOBUF2_DMA_CONTIG
+   select V4L2_MEM2MEM_DEV
+   select VIDEO_MEDIATEK_VPU
+   default n
+   ---help---
+   It is a v4l2 driver and present in Mediatek MT8173 SoCs.
+   The driver supports for scaling and color space conversion.
+
+   To compile this driver as a module, choose M here: the
+   module will be called mtk-mdp.
+
 config VIDEO_MEDIATEK_VCODEC
tristate "Mediatek Video Codec driver"
depends on MTK_IOMMU || COMPILE_TEST
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 21771c1..221aace 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -63,3 +63,5 @@ ccflags-y += -I$(srctree)/drivers/media/i2c
 obj-$(CONFIG_VIDEO_MEDIATEK_VPU)   += mtk-vpu/
 
 obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC)+= mtk-vcodec/
+
+obj-$(CONFIG_VIDEO_MEDIATEK_MDP)   += mtk-mdp/
diff --git a/drivers/media/platform/mtk-mdp/Makefile 
b/drivers/media/platform/mtk-mdp/Makefile
new file mode 100644
index 000..f802569
--- /dev/null
+++ b/drivers/media/platform/mtk-mdp/Makefile
@@ -0,0 +1,9 @@
+mtk-mdp-y += mtk_mdp_core.o
+mtk-mdp-y += mtk_mdp_comp.o
+mtk-mdp-y += mtk_mdp_m2m.o
+mtk-mdp-y += mtk_mdp_regs.o
+mtk-mdp-y += mtk_mdp_vpu.o
+
+obj-$(CONFIG_VIDEO_MEDIATEK_MDP) += mtk-mdp.o
+
+ccflags-y += -I$(srctree)/drivers/media/platform/mtk-vpu
diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c 
b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
new file mode 100644
index 000..aa8f9fd
--- /dev/null
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: Ming Hsiu Tsai <minghsiu.t...@mediatek.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mtk_mdp_comp.h"
+
+
+static const char * const mtk_mdp_comp_stem[MTK_MDP_COMP_TYPE_MAX] = {
+   "mdp_rdma",
+   "mdp_rsz",
+   "mdp_wdma",
+   "mdp_wrot",
+};
+
+struct mtk_mdp_comp_match {
+   enum mtk_mdp_comp_type type;
+   int alias_id;
+};
+
+static const struct mtk_mdp_comp_match mtk_mdp_matches[MTK_MDP_COMP_I

[PATCH v6 5/6] media: mtk-mdp: support pixelformat V4L2_PIX_FMT_MT21C

2016-09-08 Thread Minghsiu Tsai
Add V4L2_PIX_FMT_MT21C in format list.

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c  |8 
 drivers/media/platform/mtk-mdp/mtk_mdp_regs.c |4 
 2 files changed, 12 insertions(+)

diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c 
b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
index 0655027..a90972e 100644
--- a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
@@ -54,6 +54,14 @@ static struct mtk_mdp_pix_align mtk_mdp_size_align = {
 
 static const struct mtk_mdp_fmt mtk_mdp_formats[] = {
{
+   .pixelformat= V4L2_PIX_FMT_MT21C,
+   .depth  = { 8, 4 },
+   .row_depth  = { 8, 8 },
+   .num_planes = 2,
+   .num_comp   = 2,
+   .align  = _mdp_size_align,
+   .flags  = MTK_MDP_FMT_FLAG_OUTPUT,
+   }, {
.pixelformat= V4L2_PIX_FMT_NV12M,
.depth  = { 8, 4 },
.row_depth  = { 8, 8 },
diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_regs.c 
b/drivers/media/platform/mtk-mdp/mtk_mdp_regs.c
index a5601e1..86d57f3 100644
--- a/drivers/media/platform/mtk-mdp/mtk_mdp_regs.c
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_regs.c
@@ -29,6 +29,8 @@ enum MDP_COLOR_ENUM {
MDP_COLOR_NV12 = MDP_COLORFMT_PACK(0, 2, 1, 1, 1, 8, 1, 0, 12),
MDP_COLOR_I420 = MDP_COLORFMT_PACK(0, 3, 0, 1, 1, 8, 1, 0, 8),
MDP_COLOR_YV12 = MDP_COLORFMT_PACK(0, 3, 0, 1, 1, 8, 1, 1, 8),
+   /* Mediatek proprietary format */
+   MDP_COLOR_420_MT21 = MDP_COLORFMT_PACK(5, 2, 1, 1, 1, 256, 1, 0, 12),
 };
 
 static int32_t mtk_mdp_map_color_format(int v4l2_format)
@@ -37,6 +39,8 @@ static int32_t mtk_mdp_map_color_format(int v4l2_format)
case V4L2_PIX_FMT_NV12M:
case V4L2_PIX_FMT_NV12:
return MDP_COLOR_NV12;
+   case V4L2_PIX_FMT_MT21C:
+   return MDP_COLOR_420_MT21;
case V4L2_PIX_FMT_YUV420M:
case V4L2_PIX_FMT_YUV420:
return MDP_COLOR_I420;
-- 
1.7.9.5

--
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 v6 6/6] media: mtk-mdp: add Maintainers entry for Mediatek MDP driver

2016-09-08 Thread Minghsiu Tsai
Add Minghsiu Tsai, Houlong Wei and Andrew-CT Chen as
maintainers for Mediatek MDP driver

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
Signed-off-by: Houlong Wei <houlong@mediatek.com>
Signed-off-by: Andrew-CT Chen <andrew-ct.c...@mediatek.com>
---
 MAINTAINERS |9 +
 1 file changed, 9 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 20bb1d0..e17e681 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7605,6 +7605,15 @@ L:   net...@vger.kernel.org
 S: Maintained
 F: drivers/net/ethernet/mediatek/
 
+MEDIATEK MDP DRIVER
+M: Minghsiu Tsai <minghsiu.t...@mediatek.com>
+M: Houlong Wei <houlong@mediatek.com>
+M: Andrew-CT Chen <andrew-ct.c...@mediatek.com>
+S: Supported
+F: drivers/media/platform/mtk-mdp/
+F: drivers/media/platform/mtk-vpu/
+F: Documentation/devicetree/bindings/media/mediatek-mdp.txt
+
 MEDIATEK MT7601U WIRELESS LAN DRIVER
 M: Jakub Kicinski <kubak...@wp.pl>
 L: linux-wirel...@vger.kernel.org
-- 
1.7.9.5

--
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 v5 3/5] media: Add Mediatek MDP Driver

2016-09-08 Thread Minghsiu Tsai
On Mon, 2016-09-05 at 12:17 +0200, Hans Verkuil wrote:
> On 08/30/2016 02:25 PM, Minghsiu Tsai wrote:
> > Add MDP driver for MT8173
> > 
> > Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
> > ---
> >  drivers/media/platform/Kconfig|   17 +
> >  drivers/media/platform/Makefile   |2 +
> >  drivers/media/platform/mtk-mdp/Makefile   |9 +
> >  drivers/media/platform/mtk-mdp/mtk_mdp_comp.c |  159 
> >  drivers/media/platform/mtk-mdp/mtk_mdp_comp.h |   72 ++
> >  drivers/media/platform/mtk-mdp/mtk_mdp_core.c |  294 ++
> >  drivers/media/platform/mtk-mdp/mtk_mdp_core.h |  260 +
> >  drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h  |  126 +++
> >  drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c  | 1270 
> > +
> >  drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h  |   22 +
> >  drivers/media/platform/mtk-mdp/mtk_mdp_regs.c |  152 +++
> >  drivers/media/platform/mtk-mdp/mtk_mdp_regs.h |   31 +
> >  drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c  |  145 +++
> >  drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h  |   41 +
> >  14 files changed, 2600 insertions(+)
> >  create mode 100644 drivers/media/platform/mtk-mdp/Makefile
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_comp.h
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_core.c
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_core.h
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_regs.c
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_regs.h
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h
> > 
> 
> 
> 
> > +static inline bool mtk_mdp_is_target_compose(u32 target)
> > +{
> > +   if (target == V4L2_SEL_TGT_COMPOSE_DEFAULT
> > +   || target == V4L2_SEL_TGT_COMPOSE_BOUNDS
> > +   || target == V4L2_SEL_TGT_COMPOSE)
> > +   return true;
> > +   return false;
> > +}
> > +
> > +static inline bool mtk_mdp_is_target_crop(u32 target)
> > +{
> > +   if (target == V4L2_SEL_TGT_CROP_DEFAULT
> > +   || target == V4L2_SEL_TGT_CROP_BOUNDS
> > +   || target == V4L2_SEL_TGT_CROP)
> > +   return true;
> > +   return false;
> > +}
> > +
> > +static int mtk_mdp_m2m_g_selection(struct file *file, void *fh,
> > +  struct v4l2_selection *s)
> > +{
> > +   struct mtk_mdp_frame *frame;
> > +   struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
> > +   bool valid = false;
> > +
> > +   if (s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
> > +   if (mtk_mdp_is_target_compose(s->target))
> > +   valid = true;
> > +   } else if (s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
> > +   if (mtk_mdp_is_target_crop(s->target))
> > +   valid = true;
> > +   }
> > +   if (!valid) {
> > +   mtk_mdp_dbg(1, "[%d] invalid type:%d,%u", ctx->id, s->type,
> > +   s->target);
> > +   return -EINVAL;
> > +   }
> > +
> > +   frame = mtk_mdp_ctx_get_frame(ctx, s->type);
> > +
> > +   switch (s->target) {
> > +   case V4L2_SEL_TGT_COMPOSE_DEFAULT:
> > +   case V4L2_SEL_TGT_COMPOSE_BOUNDS:
> > +   case V4L2_SEL_TGT_CROP_BOUNDS:
> > +   case V4L2_SEL_TGT_CROP_DEFAULT:
> > +   s->r.left = 0;
> > +   s->r.top = 0;
> > +   s->r.width = frame->width;
> > +   s->r.height = frame->height;
> > +   return 0;
> > +
> > +   case V4L2_SEL_TGT_COMPOSE:
> > +   case V4L2_SEL_TGT_CROP:
> > +   s->r.left = frame->crop.left;
> > +   s->r.top = frame->crop.top;
> > +   s->r.width = frame->crop.width;
> > +   s->r.height = frame->crop.height;
> > +   return 0;
> > +   }
> > +
> > +   return -EINVAL;
> > +}
> > +
> > +static int mtk_mdp_check_scaler_ratio(struct mtk_mdp_variant *var, int 
> > src_w,
> > + int src_h, int dst_w, int dst_h, int rot)
> > +{
> > +   int tmp_w, tmp_h;
> > +
> > +   if 

[PATCH v5 1/5] VPU: mediatek: Add mdp support

2016-08-30 Thread Minghsiu Tsai
VPU driver add mdp support

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 drivers/media/platform/mtk-vpu/mtk_vpu.h |5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/media/platform/mtk-vpu/mtk_vpu.h 
b/drivers/media/platform/mtk-vpu/mtk_vpu.h
index f457479..291ae46 100644
--- a/drivers/media/platform/mtk-vpu/mtk_vpu.h
+++ b/drivers/media/platform/mtk-vpu/mtk_vpu.h
@@ -53,6 +53,8 @@ typedef void (*ipi_handler_t) (void *data,
 handle H264 video encoder job, and vice versa.
  * @IPI_VENC_VP8:   The interrupt fro vpu is to notify kernel to
 handle VP8 video encoder job,, and vice versa.
+ * @IPI_MDP:The interrupt from vpu is to notify kernel to
+handle MDP (Media Data Path) job, and vice versa.
  * @IPI_MAX:The maximum IPI number
  */
 
@@ -63,6 +65,7 @@ enum ipi_id {
IPI_VDEC_VP9,
IPI_VENC_H264,
IPI_VENC_VP8,
+   IPI_MDP,
IPI_MAX,
 };
 
@@ -71,11 +74,13 @@ enum ipi_id {
  *
  * @VPU_RST_ENC: encoder reset id
  * @VPU_RST_DEC: decoder reset id
+ * @VPU_RST_MDP: MDP (Media Data Path) reset id
  * @VPU_RST_MAX: maximum reset id
  */
 enum rst_id {
VPU_RST_ENC,
VPU_RST_DEC,
+   VPU_RST_MDP,
VPU_RST_MAX,
 };
 
-- 
1.7.9.5

--
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 v5 2/5] dt-bindings: Add a binding for Mediatek MDP

2016-08-30 Thread Minghsiu Tsai
Add a DT binding documentation of MDP for the MT8173 SoC
from Mediatek

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
Acked-by: Rob Herring <r...@kernel.org>
---
 .../devicetree/bindings/media/mediatek-mdp.txt |  109 
 1 file changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/mediatek-mdp.txt

diff --git a/Documentation/devicetree/bindings/media/mediatek-mdp.txt 
b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
new file mode 100644
index 000..4182063
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
@@ -0,0 +1,109 @@
+* Mediatek Media Data Path
+
+Media Data Path is used for scaling and color space conversion.
+
+Required properties (controller (parent) node):
+- compatible: "mediatek,mt8173-mdp"
+- mediatek,vpu: the node of video processor unit, see
+  Documentation/devicetree/bindings/media/mediatek-vpu.txt for details.
+
+Required properties (all function blocks, child node):
+- compatible: Should be one of
+"mediatek,mt8173-mdp-rdma"  - read DMA
+"mediatek,mt8173-mdp-rsz"   - resizer
+"mediatek,mt8173-mdp-wdma"  - write DMA
+"mediatek,mt8173-mdp-wrot"  - write DMA with rotation
+- reg: Physical base address and length of the function block register space
+- clocks: device clocks, see
+  Documentation/devicetree/bindings/clock/clock-bindings.txt for details.
+- power-domains: a phandle to the power domain, see
+  Documentation/devicetree/bindings/power/power_domain.txt for details.
+
+Required properties (DMA function blocks, child node):
+- compatible: Should be one of
+"mediatek,mt8173-mdp-rdma"
+"mediatek,mt8173-mdp-wdma"
+"mediatek,mt8173-mdp-wrot"
+- iommus: should point to the respective IOMMU block with master port as
+  argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt
+  for details.
+- mediatek,larb: must contain the local arbiters in the current Socs, see
+  Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.txt
+  for details.
+
+Example:
+mdp {
+   compatible = "mediatek,mt8173-mdp";
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+   mediatek,vpu = <>;
+
+   mdp_rdma0: rdma@14001000 {
+   compatible = "mediatek,mt8173-mdp-rdma";
+   reg = <0 0x14001000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA0>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA0>;
+   mediatek,larb = <>;
+   };
+
+   mdp_rdma1: rdma@14002000 {
+   compatible = "mediatek,mt8173-mdp-rdma";
+   reg = <0 0x14002000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA1>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA1>;
+   mediatek,larb = <>;
+   };
+
+   mdp_rsz0: rsz@14003000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14003000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ0>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_rsz1: rsz@14004000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14004000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ1>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_rsz2: rsz@14005000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14005000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ2>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_wdma0: wdma@14006000 {
+   compatible = "mediatek,mt8173-mdp-wdma";
+   reg = <0 0x14006000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WDMA>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WDMA>;
+   mediatek,larb = <>;
+   };
+
+   mdp_wrot0: wrot@14007000 {
+   compatible = "mediatek,mt8173-mdp-wrot";
+   reg = <0 0x14007000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WROT0>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WROT0>;
+   mediatek,larb = <>;
+   };
+
+   mdp_wrot1: wrot@14008000 {
+   compatible = "mediatek,mt8173-mdp-wrot";
+   reg = <0 0x14008000 0 0x1000>;

[PATCH v5 5/5] media: mtk-mdp: support pixelformat V4L2_PIX_FMT_MT21C

2016-08-30 Thread Minghsiu Tsai
Add V4L2_PIX_FMT_MT21C in format list.

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c  |8 
 drivers/media/platform/mtk-mdp/mtk_mdp_regs.c |4 
 2 files changed, 12 insertions(+)

diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c 
b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
index 927132a..0184dbe 100644
--- a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
@@ -54,6 +54,14 @@ static struct mtk_mdp_pix_align mtk_mdp_size_align = {
 
 static const struct mtk_mdp_fmt mtk_mdp_formats[] = {
{
+   .pixelformat= V4L2_PIX_FMT_MT21C,
+   .depth  = { 8, 4 },
+   .row_depth  = { 8, 8 },
+   .num_planes = 2,
+   .num_comp   = 2,
+   .align  = _mdp_size_align,
+   .flags  = MTK_MDP_FMT_FLAG_OUTPUT,
+   }, {
.pixelformat= V4L2_PIX_FMT_NV12M,
.depth  = { 8, 4 },
.row_depth  = { 8, 8 },
diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_regs.c 
b/drivers/media/platform/mtk-mdp/mtk_mdp_regs.c
index a5601e1..86d57f3 100644
--- a/drivers/media/platform/mtk-mdp/mtk_mdp_regs.c
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_regs.c
@@ -29,6 +29,8 @@ enum MDP_COLOR_ENUM {
MDP_COLOR_NV12 = MDP_COLORFMT_PACK(0, 2, 1, 1, 1, 8, 1, 0, 12),
MDP_COLOR_I420 = MDP_COLORFMT_PACK(0, 3, 0, 1, 1, 8, 1, 0, 8),
MDP_COLOR_YV12 = MDP_COLORFMT_PACK(0, 3, 0, 1, 1, 8, 1, 1, 8),
+   /* Mediatek proprietary format */
+   MDP_COLOR_420_MT21 = MDP_COLORFMT_PACK(5, 2, 1, 1, 1, 256, 1, 0, 12),
 };
 
 static int32_t mtk_mdp_map_color_format(int v4l2_format)
@@ -37,6 +39,8 @@ static int32_t mtk_mdp_map_color_format(int v4l2_format)
case V4L2_PIX_FMT_NV12M:
case V4L2_PIX_FMT_NV12:
return MDP_COLOR_NV12;
+   case V4L2_PIX_FMT_MT21C:
+   return MDP_COLOR_420_MT21;
case V4L2_PIX_FMT_YUV420M:
case V4L2_PIX_FMT_YUV420:
return MDP_COLOR_I420;
-- 
1.7.9.5

--
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 v5 3/5] media: Add Mediatek MDP Driver

2016-08-30 Thread Minghsiu Tsai
Add MDP driver for MT8173

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 drivers/media/platform/Kconfig|   17 +
 drivers/media/platform/Makefile   |2 +
 drivers/media/platform/mtk-mdp/Makefile   |9 +
 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c |  159 
 drivers/media/platform/mtk-mdp/mtk_mdp_comp.h |   72 ++
 drivers/media/platform/mtk-mdp/mtk_mdp_core.c |  294 ++
 drivers/media/platform/mtk-mdp/mtk_mdp_core.h |  260 +
 drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h  |  126 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c  | 1270 +
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h  |   22 +
 drivers/media/platform/mtk-mdp/mtk_mdp_regs.c |  152 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_regs.h |   31 +
 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c  |  145 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h  |   41 +
 14 files changed, 2600 insertions(+)
 create mode 100644 drivers/media/platform/mtk-mdp/Makefile
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_comp.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_core.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_core.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_regs.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_regs.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index f25344b..0c88532 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -166,6 +166,23 @@ config VIDEO_MEDIATEK_VPU
To compile this driver as a module, choose M here: the
module will be called mtk-vpu.
 
+config VIDEO_MEDIATEK_MDP
+   tristate "Mediatek MDP driver"
+   depends on MTK_IOMMU || COMPILE_TEST
+   depends on VIDEO_DEV && VIDEO_V4L2
+   depends on ARCH_MEDIATEK || COMPILE_TEST
+   depends on HAS_DMA
+   select VIDEOBUF2_DMA_CONTIG
+   select V4L2_MEM2MEM_DEV
+   select VIDEO_MEDIATEK_VPU
+   default n
+   ---help---
+   It is a v4l2 driver and present in Mediatek MT8173 SoCs.
+   The driver supports for scaling and color space conversion.
+
+   To compile this driver as a module, choose M here: the
+   module will be called mtk-mdp.
+
 config VIDEO_MEDIATEK_VCODEC
tristate "Mediatek Video Codec driver"
depends on MTK_IOMMU || COMPILE_TEST
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 21771c1..221aace 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -63,3 +63,5 @@ ccflags-y += -I$(srctree)/drivers/media/i2c
 obj-$(CONFIG_VIDEO_MEDIATEK_VPU)   += mtk-vpu/
 
 obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC)+= mtk-vcodec/
+
+obj-$(CONFIG_VIDEO_MEDIATEK_MDP)   += mtk-mdp/
diff --git a/drivers/media/platform/mtk-mdp/Makefile 
b/drivers/media/platform/mtk-mdp/Makefile
new file mode 100644
index 000..f802569
--- /dev/null
+++ b/drivers/media/platform/mtk-mdp/Makefile
@@ -0,0 +1,9 @@
+mtk-mdp-y += mtk_mdp_core.o
+mtk-mdp-y += mtk_mdp_comp.o
+mtk-mdp-y += mtk_mdp_m2m.o
+mtk-mdp-y += mtk_mdp_regs.o
+mtk-mdp-y += mtk_mdp_vpu.o
+
+obj-$(CONFIG_VIDEO_MEDIATEK_MDP) += mtk-mdp.o
+
+ccflags-y += -I$(srctree)/drivers/media/platform/mtk-vpu
diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c 
b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
new file mode 100644
index 000..aa8f9fd
--- /dev/null
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: Ming Hsiu Tsai <minghsiu.t...@mediatek.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mtk_mdp_comp.h"
+
+
+static const char * const mtk_mdp_comp_stem[MTK_MDP_COMP_TYPE_MAX] = {
+   "mdp_rdma",
+   "mdp_rsz",
+   "mdp_wdma",
+   "mdp_wrot",
+};
+
+struct mtk_mdp_comp_match {
+   enum mtk_mdp_comp_type type;
+   int alias_id;
+};
+
+static const struct mtk_mdp_comp_match mtk_mdp_matches[MTK_MDP_COMP_I

[PATCH v5 0/5] Add MT8173 MDP Driver

2016-08-30 Thread Minghsiu Tsai
K
test Composing: OK
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:


Total: 43, Succeeded: 43, Failed: 0, Warnings: 0


Minghsiu Tsai (5):
  VPU: mediatek: Add mdp support
  dt-bindings: Add a binding for Mediatek MDP
  media: Add Mediatek MDP Driver
  arm64: dts: mediatek: Add MDP for MT8173
  media: mtk-mdp: support pixelformat V4L2_PIX_FMT_MT21C

 .../devicetree/bindings/media/mediatek-mdp.txt |  109 ++
 arch/arm64/boot/dts/mediatek/mt8173.dtsi   |   84 ++
 drivers/media/platform/Kconfig |   17 +
 drivers/media/platform/Makefile|2 +
 drivers/media/platform/mtk-mdp/Makefile|9 +
 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c  |  159 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_comp.h  |   72 ++
 drivers/media/platform/mtk-mdp/mtk_mdp_core.c  |  294 +
 drivers/media/platform/mtk-mdp/mtk_mdp_core.h  |  260 
 drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h   |  126 ++
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c   | 1278 
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h   |   22 +
 drivers/media/platform/mtk-mdp/mtk_mdp_regs.c  |  156 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_regs.h  |   31 +
 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c   |  145 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h   |   41 +
 drivers/media/platform/mtk-vpu/mtk_vpu.h   |5 +
 17 files changed, 2810 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/mediatek-mdp.txt
 create mode 100644 drivers/media/platform/mtk-mdp/Makefile
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_comp.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_core.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_core.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_regs.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_regs.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h

-- 
1.7.9.5

--
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 v5 4/5] arm64: dts: mediatek: Add MDP for MT8173

2016-08-30 Thread Minghsiu Tsai
Add MDP node for MT8173

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   84 ++
 1 file changed, 84 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 10f638f..cd93228 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -41,6 +41,14 @@
dpi0 = 
dsi0 = 
dsi1 = 
+   mdp_rdma0 = _rdma0;
+   mdp_rdma1 = _rdma1;
+   mdp_rsz0 = _rsz0;
+   mdp_rsz1 = _rsz1;
+   mdp_rsz2 = _rsz2;
+   mdp_wdma0 = _wdma0;
+   mdp_wrot0 = _wrot0;
+   mdp_wrot1 = _wrot1;
};
 
cpus {
@@ -716,6 +724,82 @@
#clock-cells = <1>;
};
 
+   mdp {
+   compatible = "mediatek,mt8173-mdp";
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+   mediatek,vpu = <>;
+
+   mdp_rdma0: rdma@14001000 {
+   compatible = "mediatek,mt8173-mdp-rdma";
+   reg = <0 0x14001000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA0>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA0>;
+   mediatek,larb = <>;
+   };
+
+   mdp_rdma1: rdma@14002000 {
+   compatible = "mediatek,mt8173-mdp-rdma";
+   reg = <0 0x14002000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA1>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA1>;
+   mediatek,larb = <>;
+   };
+
+   mdp_rsz0: rsz@14003000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14003000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ0>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_rsz1: rsz@14004000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14004000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ1>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_rsz2: rsz@14005000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14005000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ2>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_wdma0: wdma@14006000 {
+   compatible = "mediatek,mt8173-mdp-wdma";
+   reg = <0 0x14006000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WDMA>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WDMA>;
+   mediatek,larb = <>;
+   };
+
+   mdp_wrot0: wrot@14007000 {
+   compatible = "mediatek,mt8173-mdp-wrot";
+   reg = <0 0x14007000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WROT0>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WROT0>;
+   mediatek,larb = <>;
+   };
+
+   mdp_wrot1: wrot@14008000 {
+   compatible = "mediatek,mt8173-mdp-wrot";
+   reg = <0 0x14008000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WROT1>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WROT1>;
+   mediatek,larb = <>;
+

Re: [PATCH v4 2/4] dt-bindings: Add a binding for Mediatek MDP

2016-08-21 Thread Minghsiu Tsai
On Fri, 2016-08-19 at 09:16 -0500, Rob Herring wrote:
> On Fri, Aug 19, 2016 at 07:39:25PM +0800, Minghsiu Tsai wrote:
> > Add a DT binding documentation of MDP for the MT8173 SoC
> > from Mediatek
> > 
> > Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
> > ---
> >  .../devicetree/bindings/media/mediatek-mdp.txt |  109 
> > 
> >  1 file changed, 109 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/media/mediatek-mdp.txt
> 
> Please add acks when posting new versions.
> 
> Rob

Sorry for my mistake. I will add it in next version.

--
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 v4 1/4] VPU: mediatek: Add mdp support

2016-08-19 Thread Minghsiu Tsai
VPU driver add mdp support

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 drivers/media/platform/mtk-vpu/mtk_vpu.h |5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/media/platform/mtk-vpu/mtk_vpu.h 
b/drivers/media/platform/mtk-vpu/mtk_vpu.h
index f457479..291ae46 100644
--- a/drivers/media/platform/mtk-vpu/mtk_vpu.h
+++ b/drivers/media/platform/mtk-vpu/mtk_vpu.h
@@ -53,6 +53,8 @@ typedef void (*ipi_handler_t) (void *data,
 handle H264 video encoder job, and vice versa.
  * @IPI_VENC_VP8:   The interrupt fro vpu is to notify kernel to
 handle VP8 video encoder job,, and vice versa.
+ * @IPI_MDP:The interrupt from vpu is to notify kernel to
+handle MDP (Media Data Path) job, and vice versa.
  * @IPI_MAX:The maximum IPI number
  */
 
@@ -63,6 +65,7 @@ enum ipi_id {
IPI_VDEC_VP9,
IPI_VENC_H264,
IPI_VENC_VP8,
+   IPI_MDP,
IPI_MAX,
 };
 
@@ -71,11 +74,13 @@ enum ipi_id {
  *
  * @VPU_RST_ENC: encoder reset id
  * @VPU_RST_DEC: decoder reset id
+ * @VPU_RST_MDP: MDP (Media Data Path) reset id
  * @VPU_RST_MAX: maximum reset id
  */
 enum rst_id {
VPU_RST_ENC,
VPU_RST_DEC,
+   VPU_RST_MDP,
VPU_RST_MAX,
 };
 
-- 
1.7.9.5

--
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 v4 3/4] media: Add Mediatek MDP Driver

2016-08-19 Thread Minghsiu Tsai
Add MDP driver for MT8173

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 drivers/media/platform/Kconfig|   17 +
 drivers/media/platform/Makefile   |2 +
 drivers/media/platform/mtk-mdp/Makefile   |9 +
 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c |  159 
 drivers/media/platform/mtk-mdp/mtk_mdp_comp.h |   72 ++
 drivers/media/platform/mtk-mdp/mtk_mdp_core.c |  294 ++
 drivers/media/platform/mtk-mdp/mtk_mdp_core.h |  260 +
 drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h  |  126 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c  | 1269 +
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h  |   22 +
 drivers/media/platform/mtk-mdp/mtk_mdp_regs.c |  156 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_regs.h |   31 +
 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c  |  145 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h  |   41 +
 14 files changed, 2603 insertions(+)
 create mode 100644 drivers/media/platform/mtk-mdp/Makefile
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_comp.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_core.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_core.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_regs.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_regs.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index f25344b..0c88532 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -166,6 +166,23 @@ config VIDEO_MEDIATEK_VPU
To compile this driver as a module, choose M here: the
module will be called mtk-vpu.
 
+config VIDEO_MEDIATEK_MDP
+   tristate "Mediatek MDP driver"
+   depends on MTK_IOMMU || COMPILE_TEST
+   depends on VIDEO_DEV && VIDEO_V4L2
+   depends on ARCH_MEDIATEK || COMPILE_TEST
+   depends on HAS_DMA
+   select VIDEOBUF2_DMA_CONTIG
+   select V4L2_MEM2MEM_DEV
+   select VIDEO_MEDIATEK_VPU
+   default n
+   ---help---
+   It is a v4l2 driver and present in Mediatek MT8173 SoCs.
+   The driver supports for scaling and color space conversion.
+
+   To compile this driver as a module, choose M here: the
+   module will be called mtk-mdp.
+
 config VIDEO_MEDIATEK_VCODEC
tristate "Mediatek Video Codec driver"
depends on MTK_IOMMU || COMPILE_TEST
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 21771c1..221aace 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -63,3 +63,5 @@ ccflags-y += -I$(srctree)/drivers/media/i2c
 obj-$(CONFIG_VIDEO_MEDIATEK_VPU)   += mtk-vpu/
 
 obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC)+= mtk-vcodec/
+
+obj-$(CONFIG_VIDEO_MEDIATEK_MDP)   += mtk-mdp/
diff --git a/drivers/media/platform/mtk-mdp/Makefile 
b/drivers/media/platform/mtk-mdp/Makefile
new file mode 100644
index 000..f802569
--- /dev/null
+++ b/drivers/media/platform/mtk-mdp/Makefile
@@ -0,0 +1,9 @@
+mtk-mdp-y += mtk_mdp_core.o
+mtk-mdp-y += mtk_mdp_comp.o
+mtk-mdp-y += mtk_mdp_m2m.o
+mtk-mdp-y += mtk_mdp_regs.o
+mtk-mdp-y += mtk_mdp_vpu.o
+
+obj-$(CONFIG_VIDEO_MEDIATEK_MDP) += mtk-mdp.o
+
+ccflags-y += -I$(srctree)/drivers/media/platform/mtk-vpu
diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c 
b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
new file mode 100644
index 000..aa8f9fd
--- /dev/null
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: Ming Hsiu Tsai <minghsiu.t...@mediatek.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mtk_mdp_comp.h"
+
+
+static const char * const mtk_mdp_comp_stem[MTK_MDP_COMP_TYPE_MAX] = {
+   "mdp_rdma",
+   "mdp_rsz",
+   "mdp_wdma",
+   "mdp_wrot",
+};
+
+struct mtk_mdp_comp_match {
+   enum mtk_mdp_comp_type type;
+   int alias_id;
+};
+
+static const struct mtk_mdp_comp_match mtk_mdp_matches[MTK_MDP_COMP_I

[PATCH v4 0/4] Add MT8173 MDP Driver

2016-08-19 Thread Minghsiu Tsai
(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:


Total: 43, Succeeded: 43, Failed: 0, Warnings: 0


Minghsiu Tsai (4):
  VPU: mediatek: Add mdp support
  dt-bindings: Add a binding for Mediatek MDP
  media: Add Mediatek MDP Driver
  arm64: dts: mediatek: Add MDP for MT8173

 .../devicetree/bindings/media/mediatek-mdp.txt |  109 ++
 arch/arm64/boot/dts/mediatek/mt8173.dtsi   |   84 ++
 drivers/media/platform/Kconfig |   17 +
 drivers/media/platform/Makefile|2 +
 drivers/media/platform/mtk-mdp/Makefile|9 +
 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c  |  159 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_comp.h  |   72 ++
 drivers/media/platform/mtk-mdp/mtk_mdp_core.c  |  294 +
 drivers/media/platform/mtk-mdp/mtk_mdp_core.h  |  260 
 drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h   |  126 ++
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c   | 1269 
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h   |   22 +
 drivers/media/platform/mtk-mdp/mtk_mdp_regs.c  |  156 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_regs.h  |   31 +
 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c   |  145 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h   |   41 +
 drivers/media/platform/mtk-vpu/mtk_vpu.h   |5 +
 17 files changed, 2801 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/mediatek-mdp.txt
 create mode 100644 drivers/media/platform/mtk-mdp/Makefile
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_comp.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_core.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_core.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_regs.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_regs.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h

-- 
1.7.9.5

--
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 v4 2/4] dt-bindings: Add a binding for Mediatek MDP

2016-08-19 Thread Minghsiu Tsai
Add a DT binding documentation of MDP for the MT8173 SoC
from Mediatek

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 .../devicetree/bindings/media/mediatek-mdp.txt |  109 
 1 file changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/mediatek-mdp.txt

diff --git a/Documentation/devicetree/bindings/media/mediatek-mdp.txt 
b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
new file mode 100644
index 000..4182063
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
@@ -0,0 +1,109 @@
+* Mediatek Media Data Path
+
+Media Data Path is used for scaling and color space conversion.
+
+Required properties (controller (parent) node):
+- compatible: "mediatek,mt8173-mdp"
+- mediatek,vpu: the node of video processor unit, see
+  Documentation/devicetree/bindings/media/mediatek-vpu.txt for details.
+
+Required properties (all function blocks, child node):
+- compatible: Should be one of
+"mediatek,mt8173-mdp-rdma"  - read DMA
+"mediatek,mt8173-mdp-rsz"   - resizer
+"mediatek,mt8173-mdp-wdma"  - write DMA
+"mediatek,mt8173-mdp-wrot"  - write DMA with rotation
+- reg: Physical base address and length of the function block register space
+- clocks: device clocks, see
+  Documentation/devicetree/bindings/clock/clock-bindings.txt for details.
+- power-domains: a phandle to the power domain, see
+  Documentation/devicetree/bindings/power/power_domain.txt for details.
+
+Required properties (DMA function blocks, child node):
+- compatible: Should be one of
+"mediatek,mt8173-mdp-rdma"
+"mediatek,mt8173-mdp-wdma"
+"mediatek,mt8173-mdp-wrot"
+- iommus: should point to the respective IOMMU block with master port as
+  argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt
+  for details.
+- mediatek,larb: must contain the local arbiters in the current Socs, see
+  Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.txt
+  for details.
+
+Example:
+mdp {
+   compatible = "mediatek,mt8173-mdp";
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+   mediatek,vpu = <>;
+
+   mdp_rdma0: rdma@14001000 {
+   compatible = "mediatek,mt8173-mdp-rdma";
+   reg = <0 0x14001000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA0>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA0>;
+   mediatek,larb = <>;
+   };
+
+   mdp_rdma1: rdma@14002000 {
+   compatible = "mediatek,mt8173-mdp-rdma";
+   reg = <0 0x14002000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA1>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA1>;
+   mediatek,larb = <>;
+   };
+
+   mdp_rsz0: rsz@14003000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14003000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ0>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_rsz1: rsz@14004000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14004000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ1>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_rsz2: rsz@14005000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14005000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ2>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_wdma0: wdma@14006000 {
+   compatible = "mediatek,mt8173-mdp-wdma";
+   reg = <0 0x14006000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WDMA>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WDMA>;
+   mediatek,larb = <>;
+   };
+
+   mdp_wrot0: wrot@14007000 {
+   compatible = "mediatek,mt8173-mdp-wrot";
+   reg = <0 0x14007000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WROT0>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WROT0>;
+   mediatek,larb = <>;
+   };
+
+   mdp_wrot1: wrot@14008000 {
+   compatible = "mediatek,mt8173-mdp-wrot";
+   reg = <0 0x14008000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WROT1>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WROT1>;
+   mediatek,larb = <>;
+   };
+};
-- 
1.7.9.5

--
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 v4 4/4] arm64: dts: mediatek: Add MDP for MT8173

2016-08-19 Thread Minghsiu Tsai
Add MDP node for MT8173

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   84 ++
 1 file changed, 84 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 10f638f..cd93228 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -41,6 +41,14 @@
dpi0 = 
dsi0 = 
dsi1 = 
+   mdp_rdma0 = _rdma0;
+   mdp_rdma1 = _rdma1;
+   mdp_rsz0 = _rsz0;
+   mdp_rsz1 = _rsz1;
+   mdp_rsz2 = _rsz2;
+   mdp_wdma0 = _wdma0;
+   mdp_wrot0 = _wrot0;
+   mdp_wrot1 = _wrot1;
};
 
cpus {
@@ -716,6 +724,82 @@
#clock-cells = <1>;
};
 
+   mdp {
+   compatible = "mediatek,mt8173-mdp";
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+   mediatek,vpu = <>;
+
+   mdp_rdma0: rdma@14001000 {
+   compatible = "mediatek,mt8173-mdp-rdma";
+   reg = <0 0x14001000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA0>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA0>;
+   mediatek,larb = <>;
+   };
+
+   mdp_rdma1: rdma@14002000 {
+   compatible = "mediatek,mt8173-mdp-rdma";
+   reg = <0 0x14002000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA1>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA1>;
+   mediatek,larb = <>;
+   };
+
+   mdp_rsz0: rsz@14003000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14003000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ0>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_rsz1: rsz@14004000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14004000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ1>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_rsz2: rsz@14005000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14005000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ2>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_wdma0: wdma@14006000 {
+   compatible = "mediatek,mt8173-mdp-wdma";
+   reg = <0 0x14006000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WDMA>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WDMA>;
+   mediatek,larb = <>;
+   };
+
+   mdp_wrot0: wrot@14007000 {
+   compatible = "mediatek,mt8173-mdp-wrot";
+   reg = <0 0x14007000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WROT0>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WROT0>;
+   mediatek,larb = <>;
+   };
+
+   mdp_wrot1: wrot@14008000 {
+   compatible = "mediatek,mt8173-mdp-wrot";
+   reg = <0 0x14008000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WROT1>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WROT1>;
+   mediatek,larb = <>;
+

Re: [PATCH v3 3/4] media: Add Mediatek MDP Driver

2016-08-19 Thread Minghsiu Tsai
On Mon, 2016-08-15 at 14:55 +0200, Hans Verkuil wrote:
> On 08/09/2016 03:58 PM, Minghsiu Tsai wrote:
> > Add MDP driver for MT8173
> > 
> > Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
> > ---
> >  drivers/media/platform/Kconfig|   16 +
> >  drivers/media/platform/Makefile   |2 +
> >  drivers/media/platform/mtk-mdp/Makefile   |9 +
> >  drivers/media/platform/mtk-mdp/mtk_mdp_comp.c |  159 
> >  drivers/media/platform/mtk-mdp/mtk_mdp_comp.h |   72 ++
> >  drivers/media/platform/mtk-mdp/mtk_mdp_core.c |  294 ++
> >  drivers/media/platform/mtk-mdp/mtk_mdp_core.h |  240 +
> >  drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h  |  126 +++
> >  drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c  | 1263 
> > +
> >  drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h  |   22 +
> >  drivers/media/platform/mtk-mdp/mtk_mdp_regs.c |  153 +++
> >  drivers/media/platform/mtk-mdp/mtk_mdp_regs.h |   31 +
> >  drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c  |  145 +++
> >  drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h  |   41 +
> >  14 files changed, 2573 insertions(+)
> >  create mode 100644 drivers/media/platform/mtk-mdp/Makefile
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_comp.h
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_core.c
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_core.h
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_regs.c
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_regs.h
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h
> > 
> > diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
> > index f25344b..4bb874b 100644
> > --- a/drivers/media/platform/Kconfig
> > +++ b/drivers/media/platform/Kconfig
> > @@ -166,6 +166,22 @@ config VIDEO_MEDIATEK_VPU
> > To compile this driver as a module, choose M here: the
> > module will be called mtk-vpu.
> >  
> > +config VIDEO_MEDIATEK_MDP
> > +   tristate "Mediatek MDP driver"
> > +   depends on MTK_IOMMU || COMPILE_TEST
> > +   depends on VIDEO_DEV && VIDEO_V4L2
> > +   depends on ARCH_MEDIATEK || COMPILE_TEST
> 
> This needs a 'depends on HAS_DMA' as well.
> 

Will add it.

> > +   select VIDEOBUF2_DMA_CONTIG
> > +   select V4L2_MEM2MEM_DEV
> > +   select VIDEO_MEDIATEK_VPU
> > +   default n
> > +   ---help---
> > +   It is a v4l2 driver and present in Mediatek MT8173 SoCs.
> > +   The driver supports for scaling and color space conversion.
> > +
> > +   To compile this driver as a module, choose M here: the
> > +   module will be called mtk-mdp.
> > +
> >  config VIDEO_MEDIATEK_VCODEC
> > tristate "Mediatek Video Codec driver"
> > depends on MTK_IOMMU || COMPILE_TEST
> 
> 
> 
> > +
> > +/*
> > + * Return true if rectangle a is enclosed in rectangle b, or false 
> > otherwise.
> > + */
> > +static bool mtk_mdp_m2m_is_rectangle_enclosed(struct v4l2_rect *a,
> > +struct v4l2_rect *b)
> > +{
> > +   if (a->left < b->left || a->top < b->top)
> > +   return false;
> > +
> > +   if (a->left + a->width > b->left + b->width)
> > +   return false;
> > +
> > +   if (a->top + a->height > b->top + b->height)
> > +   return false;
> > +
> > +   return true;
> > +}
> > +
> > +static int mtk_mdp_m2m_g_selection(struct file *file, void *fh,
> > +  struct v4l2_selection *s)
> > +{
> > +   struct mtk_mdp_frame *frame;
> > +   struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
> > +
> > +   if ((s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) &&
> > +   (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)) {
> > +   mtk_mdp_dbg(1, "[%d] invalid type:%d", ctx->id, s->type);
> > +   return -EINVAL;
> > +   }
> > +
> > +   frame = mtk_mdp_ctx_get_frame(ctx, s->type);
> > +
> > +   switch (s->target) {
> > +   case V4L2_SEL_TGT_COMPOSE

[PATCH v3 3/4] media: Add Mediatek MDP Driver

2016-08-09 Thread Minghsiu Tsai
Add MDP driver for MT8173

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 drivers/media/platform/Kconfig|   16 +
 drivers/media/platform/Makefile   |2 +
 drivers/media/platform/mtk-mdp/Makefile   |9 +
 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c |  159 
 drivers/media/platform/mtk-mdp/mtk_mdp_comp.h |   72 ++
 drivers/media/platform/mtk-mdp/mtk_mdp_core.c |  294 ++
 drivers/media/platform/mtk-mdp/mtk_mdp_core.h |  240 +
 drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h  |  126 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c  | 1263 +
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h  |   22 +
 drivers/media/platform/mtk-mdp/mtk_mdp_regs.c |  153 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_regs.h |   31 +
 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c  |  145 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h  |   41 +
 14 files changed, 2573 insertions(+)
 create mode 100644 drivers/media/platform/mtk-mdp/Makefile
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_comp.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_core.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_core.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_regs.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_regs.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index f25344b..4bb874b 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -166,6 +166,22 @@ config VIDEO_MEDIATEK_VPU
To compile this driver as a module, choose M here: the
module will be called mtk-vpu.
 
+config VIDEO_MEDIATEK_MDP
+   tristate "Mediatek MDP driver"
+   depends on MTK_IOMMU || COMPILE_TEST
+   depends on VIDEO_DEV && VIDEO_V4L2
+   depends on ARCH_MEDIATEK || COMPILE_TEST
+   select VIDEOBUF2_DMA_CONTIG
+   select V4L2_MEM2MEM_DEV
+   select VIDEO_MEDIATEK_VPU
+   default n
+   ---help---
+   It is a v4l2 driver and present in Mediatek MT8173 SoCs.
+   The driver supports for scaling and color space conversion.
+
+   To compile this driver as a module, choose M here: the
+   module will be called mtk-mdp.
+
 config VIDEO_MEDIATEK_VCODEC
tristate "Mediatek Video Codec driver"
depends on MTK_IOMMU || COMPILE_TEST
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 21771c1..221aace 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -63,3 +63,5 @@ ccflags-y += -I$(srctree)/drivers/media/i2c
 obj-$(CONFIG_VIDEO_MEDIATEK_VPU)   += mtk-vpu/
 
 obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC)+= mtk-vcodec/
+
+obj-$(CONFIG_VIDEO_MEDIATEK_MDP)   += mtk-mdp/
diff --git a/drivers/media/platform/mtk-mdp/Makefile 
b/drivers/media/platform/mtk-mdp/Makefile
new file mode 100644
index 000..f802569
--- /dev/null
+++ b/drivers/media/platform/mtk-mdp/Makefile
@@ -0,0 +1,9 @@
+mtk-mdp-y += mtk_mdp_core.o
+mtk-mdp-y += mtk_mdp_comp.o
+mtk-mdp-y += mtk_mdp_m2m.o
+mtk-mdp-y += mtk_mdp_regs.o
+mtk-mdp-y += mtk_mdp_vpu.o
+
+obj-$(CONFIG_VIDEO_MEDIATEK_MDP) += mtk-mdp.o
+
+ccflags-y += -I$(srctree)/drivers/media/platform/mtk-vpu
diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c 
b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
new file mode 100644
index 000..aa8f9fd
--- /dev/null
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: Ming Hsiu Tsai <minghsiu.t...@mediatek.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mtk_mdp_comp.h"
+
+
+static const char * const mtk_mdp_comp_stem[MTK_MDP_COMP_TYPE_MAX] = {
+   "mdp_rdma",
+   "mdp_rsz",
+   "mdp_wdma",
+   "mdp_wrot",
+};
+
+struct mtk_mdp_comp_match {
+   enum mtk_mdp_comp_type type;
+   int alias_id;
+};
+
+static const struct mtk_mdp_comp_match mtk_mdp_matches[MTK_MDP_COMP_ID_MA

[PATCH v3 0/4] Add MT8173 MDP Driver

2016-08-09 Thread Minghsiu Tsai
Changes in v3:
- Modify device ndoe as structured one.
- Fix conflict in dts on Linux 4.8-rc1

Changes in v2:
- Add section to describe blocks function in dts-bindings
- Remove the assignment of device_caps in querycap()
- Remove format's name assignment
- Copy colorspace-related parameters from OUTPUT to CAPTURE
- Use m2m helper functions
- Fix DMA allocation failure
- Initialize lazily vpu instance in streamon()

==
 Introduction
==

The purpose of this series is to add the driver for Media Data Path HW embedded 
in the Mediatek's MT8173 SoC.
MDP is used for scaling and color space conversion.

It could convert V4L2_PIX_FMT_MT21 to V4L2_PIX_FMT_NV12M or 
V4L2_PIX_FMT_YUV420M.

NV12M/YUV420M/MT21 -> MDP -> NV12M/YUV420M

This patch series rely on MTK VPU driver in patch series "Add MT8173 Video 
Encoder Driver and VPU Driver"[1] and "Add MT8173 Video Decoder Driver"[2].
MDP driver rely on VPU driver to load, communicate with VPU.

Internally the driver uses videobuf2 framework and MTK IOMMU and MTK SMI both 
have been merged in v4.6-rc1.

[1]https://patchwork.kernel.org/patch/9002171/
[2]https://patchwork.kernel.org/patch/9141245/

==
 Device interface
==

In principle the driver bases on v4l2 memory-to-memory framework:
it provides a single video node and each opened file handle gets its own 
private context with separate buffer queues. Each context consist of 2 buffer 
queues: OUTPUT (for source buffers) and CAPTURE (for destination buffers).
OUTPUT and CAPTURE buffer could be MMAP or DMABUF memory type.

v4l2-compliance test output:
# v4l2-compliance -d /dev/image-proc0
v4l2-compliance SHA   : ee1ab491019f80052834d14c76bdd1c1b46f2158

Driver Info:
Driver name   : mtk-mdp
Card type : soc:mdp
Bus info  : platform:mt8173
Driver version: 4.8.0
Capabilities  : 0x84204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format
Device Capabilities
Device Caps   : 0x04204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format

Compliance test for device /dev/image-proc0 (not using libv4l2):

Required ioctls:
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second video open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK

Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK (Not Supported)

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK (Not Supported)
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)

Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 5 Private Controls: 0

Format ioctls:
test 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
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK
test Composing: OK
test Scaling: OK (Not Supported)

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:


Total: 43, Succeeded: 43, Failed: 0, Warnings: 0


Minghsiu Tsai (4):
  VPU: mediatek: Add mdp support
  dt-bindings: Add 

[PATCH v3 1/4] VPU: mediatek: Add mdp support

2016-08-09 Thread Minghsiu Tsai
VPU driver add mdp support

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 drivers/media/platform/mtk-vpu/mtk_vpu.h |5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/media/platform/mtk-vpu/mtk_vpu.h 
b/drivers/media/platform/mtk-vpu/mtk_vpu.h
index f457479..291ae46 100644
--- a/drivers/media/platform/mtk-vpu/mtk_vpu.h
+++ b/drivers/media/platform/mtk-vpu/mtk_vpu.h
@@ -53,6 +53,8 @@ typedef void (*ipi_handler_t) (void *data,
 handle H264 video encoder job, and vice versa.
  * @IPI_VENC_VP8:   The interrupt fro vpu is to notify kernel to
 handle VP8 video encoder job,, and vice versa.
+ * @IPI_MDP:The interrupt from vpu is to notify kernel to
+handle MDP (Media Data Path) job, and vice versa.
  * @IPI_MAX:The maximum IPI number
  */
 
@@ -63,6 +65,7 @@ enum ipi_id {
IPI_VDEC_VP9,
IPI_VENC_H264,
IPI_VENC_VP8,
+   IPI_MDP,
IPI_MAX,
 };
 
@@ -71,11 +74,13 @@ enum ipi_id {
  *
  * @VPU_RST_ENC: encoder reset id
  * @VPU_RST_DEC: decoder reset id
+ * @VPU_RST_MDP: MDP (Media Data Path) reset id
  * @VPU_RST_MAX: maximum reset id
  */
 enum rst_id {
VPU_RST_ENC,
VPU_RST_DEC,
+   VPU_RST_MDP,
VPU_RST_MAX,
 };
 
-- 
1.7.9.5

--
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 4/4] arm64: dts: mediatek: Add MDP for MT8173

2016-08-09 Thread Minghsiu Tsai
Add MDP node for MT8173

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   84 ++
 1 file changed, 84 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 10f638f..cd93228 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -41,6 +41,14 @@
dpi0 = 
dsi0 = 
dsi1 = 
+   mdp_rdma0 = _rdma0;
+   mdp_rdma1 = _rdma1;
+   mdp_rsz0 = _rsz0;
+   mdp_rsz1 = _rsz1;
+   mdp_rsz2 = _rsz2;
+   mdp_wdma0 = _wdma0;
+   mdp_wrot0 = _wrot0;
+   mdp_wrot1 = _wrot1;
};
 
cpus {
@@ -716,6 +724,82 @@
#clock-cells = <1>;
};
 
+   mdp {
+   compatible = "mediatek,mt8173-mdp";
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+   mediatek,vpu = <>;
+
+   mdp_rdma0: rdma@14001000 {
+   compatible = "mediatek,mt8173-mdp-rdma";
+   reg = <0 0x14001000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA0>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA0>;
+   mediatek,larb = <>;
+   };
+
+   mdp_rdma1: rdma@14002000 {
+   compatible = "mediatek,mt8173-mdp-rdma";
+   reg = <0 0x14002000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA1>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA1>;
+   mediatek,larb = <>;
+   };
+
+   mdp_rsz0: rsz@14003000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14003000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ0>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_rsz1: rsz@14004000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14004000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ1>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_rsz2: rsz@14005000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14005000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ2>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_wdma0: wdma@14006000 {
+   compatible = "mediatek,mt8173-mdp-wdma";
+   reg = <0 0x14006000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WDMA>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WDMA>;
+   mediatek,larb = <>;
+   };
+
+   mdp_wrot0: wrot@14007000 {
+   compatible = "mediatek,mt8173-mdp-wrot";
+   reg = <0 0x14007000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WROT0>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WROT0>;
+   mediatek,larb = <>;
+   };
+
+   mdp_wrot1: wrot@14008000 {
+   compatible = "mediatek,mt8173-mdp-wrot";
+   reg = <0 0x14008000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WROT1>;
+   power-domains = < 
MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WROT1>;
+   mediatek,larb = <>;
+

[PATCH v3 2/4] dt-bindings: Add a binding for Mediatek MDP

2016-08-09 Thread Minghsiu Tsai
Add a DT binding documentation of MDP for the MT8173 SoC
from Mediatek

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 .../devicetree/bindings/media/mediatek-mdp.txt |  109 
 1 file changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/mediatek-mdp.txt

diff --git a/Documentation/devicetree/bindings/media/mediatek-mdp.txt 
b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
new file mode 100644
index 000..4182063
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
@@ -0,0 +1,109 @@
+* Mediatek Media Data Path
+
+Media Data Path is used for scaling and color space conversion.
+
+Required properties (controller (parent) node):
+- compatible: "mediatek,mt8173-mdp"
+- mediatek,vpu: the node of video processor unit, see
+  Documentation/devicetree/bindings/media/mediatek-vpu.txt for details.
+
+Required properties (all function blocks, child node):
+- compatible: Should be one of
+"mediatek,mt8173-mdp-rdma"  - read DMA
+"mediatek,mt8173-mdp-rsz"   - resizer
+"mediatek,mt8173-mdp-wdma"  - write DMA
+"mediatek,mt8173-mdp-wrot"  - write DMA with rotation
+- reg: Physical base address and length of the function block register space
+- clocks: device clocks, see
+  Documentation/devicetree/bindings/clock/clock-bindings.txt for details.
+- power-domains: a phandle to the power domain, see
+  Documentation/devicetree/bindings/power/power_domain.txt for details.
+
+Required properties (DMA function blocks, child node):
+- compatible: Should be one of
+"mediatek,mt8173-mdp-rdma"
+"mediatek,mt8173-mdp-wdma"
+"mediatek,mt8173-mdp-wrot"
+- iommus: should point to the respective IOMMU block with master port as
+  argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt
+  for details.
+- mediatek,larb: must contain the local arbiters in the current Socs, see
+  Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.txt
+  for details.
+
+Example:
+mdp {
+   compatible = "mediatek,mt8173-mdp";
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+   mediatek,vpu = <>;
+
+   mdp_rdma0: rdma@14001000 {
+   compatible = "mediatek,mt8173-mdp-rdma";
+   reg = <0 0x14001000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA0>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA0>;
+   mediatek,larb = <>;
+   };
+
+   mdp_rdma1: rdma@14002000 {
+   compatible = "mediatek,mt8173-mdp-rdma";
+   reg = <0 0x14002000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA1>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA1>;
+   mediatek,larb = <>;
+   };
+
+   mdp_rsz0: rsz@14003000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14003000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ0>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_rsz1: rsz@14004000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14004000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ1>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_rsz2: rsz@14005000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14005000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ2>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_wdma0: wdma@14006000 {
+   compatible = "mediatek,mt8173-mdp-wdma";
+   reg = <0 0x14006000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WDMA>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WDMA>;
+   mediatek,larb = <>;
+   };
+
+   mdp_wrot0: wrot@14007000 {
+   compatible = "mediatek,mt8173-mdp-wrot";
+   reg = <0 0x14007000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WROT0>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WROT0>;
+   mediatek,larb = <>;
+   };
+
+   mdp_wrot1: wrot@14008000 {
+   compatible = "mediatek,mt8173-mdp-wrot";
+   reg = <0 0x14008000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WROT1>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WROT1>;
+   mediatek,larb = <>;
+   };
+};
-- 
1.7.9.5

--
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 v2 2/4] dt-bindings: Add a binding for Mediatek MDP

2016-08-02 Thread Minghsiu Tsai
On Thu, 2016-07-28 at 10:55 -0500, Rob Herring wrote:
> On Tue, Jul 26, 2016 at 8:44 PM, Minghsiu Tsai
> <minghsiu.t...@mediatek.com> wrote:
> > On Tue, 2016-07-26 at 13:54 -0500, Rob Herring wrote:
> >> On Fri, Jul 22, 2016 at 04:33:01PM +0800, Minghsiu Tsai wrote:
> >> > Add a DT binding documentation of MDP for the MT8173 SoC
> >> > from Mediatek
> >> >
> >> > Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
> >> > ---
> >> >  .../devicetree/bindings/media/mediatek-mdp.txt |   96 
> >> > 
> >> >  1 file changed, 96 insertions(+)
> >> >  create mode 100644 
> >> > Documentation/devicetree/bindings/media/mediatek-mdp.txt
> >> >
> >> > diff --git a/Documentation/devicetree/bindings/media/mediatek-mdp.txt 
> >> > b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
> >> > new file mode 100644
> >> > index 000..2dad031
> >> > --- /dev/null
> >> > +++ b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
> >> > @@ -0,0 +1,96 @@
> >> > +* Mediatek Media Data Path
> >> > +
> >> > +Media Data Path is used for scaling and color space conversion.
> >> > +
> >> > +Required properties (all function blocks):
> >> > +- compatible: "mediatek,-mdp"
> >>
> >> What is this, ...
> >>
> >
> > It is used to match platform driver.
> 
> Would structuring things like this work instead:
> 
> {
>   compatible = "mediatek,-mdp";
>   ranges = ...;
>   {
> compatible = "mediatek,-mdp-rdma";
> ...
>   };
>   {
> compatible = "mediatek,-mdp-wdma";
> ...
>   };
>   ...
> };
> 

I am trying to modify it as structured node. But mdp failed to convert
image. Under debugging.


> >
> >
> >> > +"mediatek,-mdp-", one of
> >>
> >> and this?
> >>
> >
> > It is string format of HW block.  could be "mt8173", and
> >  are "rdma", "rsz", "wdma", and "wrot".
> >
> >
> >> > +"mediatek,-mdp-rdma"  - read DMA
> >> > +"mediatek,-mdp-rsz"   - resizer
> >> > +"mediatek,-mdp-wdma"  - write DMA
> >> > +"mediatek,-mdp-wrot"  - write DMA with rotation
> >>
> >> List what are valid values of .
> >>
> >
> >  - mt8173. There should be other chip added in future.
> > I will change the property as blow:
> >
> > - compatible: "mediatek,-mdp"
> > Should be one of
> > "mediatek,-mdp-rdma"  - read DMA
> > "mediatek,-mdp-rsz"   - resizer
> > "mediatek,-mdp-wdma"  - write DMA
> > "mediatek,-mdp-wrot"  - write DMA with rotation
> >  - could be 8173
> >
> >
> > If don't need , I also can change it as below. It is more clear.
> 
> Up to you. Depends on how many different chips you will have.
> 

I will replace "" with "mt8173"


> > - compatible: "mediatek,mt8173-mdp"
> > Should be one of
> > "mediatek,mt8173-mdp-rdma"  - read DMA
> > "mediatek,mt8173-mdp-rsz"   - resizer
> > "mediatek,mt8173-mdp-wdma"  - write DMA
> > "mediatek,mt8173-mdp-wrot"  - write DMA with rotation
> >
> >
> >> > +- reg: Physical base address and length of the function block register 
> >> > space
> >> > +- clocks: device clocks
> >> > +- power-domains: a phandle to the power domain.
> >> > +- mediatek,vpu: the node of video processor unit
> >> > +
> >> > +Required properties (DMA function blocks):
> >> > +- compatible: Should be one of
> >> > +"mediatek,-mdp-rdma"
> >> > +"mediatek,-mdp-wdma"
> >> > +"mediatek,-mdp-wrot"
> >> > +- iommus: should point to the respective IOMMU block with master port as
> >> > +  argument, see 
> >> > Documentation/devicetree/bindings/iommu/mediatek,iommu.txt
> >> > +  for details.
> >> > +- mediatek,larb: must contain the local arbiters in the current Socs.
> >>
> >> It is still not clear which properties apply to which compatible
> >> strings.
> >>
> >
> > I found out the document for larb.
> > I will change the property as below:
> >
> > - mediatek,larb: must contain the local arbiters in the current Socs,
> > see
> > Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.txt
> >   for details.
> 
> That's good, but not what I meant. You still have properties which
> only apply to certain blocks, but are listed for all blocks like
> mediatek,vpu for example.
> 
> Rob


I find out other properties' document. 

- clocks: device clocks, see
  Documentation/devicetree/bindings/clock/clock-bindings.txt for
details.
- power-domains: a phandle to the power domain, see
  Documentation/devicetree/bindings/power/power_domain.txt for details.
- mediatek,vpu: the node of video processor unit, see
  Documentation/devicetree/bindings/media/mediatek-vpu.txt for details.



--
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 v2 2/4] dt-bindings: Add a binding for Mediatek MDP

2016-07-26 Thread Minghsiu Tsai
On Tue, 2016-07-26 at 13:54 -0500, Rob Herring wrote:
> On Fri, Jul 22, 2016 at 04:33:01PM +0800, Minghsiu Tsai wrote:
> > Add a DT binding documentation of MDP for the MT8173 SoC
> > from Mediatek
> > 
> > Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
> > ---
> >  .../devicetree/bindings/media/mediatek-mdp.txt |   96 
> > 
> >  1 file changed, 96 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/media/mediatek-mdp.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/media/mediatek-mdp.txt 
> > b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
> > new file mode 100644
> > index 000..2dad031
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
> > @@ -0,0 +1,96 @@
> > +* Mediatek Media Data Path
> > +
> > +Media Data Path is used for scaling and color space conversion.
> > +
> > +Required properties (all function blocks):
> > +- compatible: "mediatek,-mdp"
> 
> What is this, ...
> 

It is used to match platform driver.


> > +"mediatek,-mdp-", one of
> 
> and this?
> 

It is string format of HW block.  could be "mt8173", and
 are "rdma", "rsz", "wdma", and "wrot".  


> > +"mediatek,-mdp-rdma"  - read DMA
> > +"mediatek,-mdp-rsz"   - resizer
> > +"mediatek,-mdp-wdma"  - write DMA
> > +"mediatek,-mdp-wrot"  - write DMA with rotation
> 
> List what are valid values of .
> 

 - mt8173. There should be other chip added in future.
I will change the property as blow:

- compatible: "mediatek,-mdp"
Should be one of
"mediatek,-mdp-rdma"  - read DMA
"mediatek,-mdp-rsz"   - resizer
"mediatek,-mdp-wdma"  - write DMA
"mediatek,-mdp-wrot"  - write DMA with rotation
 - could be 8173


If don't need , I also can change it as below. It is more clear.
- compatible: "mediatek,mt8173-mdp"
Should be one of
"mediatek,mt8173-mdp-rdma"  - read DMA
"mediatek,mt8173-mdp-rsz"   - resizer
"mediatek,mt8173-mdp-wdma"  - write DMA
"mediatek,mt8173-mdp-wrot"  - write DMA with rotation


> > +- reg: Physical base address and length of the function block register 
> > space
> > +- clocks: device clocks
> > +- power-domains: a phandle to the power domain.
> > +- mediatek,vpu: the node of video processor unit
> > +
> > +Required properties (DMA function blocks):
> > +- compatible: Should be one of
> > +"mediatek,-mdp-rdma"
> > +"mediatek,-mdp-wdma"
> > +"mediatek,-mdp-wrot"
> > +- iommus: should point to the respective IOMMU block with master port as
> > +  argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt
> > +  for details.
> > +- mediatek,larb: must contain the local arbiters in the current Socs.
> 
> It is still not clear which properties apply to which compatible 
> strings.
> 

I found out the document for larb. 
I will change the property as below:

- mediatek,larb: must contain the local arbiters in the current Socs,
see
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.txt 
  for details.


> > +
> > +Example:
> > +   mdp_rdma0: rdma@14001000 {
> > +   compatible = "mediatek,mt8173-mdp-rdma",
> > +"mediatek,mt8173-mdp";
> > +   reg = <0 0x14001000 0 0x1000>;
> > +   clocks = < CLK_MM_MDP_RDMA0>,
> > +< CLK_MM_MUTEX_32K>;
> > +   power-domains = < MT8173_POWER_DOMAIN_MM>;
> > +   iommus = < M4U_PORT_MDP_RDMA0>;
> > +   mediatek,larb = <>;
> > +   mediatek,vpu = <>;
> > +   };
> > +
> > +   mdp_rdma1: rdma@14002000 {
> > +   compatible = "mediatek,mt8173-mdp-rdma";
> > +   reg = <0 0x14002000 0 0x1000>;
> > +   clocks = < CLK_MM_MDP_RDMA1>,
> > +< CLK_MM_MUTEX_32K>;
> > +   power-domains = < MT8173_POWER_DOMAIN_MM>;
> > +   iommus = < M4U_PORT_MDP_RDMA1>;
> > +   mediatek,larb = <>;
> > +   };
> > +
> > +   mdp_rsz0: rsz@14003000 {
> > +   compatible = "mediatek,mt8173-mdp-rsz";
> > +   reg = <0 0x14003000 0 0x1000>;
> > + 

[PATCH v2 4/4] arm64: dts: mediatek: Add MDP for MT8173

2016-07-22 Thread Minghsiu Tsai
Add MDP node for MT8173

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   80 ++
 1 file changed, 80 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index a44cfb7..cabbd85 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -26,6 +26,16 @@
#address-cells = <2>;
#size-cells = <2>;
 
+   aliases {
+   mdp_rdma0 = _rdma0;
+   mdp_rdma1 = _rdma1;
+   mdp_rsz0 = _rsz0;
+   mdp_rsz1 = _rsz1;
+   mdp_rsz2 = _rsz2;
+   mdp_wdma0 = _wdma0;
+   mdp_wrot0 = _wrot0;
+   mdp_wrot1 = _wrot1;
+   };
cpus {
#address-cells = <1>;
#size-cells = <0>;
@@ -678,6 +688,76 @@
#clock-cells = <1>;
};
 
+   mdp_rdma0: rdma@14001000 {
+   compatible = "mediatek,mt8173-mdp-rdma",
+"mediatek,mt8173-mdp";
+   reg = <0 0x14001000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA0>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA0>;
+   mediatek,larb = <>;
+   mediatek,vpu = <>;
+   };
+
+   mdp_rdma1: rdma@14002000 {
+   compatible = "mediatek,mt8173-mdp-rdma";
+   reg = <0 0x14002000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA1>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA1>;
+   mediatek,larb = <>;
+   };
+
+   mdp_rsz0: rsz@14003000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14003000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ0>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_rsz1: rsz@14004000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14004000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ1>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_rsz2: rsz@14005000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14005000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ2>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_wdma0: wdma@14006000 {
+   compatible = "mediatek,mt8173-mdp-wdma";
+   reg = <0 0x14006000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WDMA>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WDMA>;
+   mediatek,larb = <>;
+   };
+
+   mdp_wrot0: wrot@14007000 {
+   compatible = "mediatek,mt8173-mdp-wrot";
+   reg = <0 0x14007000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WROT0>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WROT0>;
+   mediatek,larb = <>;
+   };
+
+   mdp_wrot1: wrot@14008000 {
+   compatible = "mediatek,mt8173-mdp-wrot";
+   reg = <0 0x14008000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WROT1>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WROT1>;
+   mediatek,larb = <>;
+   };
+
pwm0: pwm@1401e000 {
compatible = "mediatek,mt8173-disp-pwm",
 "mediatek,mt6595-disp-pwm";
-- 
1.7.9.5

--
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/4] media: Add Mediatek MDP Driver

2016-07-22 Thread Minghsiu Tsai
Add MDP driver for MT8173

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 drivers/media/platform/Kconfig|   16 +
 drivers/media/platform/Makefile   |2 +
 drivers/media/platform/mtk-mdp/Makefile   |9 +
 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c |  159 
 drivers/media/platform/mtk-mdp/mtk_mdp_comp.h |   72 ++
 drivers/media/platform/mtk-mdp/mtk_mdp_core.c |  294 ++
 drivers/media/platform/mtk-mdp/mtk_mdp_core.h |  240 +
 drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h  |  126 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c  | 1263 +
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h  |   22 +
 drivers/media/platform/mtk-mdp/mtk_mdp_regs.c |  153 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_regs.h |   31 +
 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c  |  145 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h  |   41 +
 14 files changed, 2573 insertions(+)
 create mode 100644 drivers/media/platform/mtk-mdp/Makefile
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_comp.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_core.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_core.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_regs.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_regs.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index f25344b..4bb874b 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -166,6 +166,22 @@ config VIDEO_MEDIATEK_VPU
To compile this driver as a module, choose M here: the
module will be called mtk-vpu.
 
+config VIDEO_MEDIATEK_MDP
+   tristate "Mediatek MDP driver"
+   depends on MTK_IOMMU || COMPILE_TEST
+   depends on VIDEO_DEV && VIDEO_V4L2
+   depends on ARCH_MEDIATEK || COMPILE_TEST
+   select VIDEOBUF2_DMA_CONTIG
+   select V4L2_MEM2MEM_DEV
+   select VIDEO_MEDIATEK_VPU
+   default n
+   ---help---
+   It is a v4l2 driver and present in Mediatek MT8173 SoCs.
+   The driver supports for scaling and color space conversion.
+
+   To compile this driver as a module, choose M here: the
+   module will be called mtk-mdp.
+
 config VIDEO_MEDIATEK_VCODEC
tristate "Mediatek Video Codec driver"
depends on MTK_IOMMU || COMPILE_TEST
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 21771c1..221aace 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -63,3 +63,5 @@ ccflags-y += -I$(srctree)/drivers/media/i2c
 obj-$(CONFIG_VIDEO_MEDIATEK_VPU)   += mtk-vpu/
 
 obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC)+= mtk-vcodec/
+
+obj-$(CONFIG_VIDEO_MEDIATEK_MDP)   += mtk-mdp/
diff --git a/drivers/media/platform/mtk-mdp/Makefile 
b/drivers/media/platform/mtk-mdp/Makefile
new file mode 100644
index 000..f802569
--- /dev/null
+++ b/drivers/media/platform/mtk-mdp/Makefile
@@ -0,0 +1,9 @@
+mtk-mdp-y += mtk_mdp_core.o
+mtk-mdp-y += mtk_mdp_comp.o
+mtk-mdp-y += mtk_mdp_m2m.o
+mtk-mdp-y += mtk_mdp_regs.o
+mtk-mdp-y += mtk_mdp_vpu.o
+
+obj-$(CONFIG_VIDEO_MEDIATEK_MDP) += mtk-mdp.o
+
+ccflags-y += -I$(srctree)/drivers/media/platform/mtk-vpu
diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c 
b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
new file mode 100644
index 000..aa8f9fd
--- /dev/null
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: Ming Hsiu Tsai <minghsiu.t...@mediatek.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mtk_mdp_comp.h"
+
+
+static const char * const mtk_mdp_comp_stem[MTK_MDP_COMP_TYPE_MAX] = {
+   "mdp_rdma",
+   "mdp_rsz",
+   "mdp_wdma",
+   "mdp_wrot",
+};
+
+struct mtk_mdp_comp_match {
+   enum mtk_mdp_comp_type type;
+   int alias_id;
+};
+
+static const struct mtk_mdp_comp_match mtk_mdp_matches[MTK_MDP_COMP_ID_MA

[PATCH v2 1/4] VPU: mediatek: Add mdp support

2016-07-22 Thread Minghsiu Tsai
VPU driver add mdp support

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 drivers/media/platform/mtk-vpu/mtk_vpu.h |5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/media/platform/mtk-vpu/mtk_vpu.h 
b/drivers/media/platform/mtk-vpu/mtk_vpu.h
index f457479..291ae46 100644
--- a/drivers/media/platform/mtk-vpu/mtk_vpu.h
+++ b/drivers/media/platform/mtk-vpu/mtk_vpu.h
@@ -53,6 +53,8 @@ typedef void (*ipi_handler_t) (void *data,
 handle H264 video encoder job, and vice versa.
  * @IPI_VENC_VP8:   The interrupt fro vpu is to notify kernel to
 handle VP8 video encoder job,, and vice versa.
+ * @IPI_MDP:The interrupt from vpu is to notify kernel to
+handle MDP (Media Data Path) job, and vice versa.
  * @IPI_MAX:The maximum IPI number
  */
 
@@ -63,6 +65,7 @@ enum ipi_id {
IPI_VDEC_VP9,
IPI_VENC_H264,
IPI_VENC_VP8,
+   IPI_MDP,
IPI_MAX,
 };
 
@@ -71,11 +74,13 @@ enum ipi_id {
  *
  * @VPU_RST_ENC: encoder reset id
  * @VPU_RST_DEC: decoder reset id
+ * @VPU_RST_MDP: MDP (Media Data Path) reset id
  * @VPU_RST_MAX: maximum reset id
  */
 enum rst_id {
VPU_RST_ENC,
VPU_RST_DEC,
+   VPU_RST_MDP,
VPU_RST_MAX,
 };
 
-- 
1.7.9.5

--
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/4] Add MT8173 MDP Driver

2016-07-22 Thread Minghsiu Tsai
Changes in v2:
- Add section to describe blocks function in dts-bindings
- Remove the assignment of device_caps in querycap()
- Remove format's name assignment
- Copy colorspace-related parameters from OUTPUT to CAPTURE
- Use m2m helper functions
- Fix DMA allocation failure
- Initialize lazily vpu instance in streamon()

==
 Introduction
==

The purpose of this series is to add the driver for Media Data Path HW embedded 
in the Mediatek's MT8173 SoC.
MDP is used for scaling and color space conversion.

It could convert V4L2_PIX_FMT_MT21 to V4L2_PIX_FMT_NV12M or 
V4L2_PIX_FMT_YUV420M.

NV12M/YUV420M/MT21 -> MDP -> NV12M/YUV420M

This patch series rely on MTK VPU driver in patch series "Add MT8173 Video 
Encoder Driver and VPU Driver"[1] and "Add MT8173 Video Decoder Driver"[2].
MDP driver rely on VPU driver to load, communicate with VPU.

Internally the driver uses videobuf2 framework and MTK IOMMU and MTK SMI both 
have been merged in v4.6-rc1.

[1]https://patchwork.kernel.org/patch/9002171/
[2]https://patchwork.kernel.org/patch/9141245/

==
 Device interface
==

In principle the driver bases on v4l2 memory-to-memory framework:
it provides a single video node and each opened file handle gets its own 
private context with separate buffer queues. Each context consist of 2 buffer 
queues: OUTPUT (for source buffers) and CAPTURE (for destination buffers).
OUTPUT and CAPTURE buffer could be MMAP or DMABUF memory type.

v4l2-compliance test output:
Need the patch "[for,4.7] v4l2-ioctl: fix stupid mistake in cropcap 
condition"[3] to pass test item Cropping.

[3]https://patchwork.linuxtv.org/patch/34374/

# v4l2-compliance -d /dev/image-proc0
v4l2-compliance SHA   : 42e5b23fcb64fd0012688b537446df565507b2d7

Driver Info:
Driver name   : mtk-mdp
Card type : 14001000.rdma
Bus info  : platform:mt8173
Driver version: 4.7.0
Capabilities  : 0x84204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format
Device Capabilities
Device Caps   : 0x04204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format

Compliance test for device /dev/image-proc0 (not using libv4l2):

Required ioctls:
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second video open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK

Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK (Not Supported)

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK (Not Supported)
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)

Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 5 Private Controls: 0

Format ioctls:
test 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
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK
test Composing: OK
test Scaling: OK (Not Supported)

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:


Total: 43, Succeeded: 43, Failed: 0, Wa

[PATCH v2 2/4] dt-bindings: Add a binding for Mediatek MDP

2016-07-22 Thread Minghsiu Tsai
Add a DT binding documentation of MDP for the MT8173 SoC
from Mediatek

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 .../devicetree/bindings/media/mediatek-mdp.txt |   96 
 1 file changed, 96 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/mediatek-mdp.txt

diff --git a/Documentation/devicetree/bindings/media/mediatek-mdp.txt 
b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
new file mode 100644
index 000..2dad031
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
@@ -0,0 +1,96 @@
+* Mediatek Media Data Path
+
+Media Data Path is used for scaling and color space conversion.
+
+Required properties (all function blocks):
+- compatible: "mediatek,-mdp"
+"mediatek,-mdp-", one of
+"mediatek,-mdp-rdma"  - read DMA
+"mediatek,-mdp-rsz"   - resizer
+"mediatek,-mdp-wdma"  - write DMA
+"mediatek,-mdp-wrot"  - write DMA with rotation
+- reg: Physical base address and length of the function block register space
+- clocks: device clocks
+- power-domains: a phandle to the power domain.
+- mediatek,vpu: the node of video processor unit
+
+Required properties (DMA function blocks):
+- compatible: Should be one of
+"mediatek,-mdp-rdma"
+"mediatek,-mdp-wdma"
+"mediatek,-mdp-wrot"
+- iommus: should point to the respective IOMMU block with master port as
+  argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt
+  for details.
+- mediatek,larb: must contain the local arbiters in the current Socs.
+
+Example:
+   mdp_rdma0: rdma@14001000 {
+   compatible = "mediatek,mt8173-mdp-rdma",
+"mediatek,mt8173-mdp";
+   reg = <0 0x14001000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA0>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA0>;
+   mediatek,larb = <>;
+   mediatek,vpu = <>;
+   };
+
+   mdp_rdma1: rdma@14002000 {
+   compatible = "mediatek,mt8173-mdp-rdma";
+   reg = <0 0x14002000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA1>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA1>;
+   mediatek,larb = <>;
+   };
+
+   mdp_rsz0: rsz@14003000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14003000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ0>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_rsz1: rsz@14004000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14004000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ1>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_rsz2: rsz@14005000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14005000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ2>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_wdma0: wdma@14006000 {
+   compatible = "mediatek,mt8173-mdp-wdma";
+   reg = <0 0x14006000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WDMA>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WDMA>;
+   mediatek,larb = <>;
+   };
+
+   mdp_wrot0: wrot@14007000 {
+   compatible = "mediatek,mt8173-mdp-wrot";
+   reg = <0 0x14007000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WROT0>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WROT0>;
+   mediatek,larb = <>;
+   };
+
+   mdp_wrot1: wrot@14008000 {
+   compatible = "mediatek,mt8173-mdp-wrot";
+   reg = <0 0x14008000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WROT1>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WROT1>;
+   mediatek,larb = <>;
+   };
-- 
1.7.9.5

--
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 3/4] media: Add Mediatek MDP Driver

2016-07-21 Thread Minghsiu Tsai
On Mon, 2016-07-18 at 14:18 +0200, Hans Verkuil wrote:
> On 07/14/2016 02:18 PM, Minghsiu Tsai wrote:
> > Add MDP driver for MT8173
> > 
> > Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
> > ---
> >  drivers/media/platform/Kconfig|   16 +
> >  drivers/media/platform/Makefile   |2 +
> >  drivers/media/platform/mtk-mdp/Makefile   |9 +
> >  drivers/media/platform/mtk-mdp/mtk_mdp_comp.c |  159 +++
> >  drivers/media/platform/mtk-mdp/mtk_mdp_comp.h |   72 ++
> >  drivers/media/platform/mtk-mdp/mtk_mdp_core.c |  294 ++
> >  drivers/media/platform/mtk-mdp/mtk_mdp_core.h |  233 +
> >  drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h  |  126 +++
> >  drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c  | 1304 
> > +
> >  drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h  |   22 +
> >  drivers/media/platform/mtk-mdp/mtk_mdp_regs.c |  153 +++
> >  drivers/media/platform/mtk-mdp/mtk_mdp_regs.h |   31 +
> >  drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c  |  140 +++
> >  drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h  |   41 +
> >  14 files changed, 2602 insertions(+)
> >  create mode 100644 drivers/media/platform/mtk-mdp/Makefile
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_comp.h
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_core.c
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_core.h
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_regs.c
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_regs.h
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c
> >  create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h
> > 
> > diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
> > index 2c2670c..782b618 100644
> > --- a/drivers/media/platform/Kconfig
> > +++ b/drivers/media/platform/Kconfig
> > @@ -166,6 +166,22 @@ config VIDEO_MEDIATEK_VPU
> > To compile this driver as a module, choose M here: the
> > module will be called mtk-vpu.
> >  
> > +config VIDEO_MEDIATEK_MDP
> > +   tristate "Mediatek MDP driver"
> > +   depends on MTK_IOMMU || COMPILE_TEST
> > +   depends on VIDEO_DEV && VIDEO_V4L2
> > +   depends on ARCH_MEDIATEK || COMPILE_TEST
> > +   select VIDEOBUF2_DMA_CONTIG
> > +   select V4L2_MEM2MEM_DEV
> > +   select VIDEO_MEDIATEK_VPU
> > +   default n
> > +   ---help---
> > +   It is a v4l2 driver and present in Mediatek MT8173 SoCs.
> > +   The driver supports for scaling and color space conversion.
> > +
> > +   To compile this driver as a module, choose M here: the
> > +   module will be called mtk-mdp.
> > +
> >  config VIDEO_MEDIATEK_VCODEC
> > tristate "Mediatek Video Codec driver"
> > depends on MTK_IOMMU || COMPILE_TEST
> > diff --git a/drivers/media/platform/Makefile 
> > b/drivers/media/platform/Makefile
> > index c6b3b92..9c54f1a 100644
> > --- a/drivers/media/platform/Makefile
> > +++ b/drivers/media/platform/Makefile
> > @@ -62,3 +62,5 @@ ccflags-y += -I$(srctree)/drivers/media/i2c
> >  obj-$(CONFIG_VIDEO_MEDIATEK_VPU)   += mtk-vpu/
> >  
> >  obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC)+= mtk-vcodec/
> > +
> > +obj-$(CONFIG_VIDEO_MEDIATEK_MDP)   += mtk-mdp/
> > diff --git a/drivers/media/platform/mtk-mdp/Makefile 
> > b/drivers/media/platform/mtk-mdp/Makefile
> > new file mode 100644
> > index 000..f802569
> > --- /dev/null
> > +++ b/drivers/media/platform/mtk-mdp/Makefile
> > @@ -0,0 +1,9 @@
> > +mtk-mdp-y += mtk_mdp_core.o
> > +mtk-mdp-y += mtk_mdp_comp.o
> > +mtk-mdp-y += mtk_mdp_m2m.o
> > +mtk-mdp-y += mtk_mdp_regs.o
> > +mtk-mdp-y += mtk_mdp_vpu.o
> > +
> > +obj-$(CONFIG_VIDEO_MEDIATEK_MDP) += mtk-mdp.o
> > +
> > +ccflags-y += -I$(srctree)/drivers/media/platform/mtk-vpu
> > diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c 
> > b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
> > new file mode 100644
> > index 000..aa8f9fd
> > --- /dev/null
> > +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
> > @@ -0,0 +1,159 @@
> > +/*
> > + * Copyright (c) 2016 MediaTek Inc.
> > + * Autho

Re: [PATCH 2/4] dt-bindings: Add a binding for Mediatek MDP

2016-07-20 Thread Minghsiu Tsai
On Sat, 2016-07-16 at 18:01 -0500, Rob Herring wrote:
> On Thu, Jul 14, 2016 at 08:17:59PM +0800, Minghsiu Tsai wrote:
> > Add a DT binding documentation of MDP for the MT8173 SoC
> > from Mediatek
> > 
> > Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
> > ---
> >  .../devicetree/bindings/media/mediatek-mdp.txt |   92 
> > 
> >  1 file changed, 92 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/media/mediatek-mdp.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/media/mediatek-mdp.txt 
> > b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
> > new file mode 100644
> > index 000..ef570c3
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
> > @@ -0,0 +1,92 @@
> > +* Mediatek Media Data Path
> > +
> > +Media Data Path is used for scaling and color space conversion.
> > +
> > +Required properties:
> > +  - compatible : should contain them as below:
> > +"mediatek,mt8173-mdp"
> > +"mediatek,mt8173-mdp-rdma"
> > +"mediatek,mt8173-mdp-rsz"
> > +"mediatek,mt8173-mdp-wdma"
> > +"mediatek,mt8173-mdp-wrot"
> > +  - clocks : device clocks
> > +  - power-domains : a phandle to the power domain.
> > +  - mediatek,larb : should contain the larbes of current platform
> > +  - iommus : Mediatek IOMMU H/W has designed the fixed associations with
> > +the multimedia H/W. and there is only one multimedia iommu domain.
> > +"iommus = < portid>" the "portid" is from
> > +dt-bindings\iommu\mt8173-iommu-port.h, it means that this portid 
> > will
> > +enable iommu. The portid default is disable iommu if "< 
> > portid>"
> > +don't be added.
> > +  - mediatek,vpu : the node of video processor unit
> 
> These properties don't apply to all the nodes. I think you need a 
> section for each IP block.


I will add description for those IP block, thanks.


--
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 4/4] arm64: dts: mediatek: Add MDP for MT8173

2016-07-14 Thread Minghsiu Tsai
Add MDP node for MT8173

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   80 ++
 1 file changed, 80 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 77b8c4e..8e1b85d 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -26,6 +26,16 @@
#address-cells = <2>;
#size-cells = <2>;
 
+   aliases {
+   mdp_rdma0 = _rdma0;
+   mdp_rdma1 = _rdma1;
+   mdp_rsz0 = _rsz0;
+   mdp_rsz1 = _rsz1;
+   mdp_rsz2 = _rsz2;
+   mdp_wdma0 = _wdma0;
+   mdp_wrot0 = _wrot0;
+   mdp_wrot1 = _wrot1;
+   };
cpus {
#address-cells = <1>;
#size-cells = <0>;
@@ -678,6 +688,76 @@
#clock-cells = <1>;
};
 
+   mdp_rdma0: rdma@14001000 {
+   compatible = "mediatek,mt8173-mdp-rdma",
+"mediatek,mt8173-mdp";
+   reg = <0 0x14001000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA0>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA0>;
+   mediatek,larb = <>;
+   mediatek,vpu = <>;
+   };
+
+   mdp_rdma1: rdma@14002000 {
+   compatible = "mediatek,mt8173-mdp-rdma";
+   reg = <0 0x14002000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA1>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA1>;
+   mediatek,larb = <>;
+   };
+
+   mdp_rsz0: rsz@14003000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14003000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ0>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_rsz1: rsz@14004000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14004000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ1>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_rsz2: rsz@14005000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14005000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ2>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_wdma0: wdma@14006000 {
+   compatible = "mediatek,mt8173-mdp-wdma";
+   reg = <0 0x14006000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WDMA>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WDMA>;
+   mediatek,larb = <>;
+   };
+
+   mdp_wrot0: wrot@14007000 {
+   compatible = "mediatek,mt8173-mdp-wrot";
+   reg = <0 0x14007000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WROT0>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WROT0>;
+   mediatek,larb = <>;
+   };
+
+   mdp_wrot1: wrot@14008000 {
+   compatible = "mediatek,mt8173-mdp-wrot";
+   reg = <0 0x14008000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WROT1>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WROT1>;
+   mediatek,larb = <>;
+   };
+
pwm0: pwm@1401e000 {
compatible = "mediatek,mt8173-disp-pwm",
 "mediatek,mt6595-disp-pwm";
-- 
1.7.9.5

--
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/4] VPU: mediatek: Add mdp support

2016-07-14 Thread Minghsiu Tsai
VPU driver add mdp support

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 drivers/media/platform/mtk-vpu/mtk_vpu.h |5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/media/platform/mtk-vpu/mtk_vpu.h 
b/drivers/media/platform/mtk-vpu/mtk_vpu.h
index f457479..291ae46 100644
--- a/drivers/media/platform/mtk-vpu/mtk_vpu.h
+++ b/drivers/media/platform/mtk-vpu/mtk_vpu.h
@@ -53,6 +53,8 @@ typedef void (*ipi_handler_t) (void *data,
 handle H264 video encoder job, and vice versa.
  * @IPI_VENC_VP8:   The interrupt fro vpu is to notify kernel to
 handle VP8 video encoder job,, and vice versa.
+ * @IPI_MDP:The interrupt from vpu is to notify kernel to
+handle MDP (Media Data Path) job, and vice versa.
  * @IPI_MAX:The maximum IPI number
  */
 
@@ -63,6 +65,7 @@ enum ipi_id {
IPI_VDEC_VP9,
IPI_VENC_H264,
IPI_VENC_VP8,
+   IPI_MDP,
IPI_MAX,
 };
 
@@ -71,11 +74,13 @@ enum ipi_id {
  *
  * @VPU_RST_ENC: encoder reset id
  * @VPU_RST_DEC: decoder reset id
+ * @VPU_RST_MDP: MDP (Media Data Path) reset id
  * @VPU_RST_MAX: maximum reset id
  */
 enum rst_id {
VPU_RST_ENC,
VPU_RST_DEC,
+   VPU_RST_MDP,
VPU_RST_MAX,
 };
 
-- 
1.7.9.5

--
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 2/4] dt-bindings: Add a binding for Mediatek MDP

2016-07-14 Thread Minghsiu Tsai
Add a DT binding documentation of MDP for the MT8173 SoC
from Mediatek

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 .../devicetree/bindings/media/mediatek-mdp.txt |   92 
 1 file changed, 92 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/mediatek-mdp.txt

diff --git a/Documentation/devicetree/bindings/media/mediatek-mdp.txt 
b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
new file mode 100644
index 000..ef570c3
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/mediatek-mdp.txt
@@ -0,0 +1,92 @@
+* Mediatek Media Data Path
+
+Media Data Path is used for scaling and color space conversion.
+
+Required properties:
+  - compatible : should contain them as below:
+"mediatek,mt8173-mdp"
+"mediatek,mt8173-mdp-rdma"
+"mediatek,mt8173-mdp-rsz"
+"mediatek,mt8173-mdp-wdma"
+"mediatek,mt8173-mdp-wrot"
+  - clocks : device clocks
+  - power-domains : a phandle to the power domain.
+  - mediatek,larb : should contain the larbes of current platform
+  - iommus : Mediatek IOMMU H/W has designed the fixed associations with
+the multimedia H/W. and there is only one multimedia iommu domain.
+"iommus = < portid>" the "portid" is from
+dt-bindings\iommu\mt8173-iommu-port.h, it means that this portid will
+enable iommu. The portid default is disable iommu if "< portid>"
+don't be added.
+  - mediatek,vpu : the node of video processor unit
+
+Example:
+   mdp_rdma0: rdma@14001000 {
+   compatible = "mediatek,mt8173-mdp-rdma",
+"mediatek,mt8173-mdp";
+   reg = <0 0x14001000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA0>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA0>;
+   mediatek,larb = <>;
+   mediatek,vpu = <>;
+   };
+
+   mdp_rdma1: rdma@14002000 {
+   compatible = "mediatek,mt8173-mdp-rdma";
+   reg = <0 0x14002000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RDMA1>,
+< CLK_MM_MUTEX_32K>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_RDMA1>;
+   mediatek,larb = <>;
+   };
+
+   mdp_rsz0: rsz@14003000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14003000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ0>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_rsz1: rsz@14004000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14004000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ1>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_rsz2: rsz@14005000 {
+   compatible = "mediatek,mt8173-mdp-rsz";
+   reg = <0 0x14005000 0 0x1000>;
+   clocks = < CLK_MM_MDP_RSZ2>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   };
+
+   mdp_wdma0: wdma@14006000 {
+   compatible = "mediatek,mt8173-mdp-wdma";
+   reg = <0 0x14006000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WDMA>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WDMA>;
+   mediatek,larb = <>;
+   };
+
+   mdp_wrot0: wrot@14007000 {
+   compatible = "mediatek,mt8173-mdp-wrot";
+   reg = <0 0x14007000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WROT0>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WROT0>;
+   mediatek,larb = <>;
+   };
+
+   mdp_wrot1: wrot@14008000 {
+   compatible = "mediatek,mt8173-mdp-wrot";
+   reg = <0 0x14008000 0 0x1000>;
+   clocks = < CLK_MM_MDP_WROT1>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   iommus = < M4U_PORT_MDP_WROT1>;
+   mediatek,larb = <>;
+   };
-- 
1.7.9.5

--
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/4] media: Add Mediatek MDP Driver

2016-07-14 Thread Minghsiu Tsai
Add MDP driver for MT8173

Signed-off-by: Minghsiu Tsai <minghsiu.t...@mediatek.com>
---
 drivers/media/platform/Kconfig|   16 +
 drivers/media/platform/Makefile   |2 +
 drivers/media/platform/mtk-mdp/Makefile   |9 +
 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c |  159 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_comp.h |   72 ++
 drivers/media/platform/mtk-mdp/mtk_mdp_core.c |  294 ++
 drivers/media/platform/mtk-mdp/mtk_mdp_core.h |  233 +
 drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h  |  126 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c  | 1304 +
 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h  |   22 +
 drivers/media/platform/mtk-mdp/mtk_mdp_regs.c |  153 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_regs.h |   31 +
 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c  |  140 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h  |   41 +
 14 files changed, 2602 insertions(+)
 create mode 100644 drivers/media/platform/mtk-mdp/Makefile
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_comp.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_core.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_core.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_m2m.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_regs.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_regs.h
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.c
 create mode 100644 drivers/media/platform/mtk-mdp/mtk_mdp_vpu.h

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 2c2670c..782b618 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -166,6 +166,22 @@ config VIDEO_MEDIATEK_VPU
To compile this driver as a module, choose M here: the
module will be called mtk-vpu.
 
+config VIDEO_MEDIATEK_MDP
+   tristate "Mediatek MDP driver"
+   depends on MTK_IOMMU || COMPILE_TEST
+   depends on VIDEO_DEV && VIDEO_V4L2
+   depends on ARCH_MEDIATEK || COMPILE_TEST
+   select VIDEOBUF2_DMA_CONTIG
+   select V4L2_MEM2MEM_DEV
+   select VIDEO_MEDIATEK_VPU
+   default n
+   ---help---
+   It is a v4l2 driver and present in Mediatek MT8173 SoCs.
+   The driver supports for scaling and color space conversion.
+
+   To compile this driver as a module, choose M here: the
+   module will be called mtk-mdp.
+
 config VIDEO_MEDIATEK_VCODEC
tristate "Mediatek Video Codec driver"
depends on MTK_IOMMU || COMPILE_TEST
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index c6b3b92..9c54f1a 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -62,3 +62,5 @@ ccflags-y += -I$(srctree)/drivers/media/i2c
 obj-$(CONFIG_VIDEO_MEDIATEK_VPU)   += mtk-vpu/
 
 obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC)+= mtk-vcodec/
+
+obj-$(CONFIG_VIDEO_MEDIATEK_MDP)   += mtk-mdp/
diff --git a/drivers/media/platform/mtk-mdp/Makefile 
b/drivers/media/platform/mtk-mdp/Makefile
new file mode 100644
index 000..f802569
--- /dev/null
+++ b/drivers/media/platform/mtk-mdp/Makefile
@@ -0,0 +1,9 @@
+mtk-mdp-y += mtk_mdp_core.o
+mtk-mdp-y += mtk_mdp_comp.o
+mtk-mdp-y += mtk_mdp_m2m.o
+mtk-mdp-y += mtk_mdp_regs.o
+mtk-mdp-y += mtk_mdp_vpu.o
+
+obj-$(CONFIG_VIDEO_MEDIATEK_MDP) += mtk-mdp.o
+
+ccflags-y += -I$(srctree)/drivers/media/platform/mtk-vpu
diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c 
b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
new file mode 100644
index 000..aa8f9fd
--- /dev/null
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: Ming Hsiu Tsai <minghsiu.t...@mediatek.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mtk_mdp_comp.h"
+
+
+static const char * const mtk_mdp_comp_stem[MTK_MDP_COMP_TYPE_MAX] = {
+   "mdp_rdma",
+   "mdp_rsz",
+   "mdp_wdma",
+   "mdp_wrot",
+};
+
+struct mtk_mdp_comp_match {
+   enum mtk_mdp_comp_type type;
+   int alias_id;
+};
+
+static const struct mtk_mdp_comp_match mtk_mdp_matches[MTK_MDP_COMP_ID_MA

[PATCH 0/4] Add MT8173 MDP Driver

2016-07-14 Thread Minghsiu Tsai
==
 Introduction
==

The purpose of this series is to add the driver for Media Data Path HW embedded 
in the Mediatek's MT8173 SoC.
MDP is used for scaling and color space conversion.

It could convert V4L2_PIX_FMT_MT21 to V4L2_PIX_FMT_NV12M or 
V4L2_PIX_FMT_YUV420M.

NV12M/YUV420M/MT21 -> MDP -> NV12M/YUV420M

This patch series rely on MTK VPU driver in patch series "Add MT8173 Video 
Encoder Driver and VPU Driver"[1] and "Add MT8173 Video Decoder Driver"[2].
MDP driver rely on VPU driver to load, communicate with VPU.

Internally the driver uses videobuf2 framework and MTK IOMMU and MTK SMI both 
have been merged in v4.6-rc1.

[1]https://patchwork.kernel.org/patch/9002171/
[2]https://patchwork.kernel.org/patch/9141245/

==
 Device interface
==

In principle the driver bases on v4l2 memory-to-memory framework:
it provides a single video node and each opened file handle gets its own 
private context with separate buffer queues. Each context consist of 2 buffer 
queues: OUTPUT (for source buffers) and CAPTURE (for destination buffers).
OUTPUT and CAPTURE buffer could be MMAP or DMABUF memory type.

v4l2-compliance test output:
localhost ~ # v4l2-compliance -d /dev/image-proc0
v4l2-compliance SHA   : 3d225130559e8578dce347052bee3813ddf08f28

Driver Info:
Driver name   : mtk-mdp
Card type : 14001000.rdma
Bus info  : platform:mt8173
Driver version: 3.18.0
Capabilities  : 0x84204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format
Device Capabilities
Device Caps   : 0x04204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format

Compliance test for device /dev/image-proc0 (not using libv4l2):

Required ioctls:
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second video open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK

Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK (Not Supported)

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK (Not Supported)
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)

Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 5 Private Controls: 0

Format ioctls:
test 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
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK
test Composing: OK
test Scaling: OK (Not Supported)

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:


Total: 42, Succeeded: 42, Failed: 0, Warnings: 0


Minghsiu Tsai (4):
  VPU: mediatek: Add mdp support
  dt-bindings: Add a binding for Mediatek MDP
  media: Add Mediatek MDP Driver
  arm64: dts: mediatek: Add MDP for MT8173

 .../devicetree/bindings/media/mediatek-mdp.txt |   92 ++
 arch/arm64/boot/dts/mediatek/mt8173.dtsi   |   80 ++
 drivers/media/platform/Kconfig |   16 +
 drivers/media/platform/Makefile|2 +
 drivers/media/platform/mtk-mdp/Makefile|9 +
 drivers/media/platf