[PATCH 1/2] media: s5p-mfc: convert drivers to use the new vb2_queue dev field

2016-12-16 Thread Pankaj Dubey
From: Smitha T Murthy <smith...@samsung.com>

commit 2548fee63d9e ("[media] media/platform: convert drivers to use the new
vb2_queue dev field") has missed to set dev pointer of vb2_queue which will be
used in reqbufs of mfc driver. Without this change following error is observed:

---
V4L2 Codec decoding example application
Kamil Debski <k.deb...@samsung.com>
Copyright 2012 Samsung Electronics Co., Ltd.

Opening MFC.
(mfc.c:mfc_open:58): MFC Info (/dev/video0): driver="s5p-mfc" \
bus_info="platform:12c3.mfc0" card="s5p-mfc-dec" fd=0x4[
42.339165] Remapping memory failed, error: -6

MFC Open Success.
(main.c:main:711): Successfully opened all necessary files and devices
(mfc.c:mfc_dec_setup_output:103): Setup MFC decoding OUTPUT buffer \
size=4194304 (requested=4194304)
(mfc.c:mfc_dec_setup_output:120): Number of MFC OUTPUT buffers is 2 \
(requested 2)

[App] Out buf phy : 0x, virt : 0x
Output Length is = 0x30
Error (mfc.c:mfc_dec_setup_output:145): Failed to MMAP MFC OUTPUT buffer
---

Signed-off-by: Smitha T Murthy <smith...@samsung.com>
[pankaj.dubey: debugging issue and formatting commit message]
Signed-off-by: Pankaj Dubey <pankaj.du...@samsung.com>
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 0a5b8f5..6ea8246 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -838,6 +838,7 @@ static int s5p_mfc_open(struct file *file)
q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
q->drv_priv = >fh;
q->lock = >mfc_mutex;
+   q->dev = >plat_dev->dev;
if (vdev == dev->vfd_dec) {
q->io_modes = VB2_MMAP;
q->ops = get_dec_queue_ops();
@@ -861,6 +862,7 @@ static int s5p_mfc_open(struct file *file)
q->io_modes = VB2_MMAP;
q->drv_priv = >fh;
q->lock = >mfc_mutex;
+   q->dev = >plat_dev->dev;
if (vdev == dev->vfd_dec) {
q->io_modes = VB2_MMAP;
q->ops = get_dec_queue_ops();
-- 
2.7.4

--
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] s5p-mfc fix for using reserved memory

2016-12-16 Thread Pankaj Dubey
It has been observed on ARM64 based Exynos SoC, if IOMMU is not enabled
and we try to use reserved memory for MFC, reqbufs fails with below
mentioned error
---
V4L2 Codec decoding example application
Kamil Debski 
Copyright 2012 Samsung Electronics Co., Ltd.

Opening MFC.
(mfc.c:mfc_open:58): MFC Info (/dev/video0): driver="s5p-mfc" \
bus_info="platform:12c3.mfc0" card="s5p-mfc-dec" fd=0x4[
42.339165] Remapping memory failed, error: -6

MFC Open Success.
(main.c:main:711): Successfully opened all necessary files and devices
(mfc.c:mfc_dec_setup_output:103): Setup MFC decoding OUTPUT buffer \
size=4194304 (requested=4194304)
(mfc.c:mfc_dec_setup_output:120): Number of MFC OUTPUT buffers is 2 \
(requested 2)

[App] Out buf phy : 0x, virt : 0x
Output Length is = 0x30
Error (mfc.c:mfc_dec_setup_output:145): Failed to MMAP MFC OUTPUT buffer
-
This is because the device requesting for memory is mfc0.left not the parent 
mfc0.
Hence setting of alloc_devs need to be done only if IOMMU is enabled
and in that case both the left and right device is treated as mfc0 only.
Also we need to populate vb2_queue's dev pointer with mfc dev pointer.

Smitha T Murthy (2):
  media: s5p-mfc: convert drivers to use the new vb2_queue dev field
  media: s5p-mfc: fix MMAP of mfc buffer during reqbufs

 drivers/media/platform/s5p-mfc/s5p_mfc.c |  2 ++
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 17 ++---
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 18 +++---
 3 files changed, 23 insertions(+), 14 deletions(-)

-- 
2.7.4

--
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: s5p-mfc: fix MMAP of mfc buffer during reqbufs

2016-12-16 Thread Pankaj Dubey
From: Smitha T Murthy <smith...@samsung.com>

It has been observed on ARM64 based Exynos SoC, if IOMMU is not enabled
and we try to use reserved memory for MFC, reqbufs fails with below
mentioned error
---
V4L2 Codec decoding example application
Kamil Debski <k.deb...@samsung.com>
Copyright 2012 Samsung Electronics Co., Ltd.

Opening MFC.
(mfc.c:mfc_open:58): MFC Info (/dev/video0): driver="s5p-mfc" \
bus_info="platform:12c3.mfc0" card="s5p-mfc-dec" fd=0x4[
42.339165] Remapping memory failed, error: -6

MFC Open Success.
(main.c:main:711): Successfully opened all necessary files and devices
(mfc.c:mfc_dec_setup_output:103): Setup MFC decoding OUTPUT buffer \
size=4194304 (requested=4194304)
(mfc.c:mfc_dec_setup_output:120): Number of MFC OUTPUT buffers is 2 \
(requested 2)

[App] Out buf phy : 0x, virt : 0x
Output Length is = 0x30
Error (mfc.c:mfc_dec_setup_output:145): Failed to MMAP MFC OUTPUT buffer
-
This is because the device requesting for memory is mfc0.left not the parent 
mfc0.
Hence setting of alloc_devs need to be done only if IOMMU is enabled
and in that case both the left and right device is treated as mfc0 only.

Signed-off-by: Smitha T Murthy <smith...@samsung.com>
[pankaj.dubey: debugging issue and formatting commit message]
Signed-off-by: Pankaj Dubey <pankaj.du...@samsung.com>
---
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 17 ++---
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 18 +++---
 2 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
index 52081dd..9cfca5d 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
@@ -30,6 +30,7 @@
 #include "s5p_mfc_intr.h"
 #include "s5p_mfc_opr.h"
 #include "s5p_mfc_pm.h"
+#include "s5p_mfc_iommu.h"
 
 static struct s5p_mfc_fmt formats[] = {
{
@@ -930,16 +931,18 @@ static int s5p_mfc_queue_setup(struct vb2_queue *vq,
vq->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
psize[0] = ctx->luma_size;
psize[1] = ctx->chroma_size;
-
-   if (IS_MFCV6_PLUS(dev))
-   alloc_devs[0] = ctx->dev->mem_dev_l;
-   else
-   alloc_devs[0] = ctx->dev->mem_dev_r;
-   alloc_devs[1] = ctx->dev->mem_dev_l;
+   if (exynos_is_iommu_available(>plat_dev->dev)) {
+   if (IS_MFCV6_PLUS(dev))
+   alloc_devs[0] = ctx->dev->mem_dev_l;
+   else
+   alloc_devs[0] = ctx->dev->mem_dev_r;
+   alloc_devs[1] = ctx->dev->mem_dev_l;
+   }
} else if (vq->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE &&
   ctx->state == MFCINST_INIT) {
psize[0] = ctx->dec_src_buf_size;
-   alloc_devs[0] = ctx->dev->mem_dev_l;
+   if (exynos_is_iommu_available(>plat_dev->dev))
+   alloc_devs[0] = ctx->dev->mem_dev_l;
} else {
mfc_err("This video node is dedicated to decoding. Decoding not 
initialized\n");
return -EINVAL;
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index fcc2e05..eb8f06d 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -30,6 +30,7 @@
 #include "s5p_mfc_enc.h"
 #include "s5p_mfc_intr.h"
 #include "s5p_mfc_opr.h"
+#include "s5p_mfc_iommu.h"
 
 #define DEF_SRC_FMT_ENCV4L2_PIX_FMT_NV12M
 #define DEF_DST_FMT_ENCV4L2_PIX_FMT_H264
@@ -1832,7 +1833,8 @@ static int s5p_mfc_queue_setup(struct vb2_queue *vq,
if (*buf_count > MFC_MAX_BUFFERS)
*buf_count = MFC_MAX_BUFFERS;
psize[0] = ctx->enc_dst_buf_size;
-   alloc_devs[0] = ctx->dev->mem_dev_l;
+   if (exynos_is_iommu_available(>plat_dev->dev))
+   alloc_devs[0] = ctx->dev->mem_dev_l;
} else if (vq->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
if (ctx->src_fmt)
*plane_count = ctx->src_fmt->num_planes;
@@ -1847,12 +1849,14 @@ static int s5p_mfc_queue_setup(struct vb2_queue *vq,
psize[0] = ctx->luma_size;
psize[1] = ctx->chroma_size;
 
-   if (IS_MFCV6_PLUS(dev)) {
-   alloc_devs[0] = ctx->dev->m

Re: media: platform: s5p-jpeg: jpeg-hw-exynos4: Remove some unused functions

2015-01-04 Thread Pankaj Dubey

+Tony Nadackal

Hi Rickard,

On Saturday 03 January 2015 02:07 AM, Rickard Strandqvist wrote:

Removes some functions that are not used anywhere:
exynos4_jpeg_set_timer_count() exynos4_jpeg_get_frame_size() 
exynos4_jpeg_set_sys_int_enable() exynos4_jpeg_get_fifo_status()

This was partially found by using a static code analysis program called 
cppcheck.

Signed-off-by: Rickard Strandqvist rickard_strandqv...@spectrumdigital.se

---
drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c |   35 -
  drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.h |5 ---
  2 files changed, 40 deletions(-)

diff --git a/drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c 
b/drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c
index ab6d6f4..5685577 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c
+++ b/drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c
@@ -163,15 +163,6 @@ unsigned int exynos4_jpeg_get_int_status(void __iomem 
*base)
return int_status;
  }

-unsigned int exynos4_jpeg_get_fifo_status(void __iomem *base)
-{
-   unsigned int fifo_status;
-
-   fifo_status = readl(base + EXYNOS4_FIFO_STATUS_REG);
-
-   return fifo_status;
-}
-
  void exynos4_jpeg_set_huf_table_enable(void __iomem *base, int value)
  {
unsigned intreg;
@@ -186,18 +177,6 @@ void exynos4_jpeg_set_huf_table_enable(void __iomem *base, 
int value)
base + EXYNOS4_JPEG_CNTL_REG);
  }

-void exynos4_jpeg_set_sys_int_enable(void __iomem *base, int value)
-{
-   unsigned intreg;
-
-   reg = readl(base + EXYNOS4_JPEG_CNTL_REG)  ~(EXYNOS4_SYS_INT_EN);
-
-   if (value == 1)
-   writel(reg | EXYNOS4_SYS_INT_EN, base + EXYNOS4_JPEG_CNTL_REG);
-   else
-   writel(reg  ~EXYNOS4_SYS_INT_EN, base + EXYNOS4_JPEG_CNTL_REG);
-}
-


Above function will be needed for enabling JPEG support on Exynos7 SoC. 
There is already inflight patch [1] which will be using it.


1: https://patchwork.kernel.org/patch/5505391/


Thanks,
Pankaj Dubey
--
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