[PATCH v3 12/13] [media] s5p-mfc: fix V4L2_CID_MIN_BUFFERS_FOR_CAPTURE on resolution change.

2014-10-21 Thread Arun Kumar K
From: Pawel Osciak 

G_CTRL on V4L2_CID_MIN_BUFFERS_FOR_CAPTURE will fail if userspace happens to
query it after getting a resolution change event and before the codec has
a chance to parse the header and switch to an initialized state.

Signed-off-by: Pawel Osciak 
Signed-off-by: Kiran AVND 
Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
index a98fe02..de90465 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
@@ -740,7 +740,8 @@ static int s5p_mfc_dec_g_v_ctrl(struct v4l2_ctrl *ctrl)
ctx->state < MFCINST_ABORT) {
ctrl->val = ctx->pb_count;
break;
-   } else if (ctx->state != MFCINST_INIT) {
+   } else if (ctx->state != MFCINST_INIT &&
+   ctx->state != MFCINST_RES_CHANGE_END) {
v4l2_err(&dev->v4l2_dev, "Decoding not initialised\n");
return -EINVAL;
}
-- 
1.7.9.5

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


[PATCH v3 13/13] [media] s5p-mfc: fix a race in interrupt flags handling

2014-10-21 Thread Arun Kumar K
From: Pawel Osciak 

Interrupt result flags have to be cleared before a hardware job is run.
Otherwise, if they are cleared asynchronously, we may end up clearing them
after the interrupt for which we wanted to wait has already arrived, thus
overwriting the job results that we intended to wait for.

To prevent this, clear the flags only under hw_lock and before running
a hardware job.

Signed-off-by: Pawel Osciak 
Signed-off-by: Kiran AVND 
Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c   |2 --
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c|3 ---
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c|1 -
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c |   13 ++---
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c |   12 ++--
 5 files changed, 4 insertions(+), 27 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
index 7c3eaa5..86d43d9 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
@@ -468,7 +468,6 @@ int s5p_mfc_open_mfc_inst(struct s5p_mfc_dev *dev, struct 
s5p_mfc_ctx *ctx)
}
 
set_work_bit_irqsave(ctx);
-   s5p_mfc_clean_ctx_int_flags(ctx);
s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev);
if (s5p_mfc_wait_for_done_ctx(ctx,
S5P_MFC_R2H_CMD_OPEN_INSTANCE_RET, 0)) {
@@ -494,7 +493,6 @@ void s5p_mfc_close_mfc_inst(struct s5p_mfc_dev *dev, struct 
s5p_mfc_ctx *ctx)
 {
ctx->state = MFCINST_RETURN_INST;
set_work_bit_irqsave(ctx);
-   s5p_mfc_clean_ctx_int_flags(ctx);
s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev);
/* Wait until instance is returned or timeout occurred */
if (s5p_mfc_wait_for_done_ctx(ctx,
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
index de90465..74bcec8 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
@@ -334,7 +334,6 @@ static int vidioc_g_fmt(struct file *file, void *priv, 
struct v4l2_format *f)
MFCINST_RES_CHANGE_END)) {
/* If the MFC is parsing the header,
 * so wait until it is finished */
-   s5p_mfc_clean_ctx_int_flags(ctx);
s5p_mfc_wait_for_done_ctx(ctx, S5P_MFC_R2H_CMD_SEQ_DONE_RET,
0);
}
@@ -746,7 +745,6 @@ static int s5p_mfc_dec_g_v_ctrl(struct v4l2_ctrl *ctrl)
return -EINVAL;
}
/* Should wait for the header to be parsed */
-   s5p_mfc_clean_ctx_int_flags(ctx);
s5p_mfc_wait_for_done_ctx(ctx,
S5P_MFC_R2H_CMD_SEQ_DONE_RET, 0);
if (ctx->state >= MFCINST_HEAD_PARSED &&
@@ -1058,7 +1056,6 @@ static void s5p_mfc_stop_streaming(struct vb2_queue *q)
if (IS_MFCV6_PLUS(dev) && (ctx->state == MFCINST_RUNNING)) {
ctx->state = MFCINST_FLUSH;
set_work_bit_irqsave(ctx);
-   s5p_mfc_clean_ctx_int_flags(ctx);
s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev);
if (s5p_mfc_wait_for_done_ctx(ctx,
S5P_MFC_R2H_CMD_DPB_FLUSH_RET, 0))
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index 6a1c890..7f919e4 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -1663,7 +1663,6 @@ static int s5p_mfc_enc_g_v_ctrl(struct v4l2_ctrl *ctrl)
return -EINVAL;
}
/* Should wait for the header to be produced */
-   s5p_mfc_clean_ctx_int_flags(ctx);
s5p_mfc_wait_for_done_ctx(ctx,
S5P_MFC_R2H_CMD_SEQ_DONE_RET, 0);
if (ctx->state >= MFCINST_HEAD_PARSED &&
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
index 7cf0796..0c4fcf2 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
@@ -1178,7 +1178,6 @@ static void s5p_mfc_run_res_change(struct s5p_mfc_ctx 
*ctx)
 
s5p_mfc_set_dec_stream_buffer_v5(ctx, 0, 0, 0);
dev->curr_ctx = ctx->num;
-   s5p_mfc_clean_ctx_int_flags(ctx);
s5p_mfc_decode_one_frame_v5(ctx, MFC_DEC_RES_CHANGE);
 }
 
@@ -1192,7 +1191,6 @@ static int s5p_mfc_run_dec_frame(struct s5p_mfc_ctx *ctx, 
int last_frame)
last_frame = MFC_DEC_LAST_FRAME;
s5p_mfc_set_dec_stream_buffer_v5(ctx, 0, 0, 0);
dev->curr_

[PATCH v3 11/13] [media] s5p-mfc: Remove unused alloc field from private buffer struct.

2014-10-21 Thread Arun Kumar K
From: Pawel Osciak 

This field is no longer used as MFC driver doesn't use vb2 alloc contexts
anymore.

Signed-off-by: Pawel Osciak 
Signed-off-by: Kiran AVND 
Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h |3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h 
b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index 5b0c334..15f7663 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -237,8 +237,6 @@ struct s5p_mfc_variant {
 
 /**
  * struct s5p_mfc_priv_buf - represents internal used buffer
- * @alloc: allocation-specific context for each buffer
- * (videobuf2 allocator)
  * @ofs:   offset of each buffer, will be used for MFC
  * @virt:  kernel virtual address, only valid when the
  * buffer accessed by driver
@@ -246,7 +244,6 @@ struct s5p_mfc_variant {
  * @size:  size of the buffer
  */
 struct s5p_mfc_priv_buf {
-   void*alloc;
unsigned long   ofs;
void*virt;
dma_addr_t  dma;
-- 
1.7.9.5

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


[PATCH v3 08/13] [media] s5p-mfc: modify mfc wakeup sequence for V8

2014-10-21 Thread Arun Kumar K
From: Arun Mankuzhi 

>From MFC V8, the MFC wakeup sequence has changed.
MFC wakeup command has to be sent after the host receives
firmware load complete status from risc.

Signed-off-by: Arun Mankuzhi 
Signed-off-by: Kiran AVND 
Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c |   78 +++--
 1 file changed, 61 insertions(+), 17 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
index 0d3661b..7c3eaa5 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
@@ -353,6 +353,58 @@ int s5p_mfc_sleep(struct s5p_mfc_dev *dev)
return ret;
 }
 
+static int s5p_mfc_v8_wait_wakeup(struct s5p_mfc_dev *dev)
+{
+   int ret;
+
+   /* Release reset signal to the RISC */
+   dev->risc_on = 1;
+   mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6);
+
+   if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_FW_STATUS_RET)) {
+   mfc_err("Failed to reset MFCV8\n");
+   return -EIO;
+   }
+   mfc_debug(2, "Write command to wakeup MFCV8\n");
+   ret = s5p_mfc_hw_call(dev->mfc_cmds, wakeup_cmd, dev);
+   if (ret) {
+   mfc_err("Failed to send command to MFCV8 - timeout\n");
+   return ret;
+   }
+
+   if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_WAKEUP_RET)) {
+   mfc_err("Failed to wakeup MFC\n");
+   return -EIO;
+   }
+   return ret;
+}
+
+static int s5p_mfc_wait_wakeup(struct s5p_mfc_dev *dev)
+{
+   int ret;
+
+   /* Send MFC wakeup command */
+   ret = s5p_mfc_hw_call(dev->mfc_cmds, wakeup_cmd, dev);
+   if (ret) {
+   mfc_err("Failed to send command to MFC - timeout\n");
+   return ret;
+   }
+
+   /* Release reset signal to the RISC */
+   if (IS_MFCV6_PLUS(dev)) {
+   dev->risc_on = 1;
+   mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6);
+   } else {
+   mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET);
+   }
+
+   if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_WAKEUP_RET)) {
+   mfc_err("Failed to wakeup MFC\n");
+   return -EIO;
+   }
+   return ret;
+}
+
 int s5p_mfc_wakeup(struct s5p_mfc_dev *dev)
 {
int ret;
@@ -365,6 +417,7 @@ int s5p_mfc_wakeup(struct s5p_mfc_dev *dev)
ret = s5p_mfc_reset(dev);
if (ret) {
mfc_err("Failed to reset MFC - timeout\n");
+   s5p_mfc_clock_off();
return ret;
}
mfc_debug(2, "Done MFC reset..\n");
@@ -373,25 +426,16 @@ int s5p_mfc_wakeup(struct s5p_mfc_dev *dev)
/* 2. Initialize registers of channel I/F */
s5p_mfc_clear_cmds(dev);
s5p_mfc_clean_dev_int_flags(dev);
-   /* 3. Initialize firmware */
-   ret = s5p_mfc_hw_call(dev->mfc_cmds, wakeup_cmd, dev);
-   if (ret) {
-   mfc_err("Failed to send command to MFC - timeout\n");
-   return ret;
-   }
-   /* 4. Release reset signal to the RISC */
-   if (IS_MFCV6_PLUS(dev)) {
-   dev->risc_on = 1;
-   mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6);
-   }
+   /* 3. Send MFC wakeup command and wait for completion*/
+   if (IS_MFCV8(dev))
+   ret = s5p_mfc_v8_wait_wakeup(dev);
else
-   mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET);
-   mfc_debug(2, "Ok, now will write a command to wakeup the system\n");
-   if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_WAKEUP_RET)) {
-   mfc_err("Failed to load firmware\n");
-   return -EIO;
-   }
+   ret = s5p_mfc_wait_wakeup(dev);
+
s5p_mfc_clock_off();
+   if (ret)
+   return ret;
+
dev->int_cond = 0;
if (dev->int_err != 0 || dev->int_type !=
S5P_MFC_R2H_CMD_WAKEUP_RET) {
-- 
1.7.9.5

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


[PATCH v3 09/13] [media] s5p-mfc: De-init MFC when watchdog kicks in

2014-10-21 Thread Arun Kumar K
From: Arun Mankuzhi 

If the software watchdog kicks in, we need to de-init MFC
before reloading firmware and re-intializing it again.

Signed-off-by: Arun Mankuzhi 
Signed-off-by: Kiran AVND 
Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c |4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 8620236..39f8f2a 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -159,6 +159,10 @@ static void s5p_mfc_watchdog_worker(struct work_struct 
*work)
}
clear_bit(0, &dev->hw_lock);
spin_unlock_irqrestore(&dev->irqlock, flags);
+
+   /* De-init MFC */
+   s5p_mfc_deinit_hw(dev);
+
/* Double check if there is at least one instance running.
 * If no instance is in memory than no firmware should be present */
if (dev->num_inst > 0) {
-- 
1.7.9.5

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


[PATCH v3 06/13] [media] s5p-mfc: check mfc bus ctrl before reset

2014-10-21 Thread Arun Kumar K
From: Kiran AVND 

during reset sequence, it is advisable to follow the below
sequence, in order to avoid unexpected behavior from MFC
. set SFR 0x7110 MFC_BUS_RESET_CTRL 0x1
  // wait for REQ_STATUS to be 1
. get SFR 0x7110 MFC_BUS_RESET_CTRL 0x3
  // reset now

Signed-off-by: Kiran AVND 
Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/regs-mfc-v6.h  |1 +
 drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c |   25 -
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h 
b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
index 51cb2dd..83e01f3 100644
--- a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
@@ -71,6 +71,7 @@
 #define S5P_FIMV_R2H_CMD_ENC_BUFFER_FUL_RET_V6 16
 #define S5P_FIMV_R2H_CMD_ERR_RET_V632
 
+#define S5P_FIMV_MFC_BUS_RESET_CTRL0x7110
 #define S5P_FIMV_FW_VERSION_V6 0xf000
 
 #define S5P_FIMV_INSTANCE_ID_V60xf008
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
index f5bb6b2..0d3661b 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
@@ -129,6 +129,25 @@ int s5p_mfc_release_firmware(struct s5p_mfc_dev *dev)
return 0;
 }
 
+int s5p_mfc_bus_reset(struct s5p_mfc_dev *dev)
+{
+   unsigned int status;
+   unsigned long timeout;
+
+   /* Reset */
+   mfc_write(dev, 0x1, S5P_FIMV_MFC_BUS_RESET_CTRL);
+   timeout = jiffies + msecs_to_jiffies(MFC_BW_TIMEOUT);
+   /* Check bus status */
+   do {
+   if (time_after(jiffies, timeout)) {
+   mfc_err("Timeout while resetting MFC.\n");
+   return -EIO;
+   }
+   status = mfc_read(dev, S5P_FIMV_MFC_BUS_RESET_CTRL);
+   } while ((status & 0x2) == 0);
+   return 0;
+}
+
 /* Reset the device */
 int s5p_mfc_reset(struct s5p_mfc_dev *dev)
 {
@@ -147,11 +166,15 @@ int s5p_mfc_reset(struct s5p_mfc_dev *dev)
for (i = 0; i < S5P_FIMV_REG_CLEAR_COUNT_V6; i++)
mfc_write(dev, 0, S5P_FIMV_REG_CLEAR_BEGIN_V6 + (i*4));
 
+   /* check bus reset control before reset */
+   if (dev->risc_on)
+   if (s5p_mfc_bus_reset(dev))
+   return -EIO;
/* Reset
 * set RISC_ON to 0 during power_on & wake_up.
 * V6 needs RISC_ON set to 0 during reset also.
 */
-   if ((!dev->risc_on) || (!IS_MFCV7(dev)))
+   if ((!dev->risc_on) || (!IS_MFCV7_PLUS(dev)))
mfc_write(dev, 0, S5P_FIMV_RISC_ON_V6);
 
mfc_write(dev, 0x1FFF, S5P_FIMV_MFC_RESET_V6);
-- 
1.7.9.5

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


[PATCH v3 10/13] [media] s5p-mfc: flush dpbs when resolution changes

2014-10-21 Thread Arun Kumar K
From: Kiran AVND 

While resolution change is detected by MFC, we flush out
older dpbs, send the resolution change event to application,
and then accept further queuing of new src buffers.

Sometimes, we error out during dpb flush because of lack of src
buffers. Since we have not started decoding new resolution yet,
it is simpler to push zero-size buffer until we flush out all dpbs.

This is already been done while handling EOS command, and this patch
extends the same logic to resolution change as well.

Signed-off-by: Kiran AVND 
Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c |   20 ++--
 1 file changed, 2 insertions(+), 18 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
index 8798b14..7b1cf73 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
@@ -1532,27 +1532,11 @@ static inline int s5p_mfc_get_new_ctx(struct 
s5p_mfc_dev *dev)
 static inline void s5p_mfc_run_dec_last_frames(struct s5p_mfc_ctx *ctx)
 {
struct s5p_mfc_dev *dev = ctx->dev;
-   struct s5p_mfc_buf *temp_vb;
-   unsigned long flags;
-
-   spin_lock_irqsave(&dev->irqlock, flags);
-
-   /* Frames are being decoded */
-   if (list_empty(&ctx->src_queue)) {
-   mfc_debug(2, "No src buffers.\n");
-   spin_unlock_irqrestore(&dev->irqlock, flags);
-   return;
-   }
-   /* Get the next source buffer */
-   temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
-   temp_vb->flags |= MFC_BUF_FLAG_USED;
-   s5p_mfc_set_dec_stream_buffer_v6(ctx,
-   vb2_dma_contig_plane_dma_addr(temp_vb->b, 0), 0, 0);
-   spin_unlock_irqrestore(&dev->irqlock, flags);
 
+   s5p_mfc_set_dec_stream_buffer_v6(ctx, 0, 0, 0);
dev->curr_ctx = ctx->num;
s5p_mfc_clean_ctx_int_flags(ctx);
-   s5p_mfc_decode_one_frame_v6(ctx, 1);
+   s5p_mfc_decode_one_frame_v6(ctx, MFC_DEC_LAST_FRAME);
 }
 
 static inline int s5p_mfc_run_dec_frame(struct s5p_mfc_ctx *ctx)
-- 
1.7.9.5

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


[PATCH v3 07/13] [media] s5p-mfc: Don't crash the kernel if the watchdog kicks in.

2014-10-21 Thread Arun Kumar K
From: Pawel Osciak 

If the software watchdog kicks in, the watchdog worker is not synchronized
with hardware interrupts and does not block other instances. It's possible
for it to clear the hw_lock, making other instances trigger a BUG() on
hw_lock checks. Since it's not fatal to clear the hw_lock to zero twice,
just WARN in those cases for now. We should not explode, as firmware will
return errors as needed for other instances after it's reloaded, or they
will time out.

A clean fix should involve killing other instances when watchdog kicks in,
but requires a major redesign of locking in the driver.

Signed-off-by: Pawel Osciak 
Signed-off-by: Kiran AVND 
Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c |   21 +++--
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index eb71055..8620236 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -342,8 +342,7 @@ static void s5p_mfc_handle_frame(struct s5p_mfc_ctx *ctx,
ctx->state = MFCINST_RES_CHANGE_INIT;
s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev);
wake_up_ctx(ctx, reason, err);
-   if (test_and_clear_bit(0, &dev->hw_lock) == 0)
-   BUG();
+   WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
s5p_mfc_clock_off();
s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev);
return;
@@ -415,8 +414,7 @@ leave_handle_frame:
clear_work_bit(ctx);
s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev);
wake_up_ctx(ctx, reason, err);
-   if (test_and_clear_bit(0, &dev->hw_lock) == 0)
-   BUG();
+   WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
s5p_mfc_clock_off();
/* if suspending, wake up device and do not try_run again*/
if (test_bit(0, &dev->enter_suspend))
@@ -463,8 +461,7 @@ static void s5p_mfc_handle_error(struct s5p_mfc_dev *dev,
break;
}
}
-   if (test_and_clear_bit(0, &dev->hw_lock) == 0)
-   BUG();
+   WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev);
s5p_mfc_clock_off();
wake_up_dev(dev, reason, err);
@@ -518,8 +515,7 @@ static void s5p_mfc_handle_seq_done(struct s5p_mfc_ctx *ctx,
}
s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, dev);
clear_work_bit(ctx);
-   if (test_and_clear_bit(0, &dev->hw_lock) == 0)
-   BUG();
+   WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
s5p_mfc_clock_off();
s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev);
wake_up_ctx(ctx, reason, err);
@@ -557,16 +553,14 @@ static void s5p_mfc_handle_init_buffers(struct 
s5p_mfc_ctx *ctx,
} else {
ctx->dpb_flush_flag = 0;
}
-   if (test_and_clear_bit(0, &dev->hw_lock) == 0)
-   BUG();
+   WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
 
s5p_mfc_clock_off();
 
wake_up(&ctx->queue);
s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev);
} else {
-   if (test_and_clear_bit(0, &dev->hw_lock) == 0)
-   BUG();
+   WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
 
s5p_mfc_clock_off();
 
@@ -643,8 +637,7 @@ static irqreturn_t s5p_mfc_irq(int irq, void *priv)
mfc_err("post_frame_start() failed\n");
s5p_mfc_hw_call_void(dev->mfc_ops, clear_int_flags, 
dev);
wake_up_ctx(ctx, reason, err);
-   if (test_and_clear_bit(0, &dev->hw_lock) == 0)
-   BUG();
+   WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
s5p_mfc_clock_off();
s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev);
} else {
-- 
1.7.9.5

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


[PATCH v3 05/13] [media] s5p-mfc: keep RISC ON during reset for V7/V8

2014-10-21 Thread Arun Kumar K
From: Kiran AVND 

Reset sequence for MFC V7 and V8 do not need RISC_ON
to be set to 0, while for MFC V6 it is still needed.

Also, remove a couple of register settings during Reset
which are not needed from V6 onwards.

Signed-off-by: Kiran AVND 
Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h |1 +
 drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c   |   25 ++-
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h 
b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index 3e41ca1..5b0c334 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -340,6 +340,7 @@ struct s5p_mfc_dev {
struct s5p_mfc_hw_cmds *mfc_cmds;
const struct s5p_mfc_regs *mfc_regs;
enum s5p_mfc_fw_ver fw_ver;
+   bool risc_on; /* indicates if RISC is on or off */
 };
 
 /**
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
index 0c885a8..f5bb6b2 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
@@ -139,12 +139,6 @@ int s5p_mfc_reset(struct s5p_mfc_dev *dev)
mfc_debug_enter();
 
if (IS_MFCV6_PLUS(dev)) {
-   /* Reset IP */
-   /*  except RISC, reset */
-   mfc_write(dev, 0xFEE, S5P_FIMV_MFC_RESET_V6);
-   /*  reset release */
-   mfc_write(dev, 0x0, S5P_FIMV_MFC_RESET_V6);
-
/* Zero Initialization of MFC registers */
mfc_write(dev, 0, S5P_FIMV_RISC2HOST_CMD_V6);
mfc_write(dev, 0, S5P_FIMV_HOST2RISC_CMD_V6);
@@ -153,8 +147,13 @@ int s5p_mfc_reset(struct s5p_mfc_dev *dev)
for (i = 0; i < S5P_FIMV_REG_CLEAR_COUNT_V6; i++)
mfc_write(dev, 0, S5P_FIMV_REG_CLEAR_BEGIN_V6 + (i*4));
 
-   /* Reset */
-   mfc_write(dev, 0, S5P_FIMV_RISC_ON_V6);
+   /* Reset
+* set RISC_ON to 0 during power_on & wake_up.
+* V6 needs RISC_ON set to 0 during reset also.
+*/
+   if ((!dev->risc_on) || (!IS_MFCV7(dev)))
+   mfc_write(dev, 0, S5P_FIMV_RISC_ON_V6);
+
mfc_write(dev, 0x1FFF, S5P_FIMV_MFC_RESET_V6);
mfc_write(dev, 0, S5P_FIMV_MFC_RESET_V6);
} else {
@@ -226,6 +225,7 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev)
/* 0. MFC reset */
mfc_debug(2, "MFC reset..\n");
s5p_mfc_clock_on();
+   dev->risc_on = 0;
ret = s5p_mfc_reset(dev);
if (ret) {
mfc_err("Failed to reset MFC - timeout\n");
@@ -238,8 +238,10 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev)
s5p_mfc_clear_cmds(dev);
/* 3. Release reset signal to the RISC */
s5p_mfc_clean_dev_int_flags(dev);
-   if (IS_MFCV6_PLUS(dev))
+   if (IS_MFCV6_PLUS(dev)) {
+   dev->risc_on = 1;
mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6);
+   }
else
mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET);
mfc_debug(2, "Will now wait for completion of firmware transfer\n");
@@ -336,6 +338,7 @@ int s5p_mfc_wakeup(struct s5p_mfc_dev *dev)
/* 0. MFC reset */
mfc_debug(2, "MFC reset..\n");
s5p_mfc_clock_on();
+   dev->risc_on = 0;
ret = s5p_mfc_reset(dev);
if (ret) {
mfc_err("Failed to reset MFC - timeout\n");
@@ -354,8 +357,10 @@ int s5p_mfc_wakeup(struct s5p_mfc_dev *dev)
return ret;
}
/* 4. Release reset signal to the RISC */
-   if (IS_MFCV6_PLUS(dev))
+   if (IS_MFCV6_PLUS(dev)) {
+   dev->risc_on = 1;
mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6);
+   }
else
mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET);
mfc_debug(2, "Ok, now will write a command to wakeup the system\n");
-- 
1.7.9.5

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


[PATCH v3 01/13] [media] s5p-mfc: support MIN_BUFFERS query for encoder

2014-10-21 Thread Arun Kumar K
From: Kiran AVND 

Add V4L2_CID_MIN_BUFFERS_FOR_OUTPUT query for encoder.
Once mfc encoder state is HEAD_PARSED, which is sequence
header produced, dpb_count is avaialable. Let user space
query this value.

Signed-off-by: Kiran AVND 
Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c |   42 ++
 1 file changed, 42 insertions(+)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index a904a1c..4816f31 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -690,6 +690,16 @@ static struct mfc_control controls[] = {
.step = 1,
.default_value = 0,
},
+   {
+   .id = V4L2_CID_MIN_BUFFERS_FOR_OUTPUT,
+   .type = V4L2_CTRL_TYPE_INTEGER,
+   .name = "Minimum number of output bufs",
+   .minimum = 1,
+   .maximum = 32,
+   .step = 1,
+   .default_value = 1,
+   .is_volatile = 1,
+   },
 };
 
 #define NUM_CTRLS ARRAY_SIZE(controls)
@@ -1624,8 +1634,40 @@ static int s5p_mfc_enc_s_ctrl(struct v4l2_ctrl *ctrl)
return ret;
 }
 
+static int s5p_mfc_enc_g_v_ctrl(struct v4l2_ctrl *ctrl)
+{
+   struct s5p_mfc_ctx *ctx = ctrl_to_ctx(ctrl);
+   struct s5p_mfc_dev *dev = ctx->dev;
+
+   switch (ctrl->id) {
+   case V4L2_CID_MIN_BUFFERS_FOR_OUTPUT:
+   if (ctx->state >= MFCINST_HEAD_PARSED &&
+   ctx->state < MFCINST_ABORT) {
+   ctrl->val = ctx->pb_count;
+   break;
+   } else if (ctx->state != MFCINST_INIT) {
+   v4l2_err(&dev->v4l2_dev, "Encoding not initialised\n");
+   return -EINVAL;
+   }
+   /* Should wait for the header to be produced */
+   s5p_mfc_clean_ctx_int_flags(ctx);
+   s5p_mfc_wait_for_done_ctx(ctx,
+   S5P_MFC_R2H_CMD_SEQ_DONE_RET, 0);
+   if (ctx->state >= MFCINST_HEAD_PARSED &&
+   ctx->state < MFCINST_ABORT) {
+   ctrl->val = ctx->pb_count;
+   } else {
+   v4l2_err(&dev->v4l2_dev, "Encoding not initialised\n");
+   return -EINVAL;
+   }
+   break;
+   }
+   return 0;
+}
+
 static const struct v4l2_ctrl_ops s5p_mfc_enc_ctrl_ops = {
.s_ctrl = s5p_mfc_enc_s_ctrl,
+   .g_volatile_ctrl = s5p_mfc_enc_g_v_ctrl,
 };
 
 static int vidioc_s_parm(struct file *file, void *priv,
-- 
1.7.9.5

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


[PATCH v3 00/13] Fixes from Chrome OS tree for MFC driver

2014-10-21 Thread Arun Kumar K
Upstreaming the fixes which have gone in to Chrome OS tree for MFC driver.
Tested on MFCV8, MFCV7 and MFCV6 based Exynos5 based boards, peach-pi
(5800), peach-pit (5420) and snow (5250).

Changes from v2:
1) Rebased on latest media-tree
2) Dropped the patch (14/14) from previous set
   s5p-mfc: Don't change the image size to smaller than the request.

Changes from v1:
1) Addressed all review comments from Kamil.
2) Dropped patches
   [media] s5p-mfc: set B-frames as 2 while encoding
   [media] s5p-mfc: remove reduntant clock on & clock off
   [media] s5p-mfc: don't disable clock when next ctx is pending
3) Rebased on media-tree

Arun Mankuzhi (2):
  [media] s5p-mfc: modify mfc wakeup sequence for V8
  [media] s5p-mfc: De-init MFC when watchdog kicks in

Ilja Friedel (1):
  [media] s5p-mfc: Only set timestamp/timecode for new frames.

Kiran AVND (4):
  [media] s5p-mfc: support MIN_BUFFERS query for encoder
  [media] s5p-mfc: keep RISC ON during reset for V7/V8
  [media] s5p-mfc: check mfc bus ctrl before reset
  [media] s5p-mfc: flush dpbs when resolution changes

Pawel Osciak (5):
  [media] s5p-mfc: Fix REQBUFS(0) for encoder.
  [media] s5p-mfc: Don't crash the kernel if the watchdog kicks in.
  [media] s5p-mfc: Remove unused alloc field from private buffer
struct.
  [media] s5p-mfc: fix V4L2_CID_MIN_BUFFERS_FOR_CAPTURE on resolution
change.
  [media] s5p-mfc: fix a race in interrupt flags handling

Prathyush K (1):
  [media] s5p-mfc: clear 'enter_suspend' flag if suspend fails

 drivers/media/platform/s5p-mfc/regs-mfc-v6.h|1 +
 drivers/media/platform/s5p-mfc/s5p_mfc.c|   45 +
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h |4 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c   |  122 ++-
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c|6 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c|   54 ++
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c |   13 +--
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c |   32 +-
 8 files changed, 188 insertions(+), 89 deletions(-)

-- 
1.7.9.5

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


[PATCH v3 02/13] [media] s5p-mfc: Fix REQBUFS(0) for encoder.

2014-10-21 Thread Arun Kumar K
From: Pawel Osciak 

Handle REQBUFS(0) for CAPTURE queue as well. Also use the proper queue to call
it on for OUTPUT.

Signed-off-by: Pawel Osciak 
Signed-off-by: Kiran AVND 
Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c |   13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index 4816f31..6a1c890 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -1147,6 +1147,11 @@ static int vidioc_reqbufs(struct file *file, void *priv,
(reqbufs->memory != V4L2_MEMORY_USERPTR))
return -EINVAL;
if (reqbufs->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
+   if (reqbufs->count == 0) {
+   ret = vb2_reqbufs(&ctx->vq_dst, reqbufs);
+   ctx->capture_state = QUEUE_FREE;
+   return ret;
+   }
if (ctx->capture_state != QUEUE_FREE) {
mfc_err("invalid capture state: %d\n",
ctx->capture_state);
@@ -1168,6 +1173,14 @@ static int vidioc_reqbufs(struct file *file, void *priv,
return -ENOMEM;
}
} else if (reqbufs->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
+   if (reqbufs->count == 0) {
+   mfc_debug(2, "Freeing buffers\n");
+   ret = vb2_reqbufs(&ctx->vq_src, reqbufs);
+   s5p_mfc_hw_call(dev->mfc_ops, release_codec_buffers,
+   ctx);
+   ctx->output_state = QUEUE_FREE;
+   return ret;
+   }
if (ctx->output_state != QUEUE_FREE) {
mfc_err("invalid output state: %d\n",
ctx->output_state);
-- 
1.7.9.5

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


[PATCH v3 04/13] [media] s5p-mfc: Only set timestamp/timecode for new frames.

2014-10-21 Thread Arun Kumar K
From: Ilja Friedel 

Timestamp i of a previously decoded buffer was overwritten for some
H.264 streams with timestamp i+1 of the next buffer. This happened when
encountering frame_type S5P_FIMV_DECODE_FRAME_SKIPPED, indicating no
new frame.

In most cases this wrong indexing might not have been noticed except
for a one frame delay in frame presentation. For H.264 streams though
that require reordering of frames for presentation, it caused a slightly
erratic presentation time lookup and consequently dropped frames in the
Pepper Flash plugin.

Signed-off-by: Ilja H. Friedel 
Signed-off-by: Kiran AVND 
Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c |   12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 79c9537..eb71055 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -220,11 +220,14 @@ static void s5p_mfc_handle_frame_copy_time(struct 
s5p_mfc_ctx *ctx)
size_t dec_y_addr;
unsigned int frame_type;
 
-   dec_y_addr = s5p_mfc_hw_call(dev->mfc_ops, get_dec_y_adr, dev);
+   /* Make sure we actually have a new frame before continuing. */
frame_type = s5p_mfc_hw_call(dev->mfc_ops, get_dec_frame_type, dev);
+   if (frame_type == S5P_FIMV_DECODE_FRAME_SKIPPED)
+   return;
+   dec_y_addr = s5p_mfc_hw_call(dev->mfc_ops, get_dec_y_adr, dev);
 
/* Copy timestamp / timecode from decoded src to dst and set
-  appropriate flags */
+  appropriate flags. */
src_buf = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
list_for_each_entry(dst_buf, &ctx->dst_queue, list) {
if (vb2_dma_contig_plane_dma_addr(dst_buf->b, 0) == dec_y_addr) 
{
@@ -250,6 +253,11 @@ static void s5p_mfc_handle_frame_copy_time(struct 
s5p_mfc_ctx *ctx)
dst_buf->b->v4l2_buf.flags |=
V4L2_BUF_FLAG_BFRAME;
break;
+   default:
+   /* Don't know how to handle
+  S5P_FIMV_DECODE_FRAME_OTHER_FRAME. */
+   mfc_debug(2, "Unexpected frame type: %d\n",
+   frame_type);
}
break;
}
-- 
1.7.9.5

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


[PATCH v3 03/13] [media] s5p-mfc: clear 'enter_suspend' flag if suspend fails

2014-10-21 Thread Arun Kumar K
From: Prathyush K 

The enter_suspend flag is set after we enter mfc suspend function but if
suspend fails after that due to any reason (like hardware timeout etc),
this flag must be cleared before returning an error. Otherwise, this
flag never gets cleared and the MFC suspend will always return an error
on subsequent tries. If clock off fails, disable hw_lock also.

Signed-off-by: Prathyush K 
Signed-off-by: Kiran AVND 
Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c |8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 165bc86..79c9537 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -1284,11 +1284,17 @@ static int s5p_mfc_suspend(struct device *dev)
m_dev->int_cond, msecs_to_jiffies(MFC_INT_TIMEOUT));
if (ret == 0) {
mfc_err("Waiting for hardware to finish timed out\n");
+   clear_bit(0, &m_dev->enter_suspend);
return -EIO;
}
}
 
-   return s5p_mfc_sleep(m_dev);
+   ret = s5p_mfc_sleep(m_dev);
+   if (ret) {
+   clear_bit(0, &m_dev->enter_suspend);
+   clear_bit(0, &m_dev->hw_lock);
+   }
+   return ret;
 }
 
 static int s5p_mfc_resume(struct device *dev)
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 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/1] ARM: exynos_defconfig: Update exynos_defconfig

2014-07-14 Thread Arun Kumar K
Tested-by: Arun Kumar K 

on Samsung chromebook boards : Snow, pit and pi.

Regards
Arun

On Wed, Jul 9, 2014 at 3:52 PM, Sachin Kamat  wrote:
> Removed outdated configs. Enabled most of the configs used on latest
> Exynos based platforms. This will provide a reference for users trying
> to verify and test various features on Exynos based platforms and also
> help in detecting breakages by widening the build coverage.
>
> Signed-off-by: Sachin Kamat 
> ---
>  arch/arm/configs/exynos_defconfig |   56 
> +++--
>  1 file changed, 48 insertions(+), 8 deletions(-)
>
> diff --git a/arch/arm/configs/exynos_defconfig 
> b/arch/arm/configs/exynos_defconfig
> index e07a227ec0db..fc7d1683bf67 100644
> --- a/arch/arm/configs/exynos_defconfig
> +++ b/arch/arm/configs/exynos_defconfig
> @@ -8,15 +8,17 @@ CONFIG_MODULE_UNLOAD=y
>  # CONFIG_BLK_DEV_BSG is not set
>  CONFIG_PARTITION_ADVANCED=y
>  CONFIG_ARCH_EXYNOS=y
> -CONFIG_S3C_LOWLEVEL_UART_PORT=3
> -CONFIG_S3C24XX_PWM=y
> -CONFIG_ARCH_EXYNOS5=y
> -CONFIG_MACH_EXYNOS4_DT=y
> +CONFIG_ARCH_EXYNOS3=y
> +CONFIG_EXYNOS5420_MCPM=y
>  CONFIG_SMP=y
> +CONFIG_BIG_LITTLE=y
> +CONFIG_BL_SWITCHER=y
> +CONFIG_BL_SWITCHER_DUMMY_IF=y
>  CONFIG_NR_CPUS=8
>  CONFIG_PREEMPT=y
>  CONFIG_AEABI=y
>  CONFIG_HIGHMEM=y
> +CONFIG_CMA=y
>  CONFIG_ZBOOT_ROM_TEXT=0x0
>  CONFIG_ZBOOT_ROM_BSS=0x0
>  CONFIG_ARM_APPENDED_DTB=y
> @@ -24,6 +26,7 @@ CONFIG_ARM_ATAG_DTB_COMPAT=y
>  CONFIG_CMDLINE="root=/dev/ram0 rw ramdisk=8192 initrd=0x4100,8M 
> console=ttySAC1,115200 init=/linuxrc mem=256M"
>  CONFIG_VFP=y
>  CONFIG_NEON=y
> +CONFIG_PM_RUNTIME=y
>  CONFIG_NET=y
>  CONFIG_PACKET=y
>  CONFIG_UNIX=y
> @@ -34,6 +37,8 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
>  CONFIG_DEVTMPFS=y
>  CONFIG_DEVTMPFS_MOUNT=y
>  CONFIG_PROC_DEVICETREE=y
> +CONFIG_DMA_CMA=y
> +CONFIG_CMA_SIZE_MBYTES=64
>  CONFIG_BLK_DEV_LOOP=y
>  CONFIG_BLK_DEV_CRYPTOLOOP=y
>  CONFIG_BLK_DEV_RAM=y
> @@ -66,11 +71,22 @@ CONFIG_I2C=y
>  CONFIG_I2C_MUX=y
>  CONFIG_I2C_ARB_GPIO_CHALLENGE=y
>  CONFIG_I2C_EXYNOS5=y
> +CONFIG_I2C_CROS_EC_TUNNEL=y
> +CONFIG_SPI=y
> +CONFIG_SPI_S3C64XX=y
>  CONFIG_I2C_S3C2410=y
>  CONFIG_DEBUG_GPIO=y
> +CONFIG_POWER_SUPPLY=y
> +CONFIG_CHARGER_TPS65090=y
>  # CONFIG_HWMON is not set
> +CONFIG_THERMAL=y
> +CONFIG_EXYNOS_THERMAL=y
> +CONFIG_EXYNOS_THERMAL_CORE=y
> +CONFIG_WATCHDOG=y
> +CONFIG_S3C2410_WATCHDOG=y
>  CONFIG_MFD_CROS_EC=y
>  CONFIG_MFD_CROS_EC_I2C=y
> +CONFIG_MFD_CROS_EC_SPI=y
>  CONFIG_MFD_MAX77686=y
>  CONFIG_MFD_MAX8997=y
>  CONFIG_MFD_SEC_CORE=y
> @@ -80,6 +96,7 @@ CONFIG_REGULATOR_FIXED_VOLTAGE=y
>  CONFIG_REGULATOR_GPIO=y
>  CONFIG_REGULATOR_MAX8997=y
>  CONFIG_REGULATOR_MAX77686=y
> +CONFIG_REGULATOR_S2MPA01=y
>  CONFIG_REGULATOR_S2MPS11=y
>  CONFIG_REGULATOR_S5M8767=y
>  CONFIG_REGULATOR_TPS65090=y
> @@ -88,28 +105,50 @@ CONFIG_FB_MODE_HELPERS=y
>  CONFIG_FB_SIMPLE=y
>  CONFIG_EXYNOS_VIDEO=y
>  CONFIG_EXYNOS_MIPI_DSI=y
> -CONFIG_EXYNOS_DP=y
>  CONFIG_FRAMEBUFFER_CONSOLE=y
>  CONFIG_FONTS=y
>  CONFIG_FONT_7x14=y
>  CONFIG_LOGO=y
> +CONFIG_SOUND=y
> +CONFIG_SND=y
> +CONFIG_SND_SOC=y
> +CONFIG_SND_SOC_SAMSUNG=y
> +CONFIG_SND_SOC_SNOW=y
>  CONFIG_USB=y
> +CONFIG_USB_XHCI_HCD=y
>  CONFIG_USB_EHCI_HCD=y
>  CONFIG_USB_EHCI_EXYNOS=y
> +CONFIG_USB_OHCI_HCD=y
> +CONFIG_USB_OHCI_EXYNOS=y
>  CONFIG_USB_STORAGE=y
>  CONFIG_USB_DWC3=y
> -CONFIG_USB_PHY=y
> -CONFIG_SAMSUNG_USB2PHY=y
> -CONFIG_SAMSUNG_USB3PHY=y
> +CONFIG_USB_HSIC_USB3503=y
>  CONFIG_MMC=y
>  CONFIG_MMC_SDHCI=y
>  CONFIG_MMC_SDHCI_S3C=y
> +CONFIG_MMC_SDHCI_S3C_DMA=y
>  CONFIG_MMC_DW=y
>  CONFIG_MMC_DW_IDMAC=y
>  CONFIG_MMC_DW_EXYNOS=y
>  CONFIG_RTC_CLASS=y
> +CONFIG_RTC_DRV_MAX77686=y
> +CONFIG_RTC_DRV_S5M=y
>  CONFIG_RTC_DRV_S3C=y
> +CONFIG_DMADEVICES=y
> +CONFIG_PL330_DMA=y
>  CONFIG_COMMON_CLK_MAX77686=y
> +CONFIG_COMMON_CLK_S2MPS11=y
> +CONFIG_EXYNOS_IOMMU=y
> +CONFIG_IIO=y
> +CONFIG_EXYNOS_ADC=y
> +CONFIG_PWM=y
> +CONFIG_PWM_SAMSUNG=y
> +CONFIG_PHY_EXYNOS5250_SATA=y
> +CONFIG_PHY_SAMSUNG_USB2=y
> +CONFIG_PHY_EXYNOS4210_USB2=y
> +CONFIG_PHY_EXYNOS4X12_USB2=y
> +CONFIG_PHY_EXYNOS5250_USB2=y
> +CONFIG_PHY_EXYNOS5_USBDRD=y
>  CONFIG_EXT2_FS=y
>  CONFIG_EXT3_FS=y
>  CONFIG_EXT4_FS=y
> @@ -123,6 +162,7 @@ CONFIG_NLS_CODEPAGE_437=y
>  CONFIG_NLS_ASCII=y
>  CONFIG_NLS_ISO8859_1=y
>  CONFIG_PRINTK_TIME=y
> +CONFIG_DEBUG_FS=y
>  CONFIG_MAGIC_SYSRQ=y
>  CONFIG_DEBUG_KERNEL=y
>  CONFIG_DETECT_HUNG_TASK=y
> --
> 1.7.9.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 
> 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-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND PATCHv2 0/3] Power-domain clk handling

2014-07-07 Thread Arun Kumar K
This patch series for clock handling in power domain is
re-send for merging after rebasing onto latest linux-samsung.git,
for-next branch.
Original series and discussion can be found here:
https://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg31550.html

Arun Kumar K (2):
  clk: exynos5420: Add IDs for clocks used in PD mfc
  ARM: dts: Add clock property for mfc_pd in 5420

Prathyush K (1):
  ARM: EXYNOS: Add support for clock handling in power domain

 .../bindings/arm/exynos/power_domain.txt   |   20 +++
 arch/arm/boot/dts/exynos5420.dtsi  |3 +
 arch/arm/mach-exynos/pm_domains.c  |   61 +++-
 drivers/clk/samsung/clk-exynos5420.c   |6 +-
 include/dt-bindings/clock/exynos5420.h |2 +
 5 files changed, 89 insertions(+), 3 deletions(-)

-- 
1.7.9.5

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


[RESEND PATCHv2 1/3] ARM: EXYNOS: Add support for clock handling in power domain

2014-07-07 Thread Arun Kumar K
From: Prathyush K 

While powering on/off a local powerdomain in exynos5 chipsets, the input
clocks to each device gets modified. This behaviour is based on the
SYSCLK_SYS_PWR_REG registers.
E.g. SYSCLK_MFC_SYS_PWR_REG = 0x0, the parent of input clock to MFC
   (aclk333) gets modified to oscclk
= 0x1, no change in clocks.
The recommended value of SYSCLK_SYS_PWR_REG before power gating any
domain is 0x0. So we must also restore the clocks while powering on a
domain everytime.

This patch adds the framework for getting the required mux and parent clocks
through a power domain device node. With this patch, while powering off
a domain, parent is set to oscclk and while powering back on, its re-set
to the correct parent which is as per the recommended pd on/off
sequence.

Signed-off-by: Prathyush K 
Signed-off-by: Andrew Bresticker 
Signed-off-by: Arun Kumar K 
Signed-off-by: Shaik Ameer Basha 
Reviewed-by: Tomasz Figa 
---
 .../bindings/arm/exynos/power_domain.txt   |   20 +++
 arch/arm/mach-exynos/pm_domains.c  |   61 +++-
 2 files changed, 80 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/arm/exynos/power_domain.txt 
b/Documentation/devicetree/bindings/arm/exynos/power_domain.txt
index 5216b41..8b4f7b7f 100644
--- a/Documentation/devicetree/bindings/arm/exynos/power_domain.txt
+++ b/Documentation/devicetree/bindings/arm/exynos/power_domain.txt
@@ -9,6 +9,18 @@ Required Properties:
 - reg: physical base address of the controller and length of memory mapped
 region.
 
+Optional Properties:
+- clocks: List of clock handles. The parent clocks of the input clocks to the
+   devices in this power domain are set to oscclk before power gating
+   and restored back after powering on a domain. This is required for
+   all domains which are powered on and off and not required for unused
+   domains.
+- clock-names: The following clocks can be specified:
+   - oscclk: Oscillator clock.
+   - pclkN, clkN: Pairs of parent of input clock and input clock to the
+   devices in this power domain. Maximum of 4 pairs (N = 0 to 3)
+   are supported currently.
+
 Node of a device using power domains must have a samsung,power-domain property
 defined with a phandle to respective power domain.
 
@@ -19,6 +31,14 @@ Example:
reg = <0x10023C00 0x10>;
};
 
+   mfc_pd: power-domain@10044060 {
+   compatible = "samsung,exynos4210-pd";
+   reg = <0x10044060 0x20>;
+   clocks = <&clock CLK_FIN_PLL>, <&clock CLK_MOUT_SW_ACLK333>,
+   <&clock CLK_MOUT_USER_ACLK333>;
+   clock-names = "oscclk", "pclk0", "clk0";
+   };
+
 Example of the node using power domain:
 
node {
diff --git a/arch/arm/mach-exynos/pm_domains.c 
b/arch/arm/mach-exynos/pm_domains.c
index bcd8dcf..41f064b 100644
--- a/arch/arm/mach-exynos/pm_domains.c
+++ b/arch/arm/mach-exynos/pm_domains.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -24,6 +25,8 @@
 
 #define INT_LOCAL_PWR_EN   0x7
 
+#define MAX_CLK_PER_DOMAIN 4
+
 /*
  * Exynos specific wrapper around the generic power domain
  */
@@ -32,6 +35,9 @@ struct exynos_pm_domain {
char const *name;
bool is_off;
struct generic_pm_domain pd;
+   struct clk *oscclk;
+   struct clk *clk[MAX_CLK_PER_DOMAIN];
+   struct clk *pclk[MAX_CLK_PER_DOMAIN];
 };
 
 static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on)
@@ -44,6 +50,19 @@ static int exynos_pd_power(struct generic_pm_domain *domain, 
bool power_on)
pd = container_of(domain, struct exynos_pm_domain, pd);
base = pd->base;
 
+   /* Set oscclk before powering off a domain*/
+   if (!power_on) {
+   int i;
+
+   for (i = 0; i < MAX_CLK_PER_DOMAIN; i++) {
+   if (IS_ERR(pd->clk[i]))
+   break;
+   if (clk_set_parent(pd->clk[i], pd->oscclk))
+   pr_err("%s: error setting oscclk as parent to 
clock %d\n",
+   pd->name, i);
+   }
+   }
+
pwr = power_on ? INT_LOCAL_PWR_EN : 0;
__raw_writel(pwr, base);
 
@@ -60,6 +79,20 @@ static int exynos_pd_power(struct generic_pm_domain *domain, 
bool power_on)
cpu_relax();
usleep_range(80, 100);
}
+
+   /* Restore clocks after powering on a domain*/
+   if (power_on) {
+   int i;
+
+   for (i = 0; i < MAX_CLK_PER_DOMAIN; i++) {
+   if (IS_ERR(pd->clk[i]))
+   break;
+ 

[RESEND PATCHv2 2/3] clk: exynos5420: Add IDs for clocks used in PD mfc

2014-07-07 Thread Arun Kumar K
Adds IDs for MUX clocks to be used by power domain for MFC
for doing re-parenting while pd on/off.

Signed-off-by: Arun Kumar K 
Signed-off-by: Shaik Ameer Basha 
Acked-by: Tomasz Figa 
---
 drivers/clk/samsung/clk-exynos5420.c   |6 --
 include/dt-bindings/clock/exynos5420.h |2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/samsung/clk-exynos5420.c 
b/drivers/clk/samsung/clk-exynos5420.c
index 9d7d7ee..f74f882f 100644
--- a/drivers/clk/samsung/clk-exynos5420.c
+++ b/drivers/clk/samsung/clk-exynos5420.c
@@ -631,7 +631,8 @@ static struct samsung_mux_clock exynos5x_mux_clks[] 
__initdata = {
SRC_TOP4, 16, 1),
MUX(0, "mout_user_aclk266", mout_user_aclk266_p, SRC_TOP4, 20, 1),
MUX(0, "mout_user_aclk166", mout_user_aclk166_p, SRC_TOP4, 24, 1),
-   MUX(0, "mout_user_aclk333", mout_user_aclk333_p, SRC_TOP4, 28, 1),
+   MUX(CLK_MOUT_USER_ACLK333, "mout_user_aclk333", mout_user_aclk333_p,
+   SRC_TOP4, 28, 1),
 
MUX(0, "mout_user_aclk400_disp1", mout_user_aclk400_disp1_p,
SRC_TOP5, 0, 1),
@@ -684,7 +685,8 @@ static struct samsung_mux_clock exynos5x_mux_clks[] 
__initdata = {
SRC_TOP11, 12, 1),
MUX(0, "mout_sw_aclk266", mout_sw_aclk266_p, SRC_TOP11, 20, 1),
MUX(0, "mout_sw_aclk166", mout_sw_aclk166_p, SRC_TOP11, 24, 1),
-   MUX(0, "mout_sw_aclk333", mout_sw_aclk333_p, SRC_TOP11, 28, 1),
+   MUX(CLK_MOUT_SW_ACLK333, "mout_sw_aclk333", mout_sw_aclk333_p,
+   SRC_TOP11, 28, 1),
 
MUX(0, "mout_sw_aclk400_disp1", mout_sw_aclk400_disp1_p,
SRC_TOP12, 4, 1),
diff --git a/include/dt-bindings/clock/exynos5420.h 
b/include/dt-bindings/clock/exynos5420.h
index 97dcb89..3fc08ff 100644
--- a/include/dt-bindings/clock/exynos5420.h
+++ b/include/dt-bindings/clock/exynos5420.h
@@ -203,6 +203,8 @@
 #define CLK_MOUT_G3D   641
 #define CLK_MOUT_VPLL  642
 #define CLK_MOUT_MAUDIO0   643
+#define CLK_MOUT_USER_ACLK333  644
+#define CLK_MOUT_SW_ACLK333645
 
 /* divider clocks */
 #define CLK_DOUT_PIXEL 768
-- 
1.7.9.5

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


[RESEND PATCHv2 3/3] ARM: dts: Add clock property for mfc_pd in 5420

2014-07-07 Thread Arun Kumar K
Adding the optional clock property for the mfc_pd for
handling the re-parenting while pd on/off.

Signed-off-by: Arun Kumar K 
Signed-off-by: Shaik Ameer Basha 
Reviewed-by: Tomasz Figa 
---
 arch/arm/boot/dts/exynos5420.dtsi |3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/boot/dts/exynos5420.dtsi 
b/arch/arm/boot/dts/exynos5420.dtsi
index 79e9119..1595722 100644
--- a/arch/arm/boot/dts/exynos5420.dtsi
+++ b/arch/arm/boot/dts/exynos5420.dtsi
@@ -260,6 +260,9 @@
mfc_pd: power-domain@10044060 {
compatible = "samsung,exynos4210-pd";
reg = <0x10044060 0x20>;
+   clocks = <&clock CLK_FIN_PLL>, <&clock CLK_MOUT_SW_ACLK333>,
+   <&clock CLK_MOUT_USER_ACLK333>;
+   clock-names = "oscclk", "pclk0", "clk0";
};
 
disp_pd: power-domain@100440C0 {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 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/2] s5p-mfc: Adding MFC v7 and v8 firmwares

2014-06-04 Thread Arun Kumar K
Hi Ben,

On Wed, Jun 4, 2014 at 5:43 PM, Ben Hutchings  wrote:
> On Wed, 2014-06-04 at 13:08 +0200, Kamil Debski wrote:
>> Hi Arun, Ben,
>>
>>
>> > From: arunkk.sams...@gmail.com [mailto:arunkk.sams...@gmail.com] On
>> > Behalf Of Arun Kumar K
>> > Sent: Wednesday, June 04, 2014 7:32 AM
>> >
>> > Hi Ben,
>> >
>> > On Wed, Jun 4, 2014 at 4:56 AM, Ben Hutchings 
>> > wrote:
>> > > On Tue, 2014-06-03 at 20:34 +0100, Ben Hutchings wrote:
>> > >> On Wed, 2014-05-21 at 18:11 +0530, Arun Kumar K wrote:
>> > >> > Adding the following firmware files for MFC
>> > >> > s5p-mfc-v7.fw: Used in exynos 5420
>> > >> > s5p-mfc-v8.fw: Used in exynos 5800
>> > >> >
>> > >> > Signed-off-by: Arun Kumar K 
>> > >> > ---
>> > >> > Changes from v1
>> > >> > - None
>> > >> > ---
>> > >> >  WHENCE|2 ++
>> > >> >  s5p-mfc/s5p-mfc-v7.fw |  Bin 0 -> 382724 bytes
>> > >> > s5p-mfc/s5p-mfc-v8.fw |  Bin 0 -> 360576 bytes
>> > >> >  3 files changed, 2 insertions(+)
>> > >> >  create mode 100644 s5p-mfc/s5p-mfc-v7.fw  create mode 100644
>> > >> > s5p-mfc/s5p-mfc-v8.fw
>> > >> [...]
>> > >>
>> > >> Applied, thanks.
>> > >
>> > > Just noticed a problem with all the s5p-mfc firmware: you are putting
>> > > it in the s5p-mfc subdirectory, so distribution packages will install
>> > > them in /lib/firmware/s5p-mfc.  However, unless I'm mistaken your
>> > > driver requests it with a bare filename (e.g. "s5p-mfc-v7.fw") so it
>> > > won't be found.
>> > >
>> >
>> > Yes this issue is there.
>> > Kamil, are you ok with changing the fw load path to s5p-mfc/s5p-mfc*.fw
>> > in the driver?
>>
>> We have two options here:
>> 1) Change the driver to request s5p-mfc/sp5-mfc-fw*
>> 2) Move the files in the firmware repository
>>
>> I would opt for the second option. The driver was uploaded before the
>> firmware. I see that there are many firmware files in the root folder
>> of the repository
>>
>> Ben, what is your opinion? Which is preferred: creating subdirectories
>> or storing firmware in the root folder?
>
> I prefer subdirectories, but compatibility wins.  So I'll apply the
> following patch if no-one objects.
>
> Ben.
>
> ---
> Subject: Move the s5p-mfc firmware out of its subdirectory
>
> The driver does not include this subdirectory name when requesting
> firmware.
>
> Signed-off-by: Ben Hutchings 
> ---
>  WHENCE   |  10 +-
>  s5p-mfc/s5p-mfc-v6-v2.fw => s5p-mfc-v6-v2.fw | Bin
>  s5p-mfc/s5p-mfc-v6.fw => s5p-mfc-v6.fw   | Bin
>  s5p-mfc/s5p-mfc-v7.fw => s5p-mfc-v7.fw   | Bin
>  s5p-mfc/s5p-mfc-v8.fw => s5p-mfc-v8.fw   | Bin
>  s5p-mfc/s5p-mfc.fw => s5p-mfc.fw | Bin
>  6 files changed, 5 insertions(+), 5 deletions(-)
>  rename s5p-mfc/s5p-mfc-v6-v2.fw => s5p-mfc-v6-v2.fw (100%)
>  rename s5p-mfc/s5p-mfc-v6.fw => s5p-mfc-v6.fw (100%)
>  rename s5p-mfc/s5p-mfc-v7.fw => s5p-mfc-v7.fw (100%)
>  rename s5p-mfc/s5p-mfc-v8.fw => s5p-mfc-v8.fw (100%)
>  rename s5p-mfc/s5p-mfc.fw => s5p-mfc.fw (100%)
>
> diff --git a/WHENCE b/WHENCE
> index 6a64fc2..a172f5f 100644
> --- a/WHENCE
> +++ b/WHENCE
> @@ -2250,11 +2250,11 @@ Licence: Redistributable. See 
> LICENCE.atheros_firmware for details
>
>  Driver: s5p-mfc - Samsung MFC video encoder/decoder driver
>
> -File: s5p-mfc/s5p-mfc.fw
> -File: s5p-mfc/s5p-mfc-v6.fw
> -File: s5p-mfc/s5p-mfc-v6-v2.fw
> -File: s5p-mfc/s5p-mfc-v7.fw
> -File: s5p-mfc/s5p-mfc-v8.fw
> +File: s5p-mfc.fw
> +File: s5p-mfc-v6.fw
> +File: s5p-mfc-v6-v2.fw
> +File: s5p-mfc-v7.fw
> +File: s5p-mfc-v8.fw
>
>  Licence:
>  Samsung grants permission to use and redistribute aforementioned firmware
> diff --git a/s5p-mfc/s5p-mfc-v6-v2.fw b/s5p-mfc-v6-v2.fw
> similarity index 100%
> rename from s5p-mfc/s5p-mfc-v6-v2.fw
> rename to s5p-mfc-v6-v2.fw
> diff --git a/s5p-mfc/s5p-mfc-v6.fw b/s5p-mfc-v6.fw
> similarity index 100%
> rename from s5p-mfc/s5p-mfc-v6.fw
> rename to s5p-mfc-v6.fw
> diff --git a/s5p-mfc/s5p-mfc-v7.fw b/s5p-mfc-v7.fw
> similarity index 100%
> rename from s5p-mfc/s5p-mfc-v7.fw
> rename to s5p-mfc-v7.fw
> diff --git a/s5p-mfc/s5p-mfc-v8.fw b/s5p-mfc-v8.fw
> similarity index 100%
> rename from s5p-mfc/s5p-mfc-v8.fw
> rename to s5p-mfc-v8.fw
> diff --git a/s5p-mfc/s5p-mfc.fw b/s5p-mfc.fw
> similarity index 100%
> rename from s5p-mfc/s5p-mfc.fw
> rename to s5p-mfc.fw
>
>

Looks good to me.

Regards
Arun

> --
> Ben Hutchings
> Experience is what causes a person to make new mistakes instead of old ones.
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 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/2] s5p-mfc: Adding MFC v7 and v8 firmwares

2014-06-03 Thread Arun Kumar K
Hi Ben,

On Wed, Jun 4, 2014 at 4:56 AM, Ben Hutchings  wrote:
> On Tue, 2014-06-03 at 20:34 +0100, Ben Hutchings wrote:
>> On Wed, 2014-05-21 at 18:11 +0530, Arun Kumar K wrote:
>> > Adding the following firmware files for MFC
>> > s5p-mfc-v7.fw: Used in exynos 5420
>> > s5p-mfc-v8.fw: Used in exynos 5800
>> >
>> > Signed-off-by: Arun Kumar K 
>> > ---
>> > Changes from v1
>> > - None
>> > ---
>> >  WHENCE|2 ++
>> >  s5p-mfc/s5p-mfc-v7.fw |  Bin 0 -> 382724 bytes
>> >  s5p-mfc/s5p-mfc-v8.fw |  Bin 0 -> 360576 bytes
>> >  3 files changed, 2 insertions(+)
>> >  create mode 100644 s5p-mfc/s5p-mfc-v7.fw
>> >  create mode 100644 s5p-mfc/s5p-mfc-v8.fw
>> [...]
>>
>> Applied, thanks.
>
> Just noticed a problem with all the s5p-mfc firmware: you are putting it
> in the s5p-mfc subdirectory, so distribution packages will install them
> in /lib/firmware/s5p-mfc.  However, unless I'm mistaken your driver
> requests it with a bare filename (e.g. "s5p-mfc-v7.fw") so it won't be
> found.
>

Yes this issue is there.
Kamil, are you ok with changing the fw load path to s5p-mfc/s5p-mfc*.fw
in the driver?

Regards
Arun

> Ben.
>
> --
> Ben Hutchings
> Experience is what causes a person to make new mistakes instead of old ones.
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 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] ARM: dts: Correct the usb phy node in peach-pi

2014-05-29 Thread Arun Kumar K
The vbus-supply property is wrongly updated in the
usbdrd node instead of the usbdrd_phy node. This patch
fixes the same.

Signed-off-by: Arun Kumar K 
---
 arch/arm/boot/dts/exynos5800-peach-pi.dts |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/exynos5800-peach-pi.dts 
b/arch/arm/boot/dts/exynos5800-peach-pi.dts
index e910de3..f3af207 100644
--- a/arch/arm/boot/dts/exynos5800-peach-pi.dts
+++ b/arch/arm/boot/dts/exynos5800-peach-pi.dts
@@ -235,11 +235,11 @@
ddc = <&i2c_2>;
 };
 
-&usbdrd3_0 {
+&usbdrd_phy0 {
vbus-supply = <&usb300_vbus_reg>;
 };
 
-&usbdrd3_1 {
+&usbdrd_phy1 {
vbus-supply = <&usb301_vbus_reg>;
 };
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 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] ARM: dts: Correct the usb phy node in peach-pit

2014-05-29 Thread Arun Kumar K
The vbus-supply property is wrongly updated in the
usbdrd node instead of the usbdrd_phy node. This patch
fixes the same.

Signed-off-by: Arun Kumar K 
---
 arch/arm/boot/dts/exynos5420-peach-pit.dts |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/exynos5420-peach-pit.dts 
b/arch/arm/boot/dts/exynos5420-peach-pit.dts
index 29f64de..1c5b8f9 100644
--- a/arch/arm/boot/dts/exynos5420-peach-pit.dts
+++ b/arch/arm/boot/dts/exynos5420-peach-pit.dts
@@ -231,11 +231,11 @@
ddc = <&i2c_2>;
 };
 
-&usbdrd3_0 {
+&usbdrd_phy0 {
vbus-supply = <&usb300_vbus_reg>;
 };
 
-&usbdrd3_1 {
+&usbdrd_phy1 {
vbus-supply = <&usb301_vbus_reg>;
 };
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 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 1/3] ARM: EXYNOS: Add support for clock handling in power domain

2014-05-29 Thread Arun Kumar K
Hi,

Can we have DT maintainers Ack for this binding change?

Regards
Arun

On Mon, May 26, 2014 at 5:26 PM, Shaik Ameer Basha
 wrote:
> From: Prathyush K 
>
> While powering on/off a local powerdomain in exynos5 chipsets, the input
> clocks to each device gets modified. This behaviour is based on the
> SYSCLK_SYS_PWR_REG registers.
> E.g. SYSCLK_MFC_SYS_PWR_REG = 0x0, the parent of input clock to MFC
>(aclk333) gets modified to oscclk
> = 0x1, no change in clocks.
> The recommended value of SYSCLK_SYS_PWR_REG before power gating any
> domain is 0x0. So we must also restore the clocks while powering on a
> domain everytime.
>
> This patch adds the framework for getting the required mux and parent clocks
> through a power domain device node. With this patch, while powering off
> a domain, parent is set to oscclk and while powering back on, its re-set
> to the correct parent which is as per the recommended pd on/off
> sequence.
>
> Signed-off-by: Prathyush K 
> Signed-off-by: Andrew Bresticker 
> Signed-off-by: Arun Kumar K 
> Signed-off-by: Shaik Ameer Basha 
> ---
>  .../bindings/arm/exynos/power_domain.txt   |   20 +++
>  arch/arm/mach-exynos/pm_domains.c  |   59 
> +++-
>  2 files changed, 78 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/devicetree/bindings/arm/exynos/power_domain.txt 
> b/Documentation/devicetree/bindings/arm/exynos/power_domain.txt
> index 5216b41..8b4f7b7f 100644
> --- a/Documentation/devicetree/bindings/arm/exynos/power_domain.txt
> +++ b/Documentation/devicetree/bindings/arm/exynos/power_domain.txt
> @@ -9,6 +9,18 @@ Required Properties:
>  - reg: physical base address of the controller and length of memory mapped
>  region.
>
> +Optional Properties:
> +- clocks: List of clock handles. The parent clocks of the input clocks to the
> +   devices in this power domain are set to oscclk before power gating
> +   and restored back after powering on a domain. This is required for
> +   all domains which are powered on and off and not required for unused
> +   domains.
> +- clock-names: The following clocks can be specified:
> +   - oscclk: Oscillator clock.
> +   - pclkN, clkN: Pairs of parent of input clock and input clock to the
> +   devices in this power domain. Maximum of 4 pairs (N = 0 to 3)
> +   are supported currently.
> +
>  Node of a device using power domains must have a samsung,power-domain 
> property
>  defined with a phandle to respective power domain.
>
> @@ -19,6 +31,14 @@ Example:
> reg = <0x10023C00 0x10>;
> };
>
> +   mfc_pd: power-domain@10044060 {
> +   compatible = "samsung,exynos4210-pd";
> +   reg = <0x10044060 0x20>;
> +   clocks = <&clock CLK_FIN_PLL>, <&clock CLK_MOUT_SW_ACLK333>,
> +   <&clock CLK_MOUT_USER_ACLK333>;
> +   clock-names = "oscclk", "pclk0", "clk0";
> +   };
> +
>  Example of the node using power domain:
>
> node {
> diff --git a/arch/arm/mach-exynos/pm_domains.c 
> b/arch/arm/mach-exynos/pm_domains.c
> index fe6570e..34d86b1 100644
> --- a/arch/arm/mach-exynos/pm_domains.c
> +++ b/arch/arm/mach-exynos/pm_domains.c
> @@ -17,6 +17,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -24,6 +25,8 @@
>
>  #include "regs-pmu.h"
>
> +#define MAX_CLK_PER_DOMAIN 4
> +
>  /*
>   * Exynos specific wrapper around the generic power domain
>   */
> @@ -32,6 +35,9 @@ struct exynos_pm_domain {
> char const *name;
> bool is_off;
> struct generic_pm_domain pd;
> +   struct clk *oscclk;
> +   struct clk *clk[MAX_CLK_PER_DOMAIN];
> +   struct clk *pclk[MAX_CLK_PER_DOMAIN];
>  };
>
>  static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on)
> @@ -44,6 +50,18 @@ static int exynos_pd_power(struct generic_pm_domain 
> *domain, bool power_on)
> pd = container_of(domain, struct exynos_pm_domain, pd);
> base = pd->base;
>
> +   /* Set oscclk before powering off a domain*/
> +   if (!power_on) {
> +   int i;
> +   for (i = 0; i < MAX_CLK_PER_DOMAIN; i++) {
> +   if (IS_ERR(pd->clk[i]))
> +   break;
> +   if (clk_set_parent(pd->clk[i], pd->oscclk))
> +   pr_err("%s: error setting oscclk as 

[PATCH] ARM: EXYNOS: Add 5800 SoC support

2014-05-23 Thread Arun Kumar K
Exynos5800 is an octa core SoC which is based on the 5420
platform. This patch adds the basic support for it in the
mach-exynos.

Signed-off-by: Arun Kumar K 
---
 arch/arm/mach-exynos/Kconfig   |5 +
 arch/arm/mach-exynos/common.h  |   11 ++-
 arch/arm/mach-exynos/platsmp.c |2 +-
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-exynos/Kconfig b/arch/arm/mach-exynos/Kconfig
index 4663417..c5423da 100644
--- a/arch/arm/mach-exynos/Kconfig
+++ b/arch/arm/mach-exynos/Kconfig
@@ -99,6 +99,11 @@ config SOC_EXYNOS5440
help
  Enable EXYNOS5440 SoC support
 
+config SOC_EXYNOS5800
+   bool "SAMSUNG EXYNOS5800"
+   default y
+   depends on SOC_EXYNOS5420
+
 endmenu
 
 config EXYNOS5420_MCPM
diff --git a/arch/arm/mach-exynos/common.h b/arch/arm/mach-exynos/common.h
index ae5f648..8fbc55b 100644
--- a/arch/arm/mach-exynos/common.h
+++ b/arch/arm/mach-exynos/common.h
@@ -23,6 +23,7 @@
 #define EXYNOS5250_SOC_ID  0x4352
 #define EXYNOS5420_SOC_ID  0xE542
 #define EXYNOS5440_SOC_ID  0xE544
+#define EXYNOS5800_SOC_ID  0xE5422000
 #define EXYNOS5_SOC_MASK   0xF000
 
 extern unsigned long samsung_cpu_id;
@@ -39,6 +40,7 @@ IS_SAMSUNG_CPU(exynos4412, EXYNOS4412_CPU_ID, 
EXYNOS4_CPU_MASK)
 IS_SAMSUNG_CPU(exynos5250, EXYNOS5250_SOC_ID, EXYNOS5_SOC_MASK)
 IS_SAMSUNG_CPU(exynos5420, EXYNOS5420_SOC_ID, EXYNOS5_SOC_MASK)
 IS_SAMSUNG_CPU(exynos5440, EXYNOS5440_SOC_ID, EXYNOS5_SOC_MASK)
+IS_SAMSUNG_CPU(exynos5800, EXYNOS5800_SOC_ID, EXYNOS5_SOC_MASK)
 
 #if defined(CONFIG_CPU_EXYNOS4210)
 # define soc_is_exynos4210()   is_samsung_exynos4210()
@@ -80,9 +82,16 @@ IS_SAMSUNG_CPU(exynos5440, EXYNOS5440_SOC_ID, 
EXYNOS5_SOC_MASK)
 # define soc_is_exynos5440()   0
 #endif
 
+#if defined(CONFIG_SOC_EXYNOS5800)
+# define soc_is_exynos5800()   is_samsung_exynos5800()
+#else
+# define soc_is_exynos5800()   0
+#endif
+
 #define soc_is_exynos4() (soc_is_exynos4210() || soc_is_exynos4212() || \
  soc_is_exynos4412())
-#define soc_is_exynos5() (soc_is_exynos5250() || soc_is_exynos5420())
+#define soc_is_exynos5() (soc_is_exynos5250() || soc_is_exynos5420() || \
+ soc_is_exynos5800())
 
 void mct_init(void __iomem *base, int irq_g0, int irq_l0, int irq_l1);
 
diff --git a/arch/arm/mach-exynos/platsmp.c b/arch/arm/mach-exynos/platsmp.c
index 9c16da2..112bc66 100644
--- a/arch/arm/mach-exynos/platsmp.c
+++ b/arch/arm/mach-exynos/platsmp.c
@@ -70,7 +70,7 @@ static inline void __iomem *cpu_boot_reg(int cpu)
return ERR_PTR(-ENODEV);
if (soc_is_exynos4412())
boot_reg += 4*cpu;
-   else if (soc_is_exynos5420())
+   else if (soc_is_exynos5420() || soc_is_exynos5800())
boot_reg += 4;
return boot_reg;
 }
-- 
1.7.9.5

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


[PATCH 3/3] ARM: dts: Add clock property for mfc_pd in 5420

2014-05-22 Thread Arun Kumar K
Adding the optional clock property for the mfc_pd for
handling the re-parenting while pd on/off.

Signed-off-by: Arun Kumar K 
---
Corrected a typo error. Sorry for the noise.
---
 arch/arm/boot/dts/exynos5420.dtsi |3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/boot/dts/exynos5420.dtsi 
b/arch/arm/boot/dts/exynos5420.dtsi
index 5a85896..d1170db 100644
--- a/arch/arm/boot/dts/exynos5420.dtsi
+++ b/arch/arm/boot/dts/exynos5420.dtsi
@@ -260,6 +260,9 @@
mfc_pd: power-domain@10044060 {
compatible = "samsung,exynos4210-pd";
reg = <0x10044060 0x20>;
+   clocks = <&clock CLK_FIN_PLL>, <&clock CLK_MOUT_SW_ACLK333>,
+   <&clock CLK_MOUT_USER_ACLK333>;
+   clock-names = "oscclk", "pclk0", "clk0";
};
 
disp_pd: power-domain@100440C0 {
-- 
1.7.9.5

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


[PATCH 1/3] ARM: EXYNOS: Add support for clock handling in power domain

2014-05-22 Thread Arun Kumar K
From: Prathyush K 

While powering on/off a local powerdomain in exynos5 chipsets, the input
clocks to each device gets modified. This behaviour is based on the
SYSCLK_SYS_PWR_REG registers.
E.g. SYSCLK_MFC_SYS_PWR_REG = 0x0, the parent of input clock to MFC
   (aclk333) gets modified to oscclk
= 0x1, no change in clocks.
The recommended value of SYSCLK_SYS_PWR_REG before power gating any
domain is 0x0. So we must also restore the clocks while powering on a
domain everytime.

This patch adds the framework for getting the required mux and parent clocks
through a power domain device node. With this patch, while powering off
a domain, parent is set to oscclk and while powering back on, its re-set
to the correct parent which is as per the recommended pd on/off
sequence.

Signed-off-by: Prathyush K 
Signed-off-by: Andrew Bresticker 
Signed-off-by: Arun Kumar K 
---
 .../bindings/arm/exynos/power_domain.txt   |   18 +++
 arch/arm/mach-exynos/pm_domains.c  |   56 +++-
 2 files changed, 73 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/arm/exynos/power_domain.txt 
b/Documentation/devicetree/bindings/arm/exynos/power_domain.txt
index 5216b41..168a191 100644
--- a/Documentation/devicetree/bindings/arm/exynos/power_domain.txt
+++ b/Documentation/devicetree/bindings/arm/exynos/power_domain.txt
@@ -9,6 +9,16 @@ Required Properties:
 - reg: physical base address of the controller and length of memory mapped
 region.
 
+Optional Properties:
+- clocks: List of clock handles. The parent clocks of the input clocks to the
+  devices in this power domain are set to oscclk before power gating and
+  restored back after powering on a domain. This is required for all domains
+  which are powered on and off and not required for unused domains.
+  The following clocks can be specified:
+  - oscclk: oscillator clock.
+  - clk(n): input clock to the devices in this power domain
+  - pclk(n): parent clock of input clock to the devices in this power domain
+
 Node of a device using power domains must have a samsung,power-domain property
 defined with a phandle to respective power domain.
 
@@ -19,6 +29,14 @@ Example:
reg = <0x10023C00 0x10>;
};
 
+   mfc_pd: power-domain@10044060 {
+   compatible = "samsung,exynos4210-pd";
+   reg = <0x10044060 0x20>;
+   clocks = <&clock CLK_FIN_PLL>, <&clock CLK_MOUT_SW_ACLK333>,
+   <&clock CLK_MOUT_USER_ACLK333>;
+   clock-names = "oscclk", "pclk0", "clk0";
+   };
+
 Example of the node using power domain:
 
node {
diff --git a/arch/arm/mach-exynos/pm_domains.c 
b/arch/arm/mach-exynos/pm_domains.c
index fe6570e..e5fe76d 100644
--- a/arch/arm/mach-exynos/pm_domains.c
+++ b/arch/arm/mach-exynos/pm_domains.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -24,6 +25,8 @@
 
 #include "regs-pmu.h"
 
+#define MAX_CLK_PER_DOMAIN 4
+
 /*
  * Exynos specific wrapper around the generic power domain
  */
@@ -32,6 +35,9 @@ struct exynos_pm_domain {
char const *name;
bool is_off;
struct generic_pm_domain pd;
+   struct clk *oscclk;
+   struct clk *clk[MAX_CLK_PER_DOMAIN];
+   struct clk *pclk[MAX_CLK_PER_DOMAIN];
 };
 
 static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on)
@@ -44,6 +50,18 @@ static int exynos_pd_power(struct generic_pm_domain *domain, 
bool power_on)
pd = container_of(domain, struct exynos_pm_domain, pd);
base = pd->base;
 
+   /* Set oscclk before powering off a domain*/
+   if (!power_on) {
+   int i;
+   for (i = 0; i < MAX_CLK_PER_DOMAIN; i++) {
+   if (!pd->clk[i])
+   break;
+   if (clk_set_parent(pd->clk[i], pd->oscclk))
+   pr_info("%s: error setting oscclk as parent to 
clock %d\n",
+   pd->name, i);
+   }
+   }
+
pwr = power_on ? S5P_INT_LOCAL_PWR_EN : 0;
__raw_writel(pwr, base);
 
@@ -60,6 +78,19 @@ static int exynos_pd_power(struct generic_pm_domain *domain, 
bool power_on)
cpu_relax();
usleep_range(80, 100);
}
+
+   /* Restore clocks after powering on a domain*/
+   if (power_on) {
+   int i;
+   for (i = 0; i < MAX_CLK_PER_DOMAIN; i++) {
+   if (!pd->clk[i])
+   break;
+   if (clk_set_parent(pd->clk[i], pd->pclk[i]))
+   pr_info("%s: error setting parent to clock%d\n",
+  

[PATCH 2/3] clk: exynos5420: Add IDs for clocks used in PD mfc

2014-05-22 Thread Arun Kumar K
Adds IDs for MUX clocks to be used by power domain for MFC
for doing re-parenting while pd on/off.

Signed-off-by: Arun Kumar K 
---
 drivers/clk/samsung/clk-exynos5420.c   |6 --
 include/dt-bindings/clock/exynos5420.h |2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/samsung/clk-exynos5420.c 
b/drivers/clk/samsung/clk-exynos5420.c
index 9d7d7ee..c899dbe 100644
--- a/drivers/clk/samsung/clk-exynos5420.c
+++ b/drivers/clk/samsung/clk-exynos5420.c
@@ -631,7 +631,8 @@ static struct samsung_mux_clock exynos5x_mux_clks[] 
__initdata = {
SRC_TOP4, 16, 1),
MUX(0, "mout_user_aclk266", mout_user_aclk266_p, SRC_TOP4, 20, 1),
MUX(0, "mout_user_aclk166", mout_user_aclk166_p, SRC_TOP4, 24, 1),
-   MUX(0, "mout_user_aclk333", mout_user_aclk333_p, SRC_TOP4, 28, 1),
+   MUX(CLK_MOUT_USER_ACLK333, "mout_user_aclk333", mout_user_aclk333_p,
+   SRC_TOP4, 28, 1),
 
MUX(0, "mout_user_aclk400_disp1", mout_user_aclk400_disp1_p,
SRC_TOP5, 0, 1),
@@ -684,7 +685,8 @@ static struct samsung_mux_clock exynos5x_mux_clks[] 
__initdata = {
SRC_TOP11, 12, 1),
MUX(0, "mout_sw_aclk266", mout_sw_aclk266_p, SRC_TOP11, 20, 1),
MUX(0, "mout_sw_aclk166", mout_sw_aclk166_p, SRC_TOP11, 24, 1),
-   MUX(0, "mout_sw_aclk333", mout_sw_aclk333_p, SRC_TOP11, 28, 1),
+   MUX(CLK_MOUT_SW_ACLK333, "mout_sw_aclk333", mout_sw_aclk333_p,
+   SRC_TOP11, 28, 1),
 
MUX(0, "mout_sw_aclk400_disp1", mout_sw_aclk400_disp1_p,
SRC_TOP12, 4, 1),
diff --git a/include/dt-bindings/clock/exynos5420.h 
b/include/dt-bindings/clock/exynos5420.h
index 97dcb89..3fc08ff 100644
--- a/include/dt-bindings/clock/exynos5420.h
+++ b/include/dt-bindings/clock/exynos5420.h
@@ -203,6 +203,8 @@
 #define CLK_MOUT_G3D   641
 #define CLK_MOUT_VPLL  642
 #define CLK_MOUT_MAUDIO0   643
+#define CLK_MOUT_USER_ACLK333  644
+#define CLK_MOUT_SW_ACLK333645
 
 /* divider clocks */
 #define CLK_DOUT_PIXEL 768
-- 
1.7.9.5

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


[PATCH 0/3] Power-domain clk handling

2014-05-22 Thread Arun Kumar K
This patchset enables the clk handling in power domain for
working as per the recommended power domain on / off sequence for
exynos5 SoCs. I have posted an RFC for the same [1] and didnt get any
review comments / objections. So I am dropping the RFC tag and
posting the patch along with the required clk and dt support.

[1] https://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg30479.html

Arun Kumar K (2):
  clk: exynos5420: Add IDs for clocks used in PD mfc
  ARM: dts: Add clock property for mfc_pd in 5420

Prathyush K (1):
  ARM: EXYNOS: Add support for clock handling in power domain

 .../bindings/arm/exynos/power_domain.txt   |   18 +++
 arch/arm/boot/dts/exynos5420.dtsi  |3 ++
 arch/arm/mach-exynos/pm_domains.c  |   56 +++-
 drivers/clk/samsung/clk-exynos5420.c   |6 ++-
 include/dt-bindings/clock/exynos5420.h |2 +
 5 files changed, 82 insertions(+), 3 deletions(-)

-- 
1.7.9.5

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


[PATCH 3/3] ARM: dts: Add clock property for mfc_pd in 5420

2014-05-22 Thread Arun Kumar K
Adding the optional clock property for the mfc_pd for
handling the re-parenting while pd on/off.

Signed-off-by: Arun Kumar K 
---
 arch/arm/boot/dts/exynos5420.dtsi |3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/boot/dts/exynos5420.dtsi 
b/arch/arm/boot/dts/exynos5420.dtsi
index 5a85896..890bdac 100644
--- a/arch/arm/boot/dts/exynos5420.dtsi
+++ b/arch/arm/boot/dts/exynos5420.dtsi
@@ -260,6 +260,9 @@
mfc_pd: power-domain@10044060 {
compatible = "samsung,exynos4210-pd";
reg = <0x10044060 0x20>;
+   clocks = <&clock CLK_FIN_PLL>, <&clock CLK_MOUT_SW_ACLK333>,
+   <&clock CLK_MOUT_USER_ACLK333>,;
+   clock-names = "oscclk", "pclk0", "clk0";
};
 
disp_pd: power-domain@100440C0 {
-- 
1.7.9.5

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


[PATCH v2 1/3] [media] s5p-mfc: Remove duplicate function s5p_mfc_reload_firmware

2014-05-21 Thread Arun Kumar K
The function s5p_mfc_reload_firmware is exactly same as
s5p_mfc_load_firmware. So removing the duplicate function.

Signed-off-by: Arun Kumar K 
Reviewed-by: Tomasz Figa 
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c  |2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c |   33 -
 2 files changed, 1 insertion(+), 34 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 9ed0985..8da4c23 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -162,7 +162,7 @@ static void s5p_mfc_watchdog_worker(struct work_struct 
*work)
/* Double check if there is at least one instance running.
 * If no instance is in memory than no firmware should be present */
if (dev->num_inst > 0) {
-   ret = s5p_mfc_reload_firmware(dev);
+   ret = s5p_mfc_load_firmware(dev);
if (ret) {
mfc_err("Failed to reload FW\n");
goto unlock;
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
index 6c3f8f7..c97c7c8 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
@@ -107,39 +107,6 @@ int s5p_mfc_load_firmware(struct s5p_mfc_dev *dev)
return 0;
 }
 
-/* Reload firmware to MFC */
-int s5p_mfc_reload_firmware(struct s5p_mfc_dev *dev)
-{
-   struct firmware *fw_blob;
-   int err;
-
-   /* Firmare has to be present as a separate file or compiled
-* into kernel. */
-   mfc_debug_enter();
-
-   err = request_firmware((const struct firmware **)&fw_blob,
-dev->variant->fw_name, dev->v4l2_dev.dev);
-   if (err != 0) {
-   mfc_err("Firmware is not present in the /lib/firmware directory 
nor compiled in kernel\n");
-   return -EINVAL;
-   }
-   if (fw_blob->size > dev->fw_size) {
-   mfc_err("MFC firmware is too big to be loaded\n");
-   release_firmware(fw_blob);
-   return -ENOMEM;
-   }
-   if (!dev->fw_virt_addr) {
-   mfc_err("MFC firmware is not allocated\n");
-   release_firmware(fw_blob);
-   return -EINVAL;
-   }
-   memcpy(dev->fw_virt_addr, fw_blob->data, fw_blob->size);
-   wmb();
-   release_firmware(fw_blob);
-   mfc_debug_leave();
-   return 0;
-}
-
 /* Release firmware memory */
 int s5p_mfc_release_firmware(struct s5p_mfc_dev *dev)
 {
-- 
1.7.9.5

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


[PATCH v2 3/3] [media] s5p-mfc: Add init buffer cmd to MFCV6

2014-05-21 Thread Arun Kumar K
Latest MFC v6 firmware requires tile mode and loop filter
setting to be done as part of Init buffer command, in sync
with v7. This patch adds this support for new v6 firmware.

Signed-off-by: Arun Kumar K 
Signed-off-by: Kiran AVND 
Reviewed-by: Tomasz Figa 
---
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
index 4f5e0ea..c1c12f8 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
@@ -48,6 +48,8 @@
 #define WRITEL(data, reg) \
(WARN_ON_ONCE(!(reg)) ? 0 : writel((data), (reg)))
 
+#define IS_MFCV6_V2(dev) (!IS_MFCV7_PLUS(dev) && dev->fw_ver == MFC_FW_V2)
+
 /* Allocate temporary buffers for decoding */
 static int s5p_mfc_alloc_dec_temp_buffers_v6(struct s5p_mfc_ctx *ctx)
 {
@@ -1352,7 +1354,7 @@ static int s5p_mfc_init_decode_v6(struct s5p_mfc_ctx *ctx)
WRITEL(ctx->display_delay, mfc_regs->d_display_delay);
}
 
-   if (IS_MFCV7_PLUS(dev)) {
+   if (IS_MFCV7_PLUS(dev) || IS_MFCV6_V2(dev)) {
WRITEL(reg, mfc_regs->d_dec_options);
reg = 0;
}
@@ -1367,7 +1369,7 @@ static int s5p_mfc_init_decode_v6(struct s5p_mfc_ctx *ctx)
if (ctx->dst_fmt->fourcc == V4L2_PIX_FMT_NV12MT_16X16)
reg |= (0x1 << S5P_FIMV_D_OPT_TILE_MODE_SHIFT_V6);
 
-   if (IS_MFCV7_PLUS(dev))
+   if (IS_MFCV7_PLUS(dev) || IS_MFCV6_V2(dev))
WRITEL(reg, mfc_regs->d_init_buffer_options);
else
WRITEL(reg, mfc_regs->d_dec_options);
-- 
1.7.9.5

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


[PATCH v2 2/3] [media] s5p-mfc: Support multiple firmware sub-versions

2014-05-21 Thread Arun Kumar K
For MFC firmwares, improved versions with bug fixes and
feature additions are released keeping the firmware version
including major and minor number same. The issue came with
the release of a new MFCv6 firmware with an interface change.
This patch adds the support of accepting multiple firmware
binaries for every version with the driver trying to load
firmwares starting from latest. This ensures full backward
compatibility regardless of which firmware version and kernel
version is used.

Signed-off-by: Arun Kumar K 
Reviewed-by: Tomasz Figa 
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c|   13 +
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h |   11 ++-
 drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c   |   15 ---
 3 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 8da4c23..7092b84 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -1343,7 +1343,7 @@ static struct s5p_mfc_variant mfc_drvdata_v5 = {
.port_num   = MFC_NUM_PORTS,
.buf_size   = &buf_size_v5,
.buf_align  = &mfc_buf_align_v5,
-   .fw_name= "s5p-mfc.fw",
+   .fw_name[0] = "s5p-mfc.fw",
 };
 
 struct s5p_mfc_buf_size_v6 mfc_buf_size_v6 = {
@@ -1370,7 +1370,12 @@ static struct s5p_mfc_variant mfc_drvdata_v6 = {
.port_num   = MFC_NUM_PORTS_V6,
.buf_size   = &buf_size_v6,
.buf_align  = &mfc_buf_align_v6,
-   .fw_name= "s5p-mfc-v6.fw",
+   .fw_name[0] = "s5p-mfc-v6.fw",
+   /*
+* v6-v2 firmware contains bug fixes and interface change
+* for init buffer command
+*/
+   .fw_name[1] = "s5p-mfc-v6-v2.fw",
 };
 
 struct s5p_mfc_buf_size_v6 mfc_buf_size_v7 = {
@@ -1397,7 +1402,7 @@ static struct s5p_mfc_variant mfc_drvdata_v7 = {
.port_num   = MFC_NUM_PORTS_V7,
.buf_size   = &buf_size_v7,
.buf_align  = &mfc_buf_align_v7,
-   .fw_name= "s5p-mfc-v7.fw",
+   .fw_name[0] = "s5p-mfc-v7.fw",
 };
 
 struct s5p_mfc_buf_size_v6 mfc_buf_size_v8 = {
@@ -1424,7 +1429,7 @@ static struct s5p_mfc_variant mfc_drvdata_v8 = {
.port_num   = MFC_NUM_PORTS_V8,
.buf_size   = &buf_size_v8,
.buf_align  = &mfc_buf_align_v8,
-   .fw_name= "s5p-mfc-v8.fw",
+   .fw_name[0] = "s5p-mfc-v8.fw",
 };
 
 static struct platform_device_id mfc_driver_ids[] = {
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h 
b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index 89681c3..de60185 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -38,6 +38,8 @@
 #define MFC_BANK2_ALIGN_ORDER  13
 #define MFC_BASE_ALIGN_ORDER   17
 
+#define MFC_FW_MAX_VERSIONS2
+
 #include 
 
 static inline dma_addr_t s5p_mfc_mem_cookie(void *a, void *b)
@@ -163,6 +165,11 @@ enum s5p_mfc_decode_arg {
MFC_DEC_RES_CHANGE,
 };
 
+enum s5p_mfc_fw_ver {
+   MFC_FW_V1,
+   MFC_FW_V2,
+};
+
 #define MFC_BUF_FLAG_USED  (1 << 0)
 #define MFC_BUF_FLAG_EOS   (1 << 1)
 
@@ -225,7 +232,7 @@ struct s5p_mfc_variant {
u32 version_bit;
struct s5p_mfc_buf_size *buf_size;
struct s5p_mfc_buf_align *buf_align;
-   char*fw_name;
+   char*fw_name[MFC_FW_MAX_VERSIONS];
 };
 
 /**
@@ -287,6 +294,7 @@ struct s5p_mfc_priv_buf {
  * @warn_start:hardware error code from which warnings start
  * @mfc_ops:   ops structure holding HW operation function pointers
  * @mfc_cmds:  cmd structure holding HW commands function pointers
+ * @fw_ver:loaded firmware sub-version
  *
  */
 struct s5p_mfc_dev {
@@ -331,6 +339,7 @@ struct s5p_mfc_dev {
struct s5p_mfc_hw_ops *mfc_ops;
struct s5p_mfc_hw_cmds *mfc_cmds;
const struct s5p_mfc_regs *mfc_regs;
+   enum s5p_mfc_fw_ver fw_ver;
 };
 
 /**
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
index c97c7c8..452ad02 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
@@ -78,14 +78,23 @@ int s5p_mfc_alloc_firmware(struct s5p_mfc_dev *dev)
 int s5p_mfc_load_firmware(struct s5p_mfc_dev *dev)
 {
struct firmware *fw_blob;
-   int err;
+   int i, err = -EINVAL;
 
/* Firmare has to be present as a separate file or compiled
 * into kernel. */
mfc_debug_enter();
 
-   err = request_firmware((const struct firmware **)&fw_blob,
-dev->variant->fw_name, dev->v4l2_dev.dev);
+   for (i = MFC_FW_MAX_VERSIONS - 1; i >= 0;

[PATCH v2 0/3] Support for multiple MFC FW sub-versions

2014-05-21 Thread Arun Kumar K
This patchset is for supporting multple firmware sub-versions
for MFC. Newer firmwares come with changed interfaces and fixes
without any change in the fw version number.
So this implementation is as per Tomasz Figa's suggestion [1].
[1] http://permalink.gmane.org/gmane.linux.kernel.samsung-soc/31735

Changes from v1
- Addressed nits pointed by Sachin on PATCH 2/3

Arun Kumar K (3):
  [media] s5p-mfc: Remove duplicate function s5p_mfc_reload_firmware
  [media] s5p-mfc: Support multiple firmware sub-versions
  [media] s5p-mfc: Add init buffer cmd to MFCV6

 drivers/media/platform/s5p-mfc/s5p_mfc.c|   15 +---
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h |   11 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c   |   44 ++-
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c |6 ++--
 4 files changed, 34 insertions(+), 42 deletions(-)

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 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/3] [media] s5p-mfc: Support multiple firmware sub-versions

2014-05-21 Thread Arun Kumar K
Hi Sachin,

On Tue, May 20, 2014 at 5:15 PM, Sachin Kamat  wrote:
> Hi Arun,
>
> On 20 May 2014 15:47, Arun Kumar K  wrote:
>> For MFC firmwares, improved versions with bug fixes and
>> feature additions are released keeping the firmware version
>> including major and minor number same. The issue came with
>> the release of a new MFCv6 firmware with an interface change.
>> This patch adds the support of accepting multiple firmware
>> binaries for every version with the driver trying to load
>> firmwares starting from latest. This ensures full backward
>> compatibility regardless of which firmware version and kernel
>> version is used.
>>
>> Signed-off-by: Arun Kumar K 
>> ---
>>  drivers/media/platform/s5p-mfc/s5p_mfc.c|9 +
>>  drivers/media/platform/s5p-mfc/s5p_mfc_common.h |   11 ++-
>>  drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c   |   15 ---
>>  3 files changed, 27 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
>> b/drivers/media/platform/s5p-mfc/s5p_mfc.c
>> index 8da4c23..514e7ec 100644
>> --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
>> +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
>> @@ -1343,7 +1343,7 @@ static struct s5p_mfc_variant mfc_drvdata_v5 = {
>> .port_num   = MFC_NUM_PORTS,
>> .buf_size   = &buf_size_v5,
>> .buf_align  = &mfc_buf_align_v5,
>> -   .fw_name= "s5p-mfc.fw",
>> +   .fw_name[0] = "s5p-mfc.fw",
>>  };
>>
>>  struct s5p_mfc_buf_size_v6 mfc_buf_size_v6 = {
>> @@ -1370,7 +1370,8 @@ static struct s5p_mfc_variant mfc_drvdata_v6 = {
>> .port_num   = MFC_NUM_PORTS_V6,
>> .buf_size   = &buf_size_v6,
>> .buf_align  = &mfc_buf_align_v6,
>> -   .fw_name= "s5p-mfc-v6.fw",
>> +   .fw_name[0] = "s5p-mfc-v6.fw",
>> +   .fw_name[1] = "s5p-mfc-v6-v2.fw",
>
> Probably a simple 1 line comment about the difference between the
> versions would help.
>

Ok will add.

>>  };
>>
>>  struct s5p_mfc_buf_size_v6 mfc_buf_size_v7 = {
>> @@ -1397,7 +1398,7 @@ static struct s5p_mfc_variant mfc_drvdata_v7 = {
>> .port_num   = MFC_NUM_PORTS_V7,
>> .buf_size   = &buf_size_v7,
>> .buf_align  = &mfc_buf_align_v7,
>> -   .fw_name= "s5p-mfc-v7.fw",
>> +   .fw_name[0] = "s5p-mfc-v7.fw",
>>  };
>>
>>  struct s5p_mfc_buf_size_v6 mfc_buf_size_v8 = {
>> @@ -1424,7 +1425,7 @@ static struct s5p_mfc_variant mfc_drvdata_v8 = {
>> .port_num   = MFC_NUM_PORTS_V8,
>> .buf_size   = &buf_size_v8,
>> .buf_align  = &mfc_buf_align_v8,
>> -   .fw_name= "s5p-mfc-v8.fw",
>> +   .fw_name[0] = "s5p-mfc-v8.fw",
>>  };
>>
>>  static struct platform_device_id mfc_driver_ids[] = {
>> diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h 
>> b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
>> index 89681c3..de60185 100644
>> --- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
>> +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
>> @@ -38,6 +38,8 @@
>>  #define MFC_BANK2_ALIGN_ORDER  13
>>  #define MFC_BASE_ALIGN_ORDER   17
>>
>> +#define MFC_FW_MAX_VERSIONS2
>> +
>>  #include 
>>
>>  static inline dma_addr_t s5p_mfc_mem_cookie(void *a, void *b)
>> @@ -163,6 +165,11 @@ enum s5p_mfc_decode_arg {
>> MFC_DEC_RES_CHANGE,
>>  };
>>
>> +enum s5p_mfc_fw_ver {
>> +   MFC_FW_V1,
>> +   MFC_FW_V2,
>> +};
>> +
>>  #define MFC_BUF_FLAG_USED  (1 << 0)
>>  #define MFC_BUF_FLAG_EOS   (1 << 1)
>>
>> @@ -225,7 +232,7 @@ struct s5p_mfc_variant {
>> u32 version_bit;
>> struct s5p_mfc_buf_size *buf_size;
>> struct s5p_mfc_buf_align *buf_align;
>> -   char*fw_name;
>> +   char*fw_name[MFC_FW_MAX_VERSIONS];
>>  };
>>
>>  /**
>> @@ -287,6 +294,7 @@ struct s5p_mfc_priv_buf {
>>   * @warn_start:hardware error code from which warnings start
>>   * @mfc_ops:   ops structure holding HW operation function pointers
>>   * @mfc_cmds:  cmd structure holding HW commands function pointers
>> + * @fw_ver:loaded firmware sub-version
>>   *
>>   */
>>  struct s5p_mfc_dev {
>> @@ -3

[PATCH 2/3] [media] s5p-mfc: Support multiple firmware sub-versions

2014-05-20 Thread Arun Kumar K
For MFC firmwares, improved versions with bug fixes and
feature additions are released keeping the firmware version
including major and minor number same. The issue came with
the release of a new MFCv6 firmware with an interface change.
This patch adds the support of accepting multiple firmware
binaries for every version with the driver trying to load
firmwares starting from latest. This ensures full backward
compatibility regardless of which firmware version and kernel
version is used.

Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c|9 +
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h |   11 ++-
 drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c   |   15 ---
 3 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 8da4c23..514e7ec 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -1343,7 +1343,7 @@ static struct s5p_mfc_variant mfc_drvdata_v5 = {
.port_num   = MFC_NUM_PORTS,
.buf_size   = &buf_size_v5,
.buf_align  = &mfc_buf_align_v5,
-   .fw_name= "s5p-mfc.fw",
+   .fw_name[0] = "s5p-mfc.fw",
 };
 
 struct s5p_mfc_buf_size_v6 mfc_buf_size_v6 = {
@@ -1370,7 +1370,8 @@ static struct s5p_mfc_variant mfc_drvdata_v6 = {
.port_num   = MFC_NUM_PORTS_V6,
.buf_size   = &buf_size_v6,
.buf_align  = &mfc_buf_align_v6,
-   .fw_name= "s5p-mfc-v6.fw",
+   .fw_name[0] = "s5p-mfc-v6.fw",
+   .fw_name[1] = "s5p-mfc-v6-v2.fw",
 };
 
 struct s5p_mfc_buf_size_v6 mfc_buf_size_v7 = {
@@ -1397,7 +1398,7 @@ static struct s5p_mfc_variant mfc_drvdata_v7 = {
.port_num   = MFC_NUM_PORTS_V7,
.buf_size   = &buf_size_v7,
.buf_align  = &mfc_buf_align_v7,
-   .fw_name= "s5p-mfc-v7.fw",
+   .fw_name[0] = "s5p-mfc-v7.fw",
 };
 
 struct s5p_mfc_buf_size_v6 mfc_buf_size_v8 = {
@@ -1424,7 +1425,7 @@ static struct s5p_mfc_variant mfc_drvdata_v8 = {
.port_num   = MFC_NUM_PORTS_V8,
.buf_size   = &buf_size_v8,
.buf_align  = &mfc_buf_align_v8,
-   .fw_name= "s5p-mfc-v8.fw",
+   .fw_name[0] = "s5p-mfc-v8.fw",
 };
 
 static struct platform_device_id mfc_driver_ids[] = {
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h 
b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index 89681c3..de60185 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -38,6 +38,8 @@
 #define MFC_BANK2_ALIGN_ORDER  13
 #define MFC_BASE_ALIGN_ORDER   17
 
+#define MFC_FW_MAX_VERSIONS2
+
 #include 
 
 static inline dma_addr_t s5p_mfc_mem_cookie(void *a, void *b)
@@ -163,6 +165,11 @@ enum s5p_mfc_decode_arg {
MFC_DEC_RES_CHANGE,
 };
 
+enum s5p_mfc_fw_ver {
+   MFC_FW_V1,
+   MFC_FW_V2,
+};
+
 #define MFC_BUF_FLAG_USED  (1 << 0)
 #define MFC_BUF_FLAG_EOS   (1 << 1)
 
@@ -225,7 +232,7 @@ struct s5p_mfc_variant {
u32 version_bit;
struct s5p_mfc_buf_size *buf_size;
struct s5p_mfc_buf_align *buf_align;
-   char*fw_name;
+   char*fw_name[MFC_FW_MAX_VERSIONS];
 };
 
 /**
@@ -287,6 +294,7 @@ struct s5p_mfc_priv_buf {
  * @warn_start:hardware error code from which warnings start
  * @mfc_ops:   ops structure holding HW operation function pointers
  * @mfc_cmds:  cmd structure holding HW commands function pointers
+ * @fw_ver:loaded firmware sub-version
  *
  */
 struct s5p_mfc_dev {
@@ -331,6 +339,7 @@ struct s5p_mfc_dev {
struct s5p_mfc_hw_ops *mfc_ops;
struct s5p_mfc_hw_cmds *mfc_cmds;
const struct s5p_mfc_regs *mfc_regs;
+   enum s5p_mfc_fw_ver fw_ver;
 };
 
 /**
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
index c97c7c8..7aabcdb 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
@@ -78,14 +78,23 @@ int s5p_mfc_alloc_firmware(struct s5p_mfc_dev *dev)
 int s5p_mfc_load_firmware(struct s5p_mfc_dev *dev)
 {
struct firmware *fw_blob;
-   int err;
+   int err = -EINVAL, i;
 
/* Firmare has to be present as a separate file or compiled
 * into kernel. */
mfc_debug_enter();
 
-   err = request_firmware((const struct firmware **)&fw_blob,
-dev->variant->fw_name, dev->v4l2_dev.dev);
+   for (i = MFC_FW_MAX_VERSIONS - 1; i >= 0; i--) {
+   if (!dev->variant->fw_name[i])
+   continue;
+   err = request_firmware((const struct firmware **)&am

[PATCH 3/3] [media] s5p-mfc: Add init buffer cmd to MFCV6

2014-05-20 Thread Arun Kumar K
Latest MFC v6 firmware requires tile mode and loop filter
setting to be done as part of Init buffer command, in sync
with v7. This patch adds this support for new v6 firmware.

Signed-off-by: Arun Kumar K 
Signed-off-by: Kiran AVND 
---
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
index 4f5e0ea..c1c12f8 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
@@ -48,6 +48,8 @@
 #define WRITEL(data, reg) \
(WARN_ON_ONCE(!(reg)) ? 0 : writel((data), (reg)))
 
+#define IS_MFCV6_V2(dev) (!IS_MFCV7_PLUS(dev) && dev->fw_ver == MFC_FW_V2)
+
 /* Allocate temporary buffers for decoding */
 static int s5p_mfc_alloc_dec_temp_buffers_v6(struct s5p_mfc_ctx *ctx)
 {
@@ -1352,7 +1354,7 @@ static int s5p_mfc_init_decode_v6(struct s5p_mfc_ctx *ctx)
WRITEL(ctx->display_delay, mfc_regs->d_display_delay);
}
 
-   if (IS_MFCV7_PLUS(dev)) {
+   if (IS_MFCV7_PLUS(dev) || IS_MFCV6_V2(dev)) {
WRITEL(reg, mfc_regs->d_dec_options);
reg = 0;
}
@@ -1367,7 +1369,7 @@ static int s5p_mfc_init_decode_v6(struct s5p_mfc_ctx *ctx)
if (ctx->dst_fmt->fourcc == V4L2_PIX_FMT_NV12MT_16X16)
reg |= (0x1 << S5P_FIMV_D_OPT_TILE_MODE_SHIFT_V6);
 
-   if (IS_MFCV7_PLUS(dev))
+   if (IS_MFCV7_PLUS(dev) || IS_MFCV6_V2(dev))
WRITEL(reg, mfc_regs->d_init_buffer_options);
else
WRITEL(reg, mfc_regs->d_dec_options);
-- 
1.7.9.5

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


[PATCH 1/3] [media] s5p-mfc: Remove duplicate function s5p_mfc_reload_firmware

2014-05-20 Thread Arun Kumar K
The function s5p_mfc_reload_firmware is exactly same as
s5p_mfc_load_firmware. So removing the duplicate function.

Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c  |2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c |   33 -
 2 files changed, 1 insertion(+), 34 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 9ed0985..8da4c23 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -162,7 +162,7 @@ static void s5p_mfc_watchdog_worker(struct work_struct 
*work)
/* Double check if there is at least one instance running.
 * If no instance is in memory than no firmware should be present */
if (dev->num_inst > 0) {
-   ret = s5p_mfc_reload_firmware(dev);
+   ret = s5p_mfc_load_firmware(dev);
if (ret) {
mfc_err("Failed to reload FW\n");
goto unlock;
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
index 6c3f8f7..c97c7c8 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
@@ -107,39 +107,6 @@ int s5p_mfc_load_firmware(struct s5p_mfc_dev *dev)
return 0;
 }
 
-/* Reload firmware to MFC */
-int s5p_mfc_reload_firmware(struct s5p_mfc_dev *dev)
-{
-   struct firmware *fw_blob;
-   int err;
-
-   /* Firmare has to be present as a separate file or compiled
-* into kernel. */
-   mfc_debug_enter();
-
-   err = request_firmware((const struct firmware **)&fw_blob,
-dev->variant->fw_name, dev->v4l2_dev.dev);
-   if (err != 0) {
-   mfc_err("Firmware is not present in the /lib/firmware directory 
nor compiled in kernel\n");
-   return -EINVAL;
-   }
-   if (fw_blob->size > dev->fw_size) {
-   mfc_err("MFC firmware is too big to be loaded\n");
-   release_firmware(fw_blob);
-   return -ENOMEM;
-   }
-   if (!dev->fw_virt_addr) {
-   mfc_err("MFC firmware is not allocated\n");
-   release_firmware(fw_blob);
-   return -EINVAL;
-   }
-   memcpy(dev->fw_virt_addr, fw_blob->data, fw_blob->size);
-   wmb();
-   release_firmware(fw_blob);
-   mfc_debug_leave();
-   return 0;
-}
-
 /* Release firmware memory */
 int s5p_mfc_release_firmware(struct s5p_mfc_dev *dev)
 {
-- 
1.7.9.5

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


[PATCH 0/3] Support for multiple MFC FW sub-versions

2014-05-20 Thread Arun Kumar K
This patchset is for supporting multple firmware sub-versions
for MFC. Newer firmwares come with changed interfaces and fixes
without any change in the fw version number.
So this implementation is as per Tomasz Figa's suggestion [1].
[1] http://permalink.gmane.org/gmane.linux.kernel.samsung-soc/31735

Arun Kumar K (3):
  [media] s5p-mfc: Remove duplicate function s5p_mfc_reload_firmware
  [media] s5p-mfc: Support multiple firmware sub-versions
  [media] s5p-mfc: Add init buffer cmd to MFCV6

 drivers/media/platform/s5p-mfc/s5p_mfc.c|   11 +++---
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h |   11 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c   |   44 ++-
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c |6 ++--
 4 files changed, 30 insertions(+), 42 deletions(-)

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 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] [media] s5p-mfc: Dequeue sequence header after STREAMON

2014-05-19 Thread Arun Kumar K
Hi Kamil,

On 05/15/14 20:47, Kamil Debski wrote:
> Hi Arun,
> 
>> From: linux-media-ow...@vger.kernel.org [mailto:linux-media-
>> ow...@vger.kernel.org] On Behalf Of Arun Kumar K
>> Sent: Wednesday, May 14, 2014 10:10 AM
>>
>> Hi Hans,
>>
>> On 05/14/14 12:39, Hans Verkuil wrote:
>>> On 05/14/2014 08:29 AM, Arun Kumar K wrote:
>>>> MFCv6 encoder needs specific minimum number of buffers to be queued
>>>> in the CAPTURE plane. This minimum number will be known only when
>> the
>>>> sequence header is generated.
>>>> So we used to allow STREAMON on the CAPTURE plane only after
>> sequence
>>>> header is generated and checked with the minimum buffer requirement.
>>>>
>>>> But this causes a problem that we call a vb2_buffer_done for the
>>>> sequence header buffer before doing a STREAON on the CAPTURE plane.
>>>
>>> How could this ever have worked? Buffers aren't queued to the driver
>>> until STREAMON is called, and calling vb2_buffer_done for a buffer
>>> that is not queued first to the driver will mess up internal data (q-
>>> queued_count for one).
>>>
>>
>> This worked till now because __enqueue_in_driver is called first and
>> then start_streaming qop is called. In MFCv6, the start_streaming
>> driver callback used to wait till sequence header interrupt is received
>> and it used to do vb2_buffer_done in that interrupt context. So it
>> happened after buffers are enqueued in driver and before completing the
>> vb2_streamon.
>>
>>>> This used to still work fine until this patch was merged -
>>>> b3379c6 : vb2: only call start_streaming if sufficient buffers are
>>>> queued
>>>
>>> Are you testing with CONFIG_VIDEO_ADV_DEBUG set? If not, you should
>> do
>>> so. That will check whether all the vb2 calls are balanced.
>>>
>>> BTW, that's a small typo in s5p_mfc_enc.c (search for 'inavlid').
>>>
>>
>> I got it. Will post a patch fixing them. Thanks for spotting this.
>>
>>>> This problem should also come in earlier MFC firmware versions if
>> the
>>>> application calls STREAMON on CAPTURE with some delay after doing
>>>> STREAMON on OUTPUT.
>>>
>>> You can also play around with the min_buffers_needed field. My
>>> rule-of-thumb is that when start_streaming is called everything
>> should
>>> be ready to stream. It is painful for drivers to have to keep track
>> of the 'do I have enough buffers' status.
>>>
>>> For that reason I introduced the min_buffers_needed field. What I
>>> believe you can do here is to set it initially to a large value,
>>> preventing start_streaming from being called, and once you really
>> know
>>> the minimum number of buffers that you need it can be updated again
>> to the actual value.
>>
>> If a large value is kept in min_buffers_needed, there will be some
>> unnecessary memory initialization needed for say 16 full HD raw YUV
>> buffers when actual needed is only 4. And once the encoding is started,
>> updating the min_buffers_needed to actual value doesnt give any
>> advantage as nobody checks for it after that.
>> So the whole idea is to not enforce a worst case buffer allocation
>> requirement beforehand itself. I hope the current scheme of things
>> works well for the requirement.
> 
> I was looking in the code of the MFC encoder and handling of this situation
> seems wrong to me.
> 
> You say that a minimum number of buffers has to be queued for MFC encoder to
> work. But this number is not checked in s5p_mfc_ctx_ready in s5p_mfc_enc.c.
> 

The situation is bit tricky here. The s5p_mfc_ctx_ready has to be true
for giving the first frame to encode which generates the sequence
header. So this condition still holds good -
/* context is ready to make header */
if (ctx->state == MFCINST_GOT_INST && ctx->dst_queue_cnt >= 1)
return 1;

So at this moment, atleast 1 buffer has to be queued in CAPTURE plane so
as to generate sequence header. But once that is generated, then only
the total buffer requirement will be known as per the v6+ firmware.
So if we make ctx_ready only after STREAMON on CAPTURE is done, then
there is no way to check for min. buffer requirement and the application
will start the encoding and will fail during runtime.

> It is only checked during reqbufs. This way it does not ensure that there is
> a minimum number of buffers queued.
> 
> Also there is a control V4L2_CID_MIN_BUFFERS_

Re: [RFC] ARM: EXYNOS: Add support for clock handling in power domain

2014-05-19 Thread Arun Kumar K
Hi,
Any comments on this patch?
If this approach is ok, then I can drop the RFC tag and resend this for merging?

Regards
Arun

On Mon, May 12, 2014 at 2:09 PM, Arun Kumar K  wrote:
> From: Prathyush K 
>
> While powering on/off a local powerdomain in exynos5 chipsets, the input
> clocks to each device gets modified. This behaviour is based on the
> SYSCLK_SYS_PWR_REG registers.
> E.g. SYSCLK_MFC_SYS_PWR_REG = 0x0, the parent of input clock to MFC
>(aclk333) gets modified to oscclk
> = 0x1, no change in clocks.
> The recommended value of SYSCLK_SYS_PWR_REG before power gating any
> domain is 0x0. So we must also restore the clocks while powering on a
> domain everytime.
>
> This patch adds the framework for getting the required mux and parent clocks
> through a power domain device node.
> Just setting the parent while powering on is not enough since according
> to the clock framework, the parent has never changed. So we set the
> parent clock as oscclk before power gating and then set back the correct
> parent clock after powering on a domain.
>
> Signed-off-by: Prathyush K 
> Signed-off-by: Andrew Bresticker 
> Signed-off-by: Arun Kumar K 
> ---
> This patch is posted for getting the opinion from all on what would
> be the best possible solution to the issue at hand.
> The issue is observed with multiple IPs like MFC, GSC, G2D, MSC etc.
> where after a PD OFF-ON sequence, the parent clock gets reset to oscclk.
> I would like to get the opinion from all on what would be the right
> place to handle this. Either the clock re-parenting should be done
> by all these individual IP drivers
> OR
> power-domain driver can handle this at a common place as is being done
> in this patch.
>
> One more possible change I can do is to make a exynos5250 compatible for
> the power-domain driver and get the extra clocks only for exynos5 onwards.
> But since there are no errors being reported even if these clocks are not
> provided, these changes are fully backward compatible with exynos4 also.
> ---
>  .../bindings/arm/exynos/power_domain.txt   |   18 +++
>  arch/arm/mach-exynos/pm_domains.c  |   56 
> +++-
>  2 files changed, 73 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/devicetree/bindings/arm/exynos/power_domain.txt 
> b/Documentation/devicetree/bindings/arm/exynos/power_domain.txt
> index 5216b41..2e19a9f 100644
> --- a/Documentation/devicetree/bindings/arm/exynos/power_domain.txt
> +++ b/Documentation/devicetree/bindings/arm/exynos/power_domain.txt
> @@ -9,6 +9,16 @@ Required Properties:
>  - reg: physical base address of the controller and length of memory mapped
>  region.
>
> +Optional Properties:
> +- clocks: List of clock handles. The parent clocks of the input clocks to the
> +  devices in this power domain are set to oscclk before power gating and
> +  restored back after powering on a domain. This is required for all domains
> +  which are powered on and off and not required for unused domains.
> +  The following clocks can be specified:
> +  - oscclk: oscillator clock.
> +  - clk(n): input clock to the devices in this power domain
> +  - pclk(n): parent clock of input clock to the devices in this power domain
> +
>  Node of a device using power domains must have a samsung,power-domain 
> property
>  defined with a phandle to respective power domain.
>
> @@ -19,6 +29,14 @@ Example:
> reg = <0x10023C00 0x10>;
> };
>
> +   mfc_pd: power-domain@10044060 {
> +   compatible = "samsung,exynos4210-pd";
> +   reg = <0x10044060 0x20>;
> +   clocks = <&clock CLK_FIN_PLL>, <&clock MOUT_SW_ACLK333>,
> +   <&clock MOUT_USER_ACLK333>;
> +   clock-names = "oscclk", "pclk0", "clk0";
> +   };
> +
>  Example of the node using power domain:
>
> node {
> diff --git a/arch/arm/mach-exynos/pm_domains.c 
> b/arch/arm/mach-exynos/pm_domains.c
> index fe6570e..e5fe76d 100644
> --- a/arch/arm/mach-exynos/pm_domains.c
> +++ b/arch/arm/mach-exynos/pm_domains.c
> @@ -17,6 +17,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -24,6 +25,8 @@
>
>  #include "regs-pmu.h"
>
> +#define MAX_CLK_PER_DOMAIN 4
> +
>  /*
>   * Exynos specific wrapper around the generic power domain
>   */
> @@ -32,6 +35,9 @@ struct exynos_pm_domain {
> char const *name;
> bool is_off;
> struct generic_pm_domain pd;
> +   s

[PATCH 2/2] [media] s5p-mfc: Core support for v8 encoder

2014-05-19 Thread Arun Kumar K
From: Kiran AVND 

This patch adds core support for v8 encoder. This
patch also adds register definitions and buffer size
requirements for H264 & VP8 encoding, needed for new
firmware version v8 for MFC

Signed-off-by: Kiran AVND 
Signed-off-by: Pawel Osciak 
Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/regs-mfc-v8.h|   30 
 drivers/media/platform/s5p-mfc/s5p_mfc.c|2 +
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c|   12 ++---
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c |   56 +++
 4 files changed, 85 insertions(+), 15 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v8.h 
b/drivers/media/platform/s5p-mfc/regs-mfc-v8.h
index c84d120..cc7cbec 100644
--- a/drivers/media/platform/s5p-mfc/regs-mfc-v8.h
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v8.h
@@ -72,16 +72,46 @@
 /* SEI related information */
 #define S5P_FIMV_D_FRAME_PACK_SEI_AVAIL_V8 0xf6dc
 
+/* Encoder Registers */
+#define S5P_FIMV_E_FIXED_PICTURE_QP_V8 0xf794
+#define S5P_FIMV_E_RC_CONFIG_V80xf798
+#define S5P_FIMV_E_RC_QP_BOUND_V8  0xf79c
+#define S5P_FIMV_E_RC_RPARAM_V80xf7a4
+#define S5P_FIMV_E_MB_RC_CONFIG_V8 0xf7a8
+#define S5P_FIMV_E_PADDING_CTRL_V8 0xf7ac
+#define S5P_FIMV_E_MV_HOR_RANGE_V8 0xf7b4
+#define S5P_FIMV_E_MV_VER_RANGE_V8 0xf7b8
+
+#define S5P_FIMV_E_VBV_BUFFER_SIZE_V8  0xf78c
+#define S5P_FIMV_E_VBV_INIT_DELAY_V8   0xf790
+
+#define S5P_FIMV_E_ASPECT_RATIO_V8 0xfb4c
+#define S5P_FIMV_E_EXTENDED_SAR_V8 0xfb50
+#define S5P_FIMV_E_H264_OPTIONS_V8 0xfb54
+
 /* MFCv8 Context buffer sizes */
 #define MFC_CTX_BUF_SIZE_V8(30 * SZ_1K)/*  30KB */
 #define MFC_H264_DEC_CTX_BUF_SIZE_V8   (2 * SZ_1M) /*  2MB */
 #define MFC_OTHER_DEC_CTX_BUF_SIZE_V8  (20 * SZ_1K)/*  20KB */
+#define MFC_H264_ENC_CTX_BUF_SIZE_V8   (100 * SZ_1K)   /* 100KB */
+#define MFC_OTHER_ENC_CTX_BUF_SIZE_V8  (10 * SZ_1K)/*  10KB */
 
 /* Buffer size defines */
+#define S5P_FIMV_TMV_BUFFER_SIZE_V8(w, h)  (((w) + 1) * ((h) + 1) * 8)
+
 #define S5P_FIMV_SCRATCH_BUF_SIZE_H264_DEC_V8(w, h)(((w) * 704) + 2176)
 #define S5P_FIMV_SCRATCH_BUF_SIZE_VP8_DEC_V8(w, h) \
(((w) * 576 + (h) * 128)  + 4128)
 
+#define S5P_FIMV_SCRATCH_BUF_SIZE_H264_ENC_V8(w, h) \
+   (((w) * 592) + 2336)
+#define S5P_FIMV_SCRATCH_BUF_SIZE_VP8_ENC_V8(w, h) \
+   (((w) * 576) + 10512 + \
+   ((w) * 16) * ((h) * 16)) * 3) / 2) * 4))
+#define S5P_FIMV_ME_BUFFER_SIZE_V8(imw, imh, mbw, mbh) \
+   ((DIV_ROUND_UP((mbw * 16), 64) *  DIV_ROUND_UP((mbh * 16), 64) * 256) \
++ (DIV_ROUND_UP((mbw) * (mbh), 32) * 16))
+
 /* BUffer alignment defines */
 #define S5P_FIMV_D_ALIGN_PLANE_SIZE_V8 64
 
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 6c466a3..9ed0985 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -1404,6 +1404,8 @@ struct s5p_mfc_buf_size_v6 mfc_buf_size_v8 = {
.dev_ctx= MFC_CTX_BUF_SIZE_V8,
.h264_dec_ctx   = MFC_H264_DEC_CTX_BUF_SIZE_V8,
.other_dec_ctx  = MFC_OTHER_DEC_CTX_BUF_SIZE_V8,
+   .h264_enc_ctx   = MFC_H264_ENC_CTX_BUF_SIZE_V8,
+   .other_enc_ctx  = MFC_OTHER_ENC_CTX_BUF_SIZE_V8,
 };
 
 struct s5p_mfc_buf_size buf_size_v8 = {
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index ad759b9..56d1edd 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -58,7 +58,7 @@ static struct s5p_mfc_fmt formats[] = {
.codec_mode = S5P_MFC_CODEC_NONE,
.type   = MFC_FMT_RAW,
.num_planes = 2,
-   .versions   = MFC_V5 | MFC_V6 | MFC_V7,
+   .versions   = MFC_V5 | MFC_V6 | MFC_V7 | MFC_V8,
},
{
.name   = "4:2:0 2 Planes Y/CrCb",
@@ -66,7 +66,7 @@ static struct s5p_mfc_fmt formats[] = {
.codec_mode = S5P_MFC_CODEC_NONE,
.type   = MFC_FMT_RAW,
.num_planes = 2,
-   .versions   = MFC_V5 | MFC_V6 | MFC_V7,
+   .versions   = MFC_V5 | MFC_V6 | MFC_V7 | MFC_V8,
},
{
.name   = "H264 Encoded Stream",
@@ -74,7 +74,7 @@ static struct s5p_mfc_fmt formats[] = {
.codec_mode = S5P_MFC_CODEC_H264_ENC,
.type   = MFC_FMT_ENC,
.num_planes = 1,
-   .versions   = MFC_V5 | MFC_V6 | MFC_V7,
+   .versions   = MFC_V5 | MFC_V6 | MFC_V7 | MFC_V8,
},
{
.name  

[PATCH 1/2] [media] s5p-mfc: Core support to add v8 decoder

2014-05-19 Thread Arun Kumar K
From: Kiran AVND 

This patch adds variant data and core support for
V8 decoder. This patch also adds the register definition
file for new firmware version v8 for MFC.

Signed-off-by: Kiran AVND 
Signed-off-by: Pawel Osciak 
Signed-off-by: Arun Kumar K 
---
 .../devicetree/bindings/media/s5p-mfc.txt  |3 +-
 drivers/media/platform/s5p-mfc/regs-mfc-v8.h   |   94 
 drivers/media/platform/s5p-mfc/s5p_mfc.c   |   31 +++
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h|5 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c   |   28 +++---
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c|   85 --
 6 files changed, 223 insertions(+), 23 deletions(-)
 create mode 100644 drivers/media/platform/s5p-mfc/regs-mfc-v8.h

diff --git a/Documentation/devicetree/bindings/media/s5p-mfc.txt 
b/Documentation/devicetree/bindings/media/s5p-mfc.txt
index f418168..3e3c5f3 100644
--- a/Documentation/devicetree/bindings/media/s5p-mfc.txt
+++ b/Documentation/devicetree/bindings/media/s5p-mfc.txt
@@ -10,7 +10,8 @@ Required properties:
   - compatible : value should be either one among the following
(a) "samsung,mfc-v5" for MFC v5 present in Exynos4 SoCs
(b) "samsung,mfc-v6" for MFC v6 present in Exynos5 SoCs
-   (b) "samsung,mfc-v7" for MFC v7 present in Exynos5420 SoC
+   (c) "samsung,mfc-v7" for MFC v7 present in Exynos5420 SoC
+   (d) "samsung,mfc-v8" for MFC v8 present in Exynos5800 SoC
 
   - reg : Physical base address of the IP registers and length of memory
  mapped region.
diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v8.h 
b/drivers/media/platform/s5p-mfc/regs-mfc-v8.h
new file mode 100644
index 000..c84d120
--- /dev/null
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v8.h
@@ -0,0 +1,94 @@
+/*
+ * Register definition file for Samsung MFC V8.x Interface (FIMV) driver
+ *
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * http://www.samsung.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.
+ */
+
+#ifndef _REGS_MFC_V8_H
+#define _REGS_MFC_V8_H
+
+#include 
+#include "regs-mfc-v7.h"
+
+/* Additional registers for v8 */
+#define S5P_FIMV_D_MVC_NUM_VIEWS_V80xf104
+#define S5P_FIMV_D_FIRST_PLANE_DPB_SIZE_V8 0xf144
+#define S5P_FIMV_D_SECOND_PLANE_DPB_SIZE_V80xf148
+#define S5P_FIMV_D_MV_BUFFER_SIZE_V8   0xf150
+
+#define S5P_FIMV_D_FIRST_PLANE_DPB_STRIDE_SIZE_V8  0xf138
+#define S5P_FIMV_D_SECOND_PLANE_DPB_STRIDE_SIZE_V8 0xf13c
+
+#define S5P_FIMV_D_FIRST_PLANE_DPB_V8  0xf160
+#define S5P_FIMV_D_SECOND_PLANE_DPB_V8 0xf260
+#define S5P_FIMV_D_MV_BUFFER_V80xf460
+
+#define S5P_FIMV_D_NUM_MV_V8   0xf134
+#define S5P_FIMV_D_INIT_BUFFER_OPTIONS_V8  0xf154
+
+#define S5P_FIMV_D_SCRATCH_BUFFER_ADDR_V8  0xf560
+#define S5P_FIMV_D_SCRATCH_BUFFER_SIZE_V8  0xf564
+
+#define S5P_FIMV_D_CPB_BUFFER_ADDR_V8  0xf5b0
+#define S5P_FIMV_D_CPB_BUFFER_SIZE_V8  0xf5b4
+#define S5P_FIMV_D_AVAILABLE_DPB_FLAG_LOWER_V8 0xf5bc
+#define S5P_FIMV_D_CPB_BUFFER_OFFSET_V80xf5c0
+#define S5P_FIMV_D_SLICE_IF_ENABLE_V8  0xf5c4
+#define S5P_FIMV_D_STREAM_DATA_SIZE_V8 0xf5d0
+
+/* Display information register */
+#define S5P_FIMV_D_DISPLAY_FRAME_WIDTH_V8  0xf600
+#define S5P_FIMV_D_DISPLAY_FRAME_HEIGHT_V8 0xf604
+
+/* Display status */
+#define S5P_FIMV_D_DISPLAY_STATUS_V8   0xf608
+
+#define S5P_FIMV_D_DISPLAY_FIRST_PLANE_ADDR_V8 0xf60c
+#define S5P_FIMV_D_DISPLAY_SECOND_PLANE_ADDR_V80xf610
+
+#define S5P_FIMV_D_DISPLAY_FRAME_TYPE_V8   0xf618
+#define S5P_FIMV_D_DISPLAY_CROP_INFO1_V8   0xf61c
+#define S5P_FIMV_D_DISPLAY_CROP_INFO2_V8   0xf620
+#define S5P_FIMV_D_DISPLAY_PICTURE_PROFILE_V8  0xf624
+
+/* Decoded picture information register */
+#define S5P_FIMV_D_DECODED_STATUS_V8   0xf644
+#define S5P_FIMV_D_DECODED_FIRST_PLANE_ADDR_V8 0xf648
+#define S5P_FIMV_D_DECODED_SECOND_PLANE_ADDR_V80xf64c
+#define S5P_FIMV_D_DECODED_THIRD_PLANE_ADDR_V8 0xf650
+#define S5P_FIMV_D_DECODED_FRAME_TYPE_V8   0xf654
+#define S5P_FIMV_D_DECODED_NAL_SIZE_V8  0xf664
+
+/* Returned value register for specific setting */
+#define S5P_FIMV_D_RET_PICTURE_TAG_TOP_V8  0xf674
+#define S5P_FIMV_D_RET_PICTURE_TAG_BOT_V8  0xf678
+#define S5P_FIMV_D_MVC_VIEW_ID_V8  0xf6d8
+
+/* SEI related information */
+#define S5P_FIMV_D_FRAME_PACK_SEI_AVAIL_V8 0xf6dc
+
+/* MFCv8 Context buffer sizes */
+#define MFC_CTX_BUF_SIZE_V8(30 * SZ_1K)/*  30KB */
+#define MFC_H264_DEC_CTX_BUF_SIZE_V8   (2 * SZ_1M) /*  2MB */
+#define MFC_OTHER_DEC_CTX_BUF_SIZE_V8  (20 * SZ_1K)/*  20KB */
+
+/* Buffer size defines */

[PATCH 0/2] Re-send MFCv8 support patches

2014-05-19 Thread Arun Kumar K
These 2 patches for MFCv8 support are rebased onto
[1] with the dependencies as mentioned below.
Changes include adding the MFC_V8 version to formats.

- Re-send MFC patches
  https://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg31051.html
- Adding version information to formats by Kamil
  v4l: s5p-mfc: Fix default pixel format selection for decoder
  v4l: s5p-mfc: Limit enum_fmt to output formats of current version

[1] http://git.linuxtv.org/cgit.cgi/kdebski/media_tree_2.git/?h=for-3.16-2

Kiran AVND (2):
  [media] s5p-mfc: Core support to add v8 decoder
  [media] s5p-mfc: Core support for v8 encoder

 .../devicetree/bindings/media/s5p-mfc.txt  |3 +-
 drivers/media/platform/s5p-mfc/regs-mfc-v8.h   |  124 +
 drivers/media/platform/s5p-mfc/s5p_mfc.c   |   33 +
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h|5 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c   |   28 ++--
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c   |   12 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c|  141 +---
 7 files changed, 308 insertions(+), 38 deletions(-)
 create mode 100644 drivers/media/platform/s5p-mfc/regs-mfc-v8.h

-- 
1.7.9.5

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


[PATCH 02/10] [media] s5p-mfc: Fixes for decode REQBUFS.

2014-05-19 Thread Arun Kumar K
From: Pawel Osciak 

- Honor return values from vb2_reqbufs on REQBUFS(0).

- Do not set the number of allocated buffers to 0 if userspace tries
  to request buffers again without freeing them.

- There is no need to verify correct instance state on reqbufs, as we will
  verify this in queue_setup().

- There is also no need to verify that vb2_reqbufs() was able to allocate enough
  buffers (pb_count) and call buf_init on that many buffers (i.e. dst_buf_count
  is at least pb_count), because this will be verified by second queue_setup()
  call as well and vb2_reqbufs() will fail otherwise.

- Only verify state is MFCINST_INIT when allocating, not when freeing.

- Refactor and simplify code.

Signed-off-by: Pawel Osciak 
Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c |  178 ++
 1 file changed, 99 insertions(+), 79 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
index 58b7bba..99a55e6 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
@@ -462,104 +462,124 @@ out:
return ret;
 }
 
-/* Reqeust buffers */
-static int vidioc_reqbufs(struct file *file, void *priv,
- struct v4l2_requestbuffers *reqbufs)
+static int reqbufs_output(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx,
+   struct v4l2_requestbuffers *reqbufs)
 {
-   struct s5p_mfc_dev *dev = video_drvdata(file);
-   struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
int ret = 0;
 
-   if (reqbufs->memory != V4L2_MEMORY_MMAP) {
-   mfc_err("Only V4L2_MEMORY_MAP is supported\n");
-   return -EINVAL;
-   }
-   if (reqbufs->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
-   /* Can only request buffers after an instance has been opened.*/
-   if (ctx->state == MFCINST_INIT) {
-   ctx->src_bufs_cnt = 0;
-   if (reqbufs->count == 0) {
-   mfc_debug(2, "Freeing buffers\n");
-   s5p_mfc_clock_on();
-   ret = vb2_reqbufs(&ctx->vq_src, reqbufs);
-   s5p_mfc_clock_off();
-   return ret;
-   }
-   /* Decoding */
-   if (ctx->output_state != QUEUE_FREE) {
-   mfc_err("Bufs have already been requested\n");
-   return -EINVAL;
-   }
-   s5p_mfc_clock_on();
-   ret = vb2_reqbufs(&ctx->vq_src, reqbufs);
-   s5p_mfc_clock_off();
-   if (ret) {
-   mfc_err("vb2_reqbufs on output failed\n");
-   return ret;
-   }
-   mfc_debug(2, "vb2_reqbufs: %d\n", ret);
-   ctx->output_state = QUEUE_BUFS_REQUESTED;
+   s5p_mfc_clock_on();
+
+   if (reqbufs->count == 0) {
+   mfc_debug(2, "Freeing buffers\n");
+   ret = vb2_reqbufs(&ctx->vq_src, reqbufs);
+   if (ret)
+   goto out;
+   ctx->src_bufs_cnt = 0;
+   } else if (ctx->output_state == QUEUE_FREE) {
+   /* Can only request buffers after the instance
+* has been opened.
+*/
+   WARN_ON(ctx->src_bufs_cnt != 0);
+   if (ctx->state != MFCINST_INIT) {
+   mfc_err("Reqbufs called in an invalid state\n");
+   ret = -EINVAL;
+   goto out;
}
-   } else if (reqbufs->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
+
+   mfc_debug(2, "Allocating %d buffers for OUTPUT queue\n",
+   reqbufs->count);
+   ret = vb2_reqbufs(&ctx->vq_src, reqbufs);
+   if (ret)
+   goto out;
+
+   ctx->output_state = QUEUE_BUFS_REQUESTED;
+   } else {
+   mfc_err("Buffers have already been requested\n");
+   ret = -EINVAL;
+   }
+out:
+   s5p_mfc_clock_off();
+   if (ret)
+   mfc_err("Failed allocating buffers for OUTPUT queue\n");
+   return ret;
+}
+
+static int reqbufs_capture(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx,
+   struct v4l2_requestbuffers *reqbufs)
+{
+   int ret = 0;
+
+   s5p_mfc_clock_on();
+
+   if (reqbufs->count == 0) {
+   mfc_debug(2, "Freeing buffers\n");
+   ret = vb2_reqbufs(&ctx-

[PATCH 10/10] [media] s5p-mfc: Rename IS_MFCV7 macro

2014-05-19 Thread Arun Kumar K
Renaming the IS_MFCV7 macro to IS_MFCV7_PLUS for the
addition of MFCv8 support which reuses the v7 code.

Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h |2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c|2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c |   12 ++--
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h 
b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index 662fcef..993c993 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -701,6 +701,6 @@ void set_work_bit_irqsave(struct s5p_mfc_ctx *ctx);
(dev->variant->port_num ? 1 : 0) : 0) : 0)
 #define IS_TWOPORT(dev)(dev->variant->port_num == 2 ? 1 : 0)
 #define IS_MFCV6_PLUS(dev) (dev->variant->version >= 0x60 ? 1 : 0)
-#define IS_MFCV7(dev)  (dev->variant->version >= 0x70 ? 1 : 0)
+#define IS_MFCV7_PLUS(dev) (dev->variant->version >= 0x70 ? 1 : 0)
 
 #endif /* S5P_MFC_COMMON_H_ */
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index 1a55487..d09c2e1 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -1039,7 +1039,7 @@ static int vidioc_try_fmt(struct file *file, void *priv, 
struct v4l2_format *f)
return -EINVAL;
}
 
-   if (!IS_MFCV7(dev) && (fmt->fourcc == V4L2_PIX_FMT_VP8)) {
+   if (!IS_MFCV7_PLUS(dev) && (fmt->fourcc == V4L2_PIX_FMT_VP8)) {
mfc_err("VP8 is supported only in MFC v7\n");
return -EINVAL;
}
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
index 37a054a..cbea828 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
@@ -113,7 +113,7 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct 
s5p_mfc_ctx *ctx)
(ctx->mv_count * ctx->mv_size);
break;
case S5P_MFC_CODEC_MPEG4_DEC:
-   if (IS_MFCV7(dev)) {
+   if (IS_MFCV7_PLUS(dev)) {
ctx->scratch_buf_size =
S5P_FIMV_SCRATCH_BUF_SIZE_MPEG4_DEC_V7(
mb_width,
@@ -354,7 +354,7 @@ static void s5p_mfc_enc_calc_src_size_v6(struct s5p_mfc_ctx 
*ctx)
ctx->chroma_size = ALIGN((mb_width * mb_height) * 128, 256);
 
/* MFCv7 needs pad bytes for Luma and Chroma */
-   if (IS_MFCV7(ctx->dev)) {
+   if (IS_MFCV7_PLUS(ctx->dev)) {
ctx->luma_size += MFC_LUMA_PAD_BYTES_V7;
ctx->chroma_size += MFC_CHROMA_PAD_BYTES_V7;
}
@@ -1303,7 +1303,7 @@ static int s5p_mfc_init_decode_v6(struct s5p_mfc_ctx *ctx)
WRITEL(ctx->display_delay, mfc_regs->d_display_delay);
}
 
-   if (IS_MFCV7(dev)) {
+   if (IS_MFCV7_PLUS(dev)) {
WRITEL(reg, mfc_regs->d_dec_options);
reg = 0;
}
@@ -1318,7 +1318,7 @@ static int s5p_mfc_init_decode_v6(struct s5p_mfc_ctx *ctx)
if (ctx->dst_fmt->fourcc == V4L2_PIX_FMT_NV12MT_16X16)
reg |= (0x1 << S5P_FIMV_D_OPT_TILE_MODE_SHIFT_V6);
 
-   if (IS_MFCV7(dev))
+   if (IS_MFCV7_PLUS(dev))
WRITEL(reg, mfc_regs->d_init_buffer_options);
else
WRITEL(reg, mfc_regs->d_dec_options);
@@ -1406,7 +1406,7 @@ static int s5p_mfc_init_encode_v6(struct s5p_mfc_ctx *ctx)
}
 
/* Set stride lengths for v7 & above */
-   if (IS_MFCV7(dev)) {
+   if (IS_MFCV7_PLUS(dev)) {
WRITEL(ctx->img_width, mfc_regs->e_source_first_plane_stride);
WRITEL(ctx->img_width, mfc_regs->e_source_second_plane_stride);
}
@@ -2148,7 +2148,7 @@ const struct s5p_mfc_regs 
*s5p_mfc_init_regs_v6_plus(struct s5p_mfc_dev *dev)
R(e_h264_frame_packing_sei_info,
S5P_FIMV_E_H264_FRAME_PACKING_SEI_INFO_V6);
 
-   if (!IS_MFCV7(dev))
+   if (!IS_MFCV7_PLUS(dev))
goto done;
 
/* Initialize registers used in MFC v7 */
-- 
1.7.9.5

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


[PATCH 03/10] [media] s5p-mfc: Extract open/close MFC instance commands.

2014-05-19 Thread Arun Kumar K
From: Pawel Osciak 

This is in preparation for a new flow to fix issues with streamon, which
should not be allocating buffer memory.

Signed-off-by: Pawel Osciak 
Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c  |   19 +---
 drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c |   61 +
 drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.h |3 ++
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c  |   28 +++-
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c  |   18 ++--
 5 files changed, 74 insertions(+), 55 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 6ef6bd1..861087c 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -877,24 +877,7 @@ static int s5p_mfc_release(struct file *file)
 * return instance and free resources */
if (ctx->inst_no != MFC_NO_INSTANCE_SET) {
mfc_debug(2, "Has to free instance\n");
-   ctx->state = MFCINST_RETURN_INST;
-   set_work_bit_irqsave(ctx);
-   s5p_mfc_clean_ctx_int_flags(ctx);
-   s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
-   /* Wait until instance is returned or timeout occurred */
-   if (s5p_mfc_wait_for_done_ctx
-   (ctx, S5P_MFC_R2H_CMD_CLOSE_INSTANCE_RET, 0)) {
-   s5p_mfc_clock_off();
-   mfc_err("Err returning instance\n");
-   }
-   mfc_debug(2, "After free instance\n");
-   /* Free resources */
-   s5p_mfc_hw_call(dev->mfc_ops, release_codec_buffers, ctx);
-   s5p_mfc_hw_call(dev->mfc_ops, release_instance_buffer, ctx);
-   if (ctx->type == MFCINST_DECODER)
-   s5p_mfc_hw_call(dev->mfc_ops, release_dec_desc_buffer,
-   ctx);
-
+   s5p_mfc_close_mfc_inst(dev, ctx);
ctx->inst_no = MFC_NO_INSTANCE_SET;
}
/* hardware locking scheme */
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
index ee05f2d..6f6e50a 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
@@ -400,3 +400,64 @@ int s5p_mfc_wakeup(struct s5p_mfc_dev *dev)
return 0;
 }
 
+int s5p_mfc_open_mfc_inst(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx)
+{
+   int ret = 0;
+
+   ret = s5p_mfc_hw_call(dev->mfc_ops, alloc_instance_buffer, ctx);
+   if (ret) {
+   mfc_err("Failed allocating instance buffer\n");
+   goto err;
+   }
+
+   if (ctx->type == MFCINST_DECODER) {
+   ret = s5p_mfc_hw_call(dev->mfc_ops,
+   alloc_dec_temp_buffers, ctx);
+   if (ret) {
+   mfc_err("Failed allocating temporary buffers\n");
+   goto err_free_inst_buf;
+   }
+   }
+
+   set_work_bit_irqsave(ctx);
+   s5p_mfc_clean_ctx_int_flags(ctx);
+   s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
+   if (s5p_mfc_wait_for_done_ctx(ctx,
+   S5P_MFC_R2H_CMD_OPEN_INSTANCE_RET, 0)) {
+   /* Error or timeout */
+   mfc_err("Error getting instance from hardware\n");
+   ret = -EIO;
+   goto err_free_desc_buf;
+   }
+
+   mfc_debug(2, "Got instance number: %d\n", ctx->inst_no);
+   return ret;
+
+err_free_desc_buf:
+   if (ctx->type == MFCINST_DECODER)
+   s5p_mfc_hw_call(dev->mfc_ops, release_dec_desc_buffer, ctx);
+err_free_inst_buf:
+   s5p_mfc_hw_call(dev->mfc_ops, release_instance_buffer, ctx);
+err:
+   return ret;
+}
+
+void s5p_mfc_close_mfc_inst(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx)
+{
+   ctx->state = MFCINST_RETURN_INST;
+   set_work_bit_irqsave(ctx);
+   s5p_mfc_clean_ctx_int_flags(ctx);
+   s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
+   /* Wait until instance is returned or timeout occurred */
+   if (s5p_mfc_wait_for_done_ctx(ctx,
+   S5P_MFC_R2H_CMD_CLOSE_INSTANCE_RET, 0))
+   mfc_err("Err returning instance\n");
+
+   /* Free resources */
+   s5p_mfc_hw_call(dev->mfc_ops, release_codec_buffers, ctx);
+   s5p_mfc_hw_call(dev->mfc_ops, release_instance_buffer, ctx);
+   if (ctx->type == MFCINST_DECODER)
+   s5p_mfc_hw_call(dev->mfc_ops, release_dec_desc_buffer, ctx);
+
+   ctx->state = MFCINST_FREE;
+}
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.h 
b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.h
index 6a9b6f8..8e5df04 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_

[PATCH 08/10] [media] s5p-mfc: Move INIT_BUFFER_OPTIONS from v7 to v6

2014-05-19 Thread Arun Kumar K
The register S5P_FIMV_D_INIT_BUFFER_OPTIONS holds good for v6
firmware too. So moving the definition from v7 regs to v6.

Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/regs-mfc-v6.h|1 +
 drivers/media/platform/s5p-mfc/regs-mfc-v7.h|2 --
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c |2 +-
 3 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h 
b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
index 8e4021c..51cb2dd 100644
--- a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
@@ -141,6 +141,7 @@
 #define S5P_FIMV_D_SLICE_IF_ENABLE_V6  0xf4c4
 #define S5P_FIMV_D_PICTURE_TAG_V6  0xf4c8
 #define S5P_FIMV_D_STREAM_DATA_SIZE_V6 0xf4d0
+#define S5P_FIMV_D_INIT_BUFFER_OPTIONS_V6  0xf47c
 
 /* Display information register */
 #define S5P_FIMV_D_DISPLAY_FRAME_WIDTH_V6  0xf500
diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v7.h 
b/drivers/media/platform/s5p-mfc/regs-mfc-v7.h
index 5dfa149..1a5c6fd 100644
--- a/drivers/media/platform/s5p-mfc/regs-mfc-v7.h
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v7.h
@@ -18,8 +18,6 @@
 #define S5P_FIMV_CODEC_VP8_ENC_V7  25
 
 /* Additional registers for v7 */
-#define S5P_FIMV_D_INIT_BUFFER_OPTIONS_V7  0xf47c
-
 #define S5P_FIMV_E_SOURCE_FIRST_ADDR_V70xf9e0
 #define S5P_FIMV_E_SOURCE_SECOND_ADDR_V7   0xf9e4
 #define S5P_FIMV_E_SOURCE_THIRD_ADDR_V70xf9e8
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
index f64621a..518d9a0 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
@@ -1310,7 +1310,7 @@ static int s5p_mfc_init_decode_v6(struct s5p_mfc_ctx *ctx)
reg |= (0x1 << S5P_FIMV_D_OPT_TILE_MODE_SHIFT_V6);
 
if (IS_MFCV7(dev))
-   WRITEL(reg, S5P_FIMV_D_INIT_BUFFER_OPTIONS_V7);
+   WRITEL(reg, S5P_FIMV_D_INIT_BUFFER_OPTIONS_V6);
else
WRITEL(reg, S5P_FIMV_D_DEC_OPTIONS_V6);
 
-- 
1.7.9.5

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


[PATCH 06/10] [media] s5p-mfc: Don't try to resubmit VP8 bitstream buffer for decode.

2014-05-19 Thread Arun Kumar K
From: Pawel Osciak 

Currently, for formats that are not H264, MFC driver will check
the consumed stream size returned by the firmware and, based on that,
will try to decide whether the bitstream buffer contained more than
one frame. If the size of the buffer is larger than the consumed
stream, it assumes that there are more frames in the buffer and that the
buffer should be resubmitted for decode. This rarely works though and
actually introduces problems, because:

- v7 firmware will always return consumed stream size equal to whatever
the driver passed to it when running decode (which is the size of the whole
buffer), which means we will never try to resubmit, because the firmware
will always tell us that it consumed all the data we passed to it;

- v6 firmware will return the number of consumed bytes, but will not
include the padding ("stuffing") bytes that are allowed after the frame
in VP8. Since there is no way of figuring out how many of those bytes
follow the frame without getting the frame size from IVF headers (or
somewhere else, but not from the stream itself), the driver tries to guess that
padding size is not larger than 4 bytes, which is not always true;

The only way to make it work is to queue only one frame per buffer from
userspace and the check in the kernel is useless and wrong for VP8.
So adding VP8 also along with H264 to disallow re-submitting of buffer
back to hardware for decode.

Signed-off-by: Pawel Osciak 
Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 70f728f..297d681 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -368,6 +368,7 @@ static void s5p_mfc_handle_frame(struct s5p_mfc_ctx *ctx,
ctx->consumed_stream += s5p_mfc_hw_call(dev->mfc_ops,
get_consumed_stream, dev);
if (ctx->codec_mode != S5P_MFC_CODEC_H264_DEC &&
+   ctx->codec_mode != S5P_MFC_CODEC_VP8_DEC &&
ctx->consumed_stream + STUFF_BYTE <
src_buf->b->v4l2_planes[0].bytesused) {
/* Run MFC again on the same buffer */
-- 
1.7.9.5

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


[PATCH 00/10] Re-send MFC patches

2014-05-19 Thread Arun Kumar K
These patches for s5p-mfc are completed review and
accepted. These are rebased onto [1] and fixed conflicts
for merging.

[1] http://git.linuxtv.org/cgit.cgi/kdebski/media_tree_2.git/?h=for-3.16-2

Arun Kumar K (3):
  [media] s5p-mfc: Update scratch buffer size for MPEG4
  [media] s5p-mfc: Move INIT_BUFFER_OPTIONS from v7 to v6
  [media] s5p-mfc: Rename IS_MFCV7 macro

Kiran AVND (2):
  [media] s5p-mfc: Update scratch buffer size for VP8 encoder
  [media] s5p-mfc: Add variants to access mfc registers

Pawel Osciak (5):
  [media] s5p-mfc: Copy timestamps only when a frame is produced.
  [media] s5p-mfc: Fixes for decode REQBUFS.
  [media] s5p-mfc: Extract open/close MFC instance commands.
  [media] s5p-mfc: Don't allocate codec buffers on STREAMON.
  [media] s5p-mfc: Don't try to resubmit VP8 bitstream buffer for
decode.

 drivers/media/platform/s5p-mfc/regs-mfc-v6.h|4 +-
 drivers/media/platform/s5p-mfc/regs-mfc-v7.h|5 +-
 drivers/media/platform/s5p-mfc/s5p_mfc.c|   35 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h |3 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c   |   62 ++
 drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.h   |3 +
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c|  216 +++
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c|   20 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_opr.c|6 +
 drivers/media/platform/s5p-mfc/s5p_mfc_opr.h|  254 
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c |  703 +++
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.h |7 +-
 12 files changed, 904 insertions(+), 414 deletions(-)

-- 
1.7.9.5

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


[PATCH 07/10] [media] s5p-mfc: Update scratch buffer size for MPEG4

2014-05-19 Thread Arun Kumar K
Update the MPEG4 decoder scratch buffer size as per the
new v6 firmware. This updation is increasing the size and so
is backward compatible with older v6 firmwares.

Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/regs-mfc-v6.h |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h 
b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
index 8d0b686..8e4021c 100644
--- a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
@@ -381,8 +381,7 @@
 (DIV_ROUND_UP((mbw) * (mbh), 32) * 16))
 #define S5P_FIMV_SCRATCH_BUF_SIZE_H264_DEC_V6(w, h)(((w) * 192) + 64)
 #define S5P_FIMV_SCRATCH_BUF_SIZE_MPEG4_DEC_V6(w, h) \
-   ((w) * ((h) * 64 + 144) + (2048/16 * (h) * 64) + \
-(2048/16 * 256 + 8320))
+   ((w) * 144 + 8192 * (h) + 49216 + 1048576)
 #define S5P_FIMV_SCRATCH_BUF_SIZE_VC1_DEC_V6(w, h) \
(2096 * ((w) + (h) + 1))
 #define S5P_FIMV_SCRATCH_BUF_SIZE_H263_DEC_V6(w, h)((w) * 400)
-- 
1.7.9.5

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


[PATCH 01/10] [media] s5p-mfc: Copy timestamps only when a frame is produced.

2014-05-19 Thread Arun Kumar K
From: Pawel Osciak 

Timestamps for destination buffers are assigned by copying them from
corresponding source buffers when the decode operation results in a frame
being outputted to a destination buffer. But the decision when to do this, i.e.
whether the decode operation on current source buffer produced a destination
frame, is wrongly based on "display status". Display status reflects the status
of the destination buffer, not source.

This used to work for firmwares version <= 6, because in addition to the above,
we'd check the decoded frame type register, which was set to "skipped" if
a destination frame was not produced, exiting early from
s5p_mfc_handle_frame_new().
Firmware >=7 does not set the frame type register for frames that were not
decoded anymore though, which results in us wrongly overwriting timestamps of
previously decoded buffers (firmware reports the same destination buffer address
as previously decoded one if a frame wasn't decoded during current operation).

To do it properly, we should be basing our decision to copy the timestamp on the
status of the source buffer, i.e. "decode status". The decode status register
values are confusing, because in its case "display" means "a frame has been
outputted to a destination buffer". We should copy if "decode and display"
is returned in it. This also works on <= v6 firmware, which behaves in the same
way with regards to decode status register.

Signed-off-by: Pawel Osciak 
Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 89356ae..6ef6bd1 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -309,12 +309,15 @@ static void s5p_mfc_handle_frame(struct s5p_mfc_ctx *ctx,
 {
struct s5p_mfc_dev *dev = ctx->dev;
unsigned int dst_frame_status;
+   unsigned int dec_frame_status;
struct s5p_mfc_buf *src_buf;
unsigned long flags;
unsigned int res_change;
 
dst_frame_status = s5p_mfc_hw_call(dev->mfc_ops, get_dspl_status, dev)
& S5P_FIMV_DEC_STATUS_DECODING_STATUS_MASK;
+   dec_frame_status = s5p_mfc_hw_call(dev->mfc_ops, get_dec_status, dev)
+   & S5P_FIMV_DEC_STATUS_DECODING_STATUS_MASK;
res_change = (s5p_mfc_hw_call(dev->mfc_ops, get_dspl_status, dev)
& S5P_FIMV_DEC_STATUS_RESOLUTION_MASK)
>> S5P_FIMV_DEC_STATUS_RESOLUTION_SHIFT;
@@ -347,8 +350,7 @@ static void s5p_mfc_handle_frame(struct s5p_mfc_ctx *ctx,
}
}
 
-   if (dst_frame_status == S5P_FIMV_DEC_STATUS_DECODING_DISPLAY ||
-   dst_frame_status == S5P_FIMV_DEC_STATUS_DECODING_ONLY)
+   if (dec_frame_status == S5P_FIMV_DEC_STATUS_DECODING_DISPLAY)
s5p_mfc_handle_frame_copy_time(ctx);
 
/* A frame has been decoded and is in the buffer  */
-- 
1.7.9.5

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


[PATCH 05/10] [media] s5p-mfc: Update scratch buffer size for VP8 encoder

2014-05-19 Thread Arun Kumar K
From: Kiran AVND 

Scratch buffer size updated for vp8 encoding as per
the latest v7 firmware. As the new macro increases the
scratch buffer size, it is backward compatible with the older
firmware too.

Signed-off-by: Kiran AVND 
Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/regs-mfc-v7.h |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v7.h 
b/drivers/media/platform/s5p-mfc/regs-mfc-v7.h
index ea5ec2a..5dfa149 100644
--- a/drivers/media/platform/s5p-mfc/regs-mfc-v7.h
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v7.h
@@ -56,6 +56,7 @@
(SZ_1M + ((w) * 144) + (8192 * (h)) + 49216)
 
 #define S5P_FIMV_SCRATCH_BUF_SIZE_VP8_ENC_V7(w, h) \
-   (((w) * 48) + (((w) + 1) / 2 * 128) + 144 + 8192)
+   (((w) * 48) + 8192 + w) + 1) / 2) * 128) + 144 + \
+   ((w) * 16) * ((h) * 16)) * 3) / 2) * 4))
 
 #endif /*_REGS_MFC_V7_H*/
-- 
1.7.9.5

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


[PATCH 04/10] [media] s5p-mfc: Don't allocate codec buffers on STREAMON.

2014-05-19 Thread Arun Kumar K
From: Pawel Osciak 

Currently, we allocate private codec buffers on STREAMON, which may fail
if we are out of memory. We don't check for failure though, which will
make us crash with the codec accessing random memory.

We shouldn't be failing STREAMON with out of memory errors though. So move
the allocation of private codec buffers to REQBUFS for OUTPUT queue. Also,
move MFC instance opening and closing to REQBUFS as well, as it's tied to
allocation and deallocation of private codec buffers.

Signed-off-by: Pawel Osciak 
Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c  |8 +++
 drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c |1 +
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c  |   30 +++--
 3 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 861087c..70f728f 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -643,6 +643,7 @@ static irqreturn_t s5p_mfc_irq(int irq, void *priv)
 
case S5P_MFC_R2H_CMD_CLOSE_INSTANCE_RET:
clear_work_bit(ctx);
+   ctx->inst_no = MFC_NO_INSTANCE_SET;
ctx->state = MFCINST_FREE;
wake_up(&ctx->queue);
goto irq_cleanup_hw;
@@ -763,7 +764,7 @@ static int s5p_mfc_open(struct file *file)
goto err_bad_node;
}
ctx->fh.ctrl_handler = &ctx->ctrl_handler;
-   ctx->inst_no = -1;
+   ctx->inst_no = MFC_NO_INSTANCE_SET;
/* Load firmware if this is the first instance */
if (dev->num_inst == 1) {
dev->watchdog_timer.expires = jiffies +
@@ -873,12 +874,11 @@ static int s5p_mfc_release(struct file *file)
vb2_queue_release(&ctx->vq_dst);
/* Mark context as idle */
clear_work_bit_irqsave(ctx);
-   /* If instance was initialised then
+   /* If instance was initialised and not yet freed,
 * return instance and free resources */
-   if (ctx->inst_no != MFC_NO_INSTANCE_SET) {
+   if (ctx->state != MFCINST_FREE && ctx->state != MFCINST_INIT) {
mfc_debug(2, "Has to free instance\n");
s5p_mfc_close_mfc_inst(dev, ctx);
-   ctx->inst_no = MFC_NO_INSTANCE_SET;
}
/* hardware locking scheme */
if (dev->curr_ctx == ctx->num)
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
index 6f6e50a..6c3f8f7 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
@@ -459,5 +459,6 @@ void s5p_mfc_close_mfc_inst(struct s5p_mfc_dev *dev, struct 
s5p_mfc_ctx *ctx)
if (ctx->type == MFCINST_DECODER)
s5p_mfc_hw_call(dev->mfc_ops, release_dec_desc_buffer, ctx);
 
+   ctx->inst_no = MFC_NO_INSTANCE_SET;
ctx->state = MFCINST_FREE;
 }
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
index 995cee2..a4e6668 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
@@ -475,11 +475,11 @@ static int reqbufs_output(struct s5p_mfc_dev *dev, struct 
s5p_mfc_ctx *ctx,
ret = vb2_reqbufs(&ctx->vq_src, reqbufs);
if (ret)
goto out;
+   s5p_mfc_close_mfc_inst(dev, ctx);
ctx->src_bufs_cnt = 0;
+   ctx->output_state = QUEUE_FREE;
} else if (ctx->output_state == QUEUE_FREE) {
-   /* Can only request buffers after the instance
-* has been opened.
-*/
+   /* Can only request buffers when we have a valid format set. */
WARN_ON(ctx->src_bufs_cnt != 0);
if (ctx->state != MFCINST_INIT) {
mfc_err("Reqbufs called in an invalid state\n");
@@ -493,6 +493,13 @@ static int reqbufs_output(struct s5p_mfc_dev *dev, struct 
s5p_mfc_ctx *ctx,
if (ret)
goto out;
 
+   ret = s5p_mfc_open_mfc_inst(dev, ctx);
+   if (ret) {
+   reqbufs->count = 0;
+   vb2_reqbufs(&ctx->vq_src, reqbufs);
+   goto out;
+   }
+
ctx->output_state = QUEUE_BUFS_REQUESTED;
} else {
mfc_err("Buffers have already been requested\n");
@@ -594,7 +601,7 @@ static int vidioc_querybuf(struct file *file, void *priv,
return -EINVAL;
}
mfc_debug(2, "State: %d, buf->type: %d\n", ctx->state, buf->type);
-   if (ctx->state == MFCINST_INIT &&
+   if (ct

Re: [PATCH 1/2] s5p-mfc: Update mfc-v6 firmware

2014-05-19 Thread Arun Kumar K
Hi Kamil, Tomasz,

On Mon, May 19, 2014 at 2:08 PM, Kamil Debski  wrote:
> Hi Tomasz, Arun,
>
>> From: Tomasz Figa [mailto:t.f...@samsung.com]
>> Sent: Friday, May 16, 2014 12:22 PM
>>
>> Hi Kamil, Arun,
>>
>> On 16.05.2014 12:09, Kamil Debski wrote:
>> > Hi,
>> >
>> > Original Message-
>> >> From: arunkk.sams...@gmail.com [mailto:arunkk.sams...@gmail.com] On
>> >> Behalf Of Arun Kumar K
>> >> Sent: Friday, May 16, 2014 12:00 PM
>> >>
>> >> Hi Kamil,
>> >>
>> >> On Fri, May 16, 2014 at 3:24 PM, Kamil Debski 
>> >> wrote:
>> >>> Hi Arun,
>> >>>
>> >>> I asked you to put old and new v6 firmware in separate files.
>> >>
>> >> But wont that require a different filename other than s5p-mfc-v6.fw?
>> >
>> > Yes.
>> >
>> >> But the driver still expects the same file name.
>> >> Can I put the new filename as s5p-mfc-v6-v2.fw and mention in the
>> >> README that the file has to be renamed to s5p-mfc-v6.fw to be used?
>> >
>> > I think this is the way to go, because the new driver (with the patch)
>> > will work with old firmware, while old driver (without the patch)
>> will
>> > not work with the new firmware.
>> >
>> >>
>> >>> You should also mention in the commit message that this new
>> firmware
>> >>> will not work with the s5p-mfc driver without the patch you
>> recently
>> >>> submitted to linux-media mailing list. Please also add a link to
>> the
>> >>> thread with the necessary patch.
>> >>
>> >> Ok will do that.
>> >>
>> >>>
>> >>> In addition to the above I think a readme/description file should
>> be
>> >>> added to the s5p-mfc folder. The issue of firmware for v6 should be
>> >>> explained, so that no one is surprised that something does not work.
>> >>>
>>
>> May I suggest a little different solution?
>>
>> Since to not break compatibility, support for both firmware versions is
>> needed in the driver anyway, why not simply make the new, incompatible
>> firmware always use a different filename.
>>
>> Then let the driver try to load the new one first and if it fails then
>> load the old one? This would also let you get rid of that version check
>> by hardcoded date, as you would know which firmware type was found.
>>
>
> Tomasz, I really like your idea. I find it both simple and elegant.
> This way there will be no need to rename the firmware file in the repo or
> by the user, if the user wishes to use the new version.
>
> Arun, what is your opinion?
>

Yes this seems like a better approach to me too.
With this the new FW used in older kernel issue is also resolved as the new
fw file will have a different name and is not accepted in old kernel.

Regards
Arun

>> Best regards,
>> Tomasz
>
> Best wishes,
> --
> Kamil Debski
> Samsung R&D Institute Poland
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 
> 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-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3] clk: exynos5420: Add 5800 specific clocks

2014-05-19 Thread Arun Kumar K
Hi Tomasz,

Can this patch be taken for the 3.16 merge?

Regards
Arun

On Thu, May 15, 2014 at 11:26 AM, Arun Kumar K  wrote:
> From: Alim Akhtar 
>
> Exynos5800 clock structure is mostly similar to 5420 with only
> a small delta changes. So the 5420 clock file is re-used for
> 5800 also. The common clocks for both are seggreagated and few
> clocks which are different for both are separately initialized.
>
> Signed-off-by: Alim Akhtar 
> Signed-off-by: Arun Kumar K 
> ---
> Changes from v2
> - Rebased on Tomasz's samsung-clk-next branch of
>   samsung-clk [1] tree.
>   [1] git://git.kernel.org/pub/scm/linux/kernel/git/tfiga/samsung-clk.git
> Changes from v1
> - Rebased on Shaik's clock consolidation for 5420
> - Addressed review comments from Tomasz
> ---
>  .../devicetree/bindings/clock/exynos5420-clock.txt |3 +-
>  drivers/clk/samsung/clk-exynos5420.c   |  309 
> 
>  include/dt-bindings/clock/exynos5420.h |4 +
>  3 files changed, 259 insertions(+), 57 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/clock/exynos5420-clock.txt 
> b/Documentation/devicetree/bindings/clock/exynos5420-clock.txt
> index ca88c97..d54f42c 100644
> --- a/Documentation/devicetree/bindings/clock/exynos5420-clock.txt
> +++ b/Documentation/devicetree/bindings/clock/exynos5420-clock.txt
> @@ -1,12 +1,13 @@
>  * Samsung Exynos5420 Clock Controller
>
>  The Exynos5420 clock controller generates and supplies clock to various
> -controllers within the Exynos5420 SoC.
> +controllers within the Exynos5420 SoC and for the Exynos5800 SoC.
>
>  Required Properties:
>
>  - compatible: should be one of the following.
>- "samsung,exynos5420-clock" - controller compatible with Exynos5420 SoC.
> +  - "samsung,exynos5800-clock" - controller compatible with Exynos5800 SoC.
>
>  - reg: physical base address of the controller and length of memory mapped
>region.
> diff --git a/drivers/clk/samsung/clk-exynos5420.c 
> b/drivers/clk/samsung/clk-exynos5420.c
> index 1c3674e..9d7d7ee 100644
> --- a/drivers/clk/samsung/clk-exynos5420.c
> +++ b/drivers/clk/samsung/clk-exynos5420.c
> @@ -57,15 +57,19 @@
>  #define SRC_TOP5   0x10214
>  #define SRC_TOP6   0x10218
>  #define SRC_TOP7   0x1021c
> +#define SRC_TOP8   0x10220 /* 5800 specific */
> +#define SRC_TOP9   0x10224 /* 5800 specific */
>  #define SRC_DISP10 0x1022c
>  #define SRC_MAU0x10240
>  #define SRC_FSYS   0x10244
>  #define SRC_PERIC0 0x10250
>  #define SRC_PERIC1 0x10254
>  #define SRC_ISP0x10270
> +#define SRC_CAM0x10274 /* 5800 specific */
>  #define SRC_TOP10  0x10280
>  #define SRC_TOP11  0x10284
>  #define SRC_TOP12  0x10288
> +#define SRC_TOP13  0x1028c /* 5800 specific */
>  #define SRC_MASK_TOP2  0x10308
>  #define SRC_MASK_TOP7  0x1031c
>  #define SRC_MASK_DISP100x1032c
> @@ -76,6 +80,8 @@
>  #define DIV_TOP0   0x10500
>  #define DIV_TOP1   0x10504
>  #define DIV_TOP2   0x10508
> +#define DIV_TOP8   0x10520 /* 5800 specific */
> +#define DIV_TOP9   0x10524 /* 5800 specific */
>  #define DIV_DISP10 0x1052c
>  #define DIV_MAU0x10544
>  #define DIV_FSYS0  0x10548
> @@ -86,6 +92,7 @@
>  #define DIV_PERIC2 0x10560
>  #define DIV_PERIC3 0x10564
>  #define DIV_PERIC4 0x10568
> +#define DIV_CAM0x10574 /* 5800 specific */
>  #define SCLK_DIV_ISP0  0x10580
>  #define SCLK_DIV_ISP1  0x10584
>  #define DIV2_RATIO00x10590
> @@ -102,6 +109,7 @@
>  #define GATE_TOP_SCLK_ISP  0x10870
>  #define GATE_IP_GSCL0  0x10910
>  #define GATE_IP_GSCL1  0x10920
> +#define GATE_IP_CAM0x10924 /* 5800 specific */
>  #define GATE_IP_MFC0x1092c
>  #define GATE_IP_DISP1  0x10928
>  #define GATE_IP_G3D0x10930
> @@ -123,23 +131,31 @@
>  #define SRC_KFC0x28200
>  #define DIV_KFC0   0x28500
>
> +/* Exynos5x SoC type */
> +enum exynos5x_soc {
> +   EXYNOS5420,
> +   EXYNOS5800,
> +};
> +
>  /* list of PLLs */
> -enum exynos5420_plls {
> +enum exynos5x_plls {
> apll, cpll, dpll, epll, rpll, ipll, spll, vpll, mpll,
> bpll, kpll,
> nr_plls /* number of PLLs */
>  };
>
>  static void __iomem *reg_bas

Re: [PATCH 1/2] s5p-mfc: Update mfc-v6 firmware

2014-05-16 Thread Arun Kumar K
Hi Kamil,

On Fri, May 16, 2014 at 3:24 PM, Kamil Debski  wrote:
> Hi Arun,
>
> I asked you to put old and new v6 firmware in separate files.

But wont that require a different filename other than s5p-mfc-v6.fw?
But the driver still expects the same file name.
Can I put the new filename as s5p-mfc-v6-v2.fw and mention in the
README that the file has to be renamed to s5p-mfc-v6.fw to be used?

> You should also mention in the commit message that this new firmware
> will not work with the s5p-mfc driver without the patch you recently
> submitted to linux-media mailing list. Please also add a link to the
> thread with the necessary patch.

Ok will do that.

>
> In addition to the above I think a readme/description file should be
> added to the s5p-mfc folder. The issue of firmware for v6 should be
> explained, so that no one is surprised that something does not work.
>

Ok.

Regards
Arun

> Best wishes,
> --
> Kamil Debski
> Samsung R&D Institute Poland
>
>
>> -Original Message-
>> From: Arun Kumar K [mailto:arunkk.sams...@gmail.com] On Behalf Of Arun
>> Kumar K
>> Sent: Friday, May 16, 2014 11:45 AM
>> To: dw...@infradead.org; b...@decadent.org.uk; linux-samsung-
>> s...@vger.kernel.org
>> Cc: k.deb...@samsung.com; arunkk.sams...@gmail.com
>> Subject: [PATCH 1/2] s5p-mfc: Update mfc-v6 firmware
>>
>> This is the newer version of s5p-mfc-v6.fw with many
>> fixes and enhancements.
>>
>> Signed-off-by: Arun Kumar K 
>> ---
>>  s5p-mfc/s5p-mfc-v6.fw |  Bin 306312 -> 343756 bytes
>>  1 file changed, 0 insertions(+), 0 deletions(-)
>>
>> diff --git a/s5p-mfc/s5p-mfc-v6.fw b/s5p-mfc/s5p-mfc-v6.fw
>> index
>> 2e1179fa6d227f1c5a23f78b4834be336e579f50..9d3345fbf4abb7ea7389816916d68
>> 57d64732380 100644
>> GIT binary patch
>> literal 343756
>
> [snip]
>
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 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/1] ARM: dts: Add PD entry to MFC codec on 5420

2014-05-15 Thread Arun Kumar K
Looks good.
Reviewed-by : Arun Kumar K 

On Tue, Apr 29, 2014 at 12:19 PM, Sachin Kamat  wrote:
> PD entry was missing in MFC codec node.
>
> Signed-off-by: Sachin Kamat 
> ---
>  arch/arm/boot/dts/exynos5420.dtsi |1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/arm/boot/dts/exynos5420.dtsi 
> b/arch/arm/boot/dts/exynos5420.dtsi
> index 6f662b5cc90d..2fd36b0a7568 100644
> --- a/arch/arm/boot/dts/exynos5420.dtsi
> +++ b/arch/arm/boot/dts/exynos5420.dtsi
> @@ -131,6 +131,7 @@
> interrupts = <0 96 0>;
> clocks = <&clock CLK_MFC>;
> clock-names = "mfc";
> +   samsung,power-domain = <&mfc_pd>;
> };
>
> mmc_0: mmc@1220 {
> --
> 1.7.9.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 
> 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-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ARM: dts: Add mfc node for exynos5800

2014-05-15 Thread Arun Kumar K
Adds the mfc node to exynos5800 which uses MFCv8.

Signed-off-by: Arun Kumar K 
---
The driver side patch adding support for MFCv8 is under
review [1]. This is based on the linux-samsung for-next branch.
[1] https://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg30670.html
---
 arch/arm/boot/dts/exynos5800.dtsi |4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/exynos5800.dtsi 
b/arch/arm/boot/dts/exynos5800.dtsi
index 6979fc7..c0bb356 100644
--- a/arch/arm/boot/dts/exynos5800.dtsi
+++ b/arch/arm/boot/dts/exynos5800.dtsi
@@ -22,3 +22,7 @@
 &clock {
compatible = "samsung,exynos5800-clock";
 };
+
+&mfc {
+   compatible = "samsung,mfc-v8";
+};
-- 
1.7.9.5

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


[PATCH v3] clk: exynos5420: Add 5800 specific clocks

2014-05-14 Thread Arun Kumar K
From: Alim Akhtar 

Exynos5800 clock structure is mostly similar to 5420 with only
a small delta changes. So the 5420 clock file is re-used for
5800 also. The common clocks for both are seggreagated and few
clocks which are different for both are separately initialized.

Signed-off-by: Alim Akhtar 
Signed-off-by: Arun Kumar K 
---
Changes from v2
- Rebased on Tomasz's samsung-clk-next branch of
  samsung-clk [1] tree.
  [1] git://git.kernel.org/pub/scm/linux/kernel/git/tfiga/samsung-clk.git
Changes from v1
- Rebased on Shaik's clock consolidation for 5420
- Addressed review comments from Tomasz
---
 .../devicetree/bindings/clock/exynos5420-clock.txt |3 +-
 drivers/clk/samsung/clk-exynos5420.c   |  309 
 include/dt-bindings/clock/exynos5420.h |4 +
 3 files changed, 259 insertions(+), 57 deletions(-)

diff --git a/Documentation/devicetree/bindings/clock/exynos5420-clock.txt 
b/Documentation/devicetree/bindings/clock/exynos5420-clock.txt
index ca88c97..d54f42c 100644
--- a/Documentation/devicetree/bindings/clock/exynos5420-clock.txt
+++ b/Documentation/devicetree/bindings/clock/exynos5420-clock.txt
@@ -1,12 +1,13 @@
 * Samsung Exynos5420 Clock Controller
 
 The Exynos5420 clock controller generates and supplies clock to various
-controllers within the Exynos5420 SoC.
+controllers within the Exynos5420 SoC and for the Exynos5800 SoC.
 
 Required Properties:
 
 - compatible: should be one of the following.
   - "samsung,exynos5420-clock" - controller compatible with Exynos5420 SoC.
+  - "samsung,exynos5800-clock" - controller compatible with Exynos5800 SoC.
 
 - reg: physical base address of the controller and length of memory mapped
   region.
diff --git a/drivers/clk/samsung/clk-exynos5420.c 
b/drivers/clk/samsung/clk-exynos5420.c
index 1c3674e..9d7d7ee 100644
--- a/drivers/clk/samsung/clk-exynos5420.c
+++ b/drivers/clk/samsung/clk-exynos5420.c
@@ -57,15 +57,19 @@
 #define SRC_TOP5   0x10214
 #define SRC_TOP6   0x10218
 #define SRC_TOP7   0x1021c
+#define SRC_TOP8   0x10220 /* 5800 specific */
+#define SRC_TOP9   0x10224 /* 5800 specific */
 #define SRC_DISP10 0x1022c
 #define SRC_MAU0x10240
 #define SRC_FSYS   0x10244
 #define SRC_PERIC0 0x10250
 #define SRC_PERIC1 0x10254
 #define SRC_ISP0x10270
+#define SRC_CAM0x10274 /* 5800 specific */
 #define SRC_TOP10  0x10280
 #define SRC_TOP11  0x10284
 #define SRC_TOP12  0x10288
+#define SRC_TOP13  0x1028c /* 5800 specific */
 #define SRC_MASK_TOP2  0x10308
 #define SRC_MASK_TOP7  0x1031c
 #define SRC_MASK_DISP100x1032c
@@ -76,6 +80,8 @@
 #define DIV_TOP0   0x10500
 #define DIV_TOP1   0x10504
 #define DIV_TOP2   0x10508
+#define DIV_TOP8   0x10520 /* 5800 specific */
+#define DIV_TOP9   0x10524 /* 5800 specific */
 #define DIV_DISP10 0x1052c
 #define DIV_MAU0x10544
 #define DIV_FSYS0  0x10548
@@ -86,6 +92,7 @@
 #define DIV_PERIC2 0x10560
 #define DIV_PERIC3 0x10564
 #define DIV_PERIC4 0x10568
+#define DIV_CAM0x10574 /* 5800 specific */
 #define SCLK_DIV_ISP0  0x10580
 #define SCLK_DIV_ISP1  0x10584
 #define DIV2_RATIO00x10590
@@ -102,6 +109,7 @@
 #define GATE_TOP_SCLK_ISP  0x10870
 #define GATE_IP_GSCL0  0x10910
 #define GATE_IP_GSCL1  0x10920
+#define GATE_IP_CAM0x10924 /* 5800 specific */
 #define GATE_IP_MFC0x1092c
 #define GATE_IP_DISP1  0x10928
 #define GATE_IP_G3D0x10930
@@ -123,23 +131,31 @@
 #define SRC_KFC0x28200
 #define DIV_KFC0   0x28500
 
+/* Exynos5x SoC type */
+enum exynos5x_soc {
+   EXYNOS5420,
+   EXYNOS5800,
+};
+
 /* list of PLLs */
-enum exynos5420_plls {
+enum exynos5x_plls {
apll, cpll, dpll, epll, rpll, ipll, spll, vpll, mpll,
bpll, kpll,
nr_plls /* number of PLLs */
 };
 
 static void __iomem *reg_base;
+static enum exynos5x_soc exynos5x_soc;
 
 #ifdef CONFIG_PM_SLEEP
-static struct samsung_clk_reg_dump *exynos5420_save;
+static struct samsung_clk_reg_dump *exynos5x_save;
+static struct samsung_clk_reg_dump *exynos5800_save;
 
 /*
  * list of controller registers to be saved and restored during a
  * suspend/resume cycle.
  */
-static unsigned long exynos5420_clk_regs[] __initdata = {
+static unsigned long exynos5x_clk_regs[] __initdata = {
SRC_CPU,
DIV_CPU0,
DIV_CPU1,
@@ -222,18 +238,37 @@ static unsigned long exynos5420_clk_regs[] __initdata = {
DIV_KFC0,
 };
 
+static unsigned long exynos5800_clk_regs[] __initdata = {
+   

Re: [PATCH v2 1/3] clk: exynos5420: Add 5800 specific clocks

2014-05-14 Thread Arun Kumar K
Hi Tomasz,

On Thu, May 15, 2014 at 2:16 AM, Tomasz Figa  wrote:
> Hi Arun, Alim,
>
> On 09.05.2014 14:25, Arun Kumar K wrote:
>> From: Alim Akhtar 
>>
>> Exynos5800 clock structure is mostly similar to 5420 with only
>> a small delta changes. So the 5420 clock file is re-used for
>> 5800 also. The common clocks for both are seggreagated and few
>> clocks which are different for both are separately initialized.
>>
>> Signed-off-by: Alim Akhtar 
>> Signed-off-by: Arun Kumar K 
>> ---
>> Changes from v1
>> ---
>> - Rebased on clock cleanup by Shaik
>
> This still isn't using correct base and won't compile with current
> sources, even if it applies fine. This is partially my fault as we had a
> lot of issues with cross-tree dependencies and it was not clear what to
> base clock patches on, but I'll try to keep samsung-clk-next branch of
> samsung-clk [1] tree up to date, so it should be safe to base on.
>
> [1] git://git.kernel.org/pub/scm/linux/kernel/git/tfiga/samsung-clk.git

Ok I will rebase the 5800 clock patch on this branch and resend it.

Thanks & Regards
Arun

>
> Best regards,
> Tomasz
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 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] [media] s5p-mfc: Dequeue sequence header after STREAMON

2014-05-14 Thread Arun Kumar K
Hi Hans,

On 05/14/14 12:39, Hans Verkuil wrote:
> On 05/14/2014 08:29 AM, Arun Kumar K wrote:
>> MFCv6 encoder needs specific minimum number of buffers to
>> be queued in the CAPTURE plane. This minimum number will
>> be known only when the sequence header is generated.
>> So we used to allow STREAMON on the CAPTURE plane only after
>> sequence header is generated and checked with the minimum
>> buffer requirement.
>>
>> But this causes a problem that we call a vb2_buffer_done
>> for the sequence header buffer before doing a STREAON on the
>> CAPTURE plane. 
> 
> How could this ever have worked? Buffers aren't queued to the driver until
> STREAMON is called, and calling vb2_buffer_done for a buffer that is not 
> queued
> first to the driver will mess up internal data (q->queued_count for one).
> 

This worked till now because __enqueue_in_driver is called first and
then start_streaming qop is called. In MFCv6, the start_streaming driver
callback used to wait till sequence header interrupt is received and it
used to do vb2_buffer_done in that interrupt context. So it happened
after buffers are enqueued in driver and before completing the vb2_streamon.

>> This used to still work fine until this patch
>> was merged -
>> b3379c6 : vb2: only call start_streaming if sufficient buffers are queued
> 
> Are you testing with CONFIG_VIDEO_ADV_DEBUG set? If not, you should do so. 
> That
> will check whether all the vb2 calls are balanced.
> 
> BTW, that's a small typo in s5p_mfc_enc.c (search for 'inavlid').
> 

I got it. Will post a patch fixing them. Thanks for spotting this.

>> This problem should also come in earlier MFC firmware versions
>> if the application calls STREAMON on CAPTURE with some delay
>> after doing STREAMON on OUTPUT.
> 
> You can also play around with the min_buffers_needed field. My rule-of-thumb 
> is that
> when start_streaming is called everything should be ready to stream. It is 
> painful
> for drivers to have to keep track of the 'do I have enough buffers' status.
> 
> For that reason I introduced the min_buffers_needed field. What I believe you 
> can
> do here is to set it initially to a large value, preventing start_streaming 
> from
> being called, and once you really know the minimum number of buffers that you 
> need
> it can be updated again to the actual value.

If a large value is kept in min_buffers_needed, there will be some
unnecessary memory initialization needed for say 16 full HD raw YUV
buffers when actual needed is only 4. And once the encoding is started,
updating the min_buffers_needed to actual value doesnt give any
advantage as nobody checks for it after that.
So the whole idea is to not enforce a worst case buffer allocation
requirement beforehand itself. I hope the current scheme of things works
well for the requirement.

Regards
Arun

> 
> I don't know this driver well enough to tell whether that works here or not, 
> but
> it is worth looking at IMHO.
> 
> Regards,
> 
>   Hans
> 
>> So this patch keeps the header buffer until the other frame
>> buffers are ready and dequeues it just before the first frame
>> is ready.
>>
>> Signed-off-by: Arun Kumar K 
>> ---
>> Changes from v1
>> - Addressed review comments from Sachin
>>   https://patchwork.linuxtv.org/patch/23839/
>> ---
>>  drivers/media/platform/s5p-mfc/s5p_mfc_common.h |2 ++
>>  drivers/media/platform/s5p-mfc/s5p_mfc_enc.c|6 +-
>>  2 files changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h 
>> b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
>> index f5404a6..cc2b96e 100644
>> --- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
>> +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
>> @@ -523,6 +523,7 @@ struct s5p_mfc_codec_ops {
>>   * @output_state:   state of the output buffers queue
>>   * @src_bufs:   information on allocated source buffers
>>   * @dst_bufs:   information on allocated destination buffers
>> + * @header_mb:  buffer pointer of the encoded sequence header
>>   * @sequence:   counter for the sequence number for v4l2
>>   * @dec_dst_flag:   flags for buffers queued in the hardware
>>   * @dec_src_buf_size:   size of the buffer for source buffers in 
>> decoding
>> @@ -607,6 +608,7 @@ struct s5p_mfc_ctx {
>>  int src_bufs_cnt;
>>  struct s5p_mfc_buf dst_bufs[MFC_MAX_BUFFERS];
>>  int dst_bufs_cnt;
>> +struct s5p_mfc_buf *header_mb;
>>  
>>  unsigned int sequence;
&

[PATCH v5 2/2] [media] s5p-mfc: Add support for resolution change event

2014-05-14 Thread Arun Kumar K
From: Pawel Osciak 

When a resolution change point is reached, queue an event to signal the
userspace that a new set of buffers is required before decoding can
continue.

Signed-off-by: Pawel Osciak 
Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c |8 
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c |2 ++
 2 files changed, 10 insertions(+)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 6b04f17..f3a4576 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -349,8 +349,16 @@ static void s5p_mfc_handle_frame(struct s5p_mfc_ctx *ctx,
/* All frames remaining in the buffer have been extracted  */
if (dst_frame_status == S5P_FIMV_DEC_STATUS_DECODING_EMPTY) {
if (ctx->state == MFCINST_RES_CHANGE_FLUSH) {
+   static const struct v4l2_event ev_src_ch = {
+   .type = V4L2_EVENT_SOURCE_CHANGE,
+   .u.src_change.changes =
+   V4L2_EVENT_SRC_CH_RESOLUTION,
+   };
+
s5p_mfc_handle_frame_all_extracted(ctx);
ctx->state = MFCINST_RES_CHANGE_END;
+   v4l2_event_queue_fh(&ctx->fh, &ev_src_ch);
+
goto leave_handle_frame;
} else {
s5p_mfc_handle_frame_all_extracted(ctx);
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
index 4586186..326d8db 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
@@ -851,6 +851,8 @@ static int vidioc_subscribe_event(struct v4l2_fh *fh,
switch (sub->type) {
case V4L2_EVENT_EOS:
return v4l2_event_subscribe(fh, sub, 2, NULL);
+   case V4L2_EVENT_SOURCE_CHANGE:
+   return v4l2_src_change_event_subscribe(fh, sub);
default:
return -EINVAL;
}
-- 
1.7.9.5

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


[PATCH v5 1/2] [media] v4l: Add source change event

2014-05-14 Thread Arun Kumar K
This event indicates that the video device has encountered
a source parameter change during runtime. This can typically be a
resolution change detected by a video decoder OR a format change
detected by an input connector.

This needs to be nofified to the userspace and the application may
be expected to reallocate buffers before proceeding. The application
can subscribe to events on a specific pad or input port which
it is interested in.

Signed-off-by: Arun Kumar K 
---
 Documentation/DocBook/media/v4l/vidioc-dqevent.xml |   33 ++
 .../DocBook/media/v4l/vidioc-subscribe-event.xml   |   20 +++
 drivers/media/v4l2-core/v4l2-event.c   |   36 
 include/media/v4l2-event.h |4 +++
 include/uapi/linux/videodev2.h |8 +
 5 files changed, 101 insertions(+)

diff --git a/Documentation/DocBook/media/v4l/vidioc-dqevent.xml 
b/Documentation/DocBook/media/v4l/vidioc-dqevent.xml
index 89891ad..820f86e 100644
--- a/Documentation/DocBook/media/v4l/vidioc-dqevent.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-dqevent.xml
@@ -242,6 +242,22 @@
   
 
 
+
+  struct v4l2_event_src_change
+  
+   &cs-str;
+   
+ 
+   __u32
+   changes
+   
+ A bitmask that tells what has changed. See .
+   
+ 
+   
+  
+
+
 
   Changes
   
@@ -270,6 +286,23 @@

   
 
+
+
+  Source Changes
+  
+   &cs-def;
+   
+ 
+   V4L2_EVENT_SRC_CH_RESOLUTION
+   0x0001
+   This event gets triggered when a resolution change is
+   detected at an input. This can come from an input connector or
+   from a video decoder.
+   
+ 
+   
+  
+
   
   
 &return-value;
diff --git a/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml 
b/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml
index 5c70b61..f016254 100644
--- a/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml
@@ -155,6 +155,26 @@

  
  
+   V4L2_EVENT_SOURCE_CHANGE
+   5
+   
+ This event is triggered when a source parameter change is
+  detected during runtime by the video device. It can be a
+  runtime resolution change triggered by a video decoder or the
+  format change happening on an input connector.
+  This event requires that the id
+  matches the input index (when used with a video device node)
+  or the pad index (when used with a subdevice node) from which
+  you want to receive events.
+
+  This event has a &v4l2-event-source-change; associated
+ with it. The changes bitfield denotes
+ what has changed for the subscribed pad. If multiple events
+ occurred before application could dequeue them, then the changes
+ will have the ORed value of all the events generated.
+   
+ 
+ 
V4L2_EVENT_PRIVATE_START
0x0800
Base event number for driver-private events.
diff --git a/drivers/media/v4l2-core/v4l2-event.c 
b/drivers/media/v4l2-core/v4l2-event.c
index 86dcb54..8761aab 100644
--- a/drivers/media/v4l2-core/v4l2-event.c
+++ b/drivers/media/v4l2-core/v4l2-event.c
@@ -318,3 +318,39 @@ int v4l2_event_subdev_unsubscribe(struct v4l2_subdev *sd, 
struct v4l2_fh *fh,
return v4l2_event_unsubscribe(fh, sub);
 }
 EXPORT_SYMBOL_GPL(v4l2_event_subdev_unsubscribe);
+
+static void v4l2_event_src_replace(struct v4l2_event *old,
+   const struct v4l2_event *new)
+{
+   u32 old_changes = old->u.src_change.changes;
+
+   old->u.src_change = new->u.src_change;
+   old->u.src_change.changes |= old_changes;
+}
+
+static void v4l2_event_src_merge(const struct v4l2_event *old,
+   struct v4l2_event *new)
+{
+   new->u.src_change.changes |= old->u.src_change.changes;
+}
+
+static const struct v4l2_subscribed_event_ops v4l2_event_src_ch_ops = {
+   .replace = v4l2_event_src_replace,
+   .merge = v4l2_event_src_merge,
+};
+
+int v4l2_src_change_event_subscribe(struct v4l2_fh *fh,
+   const struct v4l2_event_subscription *sub)
+{
+   if (sub->type == V4L2_EVENT_SOURCE_CHANGE)
+   return v4l2_event_subscribe(fh, sub, 0, &v4l2_event_src_ch_ops);
+   return -EINVAL;
+}
+EXPORT_SYMBOL_GPL(v4l2_src_change_event_subscribe);
+
+int v4l2_src_change_event_subdev_subscribe(struct v4l2_subdev *sd,
+   struct v4l2_fh *fh, struct v4l2_event_subscription *sub)
+{
+   return v4l2_src_change_event_subscribe(fh, sub);
+}
+EXPORT_SYMBOL_GPL(v4l2_src_change_event_subd

[PATCH v5 0/2] Add resolution change event

2014-05-14 Thread Arun Kumar K
This patchset adds a source_change event to the v4l2-events.
This can be used for notifying the userspace about runtime
format changes happening on video nodes / pads like resolution
change in video decoder.

Changes from v4
--
- Addressed comments from Hans
  https://patchwork.linuxtv.org/patch/23892/
  https://patchwork.linuxtv.org/patch/23893/

Changes from v3
--
- Addressed comments from Laurent / Hans
  https://patchwork.kernel.org/patch/4135731/

Changes from v2
---
- Event can be subscribed on specific pad / port as
  suggested by Hans.

Changes from v1
---
- Addressed review comments from Hans and Laurent
  https://patchwork.kernel.org/patch/4000951/

Arun Kumar K (1):
  [media] v4l: Add source change event

Pawel Osciak (1):
  [media] s5p-mfc: Add support for resolution change event

 Documentation/DocBook/media/v4l/vidioc-dqevent.xml |   33 ++
 .../DocBook/media/v4l/vidioc-subscribe-event.xml   |   20 +++
 drivers/media/platform/s5p-mfc/s5p_mfc.c   |8 +
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c   |2 ++
 drivers/media/v4l2-core/v4l2-event.c   |   36 
 include/media/v4l2-event.h |4 +++
 include/uapi/linux/videodev2.h |8 +
 7 files changed, 111 insertions(+)

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 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] s5p-mfc: Core support to add v8 decoder

2014-05-13 Thread Arun Kumar K
From: Kiran AVND 

This patch adds variant data and core support for
V8 decoder. This patch also adds the register definition
file for new firmware version v8 for MFC.

Signed-off-by: Kiran AVND 
Signed-off-by: Pawel Osciak 
Signed-off-by: Arun Kumar K 
---
 .../devicetree/bindings/media/s5p-mfc.txt  |3 +-
 drivers/media/platform/s5p-mfc/regs-mfc-v8.h   |   94 
 drivers/media/platform/s5p-mfc/s5p_mfc.c   |   30 +++
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h|4 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c   |4 +
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c|   85 --
 6 files changed, 210 insertions(+), 10 deletions(-)
 create mode 100644 drivers/media/platform/s5p-mfc/regs-mfc-v8.h

diff --git a/Documentation/devicetree/bindings/media/s5p-mfc.txt 
b/Documentation/devicetree/bindings/media/s5p-mfc.txt
index f418168..3e3c5f3 100644
--- a/Documentation/devicetree/bindings/media/s5p-mfc.txt
+++ b/Documentation/devicetree/bindings/media/s5p-mfc.txt
@@ -10,7 +10,8 @@ Required properties:
   - compatible : value should be either one among the following
(a) "samsung,mfc-v5" for MFC v5 present in Exynos4 SoCs
(b) "samsung,mfc-v6" for MFC v6 present in Exynos5 SoCs
-   (b) "samsung,mfc-v7" for MFC v7 present in Exynos5420 SoC
+   (c) "samsung,mfc-v7" for MFC v7 present in Exynos5420 SoC
+   (d) "samsung,mfc-v8" for MFC v8 present in Exynos5800 SoC
 
   - reg : Physical base address of the IP registers and length of memory
  mapped region.
diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v8.h 
b/drivers/media/platform/s5p-mfc/regs-mfc-v8.h
new file mode 100644
index 000..c84d120
--- /dev/null
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v8.h
@@ -0,0 +1,94 @@
+/*
+ * Register definition file for Samsung MFC V8.x Interface (FIMV) driver
+ *
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * http://www.samsung.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.
+ */
+
+#ifndef _REGS_MFC_V8_H
+#define _REGS_MFC_V8_H
+
+#include 
+#include "regs-mfc-v7.h"
+
+/* Additional registers for v8 */
+#define S5P_FIMV_D_MVC_NUM_VIEWS_V80xf104
+#define S5P_FIMV_D_FIRST_PLANE_DPB_SIZE_V8 0xf144
+#define S5P_FIMV_D_SECOND_PLANE_DPB_SIZE_V80xf148
+#define S5P_FIMV_D_MV_BUFFER_SIZE_V8   0xf150
+
+#define S5P_FIMV_D_FIRST_PLANE_DPB_STRIDE_SIZE_V8  0xf138
+#define S5P_FIMV_D_SECOND_PLANE_DPB_STRIDE_SIZE_V8 0xf13c
+
+#define S5P_FIMV_D_FIRST_PLANE_DPB_V8  0xf160
+#define S5P_FIMV_D_SECOND_PLANE_DPB_V8 0xf260
+#define S5P_FIMV_D_MV_BUFFER_V80xf460
+
+#define S5P_FIMV_D_NUM_MV_V8   0xf134
+#define S5P_FIMV_D_INIT_BUFFER_OPTIONS_V8  0xf154
+
+#define S5P_FIMV_D_SCRATCH_BUFFER_ADDR_V8  0xf560
+#define S5P_FIMV_D_SCRATCH_BUFFER_SIZE_V8  0xf564
+
+#define S5P_FIMV_D_CPB_BUFFER_ADDR_V8  0xf5b0
+#define S5P_FIMV_D_CPB_BUFFER_SIZE_V8  0xf5b4
+#define S5P_FIMV_D_AVAILABLE_DPB_FLAG_LOWER_V8 0xf5bc
+#define S5P_FIMV_D_CPB_BUFFER_OFFSET_V80xf5c0
+#define S5P_FIMV_D_SLICE_IF_ENABLE_V8  0xf5c4
+#define S5P_FIMV_D_STREAM_DATA_SIZE_V8 0xf5d0
+
+/* Display information register */
+#define S5P_FIMV_D_DISPLAY_FRAME_WIDTH_V8  0xf600
+#define S5P_FIMV_D_DISPLAY_FRAME_HEIGHT_V8 0xf604
+
+/* Display status */
+#define S5P_FIMV_D_DISPLAY_STATUS_V8   0xf608
+
+#define S5P_FIMV_D_DISPLAY_FIRST_PLANE_ADDR_V8 0xf60c
+#define S5P_FIMV_D_DISPLAY_SECOND_PLANE_ADDR_V80xf610
+
+#define S5P_FIMV_D_DISPLAY_FRAME_TYPE_V8   0xf618
+#define S5P_FIMV_D_DISPLAY_CROP_INFO1_V8   0xf61c
+#define S5P_FIMV_D_DISPLAY_CROP_INFO2_V8   0xf620
+#define S5P_FIMV_D_DISPLAY_PICTURE_PROFILE_V8  0xf624
+
+/* Decoded picture information register */
+#define S5P_FIMV_D_DECODED_STATUS_V8   0xf644
+#define S5P_FIMV_D_DECODED_FIRST_PLANE_ADDR_V8 0xf648
+#define S5P_FIMV_D_DECODED_SECOND_PLANE_ADDR_V80xf64c
+#define S5P_FIMV_D_DECODED_THIRD_PLANE_ADDR_V8 0xf650
+#define S5P_FIMV_D_DECODED_FRAME_TYPE_V8   0xf654
+#define S5P_FIMV_D_DECODED_NAL_SIZE_V8  0xf664
+
+/* Returned value register for specific setting */
+#define S5P_FIMV_D_RET_PICTURE_TAG_TOP_V8  0xf674
+#define S5P_FIMV_D_RET_PICTURE_TAG_BOT_V8  0xf678
+#define S5P_FIMV_D_MVC_VIEW_ID_V8  0xf6d8
+
+/* SEI related information */
+#define S5P_FIMV_D_FRAME_PACK_SEI_AVAIL_V8 0xf6dc
+
+/* MFCv8 Context buffer sizes */
+#define MFC_CTX_BUF_SIZE_V8(30 * SZ_1K)/*  30KB */
+#define MFC_H264_DEC_CTX_BUF_SIZE_V8   (2 * SZ_1M) /*  2MB */
+#define MFC_OTHER_DEC_CTX_BUF_SIZE_V8  (20 * SZ_1K)/*  20KB */
+
+/* Buffer size defines */

[PATCH v2 4/4] [media] s5p-mfc: Core support for v8 encoder

2014-05-13 Thread Arun Kumar K
From: Kiran AVND 

This patch adds core support for v8 encoder. This
patch also adds register definitions and buffer size
requirements for H264 & VP8 encoding, needed for new
firmware version v8 for MFC

Signed-off-by: Kiran AVND 
Signed-off-by: Pawel Osciak 
Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/regs-mfc-v8.h|   30 +++
 drivers/media/platform/s5p-mfc/s5p_mfc.c|2 +
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c |   61 +++
 3 files changed, 83 insertions(+), 10 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v8.h 
b/drivers/media/platform/s5p-mfc/regs-mfc-v8.h
index c84d120..cc7cbec 100644
--- a/drivers/media/platform/s5p-mfc/regs-mfc-v8.h
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v8.h
@@ -72,16 +72,46 @@
 /* SEI related information */
 #define S5P_FIMV_D_FRAME_PACK_SEI_AVAIL_V8 0xf6dc
 
+/* Encoder Registers */
+#define S5P_FIMV_E_FIXED_PICTURE_QP_V8 0xf794
+#define S5P_FIMV_E_RC_CONFIG_V80xf798
+#define S5P_FIMV_E_RC_QP_BOUND_V8  0xf79c
+#define S5P_FIMV_E_RC_RPARAM_V80xf7a4
+#define S5P_FIMV_E_MB_RC_CONFIG_V8 0xf7a8
+#define S5P_FIMV_E_PADDING_CTRL_V8 0xf7ac
+#define S5P_FIMV_E_MV_HOR_RANGE_V8 0xf7b4
+#define S5P_FIMV_E_MV_VER_RANGE_V8 0xf7b8
+
+#define S5P_FIMV_E_VBV_BUFFER_SIZE_V8  0xf78c
+#define S5P_FIMV_E_VBV_INIT_DELAY_V8   0xf790
+
+#define S5P_FIMV_E_ASPECT_RATIO_V8 0xfb4c
+#define S5P_FIMV_E_EXTENDED_SAR_V8 0xfb50
+#define S5P_FIMV_E_H264_OPTIONS_V8 0xfb54
+
 /* MFCv8 Context buffer sizes */
 #define MFC_CTX_BUF_SIZE_V8(30 * SZ_1K)/*  30KB */
 #define MFC_H264_DEC_CTX_BUF_SIZE_V8   (2 * SZ_1M) /*  2MB */
 #define MFC_OTHER_DEC_CTX_BUF_SIZE_V8  (20 * SZ_1K)/*  20KB */
+#define MFC_H264_ENC_CTX_BUF_SIZE_V8   (100 * SZ_1K)   /* 100KB */
+#define MFC_OTHER_ENC_CTX_BUF_SIZE_V8  (10 * SZ_1K)/*  10KB */
 
 /* Buffer size defines */
+#define S5P_FIMV_TMV_BUFFER_SIZE_V8(w, h)  (((w) + 1) * ((h) + 1) * 8)
+
 #define S5P_FIMV_SCRATCH_BUF_SIZE_H264_DEC_V8(w, h)(((w) * 704) + 2176)
 #define S5P_FIMV_SCRATCH_BUF_SIZE_VP8_DEC_V8(w, h) \
(((w) * 576 + (h) * 128)  + 4128)
 
+#define S5P_FIMV_SCRATCH_BUF_SIZE_H264_ENC_V8(w, h) \
+   (((w) * 592) + 2336)
+#define S5P_FIMV_SCRATCH_BUF_SIZE_VP8_ENC_V8(w, h) \
+   (((w) * 576) + 10512 + \
+   ((w) * 16) * ((h) * 16)) * 3) / 2) * 4))
+#define S5P_FIMV_ME_BUFFER_SIZE_V8(imw, imh, mbw, mbh) \
+   ((DIV_ROUND_UP((mbw * 16), 64) *  DIV_ROUND_UP((mbh * 16), 64) * 256) \
++ (DIV_ROUND_UP((mbw) * (mbh), 32) * 16))
+
 /* BUffer alignment defines */
 #define S5P_FIMV_D_ALIGN_PLANE_SIZE_V8 64
 
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index c8d7ba0..ea72502 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -1441,6 +1441,8 @@ struct s5p_mfc_buf_size_v6 mfc_buf_size_v8 = {
.dev_ctx= MFC_CTX_BUF_SIZE_V8,
.h264_dec_ctx   = MFC_H264_DEC_CTX_BUF_SIZE_V8,
.other_dec_ctx  = MFC_OTHER_DEC_CTX_BUF_SIZE_V8,
+   .h264_enc_ctx   = MFC_H264_ENC_CTX_BUF_SIZE_V8,
+   .other_enc_ctx  = MFC_OTHER_ENC_CTX_BUF_SIZE_V8,
 };
 
 struct s5p_mfc_buf_size buf_size_v8 = {
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
index eeaf122..43d0bb8 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
@@ -80,7 +80,12 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct s5p_mfc_ctx 
*ctx)
  ctx->luma_size, ctx->chroma_size, ctx->mv_size);
mfc_debug(2, "Totals bufs: %d\n", ctx->total_dpb_count);
} else if (ctx->type == MFCINST_ENCODER) {
-   ctx->tmv_buffer_size = S5P_FIMV_NUM_TMV_BUFFERS_V6 *
+   if (IS_MFCV8(dev))
+   ctx->tmv_buffer_size = S5P_FIMV_NUM_TMV_BUFFERS_V6 *
+   ALIGN(S5P_FIMV_TMV_BUFFER_SIZE_V8(mb_width, mb_height),
+   S5P_FIMV_TMV_BUFFER_ALIGN_V6);
+   else
+   ctx->tmv_buffer_size = S5P_FIMV_NUM_TMV_BUFFERS_V6 *
ALIGN(S5P_FIMV_TMV_BUFFER_SIZE_V6(mb_width, mb_height),
S5P_FIMV_TMV_BUFFER_ALIGN_V6);
 
@@ -90,10 +95,16 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct 
s5p_mfc_ctx *ctx)
ctx->chroma_dpb_size = ALIGN((mb_width * mb_height) *
S5P_FIMV_CHROMA_MB_TO_PIXEL_V6,
S5P_FIMV_CHROMA_DPB_BUFFER_ALIGN_V6);
-   ctx->me_buffer_size = ALIGN(S5P_FIMV_ME_BUFFER_SIZE_V6(
-  

[PATCH v2 2/4] [media] s5p-mfc: Rename IS_MFCV7 macro

2014-05-13 Thread Arun Kumar K
Renaming the IS_MFCV7 macro to IS_MFCV7_PLUS for the
addition of MFCv8 support which reuses the v7 code.

Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h |2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c|2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c |   14 +++---
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h 
b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index 8d85590..7b7053d 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -706,6 +706,6 @@ void set_work_bit_irqsave(struct s5p_mfc_ctx *ctx);
(dev->variant->port_num ? 1 : 0) : 0) : 0)
 #define IS_TWOPORT(dev)(dev->variant->port_num == 2 ? 1 : 0)
 #define IS_MFCV6_PLUS(dev) (dev->variant->version >= 0x60 ? 1 : 0)
-#define IS_MFCV7(dev)  (dev->variant->version >= 0x70 ? 1 : 0)
+#define IS_MFCV7_PLUS(dev) (dev->variant->version >= 0x70 ? 1 : 0)
 
 #endif /* S5P_MFC_COMMON_H_ */
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index 0c8d593e..e7dddb0 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -1049,7 +1049,7 @@ static int vidioc_try_fmt(struct file *file, void *priv, 
struct v4l2_format *f)
return -EINVAL;
}
 
-   if (!IS_MFCV7(dev) && (fmt->fourcc == V4L2_PIX_FMT_VP8)) {
+   if (!IS_MFCV7_PLUS(dev) && (fmt->fourcc == V4L2_PIX_FMT_VP8)) {
mfc_err("VP8 is supported only in MFC v7\n");
return -EINVAL;
}
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
index 47890e8..9a503ca 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
@@ -116,7 +116,7 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct 
s5p_mfc_ctx *ctx)
(ctx->mv_count * ctx->mv_size);
break;
case S5P_MFC_CODEC_MPEG4_DEC:
-   if (IS_MFCV7(dev)) {
+   if (IS_MFCV7_PLUS(dev)) {
ctx->scratch_buf_size =
S5P_FIMV_SCRATCH_BUF_SIZE_MPEG4_DEC_V7(
mb_width,
@@ -357,7 +357,7 @@ static void s5p_mfc_enc_calc_src_size_v6(struct s5p_mfc_ctx 
*ctx)
ctx->chroma_size = ALIGN((mb_width * mb_height) * 128, 256);
 
/* MFCv7 needs pad bytes for Luma and Chroma */
-   if (IS_MFCV7(ctx->dev)) {
+   if (IS_MFCV7_PLUS(ctx->dev)) {
ctx->luma_size += MFC_LUMA_PAD_BYTES_V7;
ctx->chroma_size += MFC_CHROMA_PAD_BYTES_V7;
}
@@ -1283,7 +1283,7 @@ static int s5p_mfc_set_enc_params_vp8(struct s5p_mfc_ctx 
*ctx)
 /* Check if newer v6 firmware with changed init buffer interface */
 static bool s5p_mfc_is_v6_fw_v2(struct s5p_mfc_dev *dev)
 {
-   if (IS_MFCV7(dev))
+   if (IS_MFCV7_PLUS(dev))
return false;
/*
 * FW date is in BCD format xx120629. So checking for
@@ -1320,7 +1320,7 @@ static int s5p_mfc_init_decode_v6(struct s5p_mfc_ctx *ctx)
WRITEL(ctx->display_delay, mfc_regs->d_display_delay);
}
 
-   if (IS_MFCV7(dev) || s5p_mfc_is_v6_fw_v2(dev)) {
+   if (IS_MFCV7_PLUS(dev) || s5p_mfc_is_v6_fw_v2(dev)) {
WRITEL(reg, mfc_regs->d_dec_options);
reg = 0;
}
@@ -1335,7 +1335,7 @@ static int s5p_mfc_init_decode_v6(struct s5p_mfc_ctx *ctx)
if (ctx->dst_fmt->fourcc == V4L2_PIX_FMT_NV12MT_16X16)
reg |= (0x1 << S5P_FIMV_D_OPT_TILE_MODE_SHIFT_V6);
 
-   if (IS_MFCV7(dev) || s5p_mfc_is_v6_fw_v2(dev))
+   if (IS_MFCV7_PLUS(dev) || s5p_mfc_is_v6_fw_v2(dev))
WRITEL(reg, mfc_regs->d_init_buffer_options);
else
WRITEL(reg, mfc_regs->d_dec_options);
@@ -1423,7 +1423,7 @@ static int s5p_mfc_init_encode_v6(struct s5p_mfc_ctx *ctx)
}
 
/* Set stride lengths for v7 & above */
-   if (IS_MFCV7(dev)) {
+   if (IS_MFCV7_PLUS(dev)) {
WRITEL(ctx->img_width, mfc_regs->e_source_first_plane_stride);
WRITEL(ctx->img_width, mfc_regs->e_source_second_plane_stride);
}
@@ -2165,7 +2165,7 @@ const struct s5p_mfc_regs 
*s5p_mfc_init_regs_v6_plus(struct s5p_mfc_dev *dev)
R(e_h264_frame_packing_sei_info,
S5P_FIMV_E_H264_FRAME_PACKING_SEI_INFO_V6);
 
-   if (!IS_MFCV7(dev))
+   if (!IS_MFCV7_PLUS(dev))
goto done;
 
/* Initialize registers used in MFC v7 */
-- 
1.7.

[PATCH v2 0/4] Add MFCv8 support

2014-05-13 Thread Arun Kumar K
This patchset adds MFCv8 support to the s5p-mfc driver.
MFCv8 has the same operation sequence as that of v6+, but
there is some shuffling of the registers happened. So to
re-use the exisiting code, register access uses context
variables instead of macros.
The patchset modifies opr_v6 file to use register variables
and is tested on mfc v5, v6, v7 and v8 based boards.

The patchset is based on the following set of patches
posted for MFC which are currently under review:

s5p-mfc: Update scratch buffer size for MPEG4
s5p-mfc: Add support for resolution change event
v4l: Add source change event
s5p-mfc: Don't try to resubmit VP8 bitstream buffer for decode.
s5p-mfc: Update scratch buffer size for VP8 encoder
s5p-mfc: Dequeue sequence header after STREAMON
s5p-mfc: Don't allocate codec buffers on STREAMON.
s5p-mfc: Extract open/close MFC instance commands.
s5p-mfc: Fixes for decode REQBUFS.
s5p-mfc: Copy timestamps only when a frame is produced.
s5p-mfc: add init buffer cmd to MFCV6
s5p-mfc: Add a control for IVF format for VP8 encoder

Changes from v1
- Included encoder support for v8 patch
- Addressed review comments from Kamil & Sachin
  https://patchwork.linuxtv.org/patch/23770/
  https://patchwork.linuxtv.org/patch/23768/

Arun Kumar K (1):
  [media] s5p-mfc: Rename IS_MFCV7 macro

Kiran AVND (3):
  [media] s5p-mfc: Add variants to access mfc registers
  [media] s5p-mfc: Core support to add v8 decoder
  [media] s5p-mfc: Core support for v8 encoder

 .../devicetree/bindings/media/s5p-mfc.txt  |3 +-
 drivers/media/platform/s5p-mfc/regs-mfc-v8.h   |  124 +++
 drivers/media/platform/s5p-mfc/s5p_mfc.c   |   33 +
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h|7 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c   |4 +
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c   |2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_opr.c   |6 +
 drivers/media/platform/s5p-mfc/s5p_mfc_opr.h   |  254 ++
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c|  849 +---
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.h|7 +-
 10 files changed, 1007 insertions(+), 282 deletions(-)
 create mode 100644 drivers/media/platform/s5p-mfc/regs-mfc-v8.h

-- 
1.7.9.5

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


[PATCH] [media] s5p-mfc: Update scratch buffer size for MPEG4

2014-05-13 Thread Arun Kumar K
Update the MPEG4 decoder scratch buffer size as per the
new v6 firmware. This updation is increasing the size and so
is backward compatible with older v6 firmwares.

Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/regs-mfc-v6.h |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h 
b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
index b47567c..fd04f84 100644
--- a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
@@ -382,8 +382,7 @@
 (DIV_ROUND_UP((mbw) * (mbh), 32) * 16))
 #define S5P_FIMV_SCRATCH_BUF_SIZE_H264_DEC_V6(w, h)(((w) * 192) + 64)
 #define S5P_FIMV_SCRATCH_BUF_SIZE_MPEG4_DEC_V6(w, h) \
-   ((w) * ((h) * 64 + 144) + (2048/16 * (h) * 64) + \
-(2048/16 * 256 + 8320))
+   ((w) * 144 + 8192 * (h) + 49216 + 1048576)
 #define S5P_FIMV_SCRATCH_BUF_SIZE_VC1_DEC_V6(w, h) \
(2096 * ((w) + (h) + 1))
 #define S5P_FIMV_SCRATCH_BUF_SIZE_H263_DEC_V6(w, h)((w) * 400)
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 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] s5p-mfc: Dequeue sequence header after STREAMON

2014-05-13 Thread Arun Kumar K
MFCv6 encoder needs specific minimum number of buffers to
be queued in the CAPTURE plane. This minimum number will
be known only when the sequence header is generated.
So we used to allow STREAMON on the CAPTURE plane only after
sequence header is generated and checked with the minimum
buffer requirement.

But this causes a problem that we call a vb2_buffer_done
for the sequence header buffer before doing a STREAON on the
CAPTURE plane. This used to still work fine until this patch
was merged -
b3379c6 : vb2: only call start_streaming if sufficient buffers are queued

This problem should also come in earlier MFC firmware versions
if the application calls STREAMON on CAPTURE with some delay
after doing STREAMON on OUTPUT.

So this patch keeps the header buffer until the other frame
buffers are ready and dequeues it just before the first frame
is ready.

Signed-off-by: Arun Kumar K 
---
Changes from v1
- Addressed review comments from Sachin
  https://patchwork.linuxtv.org/patch/23839/
---
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h |2 ++
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c|6 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h 
b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index f5404a6..cc2b96e 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -523,6 +523,7 @@ struct s5p_mfc_codec_ops {
  * @output_state:  state of the output buffers queue
  * @src_bufs:  information on allocated source buffers
  * @dst_bufs:  information on allocated destination buffers
+ * @header_mb: buffer pointer of the encoded sequence header
  * @sequence:  counter for the sequence number for v4l2
  * @dec_dst_flag:  flags for buffers queued in the hardware
  * @dec_src_buf_size:  size of the buffer for source buffers in decoding
@@ -607,6 +608,7 @@ struct s5p_mfc_ctx {
int src_bufs_cnt;
struct s5p_mfc_buf dst_bufs[MFC_MAX_BUFFERS];
int dst_bufs_cnt;
+   struct s5p_mfc_buf *header_mb;
 
unsigned int sequence;
unsigned long dec_dst_flag;
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index f8c7053..0c8d593e 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -787,7 +787,7 @@ static int enc_post_seq_start(struct s5p_mfc_ctx *ctx)
ctx->dst_queue_cnt--;
vb2_set_plane_payload(dst_mb->b, 0,
s5p_mfc_hw_call(dev->mfc_ops, get_enc_strm_size, dev));
-   vb2_buffer_done(dst_mb->b, VB2_BUF_STATE_DONE);
+   ctx->header_mb = dst_mb;
spin_unlock_irqrestore(&dev->irqlock, flags);
}
 
@@ -845,6 +845,10 @@ static int enc_post_frame_start(struct s5p_mfc_ctx *ctx)
unsigned int strm_size;
unsigned long flags;
 
+   if (ctx->header_mb) {
+   vb2_buffer_done(ctx->header_mb->b, VB2_BUF_STATE_DONE);
+   ctx->header_mb = NULL;
+   }
slice_type = s5p_mfc_hw_call(dev->mfc_ops, get_enc_slice_type, dev);
strm_size = s5p_mfc_hw_call(dev->mfc_ops, get_enc_strm_size, dev);
mfc_debug(2, "Encoded slice type: %d\n", slice_type);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 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] s5p-mfc: Don't allocate codec buffers on STREAMON.

2014-05-13 Thread Arun Kumar K
From: Pawel Osciak 

Currently, we allocate private codec buffers on STREAMON, which may fail
if we are out of memory. We don't check for failure though, which will
make us crash with the codec accessing random memory.

We shouldn't be failing STREAMON with out of memory errors though. So move
the allocation of private codec buffers to REQBUFS for OUTPUT queue. Also,
move MFC instance opening and closing to REQBUFS as well, as it's tied to
allocation and deallocation of private codec buffers.

Signed-off-by: Pawel Osciak 
Signed-off-by: Arun Kumar K 
---
Posting only patch 3/3 of the patchset -
MFC cleanup of reqbuf, streamon, open and close
addressing a minor comment from Kamil.
Other dependent patches are:
s5p-mfc: Extract open/close MFC instance commands.
s5p-mfc: Fixes for decode REQBUFS.

Changes from v1
- Addressed review comment from Kamil
  https://patchwork.linuxtv.org/patch/23162/
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c  |8 +++
 drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c |1 +
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c  |   30 +++--
 3 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 2faf7e6..aa08aa2 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -650,6 +650,7 @@ static irqreturn_t s5p_mfc_irq(int irq, void *priv)
 
case S5P_MFC_R2H_CMD_CLOSE_INSTANCE_RET:
clear_work_bit(ctx);
+   ctx->inst_no = MFC_NO_INSTANCE_SET;
ctx->state = MFCINST_FREE;
wake_up(&ctx->queue);
goto irq_cleanup_hw;
@@ -770,7 +771,7 @@ static int s5p_mfc_open(struct file *file)
goto err_bad_node;
}
ctx->fh.ctrl_handler = &ctx->ctrl_handler;
-   ctx->inst_no = -1;
+   ctx->inst_no = MFC_NO_INSTANCE_SET;
/* Load firmware if this is the first instance */
if (dev->num_inst == 1) {
dev->watchdog_timer.expires = jiffies +
@@ -880,12 +881,11 @@ static int s5p_mfc_release(struct file *file)
vb2_queue_release(&ctx->vq_dst);
/* Mark context as idle */
clear_work_bit_irqsave(ctx);
-   /* If instance was initialised then
+   /* If instance was initialised and not yet freed,
 * return instance and free resources */
-   if (ctx->inst_no != MFC_NO_INSTANCE_SET) {
+   if (ctx->state != MFCINST_FREE && ctx->state != MFCINST_INIT) {
mfc_debug(2, "Has to free instance\n");
s5p_mfc_close_mfc_inst(dev, ctx);
-   ctx->inst_no = MFC_NO_INSTANCE_SET;
}
/* hardware locking scheme */
if (dev->curr_ctx == ctx->num)
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
index 84d4f9d..2001a75 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
@@ -459,5 +459,6 @@ void s5p_mfc_close_mfc_inst(struct s5p_mfc_dev *dev, struct 
s5p_mfc_ctx *ctx)
if (ctx->type == MFCINST_DECODER)
s5p_mfc_hw_call(dev->mfc_ops, release_dec_desc_buffer, ctx);
 
+   ctx->inst_no = MFC_NO_INSTANCE_SET;
ctx->state = MFCINST_FREE;
 }
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
index efc78ae..4586186 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
@@ -475,11 +475,11 @@ static int reqbufs_output(struct s5p_mfc_dev *dev, struct 
s5p_mfc_ctx *ctx,
ret = vb2_reqbufs(&ctx->vq_src, reqbufs);
if (ret)
goto out;
+   s5p_mfc_close_mfc_inst(dev, ctx);
ctx->src_bufs_cnt = 0;
+   ctx->output_state = QUEUE_FREE;
} else if (ctx->output_state == QUEUE_FREE) {
-   /* Can only request buffers after the instance
-* has been opened.
-*/
+   /* Can only request buffers when we have a valid format set. */
WARN_ON(ctx->src_bufs_cnt != 0);
if (ctx->state != MFCINST_INIT) {
mfc_err("Reqbufs called in an invalid state\n");
@@ -493,6 +493,13 @@ static int reqbufs_output(struct s5p_mfc_dev *dev, struct 
s5p_mfc_ctx *ctx,
if (ret)
goto out;
 
+   ret = s5p_mfc_open_mfc_inst(dev, ctx);
+   if (ret) {
+   reqbufs->count = 0;
+   vb2_reqbufs(&ctx->vq_src, reqbufs);
+   goto out;
+   }
+
ctx->output_state = QUEUE_BUFS_REQUESTED;
} else {
mfc_err(

[PATCH v3] [media] s5p-mfc: add init buffer cmd to MFCV6

2014-05-13 Thread Arun Kumar K
From: avnd kiran 

Latest MFC v6 firmware requires tile mode and loop filter
setting to be done as part of Init buffer command, in sync
with v7. Since there are two versions of v6 firmware with
different interfaces, it is differenciated using the version
number read back from firmware which is a hexadecimal value
based on the firmware date.

Signed-off-by: avnd kiran 
Signed-off-by: Arun Kumar K 
---
Changes from v2
- Addressed Kamil's comment
  https://patchwork.linuxtv.org/patch/22989/
Changes from v1
- Check for v6 firmware date for differenciating old and new firmware
  as per comments from Kamil and Sylwester.
---
 drivers/media/platform/s5p-mfc/regs-mfc-v6.h|1 +
 drivers/media/platform/s5p-mfc/regs-mfc-v7.h|2 --
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h |2 ++
 drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c   |8 
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c |   21 ++---
 5 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h 
b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
index 8d0b686..b47567c 100644
--- a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
@@ -132,6 +132,7 @@
 #define S5P_FIMV_D_METADATA_BUFFER_ADDR_V6 0xf448
 #define S5P_FIMV_D_METADATA_BUFFER_SIZE_V6 0xf44c
 #define S5P_FIMV_D_NUM_MV_V6   0xf478
+#define S5P_FIMV_D_INIT_BUFFER_OPTIONS_V6  0xf47c
 #define S5P_FIMV_D_CPB_BUFFER_ADDR_V6  0xf4b0
 #define S5P_FIMV_D_CPB_BUFFER_SIZE_V6  0xf4b4
 
diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v7.h 
b/drivers/media/platform/s5p-mfc/regs-mfc-v7.h
index ea5ec2a..82c96fa 100644
--- a/drivers/media/platform/s5p-mfc/regs-mfc-v7.h
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v7.h
@@ -18,8 +18,6 @@
 #define S5P_FIMV_CODEC_VP8_ENC_V7  25
 
 /* Additional registers for v7 */
-#define S5P_FIMV_D_INIT_BUFFER_OPTIONS_V7  0xf47c
-
 #define S5P_FIMV_E_SOURCE_FIRST_ADDR_V70xf9e0
 #define S5P_FIMV_E_SOURCE_SECOND_ADDR_V7   0xf9e4
 #define S5P_FIMV_E_SOURCE_THIRD_ADDR_V70xf9e8
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h 
b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index 4d17df9..f5404a6 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -287,6 +287,7 @@ struct s5p_mfc_priv_buf {
  * @warn_start:hardware error code from which warnings start
  * @mfc_ops:   ops structure holding HW operation function pointers
  * @mfc_cmds:  cmd structure holding HW commands function pointers
+ * @ver:   firmware sub version
  *
  */
 struct s5p_mfc_dev {
@@ -330,6 +331,7 @@ struct s5p_mfc_dev {
int warn_start;
struct s5p_mfc_hw_ops *mfc_ops;
struct s5p_mfc_hw_cmds *mfc_cmds;
+   int ver;
 };
 
 /**
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
index ee05f2d..b86744f 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
@@ -238,7 +238,6 @@ static inline void s5p_mfc_clear_cmds(struct s5p_mfc_dev 
*dev)
 /* Initialize hardware */
 int s5p_mfc_init_hw(struct s5p_mfc_dev *dev)
 {
-   unsigned int ver;
int ret;
 
mfc_debug_enter();
@@ -300,12 +299,13 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev)
return -EIO;
}
if (IS_MFCV6_PLUS(dev))
-   ver = mfc_read(dev, S5P_FIMV_FW_VERSION_V6);
+   dev->ver = mfc_read(dev, S5P_FIMV_FW_VERSION_V6);
else
-   ver = mfc_read(dev, S5P_FIMV_FW_VERSION);
+   dev->ver = mfc_read(dev, S5P_FIMV_FW_VERSION);
 
mfc_debug(2, "MFC F/W version : %02xyy, %02xmm, %02xdd\n",
-   (ver >> 16) & 0xFF, (ver >> 8) & 0xFF, ver & 0xFF);
+   (dev->ver >> 16) & 0xFF, (dev->ver >> 8) & 0xFF,
+   dev->ver & 0xFF);
s5p_mfc_clock_off();
mfc_debug_leave();
return 0;
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
index 90edb19..444f0e8 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
@@ -48,6 +48,9 @@
 #define OFFSETA(x) (((x) - dev->port_a) >> S5P_FIMV_MEM_OFFSET)
 #define OFFSETB(x) (((x) - dev->port_b) >> S5P_FIMV_MEM_OFFSET)
 
+/* v2 interface version date of MFCv6 firmware */
+#define MFC_V6_FIRMWARE_INTERFACE_V2 0x120629
+
 /* Allocate temporary buffers for decoding */
 static int s5p_mfc_alloc_dec_temp_buffers_v6(struct s5p_mfc_ctx *ctx)
 {
@@ -1269,6 +1272,18 @@ static int s5p_mfc_set_enc_params_vp8(struct s5p_mfc_ctx 
*ctx)

Re: [PATCH] [media] s5p-mfc: Dequeue sequence header after STREAMON

2014-05-13 Thread Arun Kumar K
Hi Sachin,

Thank you for the review.
Will address your comments and post updated version.

Regards
Arun

On Thu, May 8, 2014 at 3:09 PM, Sachin Kamat  wrote:
> Hi Arun,
>
> Just 2 small nits.
>
> On 7 May 2014 17:00, Arun Kumar K  wrote:
>> MFCv6 encoder needs specific minimum number of buffers to
>> be queued in the CAPTURE plane. This minimum number will
>> be known only when the sequence header is generated.
>> So we used to allow STREAMON on the CAPTURE plane only after
>> sequence header is generated and checked with the minimum
>> buffer requirement.
>>
>> But this causes a problem that we call a vb2_buffer_done
>> for the sequence header buffer before doing a STREAON on the
>> CAPTURE plane. This used to still work fine until this patch
>> was merged b3379c6201bb3555298cdbf0aa004af260f2a6a4.
>
> Please provide the patch title too along with commit ID
> (first 12 characters of ID is enough).
>
>>
>> This problem should also come in earlier MFC firmware versions
>> if the application calls STREAMON on CAPTURE with some delay
>> after doing STREAMON on OUTPUT.
>>
>> So this patch keeps the header buffer until the other frame
>> buffers are ready and dequeues it just before the first frame
>> is ready.
>>
>> Signed-off-by: Arun Kumar K 
>> ---
>>  drivers/media/platform/s5p-mfc/s5p_mfc_common.h |2 ++
>>  drivers/media/platform/s5p-mfc/s5p_mfc_enc.c|6 +-
>>  2 files changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h 
>> b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
>> index d64b680..4fd1034 100644
>> --- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
>> +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
>> @@ -523,6 +523,7 @@ struct s5p_mfc_codec_ops {
>>   * @output_state:  state of the output buffers queue
>>   * @src_bufs:  information on allocated source buffers
>>   * @dst_bufs:  information on allocated destination buffers
>> + * @header_mb: buf pointer of the encoded sequence header
>
> s/buf/buffer
>
> --
> With warm regards,
> Sachin
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 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/3] [media] s5p-mfc: Add variants to access mfc registers

2014-05-13 Thread Arun Kumar K
Hi Kamil,

On 05/13/14 16:02, Kamil Debski wrote:
> Hi, 
> 
> One small comment below,
> 
>> -Original Message-----
>> From: Arun Kumar K [mailto:arunkk.sams...@gmail.com] On Behalf Of Arun
>> Kumar K
>> Sent: Wednesday, April 23, 2014 2:58 PM
>> To: linux-me...@vger.kernel.org; linux-samsung-soc@vger.kernel.org
>> Cc: k.deb...@samsung.com; s.nawro...@samsung.com; posc...@chromium.org;
>> avnd.ki...@samsung.com; arunkk.sams...@gmail.com
>> Subject: [PATCH 1/3] [media] s5p-mfc: Add variants to access mfc
>> registers
>>
>> From: Kiran AVND 
>>
>> This patch is needed in preparation to add MFC V8
>> where the register offsets are changed w.r.t MFC V6/V7.
>>
>> This patch adds variants of MFC V6 and V7 while
>> accessing MFC registers. Registers are kept in mfc context
>> and are initialized to a particular MFC variant during probe,
>> which is used instead of macros.
>>
>> This avoids duplication of the code for MFC variants
>> V6 & V7, and reduces the if_else checks while accessing
>> registers of different MFC variants.
>>
>> Signed-off-by: Kiran AVND 
>> Signed-off-by: Pawel Osciak 
>> Signed-off-by: Arun Kumar K 
>> ---
>>  drivers/media/platform/s5p-mfc/s5p_mfc.c|1 +
>>  drivers/media/platform/s5p-mfc/s5p_mfc_common.h |1 +
>>  drivers/media/platform/s5p-mfc/s5p_mfc_opr.c|6 +
>>  drivers/media/platform/s5p-mfc/s5p_mfc_opr.h|  254 +
>>  drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c |  697
>> +++
>>  drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.h |7 +-
>>  6 files changed, 710 insertions(+), 256 deletions(-)
>>

[snip]

>>  if (p_h264->fmo) {
>> @@ -988,10 +991,12 @@ static int s5p_mfc_set_enc_params_h264(struct
>> s5p_mfc_ctx *ctx)
>>  case V4L2_MPEG_VIDEO_H264_FMO_MAP_TYPE_INTERLEAVED_SLICES:
>>  if (p_h264->fmo_slice_grp > 4)
>>  p_h264->fmo_slice_grp = 4;
>> -for (i = 0; i < (p_h264->fmo_slice_grp & 0xF); i++)
>> +for (i = 0; i < ARRAY_SIZE(p_h264->fmo_run_len)
>> +&& i < p_h264->fmo_slice_grp; i++) {
> 
> What do you think about moving this to separate path? This seems
> like it slipped with the register patches.
> 

Sure I will remove this change from this patch. Thanks for spotting this.

Regards
Arun

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


Re: [PATCH v4 1/2] [media] v4l: Add source change event

2014-05-13 Thread Arun Kumar K
Hi Hans,

Will make the changes you suggested.

Thanks & regards
Arun

On Tue, May 13, 2014 at 1:30 PM, Hans Verkuil  wrote:
> Hi Arun,
>
> I've got some more comments w.r.t. the documentation:
>
> On 05/13/14 07:59, Arun Kumar K wrote:
>> This event indicates that the video device has encountered
>> a source parameter change during runtime. This can typically be a
>> resolution change detected by a video decoder OR a format change
>> detected by an HDMI connector.
>>
>> This needs to be nofified to the userspace and the application may
>> be expected to reallocate buffers before proceeding. The application
>> can subscribe to events on a specific pad or input port which
>> it is interested in.
>>
>> Signed-off-by: Arun Kumar K 
>> ---
>>  Documentation/DocBook/media/v4l/vidioc-dqevent.xml |   32 +
>>  .../DocBook/media/v4l/vidioc-subscribe-event.xml   |   19 +++
>>  drivers/media/v4l2-core/v4l2-event.c   |   36 
>> 
>>  include/media/v4l2-event.h |4 +++
>>  include/uapi/linux/videodev2.h |8 +
>>  5 files changed, 99 insertions(+)
>>
>> diff --git a/Documentation/DocBook/media/v4l/vidioc-dqevent.xml 
>> b/Documentation/DocBook/media/v4l/vidioc-dqevent.xml
>> index 89891ad..6afabaa 100644
>> --- a/Documentation/DocBook/media/v4l/vidioc-dqevent.xml
>> +++ b/Documentation/DocBook/media/v4l/vidioc-dqevent.xml
>> @@ -242,6 +242,22 @@
>>
>>  
>>
>> +
>> +  struct v4l2_event_src_change
>> +  
>> + &cs-str;
>> + 
>> +   
>> + __u32
>> + changes
>> + 
>> +   A bitmask that tells what has changed. See > linkend="src-changes-flags" />.
>> + 
>> +   
>> + 
>> +  
>> +
>> +
>>  
>>Changes
>>
>> @@ -270,6 +286,22 @@
>>   
>>
>>  
>> +
>> +
>> +  Source Changes
>> +  
>> + &cs-def;
>> + 
>> +   
>> + V4L2_EVENT_SRC_CH_RESOLUTION
>> + 0x0001
>> + This event gets triggered when a resolution change is
>> + detected at runtime. This can typically come from a video decoder.
>
> I would rewrite this as:
>
> "This event gets triggered when a resolution change is detected at an input.
> This can come from an input connector or from a video decoder."
>
>> + 
>> +   
>> + 
>> +  
>> +
>>
>>
>>  &return-value;
>> diff --git a/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml 
>> b/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml
>> index 5c70b61..067a0d5 100644
>> --- a/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml
>> +++ b/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml
>> @@ -155,6 +155,25 @@
>>   
>> 
>> 
>> + V4L2_EVENT_SOURCE_CHANGE
>> + 5
>> + 
>> +   This event is triggered when a source parameter change is
>> +detected during runtime by the video device. It can be a
>> +runtime resolution change triggered by a video decoder or the
>> +format change happening on an HDMI connector.
>
> s/an HDMI/an input/
>
> It's valid for e.g. a composite input as well (or DVI, or VGA, etc.)
>
>> +This event requires that the id
>> +matches the pad / input index from which you want to receive
>
> This should be more explicit:
>
> "matches the input index (when used with a video device node) or the pad
> index (when used with a subdevice node) from which you want to receive"
>
>> +events.
>> +  This event has a &v4l2-event-source-change; associated
>> +   with it. The changes bitfield denotes
>> +   what has changed for the subscribed pad. If multiple events
>> +   occured before application could dequeue them, then the changes
>
> s/occured/occurred/
>
>> +   will have the ORed value of all the events generated.
>> + 
>> +   
>> +   
>>   V4L2_EVENT_PRIVATE_START
>>   0x0800
>>   Base event number for driver-private events.
>> diff --git a/drivers/media/v4l2-core/v4l2-event.c 
>> b/drivers/media/v4l2-core/v4l2-e

Re: [PATCH v4 2/2] [media] s5p-mfc: Add support for resolution change event

2014-05-13 Thread Arun Kumar K
Hi Hans,

On Tue, May 13, 2014 at 1:29 PM, Hans Verkuil  wrote:
> On 05/13/14 07:59, Arun Kumar K wrote:
>> From: Pawel Osciak 
>>
>> When a resolution change point is reached, queue an event to signal the
>> userspace that a new set of buffers is required before decoding can
>> continue.
>>
>> Signed-off-by: Pawel Osciak 
>> Signed-off-by: Arun Kumar K 
>> ---
>>  drivers/media/platform/s5p-mfc/s5p_mfc.c |7 +++
>>  drivers/media/platform/s5p-mfc/s5p_mfc_dec.c |2 ++
>>  2 files changed, 9 insertions(+)
>>
>> diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
>> b/drivers/media/platform/s5p-mfc/s5p_mfc.c
>> index 54f7ba1..2d7d1ae 100644
>> --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
>> +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
>> @@ -320,6 +320,7 @@ static void s5p_mfc_handle_frame(struct s5p_mfc_ctx *ctx,
>>   struct s5p_mfc_buf *src_buf;
>>   unsigned long flags;
>>   unsigned int res_change;
>> + struct v4l2_event ev;
>>
>>   dst_frame_status = s5p_mfc_hw_call(dev->mfc_ops, get_dspl_status, dev)
>>   & S5P_FIMV_DEC_STATUS_DECODING_STATUS_MASK;
>> @@ -351,6 +352,12 @@ static void s5p_mfc_handle_frame(struct s5p_mfc_ctx 
>> *ctx,
>>   if (ctx->state == MFCINST_RES_CHANGE_FLUSH) {
>>   s5p_mfc_handle_frame_all_extracted(ctx);
>>   ctx->state = MFCINST_RES_CHANGE_END;
>> +
>> + memset(&ev, 0, sizeof(struct v4l2_event));
>> + ev.type = V4L2_EVENT_SOURCE_CHANGE;
>> + ev.u.src_change.changes = V4L2_EVENT_SRC_CH_RESOLUTION;
>
> I would replace this by:
>
> static const struct v4l2_event ev_src_ch = {
> .type = V4L2_EVENT_SOURCE_CHANGE,
> .u.src_change.changes = V4L2_EVENT_SRC_CH_RESOLUTION,
> };
>
> No need for memsets or filling in structs at runtime.
>

Ok will make this change.

Regards
Arun

> Regards,
>
> Hans
>
>> + v4l2_event_queue_fh(&ctx->fh, &ev);
>> +
>>   goto leave_handle_frame;
>>   } else {
>>   s5p_mfc_handle_frame_all_extracted(ctx);
>> diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c 
>> b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
>> index 4f94491..b383829 100644
>> --- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
>> +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
>> @@ -855,6 +855,8 @@ static int vidioc_subscribe_event(struct v4l2_fh *fh,
>>   switch (sub->type) {
>>   case V4L2_EVENT_EOS:
>>   return v4l2_event_subscribe(fh, sub, 2, NULL);
>> + case V4L2_EVENT_SOURCE_CHANGE:
>> + return v4l2_src_change_event_subscribe(fh, sub);
>>   default:
>>   return -EINVAL;
>>   }
>>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 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] [media] s5p-mfc: add init buffer cmd to MFCV6

2014-05-13 Thread Arun Kumar K
Hi Kamil,

On Tue, May 13, 2014 at 2:49 PM, Kamil Debski  wrote:
> Hi,
>
>> From: Arun Kumar K [mailto:arunkk.sams...@gmail.com] On Behalf Of Arun
>> Kumar K
>> Sent: Tuesday, March 11, 2014 10:16 AM
>>
>> From: avnd kiran 
>>
>> Latest MFC v6 firmware requires tile mode and loop filter setting to be
>> done as part of Init buffer command, in sync with v7. Since there are
>> two versions of v6 firmware with different interfaces, it is
>> differenciated using the version number read back from firmware which
>> is a hexadecimal value based on the firmware date.
>>
>> Signed-off-by: avnd kiran 
>> Signed-off-by: Arun Kumar K 
>> ---
>> Changes from v1
>> ---
>> - Check for v6 firmware date for differenciating old and new firmware
>>   as per comments from Kamil and Sylwester.
>> ---
>>  drivers/media/platform/s5p-mfc/regs-mfc-v6.h|1 +
>>  drivers/media/platform/s5p-mfc/regs-mfc-v7.h|2 --
>>  drivers/media/platform/s5p-mfc/s5p_mfc_common.h |2 ++
>>  drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c   |8 +++---
>>  drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c |   30
>> ---
>>  5 files changed, 34 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
>> b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
>> index 8d0b686..b47567c 100644
>> --- a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
>> +++ b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
>> @@ -132,6 +132,7 @@
>>  #define S5P_FIMV_D_METADATA_BUFFER_ADDR_V6   0xf448
>>  #define S5P_FIMV_D_METADATA_BUFFER_SIZE_V6   0xf44c
>>  #define S5P_FIMV_D_NUM_MV_V6 0xf478
>> +#define S5P_FIMV_D_INIT_BUFFER_OPTIONS_V60xf47c
>>  #define S5P_FIMV_D_CPB_BUFFER_ADDR_V60xf4b0
>>  #define S5P_FIMV_D_CPB_BUFFER_SIZE_V60xf4b4
>>
>> diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v7.h
>> b/drivers/media/platform/s5p-mfc/regs-mfc-v7.h
>> index ea5ec2a..82c96fa 100644
>> --- a/drivers/media/platform/s5p-mfc/regs-mfc-v7.h
>> +++ b/drivers/media/platform/s5p-mfc/regs-mfc-v7.h
>> @@ -18,8 +18,6 @@
>>  #define S5P_FIMV_CODEC_VP8_ENC_V725
>>
>>  /* Additional registers for v7 */
>> -#define S5P_FIMV_D_INIT_BUFFER_OPTIONS_V70xf47c
>> -
>>  #define S5P_FIMV_E_SOURCE_FIRST_ADDR_V7  0xf9e0
>>  #define S5P_FIMV_E_SOURCE_SECOND_ADDR_V7 0xf9e4
>>  #define S5P_FIMV_E_SOURCE_THIRD_ADDR_V7  0xf9e8
>> diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
>> b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
>> index 4d17df9..f5404a6 100644
>> --- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
>> +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
>> @@ -287,6 +287,7 @@ struct s5p_mfc_priv_buf {
>>   * @warn_start:  hardware error code from which warnings
> start
>>   * @mfc_ops: ops structure holding HW operation function
>> pointers
>>   * @mfc_cmds:cmd structure holding HW commands function
>> pointers
>> + * @ver: firmware sub version
>>   *
>>   */
>>  struct s5p_mfc_dev {
>> @@ -330,6 +331,7 @@ struct s5p_mfc_dev {
>>   int warn_start;
>>   struct s5p_mfc_hw_ops *mfc_ops;
>>   struct s5p_mfc_hw_cmds *mfc_cmds;
>> + int ver;
>>  };
>>
>>  /**
>> diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
>> b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
>> index 2475a3c..ba1d302 100644
>> --- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
>> +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
>> @@ -240,7 +240,6 @@ static inline void s5p_mfc_clear_cmds(struct
>> s5p_mfc_dev *dev)
>>  /* Initialize hardware */
>>  int s5p_mfc_init_hw(struct s5p_mfc_dev *dev)  {
>> - unsigned int ver;
>>   int ret;
>>
>>   mfc_debug_enter();
>> @@ -302,12 +301,13 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev)
>>   return -EIO;
>>   }
>>   if (IS_MFCV6_PLUS(dev))
>> - ver = mfc_read(dev, S5P_FIMV_FW_VERSION_V6);
>> + dev->ver = mfc_read(dev, S5P_FIMV_FW_VERSION_V6);
>>   else
>> - ver = mfc_read(dev, S5P_FIMV_FW_VERSION);
>> + dev->ver = mfc_read(dev, S5P_FIMV_FW_VERSION);
>>
>>   mfc_debug(2, "MFC F/W version : %02xyy, %02xmm, %02xdd\n",
>> - (ver >> 16) & 0xFF, (ver >&g

[PATCH] ARM: dts: Remove g2d_pd node for exynos5420

2014-05-13 Thread Arun Kumar K
G2D power domain also controls the CMU block of G2D.
Since clock registers can be accessed anytime for viewing
clk_summary, it can cause a system crash if g2d power domain
is disabled.

Signed-off-by: Arun Kumar K 
---
Please also refer to the existing discussion on removal of
mau_pd node.
http://comments.gmane.org/gmane.linux.kernel.samsung-soc/29718

This patch also fixes a similar issue of the power domian being
linked to the CMU block. AFAIK, only MAU and G2D power domains
has this problem in 5420.

The issue is more critical now with the merging of following
patches in Tomasz's clk tree -
clk: samsung exynos5250/5420: Add gate clock for SSS module
clk: exynos5420: update clocks for G2D and G3D blocks

With these patches, I get the following crash on kernel booting -
[8.971209] Unhandled fault: imprecise external abort (0x1406) at 0x
[8.993044] Kernel panic - not syncing: Attempted to kill init! 
exitcode=0x0007

For fixing this, either g2d_pd has to be removed or we need to make all
GATE clocks touching the GATE_IP_G2D as CLK_IGNORE_UNUSED.
I believe removing g2d_pd is the better solution as we get almost the
same power saving by gating off these clocks and keeping the domain ON.
---
 arch/arm/boot/dts/exynos5420.dtsi |6 --
 1 file changed, 6 deletions(-)

diff --git a/arch/arm/boot/dts/exynos5420.dtsi 
b/arch/arm/boot/dts/exynos5420.dtsi
index 2f6da50..47d3f17 100644
--- a/arch/arm/boot/dts/exynos5420.dtsi
+++ b/arch/arm/boot/dts/exynos5420.dtsi
@@ -242,11 +242,6 @@
reg = <0x100440E0 0x20>;
};
 
-   g2d_pd: power-domain@10044100 {
-   compatible = "samsung,exynos4210-pd";
-   reg = <0x10044100 0x20>;
-   };
-
msc_pd: power-domain@10044120 {
compatible = "samsung,exynos4210-pd";
reg = <0x10044120 0x20>;
@@ -755,6 +750,5 @@
interrupts = <0 112 0>;
clocks = <&clock 471>;
clock-names = "secss";
-   samsung,power-domain = <&g2d_pd>;
};
 };
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 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/2] [media] v4l: Add source change event

2014-05-12 Thread Arun Kumar K
This event indicates that the video device has encountered
a source parameter change during runtime. This can typically be a
resolution change detected by a video decoder OR a format change
detected by an HDMI connector.

This needs to be nofified to the userspace and the application may
be expected to reallocate buffers before proceeding. The application
can subscribe to events on a specific pad or input port which
it is interested in.

Signed-off-by: Arun Kumar K 
---
 Documentation/DocBook/media/v4l/vidioc-dqevent.xml |   32 +
 .../DocBook/media/v4l/vidioc-subscribe-event.xml   |   19 +++
 drivers/media/v4l2-core/v4l2-event.c   |   36 
 include/media/v4l2-event.h |4 +++
 include/uapi/linux/videodev2.h |8 +
 5 files changed, 99 insertions(+)

diff --git a/Documentation/DocBook/media/v4l/vidioc-dqevent.xml 
b/Documentation/DocBook/media/v4l/vidioc-dqevent.xml
index 89891ad..6afabaa 100644
--- a/Documentation/DocBook/media/v4l/vidioc-dqevent.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-dqevent.xml
@@ -242,6 +242,22 @@
   
 
 
+
+  struct v4l2_event_src_change
+  
+   &cs-str;
+   
+ 
+   __u32
+   changes
+   
+ A bitmask that tells what has changed. See .
+   
+ 
+   
+  
+
+
 
   Changes
   
@@ -270,6 +286,22 @@

   
 
+
+
+  Source Changes
+  
+   &cs-def;
+   
+ 
+   V4L2_EVENT_SRC_CH_RESOLUTION
+   0x0001
+   This event gets triggered when a resolution change is
+   detected at runtime. This can typically come from a video decoder.
+   
+ 
+   
+  
+
   
   
 &return-value;
diff --git a/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml 
b/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml
index 5c70b61..067a0d5 100644
--- a/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml
@@ -155,6 +155,25 @@

  
  
+   V4L2_EVENT_SOURCE_CHANGE
+   5
+   
+ This event is triggered when a source parameter change is
+  detected during runtime by the video device. It can be a
+  runtime resolution change triggered by a video decoder or the
+  format change happening on an HDMI connector.
+  This event requires that the id
+  matches the pad / input index from which you want to receive
+  events.
+
+  This event has a &v4l2-event-source-change; associated
+ with it. The changes bitfield denotes
+ what has changed for the subscribed pad. If multiple events
+ occured before application could dequeue them, then the changes
+ will have the ORed value of all the events generated.
+   
+ 
+ 
V4L2_EVENT_PRIVATE_START
0x0800
Base event number for driver-private events.
diff --git a/drivers/media/v4l2-core/v4l2-event.c 
b/drivers/media/v4l2-core/v4l2-event.c
index 86dcb54..8761aab 100644
--- a/drivers/media/v4l2-core/v4l2-event.c
+++ b/drivers/media/v4l2-core/v4l2-event.c
@@ -318,3 +318,39 @@ int v4l2_event_subdev_unsubscribe(struct v4l2_subdev *sd, 
struct v4l2_fh *fh,
return v4l2_event_unsubscribe(fh, sub);
 }
 EXPORT_SYMBOL_GPL(v4l2_event_subdev_unsubscribe);
+
+static void v4l2_event_src_replace(struct v4l2_event *old,
+   const struct v4l2_event *new)
+{
+   u32 old_changes = old->u.src_change.changes;
+
+   old->u.src_change = new->u.src_change;
+   old->u.src_change.changes |= old_changes;
+}
+
+static void v4l2_event_src_merge(const struct v4l2_event *old,
+   struct v4l2_event *new)
+{
+   new->u.src_change.changes |= old->u.src_change.changes;
+}
+
+static const struct v4l2_subscribed_event_ops v4l2_event_src_ch_ops = {
+   .replace = v4l2_event_src_replace,
+   .merge = v4l2_event_src_merge,
+};
+
+int v4l2_src_change_event_subscribe(struct v4l2_fh *fh,
+   const struct v4l2_event_subscription *sub)
+{
+   if (sub->type == V4L2_EVENT_SOURCE_CHANGE)
+   return v4l2_event_subscribe(fh, sub, 0, &v4l2_event_src_ch_ops);
+   return -EINVAL;
+}
+EXPORT_SYMBOL_GPL(v4l2_src_change_event_subscribe);
+
+int v4l2_src_change_event_subdev_subscribe(struct v4l2_subdev *sd,
+   struct v4l2_fh *fh, struct v4l2_event_subscription *sub)
+{
+   return v4l2_src_change_event_subscribe(fh, sub);
+}
+EXPORT_SYMBOL_GPL(v4l2_src_change_event_subdev_subscribe);
diff --git a/include/media/v4l2-event.h b/include/media/v4l2-event.h
index be05d01..1ab9045 100644
--- a/include/me

[PATCH v4 2/2] [media] s5p-mfc: Add support for resolution change event

2014-05-12 Thread Arun Kumar K
From: Pawel Osciak 

When a resolution change point is reached, queue an event to signal the
userspace that a new set of buffers is required before decoding can
continue.

Signed-off-by: Pawel Osciak 
Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c |7 +++
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c |2 ++
 2 files changed, 9 insertions(+)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 54f7ba1..2d7d1ae 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -320,6 +320,7 @@ static void s5p_mfc_handle_frame(struct s5p_mfc_ctx *ctx,
struct s5p_mfc_buf *src_buf;
unsigned long flags;
unsigned int res_change;
+   struct v4l2_event ev;
 
dst_frame_status = s5p_mfc_hw_call(dev->mfc_ops, get_dspl_status, dev)
& S5P_FIMV_DEC_STATUS_DECODING_STATUS_MASK;
@@ -351,6 +352,12 @@ static void s5p_mfc_handle_frame(struct s5p_mfc_ctx *ctx,
if (ctx->state == MFCINST_RES_CHANGE_FLUSH) {
s5p_mfc_handle_frame_all_extracted(ctx);
ctx->state = MFCINST_RES_CHANGE_END;
+
+   memset(&ev, 0, sizeof(struct v4l2_event));
+   ev.type = V4L2_EVENT_SOURCE_CHANGE;
+   ev.u.src_change.changes = V4L2_EVENT_SRC_CH_RESOLUTION;
+   v4l2_event_queue_fh(&ctx->fh, &ev);
+
goto leave_handle_frame;
} else {
s5p_mfc_handle_frame_all_extracted(ctx);
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
index 4f94491..b383829 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
@@ -855,6 +855,8 @@ static int vidioc_subscribe_event(struct v4l2_fh *fh,
switch (sub->type) {
case V4L2_EVENT_EOS:
return v4l2_event_subscribe(fh, sub, 2, NULL);
+   case V4L2_EVENT_SOURCE_CHANGE:
+   return v4l2_src_change_event_subscribe(fh, sub);
default:
return -EINVAL;
}
-- 
1.7.9.5

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


[PATCH v4 0/2] Add resolution change event

2014-05-12 Thread Arun Kumar K
This patchset adds a source_change event to the v4l2-events.
This can be used for notifying the userspace about runtime
format changes happening on video nodes / pads like resolution
change in video decoder.

Changes from v3
--
- Addressed comments from Laurent / Hans
  https://patchwork.kernel.org/patch/4135731/

Changes from v2
---
- Event can be subscribed on specific pad / port as
  suggested by Hans.

Changes from v1
---
- Addressed review comments from Hans and Laurent
  https://patchwork.kernel.org/patch/4000951/

Arun Kumar K (1):
  [media] v4l: Add source change event

Pawel Osciak (1):
  [media] s5p-mfc: Add support for resolution change event

 Documentation/DocBook/media/v4l/vidioc-dqevent.xml |   32 +
 .../DocBook/media/v4l/vidioc-subscribe-event.xml   |   19 +++
 drivers/media/platform/s5p-mfc/s5p_mfc.c   |7 
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c   |2 ++
 drivers/media/v4l2-core/v4l2-event.c   |   36 
 include/media/v4l2-event.h |4 +++
 include/uapi/linux/videodev2.h |8 +
 7 files changed, 108 insertions(+)

-- 
1.7.9.5

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


Re: [PATCH v3 1/2] [media] v4l: Add source change event

2014-05-12 Thread Arun Kumar K
Hi Hans, Laurent,

On 05/09/14 18:45, Hans Verkuil wrote:
> On 05/09/2014 03:09 PM, Laurent Pinchart wrote:
>> Hi Arun,
>>
>> Thank you for the patch. We're slowly getting there :-)
>>
>> On Thursday 08 May 2014 17:19:15 Arun Kumar K wrote:
>>> This event indicates that the video device has encountered
>>> a source parameter change during runtime. This can typically be a
>>> resolution change detected by a video decoder OR a format change
>>> detected by an HDMI connector.
>>>
>>> This needs to be nofified to the userspace and the application may
>>> be expected to reallocate buffers before proceeding. The application
>>> can subscribe to events on a specific pad or input/output port which
>>> it is interested in.
>>>
>>> Signed-off-by: Arun Kumar K 
>>> ---
>>>  Documentation/DocBook/media/v4l/vidioc-dqevent.xml |   32 +
>>>  .../DocBook/media/v4l/vidioc-subscribe-event.xml   |   19 +++
>>>  drivers/media/v4l2-core/v4l2-event.c   |   36 +
>>>  include/media/v4l2-event.h |4 +++
>>>  include/uapi/linux/videodev2.h |8 +
>>>  5 files changed, 99 insertions(+)
>>>
>>> diff --git a/Documentation/DocBook/media/v4l/vidioc-dqevent.xml
>>> b/Documentation/DocBook/media/v4l/vidioc-dqevent.xml index 89891ad..6afabaa
>>> 100644
>>> --- a/Documentation/DocBook/media/v4l/vidioc-dqevent.xml
>>> +++ b/Documentation/DocBook/media/v4l/vidioc-dqevent.xml
>>> @@ -242,6 +242,22 @@
>>>
>>>  
>>>
>>> +
>>> +  struct v4l2_event_src_change
>>> +  
>>> +   &cs-str;
>>> +   
>>> + 
>>> +   __u32
>>> +   changes
>>> +   
>>> + A bitmask that tells what has changed. See >> linkend="src-changes-flags" />. +   
>>> + 
>>> +   
>>> +  
>>> +
>>> +
>>>  
>>>Changes
>>>
>>> @@ -270,6 +286,22 @@
>>> 
>>>
>>>  
>>> +
>>> +
>>> +  Source Changes
>>> +  
>>> +   &cs-def;
>>> +   
>>> + 
>>> +   V4L2_EVENT_SRC_CH_RESOLUTION
>>> +   0x0001
>>> +   This event gets triggered when a resolution change is
>>> +   detected at runtime. This can typically come from a video decoder.
>>> +   
>>> + 
>>> +   
>>> +  
>>> +
>>>
>>>
>>>  &return-value;
>>> diff --git a/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml
>>> b/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml index
>>> 5c70b61..8012829 100644
>>> --- a/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml
>>> +++ b/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml
>>> @@ -155,6 +155,25 @@
>>> 
>>>   
>>>   
>>> +   V4L2_EVENT_SOURCE_CHANGE
>>> +   5
>>> +   
>>> + This event is triggered when a format change is
>>> +  detected during runtime by the video device. It can be a
>>> +  runtime resolution change triggered by a video decoder or the
>>> +  format change happening on an HDMI connector.
>>> +  This event requires that the id
>>> +   matches the pad/input/output index from which you want to
>>> +  receive events.
>>> +
>>> +  This event has a &v4l2-event-source-change; associated
>>> + with it. The changes bitfield denotes
>>> + what has changed for the subscribed pad. If multiple events
>>> + occured before application could dequeue them, then the changes
>>> + will have the ORed value of all the events generated.
>>> +   
>>> + 
>>> + 
>>> V4L2_EVENT_PRIVATE_START
>>> 0x0800
>>> Base event number for driver-private events.
>>> diff --git a/drivers/media/v4l2-core/v4l2-event.c
>>> b/drivers/media/v4l2-core/v4l2-event.c index 86dcb54..8761aab 100644
>>> --- a/drivers/media/v4l2-core/v4l2-event.c
>>> +++ b/drivers/media/v4l2-core/v4l2-event.c
>>> @@ -318,3 +318,39 @@ int v4l2_event_subdev_unsubscribe(struct v4l2_s

Re: [PATCH v3 5/5] ARM: dts: enable hdmi for exynos5800 based peach-pi board

2014-05-12 Thread Arun Kumar K
Hi Rahul,

On 05/12/14 15:54, Rahul Sharma wrote:
> From: Rahul Sharma 
> 
> Enable hdmi for peach-pi board.
> 
> Signed-off-by: Rahul Sharma 
> ---
>  arch/arm/boot/dts/exynos5800-peach-pi.dts |   26 ++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/exynos5800-peach-pi.dts 
> b/arch/arm/boot/dts/exynos5800-peach-pi.dts
> index 742655b..bbb445a 100644
> --- a/arch/arm/boot/dts/exynos5800-peach-pi.dts
> +++ b/arch/arm/boot/dts/exynos5800-peach-pi.dts
> @@ -72,6 +72,13 @@
>   samsung,pin-pud = <0>;
>   samsung,pin-drv = <0>;
>   };
> +
> + hdmi_hpd_irq: hdmi-hpd-irq {
> + samsung,pins = "gpx3-7";
> + samsung,pin-function = <0>;
> + samsung,pin-pud = <1>;
> + samsung,pin-drv = <0>;
> + };

This node is already added in 5420-pinctrl.dtsi in patch 3/5.
You can drop it from here.

Regards
Arun

>  };
>  
>  &rtc {
> @@ -134,6 +141,25 @@
>   };
>  };
>  
> +&i2c_2 {
> + status = "okay";
> + samsung,i2c-sda-delay = <100>;
> + samsung,i2c-max-bus-freq = <66000>;
> + samsung,i2c-slave-addr = <0x50>;
> +
> + hdmiddc@50 {
> + reg = <0x50>;
> + };
> +};
> +
> +&hdmi {
> + status = "okay";
> + hpd-gpio = <&gpx3 7 2>;
> + pinctrl-names = "default";
> + pinctrl-0 = <&hdmi_hpd_irq>;
> + ddc = <&i2c_2>;
> +};
> +
>  /*
>   * Use longest HW watchdog in SoC (32 seconds) since the hardware
>   * watchdog provides no debugging information (compared to soft/hard
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 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] s5p-mfc: Don't try to resubmit VP8 bitstream buffer for decode.

2014-05-12 Thread Arun Kumar K
From: Pawel Osciak 

Currently, for formats that are not H264, MFC driver will check
the consumed stream size returned by the firmware and, based on that,
will try to decide whether the bitstream buffer contained more than
one frame. If the size of the buffer is larger than the consumed
stream, it assumes that there are more frames in the buffer and that the
buffer should be resubmitted for decode. This rarely works though and
actually introduces problems, because:

- v7 firmware will always return consumed stream size equal to whatever
the driver passed to it when running decode (which is the size of the whole
buffer), which means we will never try to resubmit, because the firmware
will always tell us that it consumed all the data we passed to it;

- v6 firmware will return the number of consumed bytes, but will not
include the padding ("stuffing") bytes that are allowed after the frame
in VP8. Since there is no way of figuring out how many of those bytes
follow the frame without getting the frame size from IVF headers (or
somewhere else, but not from the stream itself), the driver tries to guess that
padding size is not larger than 4 bytes, which is not always true;

The only way to make it work is to queue only one frame per buffer from
userspace and the check in the kernel is useless and wrong for VP8.
So adding VP8 also along with H264 to disallow re-submitting of buffer
back to hardware for decode.

Signed-off-by: Pawel Osciak 
Signed-off-by: Arun Kumar K 
---
Changes from v1
- Made the condition to specifically add VP8 case only
  suggested by Kamil.
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 0f796ad..2d7d1ae 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -382,6 +382,7 @@ static void s5p_mfc_handle_frame(struct s5p_mfc_ctx *ctx,
ctx->consumed_stream += s5p_mfc_hw_call(dev->mfc_ops,
get_consumed_stream, dev);
if (ctx->codec_mode != S5P_MFC_CODEC_H264_DEC &&
+   ctx->codec_mode != S5P_MFC_CODEC_VP8_DEC &&
ctx->consumed_stream + STUFF_BYTE <
src_buf->b->v4l2_planes[0].bytesused) {
/* Run MFC again on the same buffer */
-- 
1.7.9.5

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


[RFC] ARM: EXYNOS: Add support for clock handling in power domain

2014-05-12 Thread Arun Kumar K
From: Prathyush K 

While powering on/off a local powerdomain in exynos5 chipsets, the input
clocks to each device gets modified. This behaviour is based on the
SYSCLK_SYS_PWR_REG registers.
E.g. SYSCLK_MFC_SYS_PWR_REG = 0x0, the parent of input clock to MFC
   (aclk333) gets modified to oscclk
= 0x1, no change in clocks.
The recommended value of SYSCLK_SYS_PWR_REG before power gating any
domain is 0x0. So we must also restore the clocks while powering on a
domain everytime.

This patch adds the framework for getting the required mux and parent clocks
through a power domain device node.
Just setting the parent while powering on is not enough since according
to the clock framework, the parent has never changed. So we set the
parent clock as oscclk before power gating and then set back the correct
parent clock after powering on a domain.

Signed-off-by: Prathyush K 
Signed-off-by: Andrew Bresticker 
Signed-off-by: Arun Kumar K 
---
This patch is posted for getting the opinion from all on what would
be the best possible solution to the issue at hand.
The issue is observed with multiple IPs like MFC, GSC, G2D, MSC etc.
where after a PD OFF-ON sequence, the parent clock gets reset to oscclk.
I would like to get the opinion from all on what would be the right
place to handle this. Either the clock re-parenting should be done
by all these individual IP drivers
OR
power-domain driver can handle this at a common place as is being done
in this patch.

One more possible change I can do is to make a exynos5250 compatible for
the power-domain driver and get the extra clocks only for exynos5 onwards.
But since there are no errors being reported even if these clocks are not
provided, these changes are fully backward compatible with exynos4 also.
---
 .../bindings/arm/exynos/power_domain.txt   |   18 +++
 arch/arm/mach-exynos/pm_domains.c  |   56 +++-
 2 files changed, 73 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/arm/exynos/power_domain.txt 
b/Documentation/devicetree/bindings/arm/exynos/power_domain.txt
index 5216b41..2e19a9f 100644
--- a/Documentation/devicetree/bindings/arm/exynos/power_domain.txt
+++ b/Documentation/devicetree/bindings/arm/exynos/power_domain.txt
@@ -9,6 +9,16 @@ Required Properties:
 - reg: physical base address of the controller and length of memory mapped
 region.
 
+Optional Properties:
+- clocks: List of clock handles. The parent clocks of the input clocks to the
+  devices in this power domain are set to oscclk before power gating and
+  restored back after powering on a domain. This is required for all domains
+  which are powered on and off and not required for unused domains.
+  The following clocks can be specified:
+  - oscclk: oscillator clock.
+  - clk(n): input clock to the devices in this power domain
+  - pclk(n): parent clock of input clock to the devices in this power domain
+
 Node of a device using power domains must have a samsung,power-domain property
 defined with a phandle to respective power domain.
 
@@ -19,6 +29,14 @@ Example:
reg = <0x10023C00 0x10>;
};
 
+   mfc_pd: power-domain@10044060 {
+   compatible = "samsung,exynos4210-pd";
+   reg = <0x10044060 0x20>;
+   clocks = <&clock CLK_FIN_PLL>, <&clock MOUT_SW_ACLK333>,
+   <&clock MOUT_USER_ACLK333>;
+   clock-names = "oscclk", "pclk0", "clk0";
+   };
+
 Example of the node using power domain:
 
node {
diff --git a/arch/arm/mach-exynos/pm_domains.c 
b/arch/arm/mach-exynos/pm_domains.c
index fe6570e..e5fe76d 100644
--- a/arch/arm/mach-exynos/pm_domains.c
+++ b/arch/arm/mach-exynos/pm_domains.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -24,6 +25,8 @@
 
 #include "regs-pmu.h"
 
+#define MAX_CLK_PER_DOMAIN 4
+
 /*
  * Exynos specific wrapper around the generic power domain
  */
@@ -32,6 +35,9 @@ struct exynos_pm_domain {
char const *name;
bool is_off;
struct generic_pm_domain pd;
+   struct clk *oscclk;
+   struct clk *clk[MAX_CLK_PER_DOMAIN];
+   struct clk *pclk[MAX_CLK_PER_DOMAIN];
 };
 
 static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on)
@@ -44,6 +50,18 @@ static int exynos_pd_power(struct generic_pm_domain *domain, 
bool power_on)
pd = container_of(domain, struct exynos_pm_domain, pd);
base = pd->base;
 
+   /* Set oscclk before powering off a domain*/
+   if (!power_on) {
+   int i;
+   for (i = 0; i < MAX_CLK_PER_DOMAIN; i++) {
+   if (!pd->clk[i])
+   break;
+   if (clk_set_parent(pd->clk[i],

Re: [PATCH v3 0/4] ARM: dts: enable display for peach-pit and snow boards

2014-05-11 Thread Arun Kumar K
Hi Rahul,

On Fri, May 9, 2014 at 3:39 PM, Rahul Sharma  wrote:
> From: Rahul Sharma 
>
> Add nodes for fimd and dp controller for exynos5250 based snow
> and exynos5420 based peach-pit board.
>

It would be great to include the display support for 5800 peach-pi board also
in this series. Most of the values would remain the same except for the changes
for bigger display in peach-pi.

Regards
Arun

> This series is based on Kukjin Kims, for-next branch.
>
> V3:
> 1) Dropped 1 patch "ARM: dts: move dp hpd line to the board file for
>  exynos5420".
> 2) Extra blank lines for readability.
> 3) dp hpd gpio name change (dp_hpd -> dp_hpd_gpio)
>
> V2:
> 1) Rebase on Peach-pit dependent patches.
>
> It is dependent on
> 1) Andrew Bresticker's patch for hpd gpio addition, avilable at
> http://www.spinics.net/lists/linux-samsung-soc/msg28827.html [Patch is 
> 'ACK'ed.]
> 2) Arun's patch for adding peach-pit board dts file at
> http://www.spinics.net/lists/linux-samsung-soc/msg30103.html. [Patch is 
> 'ACK'ed.]
>
> Rahul Sharma (4):
>   ARM: dts: enable fimd for exynos5250 based snow board
>   ARM: dts: enable dp-controller for exynos5250 based snow board
>   ARM: dts: enable fimd for exynos5420 based peach-pit board
>   ARM: dts: enable dp-controller for exynos5420 based peach-pit board
>
>  arch/arm/boot/dts/exynos5250-snow.dts  |   35 
>  arch/arm/boot/dts/exynos5420-peach-pit.dts |   41 
> 
>  2 files changed, 76 insertions(+)
>
> --
> 1.7.9.5
>
>
> ___
> linux-arm-kernel mailing list
> linux-arm-ker...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/3] clk: exynos5420: Add 5800 specific clocks

2014-05-09 Thread Arun Kumar K
From: Alim Akhtar 

Exynos5800 clock structure is mostly similar to 5420 with only
a small delta changes. So the 5420 clock file is re-used for
5800 also. The common clocks for both are seggreagated and few
clocks which are different for both are separately initialized.

Signed-off-by: Alim Akhtar 
Signed-off-by: Arun Kumar K 
---
Changes from v1
---
- Rebased on clock cleanup by Shaik
- Added 5800 also to save / restore handling
- Extra 5800 clocks added as now they have common
  terminating gates with 5420 (Added by Shaik's series)
---
 .../devicetree/bindings/clock/exynos5420-clock.txt |3 +-
 drivers/clk/samsung/clk-exynos5420.c   |  306 
 include/dt-bindings/clock/exynos5420.h |4 +
 3 files changed, 258 insertions(+), 55 deletions(-)

diff --git a/Documentation/devicetree/bindings/clock/exynos5420-clock.txt 
b/Documentation/devicetree/bindings/clock/exynos5420-clock.txt
index ca88c97..d54f42c 100644
--- a/Documentation/devicetree/bindings/clock/exynos5420-clock.txt
+++ b/Documentation/devicetree/bindings/clock/exynos5420-clock.txt
@@ -1,12 +1,13 @@
 * Samsung Exynos5420 Clock Controller
 
 The Exynos5420 clock controller generates and supplies clock to various
-controllers within the Exynos5420 SoC.
+controllers within the Exynos5420 SoC and for the Exynos5800 SoC.
 
 Required Properties:
 
 - compatible: should be one of the following.
   - "samsung,exynos5420-clock" - controller compatible with Exynos5420 SoC.
+  - "samsung,exynos5800-clock" - controller compatible with Exynos5800 SoC.
 
 - reg: physical base address of the controller and length of memory mapped
   region.
diff --git a/drivers/clk/samsung/clk-exynos5420.c 
b/drivers/clk/samsung/clk-exynos5420.c
index e576456..d7dedd9 100644
--- a/drivers/clk/samsung/clk-exynos5420.c
+++ b/drivers/clk/samsung/clk-exynos5420.c
@@ -57,15 +57,19 @@
 #define SRC_TOP5   0x10214
 #define SRC_TOP6   0x10218
 #define SRC_TOP7   0x1021c
+#define SRC_TOP8   0x10220 /* 5800 specific */
+#define SRC_TOP9   0x10224 /* 5800 specific */
 #define SRC_DISP10 0x1022c
 #define SRC_MAU0x10240
 #define SRC_FSYS   0x10244
 #define SRC_PERIC0 0x10250
 #define SRC_PERIC1 0x10254
 #define SRC_ISP0x10270
+#define SRC_CAM0x10274 /* 5800 specific */
 #define SRC_TOP10  0x10280
 #define SRC_TOP11  0x10284
 #define SRC_TOP12  0x10288
+#define SRC_TOP13  0x1028c /* 5800 specific */
 #define SRC_MASK_TOP2  0x10308
 #define SRC_MASK_TOP7  0x1031c
 #define SRC_MASK_DISP100x1032c
@@ -76,6 +80,8 @@
 #define DIV_TOP0   0x10500
 #define DIV_TOP1   0x10504
 #define DIV_TOP2   0x10508
+#define DIV_TOP8   0x10520 /* 5800 specific */
+#define DIV_TOP9   0x10524 /* 5800 specific */
 #define DIV_DISP10 0x1052c
 #define DIV_MAU0x10544
 #define DIV_FSYS0  0x10548
@@ -86,6 +92,7 @@
 #define DIV_PERIC2 0x10560
 #define DIV_PERIC3 0x10564
 #define DIV_PERIC4 0x10568
+#define DIV_CAM0x10574 /* 5800 specific */
 #define SCLK_DIV_ISP0  0x10580
 #define SCLK_DIV_ISP1  0x10584
 #define DIV2_RATIO00x10590
@@ -102,6 +109,7 @@
 #define GATE_TOP_SCLK_ISP  0x10870
 #define GATE_IP_GSCL0  0x10910
 #define GATE_IP_GSCL1  0x10920
+#define GATE_IP_CAM0x10924 /* 5800 specific */
 #define GATE_IP_MFC0x1092c
 #define GATE_IP_DISP1  0x10928
 #define GATE_IP_G3D0x10930
@@ -123,23 +131,31 @@
 #define SRC_KFC0x28200
 #define DIV_KFC0   0x28500
 
+/* Exynos5x SoC type */
+enum exynos5x_soc {
+   EXYNOS5420,
+   EXYNOS5800,
+};
+
 /* list of PLLs */
-enum exynos5420_plls {
+enum exynos5x_plls {
apll, cpll, dpll, epll, rpll, ipll, spll, vpll, mpll,
bpll, kpll,
nr_plls /* number of PLLs */
 };
 
 static void __iomem *reg_base;
+static enum exynos5x_soc exynos5x_soc;
 
 #ifdef CONFIG_PM_SLEEP
-static struct samsung_clk_reg_dump *exynos5420_save;
+static struct samsung_clk_reg_dump *exynos5x_save;
+static struct samsung_clk_reg_dump *exynos5800_save;
 
 /*
  * list of controller registers to be saved and restored during a
  * suspend/resume cycle.
  */
-static unsigned long exynos5420_clk_regs[] __initdata = {
+static unsigned long exynos5x_clk_regs[] __initdata = {
SRC_CPU,
DIV_CPU0,
DIV_CPU1,
@@ -222,18 +238,37 @@ static unsigned long exynos5420_clk_regs[] __initdata = {
DIV_KFC0,
 };
 
+static unsigned long exynos5800_clk_regs[] __initdata = {
+   SRC_TOP8,
+   SRC_TOP9,
+   SRC_CAM,
+   S

[PATCH v2 3/3] ARM: dts: Add peach-pi board support

2014-05-09 Thread Arun Kumar K
Adds support for google peach-pi board having the
Exynos5800 SoC.

Signed-off-by: Arun Kumar K 
Signed-off-by: Doug Anderson 
Reviewed-by: Tomasz Figa 
---
Changes from v1
- Updated memory node with a safe size of 2GB
---
 arch/arm/boot/dts/Makefile|3 +-
 arch/arm/boot/dts/exynos5800-peach-pi.dts |  144 +
 2 files changed, 146 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/boot/dts/exynos5800-peach-pi.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index a934648..cd399a2 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -77,7 +77,8 @@ dtb-$(CONFIG_ARCH_EXYNOS) += exynos4210-origen.dtb \
exynos5420-peach-pit.dtb \
exynos5420-smdk5420.dtb \
exynos5440-sd5v1.dtb \
-   exynos5440-ssdk5440.dtb
+   exynos5440-ssdk5440.dtb \
+   exynos5800-peach-pi.dtb
 dtb-$(CONFIG_ARCH_HI3xxx) += hi3620-hi4511.dtb
 dtb-$(CONFIG_ARCH_HIGHBANK) += highbank.dtb \
ecx-2000.dtb
diff --git a/arch/arm/boot/dts/exynos5800-peach-pi.dts 
b/arch/arm/boot/dts/exynos5800-peach-pi.dts
new file mode 100644
index 000..4ed9ccc
--- /dev/null
+++ b/arch/arm/boot/dts/exynos5800-peach-pi.dts
@@ -0,0 +1,144 @@
+/*
+ * Google Peach Pi Rev 10+ board device tree source
+ *
+ * Copyright (c) 2014 Google, Inc
+ *
+ * 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.
+ */
+
+/dts-v1/;
+#include 
+#include 
+#include "exynos5800.dtsi"
+
+/ {
+   model = "Google Peach Pi Rev 10+";
+
+   compatible = "google,pi-rev16",
+   "google,pi-rev15", "google,pi-rev14",
+   "google,pi-rev13", "google,pi-rev12",
+   "google,pi-rev11", "google,pi-rev10",
+   "google,pi", "google,peach", "samsung,exynos5800",
+   "samsung,exynos5";
+
+   memory {
+   reg = <0x2000 0x8000>;
+   };
+
+   fixed-rate-clocks {
+   oscclk {
+   compatible = "samsung,exynos5420-oscclk";
+   clock-frequency = <2400>;
+   };
+   };
+
+   gpio-keys {
+   compatible = "gpio-keys";
+
+   pinctrl-names = "default";
+   pinctrl-0 = <&power_key_irq>;
+
+   power {
+   label = "Power";
+   gpios = <&gpx1 2 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   gpio-key,wakeup;
+   };
+   };
+
+   backlight {
+   compatible = "pwm-backlight";
+   pwms = <&pwm 0 100 0>;
+   brightness-levels = <0 100 500 1000 1500 2000 2500 2800>;
+   default-brightness-level = <7>;
+   pinctrl-0 = <&pwm0_out>;
+   pinctrl-names = "default";
+   };
+};
+
+&pinctrl_0 {
+   tpm_irq: tpm-irq {
+   samsung,pins = "gpx1-0";
+   samsung,pin-function = <0>;
+   samsung,pin-pud = <0>;
+   samsung,pin-drv = <0>;
+   };
+
+   power_key_irq: power-key-irq {
+   samsung,pins = "gpx1-2";
+   samsung,pin-function = <0>;
+   samsung,pin-pud = <0>;
+   samsung,pin-drv = <0>;
+   };
+};
+
+&rtc {
+   status = "okay";
+};
+
+&uart_3 {
+   status = "okay";
+};
+
+&mmc_0 {
+   status = "okay";
+   num-slots = <1>;
+   broken-cd;
+   caps2-mmc-hs200-1_8v;
+   supports-highspeed;
+   non-removable;
+   card-detect-delay = <200>;
+   clock-frequency = <4>;
+   samsung,dw-mshc-ciu-div = <3>;
+   samsung,dw-mshc-sdr-timing = <0 4>;
+   samsung,dw-mshc-ddr-timing = <0 2>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&sd0_clk &sd0_cmd &sd0_bus4 &sd0_bus8>;
+
+   slot@0 {
+   reg = <0>;
+   bus-width = <8>;
+   };
+};
+
+&mmc_2 {
+   status = "okay";
+   num-slots = <1>;
+   supports-highspeed;
+   card-detect-delay = <200>;
+   clock-frequency = <4>;
+   samsung,dw-mshc-ciu-div = <3>;
+   samsung,dw-mshc-sdr-timing = <2 3>;
+   samsung,dw-mshc-ddr-timing = <1 2>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&sd2_clk &sd2_cmd &sd2_cd &sd2_bus4>;
+
+   slot@0 {
+   reg = <0>;
+ 

[PATCH v2 2/3] ARM: dts: Add Exynos5800 dt file

2014-05-09 Thread Arun Kumar K
Most of the nodes of exynos5420 remains same for exynos5800.
So the exynos5420.dtsi is included in exynos5800 and the changed
node properties will be overriden.

Signed-off-by: Arun Kumar K 
Reviewed-by: Tomasz Figa 
Acked-by: Olof Johansson 
---
No changes from v1
---
 arch/arm/boot/dts/exynos5800.dtsi |   24 
 1 file changed, 24 insertions(+)
 create mode 100644 arch/arm/boot/dts/exynos5800.dtsi

diff --git a/arch/arm/boot/dts/exynos5800.dtsi 
b/arch/arm/boot/dts/exynos5800.dtsi
new file mode 100644
index 000..6979fc7
--- /dev/null
+++ b/arch/arm/boot/dts/exynos5800.dtsi
@@ -0,0 +1,24 @@
+/*
+ * SAMSUNG EXYNOS5800 SoC device tree source
+ *
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * SAMSUNG EXYNOS5800 SoC device nodes are listed in this file.
+ * EXYNOS5800 based board files can include this file and provide
+ * values for board specfic bindings.
+ *
+ * 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.
+ */
+
+#include "exynos5420.dtsi"
+
+/ {
+   compatible = "samsung,exynos5800", "samsung,exynos5";
+};
+
+&clock {
+   compatible = "samsung,exynos5800-clock";
+};
-- 
1.7.9.5

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


[PATCH v2 0/3] Add Exynos5800 support

2014-05-09 Thread Arun Kumar K
Exynos5800 is a derivative of Exynos5420 with higher
clock speeds and most other IP blocks remaining the same
except for a few.

This patchset is based on Kukjin's for-next branch
and Tomasz's samsung-next branch containing Shaik's clock
cleanup series for 5420.

Changes from v1
--
- Rebased on Shaik's clock consolidation for 5420
- Addressed review comments from Tomasz

Alim Akhtar (1):
  clk: exynos5420: Add 5800 specific clocks

Arun Kumar K (2):
  ARM: dts: Add Exynos5800 dt file
  ARM: dts: Add peach-pi board support

 .../devicetree/bindings/clock/exynos5420-clock.txt |3 +-
 arch/arm/boot/dts/Makefile |3 +-
 arch/arm/boot/dts/exynos5800-peach-pi.dts  |  144 +
 arch/arm/boot/dts/exynos5800.dtsi  |   24 ++
 drivers/clk/samsung/clk-exynos5420.c   |  306 
 include/dt-bindings/clock/exynos5420.h |4 +
 6 files changed, 428 insertions(+), 56 deletions(-)
 create mode 100644 arch/arm/boot/dts/exynos5800-peach-pi.dts
 create mode 100644 arch/arm/boot/dts/exynos5800.dtsi

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 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/3] [media] s5p-mfc: Add variants to access mfc registers

2014-05-08 Thread Arun Kumar K
Hi Tomasz,

On 05/09/14 10:50, Tomasz Figa wrote:
> Hi Arun, Paweł,
> 
> On 09.05.2014 06:49, Arun Kumar K wrote:
>> Hi Kamil,
>>
>> On 05/09/14 06:30, Pawel Osciak wrote:
>>> Hi Kamil,
>>>
>>> On Fri, May 9, 2014 at 1:31 AM, Kamil Debski  wrote:
>>>>
>>>> Hi Arun,
>>>>
>>>> I think that this driver is getting too complicated now.
>>>>
>>>> First there are separate files for MFC versions, but in addition there are
>>>> many
>>>> IF_MFCVx in there.
>>>
>>> The intention of this patch is to actually get rid of IF_MFCVx
>>> conditionals wherever possible.
>>>
>>>>
>>>> I am curious how many additional lines it would take to
>>>> add s5p_mfc_cmd_v8.* and s5p_mfc_opr_v8.*.
>>>>
>>>> I get the point that this approach may result in less lines added, but
>>>> having a callback specific for version use register pointers specific for
>>>> another version makes the code look unreadable and difficult to maintain.
>>>
>>> Could you please give an example of how this reduces readability?
>>> I personally feel this patch makes things much more readable (see below).
>>>
>>> On the other hand, if we continued without the current method, we
>>> would have to sprinkle
>>> IF_MFCVx macros all around actual functions/operations, instead of
>>> just containing this
>>> to the regs structure, and the only difference in each path would be
>>> register name defines.
>>> I don't feel this would be a better direction to be honest.
>>>
>>> Compare, new, after this patch:
>>>
>>>> + WRITEL(y_addr, mfc_regs->e_source_first_plane_addr);
>>>> + WRITEL(c_addr, mfc_regs->e_source_second_plane_addr);
>>>
>>> vs previously, before this patch:
>>>
>>>> - if (IS_MFCV7(dev)) {
>>>> - WRITEL(y_addr, S5P_FIMV_E_SOURCE_FIRST_ADDR_V7);
>>>> - WRITEL(c_addr, S5P_FIMV_E_SOURCE_SECOND_ADDR_V7);
>>>> - } else {
>>>> - WRITEL(y_addr, S5P_FIMV_E_SOURCE_LUMA_ADDR_V6);
>>>> - WRITEL(c_addr, S5P_FIMV_E_SOURCE_CHROMA_ADDR_V6);
>>>> - }
>>>
>>> And of course adding V8 more would make it even worse with yet another
>>> else if case.
>>>
>>>
>>>> Please give your opinion on another way to add support for v8.
>>>> s5p_mfc_cmd_v8.* and s5p_mfc_opr_v8.* ?
>>>
>>> If we add v7 and v8 files, a majority of their code will look like this:
>>>
>>> s5p_mfc_opr_v6.c:
>>> (...)
>>> void foo_v6(args)
>>> {
>>> foofun(REGISTER_A_V6);
>>> barfun(REGISTER_B_V6);
>>> }
>>> (...)
>>>
>>> s5p_mfc_opr_v7.c:
>>> (...)
>>> void foo_v7(args)
>>> {
>>> foofun(REGISTER_A_V7);
>>> barfun(REGISTER_B_V7);
>>> }
>>> (...)
>>>
>>> s5p_mfc_opr_v8.c:
>>> (...)
>>> void foo_v8(args)
>>> {
>>> foofun(REGISTER_A_V8);
>>> barfun(REGISTER_B_V8);
>>> }
>>> (...)
>>>
>>> I'm not sure this is less error prone and less code...
>>>
>>
>> Adding on to this, I had a discussion with the firmware team and what I
>> got to know is future firmwares are also going to keep the operation
>> sequence same as v6, but there can be more changes in register offsets
>> as they accomodate more features. So if we go with opr_v8.c, we _might_
>> need opr_v9.c also with hardly any change in the code except register
>> offset modifications.
> 
> If register offsets make for most of the differences between particular 
> MFC versions, then probably having the register pointers used instead of 
> base + OFFSET could be useful. Unfortunately we don't have much 
> information about the newer variants, so it's hard to say.
> 
> Btw. I wonder why the firmware team couldn't simply add new registers at 
> the end of the address space, without breaking software compatibility 
> with every new version, even though rest of programming model mostly 
> stays intact, which is a pure nonsense. Couldn't you complain to the for 
> this if you have contact with them? Otherwise this madness will never stop.
> 

I had a detailed discussion with the firmware team regarding this and
updated them the concerns. The need to do it is because, the register
offsets are grouped codec-wise. Like
0x000a H264
0x000d MPEG4
0x000f VP8
etc.

There are some holes given for future register additions also, but
sometimes many additional features are added to specific codecs and also
in the common feature set which doesnt fit in the pre-defined holes. So
as per them, the re-shuffle of registers was done in v8 so as to make it
more clean and taking into consideration future feature requirements.
But again it might have few changes here and there in the next version.
Since these register offsets are not really in our control, this
approach is best in the driver to absorb these changes without many if -
else conditions. The firware team assured me that they will try to avoid
these kind of changes as much as possible in future.

Regards
Arun


> Best regards,
> Tomasz
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 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] s5p-mfc: Add IOMMU support

2014-05-08 Thread Arun Kumar K
Hi Kamil,

On 05/08/14 21:54, Kamil Debski wrote:
> Hi Arun,
> 
>> From: Arun Kumar K [mailto:arunkk.sams...@gmail.com]
>> Sent: Tuesday, April 22, 2014 2:22 PM
>>
>> Hi Laurent,
>>
>> Thank you for the review.
>>
>> On Tue, Apr 22, 2014 at 5:23 PM, Laurent Pinchart
>>  wrote:
>>> Hi Arun,
>>>
>>> Thank you for the patch.
>>>
>>> On Tuesday 22 April 2014 16:32:48 Arun Kumar K wrote:
>>>> The patch adds IOMMU support for MFC driver.
>>>
>>> I've been working on an IOMMU driver lately, which led me to think
>>> about how drivers should be interfaced with IOMMUs. Runtime IOMMU
>>> handling is performed by the DMA mapping API, but in many cases
>>> (including Exynos platforms) the
>>> arm_iommu_create_mapping() and arm_iommu_attach_device() functions
>>> still need to be called explicitly by drivers, which doesn't seem a
>> very good idea to me.
>>> Ideally IOMMU usage should be completely transparent for bus master
>>> drivers, without requiring any driver modification to use the IOMMU.
>>>
>>> What would you think about improving the Exynos IOMMU driver to
>> create
>>> the mapping and attach the device instead of having to modify all bus
>>> master drivers ? See the ipmmu_add_device() function in
>>> http://www.spinics.net/lists/linux-sh/msg30488.html for a possible
>>> implementation.
>>>
>>
>> Yes that would be a better solution. But as far as I know, exynos
>> platforms has few more complications where multiple IOMMUs are present
>> for single IP.
>> The exynos iommu work is still under progress and KyonHo Cho will have
>> some inputs / comments on this. This seems to me a valid usecase which
>> can be considered for exynos iommu also.
> 
> Arun, could you tell me how did you test this?

It is tested on the IOMMU patches sent by KyongHo Cho (v11 series)
 https://lkml.org/lkml/2014/3/14/9
I found it to work well with v12 too.

> I think that the MFC driver should not be modified to use iommu. Dma_mapping
> should be used. On Tizenorg there is a 3.10 kernel with an iommu driver that
> works with MFC without any patches to the MFC drvier.

This is as per the mainline IOMMU driver patches which are being
reviewed now. I could see the exynos DRM also using this kind of
approach and is already in mainline. Thats why I thought of sending this.

> 
> I disagree to merging this patch, sorry. This should be done the correct way.
> 

Ok. I agree we can wait till the merging of Samsung IOMMU. If it takes
care of making the mapping and attaching the device without the master
driver intervention, then we can skip this patch. But till now it is not
taken care in the patches which are under review for samsung IOMMU.

Regards
Arun

> NACK.
> 
> Best wishes,
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 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] [media] s5p-mfc: add init buffer cmd to MFCV6

2014-05-08 Thread Arun Kumar K
Hi Kamil,

On 05/08/14 21:52, Kamil Debski wrote:
> Hi,
> 
>> From: Arun Kumar K [mailto:arunkk.sams...@gmail.com] On Behalf Of Arun
>> Kumar K
>> Sent: Tuesday, March 11, 2014 10:16 AM
>>
>> From: avnd kiran 
>>
>> Latest MFC v6 firmware requires tile mode and loop filter setting to be
>> done as part of Init buffer command, in sync with v7. Since there are
>> two versions of v6 firmware with different interfaces, it is
>> differenciated using the version number read back from firmware which
>> is a hexadecimal value based on the firmware date.
> 
> MFC version has two parts major and minor. Are you sure that date is 
> the only way to check if the interface has changed? Maybe the major number
> should stay the same (6) in this case, and the minor should be updates?
> Do you have contact with persons writing the firmware?
> 

Yes I contacted with the firmware team and there is no difference in the
minor number too. Both the versions will read as MFC v6.5. Only
difference is the firmware date.

> Also, I don't see a patch with the newer firmware posted to linux-firmware.
> When it is going to be sent?
> 

I will send it along with the v7 firmware.

Regards
Arun

> Best wishes,
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 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] s5p-mfc: Don't try to resubmit VP8 bitstream buffer for decode.

2014-05-08 Thread Arun Kumar K
Hi Kamil,

On 05/08/14 21:52, Kamil Debski wrote:
> Hi,
> 
> 
>> From: Arun Kumar K [mailto:arunkk.sams...@gmail.com] On Behalf Of Arun
>> Kumar K
>> Sent: Friday, March 07, 2014 9:26 AM
>>
>> From: Pawel Osciak 
>>
>> Currently, for formats that are not H264, MFC driver will check the
>> consumed stream size returned by the firmware and, based on that, will
>> try to decide whether the bitstream buffer contained more than one
>> frame. If the size of the buffer is larger than the consumed stream, it
>> assumes that there are more frames in the buffer and that the buffer
>> should be resubmitted for decode. This rarely works though and actually
>> introduces problems, because:
>>
>> - v7 firmware will always return consumed stream size equal to whatever
>> the driver passed to it when running decode (which is the size of the
>> whole buffer), which means we will never try to resubmit, because the
>> firmware will always tell us that it consumed all the data we passed to
>> it;
>>
>> - v6 firmware will return the number of consumed bytes, but will not
>> include the padding ("stuffing") bytes that are allowed after the frame
>> in VP8. Since there is no way of figuring out how many of those bytes
>> follow the frame without getting the frame size from IVF headers (or
>> somewhere else, but not from the stream itself), the driver tries to
>> guess that padding size is not larger than 4 bytes, which is not always
>> true;
>>
>> The only way to make it work is to queue only one frame per buffer from
>> userspace and the check in the kernel is useless and wrong for VP8.
>> MPEG4 still seems to require it, so keep it only for that format.
>>
>> Signed-off-by: Pawel Osciak 
>> Signed-off-by: Arun Kumar K 
>> ---
>>  drivers/media/platform/s5p-mfc/s5p_mfc.c |2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c
>> b/drivers/media/platform/s5p-mfc/s5p_mfc.c
>> index e2aac59..66c1775 100644
>> --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
>> +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
>> @@ -360,7 +360,7 @@ static void s5p_mfc_handle_frame(struct s5p_mfc_ctx
>> *ctx,
>>  list);
>>  ctx->consumed_stream += s5p_mfc_hw_call(dev->mfc_ops,
>>  get_consumed_stream, dev);
>> -if (ctx->codec_mode != S5P_MFC_CODEC_H264_DEC &&
>> +if (ctx->codec_mode == S5P_MFC_CODEC_MPEG4_DEC &&
>>  ctx->consumed_stream + STUFF_BYTE <
>>  src_buf->b->v4l2_planes[0].bytesused) {
>>  /* Run MFC again on the same buffer */
> 
> I expressed my doubts to this patch in my previous email.
> I think that packed PB can also be found in other codecs such as H263.
> So please change to the following if this is a workaround for VP8 only.
> (The title says that it only changes behavior of VP8 decoding, so it is
> misleading).
> 

Yes it is seen as affecting only VP8 decoding.

> - if (ctx->codec_mode != S5P_MFC_CODEC_H264_DEC &&
> + if (ctx->codec_mode != S5P_MFC_CODEC_H264_DEC &&
> + ctx->codec_mode != S5P_MFC_CODEC_VP8_DEC &&
> 

Ok. I will change it this way.

> 
> Did you try to revert your patch https://patchwork.linuxtv.org/patch/15448/
> and checking if this fixes the problem for VP8?
> 

I am afraid it will not solve the VP8 issue as before that patch, it
used to check for ctx->codec_mode != S5P_MFC_CODEC_H264_DEC and frame
type is S5P_FIMV_DECODE_FRAME_P_FRAME, buffer was sent again to decode.
This condition can be triggered in VP8 case causing erroneous behaviour.

So I will make the change as you suggested above.

Regards
Arun

>> --
>> 1.7.9.5
> 
> Best wishes,
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 1/2] [media] v4l: Add source change event

2014-05-08 Thread Arun Kumar K
This event indicates that the video device has encountered
a source parameter change during runtime. This can typically be a
resolution change detected by a video decoder OR a format change
detected by an HDMI connector.

This needs to be nofified to the userspace and the application may
be expected to reallocate buffers before proceeding. The application
can subscribe to events on a specific pad or input/output port which
it is interested in.

Signed-off-by: Arun Kumar K 
---
 Documentation/DocBook/media/v4l/vidioc-dqevent.xml |   32 +
 .../DocBook/media/v4l/vidioc-subscribe-event.xml   |   19 +++
 drivers/media/v4l2-core/v4l2-event.c   |   36 
 include/media/v4l2-event.h |4 +++
 include/uapi/linux/videodev2.h |8 +
 5 files changed, 99 insertions(+)

diff --git a/Documentation/DocBook/media/v4l/vidioc-dqevent.xml 
b/Documentation/DocBook/media/v4l/vidioc-dqevent.xml
index 89891ad..6afabaa 100644
--- a/Documentation/DocBook/media/v4l/vidioc-dqevent.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-dqevent.xml
@@ -242,6 +242,22 @@
   
 
 
+
+  struct v4l2_event_src_change
+  
+   &cs-str;
+   
+ 
+   __u32
+   changes
+   
+ A bitmask that tells what has changed. See .
+   
+ 
+   
+  
+
+
 
   Changes
   
@@ -270,6 +286,22 @@

   
 
+
+
+  Source Changes
+  
+   &cs-def;
+   
+ 
+   V4L2_EVENT_SRC_CH_RESOLUTION
+   0x0001
+   This event gets triggered when a resolution change is
+   detected at runtime. This can typically come from a video decoder.
+   
+ 
+   
+  
+
   
   
 &return-value;
diff --git a/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml 
b/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml
index 5c70b61..8012829 100644
--- a/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml
@@ -155,6 +155,25 @@

  
  
+   V4L2_EVENT_SOURCE_CHANGE
+   5
+   
+ This event is triggered when a format change is
+  detected during runtime by the video device. It can be a
+  runtime resolution change triggered by a video decoder or the
+  format change happening on an HDMI connector.
+  This event requires that the id
+   matches the pad/input/output index from which you want to
+  receive events.
+
+  This event has a &v4l2-event-source-change; associated
+ with it. The changes bitfield denotes
+ what has changed for the subscribed pad. If multiple events
+ occured before application could dequeue them, then the changes
+ will have the ORed value of all the events generated.
+   
+ 
+ 
V4L2_EVENT_PRIVATE_START
0x0800
Base event number for driver-private events.
diff --git a/drivers/media/v4l2-core/v4l2-event.c 
b/drivers/media/v4l2-core/v4l2-event.c
index 86dcb54..8761aab 100644
--- a/drivers/media/v4l2-core/v4l2-event.c
+++ b/drivers/media/v4l2-core/v4l2-event.c
@@ -318,3 +318,39 @@ int v4l2_event_subdev_unsubscribe(struct v4l2_subdev *sd, 
struct v4l2_fh *fh,
return v4l2_event_unsubscribe(fh, sub);
 }
 EXPORT_SYMBOL_GPL(v4l2_event_subdev_unsubscribe);
+
+static void v4l2_event_src_replace(struct v4l2_event *old,
+   const struct v4l2_event *new)
+{
+   u32 old_changes = old->u.src_change.changes;
+
+   old->u.src_change = new->u.src_change;
+   old->u.src_change.changes |= old_changes;
+}
+
+static void v4l2_event_src_merge(const struct v4l2_event *old,
+   struct v4l2_event *new)
+{
+   new->u.src_change.changes |= old->u.src_change.changes;
+}
+
+static const struct v4l2_subscribed_event_ops v4l2_event_src_ch_ops = {
+   .replace = v4l2_event_src_replace,
+   .merge = v4l2_event_src_merge,
+};
+
+int v4l2_src_change_event_subscribe(struct v4l2_fh *fh,
+   const struct v4l2_event_subscription *sub)
+{
+   if (sub->type == V4L2_EVENT_SOURCE_CHANGE)
+   return v4l2_event_subscribe(fh, sub, 0, &v4l2_event_src_ch_ops);
+   return -EINVAL;
+}
+EXPORT_SYMBOL_GPL(v4l2_src_change_event_subscribe);
+
+int v4l2_src_change_event_subdev_subscribe(struct v4l2_subdev *sd,
+   struct v4l2_fh *fh, struct v4l2_event_subscription *sub)
+{
+   return v4l2_src_change_event_subscribe(fh, sub);
+}
+EXPORT_SYMBOL_GPL(v4l2_src_change_event_subdev_subscribe);
diff --git a/include/media/v4l2-event.h b/include/media/v4l2-event.h
index be05d01..1ab9045 100644
--- a/include/me

[PATCH v3 0/2] Add resolution change event

2014-05-08 Thread Arun Kumar K
This patchset adds a source_change event to the v4l2-events.
This can be used for notifying the userspace about runtime
format changes happening on video nodes / pads like resolution
change in video decoder.

This version includes suggestions from Hans and Laurent
to make it more generic and to be used by all kinds of
video devices to notify userspace about runtime parameter
changes. The discussion can be seen here [1]

If this is accepted, I can send another series implementing
v4l2_event_init() for zeoring the data array addressing
compatibility issues as discussed in [1].

[1] https://patchwork.kernel.org/patch/4023131/

Changes from v2
---
- Event can be subscribed on specific pad / port as
  suggested by Hans.

Changes from v1
---
- Addressed review comments from Hans and Laurent
  https://patchwork.kernel.org/patch/4000951/

Arun Kumar K (1):
  [media] v4l: Add source change event

Pawel Osciak (1):
  [media] s5p-mfc: Add support for resolution change event

 Documentation/DocBook/media/v4l/vidioc-dqevent.xml |   32 +
 .../DocBook/media/v4l/vidioc-subscribe-event.xml   |   19 +++
 drivers/media/platform/s5p-mfc/s5p_mfc.c   |7 
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c   |2 ++
 drivers/media/v4l2-core/v4l2-event.c   |   36 
 include/media/v4l2-event.h |4 +++
 include/uapi/linux/videodev2.h |8 +
 7 files changed, 108 insertions(+)

-- 
1.7.9.5

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


[PATCH v3 2/2] [media] s5p-mfc: Add support for resolution change event

2014-05-08 Thread Arun Kumar K
From: Pawel Osciak 

When a resolution change point is reached, queue an event to signal the
userspace that a new set of buffers is required before decoding can
continue.

Signed-off-by: Pawel Osciak 
Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c |7 +++
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c |2 ++
 2 files changed, 9 insertions(+)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 07c3d5e..c25a2b0 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -320,6 +320,7 @@ static void s5p_mfc_handle_frame(struct s5p_mfc_ctx *ctx,
struct s5p_mfc_buf *src_buf;
unsigned long flags;
unsigned int res_change;
+   struct v4l2_event ev;
 
dst_frame_status = s5p_mfc_hw_call(dev->mfc_ops, get_dspl_status, dev)
& S5P_FIMV_DEC_STATUS_DECODING_STATUS_MASK;
@@ -351,6 +352,12 @@ static void s5p_mfc_handle_frame(struct s5p_mfc_ctx *ctx,
if (ctx->state == MFCINST_RES_CHANGE_FLUSH) {
s5p_mfc_handle_frame_all_extracted(ctx);
ctx->state = MFCINST_RES_CHANGE_END;
+
+   memset(&ev, 0, sizeof(struct v4l2_event));
+   ev.type = V4L2_EVENT_SOURCE_CHANGE;
+   ev.u.src_change.changes = V4L2_EVENT_SRC_CH_RESOLUTION;
+   v4l2_event_queue_fh(&ctx->fh, &ev);
+
goto leave_handle_frame;
} else {
s5p_mfc_handle_frame_all_extracted(ctx);
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
index 4f94491..b383829 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
@@ -855,6 +855,8 @@ static int vidioc_subscribe_event(struct v4l2_fh *fh,
switch (sub->type) {
case V4L2_EVENT_EOS:
return v4l2_event_subscribe(fh, sub, 2, NULL);
+   case V4L2_EVENT_SOURCE_CHANGE:
+   return v4l2_src_change_event_subscribe(fh, sub);
default:
return -EINVAL;
}
-- 
1.7.9.5

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


[PATCH] [media] s5p-mfc: Update scratch buffer size for VP8 encoder

2014-05-07 Thread Arun Kumar K
From: Kiran AVND 

Scratch buffer size updated for vp8 encoding as per
the latest v7 firmware. As the new macro increases the
scratch buffer size, it is backward compatible with the older
firmware too.

Signed-off-by: Kiran AVND 
Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/regs-mfc-v7.h |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v7.h 
b/drivers/media/platform/s5p-mfc/regs-mfc-v7.h
index 82c96fa..1a5c6fd 100644
--- a/drivers/media/platform/s5p-mfc/regs-mfc-v7.h
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v7.h
@@ -54,6 +54,7 @@
(SZ_1M + ((w) * 144) + (8192 * (h)) + 49216)
 
 #define S5P_FIMV_SCRATCH_BUF_SIZE_VP8_ENC_V7(w, h) \
-   (((w) * 48) + (((w) + 1) / 2 * 128) + 144 + 8192)
+   (((w) * 48) + 8192 + w) + 1) / 2) * 128) + 144 + \
+   ((w) * 16) * ((h) * 16)) * 3) / 2) * 4))
 
 #endif /*_REGS_MFC_V7_H*/
-- 
1.7.9.5

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


[PATCH] [media] s5p-mfc: Dequeue sequence header after STREAMON

2014-05-07 Thread Arun Kumar K
MFCv6 encoder needs specific minimum number of buffers to
be queued in the CAPTURE plane. This minimum number will
be known only when the sequence header is generated.
So we used to allow STREAMON on the CAPTURE plane only after
sequence header is generated and checked with the minimum
buffer requirement.

But this causes a problem that we call a vb2_buffer_done
for the sequence header buffer before doing a STREAON on the
CAPTURE plane. This used to still work fine until this patch
was merged b3379c6201bb3555298cdbf0aa004af260f2a6a4.

This problem should also come in earlier MFC firmware versions
if the application calls STREAMON on CAPTURE with some delay
after doing STREAMON on OUTPUT.

So this patch keeps the header buffer until the other frame
buffers are ready and dequeues it just before the first frame
is ready.

Signed-off-by: Arun Kumar K 
---
 drivers/media/platform/s5p-mfc/s5p_mfc_common.h |2 ++
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c|6 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h 
b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index d64b680..4fd1034 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -523,6 +523,7 @@ struct s5p_mfc_codec_ops {
  * @output_state:  state of the output buffers queue
  * @src_bufs:  information on allocated source buffers
  * @dst_bufs:  information on allocated destination buffers
+ * @header_mb: buf pointer of the encoded sequence header
  * @sequence:  counter for the sequence number for v4l2
  * @dec_dst_flag:  flags for buffers queued in the hardware
  * @dec_src_buf_size:  size of the buffer for source buffers in decoding
@@ -607,6 +608,7 @@ struct s5p_mfc_ctx {
int src_bufs_cnt;
struct s5p_mfc_buf dst_bufs[MFC_MAX_BUFFERS];
int dst_bufs_cnt;
+   struct s5p_mfc_buf *header_mb;
 
unsigned int sequence;
unsigned long dec_dst_flag;
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index a9a23e1..e7dddb0 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -787,7 +787,7 @@ static int enc_post_seq_start(struct s5p_mfc_ctx *ctx)
ctx->dst_queue_cnt--;
vb2_set_plane_payload(dst_mb->b, 0,
s5p_mfc_hw_call(dev->mfc_ops, get_enc_strm_size, dev));
-   vb2_buffer_done(dst_mb->b, VB2_BUF_STATE_DONE);
+   ctx->header_mb = dst_mb;
spin_unlock_irqrestore(&dev->irqlock, flags);
}
 
@@ -845,6 +845,10 @@ static int enc_post_frame_start(struct s5p_mfc_ctx *ctx)
unsigned int strm_size;
unsigned long flags;
 
+   if (ctx->header_mb) {
+   vb2_buffer_done(ctx->header_mb->b, VB2_BUF_STATE_DONE);
+   ctx->header_mb = NULL;
+   }
slice_type = s5p_mfc_hw_call(dev->mfc_ops, get_enc_slice_type, dev);
strm_size = s5p_mfc_hw_call(dev->mfc_ops, get_enc_strm_size, dev);
mfc_debug(2, "Encoded slice type: %d\n", slice_type);
-- 
1.7.9.5

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


  1   2   3   4   5   >