Re: [PATCH RFC v3] media: OF: add video sync endpoint property

2013-06-24 Thread Hans Verkuil
Hi Prabhakar,

On Sat June 22 2013 17:03:03 Prabhakar Lad wrote:
 From: Lad, Prabhakar prabhakar.cse...@gmail.com
 
 This patch adds video sync properties as part of endpoint
 properties and also support to parse them in the parser.
 
 Signed-off-by: Lad, Prabhakar prabhakar.cse...@gmail.com
 Cc: Hans Verkuil hans.verk...@cisco.com

FYI: using my private email when CC-ing me generally works better.
I often skip v4l2-related emails to my work address since I assume those
have either been CC-ed to my private email and/or linux-media.

I wondered why I never saw RFC v1/2, now I know :-)

 Cc: Laurent Pinchart laurent.pinch...@ideasonboard.com
 Cc: Mauro Carvalho Chehab mche...@redhat.com
 Cc: Guennadi Liakhovetski g.liakhovet...@gmx.de
 Cc: Sylwester Nawrocki s.nawro...@samsung.com
 Cc: Sakari Ailus sakari.ai...@iki.fi
 Cc: Grant Likely grant.lik...@secretlab.ca
 Cc: Rob Herring rob.herr...@calxeda.com
 Cc: Rob Landley r...@landley.net
 Cc: devicetree-discuss@lists.ozlabs.org
 Cc: linux-...@vger.kernel.org
 Cc: linux-ker...@vger.kernel.org
 Cc: davinci-linux-open-sou...@linux.davincidsp.com
 Cc: Kyungmin Park kyungmin.p...@samsung.com
 ---
  This patch has 10 warnings for line over 80 characters
  for which I think can be ignored.
  
  RFC v2 https://patchwork.kernel.org/patch/2578091/
  RFC V1 https://patchwork.kernel.org/patch/2572341/
  Changes for v3:
  1: Fixed review comments pointed by Laurent and Sylwester.
  
  .../devicetree/bindings/media/video-interfaces.txt |1 +
  drivers/media/v4l2-core/v4l2-of.c  |   20 ++
  include/dt-bindings/media/video-interfaces.h   |   17 +++
  include/media/v4l2-mediabus.h  |   22 
 +++-
  4 files changed, 50 insertions(+), 10 deletions(-)
  create mode 100644 include/dt-bindings/media/video-interfaces.h
 
 diff --git a/Documentation/devicetree/bindings/media/video-interfaces.txt 
 b/Documentation/devicetree/bindings/media/video-interfaces.txt
 index e022d2d..2081278 100644
 --- a/Documentation/devicetree/bindings/media/video-interfaces.txt
 +++ b/Documentation/devicetree/bindings/media/video-interfaces.txt
 @@ -101,6 +101,7 @@ Optional endpoint properties
array contains only one entry.
  - clock-noncontinuous: a boolean property to allow MIPI CSI-2 non-continuous
clock mode.
 +- video-sync: property indicating to sync the video on a signal in RGB.

Please document what the various syncs actually mean.

  
  
  Example
 diff --git a/drivers/media/v4l2-core/v4l2-of.c 
 b/drivers/media/v4l2-core/v4l2-of.c
 index aa59639..1a54530 100644
 --- a/drivers/media/v4l2-core/v4l2-of.c
 +++ b/drivers/media/v4l2-core/v4l2-of.c
 @@ -100,6 +100,26 @@ static void v4l2_of_parse_parallel_bus(const struct 
 device_node *node,
   if (!of_property_read_u32(node, data-shift, v))
   bus-data_shift = v;
  
 + if (!of_property_read_u32(node, video-sync, v)) {
 + switch (v) {
 + case V4L2_MBUS_VIDEO_SEPARATE_SYNC:
 + flags |= V4L2_MBUS_VIDEO_SEPARATE_SYNC;
 + break;
 + case V4L2_MBUS_VIDEO_COMPOSITE_SYNC:
 + flags |= V4L2_MBUS_VIDEO_COMPOSITE_SYNC;
 + break;
 + case V4L2_MBUS_VIDEO_SYNC_ON_COMPOSITE:
 + flags |= V4L2_MBUS_VIDEO_SYNC_ON_COMPOSITE;
 + break;
 + case V4L2_MBUS_VIDEO_SYNC_ON_GREEN:
 + flags |= V4L2_MBUS_VIDEO_SYNC_ON_GREEN;
 + break;
 + case V4L2_MBUS_VIDEO_SYNC_ON_LUMINANCE:
 + flags |= V4L2_MBUS_VIDEO_SYNC_ON_LUMINANCE;
 + break;
 + }
 + }
 +
   bus-flags = flags;
  
  }
 diff --git a/include/dt-bindings/media/video-interfaces.h 
 b/include/dt-bindings/media/video-interfaces.h
 new file mode 100644
 index 000..1a083dd
 --- /dev/null
 +++ b/include/dt-bindings/media/video-interfaces.h
 @@ -0,0 +1,17 @@
 +/*
 + * This header provides constants for video interface.
 + *
 + */
 +
 +#ifndef _DT_BINDINGS_VIDEO_INTERFACES_H
 +#define _DT_BINDINGS_VIDEO_INTERFACES_H
 +
 +#define V4L2_MBUS_VIDEO_SEPARATE_SYNC(1  2)
 +#define V4L2_MBUS_VIDEO_COMPOSITE_SYNC   (1  3)
 +#define V4L2_MBUS_VIDEO_SYNC_ON_COMPOSITE(1  4)

What on earth is the difference between COMPOSITE_SYNC and 
SYNC_ON_COMPOSITE?!

 +#define V4L2_MBUS_VIDEO_SYNC_ON_GREEN(1  5)
 +#define V4L2_MBUS_VIDEO_SYNC_ON_LUMINANCE(1  6)
 +
 +#define V4L2_MBUS_VIDEO_INTERFACES_END   6
 +
 +#endif

Why would this be here? It isn't Device Tree specific, the same defines can
be used without DT as well.

 diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
 index 83ae07e..a4676dd 100644
 --- a/include/media/v4l2-mediabus.h
 +++ b/include/media/v4l2-mediabus.h
 @@ -11,6 +11,8 @@
  #ifndef V4L2_MEDIABUS_H
  #define V4L2_MEDIABUS_H
  
 +#include dt-bindings

Re: [PATCH v3] media: i2c: tvp514x: add OF support

2013-05-23 Thread Hans Verkuil
On Tue 14 May 2013 13:00:36 Lad Prabhakar wrote:
 From: Lad, Prabhakar prabhakar.cse...@gmail.com
 
 add OF support for the tvp514x driver. Alongside this patch
 removes unnecessary header file inclusion and sorts them alphabetically.
 
 Signed-off-by: Lad, Prabhakar prabhakar.cse...@gmail.com
 Cc: Hans Verkuil hans.verk...@cisco.com
 Cc: Laurent Pinchart laurent.pinch...@ideasonboard.com
 Cc: Mauro Carvalho Chehab mche...@redhat.com
 Cc: Guennadi Liakhovetski g.liakhovet...@gmx.de
 Cc: Sylwester Nawrocki s.nawro...@samsung.com
 Cc: Sakari Ailus sakari.ai...@iki.fi
 Cc: Grant Likely grant.lik...@secretlab.ca
 Cc: Rob Herring rob.herr...@calxeda.com
 Cc: Rob Landley r...@landley.net
 Cc: devicetree-discuss@lists.ozlabs.org
 Cc: linux-...@vger.kernel.org
 Cc: linux-ker...@vger.kernel.org
 Cc: davinci-linux-open-sou...@linux.davincidsp.com
 ---
 Tested on da850-evm.
 
  RFC v1: https://patchwork.kernel.org/patch/2030061/
  RFC v2: https://patchwork.kernel.org/patch/2061811/
 
  Changes for current version from RFC v2:
  1: Fixed review comments pointed by Sylwester.
 
  Changes for v2:
  1: Listed all the compatible property values in the documentation text file.
  2: Removed -decoder from compatible property values.
  3: Added a reference to the V4L2 DT bindings documentation to explain
 what the port and endpoint nodes are for.
  4: Fixed some Nits pointed by Laurent.
  5: Removed unnecessary header file includes and sort them alphabetically.
 
  Changes for v3:
  1: Rebased on patch https://patchwork.kernel.org/patch/2539411/
 
  .../devicetree/bindings/media/i2c/tvp514x.txt  |   45 
  drivers/media/i2c/tvp514x.c|   74 +++
  2 files changed, 103 insertions(+), 16 deletions(-)
  create mode 100644 Documentation/devicetree/bindings/media/i2c/tvp514x.txt
 
 diff --git a/Documentation/devicetree/bindings/media/i2c/tvp514x.txt 
 b/Documentation/devicetree/bindings/media/i2c/tvp514x.txt
 new file mode 100644
 index 000..cc09424
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/media/i2c/tvp514x.txt
 @@ -0,0 +1,45 @@
 +* Texas Instruments TVP514x video decoder
 +
 +The TVP5146/TVP5146m2/TVP5147/TVP5147m1 device is high quality, single-chip
 +digital video decoder that digitizes and decodes all popular baseband analog
 +video formats into digital video component. The tvp514x decoder supports 
 analog-
 +to-digital (A/D) conversion of component RGB and YPbPr signals as well as A/D
 +conversion and decoding of NTSC, PAL and SECAM composite and S-video into
 +component YCbCr.
 +
 +Required Properties :
 +- compatible : value should be either one among the following
 + (a) ti,tvp5146 for tvp5146 decoder.
 + (b) ti,tvp5146m2 for tvp5146m2 decoder.
 + (c) ti,tvp5147 for tvp5147 decoder.
 + (d) ti,tvp5147m1 for tvp5147m1 decoder.
 +
 +- hsync-active: HSYNC Polarity configuration for endpoint.
 +
 +- vsync-active: VSYNC Polarity configuration for endpoint.
 +
 +- pclk-sample: Clock polarity of the endpoint.
 +
 +
 +For further reading of port node refer 
 Documentation/devicetree/bindings/media/
 +video-interfaces.txt.
 +
 +Example:
 +
 + i2c0@1c22000 {
 + ...
 + ...
 + tvp514x@5c {
 + compatible = ti,tvp5146;
 + reg = 0x5c;
 +
 + port {
 + tvp514x_1: endpoint {
 + hsync-active = 1;
 + vsync-active = 1;
 + pclk-sample = 0;
 + };
 + };
 + };
 + ...
 + };
 diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c
 index 01d9757..202c8cb 100644
 --- a/drivers/media/i2c/tvp514x.c
 +++ b/drivers/media/i2c/tvp514x.c
 @@ -29,21 +29,16 @@
   *
   */
  
 -#include linux/i2c.h
 -#include linux/slab.h
  #include linux/delay.h
 -#include linux/videodev2.h
 +#include linux/i2c.h
  #include linux/module.h
 -#include linux/v4l2-mediabus.h
  
 +#include media/media-entity.h
 +#include media/tvp514x.h
  #include media/v4l2-async.h
 -#include media/v4l2-device.h
 -#include media/v4l2-common.h
 -#include media/v4l2-mediabus.h
 -#include media/v4l2-chip-ident.h
  #include media/v4l2-ctrls.h
 -#include media/tvp514x.h
 -#include media/media-entity.h
 +#include media/v4l2-device.h
 +#include media/v4l2-of.h

Same issue as with other patches: be careful about removing headers, i.e. don't
rely on them being included in other headers. If you use something from a 
header,
then just include it.

Regards,

Hans

  
  #include tvp514x_regs.h
  
 @@ -1056,6 +1051,40 @@ static struct tvp514x_decoder tvp514x_dev = {
  
  };
  
 +static struct tvp514x_platform_data *
 +tvp514x_get_pdata(struct i2c_client *client)
 +{
 + struct tvp514x_platform_data *pdata;
 + struct v4l2_of_endpoint bus_cfg;
 + struct device_node *endpoint

Re: [RFC PATCH 5/8] s5p-fimc: Add ISP video capture driver stubs

2013-03-18 Thread Hans Verkuil
On Sun March 17 2013 22:03:38 Sylwester Nawrocki wrote:
 On 03/12/2013 03:44 PM, Hans Verkuil wrote:
  On Mon 11 March 2013 20:44:49 Sylwester Nawrocki wrote:
 [...]
  +static int isp_video_capture_open(struct file *file)
  +{
  +  struct fimc_isp *isp = video_drvdata(file);
  +  int ret = 0;
  +
  +  if (mutex_lock_interruptible(isp-video_lock))
  +  return -ERESTARTSYS;
  +
  +  /* ret = pm_runtime_get_sync(isp-pdev-dev); */
  +  if (ret  0)
  +  goto done;
  +
  +  ret = v4l2_fh_open(file);
  +  if (ret  0)
  +  goto done;
  +
  +  /* TODO: prepare video pipeline */
  +done:
  +  mutex_unlock(isp-video_lock);
  +  return ret;
  +}
  +
  +static int isp_video_capture_close(struct file *file)
  +{
  +  struct fimc_isp *isp = video_drvdata(file);
  +  int ret = 0;
  +
  +  mutex_lock(isp-video_lock);
  +
  +  if (isp-out_path == FIMC_IO_DMA) {
  +  /* TODO: stop capture, cleanup */
  +  }
  +
  +  /* pm_runtime_put(isp-pdev-dev); */
  +
  +  if (isp-ref_count == 0)
  +  vb2_queue_release(isp-capture_vb_queue);
  +
  +  ret = v4l2_fh_release(file);
  +
  +  mutex_unlock(isp-video_lock);
  +  return ret;
  +}
  +
  +static unsigned int isp_video_capture_poll(struct file *file,
  + struct poll_table_struct *wait)
  +{
  +  struct fimc_isp *isp = video_drvdata(file);
  +  int ret;
  +
  +  mutex_lock(isp-video_lock);
  +  ret = vb2_poll(isp-capture_vb_queue, file, wait);
  +  mutex_unlock(isp-video_lock);
  +  return ret;
  +}
  +
  +static int isp_video_capture_mmap(struct file *file, struct 
  vm_area_struct *vma)
  +{
  +  struct fimc_isp *isp = video_drvdata(file);
  +  int ret;
  +
  +  if (mutex_lock_interruptible(isp-video_lock))
  +  return -ERESTARTSYS;
  +
  +  ret = vb2_mmap(isp-capture_vb_queue, vma);
  +  mutex_unlock(isp-video_lock);
  +
  +  return ret;
  +}
  +
  +static const struct v4l2_file_operations isp_video_capture_fops = {
  +  .owner  = THIS_MODULE,
  +  .open   = isp_video_capture_open,
  +  .release= isp_video_capture_close,
  +  .poll   = isp_video_capture_poll,
  +  .unlocked_ioctl = video_ioctl2,
  +  .mmap   = isp_video_capture_mmap,
 
  Can't you use the helper functions vb2_fop_open/release/poll/mmap here?
 
 It seems vb2_fop_mmap/poll can be used directly, open(), release() are
 a bit more complicated as some media pipeline operations need to
 additionally be done within these callbacks. There is no vb2_fop_open(),
 and AFAICS v4l2_fh_open() is sufficient and intended as open() helper.

That's correct. Sorry for the misinformation about the non-existant
vb2_fop_open.

 For the next iteration I have used vb2_fop_release(), called indirectly,
 as it nicely simplifies things a bit.
 
 BTW, shouldn't vb2_fop_release() also be taking the lock ? Actually it is
 more useful for me in current form, but the drivers that directly assign
 it to struct v4l2_file_operations::open might be in trouble, unless I'm
 missing something.

I don't see where a lock would be needed. I don't see any concurrency here.
Nobody else can mess with the queue as long as they are not the owner.

 
  +};
  +
  +/*
  + * Video node ioctl operations
  + */
 [...]
  +static int fimc_isp_capture_streamon(struct file *file, void *priv,
  +   enum v4l2_buf_type type)
  +{
  +  struct fimc_isp *isp = video_drvdata(file);
  +  struct v4l2_subdev *sensor = isp-pipeline.subdevs[IDX_SENSOR];
  +  struct fimc_pipeline *p =isp-pipeline;
  +  int ret;
  +
  +  /* TODO: check if the OTF interface is not running */
  +
  +  ret = media_entity_pipeline_start(sensor-entity, p-m_pipeline);
  +  if (ret  0)
  +  return ret;
  +
  +  ret = fimc_isp_pipeline_validate(isp);
  +  if (ret) {
  +  media_entity_pipeline_stop(sensor-entity);
  +  return ret;
  +  }
  +
  +  return vb2_streamon(isp-capture_vb_queue, type);
  +}
  +
  +static int fimc_isp_capture_streamoff(struct file *file, void *priv,
  +enum v4l2_buf_type type)
  +{
  +  struct fimc_isp *isp = video_drvdata(file);
  +  struct v4l2_subdev *sd = isp-pipeline.subdevs[IDX_SENSOR];
  +  int ret;
  +
  +  ret = vb2_streamoff(isp-capture_vb_queue, type);
  +  if (ret == 0)
  +  media_entity_pipeline_stop(sd-entity);
  +  return ret;
  +}
  +
  +static int fimc_isp_capture_reqbufs(struct file *file, void *priv,
  +  struct v4l2_requestbuffers *reqbufs)
  +{
  +  struct fimc_isp *isp = video_drvdata(file);
  +  int ret;
  +
  +  reqbufs-count = max_t(u32, FIMC_IS_REQ_BUFS_MIN, reqbufs-count);
  +  ret = vb2_reqbufs(isp-capture_vb_queue, reqbufs);
 
  You probably want to call vb2_ioctl_reqbufs here since that does additional
  ownership checks that vb2_reqbufs doesn't.
 
 Yes, thanks for the suggestion. That was actually helpful, previously
 it wasn't immediately clear to me one can still take advantage of those
 vb2_ioctl_* helpers, mainly have

Re: [RFC PATCH 1/8] s5p-fimc: Add Exynos4x12 FIMC-IS driver

2013-03-12 Thread Hans Verkuil
On Mon 11 March 2013 20:44:45 Sylwester Nawrocki wrote:
 This patch adds a set of core files of the Exynos4x12 FIMC-IS
 V4L2 driver. This includes main functionality like allocating
 memory, loading the firmware, FIMC-IS register interface and
 host CPU - IS command and error code definitions.
 
 The driver currently exposes a single subdev named FIMC-IS-ISP,
 which corresponds to the FIMC-IS ISP and DRC IP blocks.
 
 The FIMC-IS-ISP subdev currently supports only a subset of user
 controls. For other controls we need several extensions at the
 V4L2 API. The supported standard controls are:
 brightness, contrast, saturation, hue, sharpness, 3a_lock,
 exposure_time_absolute, white_balance_auto_preset,
 iso_sensitivity, iso_sensitivity_auto, exposure_metering_mode.
 Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
 ---

snip most of the patch

 +
 +/* Supported manual ISO values */
 +static const s64 iso_qmenu[] = {
 + 50, 100, 200, 400, 800,
 +};
 +
 +static int __ctrl_set_iso(struct fimc_is *is, int value)
 +{
 + unsigned int idx, iso;
 +
 + if (value == V4L2_ISO_SENSITIVITY_AUTO) {
 + __is_set_isp_iso(is, ISP_ISO_COMMAND_AUTO, 0);
 + return 0;
 + }
 + idx = is-isp.ctrls.iso-val;
 + if (idx = ARRAY_SIZE(iso_qmenu))
 + return -EINVAL;
 +
 + iso = iso_qmenu[idx];
 + __is_set_isp_iso(is, ISP_ISO_COMMAND_MANUAL, iso);
 + return 0;
 +}
 +
 +static int __ctrl_set_metering(struct fimc_is *is, unsigned int value)
 +{
 + unsigned int val;
 +
 + switch (value) {
 + case V4L2_EXPOSURE_METERING_AVERAGE:
 + val = ISP_METERING_COMMAND_AVERAGE;
 + break;
 + case V4L2_EXPOSURE_METERING_CENTER_WEIGHTED:
 + val = ISP_METERING_COMMAND_CENTER;
 + break;
 + case V4L2_EXPOSURE_METERING_SPOT:
 + val = ISP_METERING_COMMAND_SPOT;
 + break;
 + case V4L2_EXPOSURE_METERING_MATRIX:
 + val = ISP_METERING_COMMAND_MATRIX;
 + break;
 + default:
 + return -EINVAL;
 + };
 +
 + __is_set_isp_metering(is, IS_METERING_CONFIG_CMD, val);
 + return 0;
 +}
 +
 +static int __ctrl_set_afc(struct fimc_is *is, int value)
 +{
 + switch (value) {
 + case V4L2_CID_POWER_LINE_FREQUENCY_DISABLED:
 + __is_set_isp_afc(is, ISP_AFC_COMMAND_DISABLE, 0);
 + break;
 + case V4L2_CID_POWER_LINE_FREQUENCY_50HZ:
 + __is_set_isp_afc(is, ISP_AFC_COMMAND_MANUAL, 50);
 + break;
 + case V4L2_CID_POWER_LINE_FREQUENCY_60HZ:
 + __is_set_isp_afc(is, ISP_AFC_COMMAND_MANUAL, 60);
 + break;
 + case V4L2_CID_POWER_LINE_FREQUENCY_AUTO:
 + __is_set_isp_afc(is, ISP_AFC_COMMAND_AUTO, 0);
 + break;
 + default:
 + return -EINVAL;
 + }
 +
 + return 0;
 +}
 +
 +#if 0
 +static int __ctrl_set_flash_mode(struct fimc_is *is, int value)
 +{
 + switch (value) {
 + case IS_FLASH_MODE_OFF:
 + __is_set_isp_flash(is, ISP_FLASH_COMMAND_DISABLE, 0);
 + break;
 + case IS_FLASH_MODE_AUTO:
 + __is_set_isp_flash(is, ISP_FLASH_COMMAND_AUTO, 0);
 + break;
 + case IS_FLASH_MODE_AUTO_REDEYE:
 + __is_set_isp_flash(is, ISP_FLASH_COMMAND_AUTO, 1);
 + break;
 + case IS_FLASH_MODE_ON:
 + __is_set_isp_flash(is, ISP_FLASH_COMMAND_MANUALON, 0);
 + break;
 + case IS_FLASH_MODE_TORCH:
 + __is_set_isp_flash(is, ISP_FLASH_COMMAND_TORCH, 0);
 + break;
 + default:
 + return -EINVAL;
 + }
 +
 + return 0;
 +}
 +#endif
 +
 +static int __ctrl_set_image_effect(struct fimc_is *is, int value)
 +{
 + /* FIXME: */
 + __is_set_isp_effect(is, value);
 + return 0;
 +}
 +
 +static int fimc_is_s_ctrl(struct v4l2_ctrl *ctrl)
 +{
 + struct fimc_isp *isp = ctrl_to_fimc_isp(ctrl);
 + struct fimc_is *is = fimc_isp_to_is(isp);
 + bool set_param = true;
 + int ret = 0;
 +
 + switch (ctrl-id) {
 + case V4L2_CID_CONTRAST:
 + __is_set_isp_adjust(is, ISP_ADJUST_COMMAND_MANUAL_CONTRAST,
 + ctrl-val);
 + break;
 +
 + case V4L2_CID_SATURATION:
 + __is_set_isp_adjust(is, ISP_ADJUST_COMMAND_MANUAL_SATURATION,
 + ctrl-val);
 + break;
 +
 + case V4L2_CID_SHARPNESS:
 + __is_set_isp_adjust(is, ISP_ADJUST_COMMAND_MANUAL_SHARPNESS,
 + ctrl-val);
 + break;
 +
 + case V4L2_CID_EXPOSURE_ABSOLUTE:
 + __is_set_isp_adjust(is, ISP_ADJUST_COMMAND_MANUAL_EXPOSURE,
 + ctrl-val);
 + break;
 +
 + case V4L2_CID_BRIGHTNESS:
 + __is_set_isp_adjust(is, ISP_ADJUST_COMMAND_MANUAL_BRIGHTNESS,
 +  

Re: [RFC PATCH 5/8] s5p-fimc: Add ISP video capture driver stubs

2013-03-12 Thread Hans Verkuil
On Mon 11 March 2013 20:44:49 Sylwester Nawrocki wrote:
 This patch adds a video capture node for the FIMC-IS ISP IP block
 and Makefile/Kconfig to actually enable the driver's compilation.
 
 The ISP video capture driver is still a work in progress.
 
 Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
 ---
  drivers/media/platform/s5p-fimc/Kconfig  |   13 +
  drivers/media/platform/s5p-fimc/Makefile |4 +
  drivers/media/platform/s5p-fimc/fimc-isp-video.c |  414 
 ++
  drivers/media/platform/s5p-fimc/fimc-isp-video.h |   50 +++
  4 files changed, 481 insertions(+)
  create mode 100644 drivers/media/platform/s5p-fimc/fimc-isp-video.c
  create mode 100644 drivers/media/platform/s5p-fimc/fimc-isp-video.h
 
 diff --git a/drivers/media/platform/s5p-fimc/Kconfig 
 b/drivers/media/platform/s5p-fimc/Kconfig
 index c16b20d..1253e25 100644
 --- a/drivers/media/platform/s5p-fimc/Kconfig
 +++ b/drivers/media/platform/s5p-fimc/Kconfig
 @@ -46,4 +46,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 FIMC-IS
 +   (Imaging Subsystem).
 +
 +   To compile this driver as a module, choose M here: the
 +   module will be called exynos-fimc-is.
 +endif
 +
  endif # VIDEO_SAMSUNG_S5P_FIMC
 diff --git a/drivers/media/platform/s5p-fimc/Makefile 
 b/drivers/media/platform/s5p-fimc/Makefile
 index 4648514..55b171a 100644
 --- a/drivers/media/platform/s5p-fimc/Makefile
 +++ b/drivers/media/platform/s5p-fimc/Makefile
 @@ -1,7 +1,11 @@
  s5p-fimc-objs := fimc-core.o fimc-reg.o fimc-m2m.o fimc-capture.o 
 fimc-mdevice.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
 +exynos-fimc-is-objs += fimc-isp-video.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/s5p-fimc/fimc-isp-video.c 
 b/drivers/media/platform/s5p-fimc/fimc-isp-video.c
 new file mode 100644
 index 000..bdeacaa
 --- /dev/null
 +++ b/drivers/media/platform/s5p-fimc/fimc-isp-video.c
 @@ -0,0 +1,414 @@
 +/*
 + * Samsung EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver
 + *
 + * Copyright (C) 2013 Samsung Electronics Co., Ltd.
 + * Author: 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/device.h
 +#include linux/delay.h
 +#include linux/errno.h
 +#include linux/kernel.h
 +#include linux/module.h
 +#include linux/types.h
 +#include linux/printk.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/videobuf2-core.h
 +#include media/videobuf2-dma-contig.h
 +
 +#include fimc-mdevice.h
 +#include fimc-core.h
 +#include fimc-is.h
 +
 +static int isp_video_capture_start_streaming(struct vb2_queue *q,
 + unsigned int count)
 +{
 + /* TODO: start ISP output DMA */
 + return 0;
 +}
 +
 +static int isp_video_capture_stop_streaming(struct vb2_queue *q)
 +{
 + /* TODO: stop ISP output DMA */
 + return 0;
 +}
 +
 +static int isp_video_capture_queue_setup(struct vb2_queue *vq,
 + const struct v4l2_format *pfmt,
 + unsigned int *num_buffers, unsigned int *num_planes,
 + unsigned int sizes[], void *allocators[])
 +{
 + const struct v4l2_pix_format_mplane *pixm = NULL;
 + struct fimc_isp *isp = vq-drv_priv;
 + struct fimc_isp_frame *frame = isp-out_frame;
 + const struct fimc_fmt *fmt = isp-video_capture_format;
 + unsigned long wh;
 + int i;
 +
 + if (pfmt) {
 + pixm = pfmt-fmt.pix_mp;
 + fmt = fimc_isp_find_format(pixm-pixelformat, NULL, -1);
 + wh = pixm-width * pixm-height;
 + } else {
 + wh = frame-f_width * frame-f_height;
 + }
 +
 + if (fmt == NULL)
 + return -EINVAL;
 +
 + *num_planes = fmt-memplanes;
 +
 + for (i = 0; i  fmt-memplanes; i++) {
 + unsigned int size = (wh * fmt-depth[i]) / 8;
 + if (pixm)
 + sizes[i] = max(size, pixm-plane_fmt[i].sizeimage);
 + else
 +   

Re: [PATCH RFC v3 02/15] [media] Add a V4L2 OF parser

2013-02-03 Thread Hans Verkuil
On Fri January 18 2013 16:48:43 Sylwester Nawrocki wrote:
 On 01/03/2013 06:09 PM, Sylwester Nawrocki wrote:
  From: Guennadi Liakhovetski g.liakhovet...@gmx.de
  
  Add a V4L2 OF parser, implementing bindings documented in
  Documentation/devicetree/bindings/media/video-interfaces.txt.
  
  Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
  Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
 
 Hans, Laurent, Mauro, would you have any comments on this ?
 Anything that needs to be changed/improved ?

I'll review this on Monday.

Regards,

Hans
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH RFC v3 01/15] [media] Add common video interfaces OF bindings documentation

2013-02-03 Thread Hans Verkuil
On Thu January 3 2013 18:03:49 Sylwester Nawrocki wrote:
 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 like 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
 Reviewed-by: Stephen Warren swar...@nvidia.com
 Acked-by: Rob Herring rob.herr...@calxeda.com

As promised, here is my review:

 ---
 
 Changes since v2:
 
  - corrected pclk-sample property definition,
  - s/buses/busses,
  - whitespace changes.
 
  .../devicetree/bindings/media/video-interfaces.txt |  199 
 
  1 file changed, 199 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..9e9e95a
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/media/video-interfaces.txt
 @@ -0,1 +1,199 @@
 +Common bindings for video data 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.
 +
 +dev {
 + #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 other 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, a common scheme, using '#address-cells', '#size-cells' and 'reg' 
 properties
 +is used.
 +
 +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 the 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.
 +
 +Required properties
 +---
 +
 +If there is more than one 'port' or more than one 'endpoint' node following
 +properties are required in relevant parent node:
 +
 +- #address-cells : number of cells required to define port number, should be 
 1.
 +- #size-cells: should be zero.
 +
 +Optional endpoint properties
 +
 +
 +- remote-endpoint: phandle to an 'endpoint' subnode of the other device node.
 +- slave-mode: a boolean property, run the link in slave mode. Default is 
 master
 +  mode.
 +- bus-width: number of data lines, valid for parallel busses.
 +- data-shift: on parallel data busses, if bus-width is used to specify the
 +  number of data lines, data-shift can be used to specify which data lines 
 are
 +  used, e.g. bus-width=10; data-shift=2; means, that lines 9:2 are 
 used.
 +- hsync-active: active state of HSYNC signal, 0/1 for LOW/HIGH respectively.
 +- vsync-active: active state of VSYNC signal, 0/1 for LOW/HIGH respectively.
 +  Note, that if HSYNC and VSYNC polarities are not specified, embedded
 +  synchronization may be required, where supported.
 +- data-active: similar to HSYNC and VSYNC, specifies data line polarity.
 +- field-even-active: field signal level during the even field data 
 transmission.
 +- pclk-sample: sample data on rising (1) or falling (0) edge of the pixel 
 clock
 +  signal.
 +- data-lanes: an array of physical data lane indexes. Position of an entry
 +  determines logical lane number, while the value of an entry indicates 
 physical
 +  lane, e.g. for 2-lane MIPI CSI-2 bus we could have data-lanes = 1, 
 2;,
 +  assuming the clock lane is on hardware lane 0. This property is valid for
 +  serial busses only (e.g. MIPI CSI-2).
 +- clock-lanes: a number of physical lane used as a clock lane.

This doesn't parse. Do you mean:

a number of physical lanes used as clock lanes.?

 +- clock-noncontinuous: a boolean property to allow MIPI CSI-2 

Re: [PATCH RFC v3 02/15] [media] Add a V4L2 OF parser

2013-02-03 Thread Hans Verkuil
Hi Sylwester,

Just two comments...

On Thu January 3 2013 18:09:22 Sylwester Nawrocki wrote:
 From: Guennadi Liakhovetski g.liakhovet...@gmx.de
 
 Add a V4L2 OF parser, implementing bindings documented in
 Documentation/devicetree/bindings/media/video-interfaces.txt.
 
 Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
 Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
 ---
 Changes since v2:
  - added missing EXPORT_SYMBOL for v4l2_of_parse_mipi_csi2()
and v4l2_of_parse_parallel_bus() functions,
  - include string.h header instead of slab.h.
 
  drivers/media/v4l2-core/Makefile  |3 +
  drivers/media/v4l2-core/v4l2-of.c |  251 
 +
  include/media/v4l2-of.h   |   79 
  3 files changed, 333 insertions(+)
  create mode 100644 drivers/media/v4l2-core/v4l2-of.c
  create mode 100644 include/media/v4l2-of.h
 
 diff --git a/drivers/media/v4l2-core/Makefile 
 b/drivers/media/v4l2-core/Makefile
 index c2d61d4..00f64d6 100644
 --- a/drivers/media/v4l2-core/Makefile
 +++ b/drivers/media/v4l2-core/Makefile
 @@ -9,6 +9,9 @@ videodev-objs :=  v4l2-dev.o v4l2-ioctl.o v4l2-device.o 
 v4l2-fh.o \
  ifeq ($(CONFIG_COMPAT),y)
videodev-objs += v4l2-compat-ioctl32.o
  endif
 +ifeq ($(CONFIG_OF),y)
 +  videodev-objs += v4l2-of.o
 +endif
 
  obj-$(CONFIG_VIDEO_DEV) += videodev.o v4l2-int-device.o
  obj-$(CONFIG_VIDEO_V4L2) += v4l2-common.o
 diff --git a/drivers/media/v4l2-core/v4l2-of.c 
 b/drivers/media/v4l2-core/v4l2-of.c
 new file mode 100644
 index 000..483245c
 --- /dev/null
 +++ b/drivers/media/v4l2-core/v4l2-of.c
 @@ -0,0 +1,251 @@
 +/*
 + * V4L2 OF binding parsing library
 + *
 + * Copyright (C) 2012 Renesas Electronics Corp.
 + * Author: Guennadi Liakhovetski g.liakhovet...@gmx.de
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of version 2 of the GNU General Public License as
 + * published by the Free Software Foundation.
 + */
 +#include linux/kernel.h
 +#include linux/module.h
 +#include linux/of.h
 +#include linux/string.h
 +#include linux/types.h
 +
 +#include media/v4l2-of.h
 +
 +/**
 + * v4l2_of_parse_mipi_csi2() - parse MIPI CSI-2 bus properties
 + * @node: pointer to endpoint device_node
 + * @endpoint: pointer to v4l2_of_endpoint data structure
 + *
 + * Return: 0 on success or negative error value otherwise.
 + */
 +int v4l2_of_parse_mipi_csi2(const struct device_node *node,
 + struct v4l2_of_endpoint *endpoint)
 +{
 + struct v4l2_of_mipi_csi2 *mipi_csi2 = endpoint-mipi_csi_2;
 + u32 data_lanes[ARRAY_SIZE(mipi_csi2-data_lanes)];
 + struct property *prop;
 + const __be32 *lane = NULL;
 + u32 v;
 + int i = 0;
 +
 + prop = of_find_property(node, data-lanes, NULL);
 + if (!prop)
 + return -EINVAL;
 + do {
 + lane = of_prop_next_u32(prop, lane, data_lanes[i]);
 + } while (lane  i++  ARRAY_SIZE(data_lanes));
 +
 + mipi_csi2-num_data_lanes = i;
 + while (i--)
 + mipi_csi2-data_lanes[i] = data_lanes[i];
 +
 + if (!of_property_read_u32(node, clock-lanes, v))
 + mipi_csi2-clock_lane = v;

Hmm, the property name is 'clock-lanes', but only one lane is obtained here.

Why is the property name plural in that case?

 +
 + if (of_get_property(node, clock-noncontinuous, v))
 + endpoint-mbus_flags |= V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK;
 +
 + return 0;
 +}
 +EXPORT_SYMBOL(v4l2_of_parse_mipi_csi2);
 +
 +/**
 + * v4l2_of_parse_parallel_bus() - parse parallel bus properties
 + * @node: pointer to endpoint device_node
 + * @endpoint: pointer to v4l2_of_endpoint data structure
 + */
 +void v4l2_of_parse_parallel_bus(const struct device_node *node,
 + struct v4l2_of_endpoint *endpoint)
 +{
 + unsigned int flags = 0;
 + u32 v;
 +
 + if (WARN_ON(!endpoint))
 + return;
 +
 + if (!of_property_read_u32(node, hsync-active, v))
 + flags |= v ? V4L2_MBUS_HSYNC_ACTIVE_HIGH :
 + V4L2_MBUS_HSYNC_ACTIVE_LOW;
 +
 + if (!of_property_read_u32(node, vsync-active, v))
 + flags |= v ? V4L2_MBUS_VSYNC_ACTIVE_HIGH :
 + V4L2_MBUS_VSYNC_ACTIVE_LOW;
 +
 + if (!of_property_read_u32(node, pclk-sample, v))
 + flags |= v ? V4L2_MBUS_PCLK_SAMPLE_RISING :
 + V4L2_MBUS_PCLK_SAMPLE_FALLING;
 +
 + if (!of_property_read_u32(node, field-even-active, v))
 + flags |= v ? V4L2_MBUS_FIELD_EVEN_HIGH :
 + V4L2_MBUS_FIELD_EVEN_LOW;
 + if (flags)
 + endpoint-mbus_type = V4L2_MBUS_PARALLEL;
 + else
 + endpoint-mbus_type = V4L2_MBUS_BT656;
 +
 + if (!of_property_read_u32(node, data-active, v))
 + flags |= v ? V4L2_MBUS_DATA_ACTIVE_HIGH :
 + V4L2_MBUS_DATA_ACTIVE_LOW;
 +
 + if (of_get_property(node, slave-mode, v))
 +   

Re: [PATCH RFC v3 01/15] [media] Add common video interfaces OF bindings documentation

2013-02-03 Thread Hans Verkuil
On Wed 23 January 2013 11:21:24 Sylwester Nawrocki wrote:
 Hi Hans,
 
 On 01/21/2013 11:31 AM, Hans Verkuil wrote:
 [...]
  +Required properties
  +---
  +
  +If there is more than one 'port' or more than one 'endpoint' node 
  following
  +properties are required in relevant parent node:
  +
  +- #address-cells : number of cells required to define port number, should 
  be 1.
  +- #size-cells: should be zero.
  +
  +Optional endpoint properties
  +
  +
  +- remote-endpoint: phandle to an 'endpoint' subnode of the other device 
  node.
  +- slave-mode: a boolean property, run the link in slave mode. Default is 
  master
  +  mode.
  +- bus-width: number of data lines, valid for parallel busses.
  +- data-shift: on parallel data busses, if bus-width is used to specify the
  +  number of data lines, data-shift can be used to specify which data 
  lines are
  +  used, e.g. bus-width=10; data-shift=2; means, that lines 9:2 are 
  used.
  +- hsync-active: active state of HSYNC signal, 0/1 for LOW/HIGH 
  respectively.
  +- vsync-active: active state of VSYNC signal, 0/1 for LOW/HIGH 
  respectively.
  +  Note, that if HSYNC and VSYNC polarities are not specified, embedded
  +  synchronization may be required, where supported.
  +- data-active: similar to HSYNC and VSYNC, specifies data line polarity.
  +- field-even-active: field signal level during the even field data 
  transmission.
  +- pclk-sample: sample data on rising (1) or falling (0) edge of the pixel 
  clock
  +  signal.
  +- data-lanes: an array of physical data lane indexes. Position of an entry
  +  determines logical lane number, while the value of an entry indicates 
  physical
  +  lane, e.g. for 2-lane MIPI CSI-2 bus we could have data-lanes = 1, 
  2;,
  +  assuming the clock lane is on hardware lane 0. This property is valid 
  for
  +  serial busses only (e.g. MIPI CSI-2).
  +- clock-lanes: a number of physical lane used as a clock lane.
  
  This doesn't parse. Do you mean:
  
  a number of physical lanes used as clock lanes.?
 
 Not really, an index (an array of indexes?) of physical lanes(s) used as clock
 lane (s).
 
 Currently there are only use cases for one clock lane (MIPI CSI-2 bus).
 I'm not sure what's better, to keep that in singular (clock-lane) or plural
 form. The plural form seems more generic. So I'm inclined to define it as:
 
 clock-lanes - similarly to 'data-lanes' property, an array of physical
 clock lane indexes. For MIPI CSI-2 bus this array contains only one entry.
 
 Would it be OK like this ?

I'd go with this:

- clock-lanes: an array of physical clock lane indexes. Position of an entry
  determines the logical lane number, while the value of an entry indicates
  physical lane, e.g. for a MIPI CSI-2 bus we could have clock-lanes = 0;,
  which places the clock lane on hardware lane 0. This property is valid for
  serial busses only (e.g. MIPI CSI-2). Note that for the MIPI CSI-2 bus this
  array contains only one entry.

Regards,

Hans
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss