[PATCH -next] [media] go7007: fix invalid use of sizeof in go7007_usb_i2c_master_xfer()

2013-03-26 Thread Wei Yongjun
From: Wei Yongjun yongjun_...@trendmicro.com.cn

sizeof() when applied to a pointer typed expression gives the
size of the pointer, not that of the pointed data.

Signed-off-by: Wei Yongjun yongjun_...@trendmicro.com.cn
---
 drivers/staging/media/go7007/go7007-usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/go7007/go7007-usb.c 
b/drivers/staging/media/go7007/go7007-usb.c
index 0823506..7219ae0 100644
--- a/drivers/staging/media/go7007/go7007-usb.c
+++ b/drivers/staging/media/go7007/go7007-usb.c
@@ -1035,7 +1035,7 @@ static int go7007_usb_i2c_master_xfer(struct i2c_adapter 
*adapter,
buf, buf_len, 0)  0)
goto i2c_done;
if (msgs[i].flags  I2C_M_RD) {
-   memset(buf, 0, sizeof(buf));
+   memset(buf, 0, sizeof(*buf));
if (go7007_usb_vendor_request(go, 0x25, 0, 0, buf,
msgs[i].len + 1, 1)  0)
goto i2c_done;


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


Re: [PATCH -next] [media] go7007: fix invalid use of sizeof in go7007_usb_i2c_master_xfer()

2013-03-26 Thread Dan Carpenter
On Tue, Mar 26, 2013 at 02:42:47PM +0800, Wei Yongjun wrote:
 From: Wei Yongjun yongjun_...@trendmicro.com.cn
 
 sizeof() when applied to a pointer typed expression gives the
 size of the pointer, not that of the pointed data.


This fix isn't right.  buf is a char pointer.  I don't know what
this code is doing.  Instead of sizeof(*buf) it should be something
like buflen, msg[i].len, msg[i].len + 1 or msg[i].len + 3.

I'm not sure which is correct here or what it's doing, sorry.

regards,
dan carpenter

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


[PATCH v2] [media] s5p-mfc: Modify encoder buffer alloc sequence

2013-03-26 Thread Arun Kumar K
MFC v6 needs minimum number of output buffers to be queued
for encoder depending on the stream type and profile.
For achieving this the sequence for allocating buffers at
the encoder is modified similar to that of decoder.
The new sequence is as follows:

1) Set format on CAPTURE plane
2) REQBUF on CAPTURE
3) QBUFS and STREAMON on CAPTURE
4) G_CTRL to get minimum buffers for OUTPUT plane
5) REQBUF on OUTPUT with the minimum buffers given by driver

This also fixes the crash happeninig during multi instance encoder-
decoder simultaneous run due to memory allocation happening from
interrupt context.

Signed-off-by: Arun Kumar K arun...@samsung.com
---
Changes from v1
- Corrected the commit message as pointed out by John Sheu.
  http://www.spinics.net/lists/linux-media/msg61477.html
---
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c|   98 +++
 drivers/media/platform/s5p-mfc/s5p_mfc_opr.h|1 +
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c |7 ++
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c |   95 +-
 4 files changed, 147 insertions(+), 54 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index 4f6b553..46ca986 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -557,6 +557,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)
@@ -661,18 +671,17 @@ static int enc_post_seq_start(struct s5p_mfc_ctx *ctx)
vb2_buffer_done(dst_mb-b, VB2_BUF_STATE_DONE);
spin_unlock_irqrestore(dev-irqlock, flags);
}
-   if (IS_MFCV6(dev)) {
-   ctx-state = MFCINST_HEAD_PARSED; /* for INIT_BUFFER cmd */
-   } else {
+
+   if (!IS_MFCV6(dev)) {
ctx-state = MFCINST_RUNNING;
if (s5p_mfc_ctx_ready(ctx))
set_work_bit_irqsave(ctx);
s5p_mfc_hw_call(dev-mfc_ops, try_run, dev);
-   }
-
-   if (IS_MFCV6(dev))
+   } else {
ctx-dpb_count = s5p_mfc_hw_call(dev-mfc_ops,
get_enc_dpb_count, dev);
+   ctx-state = MFCINST_HEAD_PARSED;
+   }
 
return 0;
 }
@@ -1055,15 +1064,13 @@ static int vidioc_reqbufs(struct file *file, void *priv,
}
ctx-capture_state = QUEUE_BUFS_REQUESTED;
 
-   if (!IS_MFCV6(dev)) {
-   ret = s5p_mfc_hw_call(ctx-dev-mfc_ops,
-   alloc_codec_buffers, ctx);
-   if (ret) {
-   mfc_err(Failed to allocate encoding 
buffers\n);
-   reqbufs-count = 0;
-   ret = vb2_reqbufs(ctx-vq_dst, reqbufs);
-   return -ENOMEM;
-   }
+   ret = s5p_mfc_hw_call(ctx-dev-mfc_ops,
+   alloc_codec_buffers, ctx);
+   if (ret) {
+   mfc_err(Failed to allocate encoding buffers\n);
+   reqbufs-count = 0;
+   ret = vb2_reqbufs(ctx-vq_dst, reqbufs);
+   return -ENOMEM;
}
} else if (reqbufs-type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
if (ctx-output_state != QUEUE_FREE) {
@@ -1071,12 +1078,35 @@ static int vidioc_reqbufs(struct file *file, void *priv,
ctx-output_state);
return -EINVAL;
}
+
+   if (IS_MFCV6(dev)) {
+   if (!ctx-dpb_count) {
+   mfc_err(Streamon on CAPTURE plane should be\n
+   done first\n);
+   return -EINVAL;
+   }
+   /* Check for min encoder buffers */
+   if (reqbufs-count  ctx-dpb_count) {
+   mfc_err(Minimum %d output buffers needed\n,
+   ctx-dpb_count);
+   return -EINVAL;
+   }
+   }
+
ret = vb2_reqbufs(ctx-vq_src, reqbufs);
if (ret != 0) {
mfc_err(error in vb2_reqbufs() for E(S)\n);
return ret;
}
ctx-output_state = QUEUE_BUFS_REQUESTED;
+
+   

Re: [PATCH -next] [media] go7007: fix invalid use of sizeof in go7007_usb_i2c_master_xfer()

2013-03-26 Thread Dan Carpenter
On Tue, Mar 26, 2013 at 10:04:15AM +0300, Dan Carpenter wrote:
 On Tue, Mar 26, 2013 at 02:42:47PM +0800, Wei Yongjun wrote:
  From: Wei Yongjun yongjun_...@trendmicro.com.cn
  
  sizeof() when applied to a pointer typed expression gives the
  size of the pointer, not that of the pointed data.
 
 
 This fix isn't right.  buf is a char pointer.  I don't know what
 this code is doing.  Instead of sizeof(*buf) it should be something
 like buflen, msg[i].len, msg[i].len + 1 or msg[i].len + 3.

It should be msg[i].len + 1, I think.

On the line before it writes buflen bytes to the hardware.  Then
it clears the transfer buffer and reads msg[i].len + 1 bytes from
the hardware.  Then it saves the memory, except for the first byte,
in msg[i].buf.

So it should clear msg[i].len + 1 bytes so that the old data isn't
confused with the data that we read from the hardware.

regards,
dan carpenter

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


Re: [PATCH -next] [media] go7007: fix invalid use of sizeof in go7007_usb_i2c_master_xfer()

2013-03-26 Thread Hans Verkuil
On Tue March 26 2013 08:35:57 Dan Carpenter wrote:
 On Tue, Mar 26, 2013 at 10:04:15AM +0300, Dan Carpenter wrote:
  On Tue, Mar 26, 2013 at 02:42:47PM +0800, Wei Yongjun wrote:
   From: Wei Yongjun yongjun_...@trendmicro.com.cn
   
   sizeof() when applied to a pointer typed expression gives the
   size of the pointer, not that of the pointed data.
  
  
  This fix isn't right.  buf is a char pointer.  I don't know what
  this code is doing.  Instead of sizeof(*buf) it should be something
  like buflen, msg[i].len, msg[i].len + 1 or msg[i].len + 3.
 
 It should be msg[i].len + 1, I think.

Yes, that's correct.

'buf' used to be a local array, so the memset was fine. I changed it to an
array that was kmalloc()ed but forgot about the memset. I never noticed
the bug because the sizeof the message is typically quite small, certainly
smaller than sizeof(pointer) on a 64-bit system.

Wei Yongjun, can you post a new patch fixing this?

Thanks,

Hans

 
 On the line before it writes buflen bytes to the hardware.  Then
 it clears the transfer buffer and reads msg[i].len + 1 bytes from
 the hardware.  Then it saves the memory, except for the first byte,
 in msg[i].buf.
 
 So it should clear msg[i].len + 1 bytes so that the old data isn't
 confused with the data that we read from the hardware.
 
 regards,
 dan carpenter
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-media in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Terratec Grabby hwrev 2

2013-03-26 Thread Timo Teras
On Mon, 25 Mar 2013 21:12:38 +0200
Timo Teras timo.te...@iki.fi wrote:

 On Mon, 25 Mar 2013 15:32:20 -0300
 Mauro Carvalho Chehab mche...@redhat.com wrote:
 
  Em Mon, 25 Mar 2013 19:48:20 +0200
  Timo Teras timo.te...@iki.fi escreveu:
  
   On Mon, 25 Mar 2013 14:36:47 -0300
   Mauro Carvalho Chehab mche...@redhat.com wrote:
   
Em Mon, 25 Mar 2013 19:08:46 +0200
Timo Teras timo.te...@iki.fi escreveu:

 I just bought a Terratec Grabby hardware revision 2 in hopes
 that it would work on my linux box.
 
 But alas, I got only sound working. It seems that analog video
 picture grabbing does not work.
 
 I tried kernels 3.4.34-grsec, 3.7.1 (vanilla), 3.8.2-grsec and
 3.9.0-rc4 (vanilla). And all fail the same way - no video data
 received.
 
 The USB ID is same as on the revision 1 board:
 Bus 005 Device 002: ID 0ccd:0096 TerraTec Electronic GmbH
 
 And it is properly detected as Grabby.
 
 It seems that the videobuf2 changes for 3.9.0-rc4 resulted in
 better debug logging, and it implies that the application
 (ffmpeg 1.1.4) is behaving well: all buffers are allocated,
 mmapped, queued, streamon called. But no data is received from
 the dongle. I also tested mencoder and it fails in similar
 manner.
 
 Dmesg (on 3.9.0-rc4) tells after module load the following:
  
 [ 1250.076845] em2860 #0: AC97 vendor ID = 0x60f160f1
 [ 1250.086814] em2860 #0: AC97 features = 0x60f1

That looks weird on my eyes: 3 AC97 reads returned 0x60f1. I
suspect that the GPIOs for this device are different than on
version 1.
   
   Yes, I just noticed this now too. It seems something went wrong
   when loading em28xx with a bunch of debug logging enabled. On
   normal load it returns instead:
   
   [   12.453631] em2860 #0: AC97 vendor ID = 0x83847650
   [   12.463650] em2860 #0: AC97 features = 0x6a90
   [   12.463658] em2860 #0: Empia 202 AC97 audio processor detected
  
  Weird. Except for an additional delay, those debug stuff shouldn't
  be changing the driver's behavior.
  
  Are those results consistent? There are some known problems with a
  few em28xx devices that, from time to time, aren't able to read
  data from the eeprom. On such devices, it is a hardware issue.
 
 Actually it seems consistent that:
 1. load em28xx - attach USB - fail
 2. attach USB - load em28xx - success
 
 Sounds like if the driver is loaded, it tries to access eeprom while
 it's still initializing or something like that.
 
 Any suggestions how to debug/fix this?

The better is to run the original driver at a recent version of
KVM with USB port forward enabled, and capture the USB logs.
There are some pages at LinuxTV wiki explaining how to do it.
   
   Oh, ok. Seems Wireshark/USBPcap might be better option for me as I
   don't have KVMed Windows install handy. Will try to get traces
   from it.
  
  Ok, thanks!
 
 Seems that USBPcap needs compiling and TESTSIGNING enabled - so I'd
 rather avoid it.
 
 I did get etl format windows captures via logman start usbtrace.
 Can you read those, or know anyway to convert them to text / something
 wireshark reads?

Seems not easily. And all the nice looking USB tracers cost money to
get anything out.

I did manage to get decent traces with USBlyzer evaluation version.

The output is at:
http://dev.alpinelinux.org/~tteras/grabby-rev2-init.html

I had to add by hand the 'R xx' notes (Setup Packet wIndex) in Request
Details for VendorDevice requests. Thus they are present only in the
ones close to when the Isoch transfer starts. If you need more of them,
let me know and I can paste them. Alternatively, I can dump the
USBlyzer format capture somewhere if you have a windows with the
program installed.

The sequence to create capture was:
 1. Attach USB device
 2. Start capture
 3. Start program that uses initiates video capture
 4. Stop program
 5. Stop capture

So it should contain everything done at stream on time.

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


Re: [PATCH -next] [media] go7007: remove unused including linux/version.h

2013-03-26 Thread Hans Verkuil
On Tue March 26 2013 06:45:51 Wei Yongjun wrote:
 From: Wei Yongjun yongjun_...@trendmicro.com.cn
 
 Remove including linux/version.h that don't need it.

The include is already removed.

Regards,

Hans

 
 Signed-off-by: Wei Yongjun yongjun_...@trendmicro.com.cn
 ---
  drivers/staging/media/go7007/go7007-v4l2.c | 1 -
  1 file changed, 1 deletion(-)
 
 diff --git a/drivers/staging/media/go7007/go7007-v4l2.c 
 b/drivers/staging/media/go7007/go7007-v4l2.c
 index 24ba50e..50eb69a 100644
 --- a/drivers/staging/media/go7007/go7007-v4l2.c
 +++ b/drivers/staging/media/go7007/go7007-v4l2.c
 @@ -17,7 +17,6 @@
  
  #include linux/module.h
  #include linux/init.h
 -#include linux/version.h
  #include linux/delay.h
  #include linux/sched.h
  #include linux/spinlock.h
 
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-media in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH -next] [media] tw9906: remove unused including linux/version.h

2013-03-26 Thread Hans Verkuil
On Tue March 26 2013 06:51:54 Wei Yongjun wrote:
 From: Wei Yongjun yongjun_...@trendmicro.com.cn
 
 Remove including linux/version.h that don't need it.

The include has already been removed.

Regards,

Hans

 Signed-off-by: Wei Yongjun yongjun_...@trendmicro.com.cn
 ---
  drivers/media/i2c/tw9906.c | 1 -
  1 file changed, 1 deletion(-)
 
 diff --git a/drivers/media/i2c/tw9906.c b/drivers/media/i2c/tw9906.c
 index 2263a91..d94325b 100644
 --- a/drivers/media/i2c/tw9906.c
 +++ b/drivers/media/i2c/tw9906.c
 @@ -17,7 +17,6 @@
  
  #include linux/module.h
  #include linux/init.h
 -#include linux/version.h
  #include linux/i2c.h
  #include linux/videodev2.h
  #include linux/ioctl.h
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-media in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH -next] [media] go7007: fix invalid use of sizeof in go7007_usb_i2c_master_xfer()

2013-03-26 Thread Wei Yongjun
Hi Hans and Dan Carpenter,

On 03/26/2013 04:18 PM, Hans Verkuil wrote:
 On Tue March 26 2013 08:35:57 Dan Carpenter wrote:
 On Tue, Mar 26, 2013 at 10:04:15AM +0300, Dan Carpenter wrote:
 On Tue, Mar 26, 2013 at 02:42:47PM +0800, Wei Yongjun wrote:
 From: Wei Yongjun yongjun_...@trendmicro.com.cn

 sizeof() when applied to a pointer typed expression gives the
 size of the pointer, not that of the pointed data.

 This fix isn't right.  buf is a char pointer.  I don't know what
 this code is doing.  Instead of sizeof(*buf) it should be something
 like buflen, msg[i].len, msg[i].len + 1 or msg[i].len + 3.
 It should be msg[i].len + 1, I think.
 Yes, that's correct.

 'buf' used to be a local array, so the memset was fine. I changed it to an
 array that was kmalloc()ed but forgot about the memset. I never noticed
 the bug because the sizeof the message is typically quite small, certainly
 smaller than sizeof(pointer) on a 64-bit system.

 Wei Yongjun, can you post a new patch fixing this?

Thanks very much, I will send the v2 of this patch soon.

Regards,
Yongjun





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


[PATCH -next v2] [media] go7007: fix invalid use of sizeof in go7007_usb_i2c_master_xfer()

2013-03-26 Thread Wei Yongjun
From: Wei Yongjun yongjun_...@trendmicro.com.cn

sizeof() when applied to a pointer typed expression gives the
size of the pointer, not that of the pointed data.

Signed-off-by: Wei Yongjun yongjun_...@trendmicro.com.cn
---
 drivers/staging/media/go7007/go7007-usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/go7007/go7007-usb.c 
b/drivers/staging/media/go7007/go7007-usb.c
index 0823506..d455c0b 100644
--- a/drivers/staging/media/go7007/go7007-usb.c
+++ b/drivers/staging/media/go7007/go7007-usb.c
@@ -1035,7 +1035,7 @@ static int go7007_usb_i2c_master_xfer(struct i2c_adapter 
*adapter,
buf, buf_len, 0)  0)
goto i2c_done;
if (msgs[i].flags  I2C_M_RD) {
-   memset(buf, 0, sizeof(buf));
+   memset(buf, 0, msgs[i].len + 1);
if (go7007_usb_vendor_request(go, 0x25, 0, 0, buf,
msgs[i].len + 1, 1)  0)
goto i2c_done;


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


Re: [PATCH -next v2] [media] go7007: fix invalid use of sizeof in go7007_usb_i2c_master_xfer()

2013-03-26 Thread Hans Verkuil
On Tue March 26 2013 09:45:11 Wei Yongjun wrote:
 From: Wei Yongjun yongjun_...@trendmicro.com.cn
 
 sizeof() when applied to a pointer typed expression gives the
 size of the pointer, not that of the pointed data.
 
 Signed-off-by: Wei Yongjun yongjun_...@trendmicro.com.cn

Acked-by: Hans Verkuil hans.verk...@cisco.com

Thanks!

Hans

 ---
  drivers/staging/media/go7007/go7007-usb.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/staging/media/go7007/go7007-usb.c 
 b/drivers/staging/media/go7007/go7007-usb.c
 index 0823506..d455c0b 100644
 --- a/drivers/staging/media/go7007/go7007-usb.c
 +++ b/drivers/staging/media/go7007/go7007-usb.c
 @@ -1035,7 +1035,7 @@ static int go7007_usb_i2c_master_xfer(struct 
 i2c_adapter *adapter,
   buf, buf_len, 0)  0)
   goto i2c_done;
   if (msgs[i].flags  I2C_M_RD) {
 - memset(buf, 0, sizeof(buf));
 + memset(buf, 0, msgs[i].len + 1);
   if (go7007_usb_vendor_request(go, 0x25, 0, 0, buf,
   msgs[i].len + 1, 1)  0)
   goto i2c_done;
 
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-media in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH -next] [media] af9035: fix missing unlock on error in af9035_ctrl_msg()

2013-03-26 Thread Antti Palosaari

On 03/26/2013 07:32 AM, Wei Yongjun wrote:

From: Wei Yongjun yongjun_...@trendmicro.com.cn

Add the missing unlock before return from function af9035_ctrl_msg()
in the error handling case.

Signed-off-by: Wei Yongjun yongjun_...@trendmicro.com.cn


Acked-by: Antti Palosaari cr...@iki.fi
Reviewed-by: Antti Palosaari cr...@iki.fi



---
  drivers/media/usb/dvb-usb-v2/af9035.c | 17 +
  1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c 
b/drivers/media/usb/dvb-usb-v2/af9035.c
index b1f7059..b638fc1 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -57,7 +57,7 @@ static int af9035_ctrl_msg(struct dvb_usb_device *d, struct 
usb_req *req)
dev_err(d-udev-dev, %s: too much data wlen=%d rlen=%d\n,
__func__, req-wlen, req-rlen);
ret = -EINVAL;
-   goto err;
+   goto exit;
}

state-buf[0] = REQ_HDR_LEN + req-wlen + CHECKSUM_LEN - 1;
@@ -81,7 +81,7 @@ static int af9035_ctrl_msg(struct dvb_usb_device *d, struct 
usb_req *req)
ret = dvb_usbv2_generic_rw_locked(d,
state-buf, wlen, state-buf, rlen);
if (ret)
-   goto err;
+   goto exit;

/* no ack for those packets */
if (req-cmd == CMD_FW_DL)
@@ -95,28 +95,29 @@ static int af9035_ctrl_msg(struct dvb_usb_device *d, struct 
usb_req *req)
(%04x != %04x)\n, KBUILD_MODNAME, req-cmd,
tmp_checksum, checksum);
ret = -EIO;
-   goto err;
+   goto exit;
}

/* check status */
if (state-buf[2]) {
/* fw returns status 1 when IR code was not received */
-   if (req-cmd == CMD_IR_GET || state-buf[2] == 1)
-   return 1;
+   if (req-cmd == CMD_IR_GET || state-buf[2] == 1) {
+   ret = 1;
+   goto exit;
+   }

dev_dbg(d-udev-dev, %s: command=%02x failed fw error=%d\n,
__func__, req-cmd, state-buf[2]);
ret = -EIO;
-   goto err;
+   goto exit;
}

/* read request, copy returned data to return buf */
if (req-rlen)
memcpy(req-rbuf, state-buf[ACK_HDR_LEN], req-rlen);
  exit:
-err:
mutex_unlock(d-usb_mutex);
-   if (ret)
+   if (ret  0)
dev_dbg(d-udev-dev, %s: failed=%d\n, __func__, ret);
return ret;
  }





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


Re: [PATCH -next] [media] af9035: fix missing unlock on error in af9035_ctrl_msg()

2013-03-26 Thread Antti Palosaari
@Mauro, that bug is new and coming as I rebased AF9035 IR code to the 
new AF9035 non-stacked usb buffers, which introduces that mutex. Just 
apply it to the current master.


regards
Antti



On 03/26/2013 11:46 AM, Antti Palosaari wrote:

On 03/26/2013 07:32 AM, Wei Yongjun wrote:

From: Wei Yongjun yongjun_...@trendmicro.com.cn

Add the missing unlock before return from function af9035_ctrl_msg()
in the error handling case.

Signed-off-by: Wei Yongjun yongjun_...@trendmicro.com.cn


Acked-by: Antti Palosaari cr...@iki.fi
Reviewed-by: Antti Palosaari cr...@iki.fi



---
  drivers/media/usb/dvb-usb-v2/af9035.c | 17 +
  1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c
b/drivers/media/usb/dvb-usb-v2/af9035.c
index b1f7059..b638fc1 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -57,7 +57,7 @@ static int af9035_ctrl_msg(struct dvb_usb_device *d,
struct usb_req *req)
  dev_err(d-udev-dev, %s: too much data wlen=%d rlen=%d\n,
  __func__, req-wlen, req-rlen);
  ret = -EINVAL;
-goto err;
+goto exit;
  }

  state-buf[0] = REQ_HDR_LEN + req-wlen + CHECKSUM_LEN - 1;
@@ -81,7 +81,7 @@ static int af9035_ctrl_msg(struct dvb_usb_device *d,
struct usb_req *req)
  ret = dvb_usbv2_generic_rw_locked(d,
  state-buf, wlen, state-buf, rlen);
  if (ret)
-goto err;
+goto exit;

  /* no ack for those packets */
  if (req-cmd == CMD_FW_DL)
@@ -95,28 +95,29 @@ static int af9035_ctrl_msg(struct dvb_usb_device
*d, struct usb_req *req)
  (%04x != %04x)\n, KBUILD_MODNAME, req-cmd,
  tmp_checksum, checksum);
  ret = -EIO;
-goto err;
+goto exit;
  }

  /* check status */
  if (state-buf[2]) {
  /* fw returns status 1 when IR code was not received */
-if (req-cmd == CMD_IR_GET || state-buf[2] == 1)
-return 1;
+if (req-cmd == CMD_IR_GET || state-buf[2] == 1) {
+ret = 1;
+goto exit;
+}

  dev_dbg(d-udev-dev, %s: command=%02x failed fw error=%d\n,
  __func__, req-cmd, state-buf[2]);
  ret = -EIO;
-goto err;
+goto exit;
  }

  /* read request, copy returned data to return buf */
  if (req-rlen)
  memcpy(req-rbuf, state-buf[ACK_HDR_LEN], req-rlen);
  exit:
-err:
  mutex_unlock(d-usb_mutex);
-if (ret)
+if (ret  0)
  dev_dbg(d-udev-dev, %s: failed=%d\n, __func__, ret);
  return ret;
  }








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


[PATCH] Fix undefined reference to `au8522_attach'

2013-03-26 Thread Hans Verkuil
au8522_attach is dependent on CONFIG_DVB_AU8522_DTV, not CONFIG_DVB_AU8522.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com

diff --git a/drivers/media/dvb-frontends/au8522.h 
b/drivers/media/dvb-frontends/au8522.h
index f2111e0..83fe9a6 100644
--- a/drivers/media/dvb-frontends/au8522.h
+++ b/drivers/media/dvb-frontends/au8522.h
@@ -61,7 +61,7 @@ struct au8522_config {
enum au8522_if_freq qam_if;
 };
 
-#if IS_ENABLED(CONFIG_DVB_AU8522)
+#if IS_ENABLED(CONFIG_DVB_AU8522_DTV)
 extern struct dvb_frontend *au8522_attach(const struct au8522_config *config,
  struct i2c_adapter *i2c);
 #else
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC 01/12] exynos-fimc-is: Adding device tree nodes

2013-03-26 Thread Arun Kumar K
Hi Sylwester,

Thank you for the review.


 +Sensor sub-nodes:
 +
 +FIMC-IS IP supports custom built sensors to be controlled exclusively by
 +the FIMC-IS firmware. These sensor properties are to be defined here.


[snip]


 Defining image sensor nodes in a standard way as ISP I2C bus controller
 nodes has an disadvantage that we need dummy I2C bus controller driver,
 at least this is how I have written the driver for Exynos4x12. In some
 version of it I had sensor nodes put in a isp-i2c fimc-is sub-node, but
 then there was an issue that this was not a fully specified I2C bus
 controller node.

 You can refer to my exynos4 fimc-is patch series for details on how this
 is now implemented.

 Handling the image sensor in a standard way, as regular I2C client devices
 has an advantage that we can put pinctrl properties in relevant device
 nodes,
 where available, which more closely describes the hardware structure.

 I'm not really sure in 100% if all this complication is required. It would
 allow to use same DT blob for different Imaging Subsystem SW architecture.
 For example some parts of functionality handled currently by FIMC-IS (ARM
 Cortex-A5) could be moved to host CPU, without any change in the device
 tree structure. The kernel could decide e.g. if it uses image sensor driver
 implemented in the ISP firmware, or a driver run on the host CPU.

 What do you think ?


I have seen your Exynos4 FIMC-IS patchset and you have made a dummy
I2C sensor driver there.
That mode would work fine in Exynos4 since the sensor and ISP will be used
by the same media controller pipeline. So the ISP component in the pipeline
will ensure that the HW is initialized and sensor is working.

But in Exynos5, we are using sensor in pipeline0 and ISP in pipeline1.
So there is a possibility of using sensor subdev independently
without using pipeline1 ISP components.

So with the driver I sent, the pipeline0 can still work like this --

ISP sensor --- MIPI-CSIS --- FIMC-LITE --- Memory

This cannot be done if a dummy I2C driver is made for ISP sensor.
What is your suggestion on this?

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


Re: [PATCH] block i2c tuner reads for Avermedia Twinstar in the af9035 driver

2013-03-26 Thread Jose Alberto Reguero
On Domingo, 24 de marzo de 2013 20:39:15 Jose Alberto Reguero escribió:
 On Domingo, 17 de marzo de 2013 23:46:06 Antti Palosaari escribió:
  On 03/17/2013 08:49 PM, Jose Alberto Reguero wrote:
   On Martes, 12 de marzo de 2013 00:11:38 Antti Palosaari escribió:
   On 03/11/2013 10:02 PM, Jose Alberto Reguero wrote:
   On Lunes, 11 de marzo de 2013 14:57:37 Antti Palosaari escribió:
   On 03/11/2013 01:51 PM, Jose Alberto Reguero wrote:
   On Lunes, 11 de febrero de 2013 14:48:18 Jose Alberto Reguero
 
 escribió:
   On Domingo, 10 de febrero de 2013 22:11:53 Antti Palosaari 
escribió:
   On 02/10/2013 09:43 PM, Jose Alberto Reguero wrote:
   This patch block the i2c tuner reads for Avermedia Twinstar. If
   it's
   needed other pids can be added.
   
   Signed-off-by: Jose Alberto Reguero jaregu...@telefonica.net
   
   diff -upr linux/drivers/media/usb/dvb-usb-v2/af9035.c
   linux.new/drivers/media/usb/dvb-usb-v2/af9035.c ---
   linux/drivers/media/usb/dvb-usb-v2/af9035.c2013-01-07
   05:45:57.0 +0100 +++
   linux.new/drivers/media/usb/dvb-usb-v2/af9035.c2013-02-08
   22:55:08.304089054 +0100 @@ -232,7 +232,11 @@ static int
   af9035_i2c_master_xfer(struct
   
  buf[3] = 0x00; /* reg addr MSB */
  buf[4] = 0x00; /* reg addr LSB */
  memcpy(buf[5], msg[0].buf, msg[0].len);
   
   -  ret = af9035_ctrl_msg(d, req);
   +  if (state-block_read) {
   +  msg[1].buf[0] = 0x3f;
   +  ret = 0;
   +  } else
   +  ret = af9035_ctrl_msg(d, req);
   
  }
  
  } else if (num == 1  !(msg[0].flags  I2C_M_RD)) {
  
  if (msg[0].len  40) {
   
   @@ -638,6 +642,17 @@ static int af9035_read_config(struct dvb
   
  for (i = 0; i  ARRAY_SIZE(state-af9033_config); i++)
  
  state-af9033_config[i].clock = clock_lut[tmp];
   
   +  state-block_read = false;
   +
   +  if (le16_to_cpu(d-udev-descriptor.idVendor) ==
   USB_VID_AVERMEDIA
   
   +  le16_to_cpu(d-udev-descriptor.idProduct) ==
   +  USB_PID_AVERMEDIA_TWINSTAR) {
   +  dev_dbg(d-udev-dev,
   +  %s: AverMedia Twinstar: block i2c read 
   from tuner\n,
   +  __func__);
   +  state-block_read = true;
   +  }
   +
   
  return 0;

err:
   diff -upr linux/drivers/media/usb/dvb-usb-v2/af9035.h
   linux.new/drivers/media/usb/dvb-usb-v2/af9035.h ---
   linux/drivers/media/usb/dvb-usb-v2/af9035.h2013-01-07
   05:45:57.0 +0100 +++
   linux.new/drivers/media/usb/dvb-usb-v2/af9035.h2013-02-08
   22:52:42.293842710 +0100 @@ -54,6 +54,7 @@ struct usb_req {
   
struct state {

  u8 seq; /* packet sequence number */
  bool dual_mode;
   
   +  bool block_read;
   
  struct af9033_config af9033_config[2];

};
   
   Could you test if faking tuner ID during attach() is enough?
   
   Also, I would like to know what is returned error code from
   firmware
   when it fails. Enable debugs to see it. It should print something
   like
   that: af9035_ctrl_msg: command=03 failed fw error=2
   
   
   diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c
   b/drivers/media/usb/dvb-usb-v2/af9035.c
   index a1e953a..5a4f28d 100644
   --- a/drivers/media/usb/dvb-usb-v2/af9035.c
   +++ b/drivers/media/usb/dvb-usb-v2/af9035.c
   @@ -1082,9 +1082,22 @@ static int af9035_tuner_attach(struct
   dvb_usb_adapter *adap)
   
   tuner_addr = 0x60 | 0x80; /* I2C bus
   hack
   */
   
   }
   
   +   // fake used tuner for demod firmware / i2c
   adapter
   +   if (adap-id == 0)
   +   ret = af9035_wr_reg(d, 0x00f641,
   AF9033_TUNER_FC0011);
   +   else
   +   ret = af9035_wr_reg(d, 0x10f641,
   AF9033_TUNER_FC0011);
   +
   
   /* attach tuner */
   fe = dvb_attach(mxl5007t_attach, adap-fe[0],
   d-i2c_adap,
   
   tuner_addr,
   
   af9035_mxl5007t_config[adap-id]);
   +
   +   // return correct tuner
   +   if (adap-id == 0)
   +   ret = af9035_wr_reg(d, 0x00f641,
   AF9033_TUNER_MXL5007T);
   +   else
   +   ret = af9035_wr_reg(d, 0x10f641,
   AF9033_TUNER_MXL5007T);
   +
   
   break;
   
   case AF9033_TUNER_TDA18218:
   /* attach tuner */
   
   regards
   Antti
   
   I will try with fake tuner, but I can't test unil 

[PATCH] staging: davinci: Fix typo in staging/media/davinci

2013-03-26 Thread Masanari Iida
Correct spelling typo in staging/media/davinci

Signed-off-by: Masanari Iida standby2...@gmail.com
---
 drivers/staging/media/davinci_vpfe/davinci-vpfe-mc.txt | 2 +-
 drivers/staging/media/davinci_vpfe/dm365_isif.c| 6 +++---
 drivers/staging/media/davinci_vpfe/vpfe_video.c| 8 
 drivers/staging/media/davinci_vpfe/vpfe_video.h| 2 +-
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/media/davinci_vpfe/davinci-vpfe-mc.txt 
b/drivers/staging/media/davinci_vpfe/davinci-vpfe-mc.txt
index 1dbd564..a1e9177 100644
--- a/drivers/staging/media/davinci_vpfe/davinci-vpfe-mc.txt
+++ b/drivers/staging/media/davinci_vpfe/davinci-vpfe-mc.txt
@@ -38,7 +38,7 @@ interface to userspace.
DAVINCI RESIZER A
DAVINCI RESIZER B
 
-Each possible link in the VPFE is modeled by a link in the Media controller
+Each possible link in the VPFE is modelled by a link in the Media controller
 interface. For an example program see [1].
 
 
diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.c 
b/drivers/staging/media/davinci_vpfe/dm365_isif.c
index ebeea72..6d4a93c 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_isif.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_isif.c
@@ -685,7 +685,7 @@ static void isif_config_bclamp(struct vpfe_isif_device 
*isif,
val = (bc-bc_mode_color  ISIF_BC_MODE_COLOR_MASK) 
ISIF_BC_MODE_COLOR_SHIFT;
 
-   /* Enable BC and horizontal clamp caculation paramaters */
+   /* Enable BC and horizontal clamp calculation paramaters */
val = val | 1 | ((bc-horz.mode  ISIF_HORZ_BC_MODE_MASK) 
  ISIF_HORZ_BC_MODE_SHIFT);
 
@@ -722,7 +722,7 @@ static void isif_config_bclamp(struct vpfe_isif_device 
*isif,
isif_write(isif-isif_cfg.base_addr, val, CLHWIN2);
}
 
-   /* vertical clamp caculation paramaters */
+   /* vertical clamp calculation paramaters */
/* OB H Valid */
val = bc-vert.ob_h_sz_calc  ISIF_VERT_BC_OB_H_SZ_MASK;
 
@@ -1569,7 +1569,7 @@ isif_pad_set_crop(struct v4l2_subdev *sd, struct 
v4l2_subdev_fh *fh,
crop-rect.width = format-width;
crop-rect.height = format-height;
}
-   /* adjust the width to 16 pixel boundry */
+   /* adjust the width to 16 pixel boundary */
crop-rect.width = ((crop-rect.width + 15)  ~0xf);
vpfe_isif-crop = crop-rect;
if (crop-which == V4L2_SUBDEV_FORMAT_ACTIVE) {
diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c 
b/drivers/staging/media/davinci_vpfe/vpfe_video.c
index 99ccbeb..c91d356 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_video.c
+++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c
@@ -357,7 +357,7 @@ static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe)
  *
  * Set the pipeline to the given stream state.
  *
- * Return 0 if successfull, or the return value of the failed video::s_stream
+ * Return 0 if successful, or the return value of the failed video::s_stream
  * operation otherwise.
  */
 static int vpfe_pipeline_set_stream(struct vpfe_pipeline *pipe,
@@ -644,7 +644,7 @@ static int vpfe_g_fmt(struct file *file, void *priv,
  * fills v4l2_fmtdesc structure with output format set on adjacent subdev,
  * only one format is enumearted as subdevs are already configured
  *
- * Return 0 if successfull, error code otherwise
+ * Return 0 if successful, error code otherwise
  */
 static int vpfe_enum_fmt(struct file *file, void  *priv,
   struct v4l2_fmtdesc *fmt)
@@ -769,7 +769,7 @@ static int vpfe_try_fmt(struct file *file, void *priv,
  * fills v4l2_input structure with input available on media chain,
  * only one input is enumearted as media chain is setup by this time
  *
- * Return 0 if successfull, -EINVAL is media chain is invalid
+ * Return 0 if successful, -EINVAL is media chain is invalid
  */
 static int vpfe_enum_input(struct file *file, void *priv,
 struct v4l2_input *inp)
@@ -779,7 +779,7 @@ static int vpfe_enum_input(struct file *file, void *priv,
struct vpfe_device *vpfe_dev = video-vpfe_dev;
 
v4l2_dbg(1, debug, vpfe_dev-v4l2_dev, vpfe_enum_input\n);
-   /* enumerate from the subdev user has choosen through mc */
+   /* enumerate from the subdev user has chosen through mc */
if (inp-index  sdinfo-num_inputs) {
memcpy(inp, sdinfo-inputs[inp-index],
   sizeof(struct v4l2_input));
diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.h 
b/drivers/staging/media/davinci_vpfe/vpfe_video.h
index bf8af01..df0aeec 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_video.h
+++ b/drivers/staging/media/davinci_vpfe/vpfe_video.h
@@ -138,7 +138,7 @@ struct vpfe_video_device {
v4l2_std_id stdid;
/*
 * offset where second field starts from the starting of the
-* buffer for field seperated YCbCr formats
+ 

[PATCH v7] [media] Add common video interfaces OF bindings documentation

2013-03-26 Thread Sylwester Nawrocki
From: Guennadi Liakhovetski g.liakhovet...@gmx.de

This patch adds a document describing common OF bindings for video
capture, output and video processing devices. It is curently mainly
focused on video capture devices, with data busses defined by
standards such as ITU-R BT.656 or MIPI-CSI2.
It also documents a method of describing data links between devices.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
---
If there is no more comments I intend to send a pull request at end
of this week to merge this patch through the media tree.

Changes since v6:
 - grammar corrections and cosmetic changes.

hanges since v5:
 - added 'ports' node documentation.

Changes since v4:
 - added note that multiple endpoints at a port can be active at any time,
 - introduced optional 'ports' node aggregating 'port' nodes if required
   to avoid conflicts with any child bus of a device,
 - improved definition of the 'slave-mode' property,
 - corrected 'bus-width' and 'data-shift' properties specification,
 - dropped 'immutable' properties in the example dts snippet.

Changes since v3:
 - improved clock-lanes property description,
 - grammar corrections of the example dts snippet description.

Changes since v2:
 - corrected pclk-sample property definition,
 - s/buses/busses,
 - whitespace changes.

Changes since v1:
 - couple typo/grammar issue corrections.

Changes since initial version:
 - renamed 'link' node to 'endpoint,
 - renamed 'remote' phandle to 'remote-endpoint',
 - file v4l2.txt renamed to video-interfaces.txt,
 - removed references to V4L2,
 - added short description of the example DT snippet
 - added Required properties' paragraph,
 - updated description of 'data-lanes' property,
 - renamed all erroneous occurrences of 'data-width' to 'bus-width',
 - added 'bus-width' property description,
 - modified description of hsync-active, vsync-active properties,
 - added a little paragraph further explaining that each endpoint
   node has properties determining configuration of its corresponding
   device.

---
 .../devicetree/bindings/media/video-interfaces.txt |  227 
 1 file changed, 227 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/video-interfaces.txt

diff --git a/Documentation/devicetree/bindings/media/video-interfaces.txt 
b/Documentation/devicetree/bindings/media/video-interfaces.txt
new file mode 100644
index 000..3d10a95
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/video-interfaces.txt
@@ -0,0 +1,227 @@
+Common bindings for video receiver and transmitter interfaces
+
+General concept
+---
+
+Video data pipelines usually consist of external devices, e.g. camera sensors,
+controlled over an I2C, SPI or UART bus, and SoC internal IP blocks, including
+video DMA engines and video data processors.
+
+SoC internal blocks are described by DT nodes, placed similarly to other SoC
+blocks.  External devices are represented as child nodes of their respective
+bus controller nodes, e.g. I2C.
+
+Data interfaces on all video devices are described by their child 'port' nodes.
+Configuration of a port depends on other devices participating in the data
+transfer and is described by 'endpoint' subnodes.
+
+device {
+   ...
+   ports {
+   #address-cells = 1;
+   #size-cells = 0;
+
+   port@0 {
+   endpoint@0 { ... };
+   endpoint@1 { ... };
+   };
+   port@1 { ... };
+   };
+};
+
+If a port can be configured to work with more than one remote device on the 
same
+bus, an 'endpoint' child node must be provided for each of them.  If more than
+one port is present in a device node or there is more than one endpoint at a
+port, or port node needs to be associated with a selected hardware interface,
+a common scheme using '#address-cells', '#size-cells' and 'reg' properties is
+used.
+
+All 'port' nodes can be grouped under optional 'ports' node, which allows to
+specify #address-cells, #size-cells properties independently for the 'port'
+and 'endpoint' nodes and any child device nodes a device might have.
+
+Two 'endpoint' nodes are linked with each other through their 'remote-endpoint'
+phandles.  An endpoint subnode of a device contains all properties needed for
+configuration of this device for data exchange with other device.  In most
+cases properties at the peer 'endpoint' nodes will be identical, however they
+might need to be different when there is any signal modifications on the bus
+between two devices, e.g. there are logic signal inverters on the lines.
+
+It is allowed for multiple endpoints at a port to be active simultaneously,
+where supported by a device.  For example, in case where a data interface of
+a device is partitioned into multiple data busses, e.g. 16-bit input port
+divided into two separate ITU-R BT.656 8-bit busses.  In such case bus-width
+and 

[REVIEW PATCH 0/3] s5p-fimc driver updates

2013-03-26 Thread Sylwester Nawrocki
This patch series contains mostly conversion of the video capture node
drivers to videobuf2 ioctl/fop helpers.

Sylwester Nawrocki (3):
  s5p-fimc: Use video entity for marking media pipeline as streaming
  s5p-fimc: Use vb2 ioctl/fop helpers in FIMC capture driver
  s5p-fimc: Use vb2 ioctl helpers in fimc-lite

 drivers/media/platform/s5p-fimc/fimc-capture.c |  178 +++-
 drivers/media/platform/s5p-fimc/fimc-lite.c|  177 +++
 drivers/media/platform/s5p-fimc/fimc-m2m.c |9 +-
 3 files changed, 100 insertions(+), 264 deletions(-)

--
1.7.9.5

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


[REVIEW PATCH 1/3] s5p-fimc: Use video entity for marking media pipeline as streaming

2013-03-26 Thread Sylwester Nawrocki
It doesn't matter whether we start from the sensor of from
the video node entity. Remove use of pipeline-subdevs array
where possible, so we can partly drop dependency on struct
fimc_pipeline in the fimc-lite module, which is also used
by the exynos5-is driver.
Also make sure we revert any media entity pipeline operations
when vb2_streamon() function fails.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-capture.c |   27 +++-
 drivers/media/platform/s5p-fimc/fimc-lite.c|9 
 2 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-capture.c 
b/drivers/media/platform/s5p-fimc/fimc-capture.c
index 87b6842..257afc1 100644
--- a/drivers/media/platform/s5p-fimc/fimc-capture.c
+++ b/drivers/media/platform/s5p-fimc/fimc-capture.c
@@ -1230,36 +1230,43 @@ static int fimc_cap_streamon(struct file *file, void 
*priv,
 {
struct fimc_dev *fimc = video_drvdata(file);
struct fimc_pipeline *p = fimc-pipeline;
-   struct v4l2_subdev *sd = p-subdevs[IDX_SENSOR];
+   struct fimc_vid_cap *vc = fimc-vid_cap;
+   struct media_entity *entity = vc-vfd.entity;
int ret;
 
if (fimc_capture_active(fimc))
return -EBUSY;
 
-   ret = media_entity_pipeline_start(sd-entity, p-m_pipeline);
+   ret = media_entity_pipeline_start(entity, p-m_pipeline);
if (ret  0)
return ret;
 
-   if (fimc-vid_cap.user_subdev_api) {
+   if (vc-user_subdev_api) {
ret = fimc_pipeline_validate(fimc);
-   if (ret  0) {
-   media_entity_pipeline_stop(sd-entity);
-   return ret;
-   }
+   if (ret  0)
+   goto err_p_stop;
}
-   return vb2_streamon(fimc-vid_cap.vbq, type);
+
+   ret = vb2_streamon(vc-vbq, type);
+   if (!ret)
+   return ret;
+
+err_p_stop:
+   media_entity_pipeline_stop(entity);
+   return ret;
 }
 
 static int fimc_cap_streamoff(struct file *file, void *priv,
enum v4l2_buf_type type)
 {
struct fimc_dev *fimc = video_drvdata(file);
-   struct v4l2_subdev *sd = fimc-pipeline.subdevs[IDX_SENSOR];
int ret;
 
ret = vb2_streamoff(fimc-vid_cap.vbq, type);
+
if (ret == 0)
-   media_entity_pipeline_stop(sd-entity);
+   media_entity_pipeline_stop(fimc-vid_cap.vfd.entity);
+
return ret;
 }
 
diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.c 
b/drivers/media/platform/s5p-fimc/fimc-lite.c
index 8ebefdb..40733e0 100644
--- a/drivers/media/platform/s5p-fimc/fimc-lite.c
+++ b/drivers/media/platform/s5p-fimc/fimc-lite.c
@@ -800,20 +800,20 @@ static int fimc_lite_streamon(struct file *file, void 
*priv,
  enum v4l2_buf_type type)
 {
struct fimc_lite *fimc = video_drvdata(file);
-   struct v4l2_subdev *sensor = fimc-pipeline.subdevs[IDX_SENSOR];
+   struct media_entity *entity = fimc-vfd.entity;
struct fimc_pipeline *p = fimc-pipeline;
int ret;
 
if (fimc_lite_active(fimc))
return -EBUSY;
 
-   ret = media_entity_pipeline_start(sensor-entity, p-m_pipeline);
+   ret = media_entity_pipeline_start(entity, p-m_pipeline);
if (ret  0)
return ret;
 
ret = fimc_pipeline_validate(fimc);
if (ret) {
-   media_entity_pipeline_stop(sensor-entity);
+   media_entity_pipeline_stop(entity);
return ret;
}
 
@@ -824,12 +824,11 @@ static int fimc_lite_streamoff(struct file *file, void 
*priv,
   enum v4l2_buf_type type)
 {
struct fimc_lite *fimc = video_drvdata(file);
-   struct v4l2_subdev *sd = fimc-pipeline.subdevs[IDX_SENSOR];
int ret;
 
ret = vb2_streamoff(fimc-vb_queue, type);
if (ret == 0)
-   media_entity_pipeline_stop(sd-entity);
+   media_entity_pipeline_stop(fimc-vfd.entity);
return ret;
 }
 
-- 
1.7.9.5

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


[REVIEW PATCH 2/3] s5p-fimc: Use vb2 ioctl/fop helpers in FIMC capture driver

2013-03-26 Thread Sylwester Nawrocki
mmap/poll file operation and several ioctl handlers are replaced
with the vb2 helper functions. Some helpers are used indirectly
to maintain the buffer queue ownership.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-capture.c |  153 +---
 drivers/media/platform/s5p-fimc/fimc-m2m.c |9 +-
 2 files changed, 36 insertions(+), 126 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-capture.c 
b/drivers/media/platform/s5p-fimc/fimc-capture.c
index 257afc1..b05d97b 100644
--- a/drivers/media/platform/s5p-fimc/fimc-capture.c
+++ b/drivers/media/platform/s5p-fimc/fimc-capture.c
@@ -454,24 +454,12 @@ static void buffer_queue(struct vb2_buffer *vb)
spin_unlock_irqrestore(fimc-slock, flags);
 }
 
-static void fimc_lock(struct vb2_queue *vq)
-{
-   struct fimc_ctx *ctx = vb2_get_drv_priv(vq);
-   mutex_lock(ctx-fimc_dev-lock);
-}
-
-static void fimc_unlock(struct vb2_queue *vq)
-{
-   struct fimc_ctx *ctx = vb2_get_drv_priv(vq);
-   mutex_unlock(ctx-fimc_dev-lock);
-}
-
 static struct vb2_ops fimc_capture_qops = {
.queue_setup= queue_setup,
.buf_prepare= buffer_prepare,
.buf_queue  = buffer_queue,
-   .wait_prepare   = fimc_unlock,
-   .wait_finish= fimc_lock,
+   .wait_prepare   = vb2_ops_wait_prepare,
+   .wait_finish= vb2_ops_wait_finish,
.start_streaming= start_streaming,
.stop_streaming = stop_streaming,
 };
@@ -530,7 +518,7 @@ static int fimc_capture_open(struct file *file)
goto unlock;
}
 
-   if (++fimc-vid_cap.refcnt == 1) {
+   if (v4l2_fh_is_singular_file(file)) {
ret = fimc_pipeline_call(fimc, open, fimc-pipeline,
 fimc-vid_cap.vfd.entity, true);
 
@@ -543,8 +531,9 @@ static int fimc_capture_open(struct file *file)
if (ret  0) {
clear_bit(ST_CAPT_BUSY, fimc-state);
pm_runtime_put_sync(fimc-pdev-dev);
-   fimc-vid_cap.refcnt--;
v4l2_fh_release(file);
+   } else {
+   fimc-vid_cap.refcnt++;
}
}
 unlock:
@@ -553,7 +542,7 @@ unlock:
return ret;
 }
 
-static int fimc_capture_close(struct file *file)
+static int fimc_capture_release(struct file *file)
 {
struct fimc_dev *fimc = video_drvdata(file);
int ret;
@@ -562,50 +551,20 @@ static int fimc_capture_close(struct file *file)
 
mutex_lock(fimc-lock);
 
-   if (--fimc-vid_cap.refcnt == 0) {
+   if (v4l2_fh_is_singular_file(file)) {
clear_bit(ST_CAPT_BUSY, fimc-state);
fimc_stop_capture(fimc, false);
fimc_pipeline_call(fimc, close, fimc-pipeline);
clear_bit(ST_CAPT_SUSPENDED, fimc-state);
+   fimc-vid_cap.refcnt--;
}
 
pm_runtime_put(fimc-pdev-dev);
 
-   if (fimc-vid_cap.refcnt == 0) {
-   vb2_queue_release(fimc-vid_cap.vbq);
+   if (v4l2_fh_is_singular_file(file))
fimc_ctrls_delete(fimc-vid_cap.ctx);
-   }
-
-   ret = v4l2_fh_release(file);
-
-   mutex_unlock(fimc-lock);
-   return ret;
-}
-
-static unsigned int fimc_capture_poll(struct file *file,
- struct poll_table_struct *wait)
-{
-   struct fimc_dev *fimc = video_drvdata(file);
-   int ret;
 
-   if (mutex_lock_interruptible(fimc-lock))
-   return POLL_ERR;
-
-   ret = vb2_poll(fimc-vid_cap.vbq, file, wait);
-   mutex_unlock(fimc-lock);
-
-   return ret;
-}
-
-static int fimc_capture_mmap(struct file *file, struct vm_area_struct *vma)
-{
-   struct fimc_dev *fimc = video_drvdata(file);
-   int ret;
-
-   if (mutex_lock_interruptible(fimc-lock))
-   return -ERESTARTSYS;
-
-   ret = vb2_mmap(fimc-vid_cap.vbq, vma);
+   ret = vb2_fop_release(file);
mutex_unlock(fimc-lock);
 
return ret;
@@ -614,10 +573,10 @@ static int fimc_capture_mmap(struct file *file, struct 
vm_area_struct *vma)
 static const struct v4l2_file_operations fimc_capture_fops = {
.owner  = THIS_MODULE,
.open   = fimc_capture_open,
-   .release= fimc_capture_close,
-   .poll   = fimc_capture_poll,
+   .release= fimc_capture_release,
+   .poll   = vb2_fop_poll,
.unlocked_ioctl = video_ioctl2,
-   .mmap   = fimc_capture_mmap,
+   .mmap   = vb2_fop_mmap,
 };
 
 /*
@@ -1247,7 +1206,7 @@ static int fimc_cap_streamon(struct file *file, void 
*priv,
goto err_p_stop;
}
 
-   ret = vb2_streamon(vc-vbq, type);
+   ret = vb2_ioctl_streamon(file, 

[REVIEW PATCH 3/3] s5p-fimc: Use vb2 ioctl helpers in fimc-lite

2013-03-26 Thread Sylwester Nawrocki
Replace some ioctl, file and video buffer queue operation handlers
with the videobuf2 helpers. This allows to get rid of significant
amount of boilerplate.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-lite.c |  170 +++
 1 file changed, 45 insertions(+), 125 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.c 
b/drivers/media/platform/s5p-fimc/fimc-lite.c
index 40733e0..187d9f6 100644
--- a/drivers/media/platform/s5p-fimc/fimc-lite.c
+++ b/drivers/media/platform/s5p-fimc/fimc-lite.c
@@ -425,24 +425,12 @@ static void buffer_queue(struct vb2_buffer *vb)
spin_unlock_irqrestore(fimc-slock, flags);
 }
 
-static void fimc_lock(struct vb2_queue *vq)
-{
-   struct fimc_lite *fimc = vb2_get_drv_priv(vq);
-   mutex_lock(fimc-lock);
-}
-
-static void fimc_unlock(struct vb2_queue *vq)
-{
-   struct fimc_lite *fimc = vb2_get_drv_priv(vq);
-   mutex_unlock(fimc-lock);
-}
-
 static const struct vb2_ops fimc_lite_qops = {
.queue_setup = queue_setup,
.buf_prepare = buffer_prepare,
.buf_queue   = buffer_queue,
-   .wait_prepare= fimc_unlock,
-   .wait_finish = fimc_lock,
+   .wait_prepare= vb2_ops_wait_prepare,
+   .wait_finish = vb2_ops_wait_finish,
.start_streaming = start_streaming,
.stop_streaming  = stop_streaming,
 };
@@ -467,99 +455,69 @@ static int fimc_lite_open(struct file *file)
mutex_lock(fimc-lock);
if (atomic_read(fimc-out_path) != FIMC_IO_DMA) {
ret = -EBUSY;
-   goto done;
+   goto unlock;
}
 
set_bit(ST_FLITE_IN_USE, fimc-state);
ret = pm_runtime_get_sync(fimc-pdev-dev);
if (ret  0)
-   goto done;
+   goto unlock;
 
ret = v4l2_fh_open(file);
if (ret  0)
-   goto done;
+   goto err_pm;
 
-   if (++fimc-ref_count == 1 
-   atomic_read(fimc-out_path) == FIMC_IO_DMA) {
-   ret = fimc_pipeline_call(fimc, open, fimc-pipeline,
-fimc-vfd.entity, true);
-   if (ret  0) {
-   pm_runtime_put_sync(fimc-pdev-dev);
-   fimc-ref_count--;
-   v4l2_fh_release(file);
-   clear_bit(ST_FLITE_IN_USE, fimc-state);
-   }
+   if (!v4l2_fh_is_singular_file(file) ||
+   atomic_read(fimc-out_path) != FIMC_IO_DMA)
+   goto unlock;
 
+   ret = fimc_pipeline_call(fimc, open, fimc-pipeline,
+   me, true);
+   if (!ret) {
fimc_lite_clear_event_counters(fimc);
+   fimc-ref_count++;
+   goto unlock;
}
-done:
+
+   v4l2_fh_release(file);
+err_pm:
+   pm_runtime_put_sync(fimc-pdev-dev);
+   clear_bit(ST_FLITE_IN_USE, fimc-state);
+unlock:
mutex_unlock(fimc-lock);
mutex_unlock(me-parent-graph_mutex);
return ret;
 }
 
-static int fimc_lite_close(struct file *file)
+static int fimc_lite_release(struct file *file)
 {
struct fimc_lite *fimc = video_drvdata(file);
-   int ret;
 
mutex_lock(fimc-lock);
 
-   if (--fimc-ref_count == 0 
+   if (v4l2_fh_is_singular_file(file) 
atomic_read(fimc-out_path) == FIMC_IO_DMA) {
clear_bit(ST_FLITE_IN_USE, fimc-state);
fimc_lite_stop_capture(fimc, false);
fimc_pipeline_call(fimc, close, fimc-pipeline);
-   clear_bit(ST_FLITE_SUSPENDED, fimc-state);
+   fimc-ref_count--;
}
 
+   vb2_fop_release(file);
pm_runtime_put(fimc-pdev-dev);
+   clear_bit(ST_FLITE_SUSPENDED, fimc-state);
 
-   if (fimc-ref_count == 0)
-   vb2_queue_release(fimc-vb_queue);
-
-   ret = v4l2_fh_release(file);
-
-   mutex_unlock(fimc-lock);
-   return ret;
-}
-
-static unsigned int fimc_lite_poll(struct file *file,
-  struct poll_table_struct *wait)
-{
-   struct fimc_lite *fimc = video_drvdata(file);
-   int ret;
-
-   if (mutex_lock_interruptible(fimc-lock))
-   return POLL_ERR;
-
-   ret = vb2_poll(fimc-vb_queue, file, wait);
-   mutex_unlock(fimc-lock);
-
-   return ret;
-}
-
-static int fimc_lite_mmap(struct file *file, struct vm_area_struct *vma)
-{
-   struct fimc_lite *fimc = video_drvdata(file);
-   int ret;
-
-   if (mutex_lock_interruptible(fimc-lock))
-   return -ERESTARTSYS;
-
-   ret = vb2_mmap(fimc-vb_queue, vma);
mutex_unlock(fimc-lock);
-
-   return ret;
+   return 0;
 }
 
 static const struct v4l2_file_operations fimc_lite_fops = {
.owner  = THIS_MODULE,
.open   = fimc_lite_open,
-   .release 

[PATCH v5 0/6] Device tree support for Exynos SoC camera subsystem

2013-03-26 Thread Sylwester Nawrocki
Changes in this iteration include mostly adaptation to changes at the
V4L2 OF parser lib and an addition of clocks/clock-names properties
in the bindings of the IP blocks.

If there is no more comments I intend to send a pull request including
the DT bindings documentation, the V4L2 OF parser and these patches at
end of this week.

This patch series with all dependencies can be found at:
http://git.linuxtv.org/snawrocki/samsung.git/devicetree-fimc-v5

Sylwester Nawrocki (6):
  s5p-csis: Add device tree support
  s5p-fimc: Add device tree support for FIMC device driver
  s5p-fimc: Add device tree support for FIMC-LITE device driver
  s5p-fimc: Add device tree support for the media device driver
  s5p-fimc: Add device tree based sensors registration
  s5p-fimc: Use pinctrl API for camera ports configuration

 .../devicetree/bindings/media/exynos-fimc-lite.txt |   14 +
 .../devicetree/bindings/media/samsung-fimc.txt |  200 +++
 .../bindings/media/samsung-mipi-csis.txt   |   81 +
 drivers/media/platform/s5p-fimc/fimc-capture.c |6 +-
 drivers/media/platform/s5p-fimc/fimc-core.c|  239 +++--
 drivers/media/platform/s5p-fimc/fimc-core.h|   21 +-
 drivers/media/platform/s5p-fimc/fimc-lite.c|   63 +++-
 drivers/media/platform/s5p-fimc/fimc-m2m.c |2 +-
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |  370 +---
 drivers/media/platform/s5p-fimc/fimc-mdevice.h |   16 +
 drivers/media/platform/s5p-fimc/fimc-reg.c |6 +-
 drivers/media/platform/s5p-fimc/mipi-csis.c|  155 ++--
 drivers/media/platform/s5p-fimc/mipi-csis.h|1 +
 include/media/s5p_fimc.h   |   17 +
 14 files changed, 982 insertions(+), 209 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/exynos-fimc-lite.txt
 create mode 100644 Documentation/devicetree/bindings/media/samsung-fimc.txt
 create mode 100644 
Documentation/devicetree/bindings/media/samsung-mipi-csis.txt

--
1.7.9.5

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


[PATCH v5 1/6] s5p-csis: Add device tree support

2013-03-26 Thread Sylwester Nawrocki
This patch support for binding the driver to the MIPI-CSIS
devices instantiated from device tree and parsing the SoC
and board specific properties. The MIPI CSI-2 channel is
determined by the value of reg property placed in csis'
port subnode.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---

Changes since v5:
 - added clocks/clock-names properties to the binding documentation.

Changes since v4:
 - dropped node aliases, the IP instances are now identified
   by the port's node reg property value; as a side effect this
   introduces dependency on the s5p_fimc.h header,
 - re-added bus-width property, so the number of data lanes
   supported per each IP instance can be specified in the
   device tree,
 - the bindings documentation moved to Documentation/
   devicetree/bindings/media/samsung-mipi-csis.txt.
 - samsung,exynos3110-csis renamed to samsung,s5pv210-csis,
   updated the bindings documentation.

Changes since v3:
 - dropped 'bus-width' property, hard coded the number of supported
   data lanes per device also in dt case, it can be derived from the
   compatible property if required;
 - samsung,s5pv210-csis renamed to samsung,exynos3110-csis,
   updated the bindings description.
---
 .../bindings/media/samsung-mipi-csis.txt   |   81 ++
 drivers/media/platform/s5p-fimc/mipi-csis.c|  155 +++-
 drivers/media/platform/s5p-fimc/mipi-csis.h|1 +
 include/media/s5p_fimc.h   |   13 ++
 4 files changed, 215 insertions(+), 35 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/media/samsung-mipi-csis.txt

diff --git a/Documentation/devicetree/bindings/media/samsung-mipi-csis.txt 
b/Documentation/devicetree/bindings/media/samsung-mipi-csis.txt
new file mode 100644
index 000..5f8e28e
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/samsung-mipi-csis.txt
@@ -0,0 +1,81 @@
+Samsung S5P/EXYNOS SoC series MIPI CSI-2 receiver (MIPI CSIS)
+-
+
+Required properties:
+
+- compatible : samsung,s5pv210-csis for S5PV210 (S5PC110),
+   samsung,exynos4210-csis for Exynos4210 (S5PC210),
+   samsung,exynos4212-csis for Exynos4212/Exynos4412
+   SoC series;
+- reg: offset and length of the register set for the device;
+- interrupts  : should contain MIPI CSIS interrupt; the format of the
+   interrupt specifier depends on the interrupt controller;
+- bus-width  : maximum number of data lanes supported (SoC specific);
+- vddio-supply: MIPI CSIS I/O and PLL voltage supply (e.g. 1.8V);
+- vddcore-supply  : MIPI CSIS Core voltage supply (e.g. 1.1V);
+- clocks : list of clock specifiers, corresponding to entries in
+   clock-names property;
+- clock-names: must contain csis, sclk_csis entries, matching entries
+   in the clocks property.
+
+Optional properties:
+
+- clock-frequency : The IP's main (system bus) clock frequency in Hz, default
+   value when this property is not specified is 166 MHz;
+- samsung,csis-wclk : CSI-2 wrapper clock selection. If this property is 
present
+   external clock from CMU will be used, or the bus clock if
+   if it's not specified.
+
+The device node should contain one 'port' child node with one child 'endpoint'
+node, according to the bindings defined in Documentation/devicetree/bindings/
+media/video-interfaces.txt. The following are properties specific to those 
nodes.
+
+port node
+-
+
+- reg: (required) must be 3 for camera C input (CSIS0) or 4 for
+   camera D input (CSIS1);
+
+endpoint node
+-
+
+- data-lanes : (required) an array specifying active physical MIPI-CSI2
+   data input lanes and their mapping to logical lanes; the
+   array's content is unused, only its length is meaningful;
+
+- samsung,csis-hs-settle : (optional) differential receiver (HS-RX) settle 
time;
+
+
+Example:
+
+   reg0: regulator@0 {
+   };
+
+   reg1: regulator@1 {
+   };
+
+/* SoC properties */
+
+   csis_0: csis@1188 {
+   compatible = samsung,exynos4210-csis;
+   reg = 0x1188 0x1000;
+   interrupts = 0 78 0;
+   #address-cells = 1;
+   #size-cells = 0;
+   };
+
+/* Board properties */
+
+   csis_0: csis@1188 {
+   clock-frequency = 16600;
+   vddio-supply = reg0;
+   vddcore-supply = reg1;
+   port {
+   reg = 3; /* 3 - CSIS0, 4 - CSIS1 */
+   csis0_ep: endpoint {
+   remote-endpoint = ...;
+   data-lanes = 1, 2;
+   samsung,csis-hs-settle = 12;
+  

[PATCH v5 2/6] s5p-fimc: Add device tree support for FIMC device driver

2013-03-26 Thread Sylwester Nawrocki
This patch adds device tree support for FIMC driver on S5PV210
and Exynos4 SoCs.

The FIMC IP block's features and quirks encoded statically in
the driver are now parsed from the device tree. Once all relevant
platforms are converted to device tree based booting the FIMC
variant data structures will all be removed from the driver.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---

Changes since v5:
 - Added clocks/clock-names properties to the binding documentation.

Changes since v4:
 - Added parsing of FIMC features and quirks for DT, the static
   variant data removed for Exynos4x12 SoC which is a dt-only
   platform upstream;
 - the bindings documentation moved to Documentation/
   devicetree/bindings/media/samsung-fimc.txt

Changes since v3:
 - added optional clock-frequency property to specify local bus
   (FIMCn_LCLK) clock frequency

fimc dt doc
---
 .../devicetree/bindings/media/samsung-fimc.txt |  101 +
 drivers/media/platform/s5p-fimc/fimc-capture.c |6 +-
 drivers/media/platform/s5p-fimc/fimc-core.c|  238 
 drivers/media/platform/s5p-fimc/fimc-core.h|   21 +-
 drivers/media/platform/s5p-fimc/fimc-m2m.c |2 +-
 drivers/media/platform/s5p-fimc/fimc-reg.c |6 +-
 6 files changed, 260 insertions(+), 114 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/samsung-fimc.txt

diff --git a/Documentation/devicetree/bindings/media/samsung-fimc.txt 
b/Documentation/devicetree/bindings/media/samsung-fimc.txt
new file mode 100644
index 000..22e2889
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/samsung-fimc.txt
@@ -0,0 +1,101 @@
+Samsung S5P/EXYNOS SoC Camera Subsystem (FIMC)
+--
+
+The S5P/Exynos SoC Camera subsystem comprises of multiple sub-devices
+represented by separate device tree nodes. Currently this includes: FIMC (in
+the S5P SoCs series known as CAMIF), MIPI CSIS, FIMC-LITE and FIMC-IS (ISP).
+
+The sub-subdevices are defined as child nodes of the common 'camera' node which
+also includes common properties of the whole subsystem not really specific to
+any single sub-device, like common camera port pins or the CAMCLK clock outputs
+for external image sensors attached to an SoC.
+
+Common 'camera' node
+
+
+Required properties:
+
+- compatible   : must be samsung,fimc, simple-bus
+- clocks   : list of clock specifiers, corresponding to entries in
+ clock-names property;
+- clock-names  : must contain fimc, sclk_fimc entries, matching entries
+ in the clocks property.
+
+The 'camera' node must include at least one 'fimc' child node.
+
+
+'fimc' device nodes
+---
+
+Required properties:
+
+- compatible: samsung,s5pv210-fimc for S5PV210, samsung,exynos4210-fimc
+  for Exynos4210 and samsung,exynos4212-fimc for Exynos4x12 SoCs;
+- reg: physical base address and length of the registers set for the device;
+- interrupts: should contain FIMC interrupt;
+- clocks: list of clock specifiers, must contain an entry for each required
+  entry in clock-names;
+- clock-names: must include fimc, sclk_fimc, mux entries and optionally
+  parent entry.
+- samsung,pix-limits: an array of maximum supported image sizes in pixels, for
+  details refer to Table 2-1 in the S5PV210 SoC User Manual; The meaning of
+  each cell is as follows:
+  0 - scaler input horizontal size,
+  1 - input horizontal size for the scaler bypassed,
+  2 - REAL_WIDTH without input rotation,
+  3 - REAL_HEIGHT with input rotation,
+- samsung,sysreg: a phandle to the SYSREG node.
+
+Each FIMC device should have an alias in the aliases node, in the form of
+fimcn, where n is an integer specifying the IP block instance.
+
+Optional properties:
+
+- clock-frequency: maximum FIMC local clock (LCLK) frequency;
+- samsung,min-pix-sizes: an array specyfing minimum image size in pixels at
+  the FIMC input and output DMA, in the first and second cell respectively.
+  Default value when this property is not present is 16 16;
+- samsung,min-pix-alignment: minimum supported image height alignment (first
+  cell) and the horizontal image offset (second cell). The values are in pixels
+  and default to 2 1 when this property is not present;
+- samsung,mainscaler-ext: a boolean property indicating whether the FIMC IP
+  supports extended image size and has CIEXTEN register;
+- samsung,rotators: a bitmask specifying whether this IP has the input and
+  the output rotator. Bits 4 and 0 correspond to input and output rotator
+  respectively. If a rotator is present its corresponding bit should be set.
+  Default value when this property is not specified is 0x11.
+- samsung,cam-if: a bolean property indicating whether the IP block includes
+  the camera input interface.
+- samsung,isp-wb: this property must be present if the IP block has the ISP
+  writeback input.
+- 

[PATCH v5 3/6] s5p-fimc: Add device tree support for FIMC-LITE device driver

2013-03-26 Thread Sylwester Nawrocki
This patch adds the device tree support for FIMC-LITE device
driver. The bindings include compatible property for the Exynos5
SoC series, however the actual implementation for these SoCs will
be added in a separate patch.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---

Changes since v5:
 - Added clocks/clock-names properties to the binding documentation.
---
 .../devicetree/bindings/media/exynos-fimc-lite.txt |   14 +
 drivers/media/platform/s5p-fimc/fimc-lite.c|   63 ++--
 2 files changed, 59 insertions(+), 18 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/exynos-fimc-lite.txt

diff --git a/Documentation/devicetree/bindings/media/exynos-fimc-lite.txt 
b/Documentation/devicetree/bindings/media/exynos-fimc-lite.txt
new file mode 100644
index 000..3f62adf
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/exynos-fimc-lite.txt
@@ -0,0 +1,14 @@
+Exynos4x12/Exynos5 SoC series camera host interface (FIMC-LITE)
+
+Required properties:
+
+- compatible   : should be samsung,exynos4212-fimc for Exynos4212 and
+ Exynos4412 SoCs;
+- reg  : physical base address and size of the device memory mapped
+ registers;
+- interrupts   : should contain FIMC-LITE interrupt;
+- clocks   : FIMC LITE gate clock should be specified in this property.
+- clock-names  : should contain flite entry.
+
+Each FIMC device should have an alias in the aliases node, in the form of
+fimc-liten, where n is an integer specifying the IP block instance.
diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.c 
b/drivers/media/platform/s5p-fimc/fimc-lite.c
index 187d9f6..c76a9d6 100644
--- a/drivers/media/platform/s5p-fimc/fimc-lite.c
+++ b/drivers/media/platform/s5p-fimc/fimc-lite.c
@@ -17,6 +17,7 @@
 #include linux/kernel.h
 #include linux/list.h
 #include linux/module.h
+#include linux/of.h
 #include linux/types.h
 #include linux/platform_device.h
 #include linux/pm_runtime.h
@@ -1401,18 +1402,34 @@ static int fimc_lite_clk_get(struct fimc_lite *fimc)
return ret;
 }
 
+static const struct of_device_id flite_of_match[];
+
 static int fimc_lite_probe(struct platform_device *pdev)
 {
-   struct flite_drvdata *drv_data = fimc_lite_get_drvdata(pdev);
+   struct flite_drvdata *drv_data = NULL;
+   struct device *dev = pdev-dev;
+   const struct of_device_id *of_id;
struct fimc_lite *fimc;
struct resource *res;
int ret;
 
-   fimc = devm_kzalloc(pdev-dev, sizeof(*fimc), GFP_KERNEL);
+   fimc = devm_kzalloc(dev, sizeof(*fimc), GFP_KERNEL);
if (!fimc)
return -ENOMEM;
 
-   fimc-index = pdev-id;
+   if (dev-of_node) {
+   of_id = of_match_node(flite_of_match, dev-of_node);
+   if (of_id)
+   drv_data = (struct flite_drvdata *)of_id-data;
+   fimc-index = of_alias_get_id(dev-of_node, fimc-lite);
+   } else {
+   drv_data = fimc_lite_get_drvdata(pdev);
+   fimc-index = pdev-id;
+   }
+
+   if (!drv_data || fimc-index  0 || fimc-index = FIMC_LITE_MAX_DEVS)
+   return -EINVAL;
+
fimc-variant = drv_data-variant[fimc-index];
fimc-pdev = pdev;
 
@@ -1421,13 +1438,13 @@ static int fimc_lite_probe(struct platform_device *pdev)
mutex_init(fimc-lock);
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   fimc-regs = devm_ioremap_resource(pdev-dev, res);
+   fimc-regs = devm_ioremap_resource(dev, res);
if (IS_ERR(fimc-regs))
return PTR_ERR(fimc-regs);
 
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (res == NULL) {
-   dev_err(pdev-dev, Failed to get IRQ resource\n);
+   dev_err(dev, Failed to get IRQ resource\n);
return -ENXIO;
}
 
@@ -1435,10 +1452,10 @@ static int fimc_lite_probe(struct platform_device *pdev)
if (ret)
return ret;
 
-   ret = devm_request_irq(pdev-dev, res-start, flite_irq_handler,
-  0, dev_name(pdev-dev), fimc);
+   ret = devm_request_irq(dev, res-start, flite_irq_handler,
+  0, dev_name(dev), fimc);
if (ret) {
-   dev_err(pdev-dev, Failed to install irq (%d)\n, ret);
+   dev_err(dev, Failed to install irq (%d)\n, ret);
goto err_clk;
}
 
@@ -1448,23 +1465,23 @@ static int fimc_lite_probe(struct platform_device *pdev)
goto err_clk;
 
platform_set_drvdata(pdev, fimc);
-   pm_runtime_enable(pdev-dev);
-   ret = pm_runtime_get_sync(pdev-dev);
+   pm_runtime_enable(dev);
+   ret = pm_runtime_get_sync(dev);
if (ret  0)
goto err_sd;
 
-   fimc-alloc_ctx = vb2_dma_contig_init_ctx(pdev-dev);
+   fimc-alloc_ctx = 

[PATCH v5 4/6] s5p-fimc: Add device tree support for the media device driver

2013-03-26 Thread Sylwester Nawrocki
This patch adds changes required for the main camera media device
driver corresponding to the top level 'camera' device node.

The drivers of devices corresponding to child nodes of the 'camera'
node are looked up and and registered as sub-devices to the top
level driver. The main driver's probing is deferred if any of the
sub-device drivers is not yet initialized and ready.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Andrzej Hajda a.ha...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---

Changes since v5:

- Do not register FIMC with WB input to the camera driver. FIMC devices
  with LCD Writeback input and samsung,lcd-wb property in their device
  tree node are handled by the DRM image post-processing driver and
  registration of these devices to the camera driver is skipped.
---
 drivers/media/platform/s5p-fimc/fimc-core.c|1 -
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |  108 
 drivers/media/platform/s5p-fimc/fimc-mdevice.h |5 ++
 include/media/s5p_fimc.h   |1 +
 4 files changed, 98 insertions(+), 17 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-core.c 
b/drivers/media/platform/s5p-fimc/fimc-core.c
index d39e47a..6a8098c 100644
--- a/drivers/media/platform/s5p-fimc/fimc-core.c
+++ b/drivers/media/platform/s5p-fimc/fimc-core.c
@@ -1281,7 +1281,6 @@ static const struct platform_device_id fimc_driver_ids[] 
= {
},
{ },
 };
-MODULE_DEVICE_TABLE(platform, fimc_driver_ids);
 
 static const struct of_device_id fimc_of_match[] = {
{
diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c 
b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
index cd38d70..b62011d 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
@@ -17,11 +17,16 @@
 #include linux/kernel.h
 #include linux/list.h
 #include linux/module.h
+#include linux/of.h
+#include linux/of_platform.h
+#include linux/of_device.h
+#include linux/of_i2c.h
 #include linux/platform_device.h
 #include linux/pm_runtime.h
 #include linux/types.h
 #include linux/slab.h
 #include media/v4l2-ctrls.h
+#include media/v4l2-of.h
 #include media/media-device.h
 #include media/s5p_fimc.h
 
@@ -264,6 +269,21 @@ static void fimc_md_unregister_sensor(struct v4l2_subdev 
*sd)
i2c_put_adapter(adapter);
 }
 
+#ifdef CONFIG_OF
+static int __of_get_csis_id(struct device_node *np)
+{
+   u32 reg = 0;
+
+   np = of_get_child_by_name(np, port);
+   if (!np)
+   return -EINVAL;
+   of_property_read_u32(np, reg, reg);
+   return reg - FIMC_INPUT_MIPI_CSI2_0;
+}
+#else
+#define __of_get_csis_id(np) (-ENOSYS)
+#endif
+
 static int fimc_md_register_sensor_entities(struct fimc_md *fmd)
 {
struct s5p_platform_fimc *pdata = fmd-pdev-dev.platform_data;
@@ -368,13 +388,13 @@ static int register_csis_entity(struct fimc_md *fmd,
struct device_node *node = pdev-dev.of_node;
int id, ret;
 
-   id = node ? of_alias_get_id(node, csis) : max(0, pdev-id);
+   id = node ? __of_get_csis_id(node) : max(0, pdev-id);
 
-   if (WARN_ON(id = CSIS_MAX_ENTITIES || fmd-csis[id].sd))
-   return -EBUSY;
+   if (WARN_ON(id  0 || id = CSIS_MAX_ENTITIES))
+   return -ENOENT;
 
-   if (WARN_ON(id = CSIS_MAX_ENTITIES))
-   return 0;
+   if (WARN_ON(fmd-csis[id].sd))
+   return -EBUSY;
 
sd-grp_id = GRP_ID_CSIS;
ret = v4l2_device_register_subdev(fmd-v4l2_dev, sd);
@@ -457,6 +477,45 @@ static int fimc_md_pdev_match(struct device *dev, void 
*data)
return 0;
 }
 
+/* Register FIMC, FIMC-LITE and CSIS media entities */
+#ifdef CONFIG_OF
+static int fimc_md_register_of_platform_entities(struct fimc_md *fmd,
+struct device_node *parent)
+{
+   struct device_node *node;
+   int ret = 0;
+
+   for_each_available_child_of_node(parent, node) {
+   struct platform_device *pdev;
+   int plat_entity = -1;
+
+   pdev = of_find_device_by_node(node);
+   if (!pdev)
+   continue;
+
+   /* If driver of any entity isn't ready try all again later. */
+   if (!strcmp(node-name, CSIS_OF_NODE_NAME))
+   plat_entity = IDX_CSIS;
+   else if (!strcmp(node-name, FIMC_LITE_OF_NODE_NAME))
+   plat_entity = IDX_FLITE;
+   else if (!strcmp(node-name, FIMC_OF_NODE_NAME) 
+!of_property_read_bool(node, samsung,lcd-wb))
+   plat_entity = IDX_FIMC;
+
+   if (plat_entity = 0)
+   ret = fimc_md_register_platform_entity(fmd, pdev,
+   plat_entity);
+   put_device(pdev-dev);
+   if (ret  0)
+   

[PATCH v5 5/6] s5p-fimc: Add device tree based sensors registration

2013-03-26 Thread Sylwester Nawrocki
The sensor (I2C and/or SPI client) devices are instantiated by their
corresponding control bus drivers. Since the I2C client's master clock
is often provided by a video bus receiver (host interface) or other
than I2C/SPI controller device, the drivers of those client devices
are not accessing hardware in their driver's probe() callback. Instead,
after enabling clock, the host driver calls back into a sub-device
when it wants to activate them. This pattern is used by some in-tree
drivers and this patch also uses it for DT case. This patch is intended
as a first step for adding device tree support to the S5P/Exynos SoC
camera drivers. The second one is adding support for asynchronous
sub-devices registration and clock control from sub-device driver
level. The bindings shall not change when asynchronous probing support
is added.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---

Changes since v5:
 - Minor changes at the binding documentation.

Changes since v4:
 - Corrected typos in the bindings example.

fimc sensors
---
 .../devicetree/bindings/media/samsung-fimc.txt |   87 +++
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |  238 +---
 include/media/s5p_fimc.h   |3 +
 3 files changed, 302 insertions(+), 26 deletions(-)

diff --git a/Documentation/devicetree/bindings/media/samsung-fimc.txt 
b/Documentation/devicetree/bindings/media/samsung-fimc.txt
index 22e2889..7617b93 100644
--- a/Documentation/devicetree/bindings/media/samsung-fimc.txt
+++ b/Documentation/devicetree/bindings/media/samsung-fimc.txt
@@ -72,18 +72,96 @@ Optional properties:
   writeback input.
 
 
+
+'parallel-ports' node
+-
+
+This node should contain child 'port' nodes specifying active parallel video
+input ports. It includes camera A and camera B inputs. 'reg' property in the
+port nodes specifies data input - 0, 1 indicates input A, B respectively.
+
+Optional properties
+
+- samsung,camclk-out : specifies clock output for remote sensor,
+  0 - CAM_A_CLKOUT, 1 - CAM_B_CLKOUT;
+
+Image sensor nodes
+--
+
+The sensor device nodes should be added to their control bus controller (e.g.
+I2C0) nodes and linked to a port node in the csis or the parallel-ports node,
+using the common video interfaces bindings, defined in video-interfaces.txt.
+The implementation of this bindings requires clock-frequency property to be
+present in the sensor device nodes.
+
 Example:
 
aliases {
fimc0 = fimc_0;
};
 
+   /* Parallel bus IF sensor */
+   i2c_0: i2c@1386 {
+   s5k6aa: sensor@3c {
+   compatible = samsung,s5k6aafx;
+   reg = 0x3c;
+   vddio-supply = ...;
+
+   clock-frequency = 2400;
+   clocks = ...;
+   clock-names = mclk;
+
+   port {
+   s5k6aa_ep: endpoint {
+   remote-endpoint = fimc0_ep;
+   bus-width = 8;
+   hsync-active = 0;
+   vsync-active = 1;
+   pclk-sample = 1;
+   };
+   };
+   };
+   };
+
+   /* MIPI CSI-2 bus IF sensor */
+   s5c73m3: sensor@0x1a {
+   compatible = samsung,s5c73m3;
+   reg = 0x1a;
+   vddio-supply = ...;
+
+   clock-frequency = 2400;
+   clocks = ...;
+   clock-names = mclk;
+
+   port {
+   s5c73m3_1: endpoint {
+   data-lanes = 1 2 3 4;
+   remote-endpoint = csis0_ep;
+   };
+   };
+   };
+
camera {
compatible = samsung,fimc, simple-bus;
#address-cells = 1;
#size-cells = 1;
status = okay;
 
+   /* parallel camera ports */
+   parallel-ports {
+   /* camera A input */
+   port@0 {
+   reg = 0;
+   fimc0_ep: endpoint {
+   remote-endpoint = s5k6aa_ep;
+   bus-width = 8;
+   hsync-active = 0;
+   vsync-active = 1;
+   pclk-sample = 1;
+   };
+   };
+   };
+
fimc_0: fimc@1180 {
compatible = samsung,exynos4210-fimc;
reg = 0x1180 0x1000;
@@ -95,6 +173,15 @@ Example:

[PATCH v5 6/6] s5p-fimc: Use pinctrl API for camera ports configuration

2013-03-26 Thread Sylwester Nawrocki
Before the camera ports can be used the pinmux needs to be configured
properly. This patch adds a function to set the camera ports pinctrl
to a default state within the media driver's probe().
The camera port(s) are then configured for the video bus operation.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---

Changes since v5:
 - None.

Changes since v4:
 - Added more pinctrl states for camera port A and B normal operation
   and idle state (with CAMCLK output pin switched to high impedance
   state).

Changes since v3:
 - Removed the inactive pinctrl state, it will be added later if
   required.
---
 .../devicetree/bindings/media/samsung-fimc.txt |   12 +
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |   26 
 drivers/media/platform/s5p-fimc/fimc-mdevice.h |   11 +
 3 files changed, 49 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/samsung-fimc.txt 
b/Documentation/devicetree/bindings/media/samsung-fimc.txt
index 7617b93..b379822 100644
--- a/Documentation/devicetree/bindings/media/samsung-fimc.txt
+++ b/Documentation/devicetree/bindings/media/samsung-fimc.txt
@@ -21,6 +21,15 @@ Required properties:
 - clock-names  : must contain fimc, sclk_fimc entries, matching entries
  in the clocks property.
 
+The pinctrl bindings defined in ../pinctrl/pinctrl-bindings.txt must be used
+to define a required pinctrl state named default and optional pinctrl states:
+idle, active-a, active-b. These optional states can be used to switch the
+camera port pinmux at runtime. The idle state should configure both the 
camera
+ports A and B into high impedance state, especially the CAMCLK clock output
+should be inactive. For the active-a state the camera port A must be 
activated
+and the port B deactivated and for the state active-b it should be the other
+way around.
+
 The 'camera' node must include at least one 'fimc' child node.
 
 
@@ -147,6 +156,9 @@ Example:
#size-cells = 1;
status = okay;
 
+   pinctrl-names = default;
+   pinctrl-0 = cam_port_a_clk_active;
+
/* parallel camera ports */
parallel-ports {
/* camera A input */
diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c 
b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
index d6d38b9..b689166 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
@@ -1171,6 +1171,25 @@ static ssize_t fimc_md_sysfs_store(struct device *dev,
 static DEVICE_ATTR(subdev_conf_mode, S_IWUSR | S_IRUGO,
   fimc_md_sysfs_show, fimc_md_sysfs_store);
 
+static int fimc_md_get_pinctrl(struct fimc_md *fmd)
+{
+   struct device *dev = fmd-pdev-dev;
+   struct fimc_pinctrl *pctl = fmd-pinctl;
+
+   pctl-pinctrl = devm_pinctrl_get(dev);
+   if (IS_ERR(pctl-pinctrl))
+   return PTR_ERR(pctl-pinctrl);
+
+   pctl-state_default = pinctrl_lookup_state(pctl-pinctrl,
+   PINCTRL_STATE_DEFAULT);
+   if (IS_ERR(pctl-state_default))
+   return PTR_ERR(pctl-state_default);
+
+   pctl-state_idle = pinctrl_lookup_state(pctl-pinctrl,
+   PINCTRL_STATE_IDLE);
+   return 0;
+}
+
 static int fimc_md_probe(struct platform_device *pdev)
 {
struct device *dev = pdev-dev;
@@ -1214,6 +1233,13 @@ static int fimc_md_probe(struct platform_device *pdev)
/* Protect the media graph while we're registering entities */
mutex_lock(fmd-media_dev.graph_mutex);
 
+   ret = fimc_md_get_pinctrl(fmd);
+   if (ret  0) {
+   if (ret != EPROBE_DEFER)
+   dev_err(dev, Failed to get pinctrl: %d\n, ret);
+   goto err_unlock;
+   }
+
if (dev-of_node)
ret = fimc_md_register_of_platform_entities(fmd, dev-of_node);
else
diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.h 
b/drivers/media/platform/s5p-fimc/fimc-mdevice.h
index b6ceb59..5d6146e 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.h
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.h
@@ -12,6 +12,7 @@
 #include linux/clk.h
 #include linux/platform_device.h
 #include linux/mutex.h
+#include linux/pinctrl/consumer.h
 #include media/media-device.h
 #include media/media-entity.h
 #include media/v4l2-device.h
@@ -26,6 +27,8 @@
 #define FIMC_IS_OF_NODE_NAME   fimc-is
 #define CSIS_OF_NODE_NAME  csis
 
+#define PINCTRL_STATE_IDLE idle
+
 /* Group IDs of sensor, MIPI-CSIS, FIMC-LITE and the writeback subdevs. */
 #define GRP_ID_SENSOR  (1  8)
 #define GRP_ID_FIMC_IS_SENSOR  (1  9)
@@ -73,6 +76,9 @@ struct fimc_sensor_info {
  * @media_dev: top level media device
  * @v4l2_dev: top level v4l2_device holding up the subdevs
  * @pdev: platform device this media device is hooked up 

Re: [PATCH v5 0/6] Device tree support for Exynos SoC camera subsystem

2013-03-26 Thread Sylwester Nawrocki
On 03/26/2013 05:39 PM, Sylwester Nawrocki wrote:
 Changes in this iteration include mostly adaptation to changes at the
 V4L2 OF parser lib and an addition of clocks/clock-names properties
 in the bindings of the IP blocks.
 
 If there is no more comments I intend to send a pull request including
 the DT bindings documentation, the V4L2 OF parser and these patches at
 end of this week.
 
 This patch series with all dependencies can be found at:
 http://git.linuxtv.org/snawrocki/samsung.git/devicetree-fimc-v5

Ugh, this should have been v6 and the correct url is
http://git.linuxtv.org/snawrocki/samsung.git/devicetree-fimc-v6

My apologies for this confusion.

Thanks,

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


[PATCH v2 00/10] s5p-fimc: Exynos4x12 FIMC-IS support prerequisite

2013-03-26 Thread Sylwester Nawrocki
This patch series contains a few fixes to the s5p-fimc driver and changes
necessary for the Exynos4x12 FIMC-IS support.

The changes are listed at each patch, if there were any. I have removed
two patches, adding support for setting parent clocks and added a patch
changing the driver directory to drivers/media/platform/exynos4-is.

This series, including dependencies, can be browsed at:
http://git.linuxtv.org/snawrocki/samsung.git/exynos4-fimc-is-v2

Andrzej Hajda (1):
  s5p-fimc: Add error checks for pipeline stream on callbacks

Sylwester Nawrocki (9):
  V4L: Add MATRIX option to V4L2_CID_EXPOSURE_METERING control
  s5p-fimc: Update graph traversal for entities with multiple source
pads
  s5p-fimc: Add support for PIXELASYNCMx clocks
  s5p-fimc: Add support for ISP Writeback data input bus type
  s5p-fimc: Ensure CAMCLK clock can be enabled by FIMC-LITE devices
  s5p-fimc: Ensure proper s_stream() call order in the ISP datapaths
  s5p-fimc: Ensure proper s_power() call order in the ISP datapaths
  s5p-fimc: Remove dependency on fimc-core.h in fimc-lite driver
  s5p-fimc: Change the driver directory name to exynos4-is

 Documentation/DocBook/media/v4l/controls.xml   |7 +
 drivers/media/platform/Kconfig |2 +-
 drivers/media/platform/Makefile|2 +-
 .../platform/{s5p-fimc = exynos4-is}/Kconfig  |9 +-
 .../platform/{s5p-fimc = exynos4-is}/Makefile |2 +-
 .../{s5p-fimc = exynos4-is}/fimc-capture.c|  194 +---
 .../platform/{s5p-fimc = exynos4-is}/fimc-core.c  |   12 +-
 .../platform/{s5p-fimc = exynos4-is}/fimc-core.h  |   48 ++---
 .../{s5p-fimc = exynos4-is}/fimc-lite-reg.c   |0
 .../{s5p-fimc = exynos4-is}/fimc-lite-reg.h   |0
 .../platform/{s5p-fimc = exynos4-is}/fimc-lite.c  |3 +-
 .../platform/{s5p-fimc = exynos4-is}/fimc-lite.h  |3 +-
 .../platform/{s5p-fimc = exynos4-is}/fimc-m2m.c   |3 +-
 .../platform/{s5p-fimc = exynos4-is}/fimc-reg.c   |   75 ++--
 .../platform/{s5p-fimc = exynos4-is}/fimc-reg.h   |   11 ++
 .../fimc-mdevice.c = exynos4-is/media-dev.c}  |  182 +-
 .../fimc-mdevice.h = exynos4-is/media-dev.h}  |   12 ++
 .../platform/{s5p-fimc = exynos4-is}/mipi-csis.c  |0
 .../platform/{s5p-fimc = exynos4-is}/mipi-csis.h  |0
 drivers/media/v4l2-core/v4l2-ctrls.c   |1 +
 include/media/s5p_fimc.h   |   34 
 include/uapi/linux/v4l2-controls.h |1 +
 22 files changed, 428 insertions(+), 173 deletions(-)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/Kconfig (86%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/Makefile (94%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-capture.c (93%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-core.c (99%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-core.h (94%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-lite-reg.c (100%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-lite-reg.h (100%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-lite.c (99%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-lite.h (99%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-m2m.c (99%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-reg.c (92%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-reg.h (96%)
 rename drivers/media/platform/{s5p-fimc/fimc-mdevice.c = 
exynos4-is/media-dev.c} (89%)
 rename drivers/media/platform/{s5p-fimc/fimc-mdevice.h = 
exynos4-is/media-dev.h} (92%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/mipi-csis.c (100%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/mipi-csis.h (100%)

--
1.7.9.5

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


[PATCH v2 01/10] V4L: Add MATRIX option to V4L2_CID_EXPOSURE_METERING control

2013-03-26 Thread Sylwester Nawrocki
This patch adds a menu option to the V4L2_CID_EXPOSURE_METERING
control for multi-zone metering.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 Documentation/DocBook/media/v4l/controls.xml |7 +++
 drivers/media/v4l2-core/v4l2-ctrls.c |1 +
 include/uapi/linux/v4l2-controls.h   |1 +
 3 files changed, 9 insertions(+)

diff --git a/Documentation/DocBook/media/v4l/controls.xml 
b/Documentation/DocBook/media/v4l/controls.xml
index 7fe5be1..c5398ed 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -3159,6 +3159,13 @@ giving priority to the center of the metered 
area./entry
  
entryconstantV4L2_EXPOSURE_METERING_SPOT/constantnbsp;/entry
  entryMeasure only very small area at the center of the 
frame./entry
/row
+   row
+ 
entryconstantV4L2_EXPOSURE_METERING_MATRIX/constantnbsp;/entry
+ entryA multi-zone metering. The light intensity is measured
+in several points of the frame and the the results are combined. The
+algorithm of the zones selection and their significance in calculating the
+final value is device dependant./entry
+   /row
  /tbody
/entrytbl
  /row
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index 4b45d49..6b56d7b 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -234,6 +234,7 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
Average,
Center Weighted,
Spot,
+   Matrix,
NULL
};
static const char * const camera_auto_focus_range[] = {
diff --git a/include/uapi/linux/v4l2-controls.h 
b/include/uapi/linux/v4l2-controls.h
index f56c945..22556a2 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -642,6 +642,7 @@ enum v4l2_exposure_metering {
V4L2_EXPOSURE_METERING_AVERAGE  = 0,
V4L2_EXPOSURE_METERING_CENTER_WEIGHTED  = 1,
V4L2_EXPOSURE_METERING_SPOT = 2,
+   V4L2_EXPOSURE_METERING_MATRIX   = 3,
 };
 
 #define V4L2_CID_SCENE_MODE(V4L2_CID_CAMERA_CLASS_BASE+26)
-- 
1.7.9.5

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


[PATCH v2 02/10] s5p-fimc: Add error checks for pipeline stream on callbacks

2013-03-26 Thread Sylwester Nawrocki
From: Andrzej Hajda a.ha...@samsung.com

set_stream error for pipelines is logged or reported to user
space if possible.

Signed-off-by: Andrzej Hajda a.ha...@samsung.com
Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-capture.c |   15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-capture.c 
b/drivers/media/platform/s5p-fimc/fimc-capture.c
index 344e85e..3f3ceb2 100644
--- a/drivers/media/platform/s5p-fimc/fimc-capture.c
+++ b/drivers/media/platform/s5p-fimc/fimc-capture.c
@@ -286,8 +286,8 @@ static int start_streaming(struct vb2_queue *q, unsigned 
int count)
fimc_activate_capture(ctx);
 
if (!test_and_set_bit(ST_CAPT_ISP_STREAM, fimc-state))
-   fimc_pipeline_call(fimc, set_stream,
-  fimc-pipeline, 1);
+   return fimc_pipeline_call(fimc, set_stream,
+ fimc-pipeline, 1);
}
 
return 0;
@@ -443,12 +443,17 @@ static void buffer_queue(struct vb2_buffer *vb)
if (vb2_is_streaming(vid_cap-vbq) 
vid_cap-active_buf_cnt = min_bufs 
!test_and_set_bit(ST_CAPT_STREAM, fimc-state)) {
+   int ret;
+
fimc_activate_capture(ctx);
spin_unlock_irqrestore(fimc-slock, flags);
 
-   if (!test_and_set_bit(ST_CAPT_ISP_STREAM, fimc-state))
-   fimc_pipeline_call(fimc, set_stream,
-  fimc-pipeline, 1);
+   if (test_and_set_bit(ST_CAPT_ISP_STREAM, fimc-state))
+   return;
+
+   ret = fimc_pipeline_call(fimc, set_stream, fimc-pipeline, 1);
+   if (ret  0)
+   v4l2_err(vid_cap-vfd, stream on failed: %d\n, ret);
return;
}
spin_unlock_irqrestore(fimc-slock, flags);
-- 
1.7.9.5

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


[PATCH v2 04/10] s5p-fimc: Add support for PIXELASYNCMx clocks

2013-03-26 Thread Sylwester Nawrocki
This patch ads handling of clocks for the CAMBLK subsystem which
is a glue logic for FIMC-IS or LCD controller and FIMC IP.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---

Changes since v1:

 - Do not keep PXLASYNC clocks always enabled. Enable PXLASYNC0
   clock only if video pipeline including FIMC-IS was opened.
   Enabling this clock only when it is actually used decreases
   power consumption a bit.
---
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |   83 
 drivers/media/platform/s5p-fimc/fimc-mdevice.h |   10 +++
 2 files changed, 82 insertions(+), 11 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c 
b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
index abd3ad3..c5bc0d1 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
@@ -151,26 +151,48 @@ static int fimc_pipeline_s_power(struct fimc_pipeline *p, 
bool state)
  * __fimc_pipeline_open - update the pipeline information, enable power
  *of all pipeline subdevs and the sensor clock
  * @me: media entity to start graph walk with
- * @prep: true to acquire sensor (and csis) subdevs
+ * @prepare: true to walk the current pipeline and acquire all subdevs
  *
  * Called with the graph mutex held.
  */
 static int __fimc_pipeline_open(struct fimc_pipeline *p,
-   struct media_entity *me, bool prep)
+   struct media_entity *me, bool prepare)
 {
+   struct fimc_md *fmd = entity_to_fimc_mdev(me);
+   struct v4l2_subdev *sd;
int ret;
 
-   if (prep)
+   if (WARN_ON(p == NULL || me == NULL))
+   return -EINVAL;
+
+   if (prepare)
fimc_pipeline_prepare(p, me);
 
-   if (p-subdevs[IDX_SENSOR] == NULL)
+   sd = p-subdevs[IDX_SENSOR];
+   if (sd == NULL)
return -EINVAL;
 
-   ret = fimc_md_set_camclk(p-subdevs[IDX_SENSOR], true);
-   if (ret)
-   return ret;
+   /* Disable PXLASYNC clock if this pipeline includes FIMC-IS */
+   if (!IS_ERR(fmd-wbclk[CLK_IDX_WB_B])  p-subdevs[IDX_IS_ISP]) {
+   ret = clk_prepare_enable(fmd-wbclk[CLK_IDX_WB_B]);
+   if (ret  0)
+   return ret;
+   }
+   ret = fimc_md_set_camclk(sd, true);
+   if (ret  0)
+   goto err_wbclk;
+
+   ret = fimc_pipeline_s_power(p, 1);
+   if (!ret)
+   return 0;
+
+   fimc_md_set_camclk(sd, false);
 
-   return fimc_pipeline_s_power(p, 1);
+err_wbclk:
+   if (!IS_ERR(fmd-wbclk[CLK_IDX_WB_B])  p-subdevs[IDX_IS_ISP])
+   clk_disable_unprepare(fmd-wbclk[CLK_IDX_WB_B]);
+
+   return ret;
 }
 
 /**
@@ -181,15 +203,24 @@ static int __fimc_pipeline_open(struct fimc_pipeline *p,
  */
 static int __fimc_pipeline_close(struct fimc_pipeline *p)
 {
+   struct v4l2_subdev *sd = p ? p-subdevs[IDX_SENSOR] : NULL;
+   struct fimc_md *fmd;
int ret = 0;
 
-   if (!p || !p-subdevs[IDX_SENSOR])
+   if (WARN_ON(sd == NULL))
return -EINVAL;
 
if (p-subdevs[IDX_SENSOR]) {
ret = fimc_pipeline_s_power(p, 0);
-   fimc_md_set_camclk(p-subdevs[IDX_SENSOR], false);
+   fimc_md_set_camclk(sd, false);
}
+
+   fmd = entity_to_fimc_mdev(sd-entity);
+
+   /* Disable PXLASYNC clock if this pipeline includes FIMC-IS */
+   if (!IS_ERR(fmd-wbclk[CLK_IDX_WB_B])  p-subdevs[IDX_IS_ISP])
+   clk_disable_unprepare(fmd-wbclk[CLK_IDX_WB_B]);
+
return ret == -ENXIO ? 0 : ret;
 }
 
@@ -957,7 +988,7 @@ static int fimc_md_create_links(struct fimc_md *fmd)
 }
 
 /*
- * The peripheral sensor clock management.
+ * The peripheral sensor and CAM_BLK (PIXELASYNCMx) clocks management.
  */
 static void fimc_md_put_clocks(struct fimc_md *fmd)
 {
@@ -970,6 +1001,14 @@ static void fimc_md_put_clocks(struct fimc_md *fmd)
clk_put(fmd-camclk[i].clock);
fmd-camclk[i].clock = ERR_PTR(-EINVAL);
}
+
+   /* Writeback (PIXELASYNCMx) clocks */
+   for (i = 0; i  FIMC_MAX_WBCLKS; i++) {
+   if (IS_ERR(fmd-wbclk[i]))
+   continue;
+   clk_put(fmd-wbclk[i]);
+   fmd-wbclk[i] = ERR_PTR(-EINVAL);
+   }
 }
 
 static int fimc_md_get_clocks(struct fimc_md *fmd)
@@ -1006,6 +1045,28 @@ static int fimc_md_get_clocks(struct fimc_md *fmd)
if (ret)
fimc_md_put_clocks(fmd);
 
+   if (!fmd-use_isp)
+   return 0;
+   /*
+* For now get only PIXELASYNCM1 clock (Writeback B/ISP),
+* leave PIXELASYNCM0 out for the LCD Writeback driver.
+*/
+   fmd-wbclk[CLK_IDX_WB_A] = ERR_PTR(-EINVAL);
+
+   for (i = CLK_IDX_WB_B; i  FIMC_MAX_WBCLKS; i++) {
+   snprintf(clk_name, sizeof(clk_name), 

[PATCH v2 05/10] s5p-fimc: Add support for ISP Writeback data input bus type

2013-03-26 Thread Sylwester Nawrocki
A second sink pad is added to each FIMC.N subdev that will be used
to link it to the FIMC-IS-ISP subdev. Only V4L2_MBUS_FMT_YUV10_1X30
format is supported at this pad (FIMC_SD_PAD_SINK_FIFO).

The routine checking for mismatch in the image formats at sides of
the links is updated to account for the fact FIMC.X subdevs now have
sink pads at the pad indexes 0, 1 and source pad at pad index 2.

If link to FIMC.X pad 1 is activated we switch FIMC input data bus
type to the ISP Writeback. Only a single active link to FIMC.X pad 0
or 1 will be allowed at any time.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---

Changes since v1:

 - Use the syscon interface for SYSREG block registers access,
 - updated fimc_validate_pipeline() function to properly walk
   whole pipeline.
---
 drivers/media/platform/s5p-fimc/Kconfig|1 +
 drivers/media/platform/s5p-fimc/fimc-capture.c |  177 
 drivers/media/platform/s5p-fimc/fimc-core.c|   10 ++
 drivers/media/platform/s5p-fimc/fimc-core.h|   19 ++-
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |7 +-
 drivers/media/platform/s5p-fimc/fimc-reg.c |   75 --
 drivers/media/platform/s5p-fimc/fimc-reg.h |   11 ++
 7 files changed, 221 insertions(+), 79 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/Kconfig 
b/drivers/media/platform/s5p-fimc/Kconfig
index c16b20d..64c1116 100644
--- a/drivers/media/platform/s5p-fimc/Kconfig
+++ b/drivers/media/platform/s5p-fimc/Kconfig
@@ -3,6 +3,7 @@ config VIDEO_SAMSUNG_S5P_FIMC
bool Samsung S5P/EXYNOS SoC camera interface driver (experimental)
depends on VIDEO_V4L2  VIDEO_V4L2_SUBDEV_API  PLAT_S5P  PM_RUNTIME
depends on EXPERIMENTAL
+   depends on MFD_SYSCON
help
  Say Y here to enable camera host interface devices for
  Samsung S5P and EXYNOS SoC series.
diff --git a/drivers/media/platform/s5p-fimc/fimc-capture.c 
b/drivers/media/platform/s5p-fimc/fimc-capture.c
index 3f3ceb2..4d79d64 100644
--- a/drivers/media/platform/s5p-fimc/fimc-capture.c
+++ b/drivers/media/platform/s5p-fimc/fimc-capture.c
@@ -33,26 +33,27 @@
 
 static int fimc_capture_hw_init(struct fimc_dev *fimc)
 {
+   struct fimc_source_info *si = fimc-vid_cap.source_config;
struct fimc_ctx *ctx = fimc-vid_cap.ctx;
-   struct fimc_pipeline *p = fimc-pipeline;
-   struct fimc_sensor_info *sensor;
+   int ret;
unsigned long flags;
-   int ret = 0;
 
-   if (p-subdevs[IDX_SENSOR] == NULL || ctx == NULL)
-   return -ENXIO;
-   if (ctx-s_frame.fmt == NULL)
+   if (ctx == NULL || ctx-s_frame.fmt == NULL)
return -EINVAL;
 
-   sensor = v4l2_get_subdev_hostdata(p-subdevs[IDX_SENSOR]);
+   if (si-fimc_bus_type == FIMC_BUS_TYPE_ISP_WRITEBACK) {
+   ret = fimc_hw_camblk_cfg_writeback(fimc);
+   if (ret  0)
+   return ret;
+   }
 
spin_lock_irqsave(fimc-slock, flags);
fimc_prepare_dma_offset(ctx, ctx-d_frame);
fimc_set_yuv_order(ctx);
 
-   fimc_hw_set_camera_polarity(fimc, sensor-pdata);
-   fimc_hw_set_camera_type(fimc, sensor-pdata);
-   fimc_hw_set_camera_source(fimc, sensor-pdata);
+   fimc_hw_set_camera_polarity(fimc, si);
+   fimc_hw_set_camera_type(fimc, si);
+   fimc_hw_set_camera_source(fimc, si);
fimc_hw_set_camera_offset(fimc, ctx-s_frame);
 
ret = fimc_set_scaler_info(ctx);
@@ -606,18 +607,22 @@ static struct fimc_fmt *fimc_capture_try_format(struct 
fimc_ctx *ctx,
fimc_fmt_is_user_defined(ctx-s_frame.fmt-color))
*code = ctx-s_frame.fmt-mbus_code;
 
-   if (fourcc  *fourcc != V4L2_PIX_FMT_JPEG  pad != FIMC_SD_PAD_SINK)
+   if (fourcc  *fourcc != V4L2_PIX_FMT_JPEG  pad == FIMC_SD_PAD_SOURCE)
mask |= FMT_FLAGS_M2M;
 
+   if (pad == FIMC_SD_PAD_SINK_FIFO)
+   mask = FMT_FLAGS_WRITEBACK;
+
ffmt = fimc_find_format(fourcc, code, mask, 0);
if (WARN_ON(!ffmt))
return NULL;
+
if (code)
*code = ffmt-mbus_code;
if (fourcc)
*fourcc = ffmt-fourcc;
 
-   if (pad == FIMC_SD_PAD_SINK) {
+   if (pad != FIMC_SD_PAD_SOURCE) {
max_w = fimc_fmt_is_user_defined(ffmt-color) ?
pl-scaler_dis_w : pl-scaler_en_w;
/* Apply the camera input interface pixel constraints */
@@ -851,7 +856,7 @@ static int fimc_pipeline_try_format(struct fimc_ctx *ctx,
tfmt-width  = mf-width;
tfmt-height = mf-height;
ffmt = fimc_capture_try_format(ctx, tfmt-width, tfmt-height,
-   NULL, fcc, FIMC_SD_PAD_SINK);
+   NULL, fcc, FIMC_SD_PAD_SINK_CAM);
ffmt = fimc_capture_try_format(ctx, tfmt-width, tfmt-height,
  

[PATCH v2 03/10] s5p-fimc: Update graph traversal for entities with multiple source pads

2013-03-26 Thread Sylwester Nawrocki
We cannot assume that the passed entity the fimc_pipeline_prepare()
function is supposed to start the media graph traversal from will
always have its sink pad at pad index 0. Find the starting media
entity's sink pad by iterating over its all pads and checking the
pad flags. This ensures proper handling of FIMC, FIMC-LITE and
FIMC-IS-ISP subdevs that have more than one sink and one source pad.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |   24 +++-
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c 
b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
index b689166..abd3ad3 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
@@ -40,14 +40,13 @@ static int __fimc_md_set_camclk(struct fimc_md *fmd,
bool on);
 /**
  * fimc_pipeline_prepare - update pipeline information with subdevice pointers
- * @fimc: fimc device terminating the pipeline
+ * @me: media entity terminating the pipeline
  *
  * Caller holds the graph mutex.
  */
 static void fimc_pipeline_prepare(struct fimc_pipeline *p,
  struct media_entity *me)
 {
-   struct media_pad *pad = me-pads[0];
struct v4l2_subdev *sd;
int i;
 
@@ -55,15 +54,21 @@ static void fimc_pipeline_prepare(struct fimc_pipeline *p,
p-subdevs[i] = NULL;
 
while (1) {
-   if (!(pad-flags  MEDIA_PAD_FL_SINK))
-   break;
+   struct media_pad *pad = NULL;
+
+   /* Find remote source pad */
+   for (i = 0; i  me-num_pads; i++) {
+   struct media_pad *spad = me-pads[i];
+   if (!(spad-flags  MEDIA_PAD_FL_SINK))
+   continue;
+   pad = media_entity_remote_source(spad);
+   if (pad)
+   break;
+   }
 
-   /* source pad */
-   pad = media_entity_remote_source(pad);
if (pad == NULL ||
media_entity_type(pad-entity) != MEDIA_ENT_T_V4L2_SUBDEV)
break;
-
sd = media_entity_to_v4l2_subdev(pad-entity);
 
switch (sd-grp_id) {
@@ -84,8 +89,9 @@ static void fimc_pipeline_prepare(struct fimc_pipeline *p,
pr_warn(%s: Unknown subdev grp_id: %#x\n,
__func__, sd-grp_id);
}
-   /* sink pad */
-   pad = sd-entity.pads[0];
+   me = sd-entity;
+   if (me-num_pads == 1)
+   break;
}
 }
 
-- 
1.7.9.5

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


[PATCH v2 06/10] s5p-fimc: Ensure CAMCLK clock can be enabled by FIMC-LITE devices

2013-03-26 Thread Sylwester Nawrocki
In configurations where FIMC-LITE is used to capture image signal
from an external sensor only we need to ensure one of FIMC devices
is in active power state and the fimc gate clock is enabled.
Otherwise the CAMCLK clock output signal will be masked off
preventing an external sensor's operation.
This affect processing pipelines like:

 - sensor - FIMC-LITE - memory
 - sensor - MIPI-CSIS - FIMC-LITE - memory

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |   18 ++
 drivers/media/platform/s5p-fimc/fimc-mdevice.h |2 ++
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c 
b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
index 5b11e39..d519ee7 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
@@ -507,7 +507,6 @@ static int fimc_md_register_sensor_entities(struct fimc_md 
*fmd)
 {
struct s5p_platform_fimc *pdata = fmd-pdev-dev.platform_data;
struct device_node *of_node = fmd-pdev-dev.of_node;
-   struct fimc_dev *fd = NULL;
int num_clients = 0;
int ret, i;
 
@@ -515,13 +514,10 @@ static int fimc_md_register_sensor_entities(struct 
fimc_md *fmd)
 * Runtime resume one of the FIMC entities to make sure
 * the sclk_cam clocks are not globally disabled.
 */
-   for (i = 0; !fd  i  ARRAY_SIZE(fmd-fimc); i++)
-   if (fmd-fimc[i])
-   fd = fmd-fimc[i];
-   if (!fd)
+   if (!fmd-pmf)
return -ENXIO;
 
-   ret = pm_runtime_get_sync(fd-pdev-dev);
+   ret = pm_runtime_get_sync(fmd-pmf);
if (ret  0)
return ret;
 
@@ -555,7 +551,7 @@ static int fimc_md_register_sensor_entities(struct fimc_md 
*fmd)
}
}
 
-   pm_runtime_put(fd-pdev-dev);
+   pm_runtime_put(fmd-pmf);
return ret;
 }
 
@@ -600,6 +596,8 @@ static int register_fimc_entity(struct fimc_md *fmd, struct 
fimc_dev *fimc)
 
ret = v4l2_device_register_subdev(fmd-v4l2_dev, sd);
if (!ret) {
+   if (!fmd-pmf  fimc-pdev)
+   fmd-pmf = fimc-pdev-dev;
fmd-fimc[fimc-id] = fimc;
fimc-vid_cap.user_subdev_api = fmd-user_subdev_api;
} else {
@@ -1083,7 +1081,7 @@ static int __fimc_md_set_camclk(struct fimc_md *fmd,
struct fimc_camclk_info *camclk;
int ret = 0;
 
-   if (WARN_ON(pdata-clk_id = FIMC_MAX_CAMCLKS) || fmd == NULL)
+   if (WARN_ON(pdata-clk_id = FIMC_MAX_CAMCLKS) || !fmd || !fmd-pmf)
return -EINVAL;
 
camclk = fmd-camclk[pdata-clk_id];
@@ -1099,6 +1097,9 @@ static int __fimc_md_set_camclk(struct fimc_md *fmd,
if (camclk-use_count++ == 0) {
clk_set_rate(camclk-clock, pdata-clk_frequency);
camclk-frequency = pdata-clk_frequency;
+   ret = pm_runtime_get_sync(fmd-pmf);
+   if (ret  0)
+   return ret;
ret = clk_enable(camclk-clock);
dbg(Enabled camclk %d: f: %lu, pdata-clk_id,
clk_get_rate(camclk-clock));
@@ -,6 +1112,7 @@ static int __fimc_md_set_camclk(struct fimc_md *fmd,
 
if (--camclk-use_count == 0) {
clk_disable(camclk-clock);
+   pm_runtime_put(fmd-pmf);
dbg(Disabled camclk %d, pdata-clk_id);
}
return ret;
diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.h 
b/drivers/media/platform/s5p-fimc/fimc-mdevice.h
index 46f3b82..1d5cea5 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.h
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.h
@@ -81,6 +81,7 @@ struct fimc_sensor_info {
  * @camclk: external sensor clock information
  * @fimc: array of registered fimc devices
  * @use_isp: set to true when FIMC-IS subsystem is used
+ * @pmf: handle to the CAMCLK clock control FIMC helper device
  * @media_dev: top level media device
  * @v4l2_dev: top level v4l2_device holding up the subdevs
  * @pdev: platform device this media device is hooked up into
@@ -99,6 +100,7 @@ struct fimc_md {
struct fimc_lite *fimc_lite[FIMC_LITE_MAX_DEVS];
struct fimc_dev *fimc[FIMC_MAX_DEVS];
bool use_isp;
+   struct device *pmf;
struct media_device media_dev;
struct v4l2_device v4l2_dev;
struct platform_device *pdev;
-- 
1.7.9.5

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


[PATCH v2 07/10] s5p-fimc: Ensure proper s_stream() call order in the ISP datapaths

2013-03-26 Thread Sylwester Nawrocki
Since the FIMC-IS firmware communicates with an image sensor directly
through the ISP I2C bus controllers data streaming cannot be simply
enabled from left to right or disabled from right to left along the
processing pipeline. Thus a subdev index to call s_stream() on is
looked up from a table, rather than doing the op call based on
increasing/decreasing indexes.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |   22 +++---
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c 
b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
index d519ee7..53bfd20 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
@@ -225,28 +225,36 @@ static int __fimc_pipeline_close(struct fimc_pipeline *p)
 }
 
 /**
- * __fimc_pipeline_s_stream - invoke s_stream on pipeline subdevs
+ * __fimc_pipeline_s_stream - call s_stream() on pipeline subdevs
  * @pipeline: video pipeline structure
- * @on: passed as the s_stream call argument
+ * @on: passed as the s_stream() callback argument
  */
 static int __fimc_pipeline_s_stream(struct fimc_pipeline *p, bool on)
 {
-   int i, ret;
+   static const u8 seq[2][IDX_MAX] = {
+   { IDX_FIMC, IDX_SENSOR, IDX_IS_ISP, IDX_CSIS, IDX_FLITE },
+   { IDX_CSIS, IDX_FLITE, IDX_FIMC, IDX_SENSOR, IDX_IS_ISP },
+   };
+   int i, ret = 0;
 
if (p-subdevs[IDX_SENSOR] == NULL)
return -ENODEV;
 
for (i = 0; i  IDX_MAX; i++) {
-   unsigned int idx = on ? (IDX_MAX - 1) - i : i;
+   unsigned int idx = seq[on][i];
 
ret = v4l2_subdev_call(p-subdevs[idx], video, s_stream, on);
 
if (ret  0  ret != -ENOIOCTLCMD  ret != -ENODEV)
-   return ret;
+   goto error;
}
-
return 0;
-
+error:
+   for (; i = 0; i--) {
+   unsigned int idx = seq[on][i];
+   v4l2_subdev_call(p-subdevs[idx], video, s_stream, !on);
+   }
+   return ret;
 }
 
 /* Media pipeline operations for the FIMC/FIMC-LITE video device driver */
-- 
1.7.9.5

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


[PATCH v2 09/10] s5p-fimc: Remove dependency on fimc-core.h in fimc-lite driver

2013-03-26 Thread Sylwester Nawrocki
Drop fimc-lite.h header inclusion to make the exynos-fimc-lite
module independent on other modules. Move struct fimc_fmt
declaration to the driver's private headers as it is used in
multiple modules.

Reported-by: Shaik Ameer Basha shaik.am...@samsung.com
Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-core.h |   31 
 drivers/media/platform/s5p-fimc/fimc-lite.c |1 -
 drivers/media/platform/s5p-fimc/fimc-lite.h |3 +--
 include/media/s5p_fimc.h|   34 +++
 4 files changed, 35 insertions(+), 34 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-core.h 
b/drivers/media/platform/s5p-fimc/fimc-core.h
index 6355b33..79a 100644
--- a/drivers/media/platform/s5p-fimc/fimc-core.h
+++ b/drivers/media/platform/s5p-fimc/fimc-core.h
@@ -137,37 +137,6 @@ enum fimc_color_fmt {
 #defineFIMC_COLOR_RANGE_NARROW (1  3)
 
 /**
- * struct fimc_fmt - the driver's internal color format data
- * @mbus_code: Media Bus pixel code, -1 if not applicable
- * @name: format description
- * @fourcc: the fourcc code for this format, 0 if not applicable
- * @color: the corresponding fimc_color_fmt
- * @memplanes: number of physically non-contiguous data planes
- * @colplanes: number of physically contiguous data planes
- * @depth: per plane driver's private 'number of bits per pixel'
- * @mdataplanes: bitmask indicating meta data plane(s), (1  plane_no)
- * @flags: flags indicating which operation mode format applies to
- */
-struct fimc_fmt {
-   enum v4l2_mbus_pixelcode mbus_code;
-   char*name;
-   u32 fourcc;
-   u32 color;
-   u16 memplanes;
-   u16 colplanes;
-   u8  depth[VIDEO_MAX_PLANES];
-   u16 mdataplanes;
-   u16 flags;
-#define FMT_FLAGS_CAM  (1  0)
-#define FMT_FLAGS_M2M_IN   (1  1)
-#define FMT_FLAGS_M2M_OUT  (1  2)
-#define FMT_FLAGS_M2M  (1  1 | 1  2)
-#define FMT_HAS_ALPHA  (1  3)
-#define FMT_FLAGS_COMPRESSED   (1  4)
-#define FMT_FLAGS_WRITEBACK(1  5)
-};
-
-/**
  * struct fimc_dma_offset - pixel offset information for DMA
  * @y_h:   y value horizontal offset
  * @y_v:   y value vertical offset
diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.c 
b/drivers/media/platform/s5p-fimc/fimc-lite.c
index c76a9d6..ca78ac0 100644
--- a/drivers/media/platform/s5p-fimc/fimc-lite.c
+++ b/drivers/media/platform/s5p-fimc/fimc-lite.c
@@ -32,7 +32,6 @@
 #include media/s5p_fimc.h
 
 #include fimc-mdevice.h
-#include fimc-core.h
 #include fimc-lite.h
 #include fimc-lite-reg.h
 
diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.h 
b/drivers/media/platform/s5p-fimc/fimc-lite.h
index 7085761..4c234508 100644
--- a/drivers/media/platform/s5p-fimc/fimc-lite.h
+++ b/drivers/media/platform/s5p-fimc/fimc-lite.h
@@ -20,12 +20,11 @@
 
 #include media/media-entity.h
 #include media/videobuf2-core.h
+#include media/v4l2-ctrls.h
 #include media/v4l2-device.h
 #include media/v4l2-mediabus.h
 #include media/s5p_fimc.h
 
-#include fimc-core.h
-
 #define FIMC_LITE_DRV_NAME exynos-fimc-lite
 #define FLITE_CLK_NAME flite
 #define FIMC_LITE_MAX_DEVS 2
diff --git a/include/media/s5p_fimc.h b/include/media/s5p_fimc.h
index e2434bb..2363aff 100644
--- a/include/media/s5p_fimc.h
+++ b/include/media/s5p_fimc.h
@@ -13,6 +13,7 @@
 #define S5P_FIMC_H_
 
 #include media/media-entity.h
+#include media/v4l2-mediabus.h
 
 /*
  * Enumeration of data inputs to the camera subsystem.
@@ -93,6 +94,39 @@ struct s5p_platform_fimc {
  */
 #define S5P_FIMC_TX_END_NOTIFY _IO('e', 0)
 
+#define FIMC_MAX_PLANES3
+
+/**
+ * struct fimc_fmt - color format data structure
+ * @mbus_code: media bus pixel code, -1 if not applicable
+ * @name: format description
+ * @fourcc: fourcc code for this format, 0 if not applicable
+ * @color: the driver's private color format id
+ * @memplanes: number of physically non-contiguous data planes
+ * @colplanes: number of physically contiguous data planes
+ * @depth: per plane driver's private 'number of bits per pixel'
+ * @mdataplanes: bitmask indicating meta data plane(s), (1  plane_no)
+ * @flags: flags indicating which operation mode format applies to
+ */
+struct fimc_fmt {
+   enum v4l2_mbus_pixelcode mbus_code;
+   char*name;
+   u32 fourcc;
+   u32 color;
+   u16 memplanes;
+   u16 colplanes;
+   u8  depth[FIMC_MAX_PLANES];
+   u16 mdataplanes;
+   u16 flags;
+#define FMT_FLAGS_CAM  (1  0)
+#define FMT_FLAGS_M2M_IN   (1  1)
+#define FMT_FLAGS_M2M_OUT  (1  2)
+#define FMT_FLAGS_M2M  (1  1 | 1  2)
+#define FMT_HAS_ALPHA  (1  3)
+#define FMT_FLAGS_COMPRESSED   (1  4)
+#define FMT_FLAGS_WRITEBACK(1  5)
+};
+
 enum fimc_subdev_index {
IDX_SENSOR,
IDX_CSIS,
-- 
1.7.9.5

--
To 

[PATCH v2 10/10] s5p-fimc: Change the driver directory name to exynos4-is

2013-03-26 Thread Sylwester Nawrocki
The s5p-fimc directory now contains drivers for multiple IP blocks
found in multiple Samsung application processors. This includes FIMC
(CAMIF), MIPI CSIS and FIMC LITE. FIMC-IS (Imaging Subsystem) driver
is going to be put into same directory. Hence we rename it to
exynos4-is as s5p-fimc was only relevant for early version of this
driver, when it only supported FIMC IP block.

The imaging subsystem drivers for Exynos4 SoC series and S5PV210 will
be included in drivers/media/platform/exynos4-is directory, with some
modules shared with exynos5 series, while the rest of exynos5 specific
modules will find their home in drivers/media/platform/exynos5-is.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/Kconfig |2 +-
 drivers/media/platform/Makefile|2 +-
 .../platform/{s5p-fimc = exynos4-is}/Kconfig  |8 
 .../platform/{s5p-fimc = exynos4-is}/Makefile |2 +-
 .../{s5p-fimc = exynos4-is}/fimc-capture.c|2 +-
 .../platform/{s5p-fimc = exynos4-is}/fimc-core.c  |2 +-
 .../platform/{s5p-fimc = exynos4-is}/fimc-core.h  |0
 .../{s5p-fimc = exynos4-is}/fimc-lite-reg.c   |0
 .../{s5p-fimc = exynos4-is}/fimc-lite-reg.h   |0
 .../platform/{s5p-fimc = exynos4-is}/fimc-lite.c  |2 +-
 .../platform/{s5p-fimc = exynos4-is}/fimc-lite.h  |0
 .../platform/{s5p-fimc = exynos4-is}/fimc-m2m.c   |3 +--
 .../platform/{s5p-fimc = exynos4-is}/fimc-reg.c   |2 +-
 .../platform/{s5p-fimc = exynos4-is}/fimc-reg.h   |0
 .../fimc-mdevice.c = exynos4-is/media-dev.c}  |2 +-
 .../fimc-mdevice.h = exynos4-is/media-dev.h}  |0
 .../platform/{s5p-fimc = exynos4-is}/mipi-csis.c  |0
 .../platform/{s5p-fimc = exynos4-is}/mipi-csis.h  |0
 18 files changed, 13 insertions(+), 14 deletions(-)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/Kconfig (87%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/Makefile (94%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-capture.c (99%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-core.c (99%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-core.h (100%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-lite-reg.c (100%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-lite-reg.h (100%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-lite.c (99%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-lite.h (100%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-m2m.c (99%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-reg.c (99%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-reg.h (100%)
 rename drivers/media/platform/{s5p-fimc/fimc-mdevice.c = 
exynos4-is/media-dev.c} (99%)
 rename drivers/media/platform/{s5p-fimc/fimc-mdevice.h = 
exynos4-is/media-dev.h} (100%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/mipi-csis.c (100%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/mipi-csis.h (100%)

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 3dcfea6..7813b2a 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -122,7 +122,7 @@ config VIDEO_S3C_CAMIF
  will be called s3c-camif.
 
 source drivers/media/platform/soc_camera/Kconfig
-source drivers/media/platform/s5p-fimc/Kconfig
+source drivers/media/platform/exynos4-is/Kconfig
 source drivers/media/platform/s5p-tv/Kconfig
 
 endif # V4L_PLATFORM_DRIVERS
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 4817d28..8d691fe 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -28,7 +28,7 @@ obj-$(CONFIG_VIDEO_CODA)  += coda.o
 obj-$(CONFIG_VIDEO_MEM2MEM_DEINTERLACE)+= m2m-deinterlace.o
 
 obj-$(CONFIG_VIDEO_S3C_CAMIF)  += s3c-camif/
-obj-$(CONFIG_VIDEO_SAMSUNG_S5P_FIMC)   += s5p-fimc/
+obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS4_IS) += exynos4-is/
 obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG)   += s5p-jpeg/
 obj-$(CONFIG_VIDEO_SAMSUNG_S5P_MFC)+= s5p-mfc/
 obj-$(CONFIG_VIDEO_SAMSUNG_S5P_TV) += s5p-tv/
diff --git a/drivers/media/platform/s5p-fimc/Kconfig 
b/drivers/media/platform/exynos4-is/Kconfig
similarity index 87%
rename from drivers/media/platform/s5p-fimc/Kconfig
rename to drivers/media/platform/exynos4-is/Kconfig
index 64c1116..ed96dbc 100644
--- a/drivers/media/platform/s5p-fimc/Kconfig
+++ b/drivers/media/platform/exynos4-is/Kconfig
@@ -1,6 +1,6 @@
 
-config VIDEO_SAMSUNG_S5P_FIMC
-   bool Samsung S5P/EXYNOS SoC camera interface driver (experimental)
+config VIDEO_SAMSUNG_EXYNOS4_IS
+   bool Samsung S5P/EXYNOS4 SoC series Camera Subsystem driver
depends on VIDEO_V4L2  VIDEO_V4L2_SUBDEV_API  PLAT_S5P  PM_RUNTIME
depends on EXPERIMENTAL
depends on MFD_SYSCON
@@ -8,7 +8,7 @@ config 

[PATCH v3 0/5] em28xx: add support for the em2765 bridge

2013-03-26 Thread Frank Schäfer
This patch series adds basic support for the em25xx/276x/7x/8x camera bridges.
These devices differ from the em2710/2750 and em28xx bridges in several points:
1) a second i2c bus is provided which has to be accessed with a different 
   read/write algorithm (= patch 1)
2) a different frame data format is used (= patch 3)
3) additional output formats (e.g. mpeg) are provided. This patch series does
   not (yet) add support for them, but it fixes the output format selection 
   for these bridges (the current code sets bit 5 of the output format register,
   which has a different meaning for the other bridges and breaks capturing
   with em25xx family sdevices). (= patch 4)
4) registers 0x34+0x35 (VBI_START_H/V for em28xx devices) are used for a 
   different (unknown) purpose. This needs to be investigated further (could be 
   zooming, cropping, image statistics or AWB/AE window selection).
   At normal operation, these registers are set to capturing (input) 
   width/height / 16. (= patch 5)

Patch 2 adds the chip id of the em2765 as found in the SpeedLink Vicious And 
Devine Laplace webcam. The changes have also been tested with this device.

Changes since v1:
- rebased on the recent em28xx i2c bus changes (real support for 2 busses)
- moved i2c algorithm depending transfer function calls to separate functions

Changes since v2:
- fixed some coding style issues and comments

Frank Schäfer (5):
  em28xx: add support for em25xx i2c bus B read/write/check device
operations
  em28xx: add chip id of the em2765
  em28xx: add support for em25xx/em276x/em277x/em278x frame data
processing
  em28xx: make em28xx_set_outfmt() working with EM25xx family bridges
  em28xx: write output frame resolution to regs 0x34+0x35 for em25xx
family bridges

 drivers/media/usb/em28xx/em28xx-cards.c |   19 ++-
 drivers/media/usb/em28xx/em28xx-core.c  |   28 +++-
 drivers/media/usb/em28xx/em28xx-i2c.c   |  236 ++-
 drivers/media/usb/em28xx/em28xx-reg.h   |   10 +-
 drivers/media/usb/em28xx/em28xx-video.c |   74 +-
 drivers/media/usb/em28xx/em28xx.h   |   11 +-
 6 Dateien geändert, 329 Zeilen hinzugefügt(+), 49 Zeilen entfernt(-)

-- 
1.7.10.4

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


[PATCH v3 2/5] em28xx: add chip id of the em2765

2013-03-26 Thread Frank Schäfer
This chip can be found in the SpeedLink VAD Laplace webcam (1ae7:9003 and 
1ae7:9004).

Signed-off-by: Frank Schäfer fschaefer@googlemail.com
---
 drivers/media/usb/em28xx/em28xx-cards.c |   13 -
 drivers/media/usb/em28xx/em28xx-reg.h   |1 +
 drivers/media/usb/em28xx/em28xx.h   |1 +
 3 Dateien geändert, 14 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)

diff --git a/drivers/media/usb/em28xx/em28xx-cards.c 
b/drivers/media/usb/em28xx/em28xx-cards.c
index 033b6cb..54e0362 100644
--- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -3041,6 +3041,12 @@ static int em28xx_init_dev(struct em28xx *dev, struct 
usb_device *udev,
case CHIP_ID_EM2750:
chip_name = em2750;
break;
+   case CHIP_ID_EM2765:
+   chip_name = em2765;
+   dev-wait_after_write = 0;
+   dev-is_em25xx = 1;
+   dev-eeprom_addrwidth_16bit = 1;
+   break;
case CHIP_ID_EM2820:
chip_name = em2710/2820;
break;
@@ -3151,7 +3157,12 @@ static int em28xx_init_dev(struct em28xx *dev, struct 
usb_device *udev,
 
/* register i2c bus 1 */
if (dev-def_i2c_bus) {
-   retval = em28xx_i2c_register(dev, 1, EM28XX_I2C_ALGO_EM28XX);
+   if (dev-is_em25xx)
+   retval = em28xx_i2c_register(dev, 1,
+ EM28XX_I2C_ALGO_EM25XX_BUS_B);
+   else
+   retval = em28xx_i2c_register(dev, 1,
+   EM28XX_I2C_ALGO_EM28XX);
if (retval  0) {
em28xx_errdev(%s: em28xx_i2c_register bus 1 - error 
[%d]!\n,
__func__, retval);
diff --git a/drivers/media/usb/em28xx/em28xx-reg.h 
b/drivers/media/usb/em28xx/em28xx-reg.h
index 8fd3c7f..1b0ecd6 100644
--- a/drivers/media/usb/em28xx/em28xx-reg.h
+++ b/drivers/media/usb/em28xx/em28xx-reg.h
@@ -219,6 +219,7 @@ enum em28xx_chip_id {
CHIP_ID_EM2860 = 34,
CHIP_ID_EM2870 = 35,
CHIP_ID_EM2883 = 36,
+   CHIP_ID_EM2765 = 54,
CHIP_ID_EM2874 = 65,
CHIP_ID_EM2884 = 68,
CHIP_ID_EM28174 = 113,
diff --git a/drivers/media/usb/em28xx/em28xx.h 
b/drivers/media/usb/em28xx/em28xx.h
index aeee896..7be008f 100644
--- a/drivers/media/usb/em28xx/em28xx.h
+++ b/drivers/media/usb/em28xx/em28xx.h
@@ -482,6 +482,7 @@ struct em28xx {
int model;  /* index in the device_data struct */
int devno;  /* marks the number of this device */
enum em28xx_chip_id chip_id;
+   unsigned int is_em25xx:1;   /* em25xx/em276x/7x/8x family bridge */
 
unsigned char disconnected:1;   /* device has been diconnected */
 
-- 
1.7.10.4

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


[PATCH v3 4/5] em28xx: make em28xx_set_outfmt() working with EM25xx family bridges

2013-03-26 Thread Frank Schäfer
Streaming doesn't work with the EM2765 if bit 5 of the output format register
0x27 is set.
It's actually not clear if really has to be set for the other chips, but for
now let's keep it to avoid regressions and add a comment to the code.

Signed-off-by: Frank Schäfer fschaefer@googlemail.com
---
 drivers/media/usb/em28xx/em28xx-core.c |   21 -
 1 Datei geändert, 16 Zeilen hinzugefügt(+), 5 Zeilen entfernt(-)

diff --git a/drivers/media/usb/em28xx/em28xx-core.c 
b/drivers/media/usb/em28xx/em28xx-core.c
index b2dcb3d..575a46a 100644
--- a/drivers/media/usb/em28xx/em28xx-core.c
+++ b/drivers/media/usb/em28xx/em28xx-core.c
@@ -697,12 +697,23 @@ int em28xx_vbi_supported(struct em28xx *dev)
 int em28xx_set_outfmt(struct em28xx *dev)
 {
int ret;
-   u8 vinctrl;
-
-   ret = em28xx_write_reg_bits(dev, EM28XX_R27_OUTFMT,
-   dev-format-reg | 0x20, 0xff);
+   u8 fmt, vinctrl;
+
+   fmt = dev-format-reg;
+   if (!dev-is_em25xx)
+   fmt |= 0x20;
+   /*
+* NOTE: it's not clear if this is really needed !
+* The datasheets say bit 5 is a reserved bit and devices seem to work
+* fine without it. But the Windows driver sets it for em2710/50+em28xx
+* devices and we've always been setting it, too.
+*
+* em2765 (em25xx, em276x/7x/8x) devices do NOT work with this bit set,
+* it's likely used for an additional (compressed ?) format there.
+*/
+   ret = em28xx_write_reg(dev, EM28XX_R27_OUTFMT, fmt);
if (ret  0)
-   return ret;
+   return ret;
 
ret = em28xx_write_reg(dev, EM28XX_R10_VINMODE, dev-vinmode);
if (ret  0)
-- 
1.7.10.4

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


[PATCH v3 5/5] em28xx: write output frame resolution to regs 0x34+0x35 for em25xx family bridges

2013-03-26 Thread Frank Schäfer
The Windows driver writes the output resolution to registers 0x34 (width / 16)
and 0x35 (height / 16) always.
We don't know yet what these registers are used for.

Signed-off-by: Frank Schäfer fschaefer@googlemail.com
---
 drivers/media/usb/em28xx/em28xx-core.c |7 +++
 drivers/media/usb/em28xx/em28xx-reg.h  |9 -
 2 Dateien geändert, 15 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)

diff --git a/drivers/media/usb/em28xx/em28xx-core.c 
b/drivers/media/usb/em28xx/em28xx-core.c
index 575a46a..a802128 100644
--- a/drivers/media/usb/em28xx/em28xx-core.c
+++ b/drivers/media/usb/em28xx/em28xx-core.c
@@ -767,6 +767,13 @@ static void em28xx_capture_area_set(struct em28xx *dev, u8 
hstart, u8 vstart,
em28xx_write_regs(dev, EM28XX_R1E_CWIDTH, cwidth, 1);
em28xx_write_regs(dev, EM28XX_R1F_CHEIGHT, cheight, 1);
em28xx_write_regs(dev, EM28XX_R1B_OFLOW, overflow, 1);
+
+   /* FIXME: function/meaning of these registers ? */
+   /* FIXME: align width+height to multiples of 4 ?! */
+   if (dev-is_em25xx) {
+   em28xx_write_reg(dev, 0x34, width  4);
+   em28xx_write_reg(dev, 0x35, height  4);
+   }
 }
 
 static int em28xx_scaler_set(struct em28xx *dev, u16 h, u16 v)
diff --git a/drivers/media/usb/em28xx/em28xx-reg.h 
b/drivers/media/usb/em28xx/em28xx-reg.h
index 1b0ecd6..622871d 100644
--- a/drivers/media/usb/em28xx/em28xx-reg.h
+++ b/drivers/media/usb/em28xx/em28xx-reg.h
@@ -48,7 +48,7 @@
 #define EM28XX_CHIPCFG2_TS_PACKETSIZE_752  0x03
 
 
-   /* GPIO/GPO registers */
+/* GPIO/GPO registers */
 #define EM2880_R04_GPO 0x04/* em2880-em2883 only */
 #define EM28XX_R08_GPIO0x08/* em2820 or upper */
 
@@ -167,6 +167,13 @@
 
 #define EM28XX_R34_VBI_START_H 0x34
 #define EM28XX_R35_VBI_START_V 0x35
+/*
+ * NOTE: the EM276x (and EM25xx, EM277x/8x ?) (camera bridges) use these
+ * registers for a different unknown purpose.
+ *   = register 0x34 is set to capture width / 16
+ *   = register 0x35 is set to capture height / 16
+ */
+
 #define EM28XX_R36_VBI_WIDTH   0x36
 #define EM28XX_R37_VBI_HEIGHT  0x37
 
-- 
1.7.10.4

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


[PATCH v3 1/5] em28xx: add support for em25xx i2c bus B read/write/check device operations

2013-03-26 Thread Frank Schäfer
The webcam SpeedLink VAD Laplace (em2765 + ov2640) uses a special algorithm
for i2c communication with the sensor, which is connected to a second i2c bus.

We don't know yet how to find out which devices support/use it.
It's very likely used by all em25xx and em276x+ bridges.
Tests with other em28xx chips (em2820, em2882/em2883) show, that this
algorithm always succeeds there although no slave device is connected.

The algorithm likely also works for real i2c client devices (OV2640 uses SCCB),
because the Windows driver seems to use it for probing Samsung and Kodak
sensors.

Signed-off-by: Frank Schäfer fschaefer@googlemail.com
---
 drivers/media/usb/em28xx/em28xx-cards.c |8 +-
 drivers/media/usb/em28xx/em28xx-i2c.c   |  236 ++-
 drivers/media/usb/em28xx/em28xx.h   |   10 +-
 3 Dateien geändert, 212 Zeilen hinzugefügt(+), 42 Zeilen entfernt(-)

diff --git a/drivers/media/usb/em28xx/em28xx-cards.c 
b/drivers/media/usb/em28xx/em28xx-cards.c
index cb7cdd3..033b6cb 100644
--- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -3139,15 +3139,19 @@ static int em28xx_init_dev(struct em28xx *dev, struct 
usb_device *udev,
rt_mutex_init(dev-i2c_bus_lock);
 
/* register i2c bus 0 */
-   retval = em28xx_i2c_register(dev, 0);
+   if (dev-board.is_em2800)
+   retval = em28xx_i2c_register(dev, 0, EM28XX_I2C_ALGO_EM2800);
+   else
+   retval = em28xx_i2c_register(dev, 0, EM28XX_I2C_ALGO_EM28XX);
if (retval  0) {
em28xx_errdev(%s: em28xx_i2c_register bus 0 - error [%d]!\n,
__func__, retval);
goto unregister_dev;
}
 
+   /* register i2c bus 1 */
if (dev-def_i2c_bus) {
-   retval = em28xx_i2c_register(dev, 1);
+   retval = em28xx_i2c_register(dev, 1, EM28XX_I2C_ALGO_EM28XX);
if (retval  0) {
em28xx_errdev(%s: em28xx_i2c_register bus 1 - error 
[%d]!\n,
__func__, retval);
diff --git a/drivers/media/usb/em28xx/em28xx-i2c.c 
b/drivers/media/usb/em28xx/em28xx-i2c.c
index 704f283..4851cc2 100644
--- a/drivers/media/usb/em28xx/em28xx-i2c.c
+++ b/drivers/media/usb/em28xx/em28xx-i2c.c
@@ -5,6 +5,7 @@
  Markus Rechberger mrechber...@gmail.com
  Mauro Carvalho Chehab mche...@infradead.org
  Sascha Sommer saschasom...@freenet.de
+   Copyright (C) 2013 Frank Schäfer fschaefer@googlemail.com
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -279,6 +280,183 @@ static int em28xx_i2c_check_for_device(struct em28xx 
*dev, u16 addr)
 }
 
 /*
+ * em25xx_bus_B_send_bytes
+ * write bytes to the i2c device
+ */
+static int em25xx_bus_B_send_bytes(struct em28xx *dev, u16 addr, u8 *buf,
+  u16 len)
+{
+   int ret;
+
+   if (len  1 || len  64)
+   return -EOPNOTSUPP;
+   /*
+* NOTE: limited by the USB ctrl message constraints
+* Zero length reads always succeed, even if no device is connected
+*/
+
+   /* Set register and write value */
+   ret = dev-em28xx_write_regs_req(dev, 0x06, addr, buf, len);
+   if (ret != len) {
+   if (ret  0) {
+   em28xx_warn(writing to i2c device at 0x%x failed 
(error=%i)\n,
+   addr, ret);
+   return ret;
+   } else {
+   em28xx_warn(%i bytes write to i2c device at 0x%x 
requested, but %i bytes written\n,
+   len, addr, ret);
+   return -EIO;
+   }
+   }
+   /* Check success */
+   ret = dev-em28xx_read_reg_req(dev, 0x08, 0x);
+   /*
+* NOTE: the only error we've seen so far is
+* 0x01 when the slave device is not present
+*/
+   if (!ret)
+   return len;
+   else if (ret  0)
+   return -ENODEV;
+
+   return ret;
+   /*
+* NOTE: With chip types (other chip IDs) which actually don't support
+* this operation, it seems to succeed ALWAYS ! (even if there is no
+* slave device or even no second i2c bus provided)
+*/
+}
+
+/*
+ * em25xx_bus_B_recv_bytes
+ * read bytes from the i2c device
+ */
+static int em25xx_bus_B_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf,
+  u16 len)
+{
+   int ret;
+
+   if (len  1 || len  64)
+   return -EOPNOTSUPP;
+   /*
+* NOTE: limited by the USB ctrl message constraints
+* Zero length reads always succeed, even if no device is connected
+*/
+
+   /* Read value */
+   ret = dev-em28xx_read_reg_req_len(dev, 0x06, addr, buf, len);
+   if (ret  0) {
+  

[PATCH v3 3/5] em28xx: add support for em25xx/em276x/em277x/em278x frame data processing

2013-03-26 Thread Frank Schäfer
The em25xx/em276x/em277x/em278x frame data format is different to the one used
by the em2710/em2750/em28xx chips.
With the recent cleanups and reorganization of the frame data processing code it
can be easily extended to support these devices.

Signed-off-by: Frank Schäfer fschaefer@googlemail.com
---
 drivers/media/usb/em28xx/em28xx-video.c |   74 ++-
 1 Datei geändert, 73 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)

diff --git a/drivers/media/usb/em28xx/em28xx-video.c 
b/drivers/media/usb/em28xx/em28xx-video.c
index b181723..ef1959b 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -76,6 +76,16 @@ MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE(GPL);
 MODULE_VERSION(EM28XX_VERSION);
 
+
+#define EM25XX_FRMDATAHDR_BYTE10x02
+#define EM25XX_FRMDATAHDR_BYTE2_STILL_IMAGE0x20
+#define EM25XX_FRMDATAHDR_BYTE2_FRAME_END  0x02
+#define EM25XX_FRMDATAHDR_BYTE2_FRAME_ID   0x01
+#define EM25XX_FRMDATAHDR_BYTE2_MASK   (EM25XX_FRMDATAHDR_BYTE2_STILL_IMAGE | \
+EM25XX_FRMDATAHDR_BYTE2_FRAME_END |   \
+EM25XX_FRMDATAHDR_BYTE2_FRAME_ID)
+
+
 static unsigned int video_nr[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = -1U };
 static unsigned int vbi_nr[]   = {[0 ... (EM28XX_MAXBOARDS - 1)] = -1U };
 static unsigned int radio_nr[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = -1U };
@@ -408,6 +418,62 @@ static inline void process_frame_data_em28xx(struct em28xx 
*dev,
em28xx_copy_video(dev, buf, data_pkt, data_len);
 }
 
+/*
+ * Process data packet according to the em25xx/em276x/7x/8x frame data format
+ */
+static inline void process_frame_data_em25xx(struct em28xx *dev,
+unsigned char *data_pkt,
+unsigned int  data_len)
+{
+   struct em28xx_buffer*buf = dev-usb_ctl.vid_buf;
+   struct em28xx_dmaqueue  *dmaq = dev-vidq;
+   bool frame_end = 0;
+
+   /* Check for header */
+   /* NOTE: at least with bulk transfers, only the first packet
+* has a header and has always set the FRAME_END bit */
+   if (data_len = 2) {/* em25xx header is only 2 bytes long */
+   if ((data_pkt[0] == EM25XX_FRMDATAHDR_BYTE1) 
+   ((data_pkt[1]  ~EM25XX_FRMDATAHDR_BYTE2_MASK) == 0x00)) {
+   dev-top_field = !(data_pkt[1] 
+  EM25XX_FRMDATAHDR_BYTE2_FRAME_ID);
+   frame_end = data_pkt[1] 
+   EM25XX_FRMDATAHDR_BYTE2_FRAME_END;
+   data_pkt += 2;
+   data_len -= 2;
+   }
+
+   /* Finish field and prepare next (BULK only) */
+   if (dev-analog_xfer_bulk  frame_end) {
+   buf = finish_field_prepare_next(dev, buf, dmaq);
+   dev-usb_ctl.vid_buf = buf;
+   }
+   /* NOTE: in ISOC mode when a new frame starts and buf==NULL,
+* we COULD already prepare a buffer here to avoid skipping the
+* first frame.
+*/
+   }
+
+   /* Copy data */
+   if (buf != NULL  data_len  0)
+   em28xx_copy_video(dev, buf, data_pkt, data_len);
+
+   /* Finish frame (ISOC only) = avoids lag of 1 frame */
+   if (!dev-analog_xfer_bulk  frame_end) {
+   buf = finish_field_prepare_next(dev, buf, dmaq);
+   dev-usb_ctl.vid_buf = buf;
+   }
+
+   /* NOTE: Tested with USB bulk transfers only !
+* The wording in the datasheet suggests that isoc might work different.
+* The current code assumes that with isoc transfers each packet has a
+* header like with the other em28xx devices.
+*/
+   /* NOTE: Support for interlaced mode is pure theory. It has not been
+* tested and it is unknown if these devices actually support it. */
+   /* NOTE: No VBI support yet (these chips likely do not support VBI). */
+}
+
 /* Processes and copies the URB data content (video and VBI data) */
 static inline int em28xx_urb_data_copy(struct em28xx *dev, struct urb *urb)
 {
@@ -460,7 +526,13 @@ static inline int em28xx_urb_data_copy(struct em28xx *dev, 
struct urb *urb)
continue;
}
 
-   process_frame_data_em28xx(dev, usb_data_pkt, usb_data_len);
+   if (dev-is_em25xx)
+   process_frame_data_em25xx(dev,
+ usb_data_pkt, usb_data_len);
+   else
+   process_frame_data_em28xx(dev,
+ usb_data_pkt, usb_data_len);
+
}
return 1;
 }
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a 

[PATCH v2 0/7] V4L2 driver for Exynos4x12 Imaging Subsystem

2013-03-26 Thread Sylwester Nawrocki
This iteration includes couple bug fixes and minor cleanup comparing
to the original version (original cover letter can be found below).
A patch adding ISP capture node has been removed as I'll need more
time to enable this feature and I'd like to possibly have this series
included in 3.10.
   ---

This patch series is an initial version of a driver for the camera ISP
subsystem (FIMC-IS) found in Samsung Exynos4x12 SoCs.

The FIMC-IS subsystem is build around a ARM Cortex-A5 CPU that controls
its dedicated peripherals, like I2C, SPI, UART, PWM, ADC,...  and the
ISP chain. There are 3 hardware image processing blocks: ISP, DRC
(dynamic range compression) and FD (face detection) that are normally
controlled by the Cortex-A5 firmware.

The driver currently exposes two additional sub-devices to user space:
the image sensor and FIMC-IS-ISP sub-device. Another one might be
added in future for the FD features.

The FIMC-IS has various data inputs, it can capture data from memory
or from other SoC IP blocks (FIMC-LITE). It is currently plugged
between FIMC-LITE and FIMC IP blocks, so there is a media pipeline
like:

sensor - MIPI-CSIS - FIMC-LITE - FIMC-IS-ISP - FIMC - memory

A raw Bayer image data can be captured from the ISP block which has
it's own DMA engines. Support for this is not really included in
this series though, only a video capture node driver stubs are added.

This is a bit complicated code, nevertheless I would really appreciate
any review comments you might have.

And this is just a basic set of futures this patch series addresses.
Others include input/output DMA support for the DRC and FD blocks,
support for more ISP controls, etc.


Full git tree with all dependencies can be found at:
http://git.linuxtv.org/snawrocki/samsung.git/exynos4-fimc-is-v2

Sylwester Nawrocki (7):
  exynos4-is: Add Exynos4x12 FIMC-IS driver
  exynos4-is: Add FIMC-IS ISP I2C bus driver
  exynos4-is: Add FIMC-IS parameter region definitions
  exynos4-is: Add common FIMC-IS image sensor driver
  exynos4-is: Add Exynos4x12 FIMC-IS device tree bindings documentation
  s5p-fimc: Add fimc-is subdevs registration
  s5p-fimc: Create media links for the FIMC-IS entities

 .../devicetree/bindings/media/exynos4-fimc-is.txt  |   45 +
 drivers/media/platform/exynos4-is/Kconfig  |   13 +
 drivers/media/platform/exynos4-is/Makefile |3 +
 .../media/platform/exynos4-is/fimc-is-command.h|  147 +++
 drivers/media/platform/exynos4-is/fimc-is-errno.c  |  272 ++
 drivers/media/platform/exynos4-is/fimc-is-errno.h  |  248 +
 drivers/media/platform/exynos4-is/fimc-is-i2c.c|   81 ++
 drivers/media/platform/exynos4-is/fimc-is-i2c.h|   15 +
 drivers/media/platform/exynos4-is/fimc-is-param.c  |  971 +++
 drivers/media/platform/exynos4-is/fimc-is-param.h  | 1022 
 drivers/media/platform/exynos4-is/fimc-is-regs.c   |  242 +
 drivers/media/platform/exynos4-is/fimc-is-regs.h   |  164 
 drivers/media/platform/exynos4-is/fimc-is-sensor.c |  307 ++
 drivers/media/platform/exynos4-is/fimc-is-sensor.h |   80 ++
 drivers/media/platform/exynos4-is/fimc-is.c|  962 ++
 drivers/media/platform/exynos4-is/fimc-is.h|  340 +++
 drivers/media/platform/exynos4-is/fimc-isp.c   |  707 ++
 drivers/media/platform/exynos4-is/fimc-isp.h   |  181 
 drivers/media/platform/exynos4-is/media-dev.c  |  120 ++-
 drivers/media/platform/exynos4-is/media-dev.h  |   13 +
 20 files changed, 5911 insertions(+), 22 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/exynos4-fimc-is.txt
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-command.h
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-errno.c
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-errno.h
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-i2c.c
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-i2c.h
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-param.c
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-param.h
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-regs.c
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-regs.h
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-sensor.c
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-sensor.h
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is.c
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is.h
 create mode 100644 drivers/media/platform/exynos4-is/fimc-isp.c
 create mode 100644 drivers/media/platform/exynos4-is/fimc-isp.h

--
1.7.9.5

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


[PATCH v2 2/7] exynos4-is: Add FIMC-IS ISP I2C bus driver

2013-03-26 Thread Sylwester Nawrocki
This patch adds the ISP I2C bus controller driver files.

Creating a standard I2C bus adapter, even if the driver doesn't
actually communicates with the hardware and it is instead used
by the ISP firmware running on the Cortex-A5, allows to use
standard hardware description in the device tree. As the sensor
would have actually had a standard V4L2 sub-device driver run
on the host CPU.

This approach allows to adapt the driver with a relatively small
effort should the Imaging Subsystem architecture change so that
the I2C bus is controlled by the host CPU, rather than the
internal FIMC-IS ARM CPU. The image sensor drivers can be
standard I2C client driver, as in case of most existing image
sensor driver.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/exynos4-is/fimc-is-i2c.c |   81 +++
 drivers/media/platform/exynos4-is/fimc-is-i2c.h |   15 +
 2 files changed, 96 insertions(+)
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-i2c.c
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-i2c.h

diff --git a/drivers/media/platform/exynos4-is/fimc-is-i2c.c 
b/drivers/media/platform/exynos4-is/fimc-is-i2c.c
new file mode 100644
index 000..d4c75dc
--- /dev/null
+++ b/drivers/media/platform/exynos4-is/fimc-is-i2c.c
@@ -0,0 +1,81 @@
+/*
+ * Samsung EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Sylwester Nawrocki s.nawro...@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.
+ */
+#define pr_fmt(fmt) %s:%d  fmt, __func__, __LINE__
+
+#include linux/module.h
+#include linux/of_i2c.h
+#include linux/platform_device.h
+#include fimc-is-i2c.h
+
+/*
+ * An empty algorithm is used as the actual I2C bus controller driver
+ * is implemented in the FIMC-IS subsystem firmware and the host CPU
+ * doesn't touch the hardware.
+ */
+static const struct i2c_algorithm fimc_is_i2c_algorithm;
+
+static int fimc_is_i2c_probe(struct platform_device *pdev)
+{
+   struct device_node *node = pdev-dev.of_node;
+   struct i2c_adapter *i2c_adap;
+   int ret;
+
+   i2c_adap = devm_kzalloc(pdev-dev, sizeof(*i2c_adap), GFP_KERNEL);
+
+   i2c_adap-dev.of_node = node;
+   i2c_adap-dev.parent = pdev-dev;
+   strlcpy(i2c_adap-name, exynos4x12-is-i2c, sizeof(i2c_adap-name));
+   i2c_adap-owner = THIS_MODULE;
+   i2c_adap-algo = fimc_is_i2c_algorithm;
+   i2c_adap-class = I2C_CLASS_SPD;
+
+   ret = i2c_add_adapter(i2c_adap);
+   if (ret  0) {
+   dev_err(pdev-dev, failed to add I2C bus %s\n,
+   node-full_name);
+   return ret;
+   }
+   of_i2c_register_devices(i2c_adap);
+
+   return 0;
+}
+
+static int fimc_is_i2c_remove(struct platform_device *pdev)
+{
+   return 0;
+}
+
+static const struct of_device_id fimc_is_i2c_of_match[] = {
+   { .compatible = FIMC_IS_I2C_COMPATIBLE },
+   { },
+};
+MODULE_DEVICE_TABLE(of, fimc_is_i2c_of_match);
+
+static struct platform_driver fimc_is_i2c_driver = {
+   .probe  = fimc_is_i2c_probe,
+   .remove = fimc_is_i2c_remove,
+   .driver = {
+   .of_match_table = fimc_is_i2c_of_match,
+   .name   = fimc-is-i2c,
+   .owner  = THIS_MODULE,
+   }
+};
+
+int fimc_is_register_i2c_driver(void)
+{
+   return platform_driver_register(fimc_is_i2c_driver);
+}
+
+void fimc_is_unregister_i2c_driver(void)
+{
+   platform_driver_unregister(fimc_is_i2c_driver);
+}
+
diff --git a/drivers/media/platform/exynos4-is/fimc-is-i2c.h 
b/drivers/media/platform/exynos4-is/fimc-is-i2c.h
new file mode 100644
index 000..0d38d6b
--- /dev/null
+++ b/drivers/media/platform/exynos4-is/fimc-is-i2c.h
@@ -0,0 +1,15 @@
+/*
+ * Samsung EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Sylwester Nawrocki s.nawro...@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.
+ */
+
+#define FIMC_IS_I2C_COMPATIBLE samsung,exynos4212-i2c-isp
+
+int fimc_is_register_i2c_driver(void);
+void fimc_is_unregister_i2c_driver(void);
-- 
1.7.9.5

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


[PATCH v2 3/7] exynos4-is: Add FIMC-IS parameter region definitions

2013-03-26 Thread Sylwester Nawrocki
This patch adds ISP processing parameters interface files.

Signed-off-by: Younghwan Joo yhwan@samsung.com
Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/exynos4-is/fimc-is-param.c |  971 
 drivers/media/platform/exynos4-is/fimc-is-param.h | 1022 +
 2 files changed, 1993 insertions(+)
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-param.c
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-param.h

diff --git a/drivers/media/platform/exynos4-is/fimc-is-param.c 
b/drivers/media/platform/exynos4-is/fimc-is-param.c
new file mode 100644
index 000..5674c3b
--- /dev/null
+++ b/drivers/media/platform/exynos4-is/fimc-is-param.c
@@ -0,0 +1,971 @@
+/*
+ * Samsung EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ *
+ * Authors: Younghwan Joo yhwan@samsung.com
+ *  Sylwester Nawrocki s.nawro...@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.
+ */
+#define pr_fmt(fmt) %s:%d  fmt, __func__, __LINE__
+
+#include linux/bug.h
+#include linux/device.h
+#include linux/delay.h
+#include linux/errno.h
+#include linux/firmware.h
+#include linux/gpio.h
+#include plat/gpio-cfg.h
+#include linux/interrupt.h
+#include linux/kernel.h
+#include linux/list.h
+#include linux/module.h
+#include linux/types.h
+#include linux/platform_device.h
+#include linux/pm_runtime.h
+#include linux/slab.h
+#include linux/videodev2.h
+
+#include media/v4l2-device.h
+#include media/v4l2-ioctl.h
+#include media/v4l2-mem2mem.h
+#include media/videobuf2-core.h
+#include media/videobuf2-dma-contig.h
+
+#include fimc-is.h
+#include fimc-is-command.h
+#include fimc-is-errno.h
+#include fimc-is-param.h
+#include fimc-is-regs.h
+#include fimc-is-sensor.h
+
+static void __hw_param_copy(void *dst, void *src)
+{
+   memcpy(dst, src, FIMC_IS_PARAM_MAX_SIZE);
+}
+
+void __fimc_is_hw_update_param_global_shotmode(struct fimc_is *is)
+{
+   struct param_global_shotmode *dst, *src;
+
+   dst = is-is_p_region-parameter.global.shotmode;
+   src = is-cfg_param[is-scenario_id].global.shotmode;
+   __hw_param_copy(dst, src);
+}
+
+void __fimc_is_hw_update_param_sensor_framerate(struct fimc_is *is)
+{
+   struct param_sensor_framerate *dst, *src;
+
+   dst = is-is_p_region-parameter.sensor.frame_rate;
+   src = is-cfg_param[is-scenario_id].sensor.frame_rate;
+   __hw_param_copy(dst, src);
+}
+
+int __fimc_is_hw_update_param(struct fimc_is *is, u32 offset)
+{
+   struct is_param_region *par = is-is_p_region-parameter;
+   struct is_config_param *cfg = is-cfg_param[is-scenario_id];
+
+   switch (offset) {
+   case PARAM_ISP_CONTROL:
+   __hw_param_copy(par-isp.control, cfg-isp.control);
+   break;
+
+   case PARAM_ISP_OTF_INPUT:
+   __hw_param_copy(par-isp.otf_input, cfg-isp.otf_input);
+   break;
+
+   case PARAM_ISP_DMA1_INPUT:
+   __hw_param_copy(par-isp.dma1_input, cfg-isp.dma1_input);
+   break;
+
+   case PARAM_ISP_DMA2_INPUT:
+   __hw_param_copy(par-isp.dma2_input, cfg-isp.dma2_input);
+   break;
+
+   case PARAM_ISP_AA:
+   __hw_param_copy(par-isp.aa, cfg-isp.aa);
+   break;
+
+   case PARAM_ISP_FLASH:
+   __hw_param_copy(par-isp.flash, cfg-isp.flash);
+   break;
+
+   case PARAM_ISP_AWB:
+   __hw_param_copy(par-isp.awb, cfg-isp.awb);
+   break;
+
+   case PARAM_ISP_IMAGE_EFFECT:
+   __hw_param_copy(par-isp.effect, cfg-isp.effect);
+   break;
+
+   case PARAM_ISP_ISO:
+   __hw_param_copy(par-isp.iso, cfg-isp.iso);
+   break;
+
+   case PARAM_ISP_ADJUST:
+   __hw_param_copy(par-isp.adjust, cfg-isp.adjust);
+   break;
+
+   case PARAM_ISP_METERING:
+   __hw_param_copy(par-isp.metering, cfg-isp.metering);
+   break;
+
+   case PARAM_ISP_AFC:
+   __hw_param_copy(par-isp.afc, cfg-isp.afc);
+   break;
+
+   case PARAM_ISP_OTF_OUTPUT:
+   __hw_param_copy(par-isp.otf_output, cfg-isp.otf_output);
+   break;
+
+   case PARAM_ISP_DMA1_OUTPUT:
+   __hw_param_copy(par-isp.dma1_output, cfg-isp.dma1_output);
+   break;
+
+   case PARAM_ISP_DMA2_OUTPUT:
+   __hw_param_copy(par-isp.dma2_output, cfg-isp.dma2_output);
+   break;
+
+   case PARAM_DRC_CONTROL:
+   __hw_param_copy(par-drc.control, cfg-drc.control);
+   break;
+
+   case PARAM_DRC_OTF_INPUT:
+   __hw_param_copy(par-drc.otf_input, 

[PATCH v2 4/7] exynos4-is: Add common FIMC-IS image sensor driver

2013-03-26 Thread Sylwester Nawrocki
This patch adds a common image sensor driver and Makefile/Kconfig
to enable cpmpilation of the whole IS drives.

The sensor subdev driver currently only handles an image sensor's
power supplies and reset signal. There is no an I2C communication
as it is handled by the ISP's firmware.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/exynos4-is/Kconfig  |   13 +
 drivers/media/platform/exynos4-is/Makefile |3 +
 drivers/media/platform/exynos4-is/fimc-is-sensor.c |  307 
 drivers/media/platform/exynos4-is/fimc-is-sensor.h |   80 +
 4 files changed, 403 insertions(+)
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-sensor.c
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-sensor.h

diff --git a/drivers/media/platform/exynos4-is/Kconfig 
b/drivers/media/platform/exynos4-is/Kconfig
index ed96dbc..c72d6b5 100644
--- a/drivers/media/platform/exynos4-is/Kconfig
+++ b/drivers/media/platform/exynos4-is/Kconfig
@@ -47,4 +47,17 @@ config VIDEO_EXYNOS_FIMC_LITE
  module will be called exynos-fimc-lite.
 endif
 
+if (SOC_EXYNOS4212 || SOC_EXYNOS4412)  OF  !ARCH_MULTIPLATFORM
+
+config VIDEO_EXYNOS4_FIMC_IS
+   tristate EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver
+   select VIDEOBUF2_DMA_CONTIG
+   help
+ This is a V4L2 driver for Samsung EXYNOS4x12 SoC series
+ FIMC-IS (Imaging Subsystem).
+
+ To compile this driver as a module, choose M here: the
+ module will be called exynos4-fimc-is.
+endif
+
 endif # VIDEO_SAMSUNG_S5P_FIMC
diff --git a/drivers/media/platform/exynos4-is/Makefile 
b/drivers/media/platform/exynos4-is/Makefile
index 8c67441..f25f463 100644
--- a/drivers/media/platform/exynos4-is/Makefile
+++ b/drivers/media/platform/exynos4-is/Makefile
@@ -1,7 +1,10 @@
 s5p-fimc-objs := fimc-core.o fimc-reg.o fimc-m2m.o fimc-capture.o media-dev.o
 exynos-fimc-lite-objs += fimc-lite-reg.o fimc-lite.o
+exynos-fimc-is-objs := fimc-is.o fimc-isp.o fimc-is-sensor.o fimc-is-regs.o
+exynos-fimc-is-objs += fimc-is-param.o fimc-is-errno.o fimc-is-i2c.o
 s5p-csis-objs := mipi-csis.o
 
 obj-$(CONFIG_VIDEO_S5P_MIPI_CSIS)  += s5p-csis.o
 obj-$(CONFIG_VIDEO_EXYNOS_FIMC_LITE)   += exynos-fimc-lite.o
+obj-$(CONFIG_VIDEO_EXYNOS4_FIMC_IS)+= exynos-fimc-is.o
 obj-$(CONFIG_VIDEO_S5P_FIMC)   += s5p-fimc.o
diff --git a/drivers/media/platform/exynos4-is/fimc-is-sensor.c 
b/drivers/media/platform/exynos4-is/fimc-is-sensor.c
new file mode 100644
index 000..9084437
--- /dev/null
+++ b/drivers/media/platform/exynos4-is/fimc-is-sensor.c
@@ -0,0 +1,307 @@
+/*
+ * Samsung EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Sylwester Nawrocki s.nawro...@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.
+ */
+#include linux/delay.h
+#include linux/device.h
+#include linux/errno.h
+#include linux/gpio.h
+#include linux/interrupt.h
+#include linux/io.h
+#include linux/irq.h
+#include linux/kernel.h
+#include linux/memory.h
+#include linux/module.h
+#include linux/of_gpio.h
+#include linux/regulator/consumer.h
+#include linux/slab.h
+#include media/v4l2-subdev.h
+
+#include fimc-is.h
+#include fimc-is-sensor.h
+
+#define DRIVER_NAME FIMC-IS-SENSOR
+
+static const char * const sensor_supply_names[] = {
+   svdda,
+   svddio,
+};
+
+static const struct v4l2_mbus_framefmt fimc_is_sensor_formats[] = {
+   {
+   .code = V4L2_MBUS_FMT_SGRBG10_1X10,
+   .colorspace = V4L2_COLORSPACE_SRGB,
+   .field = V4L2_FIELD_NONE,
+   }
+};
+
+static struct fimc_is_sensor *sd_to_fimc_is_sensor(struct v4l2_subdev *sd)
+{
+   return container_of(sd, struct fimc_is_sensor, subdev);
+}
+
+static const struct v4l2_mbus_framefmt *find_sensor_format(
+   struct v4l2_mbus_framefmt *mf)
+{
+   int i;
+
+   for (i = 0; i  ARRAY_SIZE(fimc_is_sensor_formats); i++)
+   if (mf-code == fimc_is_sensor_formats[i].code)
+   return fimc_is_sensor_formats[i];
+
+   return fimc_is_sensor_formats[0];
+}
+
+static int fimc_is_sensor_enum_mbus_code(struct v4l2_subdev *sd,
+ struct v4l2_subdev_fh *fh,
+ struct v4l2_subdev_mbus_code_enum *code)
+{
+   if (code-index = ARRAY_SIZE(fimc_is_sensor_formats))
+   return -EINVAL;
+
+   code-code = fimc_is_sensor_formats[code-index].code;
+   return 0;
+}
+
+static void fimc_is_sensor_try_format(struct fimc_is_sensor *sensor,
+ struct v4l2_mbus_framefmt *mf)
+{
+   const struct sensor_drv_data *dd = sensor-drvdata;
+   const struct v4l2_mbus_framefmt *fmt;
+
+   fmt = 

[PATCH v2 5/7] exynos4-is: Add Exynos4x12 FIMC-IS device tree bindings documentation

2013-03-26 Thread Sylwester Nawrocki
Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 .../devicetree/bindings/media/exynos4-fimc-is.txt  |   45 
 1 file changed, 45 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/exynos4-fimc-is.txt

diff --git a/Documentation/devicetree/bindings/media/exynos4-fimc-is.txt 
b/Documentation/devicetree/bindings/media/exynos4-fimc-is.txt
new file mode 100644
index 000..476eac8
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/exynos4-fimc-is.txt
@@ -0,0 +1,45 @@
+Exynos4x12 SoC series Imaging Subsystem (FIMC-IS)
+
+The FIMC-IS is a subsystem for processing image signal from an image sensor.
+The Exynos4x12 SoC series FIMC-IS V1.5 comprises of a dedicated ARM Cortex-A5
+processor, ISP, DRC and FD IP blocks and peripheral devices such as UART, I2C
+and SPI bus controllers, PWM and ADC.
+
+fimc-is node
+
+
+Required properties:
+
+- compatible   : should be samsung,exynos4212-fimc-is for Exynos4212 and
+ Exynos4412 SoCs;
+- reg  : physical base address and size of the device memory mapped
+ registers;
+- interrupts   : should contain FIMC-IS interrupts;
+- clocks   : list of clock specifiers, corresponding to entries in
+ clock-names property;
+- clock-names  : must contain ppmuispx, ppmuispx, flite0, flite1
+ entries, matching entries in the clocks property.
+
+pmu subnode
+---
+
+Required properties:
+ - reg : should contain PMU physical base address and size of the memory
+ mapped registers, size should be 0x3000.
+
+
+The following are the FIMC-IS peripheral device nodes and can be specified
+either standalone or as the fimc-is node child nodes.
+
+i2c-isp (ISP I2C bus controller) nodes
+--
+
+Required properties:
+
+- compatible   : should be samsung,exynos4212-i2c-isp for Exynos4212 and
+ Exynos4412 SoCs;
+- reg  : physical base address and size of the device memory mapped
+ registers;
+
+For the above nodes it is required to specify a pinctrl state named default,
+according to the pinctrl bindings defined in ../pinctrl/pinctrl-bindings.txt.
-- 
1.7.9.5

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


[PATCH v2 7/7] s5p-fimc: Create media links for the FIMC-IS entities

2013-03-26 Thread Sylwester Nawrocki
Create disabled links from the FIMC-LITE subdevs to the FIMC-IS-ISP
subdev and from FIMC-IS-ISP to all FIMC subdevs.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/exynos4-is/media-dev.c |   83 +++--
 1 file changed, 64 insertions(+), 19 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/media-dev.c 
b/drivers/media/platform/exynos4-is/media-dev.c
index 5e1c28e..e5e0c37 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -836,12 +836,19 @@ static int __fimc_md_create_fimc_sink_links(struct 
fimc_md *fmd,
struct v4l2_subdev *sensor,
int pad, int link_mask)
 {
-   struct fimc_sensor_info *s_info = NULL;
+   struct fimc_sensor_info *si = NULL;
struct media_entity *sink;
unsigned int flags = 0;
-   int ret, i;
+   int i, ret = 0;
 
-   for (i = 0; i  FIMC_MAX_DEVS; i++) {
+   if (sensor) {
+   si = v4l2_get_subdev_hostdata(sensor);
+   /* Skip direct FIMC links in the logical FIMC-IS sensor path */
+   if (si  si-pdata.fimc_bus_type == 
FIMC_BUS_TYPE_ISP_WRITEBACK)
+   ret = 1;
+   }
+
+   for (i = 0; !ret  i  FIMC_MAX_DEVS; i++) {
if (!fmd-fimc[i])
continue;
/*
@@ -870,11 +877,11 @@ static int __fimc_md_create_fimc_sink_links(struct 
fimc_md *fmd,
 
if (flags == 0 || sensor == NULL)
continue;
-   s_info = v4l2_get_subdev_hostdata(sensor);
-   if (!WARN_ON(s_info == NULL)) {
+
+   if (!WARN_ON(si == NULL)) {
unsigned long irq_flags;
spin_lock_irqsave(fmd-slock, irq_flags);
-   s_info-host = fmd-fimc[i];
+   si-host = fmd-fimc[i];
spin_unlock_irqrestore(fmd-slock, irq_flags);
}
}
@@ -883,25 +890,20 @@ static int __fimc_md_create_fimc_sink_links(struct 
fimc_md *fmd,
if (!fmd-fimc_lite[i])
continue;
 
-   if (link_mask  (1  (i + FIMC_MAX_DEVS)))
-   flags = MEDIA_LNK_FL_ENABLED;
-   else
-   flags = 0;
-
sink = fmd-fimc_lite[i]-subdev.entity;
ret = media_entity_create_link(source, pad, sink,
-  FLITE_SD_PAD_SINK, flags);
+  FLITE_SD_PAD_SINK, 0);
if (ret)
return ret;
 
/* Notify FIMC-LITE subdev entity */
ret = media_entity_call(sink, link_setup, sink-pads[0],
-   source-pads[pad], flags);
+   source-pads[pad], 0);
if (ret)
break;
 
-   v4l2_info(fmd-v4l2_dev, created link [%s] %c [%s]\n,
- source-name, flags ? '=' : '-', sink-name);
+   v4l2_info(fmd-v4l2_dev, created link [%s] - [%s]\n,
+ source-name, sink-name);
}
return 0;
 }
@@ -910,26 +912,59 @@ static int __fimc_md_create_fimc_sink_links(struct 
fimc_md *fmd,
 static int __fimc_md_create_flite_source_links(struct fimc_md *fmd)
 {
struct media_entity *source, *sink;
-   unsigned int flags = MEDIA_LNK_FL_ENABLED;
int i, ret = 0;
 
for (i = 0; i  FIMC_LITE_MAX_DEVS; i++) {
struct fimc_lite *fimc = fmd-fimc_lite[i];
+
if (fimc == NULL)
continue;
+
source = fimc-subdev.entity;
sink = fimc-vfd.entity;
/* FIMC-LITE's subdev and video node */
ret = media_entity_create_link(source, FLITE_SD_PAD_SOURCE_DMA,
-  sink, 0, flags);
+  sink, 0, 0);
+   if (ret)
+   break;
+   /* Link from FIMC-LITE to IS-ISP subdev */
+   sink = fmd-fimc_is-isp.subdev.entity;
+   ret = media_entity_create_link(source, FLITE_SD_PAD_SOURCE_ISP,
+  sink, 0, 0);
if (ret)
break;
-   /* TODO: create links to other entities */
}
 
return ret;
 }
 
+/* Create FIMC-IS links */
+static int __fimc_md_create_fimc_is_links(struct fimc_md *fmd)
+{
+   struct media_entity *source, *sink;
+   int i, ret;
+
+   source = fmd-fimc_is-isp.subdev.entity;
+
+   for (i = 0; i  FIMC_MAX_DEVS; i++) {
+   if (fmd-fimc[i] == NULL)
+   

[PATCH v2 6/7] s5p-fimc: Add fimc-is subdevs registration

2013-03-26 Thread Sylwester Nawrocki
This patch allows to register FIMC-IS device represented by FIMC-IS-ISP
subdev to the top level media device driver. The use_isp platform data
structure field allows to select whether the fimc-is ISP subdev should
be tried to be registered or not.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Andrzej Hajda a.ha...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/exynos4-is/media-dev.c |   37 +++--
 drivers/media/platform/exynos4-is/media-dev.h |   13 +
 2 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/media-dev.c 
b/drivers/media/platform/exynos4-is/media-dev.c
index 6048290..5e1c28e 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -32,6 +32,7 @@
 
 #include media-dev.h
 #include fimc-core.h
+#include fimc-is.h
 #include fimc-lite.h
 #include mipi-csis.h
 
@@ -85,9 +86,11 @@ static void fimc_pipeline_prepare(struct fimc_pipeline *p,
case GRP_ID_FIMC:
/* No need to control FIMC subdev through subdev ops */
break;
+   case GRP_ID_FIMC_IS:
+   p-subdevs[IDX_IS_ISP] = sd;
+   break;
default:
-   pr_warn(%s: Unknown subdev grp_id: %#x\n,
-   __func__, sd-grp_id);
+   break;
}
me = sd-entity;
if (me-num_pads == 1)
@@ -322,6 +325,7 @@ static void fimc_md_unregister_sensor(struct v4l2_subdev 
*sd)
 
if (!client)
return;
+
v4l2_device_unregister_subdev(sd);
 
if (!client-dev.of_node) {
@@ -372,7 +376,11 @@ static int fimc_md_of_add_sensor(struct fimc_md *fmd,
goto mod_put;
 
v4l2_set_subdev_hostdata(sd, si);
-   sd-grp_id = GRP_ID_SENSOR;
+   if (si-pdata.fimc_bus_type == FIMC_BUS_TYPE_ISP_WRITEBACK)
+   sd-grp_id = GRP_ID_FIMC_IS_SENSOR;
+   else
+   sd-grp_id = GRP_ID_SENSOR;
+
si-subdev = sd;
v4l2_info(fmd-v4l2_dev, Registered sensor subdevice: %s (%d)\n,
  sd-name, fmd-num_sensors);
@@ -650,6 +658,22 @@ static int register_csis_entity(struct fimc_md *fmd,
return ret;
 }
 
+static int register_fimc_is_entity(struct fimc_md *fmd, struct fimc_is *is)
+{
+   struct v4l2_subdev *sd = is-isp.subdev;
+   int ret;
+
+   ret = v4l2_device_register_subdev(fmd-v4l2_dev, sd);
+   if (ret) {
+   v4l2_err(fmd-v4l2_dev,
+Failed to register FIMC-ISP (%d)\n, ret);
+   return ret;
+   }
+
+   fmd-fimc_is = is;
+   return 0;
+}
+
 static int fimc_md_register_platform_entity(struct fimc_md *fmd,
struct platform_device *pdev,
int plat_entity)
@@ -677,6 +701,9 @@ static int fimc_md_register_platform_entity(struct fimc_md 
*fmd,
case IDX_CSIS:
ret = register_csis_entity(fmd, pdev, drvdata);
break;
+   case IDX_IS_ISP:
+   ret = register_fimc_is_entity(fmd, drvdata);
+   break;
default:
ret = -ENODEV;
}
@@ -740,6 +767,8 @@ static int fimc_md_register_of_platform_entities(struct 
fimc_md *fmd,
/* If driver of any entity isn't ready try all again later. */
if (!strcmp(node-name, CSIS_OF_NODE_NAME))
plat_entity = IDX_CSIS;
+   else if (!strcmp(node-name, FIMC_IS_OF_NODE_NAME))
+   plat_entity = IDX_IS_ISP;
else if (!strcmp(node-name, FIMC_LITE_OF_NODE_NAME))
plat_entity = IDX_FLITE;
else if (!strcmp(node-name, FIMC_OF_NODE_NAME) 
@@ -1306,6 +1335,8 @@ static int fimc_md_probe(struct platform_device *pdev)
v4l2_dev-notify = fimc_sensor_notify;
strlcpy(v4l2_dev-name, s5p-fimc-md, sizeof(v4l2_dev-name));
 
+   fmd-use_isp = fimc_md_is_isp_available(dev-of_node);
+
ret = v4l2_device_register(dev, fmd-v4l2_dev);
if (ret  0) {
v4l2_err(v4l2_dev, Failed to register v4l2_device: %d\n, ret);
diff --git a/drivers/media/platform/exynos4-is/media-dev.h 
b/drivers/media/platform/exynos4-is/media-dev.h
index 1d5cea5..0b14cd5 100644
--- a/drivers/media/platform/exynos4-is/media-dev.h
+++ b/drivers/media/platform/exynos4-is/media-dev.h
@@ -12,6 +12,7 @@
 #include linux/clk.h
 #include linux/platform_device.h
 #include linux/mutex.h
+#include linux/of.h
 #include linux/pinctrl/consumer.h
 #include media/media-device.h
 #include media/media-entity.h
@@ -80,6 +81,7 @@ struct fimc_sensor_info {
  * @num_sensors: actual number of registered 

[PATCH v2 0/4] exynos4-is updates

2013-03-26 Thread Sylwester Nawrocki
This patch series includes YUV order handling fix for the FIMC
and FIMC-LITE, a fix for media entity ref_count issue, minor
refactoring and removal of some static data that will no longer
be needed since starting from 3.10 Exynos platform is going to
be DT only.

All dependencies of this series are available at:
git://linuxtv.org/snawrocki/samsung.git exynos4-fimc-is-v2

Sylwester Nawrocki (5):
  exynos4-is: Remove static driver data for Exynos4210 FIMC variants
  exynos4-is: Use common driver data for all FIMC-LITE IP instances
  exynos4-is: Allow colorspace conversion at fimc-lite
  exynos4-is: Correct input DMA YUV order configuration
  exynos4-is: Ensure proper media pipeline state on device close

 drivers/media/platform/exynos4-is/fimc-capture.c  |   18 ++-
 drivers/media/platform/exynos4-is/fimc-core.c |   51 ++---
 drivers/media/platform/exynos4-is/fimc-core.h |1 +
 drivers/media/platform/exynos4-is/fimc-lite-reg.c |4 +-
 drivers/media/platform/exynos4-is/fimc-lite-reg.h |8 +-
 drivers/media/platform/exynos4-is/fimc-lite.c |  127 +
 drivers/media/platform/exynos4-is/fimc-lite.h |   15 +--
 drivers/media/platform/exynos4-is/fimc-reg.c  |3 +-
 drivers/media/platform/exynos4-is/fimc-reg.h  |   16 +--
 include/media/s5p_fimc.h  |2 +
 10 files changed, 124 insertions(+), 121 deletions(-)

--
1.7.9.5

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


[PATCH v2 1/5] exynos4-is: Remove static driver data for Exynos4210 FIMC variants

2013-03-26 Thread Sylwester Nawrocki
All Exynos4210 based boards files using FIMC are going to be removed
in 3.10 and corresponding device trees are to be used instead.
The FIMC variant data will be parsed directly form the device tree
for those SoCs as well. Hence now unused static data is removed.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/exynos4-is/fimc-core.c |   35 -
 1 file changed, 35 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-core.c 
b/drivers/media/platform/exynos4-is/fimc-core.c
index 1248cdd..2e153bb 100644
--- a/drivers/media/platform/exynos4-is/fimc-core.c
+++ b/drivers/media/platform/exynos4-is/fimc-core.c
@@ -1141,14 +1141,6 @@ static const struct fimc_pix_limit s5p_pix_limit[4] = {
.out_rot_en_w   = 1280,
.out_rot_dis_w  = 1920,
},
-   [3] = {
-   .scaler_en_w= 1920,
-   .scaler_dis_w   = 8192,
-   .in_rot_en_h= 1366,
-   .in_rot_dis_w   = 8192,
-   .out_rot_en_w   = 1366,
-   .out_rot_dis_w  = 1920,
-   },
 };
 
 static const struct fimc_variant fimc0_variant_s5p = {
@@ -1203,27 +1195,6 @@ static const struct fimc_variant fimc2_variant_s5pv210 = 
{
.pix_limit   = s5p_pix_limit[2],
 };
 
-static const struct fimc_variant fimc0_variant_exynos4210 = {
-   .has_inp_rot = 1,
-   .has_out_rot = 1,
-   .has_cam_if  = 1,
-   .has_mainscaler_ext = 1,
-   .min_inp_pixsize = 16,
-   .min_out_pixsize = 16,
-   .hor_offs_align  = 2,
-   .min_vsize_align = 1,
-   .pix_limit   = s5p_pix_limit[1],
-};
-
-static const struct fimc_variant fimc3_variant_exynos4210 = {
-   .has_mainscaler_ext = 1,
-   .min_inp_pixsize = 16,
-   .min_out_pixsize = 16,
-   .hor_offs_align  = 2,
-   .min_vsize_align = 1,
-   .pix_limit   = s5p_pix_limit[3],
-};
-
 /* S5PC100 */
 static const struct fimc_drvdata fimc_drvdata_s5p = {
.variant = {
@@ -1251,12 +1222,6 @@ static const struct fimc_drvdata fimc_drvdata_s5pv210 = {
 
 /* EXYNOS4210, S5PV310, S5PC210 */
 static const struct fimc_drvdata fimc_drvdata_exynos4210 = {
-   .variant = {
-   [0] = fimc0_variant_exynos4210,
-   [1] = fimc0_variant_exynos4210,
-   [2] = fimc0_variant_exynos4210,
-   [3] = fimc3_variant_exynos4210,
-   },
.num_entities   = 4,
.lclk_frequency = 16600UL,
.dma_pix_hoff   = 1,
-- 
1.7.9.5

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


[PATCH v2 1/4] exynos4-is: Use common driver data for all FIMC-LITE IP instances

2013-03-26 Thread Sylwester Nawrocki
There is no need to use separate variant data structure for each
FIMC-LITE IP instance. According to my knowledge there are no
differences across them on Exynos4 as well as Exynos5 SoCs. Drop
flite_variant data structure and use struct flite_drvdata instead.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/exynos4-is/fimc-lite.c |   35 ++---
 drivers/media/platform/exynos4-is/fimc-lite.h |   10 +++
 2 files changed, 17 insertions(+), 28 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c 
b/drivers/media/platform/exynos4-is/fimc-lite.c
index 70c0cc2..ba35328 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -528,7 +528,7 @@ static const struct fimc_fmt *fimc_lite_try_format(struct 
fimc_lite *fimc,
u32 *width, u32 *height,
u32 *code, u32 *fourcc, int pad)
 {
-   struct flite_variant *variant = fimc-variant;
+   struct flite_drvdata *dd = fimc-dd;
const struct fimc_fmt *fmt;
 
fmt = fimc_lite_find_format(fourcc, code, 0);
@@ -541,12 +541,12 @@ static const struct fimc_fmt *fimc_lite_try_format(struct 
fimc_lite *fimc,
*fourcc = fmt-fourcc;
 
if (pad == FLITE_SD_PAD_SINK) {
-   v4l_bound_align_image(width, 8, variant-max_width,
- ffs(variant-out_width_align) - 1,
- height, 0, variant-max_height, 0, 0);
+   v4l_bound_align_image(width, 8, dd-max_width,
+ ffs(dd-out_width_align) - 1,
+ height, 0, dd-max_height, 0, 0);
} else {
v4l_bound_align_image(width, 8, fimc-inp_frame.rect.width,
- ffs(variant-out_width_align) - 1,
+ ffs(dd-out_width_align) - 1,
  height, 0, fimc-inp_frame.rect.height,
  0, 0);
}
@@ -566,7 +566,7 @@ static void fimc_lite_try_crop(struct fimc_lite *fimc, 
struct v4l2_rect *r)
 
/* Adjust left/top if cropping rectangle got out of bounds */
r-left = clamp_t(u32, r-left, 0, frame-f_width - r-width);
-   r-left = round_down(r-left, fimc-variant-win_hor_offs_align);
+   r-left = round_down(r-left, fimc-dd-win_hor_offs_align);
r-top  = clamp_t(u32, r-top, 0, frame-f_height - r-height);
 
v4l2_dbg(1, debug, fimc-subdev, (%d,%d)/%dx%d, sink fmt: %dx%d\n,
@@ -586,7 +586,7 @@ static void fimc_lite_try_compose(struct fimc_lite *fimc, 
struct v4l2_rect *r)
 
/* Adjust left/top if the composing rectangle got out of bounds */
r-left = clamp_t(u32, r-left, 0, frame-f_width - r-width);
-   r-left = round_down(r-left, fimc-variant-out_hor_offs_align);
+   r-left = round_down(r-left, fimc-dd-out_hor_offs_align);
r-top  = clamp_t(u32, r-top, 0, fimc-out_frame.f_height - r-height);
 
v4l2_dbg(1, debug, fimc-subdev, (%d,%d)/%dx%d, source fmt: %dx%d\n,
@@ -647,8 +647,8 @@ static int fimc_lite_try_fmt(struct fimc_lite *fimc,
 struct v4l2_pix_format_mplane *pixm,
 const struct fimc_fmt **ffmt)
 {
-   struct flite_variant *variant = fimc-variant;
u32 bpl = pixm-plane_fmt[0].bytesperline;
+   struct flite_drvdata *dd = fimc-dd;
const struct fimc_fmt *fmt;
 
fmt = fimc_lite_find_format(pixm-pixelformat, NULL, 0);
@@ -656,9 +656,9 @@ static int fimc_lite_try_fmt(struct fimc_lite *fimc,
return -EINVAL;
if (ffmt)
*ffmt = fmt;
-   v4l_bound_align_image(pixm-width, 8, variant-max_width,
- ffs(variant-out_width_align) - 1,
- pixm-height, 0, variant-max_height, 0, 0);
+   v4l_bound_align_image(pixm-width, 8, dd-max_width,
+ ffs(dd-out_width_align) - 1,
+ pixm-height, 0, dd-max_height, 0, 0);
 
if ((bpl == 0 || ((bpl * 8) / fmt-depth[0])  pixm-width))
pixm-plane_fmt[0].bytesperline = (pixm-width *
@@ -1429,7 +1429,7 @@ static int fimc_lite_probe(struct platform_device *pdev)
if (!drv_data || fimc-index  0 || fimc-index = FIMC_LITE_MAX_DEVS)
return -EINVAL;
 
-   fimc-variant = drv_data-variant[fimc-index];
+   fimc-dd = drv_data;
fimc-pdev = pdev;
 
init_waitqueue_head(fimc-irq_queue);
@@ -1577,7 +1577,8 @@ static const struct dev_pm_ops fimc_lite_pm_ops = {
   NULL)
 };
 
-static struct flite_variant fimc_lite0_variant_exynos4 = {
+/* EXYNOS4212, EXYNOS4412 */
+static struct flite_drvdata fimc_lite_drvdata_exynos4 = {
.max_width   

[PATCH v2 2/4] exynos4-is: Allow colorspace conversion at fimc-lite

2013-03-26 Thread Sylwester Nawrocki
The FIMC-LITE output DMA allows to configure different YUV order
than the order at the camera input interface. Thus there is some
limited colorspace conversion possible. This patch makes the
color format variable be per FIMC-LITE input/output, rather than
a global per device. This also fixes incorrect behavior where
color format at the FIMC-LITE.N subdev's source pad is modified
by VIDIOC_S_FMT ioctl on the related video node.

YUV order definitions are corrected so that we use notation:

 | byte3 | byte2 | byte1 | byte0
  ---+---+---+---+--
  YCBYCR | CR| Y | CB| Y
  YCRYCB | CB| Y | CR| Y
  CBYCRY | Y | CR| Y | CB
  CRYCBY | Y | CB| Y | CR

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/exynos4-is/fimc-lite-reg.c |4 +-
 drivers/media/platform/exynos4-is/fimc-lite-reg.h |8 +--
 drivers/media/platform/exynos4-is/fimc-lite.c |   76 ++---
 drivers/media/platform/exynos4-is/fimc-lite.h |4 +-
 include/media/s5p_fimc.h  |2 +
 5 files changed, 61 insertions(+), 33 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-lite-reg.c 
b/drivers/media/platform/exynos4-is/fimc-lite-reg.c
index ac9663c..8cc0d39 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite-reg.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite-reg.c
@@ -127,7 +127,7 @@ static const u32 src_pixfmt_map[8][3] = {
 /* Set camera input pixel format and resolution */
 void flite_hw_set_source_format(struct fimc_lite *dev, struct flite_frame *f)
 {
-   enum v4l2_mbus_pixelcode pixelcode = dev-fmt-mbus_code;
+   enum v4l2_mbus_pixelcode pixelcode = f-fmt-mbus_code;
int i = ARRAY_SIZE(src_pixfmt_map);
u32 cfg;
 
@@ -227,7 +227,7 @@ static void flite_hw_set_out_order(struct fimc_lite *dev, 
struct flite_frame *f)
int i = ARRAY_SIZE(pixcode);
 
while (--i = 0)
-   if (pixcode[i][0] == dev-fmt-mbus_code)
+   if (pixcode[i][0] == f-fmt-mbus_code)
break;
cfg = ~FLITE_REG_CIODMAFMT_YCBCR_ORDER_MASK;
writel(cfg | pixcode[i][1], dev-regs + FLITE_REG_CIODMAFMT);
diff --git a/drivers/media/platform/exynos4-is/fimc-lite-reg.h 
b/drivers/media/platform/exynos4-is/fimc-lite-reg.h
index 0e34584..3903839 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite-reg.h
+++ b/drivers/media/platform/exynos4-is/fimc-lite-reg.h
@@ -72,10 +72,10 @@
 #define FLITE_REG_CIODMAFMT0x18
 #define FLITE_REG_CIODMAFMT_RAW_CON(1  15)
 #define FLITE_REG_CIODMAFMT_PACK12 (1  14)
-#define FLITE_REG_CIODMAFMT_CRYCBY (0  4)
-#define FLITE_REG_CIODMAFMT_CBYCRY (1  4)
-#define FLITE_REG_CIODMAFMT_YCRYCB (2  4)
-#define FLITE_REG_CIODMAFMT_YCBYCR (3  4)
+#define FLITE_REG_CIODMAFMT_YCBYCR (0  4)
+#define FLITE_REG_CIODMAFMT_YCRYCB (1  4)
+#define FLITE_REG_CIODMAFMT_CBYCRY (2  4)
+#define FLITE_REG_CIODMAFMT_CRYCBY (3  4)
 #define FLITE_REG_CIODMAFMT_YCBCR_ORDER_MASK   (0x3  4)
 
 /* Camera Output Canvas */
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c 
b/drivers/media/platform/exynos4-is/fimc-lite.c
index ba35328..b11e358 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -46,6 +46,7 @@ static const struct fimc_fmt fimc_lite_formats[] = {
.color  = FIMC_FMT_YCBYCR422,
.memplanes  = 1,
.mbus_code  = V4L2_MBUS_FMT_YUYV8_2X8,
+   .flags  = FMT_FLAGS_YUV,
}, {
.name   = YUV 4:2:2 packed, CbYCrY,
.fourcc = V4L2_PIX_FMT_UYVY,
@@ -53,6 +54,7 @@ static const struct fimc_fmt fimc_lite_formats[] = {
.color  = FIMC_FMT_CBYCRY422,
.memplanes  = 1,
.mbus_code  = V4L2_MBUS_FMT_UYVY8_2X8,
+   .flags  = FMT_FLAGS_YUV,
}, {
.name   = YUV 4:2:2 packed, CrYCbY,
.fourcc = V4L2_PIX_FMT_VYUY,
@@ -60,6 +62,7 @@ static const struct fimc_fmt fimc_lite_formats[] = {
.color  = FIMC_FMT_CRYCBY422,
.memplanes  = 1,
.mbus_code  = V4L2_MBUS_FMT_VYUY8_2X8,
+   .flags  = FMT_FLAGS_YUV,
}, {
.name   = YUV 4:2:2 packed, YCrYCb,
.fourcc = V4L2_PIX_FMT_YVYU,
@@ -67,6 +70,7 @@ static const struct fimc_fmt fimc_lite_formats[] = {
.color  = FIMC_FMT_YCRYCB422,
.memplanes  = 1,
.mbus_code  = V4L2_MBUS_FMT_YVYU8_2X8,
+   .flags  = FMT_FLAGS_YUV,
}, {
.name

[PATCH v2 2/5] exynos4-is: Use common driver data for all FIMC-LITE IP instances

2013-03-26 Thread Sylwester Nawrocki
There is no need to use separate variant data structure for each
FIMC-LITE IP instance. According to my knowledge there are no
differences across them on Exynos4 as well as Exynos5 SoCs. Drop
flite_variant data structure and use struct flite_drvdata instead.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/exynos4-is/fimc-lite.c |   35 ++---
 drivers/media/platform/exynos4-is/fimc-lite.h |   10 +++
 2 files changed, 17 insertions(+), 28 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c 
b/drivers/media/platform/exynos4-is/fimc-lite.c
index 70c0cc2..ba35328 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -528,7 +528,7 @@ static const struct fimc_fmt *fimc_lite_try_format(struct 
fimc_lite *fimc,
u32 *width, u32 *height,
u32 *code, u32 *fourcc, int pad)
 {
-   struct flite_variant *variant = fimc-variant;
+   struct flite_drvdata *dd = fimc-dd;
const struct fimc_fmt *fmt;
 
fmt = fimc_lite_find_format(fourcc, code, 0);
@@ -541,12 +541,12 @@ static const struct fimc_fmt *fimc_lite_try_format(struct 
fimc_lite *fimc,
*fourcc = fmt-fourcc;
 
if (pad == FLITE_SD_PAD_SINK) {
-   v4l_bound_align_image(width, 8, variant-max_width,
- ffs(variant-out_width_align) - 1,
- height, 0, variant-max_height, 0, 0);
+   v4l_bound_align_image(width, 8, dd-max_width,
+ ffs(dd-out_width_align) - 1,
+ height, 0, dd-max_height, 0, 0);
} else {
v4l_bound_align_image(width, 8, fimc-inp_frame.rect.width,
- ffs(variant-out_width_align) - 1,
+ ffs(dd-out_width_align) - 1,
  height, 0, fimc-inp_frame.rect.height,
  0, 0);
}
@@ -566,7 +566,7 @@ static void fimc_lite_try_crop(struct fimc_lite *fimc, 
struct v4l2_rect *r)
 
/* Adjust left/top if cropping rectangle got out of bounds */
r-left = clamp_t(u32, r-left, 0, frame-f_width - r-width);
-   r-left = round_down(r-left, fimc-variant-win_hor_offs_align);
+   r-left = round_down(r-left, fimc-dd-win_hor_offs_align);
r-top  = clamp_t(u32, r-top, 0, frame-f_height - r-height);
 
v4l2_dbg(1, debug, fimc-subdev, (%d,%d)/%dx%d, sink fmt: %dx%d\n,
@@ -586,7 +586,7 @@ static void fimc_lite_try_compose(struct fimc_lite *fimc, 
struct v4l2_rect *r)
 
/* Adjust left/top if the composing rectangle got out of bounds */
r-left = clamp_t(u32, r-left, 0, frame-f_width - r-width);
-   r-left = round_down(r-left, fimc-variant-out_hor_offs_align);
+   r-left = round_down(r-left, fimc-dd-out_hor_offs_align);
r-top  = clamp_t(u32, r-top, 0, fimc-out_frame.f_height - r-height);
 
v4l2_dbg(1, debug, fimc-subdev, (%d,%d)/%dx%d, source fmt: %dx%d\n,
@@ -647,8 +647,8 @@ static int fimc_lite_try_fmt(struct fimc_lite *fimc,
 struct v4l2_pix_format_mplane *pixm,
 const struct fimc_fmt **ffmt)
 {
-   struct flite_variant *variant = fimc-variant;
u32 bpl = pixm-plane_fmt[0].bytesperline;
+   struct flite_drvdata *dd = fimc-dd;
const struct fimc_fmt *fmt;
 
fmt = fimc_lite_find_format(pixm-pixelformat, NULL, 0);
@@ -656,9 +656,9 @@ static int fimc_lite_try_fmt(struct fimc_lite *fimc,
return -EINVAL;
if (ffmt)
*ffmt = fmt;
-   v4l_bound_align_image(pixm-width, 8, variant-max_width,
- ffs(variant-out_width_align) - 1,
- pixm-height, 0, variant-max_height, 0, 0);
+   v4l_bound_align_image(pixm-width, 8, dd-max_width,
+ ffs(dd-out_width_align) - 1,
+ pixm-height, 0, dd-max_height, 0, 0);
 
if ((bpl == 0 || ((bpl * 8) / fmt-depth[0])  pixm-width))
pixm-plane_fmt[0].bytesperline = (pixm-width *
@@ -1429,7 +1429,7 @@ static int fimc_lite_probe(struct platform_device *pdev)
if (!drv_data || fimc-index  0 || fimc-index = FIMC_LITE_MAX_DEVS)
return -EINVAL;
 
-   fimc-variant = drv_data-variant[fimc-index];
+   fimc-dd = drv_data;
fimc-pdev = pdev;
 
init_waitqueue_head(fimc-irq_queue);
@@ -1577,7 +1577,8 @@ static const struct dev_pm_ops fimc_lite_pm_ops = {
   NULL)
 };
 
-static struct flite_variant fimc_lite0_variant_exynos4 = {
+/* EXYNOS4212, EXYNOS4412 */
+static struct flite_drvdata fimc_lite_drvdata_exynos4 = {
.max_width   

[PATCH v2 3/5] exynos4-is: Allow colorspace conversion at fimc-lite

2013-03-26 Thread Sylwester Nawrocki
The FIMC-LITE output DMA allows to configure different YUV order
than the order at the camera input interface. Thus there is some
limited colorspace conversion possible. This patch makes the
color format variable be per FIMC-LITE input/output, rather than
a global per device. This also fixes incorrect behavior where
color format at the FIMC-LITE.N subdev's source pad is modified
by VIDIOC_S_FMT ioctl on the related video node.

YUV order definitions are corrected so that we use notation:

 | byte3 | byte2 | byte1 | byte0
  ---+---+---+---+--
  YCBYCR | CR| Y | CB| Y
  YCRYCB | CB| Y | CR| Y
  CBYCRY | Y | CR| Y | CB
  CRYCBY | Y | CB| Y | CR

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/exynos4-is/fimc-lite-reg.c |4 +-
 drivers/media/platform/exynos4-is/fimc-lite-reg.h |8 +--
 drivers/media/platform/exynos4-is/fimc-lite.c |   76 ++---
 drivers/media/platform/exynos4-is/fimc-lite.h |4 +-
 include/media/s5p_fimc.h  |2 +
 5 files changed, 61 insertions(+), 33 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-lite-reg.c 
b/drivers/media/platform/exynos4-is/fimc-lite-reg.c
index ac9663c..8cc0d39 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite-reg.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite-reg.c
@@ -127,7 +127,7 @@ static const u32 src_pixfmt_map[8][3] = {
 /* Set camera input pixel format and resolution */
 void flite_hw_set_source_format(struct fimc_lite *dev, struct flite_frame *f)
 {
-   enum v4l2_mbus_pixelcode pixelcode = dev-fmt-mbus_code;
+   enum v4l2_mbus_pixelcode pixelcode = f-fmt-mbus_code;
int i = ARRAY_SIZE(src_pixfmt_map);
u32 cfg;
 
@@ -227,7 +227,7 @@ static void flite_hw_set_out_order(struct fimc_lite *dev, 
struct flite_frame *f)
int i = ARRAY_SIZE(pixcode);
 
while (--i = 0)
-   if (pixcode[i][0] == dev-fmt-mbus_code)
+   if (pixcode[i][0] == f-fmt-mbus_code)
break;
cfg = ~FLITE_REG_CIODMAFMT_YCBCR_ORDER_MASK;
writel(cfg | pixcode[i][1], dev-regs + FLITE_REG_CIODMAFMT);
diff --git a/drivers/media/platform/exynos4-is/fimc-lite-reg.h 
b/drivers/media/platform/exynos4-is/fimc-lite-reg.h
index 0e34584..3903839 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite-reg.h
+++ b/drivers/media/platform/exynos4-is/fimc-lite-reg.h
@@ -72,10 +72,10 @@
 #define FLITE_REG_CIODMAFMT0x18
 #define FLITE_REG_CIODMAFMT_RAW_CON(1  15)
 #define FLITE_REG_CIODMAFMT_PACK12 (1  14)
-#define FLITE_REG_CIODMAFMT_CRYCBY (0  4)
-#define FLITE_REG_CIODMAFMT_CBYCRY (1  4)
-#define FLITE_REG_CIODMAFMT_YCRYCB (2  4)
-#define FLITE_REG_CIODMAFMT_YCBYCR (3  4)
+#define FLITE_REG_CIODMAFMT_YCBYCR (0  4)
+#define FLITE_REG_CIODMAFMT_YCRYCB (1  4)
+#define FLITE_REG_CIODMAFMT_CBYCRY (2  4)
+#define FLITE_REG_CIODMAFMT_CRYCBY (3  4)
 #define FLITE_REG_CIODMAFMT_YCBCR_ORDER_MASK   (0x3  4)
 
 /* Camera Output Canvas */
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c 
b/drivers/media/platform/exynos4-is/fimc-lite.c
index ba35328..b11e358 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -46,6 +46,7 @@ static const struct fimc_fmt fimc_lite_formats[] = {
.color  = FIMC_FMT_YCBYCR422,
.memplanes  = 1,
.mbus_code  = V4L2_MBUS_FMT_YUYV8_2X8,
+   .flags  = FMT_FLAGS_YUV,
}, {
.name   = YUV 4:2:2 packed, CbYCrY,
.fourcc = V4L2_PIX_FMT_UYVY,
@@ -53,6 +54,7 @@ static const struct fimc_fmt fimc_lite_formats[] = {
.color  = FIMC_FMT_CBYCRY422,
.memplanes  = 1,
.mbus_code  = V4L2_MBUS_FMT_UYVY8_2X8,
+   .flags  = FMT_FLAGS_YUV,
}, {
.name   = YUV 4:2:2 packed, CrYCbY,
.fourcc = V4L2_PIX_FMT_VYUY,
@@ -60,6 +62,7 @@ static const struct fimc_fmt fimc_lite_formats[] = {
.color  = FIMC_FMT_CRYCBY422,
.memplanes  = 1,
.mbus_code  = V4L2_MBUS_FMT_VYUY8_2X8,
+   .flags  = FMT_FLAGS_YUV,
}, {
.name   = YUV 4:2:2 packed, YCrYCb,
.fourcc = V4L2_PIX_FMT_YVYU,
@@ -67,6 +70,7 @@ static const struct fimc_fmt fimc_lite_formats[] = {
.color  = FIMC_FMT_YCRYCB422,
.memplanes  = 1,
.mbus_code  = V4L2_MBUS_FMT_YVYU8_2X8,
+   .flags  = FMT_FLAGS_YUV,
}, {
.name

[PATCH v2 3/4] exynos4-is: Correct input DMA YUV order configuration

2013-03-26 Thread Sylwester Nawrocki
This patch fixes erroneous setup of the YUV order caused by not
clearing FIMC_REG_MSCTRL_ORDER422_MASK bit field before setting
proper FIMC_REG_MSCTRL_ORDER422 bits. This resulted in false
colors for YUYV, YVYU, UYVY, VYUY color formats, depending in
what sequence those were configured by user space.

YUV order definitions are corrected so that following convention
is used:

| byte3 | byte2 | byte1 | byte0
 ---+---+---+---+--
 YCBYCR | CR| Y | CB| Y
 YCRYCB | CB| Y | CR| Y
 CBYCRY | Y | CR| Y | CB
 CRYCBY | Y | CB| Y | CR

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/exynos4-is/fimc-core.c |   16 
 drivers/media/platform/exynos4-is/fimc-reg.c  |3 ++-
 drivers/media/platform/exynos4-is/fimc-reg.h  |   16 
 3 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-core.c 
b/drivers/media/platform/exynos4-is/fimc-core.c
index 2e153bb..f6efa47 100644
--- a/drivers/media/platform/exynos4-is/fimc-core.c
+++ b/drivers/media/platform/exynos4-is/fimc-core.c
@@ -412,34 +412,34 @@ void fimc_set_yuv_order(struct fimc_ctx *ctx)
/* Set order for 1 plane input formats. */
switch (ctx-s_frame.fmt-color) {
case FIMC_FMT_YCRYCB422:
-   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_CBYCRY;
+   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_YCRYCB;
break;
case FIMC_FMT_CBYCRY422:
-   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_YCRYCB;
+   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_CBYCRY;
break;
case FIMC_FMT_CRYCBY422:
-   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_YCBYCR;
+   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_CRYCBY;
break;
case FIMC_FMT_YCBYCR422:
default:
-   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_CRYCBY;
+   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_YCBYCR;
break;
}
dbg(ctx-in_order_1p= %d, ctx-in_order_1p);
 
switch (ctx-d_frame.fmt-color) {
case FIMC_FMT_YCRYCB422:
-   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_CBYCRY;
+   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_YCRYCB;
break;
case FIMC_FMT_CBYCRY422:
-   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_YCRYCB;
+   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_CBYCRY;
break;
case FIMC_FMT_CRYCBY422:
-   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_YCBYCR;
+   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_CRYCBY;
break;
case FIMC_FMT_YCBYCR422:
default:
-   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_CRYCBY;
+   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_YCBYCR;
break;
}
dbg(ctx-out_order_1p= %d, ctx-out_order_1p);
diff --git a/drivers/media/platform/exynos4-is/fimc-reg.c 
b/drivers/media/platform/exynos4-is/fimc-reg.c
index c276eb8..fd144a1 100644
--- a/drivers/media/platform/exynos4-is/fimc-reg.c
+++ b/drivers/media/platform/exynos4-is/fimc-reg.c
@@ -449,7 +449,8 @@ void fimc_hw_set_in_dma(struct fimc_ctx *ctx)
 | FIMC_REG_MSCTRL_IN_BURST_COUNT_MASK
 | FIMC_REG_MSCTRL_INPUT_MASK
 | FIMC_REG_MSCTRL_C_INT_IN_MASK
-| FIMC_REG_MSCTRL_2P_IN_ORDER_MASK);
+| FIMC_REG_MSCTRL_2P_IN_ORDER_MASK
+| FIMC_REG_MSCTRL_ORDER422_MASK);
 
cfg |= (FIMC_REG_MSCTRL_IN_BURST_COUNT(4)
| FIMC_REG_MSCTRL_INPUT_MEMORY
diff --git a/drivers/media/platform/exynos4-is/fimc-reg.h 
b/drivers/media/platform/exynos4-is/fimc-reg.h
index 01da7f3..6c97798 100644
--- a/drivers/media/platform/exynos4-is/fimc-reg.h
+++ b/drivers/media/platform/exynos4-is/fimc-reg.h
@@ -95,10 +95,10 @@
 /* Output DMA control */
 #define FIMC_REG_CIOCTRL   0x4c
 #define FIMC_REG_CIOCTRL_ORDER422_MASK (3  0)
-#define FIMC_REG_CIOCTRL_ORDER422_CRYCBY   (0  0)
-#define FIMC_REG_CIOCTRL_ORDER422_CBYCRY   (1  0)
-#define FIMC_REG_CIOCTRL_ORDER422_YCRYCB   (2  0)
-#define FIMC_REG_CIOCTRL_ORDER422_YCBYCR   (3  0)
+#define FIMC_REG_CIOCTRL_ORDER422_YCBYCR   (0  0)
+#define FIMC_REG_CIOCTRL_ORDER422_YCRYCB   (1  0)
+#define FIMC_REG_CIOCTRL_ORDER422_CBYCRY   (2  0)
+#define FIMC_REG_CIOCTRL_ORDER422_CRYCBY   (3  0)
 #define FIMC_REG_CIOCTRL_LASTIRQ_ENABLE(1  2)
 #define FIMC_REG_CIOCTRL_YCBCR_3PLANE  (0  3)
 #define FIMC_REG_CIOCTRL_YCBCR_2PLANE  (1  3)
@@ -220,10 +220,10 @@
 #define FIMC_REG_MSCTRL_FLIP_180   (3  13)
 #define FIMC_REG_MSCTRL_FIFO_CTRL_FULL (1  12)
 #define 

[PATCH v2 4/5] exynos4-is: Correct input DMA YUV order configuration

2013-03-26 Thread Sylwester Nawrocki
This patch fixes erroneous setup of the YUV order caused by not
clearing FIMC_REG_MSCTRL_ORDER422_MASK bit field before setting
proper FIMC_REG_MSCTRL_ORDER422 bits. This resulted in false
colors for YUYV, YVYU, UYVY, VYUY color formats, depending in
what sequence those were configured by user space.

YUV order definitions are corrected so that following convention
is used:

| byte3 | byte2 | byte1 | byte0
 ---+---+---+---+--
 YCBYCR | CR| Y | CB| Y
 YCRYCB | CB| Y | CR| Y
 CBYCRY | Y | CR| Y | CB
 CRYCBY | Y | CB| Y | CR

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/exynos4-is/fimc-core.c |   16 
 drivers/media/platform/exynos4-is/fimc-reg.c  |3 ++-
 drivers/media/platform/exynos4-is/fimc-reg.h  |   16 
 3 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-core.c 
b/drivers/media/platform/exynos4-is/fimc-core.c
index 2e153bb..f6efa47 100644
--- a/drivers/media/platform/exynos4-is/fimc-core.c
+++ b/drivers/media/platform/exynos4-is/fimc-core.c
@@ -412,34 +412,34 @@ void fimc_set_yuv_order(struct fimc_ctx *ctx)
/* Set order for 1 plane input formats. */
switch (ctx-s_frame.fmt-color) {
case FIMC_FMT_YCRYCB422:
-   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_CBYCRY;
+   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_YCRYCB;
break;
case FIMC_FMT_CBYCRY422:
-   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_YCRYCB;
+   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_CBYCRY;
break;
case FIMC_FMT_CRYCBY422:
-   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_YCBYCR;
+   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_CRYCBY;
break;
case FIMC_FMT_YCBYCR422:
default:
-   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_CRYCBY;
+   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_YCBYCR;
break;
}
dbg(ctx-in_order_1p= %d, ctx-in_order_1p);
 
switch (ctx-d_frame.fmt-color) {
case FIMC_FMT_YCRYCB422:
-   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_CBYCRY;
+   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_YCRYCB;
break;
case FIMC_FMT_CBYCRY422:
-   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_YCRYCB;
+   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_CBYCRY;
break;
case FIMC_FMT_CRYCBY422:
-   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_YCBYCR;
+   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_CRYCBY;
break;
case FIMC_FMT_YCBYCR422:
default:
-   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_CRYCBY;
+   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_YCBYCR;
break;
}
dbg(ctx-out_order_1p= %d, ctx-out_order_1p);
diff --git a/drivers/media/platform/exynos4-is/fimc-reg.c 
b/drivers/media/platform/exynos4-is/fimc-reg.c
index c276eb8..fd144a1 100644
--- a/drivers/media/platform/exynos4-is/fimc-reg.c
+++ b/drivers/media/platform/exynos4-is/fimc-reg.c
@@ -449,7 +449,8 @@ void fimc_hw_set_in_dma(struct fimc_ctx *ctx)
 | FIMC_REG_MSCTRL_IN_BURST_COUNT_MASK
 | FIMC_REG_MSCTRL_INPUT_MASK
 | FIMC_REG_MSCTRL_C_INT_IN_MASK
-| FIMC_REG_MSCTRL_2P_IN_ORDER_MASK);
+| FIMC_REG_MSCTRL_2P_IN_ORDER_MASK
+| FIMC_REG_MSCTRL_ORDER422_MASK);
 
cfg |= (FIMC_REG_MSCTRL_IN_BURST_COUNT(4)
| FIMC_REG_MSCTRL_INPUT_MEMORY
diff --git a/drivers/media/platform/exynos4-is/fimc-reg.h 
b/drivers/media/platform/exynos4-is/fimc-reg.h
index 01da7f3..6c97798 100644
--- a/drivers/media/platform/exynos4-is/fimc-reg.h
+++ b/drivers/media/platform/exynos4-is/fimc-reg.h
@@ -95,10 +95,10 @@
 /* Output DMA control */
 #define FIMC_REG_CIOCTRL   0x4c
 #define FIMC_REG_CIOCTRL_ORDER422_MASK (3  0)
-#define FIMC_REG_CIOCTRL_ORDER422_CRYCBY   (0  0)
-#define FIMC_REG_CIOCTRL_ORDER422_CBYCRY   (1  0)
-#define FIMC_REG_CIOCTRL_ORDER422_YCRYCB   (2  0)
-#define FIMC_REG_CIOCTRL_ORDER422_YCBYCR   (3  0)
+#define FIMC_REG_CIOCTRL_ORDER422_YCBYCR   (0  0)
+#define FIMC_REG_CIOCTRL_ORDER422_YCRYCB   (1  0)
+#define FIMC_REG_CIOCTRL_ORDER422_CBYCRY   (2  0)
+#define FIMC_REG_CIOCTRL_ORDER422_CRYCBY   (3  0)
 #define FIMC_REG_CIOCTRL_LASTIRQ_ENABLE(1  2)
 #define FIMC_REG_CIOCTRL_YCBCR_3PLANE  (0  3)
 #define FIMC_REG_CIOCTRL_YCBCR_2PLANE  (1  3)
@@ -220,10 +220,10 @@
 #define FIMC_REG_MSCTRL_FLIP_180   (3  13)
 #define FIMC_REG_MSCTRL_FIFO_CTRL_FULL (1  12)
 #define 

[PATCH v2 4/4] exynos4-is: Ensure proper media pipeline state on device close

2013-03-26 Thread Sylwester Nawrocki
Make sure media_entity_pipeline_stop() is called on video device
close in cases where there was VIDIOC_STREAMON ioctl and no
VIDIOC_STREAMOFF. This patch fixes media entities stream_count
state which could prevent links from being disconnected, due to
non-zero stream_count.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/exynos4-is/fimc-capture.c |   18 +-
 drivers/media/platform/exynos4-is/fimc-core.h|1 +
 drivers/media/platform/exynos4-is/fimc-lite.c|   18 ++
 drivers/media/platform/exynos4-is/fimc-lite.h|1 +
 4 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c 
b/drivers/media/platform/exynos4-is/fimc-capture.c
index b9c0817..0ae6bdb 100644
--- a/drivers/media/platform/exynos4-is/fimc-capture.c
+++ b/drivers/media/platform/exynos4-is/fimc-capture.c
@@ -551,6 +551,7 @@ unlock:
 static int fimc_capture_release(struct file *file)
 {
struct fimc_dev *fimc = video_drvdata(file);
+   struct fimc_vid_cap *vc = fimc-vid_cap;
int ret;
 
dbg(pid: %d, state: 0x%lx, task_pid_nr(current), fimc-state);
@@ -558,6 +559,10 @@ static int fimc_capture_release(struct file *file)
mutex_lock(fimc-lock);
 
if (v4l2_fh_is_singular_file(file)) {
+   if (vc-streaming) {
+   media_entity_pipeline_stop(vc-vfd.entity);
+   vc-streaming = false;
+   }
clear_bit(ST_CAPT_BUSY, fimc-state);
fimc_stop_capture(fimc, false);
fimc_pipeline_call(fimc, close, fimc-pipeline);
@@ -1243,8 +1248,10 @@ static int fimc_cap_streamon(struct file *file, void 
*priv,
}
 
ret = vb2_ioctl_streamon(file, priv, type);
-   if (!ret)
+   if (!ret) {
+   vc-streaming = true;
return ret;
+   }
 
 err_p_stop:
media_entity_pipeline_stop(entity);
@@ -1258,11 +1265,12 @@ static int fimc_cap_streamoff(struct file *file, void 
*priv,
int ret;
 
ret = vb2_ioctl_streamoff(file, priv, type);
+   if (ret  0)
+   return ret;
 
-   if (ret == 0)
-   media_entity_pipeline_stop(fimc-vid_cap.vfd.entity);
-
-   return ret;
+   media_entity_pipeline_stop(fimc-vid_cap.vfd.entity);
+   fimc-vid_cap.streaming = false;
+   return 0;
 }
 
 static int fimc_cap_reqbufs(struct file *file, void *priv,
diff --git a/drivers/media/platform/exynos4-is/fimc-core.h 
b/drivers/media/platform/exynos4-is/fimc-core.h
index 79a..de2b57e 100644
--- a/drivers/media/platform/exynos4-is/fimc-core.h
+++ b/drivers/media/platform/exynos4-is/fimc-core.h
@@ -318,6 +318,7 @@ struct fimc_vid_cap {
int buf_index;
unsigned intframe_count;
unsigned intreqbufs_count;
+   boolstreaming;
int input_index;
int refcnt;
u32 input;
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c 
b/drivers/media/platform/exynos4-is/fimc-lite.c
index b11e358..cb196b8 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -507,6 +507,10 @@ static int fimc_lite_release(struct file *file)
 
if (v4l2_fh_is_singular_file(file) 
atomic_read(fimc-out_path) == FIMC_IO_DMA) {
+   if (fimc-streaming) {
+   media_entity_pipeline_stop(fimc-vfd.entity);
+   fimc-streaming = false;
+   }
clear_bit(ST_FLITE_IN_USE, fimc-state);
fimc_lite_stop_capture(fimc, false);
fimc_pipeline_call(fimc, close, fimc-pipeline);
@@ -798,8 +802,11 @@ static int fimc_lite_streamon(struct file *file, void 
*priv,
goto err_p_stop;
 
ret = vb2_ioctl_streamon(file, priv, type);
-   if (!ret)
+   if (!ret) {
+   fimc-streaming = true;
return ret;
+   }
+
 err_p_stop:
media_entity_pipeline_stop(entity);
return 0;
@@ -812,9 +819,12 @@ static int fimc_lite_streamoff(struct file *file, void 
*priv,
int ret;
 
ret = vb2_ioctl_streamoff(file, priv, type);
-   if (ret == 0)
-   media_entity_pipeline_stop(fimc-vfd.entity);
-   return ret;
+   if (ret  0)
+   return ret;
+
+   media_entity_pipeline_stop(fimc-vfd.entity);
+   fimc-streaming = false;
+   return 0;
 }
 
 static int fimc_lite_reqbufs(struct file *file, void *priv,
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.h 
b/drivers/media/platform/exynos4-is/fimc-lite.h
index 8a8d26f..71fed51 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.h
+++ 

[PATCH v2 5/5] exynos4-is: Ensure proper media pipeline state on device close

2013-03-26 Thread Sylwester Nawrocki
Make sure media_entity_pipeline_stop() is called on video device
close in cases where there was VIDIOC_STREAMON ioctl and no
VIDIOC_STREAMOFF. This patch fixes media entities stream_count
state which could prevent links from being disconnected, due to
non-zero stream_count.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/exynos4-is/fimc-capture.c |   18 +-
 drivers/media/platform/exynos4-is/fimc-core.h|1 +
 drivers/media/platform/exynos4-is/fimc-lite.c|   18 ++
 drivers/media/platform/exynos4-is/fimc-lite.h|1 +
 4 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c 
b/drivers/media/platform/exynos4-is/fimc-capture.c
index b9c0817..0ae6bdb 100644
--- a/drivers/media/platform/exynos4-is/fimc-capture.c
+++ b/drivers/media/platform/exynos4-is/fimc-capture.c
@@ -551,6 +551,7 @@ unlock:
 static int fimc_capture_release(struct file *file)
 {
struct fimc_dev *fimc = video_drvdata(file);
+   struct fimc_vid_cap *vc = fimc-vid_cap;
int ret;
 
dbg(pid: %d, state: 0x%lx, task_pid_nr(current), fimc-state);
@@ -558,6 +559,10 @@ static int fimc_capture_release(struct file *file)
mutex_lock(fimc-lock);
 
if (v4l2_fh_is_singular_file(file)) {
+   if (vc-streaming) {
+   media_entity_pipeline_stop(vc-vfd.entity);
+   vc-streaming = false;
+   }
clear_bit(ST_CAPT_BUSY, fimc-state);
fimc_stop_capture(fimc, false);
fimc_pipeline_call(fimc, close, fimc-pipeline);
@@ -1243,8 +1248,10 @@ static int fimc_cap_streamon(struct file *file, void 
*priv,
}
 
ret = vb2_ioctl_streamon(file, priv, type);
-   if (!ret)
+   if (!ret) {
+   vc-streaming = true;
return ret;
+   }
 
 err_p_stop:
media_entity_pipeline_stop(entity);
@@ -1258,11 +1265,12 @@ static int fimc_cap_streamoff(struct file *file, void 
*priv,
int ret;
 
ret = vb2_ioctl_streamoff(file, priv, type);
+   if (ret  0)
+   return ret;
 
-   if (ret == 0)
-   media_entity_pipeline_stop(fimc-vid_cap.vfd.entity);
-
-   return ret;
+   media_entity_pipeline_stop(fimc-vid_cap.vfd.entity);
+   fimc-vid_cap.streaming = false;
+   return 0;
 }
 
 static int fimc_cap_reqbufs(struct file *file, void *priv,
diff --git a/drivers/media/platform/exynos4-is/fimc-core.h 
b/drivers/media/platform/exynos4-is/fimc-core.h
index 79a..de2b57e 100644
--- a/drivers/media/platform/exynos4-is/fimc-core.h
+++ b/drivers/media/platform/exynos4-is/fimc-core.h
@@ -318,6 +318,7 @@ struct fimc_vid_cap {
int buf_index;
unsigned intframe_count;
unsigned intreqbufs_count;
+   boolstreaming;
int input_index;
int refcnt;
u32 input;
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c 
b/drivers/media/platform/exynos4-is/fimc-lite.c
index b11e358..cb196b8 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -507,6 +507,10 @@ static int fimc_lite_release(struct file *file)
 
if (v4l2_fh_is_singular_file(file) 
atomic_read(fimc-out_path) == FIMC_IO_DMA) {
+   if (fimc-streaming) {
+   media_entity_pipeline_stop(fimc-vfd.entity);
+   fimc-streaming = false;
+   }
clear_bit(ST_FLITE_IN_USE, fimc-state);
fimc_lite_stop_capture(fimc, false);
fimc_pipeline_call(fimc, close, fimc-pipeline);
@@ -798,8 +802,11 @@ static int fimc_lite_streamon(struct file *file, void 
*priv,
goto err_p_stop;
 
ret = vb2_ioctl_streamon(file, priv, type);
-   if (!ret)
+   if (!ret) {
+   fimc-streaming = true;
return ret;
+   }
+
 err_p_stop:
media_entity_pipeline_stop(entity);
return 0;
@@ -812,9 +819,12 @@ static int fimc_lite_streamoff(struct file *file, void 
*priv,
int ret;
 
ret = vb2_ioctl_streamoff(file, priv, type);
-   if (ret == 0)
-   media_entity_pipeline_stop(fimc-vfd.entity);
-   return ret;
+   if (ret  0)
+   return ret;
+
+   media_entity_pipeline_stop(fimc-vfd.entity);
+   fimc-streaming = false;
+   return 0;
 }
 
 static int fimc_lite_reqbufs(struct file *file, void *priv,
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.h 
b/drivers/media/platform/exynos4-is/fimc-lite.h
index 8a8d26f..71fed51 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.h
+++ 

cron job: media_tree daily build: ERRORS

2013-03-26 Thread Hans Verkuil
This message is generated daily by a cron job that builds media_tree for
the kernels and architectures in the list below.

Results of the daily build of media_tree:

date:   Tue Mar 26 19:00:30 CET 2013
git branch: test
git hash:   004e45d736bfe62159bd4dc1549eff414bd27496
gcc version:i686-linux-gcc (GCC) 4.7.2
host hardware:  x86_64
host os:3.8-3.slh.2-amd64

linux-git-arm-davinci: OK
linux-git-arm-exynos: ERRORS
linux-git-arm-omap: WARNINGS
linux-git-blackfin: WARNINGS
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: ERRORS
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.31.14-i686: ERRORS
linux-2.6.32.27-i686: ERRORS
linux-2.6.33.7-i686: ERRORS
linux-2.6.34.7-i686: ERRORS
linux-2.6.35.9-i686: ERRORS
linux-2.6.36.4-i686: ERRORS
linux-2.6.37.6-i686: ERRORS
linux-2.6.38.8-i686: ERRORS
linux-2.6.39.4-i686: ERRORS
linux-3.0.60-i686: ERRORS
linux-3.1.10-i686: ERRORS
linux-3.2.37-i686: WARNINGS
linux-3.3.8-i686: WARNINGS
linux-3.4.27-i686: WARNINGS
linux-3.5.7-i686: WARNINGS
linux-3.6.11-i686: ERRORS
linux-3.7.4-i686: ERRORS
linux-3.8-i686: ERRORS
linux-3.9-rc1-i686: WARNINGS
linux-2.6.31.14-x86_64: ERRORS
linux-2.6.32.27-x86_64: ERRORS
linux-2.6.33.7-x86_64: ERRORS
linux-2.6.34.7-x86_64: ERRORS
linux-2.6.35.9-x86_64: ERRORS
linux-2.6.36.4-x86_64: ERRORS
linux-2.6.37.6-x86_64: ERRORS
linux-2.6.38.8-x86_64: ERRORS
linux-2.6.39.4-x86_64: ERRORS
linux-3.0.60-x86_64: ERRORS
linux-3.1.10-x86_64: ERRORS
linux-3.2.37-x86_64: WARNINGS
linux-3.3.8-x86_64: WARNINGS
linux-3.4.27-x86_64: WARNINGS
linux-3.5.7-x86_64: WARNINGS
linux-3.6.11-x86_64: ERRORS
linux-3.7.4-x86_64: ERRORS
linux-3.8-x86_64: ERRORS
linux-3.9-rc1-x86_64: WARNINGS
apps: WARNINGS
spec-git: OK
sparse: ERRORS

Detailed results are available here:

http://www.xs4all.nl/~hverkuil/logs/Tuesday.log

Full logs are available here:

http://www.xs4all.nl/~hverkuil/logs/Tuesday.tar.bz2

The Media Infrastructure API from this daily build is here:

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


Re: [PATCH v2 0/4] exynos4-is updates

2013-03-26 Thread Sylwester Nawrocki
On 03/26/2013 07:38 PM, Sylwester Nawrocki wrote:
 This patch series includes YUV order handling fix for the FIMC
 and FIMC-LITE, a fix for media entity ref_count issue, minor
 refactoring and removal of some static data that will no longer
 be needed since starting from 3.10 Exynos platform is going to
 be DT only.

Sorry for spamming with this double patch series. Will try to
be more careful next time.

 Sylwester Nawrocki (5):
   exynos4-is: Remove static driver data for Exynos4210 FIMC variants
   exynos4-is: Use common driver data for all FIMC-LITE IP instances
   exynos4-is: Allow colorspace conversion at fimc-lite
   exynos4-is: Correct input DMA YUV order configuration
   exynos4-is: Ensure proper media pipeline state on device close

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


Re: [RFC 01/12] exynos-fimc-is: Adding device tree nodes

2013-03-26 Thread Sylwester Nawrocki

On 03/26/2013 01:17 PM, Arun Kumar K wrote:

+Sensor sub-nodes:
+
+FIMC-IS IP supports custom built sensors to be controlled exclusively by
+the FIMC-IS firmware. These sensor properties are to be defined here.


[snip]


Defining image sensor nodes in a standard way as ISP I2C bus controller
nodes has an disadvantage that we need dummy I2C bus controller driver,
at least this is how I have written the driver for Exynos4x12. In some
version of it I had sensor nodes put in a isp-i2c fimc-is sub-node, but
then there was an issue that this was not a fully specified I2C bus
controller node.

You can refer to my exynos4 fimc-is patch series for details on how this
is now implemented.

Handling the image sensor in a standard way, as regular I2C client devices
has an advantage that we can put pinctrl properties in relevant device
nodes,
where available, which more closely describes the hardware structure.

I'm not really sure in 100% if all this complication is required. It would
allow to use same DT blob for different Imaging Subsystem SW architecture.
For example some parts of functionality handled currently by FIMC-IS (ARM
Cortex-A5) could be moved to host CPU, without any change in the device
tree structure. The kernel could decide e.g. if it uses image sensor driver
implemented in the ISP firmware, or a driver run on the host CPU.

What do you think ?


I have seen your Exynos4 FIMC-IS patchset and you have made a dummy
I2C sensor driver there.
That mode would work fine in Exynos4 since the sensor and ISP will be used
by the same media controller pipeline. So the ISP component in the pipeline
will ensure that the HW is initialized and sensor is working.

But in Exynos5, we are using sensor in pipeline0 and ISP in pipeline1.
So there is a possibility of using sensor subdev independently
without using pipeline1 ISP components.

So with the driver I sent, the pipeline0 can still work like this --

ISP sensor ---  MIPI-CSIS ---  FIMC-LITE ---  Memory

This cannot be done if a dummy I2C driver is made for ISP sensor.


Why not ? I'm not sure what the problem is here.

I realize that describing image sensors in DT as standard I2C slave devices
is not helpful with current firmware architecture. It adds some unnecessary
complication, OTOH it could simplify the sensors registration and media 
graph

initialization code, by unifying it for the firmware based ISP specific
sensors and the external ones with a built-in ISP. Also we could avoid 
having

the bindings defined by current architecture of the driver.

Nevertheless, coming back to your question, the I2C controller driver would
be in same module as the FIMC-IS driver. From user space perspective nothing
changes when you add I2C bus driver and register the sensor in a 
standard way.

What exactly couldn't be done in the kernel ?
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 1/7] media: V4L2: add temporary clock helpers

2013-03-26 Thread Laurent Pinchart
Hello,

On Tuesday 19 March 2013 10:52:29 Sylwester Nawrocki wrote:
 On 03/19/2013 08:32 AM, Guennadi Liakhovetski wrote:
  On Mon, 18 Mar 2013, Sylwester Nawrocki wrote:
  On 03/15/2013 10:27 PM, Guennadi Liakhovetski wrote:
 [...]
 
  diff --git a/drivers/media/v4l2-core/v4l2-clk.c
  b/drivers/media/v4l2-core/v4l2-clk.c
  new file mode 100644
  index 000..3505972
  --- /dev/null
  +++ b/drivers/media/v4l2-core/v4l2-clk.c

[snip]

  +static struct v4l2_clk *v4l2_clk_find(const struct v4l2_subdev *sd,
  +   const char *dev_id, const char *id)
  +{
  + struct v4l2_clk *clk;
  +
  + list_for_each_entry(clk,clk_list, list) {
  + if (!sd || !(sd-flags  V4L2_SUBDEV_FL_IS_I2C)) {
  + if (strcmp(dev_id, clk-dev_id))
  + continue;
  + } else {
  + char *i2c = strstr(dev_id, clk-dev_id);
  + if (!i2c || i2c == dev_id || *(i2c - 1) != ' ')
  + continue;
  + }
  +
  + if (!id || !clk-id || !strcmp(clk-id, id))
  + return clk;
  + }
  +
  + return ERR_PTR(-ENODEV);
  +}
  +
  +struct v4l2_clk *v4l2_clk_get(struct v4l2_subdev *sd, const char *id)
  +{
  + struct v4l2_clk *clk;
  +
  + mutex_lock(clk_lock);
  + clk = v4l2_clk_find(sd, sd-name, id);
  
  Couldn't we just pass the I2C client's struct device name to this
  function ?
  
  Certainly not. This is a part of the generic V4L2 clock API, it's not I2C
  specific.
 
 I have been thinking about something like dev_name(sd-dev), but struct
 v4l2_subdev doesn't have struct device associated with it.

But the caller of v4l2_clk_get() will have a struct device * available, so I 
think it would make sense to pass a struct device * to v4l2_clk_get() and call 
dev_name() on it internally. Clocks would be registered with the device ID as 
well. This requires knowledge of the clock user device in the clock provider, 
but no knowledge of the clock user module name.
 
  And if the host driver that registers a clock for its sub-device knows
  the type of device (I2C, SPI client, etc.) why we need to even bother
  with checking the subdev/bus type in v4l2_clk_find() function above, when
  the host could properly format dev_id when it registers a clock ?
  
  This has been discussed. The host doesn't know the name of the I2C driver,
  that would attach to this subdevice at the time, it registers the clock.
  This is the easiest way to oversome this problem.
 
 OK, thanks for reminding. It would be probably much easier to associate
 the clock with struct device, not with subdev driver. Devices have more
 clear naming rules (at last I2C, SPI clients). And most host drivers
 already have information about I2C bus id, just I2C slave address would
 need to be passed to the host driver so it can register a clock for its
 subdev.
 
  Then the subdev would just pass its struct device pointer to this API to
  find its clock. What am I missing here ?
  I don't think there's a 1-to-1 correspondence between devices and V4L2
  subdevices.
 
 I would expect at least a subdev that needs a clock to have struct device
 associated with it. It would be also much easier this way to use generic
 clocks API in the device tree instantiated systems.

I agree. Let's not overdesign the v4l2-clock API to support clock users 
without a struct device. This is a transitional API only after all.

  + if (!IS_ERR(clk)  !try_module_get(clk-ops-owner))
  + clk = ERR_PTR(-ENODEV);
  + mutex_unlock(clk_lock);
  +
  + if (!IS_ERR(clk)) {
  + clk-subdev = sd;
  
  Why is this needed ? It seems a strange addition that might potentially
  make transition to the common clocks API more difficult.
  
  We got rid of the v4l2_clk_bind() function and the .bind() callback. Now I
  need a pointer to subdevice _before_ v4l2_clk_register() (former
  v4l2_clk_bound()), that's why I have to store it here.
 
 Hmm, sorry, I'm not following. How can we store a subdev pointer in the
 clock data structure that has not been registered yet and thus cannot be
 found with v4l2_clk_find() ?
 
  + atomic_inc(clk-use_count);
  + }
  +
  + return clk;
  +}
  +EXPORT_SYMBOL(v4l2_clk_get);

-- 
Regards,

Laurent Pinchart

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


Re: [PATCH v6 1/7] media: V4L2: add temporary clock helpers

2013-03-26 Thread Laurent Pinchart
Hi Guennadi,

On Tuesday 19 March 2013 11:27:56 Guennadi Liakhovetski wrote:
 On Tue, 19 Mar 2013, Sylwester Nawrocki wrote:
   +   if (!IS_ERR(clk)  !try_module_get(clk-ops-owner))
   +   clk = ERR_PTR(-ENODEV);
   +   mutex_unlock(clk_lock);
   +
   +   if (!IS_ERR(clk)) {
   +   clk-subdev = sd;
   
   Why is this needed ? It seems a strange addition that might potentially
   make transition to the common clocks API more difficult.
   
   We got rid of the v4l2_clk_bind() function and the .bind() callback. Now
   I need a pointer to subdevice _before_ v4l2_clk_register() (former
   v4l2_clk_bound()), that's why I have to store it here.
  
  Hmm, sorry, I'm not following. How can we store a subdev pointer in the
  clock data structure that has not been registered yet and thus cannot be
  found with v4l2_clk_find() ?
 
 sorry, I meant v4l2_async_subdev_register(), not v4l2_clk_register(), my
 mistake. And I meant v4l2_async_subdev_bind(), v4l2_async_subdev_unbind().
 Before we had in the subdev driver (see imx074 example)
 
   /* Tell the bridge the subdevice is about to bind */
   v4l2_async_subdev_bind();
 
   /* get a clock */
   clk = v4l2_clk_get();
   if (IS_ERR(clk))
   return -EPROBE_DEFER;
 
   /*
* enable the clock - this needs a subdev pointer, that we passed
* to the bridge with v4l2_async_subdev_bind() above
*/
   v4l2_clk_enable(clk);
   do_probe();
   v4l2_clk_disable(clk);
 
   /* inform the bridge: binding successful */
   v4l2_async_subdev_bound();
 
 Now we have just
 
   /* get a clock */
   clk = v4l2_clk_get();
   if (IS_ERR(clk))
   return -EPROBE_DEFER;
 
   /*
* enable the clock - this needs a subdev pointer, that we stored
* in the clock object for the bridge driver to use with
* v4l2_clk_get() above
*/
   v4l2_clk_enable(clk);
   do_probe();
   v4l2_clk_disable(clk);

I'm sorry, but I still don't understand why you need a pointer to the subdev 
in the clock provider implementation of v4l2_clk_enable/disable() :-)

   /* inform the bridge: binding successful */
   v4l2_async_subdev_bound();

-- 
Regards,

Laurent Pinchart

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


Re: [PATCH v6 2/7] media: V4L2: support asynchronous subdevice registration

2013-03-26 Thread Laurent Pinchart
Hi Guennadi,

Thanks for the patch.

On Friday 15 March 2013 22:27:48 Guennadi Liakhovetski wrote:
 Currently bridge device drivers register devices for all subdevices
 synchronously, tupically, during their probing. E.g. if an I2C CMOS sensor
 is attached to a video bridge device, the bridge driver will create an I2C
 device and wait for the respective I2C driver to probe. This makes linking
 of devices straight forward, but this approach cannot be used with
 intrinsically asynchronous and unordered device registration systems like
 the Flattened Device Tree. To support such systems this patch adds an
 asynchronous subdevice registration framework to V4L2. To use it respective
 (e.g. I2C) subdevice drivers must register themselves with the framework.
 A bridge driver on the other hand must register notification callbacks,
 that will be called upon various related events.
 
 Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
 ---
 
 v6:
 1. clock name is now I2C adapter ID-I2C address

Is that related to this patch ? :-)

 2. modified API: instead of bind-bound-unbind use register-unregister
 3. removed the bind notifier callback

This version looks much better than the previous one, but I still think work 
is needed. Sorry :-)

  drivers/media/v4l2-core/Makefile |3 +-
  drivers/media/v4l2-core/v4l2-async.c |  272 +++
  include/media/v4l2-async.h   |  105 +
  3 files changed, 379 insertions(+), 1 deletions(-)
  create mode 100644 drivers/media/v4l2-core/v4l2-async.c
  create mode 100644 include/media/v4l2-async.h

[snip]

 diff --git a/drivers/media/v4l2-core/v4l2-async.c
 b/drivers/media/v4l2-core/v4l2-async.c new file mode 100644
 index 000..ce26043
 --- /dev/null
 +++ b/drivers/media/v4l2-core/v4l2-async.c
 @@ -0,0 +1,272 @@
 +/*
 + * V4L2 asynchronous subdevice registration API
 + *
 + * Copyright (C) 2012, Guennadi Liakhovetski g.liakhovet...@gmx.de
 + *
 + * 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 linux/device.h
 +#include linux/err.h
 +#include linux/i2c.h
 +#include linux/list.h
 +#include linux/module.h
 +#include linux/mutex.h
 +#include linux/notifier.h
 +#include linux/platform_device.h
 +#include linux/slab.h
 +#include linux/types.h
 +
 +#include media/v4l2-async.h
 +#include media/v4l2-device.h
 +#include media/v4l2-subdev.h
 +
 +static bool match_i2c(struct device *dev, struct v4l2_async_hw_device
 *hw_dev)
 +{
 + struct i2c_client *client = i2c_verify_client(dev);
 + return client 
 + hw_dev-bus_type == V4L2_ASYNC_BUS_I2C 
 + hw_dev-match.i2c.adapter_id == client-adapter-nr 
 + hw_dev-match.i2c.address == client-addr;
 +}
 +
 +static bool match_platform(struct device *dev, struct v4l2_async_hw_device
 *hw_dev)
 +{
 + return hw_dev-bus_type == V4L2_ASYNC_BUS_PLATFORM 
 + !strcmp(hw_dev-match.platform.name, dev_name(dev));
 +}
 +
 +static LIST_HEAD(subdev_list);
 +static LIST_HEAD(notifier_list);
 +static DEFINE_MUTEX(list_lock);
 +
 +static struct v4l2_async_subdev *v4l2_async_belongs(struct
 v4l2_async_notifier *notifier,
 + struct 
 v4l2_async_subdev_list *asdl)
 +{
 + struct v4l2_async_subdev *asd = NULL;
 + bool (*match)(struct device *,
 +   struct v4l2_async_hw_device *);
 +
 + list_for_each_entry (asd, notifier-waiting, list) {
 + struct v4l2_async_hw_device *hw = asd-hw;
 + switch (hw-bus_type) {
 + case V4L2_ASYNC_BUS_SPECIAL:
 + match = hw-match.special.match;
 + if (!match)
 + /* Match always */
 + return asd;
 + break;
 + case V4L2_ASYNC_BUS_PLATFORM:
 + match = match_platform;
 + break;
 + case V4L2_ASYNC_BUS_I2C:
 + match = match_i2c;
 + break;
 + default:
 + /* Oops */
 + match = NULL;
 + dev_err(notifier-v4l2_dev ? notifier-v4l2_dev-dev : 
 NULL,
 + Invalid bus-type %u on %p\n, hw-bus_type, 
 asd);
 + }
 +
 + if (match  match(asdl-dev, hw))
 + break;
 + }
 +
 + return asd;
 +}
 +
 +static int v4l2_async_test_notify(struct v4l2_async_notifier *notifier,
 +   struct v4l2_async_subdev_list *asdl,
 +   struct v4l2_async_subdev *asd)
 +{
 + int ret;
 +
 + /* Remove from the waiting list */
 + list_del(asd-list);
 + asdl-asd = asd;
 + asdl-notifier = notifier;
 +
 + if (notifier-bound) {
 + ret = notifier-bound(notifier, 

Re: [PATCH v6 3/7] media: soc-camera: switch I2C subdevice drivers to use v4l2-clk

2013-03-26 Thread Laurent Pinchart
Hi Guennadi,

Thanks for the patch.

On Friday 15 March 2013 22:27:49 Guennadi Liakhovetski wrote:
 Instead of centrally enabling and disabling subdevice master clocks in
 soc-camera core, let subdevice drivers do that themselves, using the
 V4L2 clock API and soc-camera convenience wrappers.
 
 Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de

[snip]

 diff --git a/drivers/media/platform/soc_camera/soc_camera.c
 b/drivers/media/platform/soc_camera/soc_camera.c index 4e626a6..01cd5a0
 100644
 --- a/drivers/media/platform/soc_camera/soc_camera.c
 +++ b/drivers/media/platform/soc_camera/soc_camera.c
 @@ -30,6 +30,7 @@
  #include linux/vmalloc.h
 
  #include media/soc_camera.h
 +#include media/v4l2-clk.h
  #include media/v4l2-common.h
  #include media/v4l2-ioctl.h
  #include media/v4l2-dev.h
 @@ -50,13 +51,19 @@ static LIST_HEAD(hosts);
  static LIST_HEAD(devices);
  static DEFINE_MUTEX(list_lock);  /* Protects the list of hosts */
 
 -int soc_camera_power_on(struct device *dev, struct soc_camera_subdev_desc
 *ssdd)
 +int soc_camera_power_on(struct device *dev, struct soc_camera_subdev_desc
 *ssdd,
 + struct v4l2_clk *clk)
  {
 - int ret = regulator_bulk_enable(ssdd-num_regulators,
 + int ret = clk ? v4l2_clk_enable(clk) : 0;
 + if (ret  0) {
 + dev_err(dev, Cannot enable clock\n);
 + return ret;
 + }

Will that work for all devices ? Aren't there devices that would need the 
clock to be turned on after the power supply is stable ?

 + ret = regulator_bulk_enable(ssdd-num_regulators,
   ssdd-regulators);
   if (ret  0) {
   dev_err(dev, Cannot enable regulators\n);
 - return ret;
 + goto eregenable;;
   }
 
   if (ssdd-power) {
 @@ -64,16 +71,25 @@ int soc_camera_power_on(struct device *dev, struct
 soc_camera_subdev_desc *ssdd) if (ret  0) {
   dev_err(dev,
   Platform failed to power-on the camera.\n);
 - regulator_bulk_disable(ssdd-num_regulators,
 -ssdd-regulators);
 + goto epwron;
   }
   }
 
 + return 0;
 +
 +epwron:
 + regulator_bulk_disable(ssdd-num_regulators,
 +ssdd-regulators);
 +eregenable:
 + if (clk)
 + v4l2_clk_disable(clk);
 +
   return ret;
  }
  EXPORT_SYMBOL(soc_camera_power_on);
 
 -int soc_camera_power_off(struct device *dev, struct soc_camera_subdev_desc
 *ssdd)
 +int soc_camera_power_off(struct device *dev, struct soc_camera_subdev_desc
 *ssdd,
 +  struct v4l2_clk *clk)
  {
   int ret = 0;
   int err;
 @@ -94,28 +110,44 @@ int soc_camera_power_off(struct device *dev, struct
 soc_camera_subdev_desc *ssdd ret = ret ? : err;
   }
 
 + if (clk)
 + v4l2_clk_disable(clk);
 +
   return ret;
  }
  EXPORT_SYMBOL(soc_camera_power_off);
 
  static int __soc_camera_power_on(struct soc_camera_device *icd)
  {
 + struct soc_camera_host *ici = to_soc_camera_host(icd-parent);
   struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
   int ret;
 
 + if (!icd-clk) {
 + ret = ici-ops-add(icd);
 + if (ret  0)
 + return ret;
 + }
 +
   ret = v4l2_subdev_call(sd, core, s_power, 1);
 - if (ret  0  ret != -ENOIOCTLCMD  ret != -ENODEV)
 + if (ret  0  ret != -ENOIOCTLCMD  ret != -ENODEV) {
 + if (!icd-clk)
 + ici-ops-remove(icd);
   return ret;
 + }
 
   return 0;
  }
 
  static int __soc_camera_power_off(struct soc_camera_device *icd)
  {
 + struct soc_camera_host *ici = to_soc_camera_host(icd-parent);
   struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
   int ret;
 
   ret = v4l2_subdev_call(sd, core, s_power, 0);
 + if (!icd-clk)
 + ici-ops-remove(icd);
   if (ret  0  ret != -ENOIOCTLCMD  ret != -ENODEV)
   return ret;
 
 @@ -563,12 +595,6 @@ static int soc_camera_open(struct file *file)
   if (sdesc-subdev_desc.reset)
   sdesc-subdev_desc.reset(icd-pdev);
 
 - ret = ici-ops-add(icd);
 - if (ret  0) {
 - dev_err(icd-pdev, Couldn't activate the camera: 
 %d\n, ret);
 - goto eiciadd;
 - }
 -
   ret = __soc_camera_power_on(icd);
   if (ret  0)
   goto epower;
 @@ -614,8 +640,6 @@ esfmt:
  eresume:
   __soc_camera_power_off(icd);
  epower:
 - ici-ops-remove(icd);
 -eiciadd:
   icd-use_count--;
   mutex_unlock(ici-host_lock);
  elockhost:
 @@ -638,7 +662,6 @@ static int soc_camera_close(struct file *file)
 
   if (ici-ops-init_videobuf2)
   vb2_queue_release(icd-vb2_vidq);
 - ici-ops-remove(icd);
 
   

Re: [PATCH 2/2] dma-buf: Add debugfs support

2013-03-26 Thread Laurent Pinchart
Hi Sumit,

Thanks for the patch.

On Monday 25 March 2013 16:50:46 Sumit Semwal wrote:
 Add debugfs support to make it easier to print debug information
 about the dma-buf buffers.
 
 Cc: Dave Airlie airl...@redhat.com
  [minor fixes on init and warning fix]
 Signed-off-by: Sumit Semwal sumit.sem...@linaro.org
 ---
 changes since v1:
  - fixes on init and warnings as reported and corrected by Dave Airlie.
  - add locking while walking attachment list - reported by Daniel Vetter.
 
  drivers/base/dma-buf.c  |  162 
  include/linux/dma-buf.h |5 +-
  2 files changed, 166 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c
 index d89102a..7d867ed 100644
 --- a/drivers/base/dma-buf.c
 +++ b/drivers/base/dma-buf.c
 @@ -27,9 +27,18 @@
  #include linux/dma-buf.h
  #include linux/anon_inodes.h
  #include linux/export.h
 +#include linux/debugfs.h
 +#include linux/seq_file.h
 
  static inline int is_dma_buf_file(struct file *);
 
 +struct dma_buf_list {
 + struct list_head head;
 + struct mutex lock;
 +};
 +
 +static struct dma_buf_list db_list;
 +
  static int dma_buf_release(struct inode *inode, struct file *file)
  {
   struct dma_buf *dmabuf;
 @@ -42,6 +51,11 @@ static int dma_buf_release(struct inode *inode, struct
 file *file) BUG_ON(dmabuf-vmapping_counter);
 
   dmabuf-ops-release(dmabuf);
 +
 + mutex_lock(db_list.lock);
 + list_del(dmabuf-list_node);
 + mutex_unlock(db_list.lock);
 +
   kfree(dmabuf);
   return 0;
  }
 @@ -125,6 +139,10 @@ struct dma_buf *dma_buf_export_named(void *priv, const
 struct dma_buf_ops *ops, mutex_init(dmabuf-lock);
   INIT_LIST_HEAD(dmabuf-attachments);
 
 + mutex_lock(db_list.lock);
 + list_add(dmabuf-list_node, db_list.head);
 + mutex_unlock(db_list.lock);
 +
   return dmabuf;
  }
  EXPORT_SYMBOL_GPL(dma_buf_export_named);
 @@ -551,3 +569,147 @@ void dma_buf_vunmap(struct dma_buf *dmabuf, void
 *vaddr) mutex_unlock(dmabuf-lock);
  }
  EXPORT_SYMBOL_GPL(dma_buf_vunmap);
 +
 +static int dma_buf_init_debugfs(void);
 +static void dma_buf_uninit_debugfs(void);
 +
 +static int __init dma_buf_init(void)
 +{
 + mutex_init(db_list.lock);
 + INIT_LIST_HEAD(db_list.head);
 + dma_buf_init_debugfs();
 + return 0;
 +}
 +
 +subsys_initcall(dma_buf_init);
 +
 +static void __exit dma_buf_deinit(void)

This function is never called.

 +{
 + dma_buf_uninit_debugfs();
 +}

If you moved those two functions at the end of the file you could get rid of 
the forward declarations above.

 +
 +#ifdef CONFIG_DEBUG_FS
 +static int dma_buf_describe(struct seq_file *s)
 +{
 + int ret;
 + struct dma_buf *buf_obj;
 + struct dma_buf_attachment *attach_obj;
 + int count = 0, attach_count;
 + size_t size = 0;
 +
 + ret = mutex_lock_interruptible(db_list.lock);
 +
 + if (ret)
 + return ret;
 +
 + seq_printf(s, \nDma-buf Objects:\n);
 + seq_printf(s, \texp_name\tsize\tflags\tmode\tcount\n);
 +
 + list_for_each_entry(buf_obj, db_list.head, list_node) {
 + ret = mutex_lock_interruptible(buf_obj-lock);
 +
 + if (ret) {
 + seq_printf(s,
 +   \tERROR locking buffer object: skipping\n);
 + goto skip_buffer;
 + }
 +
 + seq_printf(s, \t);
 +
 + seq_printf(s, \t%s\t%08zu\t%08x\t%08x\t%08d\n,
 + buf_obj-exp_name, buf_obj-size,
 + buf_obj-file-f_flags, buf_obj-file-f_mode,
 + buf_obj-file-f_count.counter);
 +
 + seq_printf(s, \t\tAttached Devices:\n);
 + attach_count = 0;
 +
 + list_for_each_entry(attach_obj, buf_obj-attachments, node) {
 + seq_printf(s, \t\t);
 +
 + seq_printf(s, %s\n, attach_obj-dev-init_name);
 + attach_count++;
 + }
 +
 + seq_printf(s, \n\t\tTotal %d devices attached\n,
 + attach_count);
 +
 + count++;
 + size += buf_obj-size;
 +skip_buffer:
 + mutex_unlock(buf_obj-lock);
 + }
 +
 + seq_printf(s, \nTotal %d objects, %zu bytes\n, count, size);
 +
 + mutex_unlock(db_list.lock);
 + return 0;
 +}
 +
 +static int dma_buf_show(struct seq_file *s, void *unused)
 +{
 + void (*func)(struct seq_file *) = s-private;
 + func(s);
 + return 0;
 +}
 +
 +static int dma_buf_debug_open(struct inode *inode, struct file *file)
 +{
 + return single_open(file, dma_buf_show, inode-i_private);
 +}
 +
 +static const struct file_operations dma_buf_debug_fops = {
 + .open   = dma_buf_debug_open,
 + .read   = seq_read,
 + .llseek = seq_lseek,
 + .release= single_release,
 +};
 +
 +static struct dentry *dma_buf_debugfs_dir;
 +
 +static int 

Re: [PATCH RFC] [media] add Aptina mt9m114 HD digital image sensor driver

2013-03-26 Thread Laurent Pinchart
Hi Scott,

Thank you for the patch.

On Friday 18 January 2013 17:00:44 Scott Jiang wrote:
 This driver support parallel data output mode and
 QVGA/VGA/WVGA/720P resolution. You can select YCbCr and RGB565
 output format.

What host bridge do you use this driver with ?

 Signed-off-by: Scott Jiang scott.jiang.li...@gmail.com
 ---
  drivers/media/i2c/Kconfig   |   10 +
  drivers/media/i2c/Makefile  |1 +
  drivers/media/i2c/mt9m114.c | 1055 
  3 files changed, 1066 insertions(+), 0 deletions(-)
  create mode 100644 drivers/media/i2c/mt9m114.c

[snip]


 diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c
 new file mode 100644
 index 000..564b711
 --- /dev/null
 +++ b/drivers/media/i2c/mt9m114.c
 @@ -0,0 +1,1055 @@
 +/*
 + * mt9m114.c Aptina MT9M114 sensor driver
 + *
 + * Copyright (c) 2012 Analog Devices Inc.
 + *
 + * refer to: SoC Camera driver by Andrew Chew ac...@nvidia.com
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License version 2 as
 + * published by the Free Software Foundation.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

You can remove the last paragraph, it doesn't bring any legal added value, and 
we don't want to patch every source file in the kernel if the FSF moves :-)

 + */

[snip]

 +struct mt9m114_reg {
 + u16 reg;
 + u32 val;
 + int width;
 +};
 +
 +enum {
 + MT9M114_QVGA,
 + MT9M114_VGA,
 + MT9M114_WVGA,
 + MT9M114_720P,
 +};

This is the part I don't like. Instead of hardcoding 4 different resolutions 
and using large register address/value tables, you should compute the register 
values from the image size requested by the user.

-- 
Regards,

Laurent Pinchart

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


Re: [RFC PATCH 2/6] v4l2: add new VIDIOC_DBG_G_CHIP_NAME ioctl.

2013-03-26 Thread Laurent Pinchart
Hi Hans,

On Monday 18 March 2013 17:38:16 Hans Verkuil wrote:
 From: Hans Verkuil hans.verk...@cisco.com
 
 Simplify the debugging ioctls by creating the VIDIOC_DBG_G_CHIP_NAME ioctl.
 This will eventually replace VIDIOC_DBG_G_CHIP_IDENT. Chip matching is done
 by the name or index of subdevices or an index to a bridge chip. Most of
 this can all be done automatically, so most drivers just need to provide
 get/set register ops.
 
 In particular, it is now possible to get/set subdev registers without
 requiring assistance of the bridge driver.

My biggest question is why don't we use the media controller API to get the 
information provided by this new ioctl ?

 Signed-off-by: Hans Verkuil hans.verk...@cisco.com
 ---
  drivers/media/v4l2-core/v4l2-common.c |5 +-
  drivers/media/v4l2-core/v4l2-dev.c|5 +-
  drivers/media/v4l2-core/v4l2-ioctl.c  |  115 --
  include/media/v4l2-ioctl.h|3 +
  include/uapi/linux/videodev2.h|   34 +++---
  5 files changed, 146 insertions(+), 16 deletions(-)

[snip]

 diff --git a/drivers/media/v4l2-core/v4l2-dev.c
 b/drivers/media/v4l2-core/v4l2-dev.c index de1e9ab..c0c651d 100644
 --- a/drivers/media/v4l2-core/v4l2-dev.c
 +++ b/drivers/media/v4l2-core/v4l2-dev.c
 @@ -591,9 +591,10 @@ static void determine_valid_ioctls(struct video_device

[snip]

 +static int v4l_dbg_g_chip_name(const struct v4l2_ioctl_ops *ops,
 + struct file *file, void *fh, void *arg)

As this is a debug ioctl that should never be used in application, I would 
like to guard the whole implementation with #ifdef CONFIG_VIDEO_ADV_DEBUG. 
This will make sure that no applications will abuse it, as it won't be 
available in distro kernels.

 +{
 + struct video_device *vfd = video_devdata(file);
 + struct v4l2_dbg_chip_name *p = arg;
 + struct v4l2_subdev *sd;
 + int idx = 0;
 +
 + switch (p-match.type) {
 + case V4L2_CHIP_MATCH_BRIDGE:
 +#ifdef CONFIG_VIDEO_ADV_DEBUG
 + if (ops-vidioc_s_register)
 + p-flags |= V4L2_CHIP_FL_WRITABLE;
 + if (ops-vidioc_g_register)
 + p-flags |= V4L2_CHIP_FL_READABLE;
 +#endif
 + if (ops-vidioc_g_chip_name)
 + return ops-vidioc_g_chip_name(file, fh, arg);
 + if (p-match.addr)
 + return -EINVAL;
 + if (vfd-v4l2_dev)
 + strlcpy(p-name, vfd-v4l2_dev-name, sizeof(p-name));
 + else if (vfd-parent)
 + strlcpy(p-name, vfd-parent-driver-name, 
 sizeof(p-name));
 + else
 + strlcpy(p-name, bridge, sizeof(p-name));
 + return 0;
 +
 + case V4L2_CHIP_MATCH_SUBDEV_IDX:
 + case V4L2_CHIP_MATCH_SUBDEV_NAME:
 + if (vfd-v4l2_dev == NULL)
 + break;
 + v4l2_device_for_each_subdev(sd, vfd-v4l2_dev) {
 + if (v4l_dbg_found_match(p-match, sd, idx++)) {
 +#ifdef CONFIG_VIDEO_ADV_DEBUG
 + if (sd-ops-core  sd-ops-core-s_register)
 + p-flags |= V4L2_CHIP_FL_WRITABLE;
 + if (sd-ops-core  sd-ops-core-g_register)
 + p-flags |= V4L2_CHIP_FL_READABLE;
 +#endif
 + strlcpy(p-name, sd-name, sizeof(p-name));
 + return 0;
 + }
 + }
 + break;
 + }
 + return -EINVAL;
 +}

-- 
Regards,

Laurent Pinchart

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


Re: [PATCH] [media] s5p-mfc: Change MFC clock reference w.r.t Common Clock Framework

2013-03-26 Thread Mike Turquette
Quoting Prasanna Kumar (2013-03-25 22:20:51)
 From: Prasanna Kumar prasanna...@samsung.com
 
 According to Common Clock framework , modified the method of getting
 clock for MFC Block.
 
 Signed-off-by: Prasanna Kumar prasanna...@samsung.com
 ---
  drivers/media/platform/s5p-mfc/s5p_mfc_pm.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 
 diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c 
 b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
 index 6aa38a5..b8ac8f6 100644
 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
 +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
 @@ -50,7 +50,7 @@ int s5p_mfc_init_pm(struct s5p_mfc_dev *dev)
 goto err_p_ip_clk;
 }
  
 -   pm-clock = clk_get(dev-plat_dev-dev, dev-variant-mclk_name);
 +   pm-clock = clk_get_parent(pm-clock_gate);

Ok, I'll bite.  Why make this change?  Was there an issue using
clkdev/clk_get to get the clock you needed?

Regards,
Mike

 if (IS_ERR(pm-clock)) {
 mfc_err(Failed to get MFC clock\n);
 ret = PTR_ERR(pm-clock);
 -- 
 1.7.5.4
 
 
 ___
 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-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v8 1/9] mfd: Add commands abstraction layer for SI476X MFD

2013-03-26 Thread Andrey Smirnov
From: Andrey Smirnov andreysm@charmander.(none)

This patch adds all the functions used for exchanging commands with
the chip.

Acked-by: Hans Verkuil hans.verk...@cisco.com
Signed-off-by: Andrey Smirnov andrew.smir...@gmail.com
---
 drivers/mfd/si476x-cmd.c | 1554 ++
 1 file changed, 1554 insertions(+)
 create mode 100644 drivers/mfd/si476x-cmd.c

diff --git a/drivers/mfd/si476x-cmd.c b/drivers/mfd/si476x-cmd.c
new file mode 100644
index 000..71ac2e8
--- /dev/null
+++ b/drivers/mfd/si476x-cmd.c
@@ -0,0 +1,1554 @@
+/*
+ * drivers/mfd/si476x-cmd.c -- Subroutines implementing command
+ * protocol of si476x series of chips
+ *
+ * Copyright (C) 2012 Innovative Converged Devices(ICD)
+ * Copyright (C) 2013 Andrey Smirnov
+ *
+ * Author: Andrey Smirnov andrew.smir...@gmail.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#include linux/module.h
+#include linux/completion.h
+#include linux/delay.h
+#include linux/atomic.h
+#include linux/i2c.h
+#include linux/device.h
+#include linux/gpio.h
+#include linux/videodev2.h
+
+#include media/si476x.h
+#include linux/mfd/si476x-core.h
+
+#define msb(x)  ((u8)((u16) x  8))
+#define lsb(x)  ((u8)((u16) x   0x00FF))
+
+
+
+#define CMD_POWER_UP   0x01
+#define CMD_POWER_UP_A10_NRESP 1
+#define CMD_POWER_UP_A10_NARGS 5
+
+#define CMD_POWER_UP_A20_NRESP 1
+#define CMD_POWER_UP_A20_NARGS 5
+
+#define POWER_UP_DELAY_MS  110
+
+#define CMD_POWER_DOWN 0x11
+#define CMD_POWER_DOWN_A10_NRESP   1
+
+#define CMD_POWER_DOWN_A20_NRESP   1
+#define CMD_POWER_DOWN_A20_NARGS   1
+
+#define CMD_FUNC_INFO  0x12
+#define CMD_FUNC_INFO_NRESP7
+
+#define CMD_SET_PROPERTY   0x13
+#define CMD_SET_PROPERTY_NARGS 5
+#define CMD_SET_PROPERTY_NRESP 1
+
+#define CMD_GET_PROPERTY   0x14
+#define CMD_GET_PROPERTY_NARGS 3
+#define CMD_GET_PROPERTY_NRESP 4
+
+#define CMD_AGC_STATUS 0x17
+#define CMD_AGC_STATUS_NRESP_A10   2
+#define CMD_AGC_STATUS_NRESP_A206
+
+#define PIN_CFG_BYTE(x) (0x7F  (x))
+#define CMD_DIG_AUDIO_PIN_CFG  0x18
+#define CMD_DIG_AUDIO_PIN_CFG_NARGS4
+#define CMD_DIG_AUDIO_PIN_CFG_NRESP5
+
+#define CMD_ZIF_PIN_CFG0x19
+#define CMD_ZIF_PIN_CFG_NARGS  4
+#define CMD_ZIF_PIN_CFG_NRESP  5
+
+#define CMD_IC_LINK_GPO_CTL_PIN_CFG0x1A
+#define CMD_IC_LINK_GPO_CTL_PIN_CFG_NARGS  4
+#define CMD_IC_LINK_GPO_CTL_PIN_CFG_NRESP  5
+
+#define CMD_ANA_AUDIO_PIN_CFG  0x1B
+#define CMD_ANA_AUDIO_PIN_CFG_NARGS1
+#define CMD_ANA_AUDIO_PIN_CFG_NRESP2
+
+#define CMD_INTB_PIN_CFG   0x1C
+#define CMD_INTB_PIN_CFG_NARGS 2
+#define CMD_INTB_PIN_CFG_A10_NRESP 6
+#define CMD_INTB_PIN_CFG_A20_NRESP 3
+
+#define CMD_FM_TUNE_FREQ   0x30
+#define CMD_FM_TUNE_FREQ_A10_NARGS 5
+#define CMD_FM_TUNE_FREQ_A20_NARGS 3
+#define CMD_FM_TUNE_FREQ_NRESP 1
+
+#define CMD_FM_RSQ_STATUS  0x32
+
+#define CMD_FM_RSQ_STATUS_A10_NARGS1
+#define CMD_FM_RSQ_STATUS_A10_NRESP17
+#define CMD_FM_RSQ_STATUS_A30_NARGS1
+#define CMD_FM_RSQ_STATUS_A30_NRESP23
+
+
+#define CMD_FM_SEEK_START  0x31
+#define CMD_FM_SEEK_START_NARGS1
+#define CMD_FM_SEEK_START_NRESP1
+
+#define CMD_FM_RDS_STATUS  0x36
+#define CMD_FM_RDS_STATUS_NARGS1
+#define CMD_FM_RDS_STATUS_NRESP16
+
+#define CMD_FM_RDS_BLOCKCOUNT  0x37
+#define CMD_FM_RDS_BLOCKCOUNT_NARGS1
+#define CMD_FM_RDS_BLOCKCOUNT_NRESP8
+
+#define CMD_FM_PHASE_DIVERSITY 0x38
+#define CMD_FM_PHASE_DIVERSITY_NARGS   1
+#define CMD_FM_PHASE_DIVERSITY_NRESP   1
+
+#define CMD_FM_PHASE_DIV_STATUS0x39
+#define CMD_FM_PHASE_DIV_STATUS_NRESP  2
+
+#define CMD_AM_TUNE_FREQ   0x40
+#define CMD_AM_TUNE_FREQ_NARGS 3
+#define 

[PATCH v8 5/9] v4l2: Fix the type of V4L2_CID_TUNE_PREEMPHASIS in the documentation

2013-03-26 Thread Andrey Smirnov
Change the type of V4L2_CID_TUNE_PREEMPHASIS from 'integer' to 'enum
v4l2_preemphasis'

Acked-by: Hans Verkuil hans.verk...@cisco.com
Signed-off-by: Andrey Smirnov andrew.smir...@gmail.com
---
 Documentation/DocBook/media/v4l/controls.xml |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/DocBook/media/v4l/controls.xml 
b/Documentation/DocBook/media/v4l/controls.xml
index 9e8f854..1ad20cc 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -3848,7 +3848,7 @@ in Hz. The range and step are driver-specific./entry
  /row
  row
entry 
spanname=idconstantV4L2_CID_TUNE_PREEMPHASIS/constantnbsp;/entry
-   entryinteger/entry
+   entryenum v4l2_preemphasis/entry
  /row
  row id=v4l2-preemphasisentry spanname=descrConfigures the 
pre-emphasis value for broadcasting.
 A pre-emphasis filter is applied to the broadcast to accentuate the high audio 
frequencies.
-- 
1.7.10.4

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


[PATCH v8 0/9] Driver for Si476x series of chips

2013-03-26 Thread Andrey Smirnov
Driver for Si476x series of chips

This is a eight version of the patchset originaly posted here:
https://lkml.org/lkml/2012/9/13/590

Second version of the patch was posted here:
https://lkml.org/lkml/2012/10/5/598

Third version of the patch was posted here:
https://lkml.org/lkml/2012/10/23/510

Fourth version of the patch was posted here:
https://lkml.org/lkml/2013/2/18/572

Fifth version of the patch was posted here:
https://lkml.org/lkml/2013/2/26/45

Sixth version of the patch was posted here:
https://lkml.org/lkml/2013/2/26/257

Seventh version of the patch was posted here:
https://lkml.org/lkml/2013/2/27/22


To save everyone's time I'll repost the original description of it:

This patchset contains a driver for a Silicon Laboratories 476x series
of radio tuners. The driver itself is implemented as an MFD devices
comprised of three parts: 
 1. Core device that provides all the other devices with basic
functionality and locking scheme.
 2. Radio device that translates between V4L2 subsystem requests into
Core device commands.
 3. Codec device that does similar to the earlier described task, but
for ALSA SoC subsystem.

v8 of this driver has following changes:
   - checkpatch.pl fixes

Pleas note that patches are not completely warning free, as far as
checkpatch.pl is concerned, because I skipped all the places where
80-character compliance can be acheived only by means of weird
indentation.

Andrey Smirnov (9):
  mfd: Add commands abstraction layer for SI476X MFD
  mfd: Add the main bulk of core driver for SI476x code
  mfd: Add chip properties handling code for SI476X MFD
  mfd: Add header files and Kbuild plumbing for SI476x MFD core
  v4l2: Fix the type of V4L2_CID_TUNE_PREEMPHASIS in the documentation
  v4l2: Add standard controls for FM receivers
  v4l2: Add documentation for the FM RX controls
  v4l2: Add private controls base for SI476X
  v4l2: Add a V4L2 driver for SI476X MFD

 Documentation/DocBook/media/v4l/compat.xml |3 +
 Documentation/DocBook/media/v4l/controls.xml   |   74 +-
 .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml   |9 +
 Documentation/video4linux/si476x.txt   |  187 +++
 drivers/media/radio/Kconfig|   17 +
 drivers/media/radio/Makefile   |1 +
 drivers/media/radio/radio-si476x.c | 1599 
 drivers/media/v4l2-core/v4l2-ctrls.c   |   14 +-
 drivers/mfd/Kconfig|   12 +
 drivers/mfd/Makefile   |4 +
 drivers/mfd/si476x-cmd.c   | 1554 +++
 drivers/mfd/si476x-i2c.c   |  886 +++
 drivers/mfd/si476x-prop.c  |  242 +++
 include/linux/mfd/si476x-core.h|  525 +++
 include/media/si476x.h |  426 ++
 include/uapi/linux/v4l2-controls.h |   17 +
 16 files changed, 5566 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/video4linux/si476x.txt
 create mode 100644 drivers/media/radio/radio-si476x.c
 create mode 100644 drivers/mfd/si476x-cmd.c
 create mode 100644 drivers/mfd/si476x-i2c.c
 create mode 100644 drivers/mfd/si476x-prop.c
 create mode 100644 include/linux/mfd/si476x-core.h
 create mode 100644 include/media/si476x.h

-- 
1.7.10.4

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


[PATCH v8 3/9] mfd: Add chip properties handling code for SI476X MFD

2013-03-26 Thread Andrey Smirnov
From: Andrey Smirnov andreysm@charmander.(none)

This patch adds code related to manipulation of the properties of
SI476X chips.

Acked-by: Hans Verkuil hans.verk...@cisco.com
Signed-off-by: Andrey Smirnov andrew.smir...@gmail.com
---
 drivers/mfd/si476x-prop.c |  242 +
 1 file changed, 242 insertions(+)
 create mode 100644 drivers/mfd/si476x-prop.c

diff --git a/drivers/mfd/si476x-prop.c b/drivers/mfd/si476x-prop.c
new file mode 100644
index 000..d1f548a
--- /dev/null
+++ b/drivers/mfd/si476x-prop.c
@@ -0,0 +1,242 @@
+/*
+ * drivers/mfd/si476x-prop.c -- Subroutines to access
+ * properties of si476x chips
+ *
+ * Copyright (C) 2012 Innovative Converged Devices(ICD)
+ * Copyright (C) 2013 Andrey Smirnov
+ *
+ * Author: Andrey Smirnov andrew.smir...@gmail.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ */
+#include linux/module.h
+
+#include media/si476x.h
+#include linux/mfd/si476x-core.h
+
+struct si476x_property_range {
+   u16 low, high;
+};
+
+static bool si476x_core_element_is_in_array(u16 element,
+   const u16 array[],
+   size_t size)
+{
+   int i;
+
+   for (i = 0; i  size; i++)
+   if (element == array[i])
+   return true;
+
+   return false;
+}
+
+static bool si476x_core_element_is_in_range(u16 element,
+   const struct si476x_property_range 
range[],
+   size_t size)
+{
+   int i;
+
+   for (i = 0; i  size; i++)
+   if (element = range[i].high  element = range[i].low)
+   return true;
+
+   return false;
+}
+
+static bool si476x_core_is_valid_property_a10(struct si476x_core *core,
+ u16 property)
+{
+   static const u16 valid_properties[] = {
+   0x,
+   0x0500, 0x0501,
+   0x0600,
+   0x0709, 0x070C, 0x070D, 0x70E, 0x710,
+   0x0718,
+   0x1207, 0x1208,
+   0x2007,
+   0x2300,
+   };
+
+   static const struct si476x_property_range valid_ranges[] = {
+   { 0x0200, 0x0203 },
+   { 0x0300, 0x0303 },
+   { 0x0400, 0x0404 },
+   { 0x0700, 0x0707 },
+   { 0x1100, 0x1102 },
+   { 0x1200, 0x1204 },
+   { 0x1300, 0x1306 },
+   { 0x2000, 0x2005 },
+   { 0x2100, 0x2104 },
+   { 0x2106, 0x2106 },
+   { 0x2200, 0x220E },
+   { 0x3100, 0x3104 },
+   { 0x3207, 0x320F },
+   { 0x3300, 0x3304 },
+   { 0x3500, 0x3517 },
+   { 0x3600, 0x3617 },
+   { 0x3700, 0x3717 },
+   { 0x4000, 0x4003 },
+   };
+
+   return  si476x_core_element_is_in_range(property, valid_ranges,
+   ARRAY_SIZE(valid_ranges)) ||
+   si476x_core_element_is_in_array(property, valid_properties,
+   ARRAY_SIZE(valid_properties));
+}
+
+static bool si476x_core_is_valid_property_a20(struct si476x_core *core,
+ u16 property)
+{
+   static const u16 valid_properties[] = {
+   0x071B,
+   0x1006,
+   0x2210,
+   0x3401,
+   };
+
+   static const struct si476x_property_range valid_ranges[] = {
+   { 0x2215, 0x2219 },
+   };
+
+   return  si476x_core_is_valid_property_a10(core, property) ||
+   si476x_core_element_is_in_range(property, valid_ranges,
+   ARRAY_SIZE(valid_ranges))  ||
+   si476x_core_element_is_in_array(property, valid_properties,
+   ARRAY_SIZE(valid_properties));
+}
+
+static bool si476x_core_is_valid_property_a30(struct si476x_core *core,
+ u16 property)
+{
+   static const u16 valid_properties[] = {
+   0x071C, 0x071D,
+   0x1007, 0x1008,
+   0x220F, 0x2214,
+   0x2301,
+   0x3105, 0x3106,
+   0x3402,
+   };
+
+   static const struct si476x_property_range valid_ranges[] = {
+   { 0x0405, 0x0411 },
+   { 0x2008, 0x200B },
+   { 0x2220, 0x2223 },
+   { 

[PATCH v8 6/9] v4l2: Add standard controls for FM receivers

2013-03-26 Thread Andrey Smirnov
This commit introduces new class of standard controls
V4L2_CTRL_CLASS_FM_RX. This class is intended to all controls
pertaining to FM receiver chips. Also, two controls belonging to said
class are added as a part of this commit: V4L2_CID_TUNE_DEEMPHASIS and
V4L2_CID_RDS_RECEPTION.

This patch is based on the code found in the patch by Manjunatha Halli [1]

[1] 
http://lists-archives.com/linux-kernel/27641307-new-control-class-and-features-for-fm-rx.html

Acked-by: Hans Verkuil hans.verk...@cisco.com
Signed-off-by: Andrey Smirnov andrew.smir...@gmail.com
---
 drivers/media/v4l2-core/v4l2-ctrls.c |   14 +++---
 include/uapi/linux/v4l2-controls.h   |   13 +
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index 6b28b58..8b89fb8 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -297,8 +297,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
Text,
NULL
};
-   static const char * const tune_preemphasis[] = {
-   No Preemphasis,
+   static const char * const tune_emphasis[] = {
+   None,
50 Microseconds,
75 Microseconds,
NULL,
@@ -508,7 +508,9 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
case V4L2_CID_SCENE_MODE:
return scene_mode;
case V4L2_CID_TUNE_PREEMPHASIS:
-   return tune_preemphasis;
+   return tune_emphasis;
+   case V4L2_CID_TUNE_DEEMPHASIS:
+   return tune_emphasis;
case V4L2_CID_FLASH_LED_MODE:
return flash_led_mode;
case V4L2_CID_FLASH_STROBE_SOURCE:
@@ -799,6 +801,9 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_DV_RX_POWER_PRESENT:  return Power Present;
case V4L2_CID_DV_RX_RGB_RANGE:  return Rx RGB Quantization 
Range;
 
+   case V4L2_CID_FM_RX_CLASS:  return FM Radio Receiver 
Controls;
+   case V4L2_CID_TUNE_DEEMPHASIS:  return De-Emphasis;
+   case V4L2_CID_RDS_RECEPTION:return RDS Reception;
default:
return NULL;
}
@@ -846,6 +851,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_MPEG_VIDEO_MPEG4_QPEL:
case V4L2_CID_WIDE_DYNAMIC_RANGE:
case V4L2_CID_IMAGE_STABILIZATION:
+   case V4L2_CID_RDS_RECEPTION:
*type = V4L2_CTRL_TYPE_BOOLEAN;
*min = 0;
*max = *step = 1;
@@ -904,6 +910,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_DV_TX_RGB_RANGE:
case V4L2_CID_DV_RX_RGB_RANGE:
case V4L2_CID_TEST_PATTERN:
+   case V4L2_CID_TUNE_DEEMPHASIS:
*type = V4L2_CTRL_TYPE_MENU;
break;
case V4L2_CID_LINK_FREQ:
@@ -926,6 +933,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_IMAGE_SOURCE_CLASS:
case V4L2_CID_IMAGE_PROC_CLASS:
case V4L2_CID_DV_CLASS:
+   case V4L2_CID_FM_RX_CLASS:
*type = V4L2_CTRL_TYPE_CTRL_CLASS;
/* You can neither read not write these */
*flags |= V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_WRITE_ONLY;
diff --git a/include/uapi/linux/v4l2-controls.h 
b/include/uapi/linux/v4l2-controls.h
index dcd6374..3e985be 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -59,6 +59,7 @@
 #define V4L2_CTRL_CLASS_IMAGE_SOURCE   0x009e  /* Image source 
controls */
 #define V4L2_CTRL_CLASS_IMAGE_PROC 0x009f  /* Image processing 
controls */
 #define V4L2_CTRL_CLASS_DV 0x00a0  /* Digital Video 
controls */
+#define V4L2_CTRL_CLASS_FM_RX  0x00a1  /* Digital Video 
controls */
 
 /* User-class control IDs */
 
@@ -825,4 +826,16 @@ enum v4l2_dv_rgb_range {
 #defineV4L2_CID_DV_RX_POWER_PRESENT(V4L2_CID_DV_CLASS_BASE 
+ 100)
 #define V4L2_CID_DV_RX_RGB_RANGE   (V4L2_CID_DV_CLASS_BASE + 101)
 
+#define V4L2_CID_FM_RX_CLASS_BASE  (V4L2_CTRL_CLASS_FM_RX | 0x900)
+#define V4L2_CID_FM_RX_CLASS   (V4L2_CTRL_CLASS_FM_RX | 1)
+
+#define V4L2_CID_TUNE_DEEMPHASIS   (V4L2_CID_FM_RX_CLASS_BASE + 1)
+enum v4l2_deemphasis {
+   V4L2_DEEMPHASIS_DISABLED= V4L2_PREEMPHASIS_DISABLED,
+   V4L2_DEEMPHASIS_50_uS   = V4L2_PREEMPHASIS_50_uS,
+   V4L2_DEEMPHASIS_75_uS   = V4L2_PREEMPHASIS_75_uS,
+};
+
+#define V4L2_CID_RDS_RECEPTION (V4L2_CID_FM_RX_CLASS_BASE + 2)
+
 #endif
-- 
1.7.10.4

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


[PATCH v8 8/9] v4l2: Add private controls base for SI476X

2013-03-26 Thread Andrey Smirnov
Add a base to be used for allocation of all the SI476X specific
controls in the corresponding driver.

Acked-by: Hans Verkuil hans.verk...@cisco.com
Signed-off-by: Andrey Smirnov andrew.smir...@gmail.com
---
 include/uapi/linux/v4l2-controls.h |4 
 1 file changed, 4 insertions(+)

diff --git a/include/uapi/linux/v4l2-controls.h 
b/include/uapi/linux/v4l2-controls.h
index 3e985be..22e5170 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -147,6 +147,10 @@ enum v4l2_colorfx {
  * of controls. We reserve 16 controls for this driver. */
 #define V4L2_CID_USER_MEYE_BASE(V4L2_CID_USER_BASE + 
0x1000)
 
+/* The base for the si476x driver controls. See include/media/si476x.h for the 
list
+ * of controls. Total of 16 controls is reserved for that driver */
+#define V4L2_CID_USER_SI476X_BASE  (V4L2_CID_USER_BASE + 0x1010)
+
 /* MPEG-class control IDs */
 
 #define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900)
-- 
1.7.10.4

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


[PATCH v8 7/9] v4l2: Add documentation for the FM RX controls

2013-03-26 Thread Andrey Smirnov
Add appropriate documentation for all the newly added standard
controls.

Based on the patch by Manjunatha Halli [1]

[1] 
http://lists-archives.com/linux-kernel/27641303-media-update-docs-for-v4l2-fm-new-features.html

Acked-by: Hans Verkuil hans.verk...@cisco.com
Signed-off-by: Andrey Smirnov andrew.smir...@gmail.com
---
 Documentation/DocBook/media/v4l/compat.xml |3 +
 Documentation/DocBook/media/v4l/controls.xml   |   72 
 .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml   |9 +++
 3 files changed, 84 insertions(+)

diff --git a/Documentation/DocBook/media/v4l/compat.xml 
b/Documentation/DocBook/media/v4l/compat.xml
index 104a1a2..f418bc3 100644
--- a/Documentation/DocBook/media/v4l/compat.xml
+++ b/Documentation/DocBook/media/v4l/compat.xml
@@ -2310,6 +2310,9 @@ more information./para
listitem
  paraAdded FM Modulator (FM TX) Extended Control Class: 
constantV4L2_CTRL_CLASS_FM_TX/constant and their Control IDs./para
/listitem
+listitem
+ paraAdded FM Receiver (FM RX) Extended Control Class: 
constantV4L2_CTRL_CLASS_FM_RX/constant and their Control IDs./para
+   /listitem
listitem
  paraAdded Remote Controller chapter, describing the default Remote 
Controller mapping for media devices./para
/listitem
diff --git a/Documentation/DocBook/media/v4l/controls.xml 
b/Documentation/DocBook/media/v4l/controls.xml
index 1ad20cc..6aa647a 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -4687,4 +4687,76 @@ interface and may change in the future./para
   /table
 
 /section
+
+section id=fm-rx-controls
+  titleFM Receiver Control Reference/title
+
+  paraThe FM Receiver (FM_RX) class includes controls for common 
features of
+  FM Reception capable devices./para
+
+  table pgwide=1 frame=none id=fm-rx-control-id
+  titleFM_RX Control IDs/title
+
+  tgroup cols=4
+colspec colname=c1 colwidth=1* /
+colspec colname=c2 colwidth=6* /
+colspec colname=c3 colwidth=2* /
+colspec colname=c4 colwidth=6* /
+spanspec namest=c1 nameend=c2 spanname=id /
+spanspec namest=c2 nameend=c4 spanname=descr /
+thead
+  row
+entry spanname=id align=leftID/entry
+entry align=leftType/entry
+  /rowrow rowsep=1entry spanname=descr 
align=leftDescription/entry
+  /row
+/thead
+tbody valign=top
+  rowentry/entry/row
+  row
+entry 
spanname=idconstantV4L2_CID_FM_RX_CLASS/constantnbsp;/entry
+entryclass/entry
+  /rowrowentry spanname=descrThe FM_RX class
+descriptor. Calling VIDIOC-QUERYCTRL; for this control will return a
+description of this control class./entry
+  /row
+  row
+entry 
spanname=idconstantV4L2_CID_RDS_RECEPTION/constantnbsp;/entry
+entryboolean/entry
+  /rowrowentry spanname=descrEnables/disables RDS
+ reception by the radio tuner/entry
+  /row
+  row
+   entry 
spanname=idconstantV4L2_CID_TUNE_DEEMPHASIS/constantnbsp;/entry
+   entryenum v4l2_deemphasis/entry
+ /row
+ row id=v4l2-deemphasisentry spanname=descrConfigures the 
de-emphasis value for reception.
+A de-emphasis filter is applied to the broadcast to accentuate the high audio 
frequencies.
+Depending on the region, a time constant of either 50 or 75 useconds is used. 
The enumnbsp;v4l2_deemphasis
+defines possible values for de-emphasis. Here they are:/entry
+   /rowrow
+   entrytbl spanname=descr cols=2
+ tbody valign=top
+   row
+ 
entryconstantV4L2_DEEMPHASIS_DISABLED/constantnbsp;/entry
+ entryNo de-emphasis is applied./entry
+   /row
+   row
+ 
entryconstantV4L2_DEEMPHASIS_50_uS/constantnbsp;/entry
+ entryA de-emphasis of 50 uS is used./entry
+   /row
+   row
+ 
entryconstantV4L2_DEEMPHASIS_75_uS/constantnbsp;/entry
+ entryA de-emphasis of 75 uS is used./entry
+   /row
+ /tbody
+   /entrytbl
+
+ /row
+  rowentry/entry/row
+/tbody
+  /tgroup
+  /table
+
+  /section
 /section
diff --git a/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml 
b/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml
index 4e16112..b3bb957 100644
--- a/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml
@@ -319,6 +319,15 @@ These controls are described in xref
processing controls. These controls are described in xref
linkend=image-process-controls /./entry
  /row
+
+ row
+   

[PATCH v8 4/9] mfd: Add header files and Kbuild plumbing for SI476x MFD core

2013-03-26 Thread Andrey Smirnov
From: Andrey Smirnov andreysm@charmander.(none)

This patch adds all necessary header files and Kbuild plumbing for the
core driver for Silicon Laboratories Si476x series of AM/FM tuner
chips.

The driver as a whole is implemented as an MFD device and this patch
adds a core portion of it that provides all the necessary
functionality to the two other drivers that represent radio and audio
codec subsystems of the chip.

Acked-by: Hans Verkuil hans.verk...@cisco.com
Acked-by: Sam Ravnborg s...@ravnborg.org
Signed-off-by: Andrey Smirnov andrew.smir...@gmail.com
---
 drivers/mfd/Kconfig |   12 +
 drivers/mfd/Makefile|4 +
 include/linux/mfd/si476x-core.h |  525 +++
 3 files changed, 541 insertions(+)
 create mode 100644 include/linux/mfd/si476x-core.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 1c0abd4..3cd8f21 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -970,6 +970,18 @@ config MFD_WL1273_CORE
  driver connects the radio-wl1273 V4L2 module and the wl1273
  audio codec.
 
+config MFD_SI476X_CORE
+   tristate Support for Silicon Laboratories 4761/64/68 AM/FM radio.
+   depends on I2C
+   select MFD_CORE
+   help
+ This is the core driver for the SI476x series of AM/FM
+ radio. This MFD driver connects the radio-si476x V4L2 module
+ and the si476x audio codec.
+
+ To compile this driver as a module, choose M here: the
+ module will be called si476x-core.
+
 config MFD_OMAP_USB_HOST
bool Support OMAP USBHS core and TLL driver
depends on USB_EHCI_HCD_OMAP || USB_OHCI_HCD_OMAP3
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 8b977f8..ca87ae8 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -131,6 +131,10 @@ obj-$(CONFIG_MFD_JZ4740_ADC)   += jz4740-adc.o
 obj-$(CONFIG_MFD_TPS6586X) += tps6586x.o
 obj-$(CONFIG_MFD_VX855)+= vx855.o
 obj-$(CONFIG_MFD_WL1273_CORE)  += wl1273-core.o
+
+si476x-core-y := si476x-cmd.o si476x-prop.o si476x-i2c.o
+obj-$(CONFIG_MFD_SI476X_CORE)  += si476x-core.o
+
 obj-$(CONFIG_MFD_CS5535)   += cs5535-mfd.o
 obj-$(CONFIG_MFD_OMAP_USB_HOST)+= omap-usb-host.o omap-usb-tll.o
 obj-$(CONFIG_MFD_PM8921_CORE)  += pm8921-core.o
diff --git a/include/linux/mfd/si476x-core.h b/include/linux/mfd/si476x-core.h
new file mode 100644
index 000..2136b26
--- /dev/null
+++ b/include/linux/mfd/si476x-core.h
@@ -0,0 +1,525 @@
+/*
+ * include/media/si476x-core.h -- Common definitions for si476x core
+ * device
+ *
+ * Copyright (C) 2012 Innovative Converged Devices(ICD)
+ *
+ * Author: Andrey Smirnov andrey.smir...@convergeddevices.net
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#ifndef SI476X_CORE_H
+#define SI476X_CORE_H
+
+#include linux/kfifo.h
+#include linux/atomic.h
+#include linux/i2c.h
+#include linux/regmap.h
+#include linux/mutex.h
+#include linux/mfd/core.h
+#include linux/videodev2.h
+#include linux/regulator/consumer.h
+
+#include media/si476x.h
+
+/* Command Timeouts */
+#define SI476X_DEFAULT_TIMEOUT 10
+#define SI476X_TIMEOUT_TUNE70
+#define SI476X_TIMEOUT_POWER_UP33
+#define SI476X_STATUS_POLL_US  0
+
+/*  si476x-i2c.c --- */
+
+enum si476x_freq_supported_chips {
+   SI476X_CHIP_SI4761 = 1,
+   SI476X_CHIP_SI4764,
+   SI476X_CHIP_SI4768,
+};
+
+enum si476x_mfd_cells {
+   SI476X_RADIO_CELL = 0,
+   SI476X_CODEC_CELL,
+   SI476X_MFD_CELLS,
+};
+
+/**
+ * enum si476x_power_state - possible power state of the si476x
+ * device.
+ *
+ * @SI476X_POWER_DOWN: In this state all regulators are turned off
+ * and the reset line is pulled low. The device is completely
+ * inactive.
+ * @SI476X_POWER_UP_FULL: In this state all the power regualtors are
+ * turned on, reset line pulled high, IRQ line is enabled(polling is
+ * active for polling use scenario) and device is turned on with
+ * POWER_UP command. The device is ready to be used.
+ * @SI476X_POWER_INCONSISTENT: This state indicates that previous
+ * power down was inconsistent, meaning some of the regulators were
+ * not turned down and thus use of the device, without power-cycling
+ * is impossible.
+ */
+enum si476x_power_state {
+   SI476X_POWER_DOWN   = 0,
+   SI476X_POWER_UP_FULL= 1,
+   SI476X_POWER_INCONSISTENT   = 2,
+};
+
+/**
+ * struct si476x_core - internal data structure representing the
+ * underlying core device which all the MFD 

[PATCH v8 2/9] mfd: Add the main bulk of core driver for SI476x code

2013-03-26 Thread Andrey Smirnov
From: Andrey Smirnov andreysm@charmander.(none)

This patch adds main part(out of three) of the I2C driver for the
core of MFD device.

Acked-by: Hans Verkuil hans.verk...@cisco.com
Signed-off-by: Andrey Smirnov andrew.smir...@gmail.com
---
 drivers/mfd/si476x-i2c.c |  886 ++
 1 file changed, 886 insertions(+)
 create mode 100644 drivers/mfd/si476x-i2c.c

diff --git a/drivers/mfd/si476x-i2c.c b/drivers/mfd/si476x-i2c.c
new file mode 100644
index 000..118c6b1
--- /dev/null
+++ b/drivers/mfd/si476x-i2c.c
@@ -0,0 +1,886 @@
+/*
+ * drivers/mfd/si476x-i2c.c -- Core device driver for si476x MFD
+ * device
+ *
+ * Copyright (C) 2012 Innovative Converged Devices(ICD)
+ * Copyright (C) 2013 Andrey Smirnov
+ *
+ * Author: Andrey Smirnov andrew.smir...@gmail.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ */
+#include linux/module.h
+
+#include linux/slab.h
+#include linux/interrupt.h
+#include linux/delay.h
+#include linux/gpio.h
+#include linux/regulator/consumer.h
+#include linux/i2c.h
+#include linux/err.h
+
+#include linux/mfd/si476x-core.h
+
+#define SI476X_MAX_IO_ERRORS   10
+#define SI476X_DRIVER_RDS_FIFO_DEPTH   128
+
+/**
+ * si476x_core_config_pinmux() - pin function configuration function
+ *
+ * @core: Core device structure
+ *
+ * Configure the functions of the pins of the radio chip.
+ *
+ * The function returns zero in case of succes or negative error code
+ * otherwise.
+ */
+static int si476x_core_config_pinmux(struct si476x_core *core)
+{
+   int err;
+   dev_dbg(core-client-dev, Configuring pinmux\n);
+   err = si476x_core_cmd_dig_audio_pin_cfg(core,
+   core-pinmux.dclk,
+   core-pinmux.dfs,
+   core-pinmux.dout,
+   core-pinmux.xout);
+   if (err  0) {
+   dev_err(core-client-dev,
+   Failed to configure digital audio pins(err = %d)\n,
+   err);
+   return err;
+   }
+
+   err = si476x_core_cmd_zif_pin_cfg(core,
+ core-pinmux.iqclk,
+ core-pinmux.iqfs,
+ core-pinmux.iout,
+ core-pinmux.qout);
+   if (err  0) {
+   dev_err(core-client-dev,
+   Failed to configure ZIF pins(err = %d)\n,
+   err);
+   return err;
+   }
+
+   err = si476x_core_cmd_ic_link_gpo_ctl_pin_cfg(core,
+ core-pinmux.icin,
+ core-pinmux.icip,
+ core-pinmux.icon,
+ core-pinmux.icop);
+   if (err  0) {
+   dev_err(core-client-dev,
+   Failed to configure IC-Link/GPO pins(err = %d)\n,
+   err);
+   return err;
+   }
+
+   err = si476x_core_cmd_ana_audio_pin_cfg(core,
+   core-pinmux.lrout);
+   if (err  0) {
+   dev_err(core-client-dev,
+   Failed to configure analog audio pins(err = %d)\n,
+   err);
+   return err;
+   }
+
+   err = si476x_core_cmd_intb_pin_cfg(core,
+  core-pinmux.intb,
+  core-pinmux.a1);
+   if (err  0) {
+   dev_err(core-client-dev,
+   Failed to configure interrupt pins(err = %d)\n,
+   err);
+   return err;
+   }
+
+   return 0;
+}
+
+static inline void si476x_core_schedule_polling_work(struct si476x_core *core)
+{
+   schedule_delayed_work(core-status_monitor,
+ usecs_to_jiffies(SI476X_STATUS_POLL_US));
+}
+
+/**
+ * si476x_core_start() - early chip startup function
+ * @core: Core device structure
+ * @soft: When set, this flag forces soft startup, where soft
+ * power down is the one done by sending appropriate command instead
+ * of using reset pin of the tuner
+ *
+ * Perform required startup sequence to correctly power
+ * up the chip and perform initial configuration. It does the
+ * following sequence of actions:
+ *   1. Claims and enables the power 

Re: [PATCH] staging: davinci: Fix typo in staging/media/davinci

2013-03-26 Thread Prabhakar Lad
Hi Masanari,

Thanks for the patch!

On Tue, Mar 26, 2013 at 8:53 PM, Masanari Iida standby2...@gmail.com wrote:
 Correct spelling typo in staging/media/davinci

 Signed-off-by: Masanari Iida standby2...@gmail.com
 ---
  drivers/staging/media/davinci_vpfe/davinci-vpfe-mc.txt | 2 +-
  drivers/staging/media/davinci_vpfe/dm365_isif.c| 6 +++---
  drivers/staging/media/davinci_vpfe/vpfe_video.c| 8 
  drivers/staging/media/davinci_vpfe/vpfe_video.h| 2 +-
  4 files changed, 9 insertions(+), 9 deletions(-)

 diff --git a/drivers/staging/media/davinci_vpfe/davinci-vpfe-mc.txt 
 b/drivers/staging/media/davinci_vpfe/davinci-vpfe-mc.txt
 index 1dbd564..a1e9177 100644
 --- a/drivers/staging/media/davinci_vpfe/davinci-vpfe-mc.txt
 +++ b/drivers/staging/media/davinci_vpfe/davinci-vpfe-mc.txt
 @@ -38,7 +38,7 @@ interface to userspace.
 DAVINCI RESIZER A
 DAVINCI RESIZER B

 -Each possible link in the VPFE is modeled by a link in the Media controller
 +Each possible link in the VPFE is modelled by a link in the Media controller

s/modeled/modelled are one and the same. you can keep it as is.
Rest of the patch looks OK. With this change you can add my ACK.

Signed-off-by: Lad, Prabhakar prabhakar.cse...@gmail.com

Regards,
--Prabhakar

  interface. For an example program see [1].


 diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.c 
 b/drivers/staging/media/davinci_vpfe/dm365_isif.c
 index ebeea72..6d4a93c 100644
 --- a/drivers/staging/media/davinci_vpfe/dm365_isif.c
 +++ b/drivers/staging/media/davinci_vpfe/dm365_isif.c
 @@ -685,7 +685,7 @@ static void isif_config_bclamp(struct vpfe_isif_device 
 *isif,
 val = (bc-bc_mode_color  ISIF_BC_MODE_COLOR_MASK) 
 ISIF_BC_MODE_COLOR_SHIFT;

 -   /* Enable BC and horizontal clamp caculation paramaters */
 +   /* Enable BC and horizontal clamp calculation paramaters */
 val = val | 1 | ((bc-horz.mode  ISIF_HORZ_BC_MODE_MASK) 
   ISIF_HORZ_BC_MODE_SHIFT);

 @@ -722,7 +722,7 @@ static void isif_config_bclamp(struct vpfe_isif_device 
 *isif,
 isif_write(isif-isif_cfg.base_addr, val, CLHWIN2);
 }

 -   /* vertical clamp caculation paramaters */
 +   /* vertical clamp calculation paramaters */
 /* OB H Valid */
 val = bc-vert.ob_h_sz_calc  ISIF_VERT_BC_OB_H_SZ_MASK;

 @@ -1569,7 +1569,7 @@ isif_pad_set_crop(struct v4l2_subdev *sd, struct 
 v4l2_subdev_fh *fh,
 crop-rect.width = format-width;
 crop-rect.height = format-height;
 }
 -   /* adjust the width to 16 pixel boundry */
 +   /* adjust the width to 16 pixel boundary */
 crop-rect.width = ((crop-rect.width + 15)  ~0xf);
 vpfe_isif-crop = crop-rect;
 if (crop-which == V4L2_SUBDEV_FORMAT_ACTIVE) {
 diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c 
 b/drivers/staging/media/davinci_vpfe/vpfe_video.c
 index 99ccbeb..c91d356 100644
 --- a/drivers/staging/media/davinci_vpfe/vpfe_video.c
 +++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c
 @@ -357,7 +357,7 @@ static int vpfe_pipeline_disable(struct vpfe_pipeline 
 *pipe)
   *
   * Set the pipeline to the given stream state.
   *
 - * Return 0 if successfull, or the return value of the failed video::s_stream
 + * Return 0 if successful, or the return value of the failed video::s_stream
   * operation otherwise.
   */
  static int vpfe_pipeline_set_stream(struct vpfe_pipeline *pipe,
 @@ -644,7 +644,7 @@ static int vpfe_g_fmt(struct file *file, void *priv,
   * fills v4l2_fmtdesc structure with output format set on adjacent subdev,
   * only one format is enumearted as subdevs are already configured
   *
 - * Return 0 if successfull, error code otherwise
 + * Return 0 if successful, error code otherwise
   */
  static int vpfe_enum_fmt(struct file *file, void  *priv,
struct v4l2_fmtdesc *fmt)
 @@ -769,7 +769,7 @@ static int vpfe_try_fmt(struct file *file, void *priv,
   * fills v4l2_input structure with input available on media chain,
   * only one input is enumearted as media chain is setup by this time
   *
 - * Return 0 if successfull, -EINVAL is media chain is invalid
 + * Return 0 if successful, -EINVAL is media chain is invalid
   */
  static int vpfe_enum_input(struct file *file, void *priv,
  struct v4l2_input *inp)
 @@ -779,7 +779,7 @@ static int vpfe_enum_input(struct file *file, void *priv,
 struct vpfe_device *vpfe_dev = video-vpfe_dev;

 v4l2_dbg(1, debug, vpfe_dev-v4l2_dev, vpfe_enum_input\n);
 -   /* enumerate from the subdev user has choosen through mc */
 +   /* enumerate from the subdev user has chosen through mc */
 if (inp-index  sdinfo-num_inputs) {
 memcpy(inp, sdinfo-inputs[inp-index],
sizeof(struct v4l2_input));
 diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.h 
 

Re: [RFC 01/12] exynos-fimc-is: Adding device tree nodes

2013-03-26 Thread Arun Kumar K
On Wed, Mar 27, 2013 at 4:21 AM, Sylwester Nawrocki
sylvester.nawro...@gmail.com wrote:
 On 03/26/2013 01:17 PM, Arun Kumar K wrote:

 +Sensor sub-nodes:
 +
 +FIMC-IS IP supports custom built sensors to be controlled exclusively
 by
 +the FIMC-IS firmware. These sensor properties are to be defined here.


 [snip]

 Defining image sensor nodes in a standard way as ISP I2C bus controller
 nodes has an disadvantage that we need dummy I2C bus controller driver,
 at least this is how I have written the driver for Exynos4x12. In some
 version of it I had sensor nodes put in a isp-i2c fimc-is sub-node, but
 then there was an issue that this was not a fully specified I2C bus
 controller node.

 You can refer to my exynos4 fimc-is patch series for details on how this
 is now implemented.

 Handling the image sensor in a standard way, as regular I2C client
 devices
 has an advantage that we can put pinctrl properties in relevant device
 nodes,
 where available, which more closely describes the hardware structure.

 I'm not really sure in 100% if all this complication is required. It
 would
 allow to use same DT blob for different Imaging Subsystem SW
 architecture.
 For example some parts of functionality handled currently by FIMC-IS (ARM
 Cortex-A5) could be moved to host CPU, without any change in the device
 tree structure. The kernel could decide e.g. if it uses image sensor
 driver
 implemented in the ISP firmware, or a driver run on the host CPU.

 What do you think ?


 I have seen your Exynos4 FIMC-IS patchset and you have made a dummy
 I2C sensor driver there.
 That mode would work fine in Exynos4 since the sensor and ISP will be used
 by the same media controller pipeline. So the ISP component in the
 pipeline
 will ensure that the HW is initialized and sensor is working.

 But in Exynos5, we are using sensor in pipeline0 and ISP in pipeline1.
 So there is a possibility of using sensor subdev independently
 without using pipeline1 ISP components.

 So with the driver I sent, the pipeline0 can still work like this --

 ISP sensor ---  MIPI-CSIS ---  FIMC-LITE ---  Memory

 This cannot be done if a dummy I2C driver is made for ISP sensor.


 Why not ? I'm not sure what the problem is here.

 I realize that describing image sensors in DT as standard I2C slave devices
 is not helpful with current firmware architecture. It adds some unnecessary
 complication, OTOH it could simplify the sensors registration and media
 graph
 initialization code, by unifying it for the firmware based ISP specific
 sensors and the external ones with a built-in ISP. Also we could avoid
 having
 the bindings defined by current architecture of the driver.

 Nevertheless, coming back to your question, the I2C controller driver would
 be in same module as the FIMC-IS driver. From user space perspective nothing
 changes when you add I2C bus driver and register the sensor in a standard
 way.
 What exactly couldn't be done in the kernel ?


Only issue is with the context sharing.
Right now you can see that the fimc-is context is shared between all
the subdevs.
As all of them are part of the same driver, it is possible.
If sensor is made as an independent i2c device, a separate probe will
be called for it.
For ISP sensor subdev to work independently, it needs to call the
fimc_is_pipeline_* calls
for FW initialization and other configurations for which it needs the
fimc-is main context.

Now there is a workaround here by calling a get_context() macro in
sensor's probe
to get the fimc-is context. This will cause the same context to be
shared and updated by
2 drivers though both are part of fimc-is.
Is this acceptable? Or am I missing some other simple solution of implementing
it in a better way?

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