cron job: media_tree daily build: ERRORS

2016-11-02 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:   Thu Nov  3 05:00:14 CET 2016
media-tree git hash:bd676c0c04ec94bd830b9192e2c33f2c4532278d
media_build git hash:   dac8db4dd7fa3cc87715cb19ace554e080690b39
v4l-utils git hash: 7bcf9c69b0fe38fbff8c8e5798b3fb31c34ee1c7
gcc version:i686-linux-gcc (GCC) 6.2.0
sparse version: v0.5.0-3553-g78b2ea6
smatch version: v0.5.0-3553-g78b2ea6
host hardware:  x86_64
host os:4.7.0-164

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-multi: OK
linux-git-arm-pxa: OK
linux-git-blackfin-bf561: OK
linux-git-i686: OK
linux-git-m32r: WARNINGS
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
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: ERRORS
linux-3.3.8-i686: ERRORS
linux-3.4.27-i686: ERRORS
linux-3.5.7-i686: ERRORS
linux-3.6.11-i686: ERRORS
linux-3.7.4-i686: ERRORS
linux-3.8-i686: ERRORS
linux-3.9.2-i686: ERRORS
linux-3.10.1-i686: ERRORS
linux-3.11.1-i686: ERRORS
linux-3.13.11-i686: ERRORS
linux-3.14.9-i686: ERRORS
linux-3.15.2-i686: ERRORS
linux-3.16.7-i686: ERRORS
linux-3.17.8-i686: ERRORS
linux-3.18.7-i686: ERRORS
linux-3.19-i686: ERRORS
linux-4.0.9-i686: ERRORS
linux-4.1.33-i686: ERRORS
linux-4.2.8-i686: ERRORS
linux-4.3.6-i686: WARNINGS
linux-4.4.22-i686: WARNINGS
linux-4.5.7-i686: WARNINGS
linux-4.6.7-i686: WARNINGS
linux-4.7.5-i686: WARNINGS
linux-4.8-i686: WARNINGS
linux-4.9-rc1-i686: WARNINGS
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: ERRORS
linux-3.3.8-x86_64: ERRORS
linux-3.4.27-x86_64: ERRORS
linux-3.5.7-x86_64: ERRORS
linux-3.6.11-x86_64: ERRORS
linux-3.7.4-x86_64: ERRORS
linux-3.8-x86_64: ERRORS
linux-3.9.2-x86_64: ERRORS
linux-3.10.1-x86_64: ERRORS
linux-3.11.1-x86_64: ERRORS
linux-3.13.11-x86_64: ERRORS
linux-3.14.9-x86_64: ERRORS
linux-3.15.2-x86_64: ERRORS
linux-3.16.7-x86_64: ERRORS
linux-3.17.8-x86_64: ERRORS
linux-3.18.7-x86_64: ERRORS
linux-3.19-x86_64: ERRORS
linux-4.0.9-x86_64: ERRORS
linux-4.1.33-x86_64: ERRORS
linux-4.2.8-x86_64: ERRORS
linux-4.3.6-x86_64: WARNINGS
linux-4.4.22-x86_64: WARNINGS
linux-4.5.7-x86_64: WARNINGS
linux-4.6.7-x86_64: WARNINGS
linux-4.7.5-x86_64: WARNINGS
linux-4.8-x86_64: WARNINGS
linux-4.9-rc1-x86_64: WARNINGS
apps: WARNINGS
spec-git: OK
smatch: ERRORS
ABI WARNING: change for arm-davinci
ABI WARNING: change for arm-multi
ABI WARNING: change for blackfin-bf561
ABI WARNING: change for mips
sparse: WARNINGS

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

http://www.xs4all.nl/~hverkuil/spec/index.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


Xmas Offer

2016-11-02 Thread Mrs Julie Leach
You are a recipient to Mrs Julie Leach Donation of $3 million USD. Contact ( 
julieleac...@gmail.com) for claims.
--
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


STRICTLY CONFIDENTIAL

2016-11-02 Thread Acct. Dept.
I have important transaction for you as next of kin to claim US$18.37m  Mail me 
on my private email:   chimwia...@gmail.com
 so I can send you more details

Thanks

Mr.Chim Wai Kim










==MOVE TO INBOX===

DISCLAIMER: This email and any files it contains are confidential and intended 
for the use of the recipient(s) only. If you are not the intended recipient you 
should notify the sender immediately and destroy the material from your system. 



--
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/2] media: i2c/ov5645: add the device tree binding document

2016-11-02 Thread Laurent Pinchart
Hi Todor,

On Tuesday 01 Nov 2016 10:24:26 Todor Tomov wrote:
> On 10/26/2016 09:53 PM, Rob Herring wrote:
> > On Wed, Oct 19, 2016 at 4:21 AM, Laurent Pinchart wrote:
> >> On Wednesday 19 Oct 2016 12:14:55 Todor Tomov wrote:
> >>> On 10/19/2016 11:49 AM, Laurent Pinchart wrote:
>  On Friday 14 Oct 2016 15:01:08 Todor Tomov wrote:
> > On 09/08/2016 03:22 PM, Laurent Pinchart wrote:
> >> On Thursday 08 Sep 2016 12:13:54 Todor Tomov wrote:
> >>> Add the document for ov5645 device tree binding.
> >>> 
> >>> Signed-off-by: Todor Tomov 
> >>> ---
> >>> 
> >>>  .../devicetree/bindings/media/i2c/ov5645.txt   | 52 +++
> >>>  1 file changed, 52 insertions(+)
> >>>  create mode 100644
> >>>  Documentation/devicetree/bindings/media/i2c/ov5645.txt
> >>> 
> >>> diff --git a/Documentation/devicetree/bindings/media/i2c/ov5645.txt
> >>> b/Documentation/devicetree/bindings/media/i2c/ov5645.txt new file
> >>> mode
> >>> 100644
> >>> index 000..bcf6dba
> >>> --- /dev/null
> >>> +++ b/Documentation/devicetree/bindings/media/i2c/ov5645.txt
> >>> @@ -0,0 +1,52 @@
> >>> +* Omnivision 1/4-Inch 5Mp CMOS Digital Image Sensor
> >>> +
> >>> +The Omnivision OV5645 is a 1/4-Inch CMOS active pixel digital image
> >>> sensor with
> >>> +an active array size of 2592H x 1944V. It is programmable through a
> >>> serial I2C
> >>> +interface.
> >>> +
> >>> +Required Properties:
> >>> +- compatible: Value should be "ovti,ov5645".
> >>> +- clocks: Reference to the xclk clock.
> >>> +- clock-names: Should be "xclk".
> >>> +- clock-frequency: Frequency of the xclk clock.
> >>> +- enable-gpios: Chip enable GPIO. Polarity is GPIO_ACTIVE_HIGH.
>  
>  By the way, isn't the pin called pwdnb and isn't it active low ?
> >>> 
> >>> Yes, the pin is called "pwdnb" and is active low (must be up for power
> >>> to be up). I have changed the name to "enable" as it is more generally
> >>> used - this change was suggested by Rob Herring. As the logic switches
> >>> with this change of the name I have stated it is active high which ends
> >>> up in the same condition (enable must be up for the power to be up). I
> >>> think this is correct, isn't it?
> >> 
> >> I thought that the rule was to name the GPIO properties based on the name
> >> of the pin. I could be wrong though. Rob, what's your opinion ?
> > 
> > Generally, yes that is the rule. However, an enable (or powerdown
> > being the inverse) pin is so common that I think it makes sense to use
> > a common name. Then generic power sequencing code can power up devices
> > (in the simple cases at least).
> 
> Ok, so what can we decide about this case? I personally have a slight
> preference for the name same as documentation. But I think most important
> is to follow the rule if we have such a rule. If we don't have a single
> rule to follow every time then it is not really important which one we will
> choose.

I'm fine with both solutions (and also have a slight preference for using the 
chip's pin name). If we decide to use "enable-gpios", the DT binding document 
should mention that the property corresponds to the chip's PWDNB pin.

-- 
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 2/3] v4l: vsp1: allow entities to have multiple source pads

2016-11-02 Thread Laurent Pinchart
Hi Kieran,

Thank you for the patch.

On Thursday 27 Oct 2016 15:01:24 Kieran Bingham wrote:
> The upcoming writeback feature of the VSP1 WPF, allows the active output
> of the DU to be written back to memory. On Generation 3 hardware, the DU
> is fed by the LIF, which is in turn fed by the WPF.
> 
> It is the WPF which will perform memory writeback functionality, and
> this brings in a second output of the entity. Configured in this mode,
> the WPF will output to both the LIF, and to a memory (V4L2 video)
> device.
> 
> Support this feature by extending vsp1_entity_init() to specify the
> number of source and sink pads.

Do we need this, can't we just connect the single WPF source pad to both the 
LIF and WPF output (video node) entities ?

> Signed-off-by: Kieran Bingham 
> ---
>  drivers/media/platform/vsp1/vsp1_bru.c|  2 +-
>  drivers/media/platform/vsp1/vsp1_clu.c|  2 +-
>  drivers/media/platform/vsp1/vsp1_entity.c | 15 ---
>  drivers/media/platform/vsp1/vsp1_entity.h |  3 ++-
>  drivers/media/platform/vsp1/vsp1_histo.c  |  2 +-
>  drivers/media/platform/vsp1/vsp1_hsit.c   |  2 +-
>  drivers/media/platform/vsp1/vsp1_lif.c|  2 +-
>  drivers/media/platform/vsp1/vsp1_lut.c|  2 +-
>  drivers/media/platform/vsp1/vsp1_rpf.c|  2 +-
>  drivers/media/platform/vsp1/vsp1_sru.c|  2 +-
>  drivers/media/platform/vsp1/vsp1_uds.c|  2 +-
>  drivers/media/platform/vsp1/vsp1_wpf.c|  2 +-
>  12 files changed, 20 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/media/platform/vsp1/vsp1_bru.c
> b/drivers/media/platform/vsp1/vsp1_bru.c index ee8355c28f94..796bcc77eb44
> 100644
> --- a/drivers/media/platform/vsp1/vsp1_bru.c
> +++ b/drivers/media/platform/vsp1/vsp1_bru.c
> @@ -411,7 +411,7 @@ struct vsp1_bru *vsp1_bru_create(struct vsp1_device
> *vsp1) bru->entity.type = VSP1_ENTITY_BRU;
> 
>   ret = vsp1_entity_init(vsp1, >entity, "bru",
> -vsp1->info->num_bru_inputs + 1, _ops,
> +vsp1->info->num_bru_inputs, 1, _ops,
>  MEDIA_ENT_F_PROC_VIDEO_COMPOSER);
>   if (ret < 0)
>   return ERR_PTR(ret);
> diff --git a/drivers/media/platform/vsp1/vsp1_clu.c
> b/drivers/media/platform/vsp1/vsp1_clu.c index f2fb26e5ab4e..b38692b1f0dd
> 100644
> --- a/drivers/media/platform/vsp1/vsp1_clu.c
> +++ b/drivers/media/platform/vsp1/vsp1_clu.c
> @@ -283,7 +283,7 @@ struct vsp1_clu *vsp1_clu_create(struct vsp1_device
> *vsp1) clu->entity.ops = _entity_ops;
>   clu->entity.type = VSP1_ENTITY_CLU;
> 
> - ret = vsp1_entity_init(vsp1, >entity, "clu", 2, _ops,
> + ret = vsp1_entity_init(vsp1, >entity, "clu", 1, 1, _ops,
>  MEDIA_ENT_F_PROC_VIDEO_LUT);
>   if (ret < 0)
>   return ERR_PTR(ret);
> diff --git a/drivers/media/platform/vsp1/vsp1_entity.c
> b/drivers/media/platform/vsp1/vsp1_entity.c index
> 5263387f7ec7..72c99de6e3a4 100644
> --- a/drivers/media/platform/vsp1/vsp1_entity.c
> +++ b/drivers/media/platform/vsp1/vsp1_entity.c
> @@ -472,11 +472,13 @@ static const struct vsp1_route vsp1_routes[] = {
>  };
> 
>  int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
> -  const char *name, unsigned int num_pads,
> +  const char *name, unsigned int num_sink_pads,
> +  unsigned int num_source_pads,
>const struct v4l2_subdev_ops *ops, u32 function)
>  {
>   struct v4l2_subdev *subdev;
>   unsigned int i;
> + unsigned int num_pads = num_sink_pads + num_source_pads;
>   int ret;
> 
>   for (i = 0; i < ARRAY_SIZE(vsp1_routes); ++i) {
> @@ -501,18 +503,17 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct
> vsp1_entity *entity, if (entity->pads == NULL)
>   return -ENOMEM;
> 
> - for (i = 0; i < num_pads - 1; ++i)
> + for (i = 0; i < num_sink_pads; ++i)
>   entity->pads[i].flags = MEDIA_PAD_FL_SINK;
> 
> - entity->sources = devm_kcalloc(vsp1->dev, max(num_pads - 1, 1U),
> + for (; i < num_pads; ++i)
> + entity->pads[i].flags = MEDIA_PAD_FL_SOURCE;
> +
> + entity->sources = devm_kcalloc(vsp1->dev, num_source_pads,
>  sizeof(*entity->sources), GFP_KERNEL);
>   if (entity->sources == NULL)
>   return -ENOMEM;
> 
> - /* Single-pad entities only have a sink. */
> - entity->pads[num_pads - 1].flags = num_pads > 1 ? MEDIA_PAD_FL_SOURCE
> -  : MEDIA_PAD_FL_SINK;
> -
>   /* Initialize the media entity. */
>   ret = media_entity_pads_init(>subdev.entity, num_pads,
>entity->pads);
> diff --git a/drivers/media/platform/vsp1/vsp1_entity.h
> b/drivers/media/platform/vsp1/vsp1_entity.h index
> c169a060b6d2..c709c29eb994 100644
> --- a/drivers/media/platform/vsp1/vsp1_entity.h
> +++ 

Re: [RFC 1/3] Revert "[media] v4l: vsp1: Supply frames to the DU continuously"

2016-11-02 Thread Laurent Pinchart
Hi Kieran,

Thank you for the patch.

On Thursday 27 Oct 2016 15:01:23 Kieran Bingham wrote:
> This reverts commit 3299ba5c0b213be5d911752d40251c1abc1004f7.
> 
> The DU output mode does not rely on frames being supplied on the WPF as
> its pipeline is supplied from DRM. For the upcoming WPF writeback
> functionality, we will choose to enable writeback mode if there is an
> output buffer, or disable it (leaving the existing display pipeline
> unharmed) otherwise.
> 
> Signed-off-by: Kieran Bingham 

Reviewed-by: Laurent Pinchart 

and applied to my tree.

> ---
>  drivers/media/platform/vsp1/vsp1_video.c | 11 ---
>  1 file changed, 11 deletions(-)
> 
> diff --git a/drivers/media/platform/vsp1/vsp1_video.c
> b/drivers/media/platform/vsp1/vsp1_video.c index 94b428596c4f..f10401065cd3
> 100644
> --- a/drivers/media/platform/vsp1/vsp1_video.c
> +++ b/drivers/media/platform/vsp1/vsp1_video.c
> @@ -296,11 +296,6 @@ static struct v4l2_rect vsp1_video_partition(struct
> vsp1_pipeline *pipe, * This function completes the current buffer by
> filling its sequence number, * time stamp and payload size, and hands it
> back to the videobuf core. *
> - * When operating in DU output mode (deep pipeline to the DU through the
> LIF), - * the VSP1 needs to constantly supply frames to the display. In
> that case, if - * no other buffer is queued, reuse the one that has just
> been processed instead - * of handing it back to the videobuf core.
> - *
>   * Return the next queued buffer or NULL if the queue is empty.
>   */
>  static struct vsp1_vb2_buffer *
> @@ -322,12 +317,6 @@ vsp1_video_complete_buffer(struct vsp1_video *video)
>   done = list_first_entry(>irqqueue,
>   struct vsp1_vb2_buffer, queue);
> 
> - /* In DU output mode reuse the buffer if the list is singular. */
> - if (pipe->lif && list_is_singular(>irqqueue)) {
> - spin_unlock_irqrestore(>irqlock, flags);
> - return done;
> - }
> -
>   list_del(>queue);
> 
>   if (!list_empty(>irqqueue))

-- 
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 RESEND] media: omap3isp: Use dma_request_chan() to requesting DMA channel

2016-11-02 Thread Laurent Pinchart
Hi Peter,

Thank you for the patch.

On Wednesday 02 Nov 2016 14:39:59 Peter Ujfalusi wrote:
> With the new dma_request_chan() the client driver does not need to look for
> the DMA resource and it does not need to pass filter_fn anymore.
> By switching to the new API the driver can now support deferred probing
> against DMA.

I believe this breaks the OMAP3 ISP driver. dma_request_slave_channel_compat() 
is a superset of dma_request_chan() that will, when called with 
omap_dma_filter_fn, return as a fallback any free channel handled by the OMAP 
DMA engine driver. This feature is actively used by this driver and must be 
preserved.

> Signed-off-by: Peter Ujfalusi 
> CC: Laurent Pinchart 
> CC: Mauro Carvalho Chehab 
> ---
> Hi,
> 
> the original patch was sent 29.04.2016:
> https://patchwork.kernel.org/patch/8981811/
> 
> I have rebased it on top of linux-next.
> 
> Regards,
> Peter
> 
>  drivers/media/platform/omap3isp/isphist.c | 27 +--
>  1 file changed, 9 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/media/platform/omap3isp/isphist.c
> b/drivers/media/platform/omap3isp/isphist.c index
> 7138b043a4aa..e163e3d92517 100644
> --- a/drivers/media/platform/omap3isp/isphist.c
> +++ b/drivers/media/platform/omap3isp/isphist.c
> @@ -18,7 +18,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
> 
> @@ -486,27 +485,19 @@ int omap3isp_hist_init(struct isp_device *isp)
>   hist->isp = isp;
> 
>   if (HIST_CONFIG_DMA) {
> - struct platform_device *pdev = to_platform_device(isp->dev);
> - struct resource *res;
> - unsigned int sig = 0;
> - dma_cap_mask_t mask;
> -
> - dma_cap_zero(mask);
> - dma_cap_set(DMA_SLAVE, mask);
> -
> - res = platform_get_resource_byname(pdev, IORESOURCE_DMA,
> -"hist");
> - if (res)
> - sig = res->start;
> -
> - hist->dma_ch = dma_request_slave_channel_compat(mask,
> - omap_dma_filter_fn, , isp->dev, "hist");
> - if (!hist->dma_ch)
> + hist->dma_ch = dma_request_chan(isp->dev, "hist");
> + if (IS_ERR(hist->dma_ch)) {
> + ret = PTR_ERR(hist->dma_ch);
> + if (ret == -EPROBE_DEFER)
> + return ret;
> +
> + hist->dma_ch = NULL;
>   dev_warn(isp->dev,
>"hist: DMA channel request failed, using 
PIO\n");
> - else
> + } else {
>   dev_dbg(isp->dev, "hist: using DMA channel %s\n",
>   dma_chan_name(hist->dma_ch));
> + }
>   }
> 
>   hist->ops = _ops;

-- 
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 2/2] [media] lirc: remove lirc_serial driver

2016-11-02 Thread Sean Young
On Wed, Nov 02, 2016 at 02:00:16PM -0700, VDR User wrote:
> > serial_ir driver in rc-core
> 
> Which kernel did this happen in? I don't see a sign of it in 4.8.5 and
> I want to make sure that homebrew serial devices still work with lirc
> after this. Are you sure the serial_ir driver you refer to isn't about
> a usb-based serial ir?

See patch 1/2. That introduces the serial_ir rc-core driver. 

http://www.spinics.net/lists/linux-media/msg107352.html


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


Re: [PATCH 2/2] [media] lirc: remove lirc_serial driver

2016-11-02 Thread VDR User
> serial_ir driver in rc-core

Which kernel did this happen in? I don't see a sign of it in 4.8.5 and
I want to make sure that homebrew serial devices still work with lirc
after this. Are you sure the serial_ir driver you refer to isn't about
a usb-based serial ir?

Thanks for clarity.
--
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 5/5] doc_rst: media: New SDR formats SC16, SC18 & SC20

2016-11-02 Thread Laurent Pinchart
Hi Ramesh,

On Wednesday 02 Nov 2016 09:00:00 Ramesh Shanmugasundaram wrote:
> Hi Laurent,
> 
> Any further thoughts on the SDR format please (especially the comment
> below). I would appreciate your feedback.
>
> >> On Wednesday 12 Oct 2016 15:10:29 Ramesh Shanmugasundaram wrote:
> >>> This patch adds documentation for the three new SDR formats
> >>> 
> >>> V4L2_SDR_FMT_SCU16BE
> >>> V4L2_SDR_FMT_SCU18BE
> >>> V4L2_SDR_FMT_SCU20BE
> 
> [snip]
> 
> >>> +
> >>> +   -  start + 0:
> >>> +
> >>> +   -  I'\ :sub:`0[D13:D6]`
> >>> +
> >>> +   -  I'\ :sub:`0[D5:D0]`
> >>> +
> >>> +-  .. row 2
> >>> +
> >>> +   -  start + buffer_size/2:
> >>> +
> >>> +   -  Q'\ :sub:`0[D13:D6]`
> >>> +
> >>> +   -  Q'\ :sub:`0[D5:D0]`
> >> 
> >> The format looks planar, does it use one V4L2 plane (as does NV12) or
> >> two V4L2 planes (as does NV12M) ? Same question for the other formats.
> > 
> > Thank you for bringing up this topic. This is one of the key design
> > dilemma.
> > 
> > The I & Q data for these three SDR formats comes from two different DMA
> > channels and hence two separate pointers -> we could say it is v4l2 multi-
> > planar. Right now, I am making it look like a single plane by presenting
> > the data in one single buffer ptr.
> > 
> > For e.g. multi-planar SC16 format would look something like this
> > 
> > <32bits-->
> > <--I(14 bit data) + 2bit status--16bit padded zeros--> : start0 + 0
> > <--I(14 bit data) + 2bit status--16bit padded zeros--> : start0 + 4 ...
> > <--Q(14 bit data) + 2bit status--16bit padded zeros--> : start1 + 0
> > <--Q(14 bit data) + 2bit status--16bit padded zeros--> : start1 + 4
> > 
> > My concerns are
> > 
> > 1) These formats are not a standard as the video "Image Formats". These
> > formats are possible when we use DRIF + MAX2175 combination. If we
> > interface with a different tuner vendor, the above format(s) MAY/MAY NOT
> > be re-usable. We do not know at this point. This is the main open item for
> > discussion in the cover letter.

If the formats are really device-specific then they should be documented 
accordingly and not made generic.

> > 2) MPLANE support within V4L2 seems specific to video. Please correct me
> > if this is wrong interpretation.
> > 
> > - struct v4l2_format contains v4l2_sdr_format and
> > v4l2_pix_format_mplane as members of union. Should I create a new
> > v4l2_sdr_format_mplane? If I have to use v4l2_pix_format_mplane most of
> > the video specific members would be unused (it would be similar to using
> > v4l2_pix_format itself instead of v4l2_sdr_format)?

I have no answer to that question as I'm not familiar with SDR. Antti, you've 
added v4l2_sdr_format to the API, what's your opinion ? Hans, as you've acked 
the patch, your input would be appreciated as well.

> > - The above decision (accomodate SDR & MPLANE) needs to be
> > propagated across the framework. Is this the preferred approach?
> > 
> > It goes back to point (1). As of today, the change set for this combo
> > (DRIF+MAX2175) introduces new SDR formats only. Should it add further
> > SDR+MPLANE support to the framework as well?
> > 
> > I would appreciate your suggestions on this regard.

-- 
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 v3 0/6] Add support for IR transmitters

2016-11-02 Thread Heiner Kallweit
Am 02.11.2016 um 11:40 schrieb Andi Shyti:
> Hi,
> 
> The main goal is to add support in the rc framework for IR
> transmitters, which currently is only supported by lirc but that
> is not the preferred way.
> 
> The last patch adds support for an IR transmitter driven by
> the MOSI line of an SPI controller, it's the case of the Samsung
> TM2(e) board which support is currently ongoing.
> 
> The last patch adds support for an IR transmitter driven by
> the MOSI line of an SPI controller, it's the case of the Samsung
> TM2(e) board which support is currently ongoing.
> 
> Thanks Sean for your prompt reviews.
> 
> Andi
> 
> Changelog from version 1:
> 
> The RFC is now PATCH. The main difference is that this version
> doesn't try to add the any bit streaming protocol and doesn't
> modify any LIRC interface specification.
> 
> patch 1: updates all the drivers using rc_allocate_device
> patch 2: fixed errors and warning reported from the kbuild test
>  robot
> patch 5: this patch has been dropped and replaced with a new one
>  which avoids waiting for transmitters.
> patch 6: added new properties to the dts specification
> patch 7: the driver uses the pulse/space input and converts it to
>  a bit stream.
> 
> 
> Changelog from version 2:
> 
> The original patch number 5 has been abandoned because it was not
> bringing much benenfit.
> 
> patch 1: rebased on the new kernel.
> patch 3: removed the sysfs attribute protocol for transmitters
> patch 5: the binding has been moved to the leds section instead
>  of the media. Fixed all the comments from Rob
> patch 6: fixed all the comments from Sean added also Sean's
>  review.
> 
> Andi Shyti (6):
>   [media] rc-main: assign driver type during allocation
>   [media] rc-main: split setup and unregister functions
>   [media] rc-core: add support for IR raw transmitters
>   [media] rc-ir-raw: do not generate any receiving thread for raw
> transmitters
>   Documentation: bindings: add documentation for ir-spi device driver
>   [media] rc: add support for IR LEDs driven through SPI
> 
Hi Andi,

at least patches 1 and 2 conflict with recent extensions. See commits
ddbf7d5a698c "rc: core: add managed versions of rc_allocate_device and
rc_register_device" and b6f3ece38733 "[media] rc: nuvoton: use managed
versions of rc_allocate_device and rc_register_device".

It would be good if you could rebase your patch set on top of the
latest master branch of media tree. Most likely you will have to make
changes to the recently introduced managed versions of
rc_allocate_device and rc_register_device.

Rgds, Heiner

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


Re: [PATCH 1/2] [media] serial_ir: port lirc_serial to rc-core

2016-11-02 Thread kbuild test robot
Hi Sean,

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on v4.9-rc3 next-20161028]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]
[Suggest to use git(>=2.9.0) format-patch --base= (or --base=auto for 
convenience) to record what (public, well-known) commit your patch series was 
built on]
[Check https://git-scm.com/docs/git-format-patch for more information]

url:
https://github.com/0day-ci/linux/commits/Sean-Young/serial_ir-port-lirc_serial-to-rc-core/20161103-014155
base:   git://linuxtv.org/media_tree.git master
config: parisc-allyesconfig (attached as .config)
compiler: hppa-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=parisc 

All warnings (new ones prefixed by >>):

   drivers/media/rc/serial_ir.c: In function 'serial_ir_irq_handler':
>> drivers/media/rc/serial_ir.c:592:1: warning: the frame size of 1196 bytes is 
>> larger than 1024 bytes [-Wframe-larger-than=]
}
^

vim +592 drivers/media/rc/serial_ir.c

   576  ktime_to_us(lastkt));
   577  /*
   578   * detecting pulse while this
   579   * MUST be a space!
   580   */
   581  sense = sense ? 0 : 1;
   582  }
   583  } else
   584  data = (unsigned int)ktime_to_ns(delkt);
   585  frbwrite(data, !(dcd^sense));
   586  lastkt = kt;
   587  last_dcd = dcd;
   588  ir_raw_event_handle(rcdev);
   589  }
   590  } while (!(sinp(UART_IIR) & UART_IIR_NO_INT)); /* still pending 
? */
   591  return IRQ_HANDLED;
 > 592  }
   593  
   594  
   595  static int hardware_init_port(void)
   596  {
   597  u8 scratch, scratch2, scratch3;
   598  
   599  /*
   600   * This is a simple port existence test, borrowed from the 
autoconfig

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


[PATCH 2/2] [media] lirc: remove lirc_serial driver

2016-11-02 Thread Sean Young
This has been replaced by the serial_ir driver in rc-core.

Signed-off-by: Sean Young 
---
 drivers/staging/media/lirc/Kconfig   |   13 -
 drivers/staging/media/lirc/Makefile  |1 -
 drivers/staging/media/lirc/lirc_serial.c | 1130 --
 3 files changed, 1144 deletions(-)
 delete mode 100644 drivers/staging/media/lirc/lirc_serial.c

diff --git a/drivers/staging/media/lirc/Kconfig 
b/drivers/staging/media/lirc/Kconfig
index 6879c46..25b7e7c 100644
--- a/drivers/staging/media/lirc/Kconfig
+++ b/drivers/staging/media/lirc/Kconfig
@@ -38,19 +38,6 @@ config LIRC_SASEM
help
  Driver for the Sasem OnAir Remocon-V or Dign HV5 HTPC IR/VFD Module
 
-config LIRC_SERIAL
-   tristate "Homebrew Serial Port Receiver"
-   depends on LIRC
-   help
- Driver for Homebrew Serial Port Receivers
-
-config LIRC_SERIAL_TRANSMITTER
-   bool "Serial Port Transmitter"
-   default y
-   depends on LIRC_SERIAL
-   help
- Serial Port Transmitter support
-
 config LIRC_SIR
tristate "Built-in SIR IrDA port"
depends on LIRC
diff --git a/drivers/staging/media/lirc/Makefile 
b/drivers/staging/media/lirc/Makefile
index 5430adf..7f919ea 100644
--- a/drivers/staging/media/lirc/Makefile
+++ b/drivers/staging/media/lirc/Makefile
@@ -7,6 +7,5 @@ obj-$(CONFIG_LIRC_BT829)+= lirc_bt829.o
 obj-$(CONFIG_LIRC_IMON)+= lirc_imon.o
 obj-$(CONFIG_LIRC_PARALLEL)+= lirc_parallel.o
 obj-$(CONFIG_LIRC_SASEM)   += lirc_sasem.o
-obj-$(CONFIG_LIRC_SERIAL)  += lirc_serial.o
 obj-$(CONFIG_LIRC_SIR) += lirc_sir.o
 obj-$(CONFIG_LIRC_ZILOG)   += lirc_zilog.o
diff --git a/drivers/staging/media/lirc/lirc_serial.c 
b/drivers/staging/media/lirc/lirc_serial.c
deleted file mode 100644
index b798b31..000
--- a/drivers/staging/media/lirc/lirc_serial.c
+++ /dev/null
@@ -1,1130 +0,0 @@
-/*
- * lirc_serial.c
- *
- * lirc_serial - Device driver that records pulse- and pause-lengths
- *(space-lengths) between DDCD event on a serial port.
- *
- * Copyright (C) 1996,97 Ralph Metzler 
- * Copyright (C) 1998 Trent Piepho 
- * Copyright (C) 1998 Ben Pfaff 
- * Copyright (C) 1999 Christoph Bartelmus 
- * Copyright (C) 2007 Andrei Tanas  (suspend/resume support)
- *  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; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-/*
- * Steve's changes to improve transmission fidelity:
- *   - for systems with the rdtsc instruction and the clock counter, a
- * send_pule that times the pulses directly using the counter.
- * This means that the LIRC_SERIAL_TRANSMITTER_LATENCY fudge is
- * not needed. Measurement shows very stable waveform, even where
- * PCI activity slows the access to the UART, which trips up other
- * versions.
- *   - For other system, non-integer-microsecond pulse/space lengths,
- * done using fixed point binary. So, much more accurate carrier
- * frequency.
- *   - fine tuned transmitter latency, taking advantage of fractional
- * microseconds in previous change
- *   - Fixed bug in the way transmitter latency was accounted for by
- * tuning the pulse lengths down - the send_pulse routine ignored
- * this overhead as it timed the overall pulse length - so the
- * pulse frequency was right but overall pulse length was too
- * long. Fixed by accounting for latency on each pulse/space
- * iteration.
- *
- * Steve Davies   July 2001
- */
-
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-/* From Intel IXP42X Developer's Manual (#252480-005): */
-/* ftp://download.intel.com/design/network/manuals/25248005.pdf */
-#define UART_IE_IXP42X_UUE   0x40 /* IXP42X UART Unit enable */
-#define UART_IE_IXP42X_RTOIE 0x10 /* IXP42X Receiver Data Timeout int.enable */
-
-#include 
-#include 
-
-#define LIRC_DRIVER_NAME "lirc_serial"
-
-struct lirc_serial {
-   int signal_pin;
-   int signal_pin_change;
-   u8 on;

[PATCH 1/2] [media] serial_ir: port lirc_serial to rc-core

2016-11-02 Thread Sean Young
Tested with a homebrew serial ir.

Signed-off-by: Sean Young 
---
 MAINTAINERS  |6 +
 drivers/media/rc/Kconfig |   17 +
 drivers/media/rc/Makefile|1 +
 drivers/media/rc/serial_ir.c | 1020 ++
 4 files changed, 1044 insertions(+)
 create mode 100644 drivers/media/rc/serial_ir.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 93e9f42..cd8fd50 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10604,6 +10604,12 @@ S: Maintained
 F: Documentation/devicetree/bindings/serial/
 F: drivers/tty/serial/
 
+SERIAL IR RECEIVER
+M: Sean Young 
+L: linux-media@vger.kernel.org
+S: Maintained
+F: drivers/media/rc/serial_ir.c
+
 STI CEC DRIVER
 M: Benjamin Gaignard 
 L: ker...@stlinux.com
diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig
index 370e16e..629e8ca 100644
--- a/drivers/media/rc/Kconfig
+++ b/drivers/media/rc/Kconfig
@@ -389,4 +389,21 @@ config IR_SUNXI
   To compile this driver as a module, choose M here: the module will
   be called sunxi-ir.
 
+config IR_SERIAL
+   tristate "Homebrew Serial Port Receiver"
+   depends on RC_CORE
+   ---help---
+  Say Y if you want to use Homebrew Serial Port Receivers and
+  Transceivers.
+
+  To compile this driver as a module, choose M here: the module will
+  be called serial-ir.
+
+config IR_SERIAL_TRANSMITTER
+   bool "Serial Port Transmitter"
+   default y
+   depends on IR_SERIAL
+   ---help---
+  Serial Port Transmitter support
+
 endif #RC_DEVICES
diff --git a/drivers/media/rc/Makefile b/drivers/media/rc/Makefile
index 379a5c0..3a984ee 100644
--- a/drivers/media/rc/Makefile
+++ b/drivers/media/rc/Makefile
@@ -37,3 +37,4 @@ obj-$(CONFIG_IR_TTUSBIR) += ttusbir.o
 obj-$(CONFIG_RC_ST) += st_rc.o
 obj-$(CONFIG_IR_SUNXI) += sunxi-cir.o
 obj-$(CONFIG_IR_IMG) += img-ir/
+obj-$(CONFIG_IR_SERIAL) += serial_ir.o
diff --git a/drivers/media/rc/serial_ir.c b/drivers/media/rc/serial_ir.c
new file mode 100644
index 000..77193c3
--- /dev/null
+++ b/drivers/media/rc/serial_ir.c
@@ -0,0 +1,1020 @@
+/*
+ * serial-ir.c
+ *
+ * serial-ir - Device driver that records pulse- and pause-lengths
+ *(space-lengths) between DDCD event on a serial port.
+ *
+ * Copyright (C) 1996,97 Ralph Metzler 
+ * Copyright (C) 1998 Trent Piepho 
+ * Copyright (C) 1998 Ben Pfaff 
+ * Copyright (C) 1999 Christoph Bartelmus 
+ * Copyright (C) 2007 Andrei Tanas  (suspend/resume support)
+ * Copyright (C) 2016 Sean Young  (port to rc-core)
+ *  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; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  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.
+ */
+
+/*
+ * Steve's changes to improve transmission fidelity:
+ *   - for systems with the rdtsc instruction and the clock counter, a
+ * send_pule that times the pulses directly using the counter.
+ * This means that the IR_SERIAL_TRANSMITTER_LATENCY fudge is
+ * not needed. Measurement shows very stable waveform, even where
+ * PCI activity slows the access to the UART, which trips up other
+ * versions.
+ *   - For other system, non-integer-microsecond pulse/space lengths,
+ * done using fixed point binary. So, much more accurate carrier
+ * frequency.
+ *   - fine tuned transmitter latency, taking advantage of fractional
+ * microseconds in previous change
+ *   - Fixed bug in the way transmitter latency was accounted for by
+ * tuning the pulse lengths down - the send_pulse routine ignored
+ * this overhead as it timed the overall pulse length - so the
+ * pulse frequency was right but overall pulse length was too
+ * long. Fixed by accounting for latency on each pulse/space
+ * iteration.
+ *
+ * Steve Davies   July 2001
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* From Intel IXP42X Developer's Manual (#252480-005): */
+/* ftp://download.intel.com/design/network/manuals/25248005.pdf */
+#define UART_IE_IXP42X_UUE   0x40 /* IXP42X UART Unit enable */
+#define UART_IE_IXP42X_RTOIE 0x10 /* IXP42X Receiver Data Timeout int.enable */
+
+#define DRIVER_NAME "serial_ir"
+
+struct serial_ir {
+   int signal_pin;
+   int signal_pin_change;
+   u8 on;
+   u8 off;
+   long 

Re: [PATCH v3 0/6] Add support for IR transmitters

2016-11-02 Thread Sean Young
On Wed, Nov 02, 2016 at 07:40:04PM +0900, Andi Shyti wrote:
> The main goal is to add support in the rc framework for IR
> transmitters, which currently is only supported by lirc but that
> is not the preferred way.
> 
> The last patch adds support for an IR transmitter driven by
> the MOSI line of an SPI controller, it's the case of the Samsung
> TM2(e) board which support is currently ongoing.
> 
> The last patch adds support for an IR transmitter driven by
> the MOSI line of an SPI controller, it's the case of the Samsung
> TM2(e) board which support is currently ongoing.

Looks great! For the whole series:

Reviewed-by: Sean Young 

Thanks,
Sean
--
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 20/32] media: rcar-vin: expose a sink pad if we are on Gen3

2016-11-02 Thread Sergei Shtylyov

On 11/02/2016 04:23 PM, Niklas Söderlund wrote:


Refactor the probe code path to look for the digital subdevice, if one
is found use it just like the driver did before (Gen2 mode) but if it's
not found prepare for a Gen3 mode by registering a pad for the media
controller API to use.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-core.c | 21 -
 drivers/media/platform/rcar-vin/rcar-vin.h  |  9 +
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
b/drivers/media/platform/rcar-vin/rcar-core.c
index f961957..ce8b59a 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -308,6 +308,25 @@ static const struct of_device_id rvin_of_id_table[] = {
 };
 MODULE_DEVICE_TABLE(of, rvin_of_id_table);

+static int rvin_graph_init(struct rvin_dev *vin)
+{
+   int ret;
+
+   /* Try to get digital video pipe */
+   ret = rvin_digital_graph_init(vin);
+
+   /* No digital pipe and we are on Gen3 try to joint CSI2 group */
+   if (ret == -ENODEV && vin->info->chip == RCAR_GEN3) {
+
+   vin->pads[RVIN_SINK].flags = MEDIA_PAD_FL_SINK;
+   ret = media_entity_pads_init(>vdev.entity, 1, vin->pads);
+   if (ret)
+   return ret;


   This *if* is not necessary, you'll return below anyway.


+   }
+
+   return ret;
+}
+
 static int rcar_vin_probe(struct platform_device *pdev)
 {
const struct of_device_id *match;

[...]

MBR, Sergei

--
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] dib0700: fix nec repeat handling

2016-11-02 Thread Sean Young
On Sat, Oct 29, 2016 at 11:04:32PM +0200, Arnd Bergmann wrote:
> On Thursday, October 13, 2016 10:28:44 PM CEST Sean Young wrote:
> > When receiving a nec repeat, ensure the correct scancode is repeated
> > rather than a random value from the stack. This removes the need
> > for the bogus uninitialized_var() and also fixes the warnings:
> > 
> > drivers/media/usb/dvb-usb/dib0700_core.c: In function 
> > ‘dib0700_rc_urb_completion’:
> > drivers/media/usb/dvb-usb/dib0700_core.c:679: warning: ‘protocol’ may 
> > be used uninitialized in this function
> > 
> > Signed-off-by: Sean Young 
> > ---
> >  drivers/media/usb/dvb-usb/dib0700_core.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> Acked-by: Arnd Bergmann 
> Cc: sta...@vger.kernel.org
> Fixes: 2ceeca0499d7 ("[media] rc: split nec protocol into its three variants")
> Fixes: d3c501d1938c ("V4L/DVB: dib0700: Fix RC protocol logic to properly 
> handle NEC/NECx and RC-5")
> 
> 
> The warning is gone for me too, so this obsoletes both
> https://patchwork.linuxtv.org/patch/37494/ and
> https://patchwork.kernel.org/patch/9380747/
> 
> Can we get this patch merged into v4.9 soonish? The warning
> is currently disabled, but I'd like to make sure it gets turned
> on again by default, and we should fix all the actual bugs in
> the process.

So after writing the patch and submitting it, I've bought the hardware on
ebay. Without this patch you get random scancodes on nec repeats, which
the patch indeed fixes.

Tested-by: Sean Young 

Note that this has been broken forever, so it is not a regression, so 
does it belong in stable?
 

Sean
--
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 03/32] media: rcar-vin: reset bytesperline and sizeimage when resetting format

2016-11-02 Thread Sergei Shtylyov

Hello.

On 11/02/2016 04:23 PM, Niklas Söderlund wrote:


These two fields where forgotten when refactoring the format reset code
path. If they are not also reset at the same time as width and hight the
format read using G_FMT will not match realty.


   Reality?


Signed-off-by: Niklas Söderlund 

[...]

MBR, Sergei

--
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: YUV444 contradicting wikipedia

2016-11-02 Thread Fabien DESSENNE
Hi


"4:x:y" refers to chroma subsampling, details here: 
https://en.wikipedia.org/wiki/Chroma_subsampling. With "YUV 4:4:4" each 
pixel has 1 Luma information and 1 Chroma information: 1 Y + 1 Cb + 1 Cr 
= 24 bits per pixel.


In top of that, each of the three components (Y, Cb, Cr) can be stored 
in a single memory plane (packed format), just like usual RGB formats 
are. Or components can be stored in 2 (Y + Cb-Cr) or 3 (Y + Cb + Cr) 
memory planes.


The combination of the chroma subsampling and the number of planes, 
defines a pixel format. The problem is that each sub-system (DRM, V4L2, 
GStreamer, ...) uses its own constants with unfortunately unconsistent 
names across them.


Let's consider the YUV 4:4:4 with three planes format:

DRM =DRM_FORMAT_YUV444

V4L2 =   V4L2_PIX_FMT_YUV444M

GStreamer = GST_VIDEO_FORMAT_Y444

As you can see, although all of them specify the same pixel format, the 
names are quite different.

And regarding V4L2_PIX_FMT_YUV444 (not ending with "M"), it defines 
another format with the following specifications:

- YUV packed

- 4:4:4 chroma sampling

- Alpha (when supported by driver)

- 4 (not 8) bits per component

Very different from the "standard" YUV 4:4:4 pixel format.

I agree that its name is confusing, but since it is part of the API, we 
shall consider that it won't be updated.

 From what I have seen, DRM (maybe because it is a relatively recent 
'framework') has a clear definition of the pixel formats.


Fabien


On 10/27/2016 08:16 AM, Guennadi Liakhovetski wrote:
> Hi,
>
> Looks like the Linux definition of the (packed) YUV444 format contradicts
> wikipedia. According to
> https://linuxtv.org/downloads/v4l-dvb-apis-new/uapi/v4l/pixfmt-packed-yuv.html
> The Linux V4L2_PIX_FMT_YUV444 format takes 16 bits per pixel, whereas the
> wikipedia
> https://en.wikipedia.org/wiki/YUV#Converting_between_Y.E2.80.B2UV_and_RGB
> says it's 24 bits per pixel. I understand that the wikipedia doesn't have
> an absolute authority, but I also saw other sources using the same
> definition. So, looks like some confusion is possible.
>
> Thanks
> Guennadi
> --
> 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 1/3] doc-rst: generic way to build PDF of sub-folders

2016-11-02 Thread Jani Nikula
On Wed, 02 Nov 2016, Markus Heiser  wrote:
> Am 02.11.2016 um 12:43 schrieb Jani Nikula :
>
>> On Wed, 24 Aug 2016, Markus Heiser  wrote:
>>> From: Markus Heiser 
>>> 
>>> This extends the method to build only sub-folders to the targets
>>> "latexdocs" and "pdfdocs". To do so, a conf.py in the sub-folder is
>>> required, where the latex_documents of the sub-folder are
>>> defined. E.g. to build only gpu's PDF add the following to the
>>> Documentation/gpu/conf.py::
>>> 
>>>  +latex_documents = [
>>>  +("index", "gpu.tex", "Linux GPU Driver Developer's Guide",
>>>  + "The kernel development community", "manual"),
>>>  +]
>>> 
>>> and run:
>>> 
>>>  make SPHINXDIRS=gpu pdfdocs
>> 
>> Did you ever try this with more than one subfolder?
>
> Seems not, there is a ";" missed in the 'foreach' loop, see patch
> below.
>
> To avoid conflicts, can you apply the ";" on your 
> "Makefile.sphinx improvements" series? / Thanks

Thanks, done.

http://lkml.kernel.org/r/1478097913-12561-1-git-send-email-jani.nik...@intel.com

>
> diff --git a/Documentation/Makefile.sphinx b/Documentation/Makefile.sphinx
> index 92deea3..b7fbd12 100644
> --- a/Documentation/Makefile.sphinx
> +++ b/Documentation/Makefile.sphinx
> @@ -76,7 +76,7 @@ endif # HAVE_PDFLATEX
>  
>  pdfdocs: latexdocs
>  ifneq ($(HAVE_PDFLATEX),0)
> -   $(foreach var,$(SPHINXDIRS), $(MAKE) PDFLATEX=xelatex 
> LATEXOPTS="-interaction=nonstopmode" -C $(BUILDDIR)/$(var)/latex)
> +   $(foreach var,$(SPHINXDIRS), $(MAKE) PDFLATEX=xelatex 
> LATEXOPTS="-interaction=nonstopmode" -C $(BUILDDIR)/$(var)/latex;)
>  endif # HAVE_PDFLATEX
>  
>  epubdocs:
>
>
> --Markus --
>

-- 
Jani Nikula, Intel Open Source Technology Center
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] doc-rst: generic way to build PDF of sub-folders

2016-11-02 Thread Markus Heiser

Am 02.11.2016 um 12:43 schrieb Jani Nikula :

> On Wed, 24 Aug 2016, Markus Heiser  wrote:
>> From: Markus Heiser 
>> 
>> This extends the method to build only sub-folders to the targets
>> "latexdocs" and "pdfdocs". To do so, a conf.py in the sub-folder is
>> required, where the latex_documents of the sub-folder are
>> defined. E.g. to build only gpu's PDF add the following to the
>> Documentation/gpu/conf.py::
>> 
>>  +latex_documents = [
>>  +("index", "gpu.tex", "Linux GPU Driver Developer's Guide",
>>  + "The kernel development community", "manual"),
>>  +]
>> 
>> and run:
>> 
>>  make SPHINXDIRS=gpu pdfdocs
> 
> Did you ever try this with more than one subfolder?

Seems not, there is a ";" missed in the 'foreach' loop, see patch
below.

To avoid conflicts, can you apply the ";" on your 
"Makefile.sphinx improvements" series? / Thanks

diff --git a/Documentation/Makefile.sphinx b/Documentation/Makefile.sphinx
index 92deea3..b7fbd12 100644
--- a/Documentation/Makefile.sphinx
+++ b/Documentation/Makefile.sphinx
@@ -76,7 +76,7 @@ endif # HAVE_PDFLATEX
 
 pdfdocs: latexdocs
 ifneq ($(HAVE_PDFLATEX),0)
-   $(foreach var,$(SPHINXDIRS), $(MAKE) PDFLATEX=xelatex 
LATEXOPTS="-interaction=nonstopmode" -C $(BUILDDIR)/$(var)/latex)
+   $(foreach var,$(SPHINXDIRS), $(MAKE) PDFLATEX=xelatex 
LATEXOPTS="-interaction=nonstopmode" -C $(BUILDDIR)/$(var)/latex;)
 endif # HAVE_PDFLATEX
 
 epubdocs:


--Markus --

--
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 14/32] media: rcar-vin: move chip information to own struct

2016-11-02 Thread Niklas Söderlund
When Gen3 support is added to the driver more then chip id will be
different for the different Soc. To avoid a lot of if statements in the
code create a struct chip_info to contain this information.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-core.c | 49 -
 drivers/media/platform/rcar-vin/rcar-v4l2.c |  3 +-
 drivers/media/platform/rcar-vin/rcar-vin.h  | 12 +--
 3 files changed, 53 insertions(+), 11 deletions(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
b/drivers/media/platform/rcar-vin/rcar-core.c
index 5807d8d..372443e 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -253,14 +253,47 @@ static int rvin_digital_graph_init(struct rvin_dev *vin)
  * Platform Device Driver
  */
 
+static const struct rvin_info rcar_info_h1 = {
+   .chip = RCAR_H1,
+};
+
+static const struct rvin_info rcar_info_m1 = {
+   .chip = RCAR_M1,
+};
+
+static const struct rvin_info rcar_info_gen2 = {
+   .chip = RCAR_GEN2,
+};
+
 static const struct of_device_id rvin_of_id_table[] = {
-   { .compatible = "renesas,vin-r8a7794", .data = (void *)RCAR_GEN2 },
-   { .compatible = "renesas,vin-r8a7793", .data = (void *)RCAR_GEN2 },
-   { .compatible = "renesas,vin-r8a7791", .data = (void *)RCAR_GEN2 },
-   { .compatible = "renesas,vin-r8a7790", .data = (void *)RCAR_GEN2 },
-   { .compatible = "renesas,vin-r8a7779", .data = (void *)RCAR_H1 },
-   { .compatible = "renesas,vin-r8a7778", .data = (void *)RCAR_M1 },
-   { .compatible = "renesas,rcar-gen2-vin", .data = (void *)RCAR_GEN2 },
+   {
+   .compatible = "renesas,vin-r8a7794",
+   .data = (void *)_info_gen2,
+   },
+   {
+   .compatible = "renesas,vin-r8a7793",
+   .data = (void *)_info_gen2,
+   },
+   {
+   .compatible = "renesas,vin-r8a7791",
+   .data = (void *)_info_gen2,
+   },
+   {
+   .compatible = "renesas,vin-r8a7790",
+   .data = (void *)_info_gen2,
+   },
+   {
+   .compatible = "renesas,vin-r8a7779",
+   .data = (void *)_info_h1,
+   },
+   {
+   .compatible = "renesas,vin-r8a7778",
+   .data = (void *)_info_m1,
+   },
+   {
+   .compatible = "renesas,rcar-gen2-vin",
+   .data = (void *)_info_gen2,
+   },
{ },
 };
 MODULE_DEVICE_TABLE(of, rvin_of_id_table);
@@ -281,7 +314,7 @@ static int rcar_vin_probe(struct platform_device *pdev)
return -ENODEV;
 
vin->dev = >dev;
-   vin->chip = (enum chip_id)match->data;
+   vin->info = (const struct rvin_info *)match->data;
vin->last_input = NULL;
 
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index 47137d7..05b0181 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -279,7 +279,8 @@ static int __rvin_try_format(struct rvin_dev *vin,
pix->sizeimage = max_t(u32, pix->sizeimage,
   rvin_format_sizeimage(pix));
 
-   if (vin->chip == RCAR_M1 && pix->pixelformat == V4L2_PIX_FMT_XBGR32) {
+   if (vin->info->chip == RCAR_M1 &&
+   pix->pixelformat == V4L2_PIX_FMT_XBGR32) {
vin_err(vin, "pixel format XBGR32 not supported on M1\n");
return -EINVAL;
}
diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h 
b/drivers/media/platform/rcar-vin/rcar-vin.h
index 2a1b190..17a5fce 100644
--- a/drivers/media/platform/rcar-vin/rcar-vin.h
+++ b/drivers/media/platform/rcar-vin/rcar-vin.h
@@ -89,10 +89,18 @@ struct rvin_graph_entity {
 };
 
 /**
+ * struct rvin_info- Information about the particular VIN implementation
+ * @chip:  type of VIN chip
+ */
+struct rvin_info {
+   enum chip_id chip;
+};
+
+/**
  * struct rvin_dev - Renesas VIN device structure
  * @dev:   (OF) device
  * @base:  device I/O register space remapped to virtual memory
- * @chip:  type of VIN chip
+ * @info   info about VIN instance
  *
  * @vdev:  V4L2 video device associated with VIN
  * @v4l2_dev:  V4L2 device
@@ -121,7 +129,7 @@ struct rvin_graph_entity {
 struct rvin_dev {
struct device *dev;
void __iomem *base;
-   enum chip_id chip;
+   const struct rvin_info *info;
 
struct video_device vdev;
struct v4l2_device v4l2_dev;
-- 
2.10.2

--
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 16/32] media: rcar-vin: change name of video device

2016-11-02 Thread Niklas Söderlund
The rcar-vin driver needs to be part of a media controller to support
Gen3. Give each VIN instance a unique name so it can be referenced from
userspace.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-v4l2.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index f5fbe9f..e99815f 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -944,7 +944,8 @@ int rvin_v4l2_probe(struct rvin_dev *vin)
vdev->fops = _fops;
vdev->v4l2_dev = >v4l2_dev;
vdev->queue = >queue;
-   strlcpy(vdev->name, KBUILD_MODNAME, sizeof(vdev->name));
+   snprintf(vdev->name, sizeof(vdev->name), "%s.%s", KBUILD_MODNAME,
+dev_name(vin->dev));
vdev->release = video_device_release_empty;
vdev->ioctl_ops = _ioctl_ops;
vdev->lock = >lock;
-- 
2.10.2

--
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 18/32] media: rcar-vin: enable Gen3 hardware configuration

2016-11-02 Thread Niklas Söderlund
Add the register needed to work with Gen3 hardware. This patch adds
the logic for how to work with the Gen3 hardware. More work is required
to enable the subdevice structure needed to configure capturing.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-dma.c | 98 --
 drivers/media/platform/rcar-vin/rcar-vin.h |  1 +
 2 files changed, 68 insertions(+), 31 deletions(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c 
b/drivers/media/platform/rcar-vin/rcar-dma.c
index eac5c19..80958e6 100644
--- a/drivers/media/platform/rcar-vin/rcar-dma.c
+++ b/drivers/media/platform/rcar-vin/rcar-dma.c
@@ -33,21 +33,23 @@
 #define VNELPRC_REG0x10/* Video n End Line Pre-Clip Register */
 #define VNSPPRC_REG0x14/* Video n Start Pixel Pre-Clip Register */
 #define VNEPPRC_REG0x18/* Video n End Pixel Pre-Clip Register */
-#define VNSLPOC_REG0x1C/* Video n Start Line Post-Clip Register */
-#define VNELPOC_REG0x20/* Video n End Line Post-Clip Register */
-#define VNSPPOC_REG0x24/* Video n Start Pixel Post-Clip Register */
-#define VNEPPOC_REG0x28/* Video n End Pixel Post-Clip Register */
 #define VNIS_REG   0x2C/* Video n Image Stride Register */
 #define VNMB_REG(m)(0x30 + ((m) << 2)) /* Video n Memory Base m Register */
 #define VNIE_REG   0x40/* Video n Interrupt Enable Register */
 #define VNINTS_REG 0x44/* Video n Interrupt Status Register */
 #define VNSI_REG   0x48/* Video n Scanline Interrupt Register */
 #define VNMTC_REG  0x4C/* Video n Memory Transfer Control Register */
-#define VNYS_REG   0x50/* Video n Y Scale Register */
-#define VNXS_REG   0x54/* Video n X Scale Register */
 #define VNDMR_REG  0x58/* Video n Data Mode Register */
 #define VNDMR2_REG 0x5C/* Video n Data Mode Register 2 */
 #define VNUVAOF_REG0x60/* Video n UV Address Offset Register */
+
+/* Register offsets specific for Gen2 */
+#define VNSLPOC_REG0x1C/* Video n Start Line Post-Clip Register */
+#define VNELPOC_REG0x20/* Video n End Line Post-Clip Register */
+#define VNSPPOC_REG0x24/* Video n Start Pixel Post-Clip Register */
+#define VNEPPOC_REG0x28/* Video n End Pixel Post-Clip Register */
+#define VNYS_REG   0x50/* Video n Y Scale Register */
+#define VNXS_REG   0x54/* Video n X Scale Register */
 #define VNC1A_REG  0x80/* Video n Coefficient Set C1A Register */
 #define VNC1B_REG  0x84/* Video n Coefficient Set C1B Register */
 #define VNC1C_REG  0x88/* Video n Coefficient Set C1C Register */
@@ -73,9 +75,13 @@
 #define VNC8B_REG  0xF4/* Video n Coefficient Set C8B Register */
 #define VNC8C_REG  0xF8/* Video n Coefficient Set C8C Register */
 
+/* Register offsets specific for Gen3 */
+#define VNCSI_IFMD_REG 0x20 /* Video n CSI2 Interface Mode Register */
 
 /* Register bit fields for R-Car VIN */
 /* Video n Main Control Register bits */
+#define VNMC_DPINE (1 << 27) /* Gen3 specific */
+#define VNMC_SCLE  (1 << 26) /* Gen3 specific */
 #define VNMC_FOC   (1 << 21)
 #define VNMC_YCAL  (1 << 19)
 #define VNMC_INF_YUV8_BT656(0 << 16)
@@ -119,6 +125,13 @@
 #define VNDMR2_FTEV(1 << 17)
 #define VNDMR2_VLV(n)  ((n & 0xf) << 12)
 
+/* Video n CSI2 Interface Mode Register (Gen3) */
+#define VNCSI_IFMD_DES2(1 << 27)
+#define VNCSI_IFMD_DES1(1 << 26)
+#define VNCSI_IFMD_DES0(1 << 25)
+#define VNCSI_IFMD_CSI_CHSEL(n) ((n & 0xf) << 0)
+#define VNCSI_IFMD_CSI_CHSEL_MASK 0xf
+
 static void rvin_write(struct rvin_dev *vin, u32 value, u32 offset)
 {
iowrite32(value, vin->base + offset);
@@ -205,7 +218,10 @@ static int rvin_setup(struct rvin_dev *vin)
}
 
/* Enable VSYNC Field Toogle mode after one VSYNC input */
-   dmr2 = VNDMR2_FTEV | VNDMR2_VLV(1);
+   if (vin->info->chip == RCAR_GEN3)
+   dmr2 = VNDMR2_FTEV;
+   else
+   dmr2 = VNDMR2_FTEV | VNDMR2_VLV(1);
 
/* Hsync Signal Polarity Select */
if (!(rent->mbus_cfg.flags & V4L2_MBUS_HSYNC_ACTIVE_LOW))
@@ -257,6 +273,14 @@ static int rvin_setup(struct rvin_dev *vin)
if (input_is_yuv == output_is_yuv)
vnmc |= VNMC_BPS;
 
+   if (vin->info->chip == RCAR_GEN3) {
+   /* Select between CSI-2 and Digital input */
+   if (rent->mbus_cfg.type == V4L2_MBUS_CSI2)
+   vnmc &= ~VNMC_DPINE;
+   else
+   vnmc |= VNMC_DPINE;
+   }
+
/* Progressive or interlaced mode */
interrupts = progressive ? VNIE_FIE : VNIE_EFE;
 
@@ -758,28 +782,10 @@ static void rvin_set_coeff(struct rvin_dev *vin, unsigned 
short xs)
rvin_write(vin, p_set->coeff_set[23], VNC8C_REG);
 }
 

[PATCH 07/32] media: rcar-vin: add wrapper to get rvin_graph_entity

2016-11-02 Thread Niklas Söderlund
Update the driver to retrieve the code and mbus_cfg values from a
rvin_graph_entity retrieved from a wrapper function instead of directly
accessing the entity for the digital port. This is done to prepare for
Gen3 support where the subdeivce might change during runtime, so to
directly accesses a specific rvin_graph_entity is bad.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-core.c |  9 +
 drivers/media/platform/rcar-vin/rcar-dma.c  | 15 ++-
 drivers/media/platform/rcar-vin/rcar-v4l2.c |  6 +-
 drivers/media/platform/rcar-vin/rcar-vin.h  |  1 +
 4 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
b/drivers/media/platform/rcar-vin/rcar-core.c
index 098a0b1..89a9280 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -26,6 +26,15 @@
 #include "rcar-vin.h"
 
 /* 
-
+ * Subdevice helpers
+ */
+
+struct rvin_graph_entity *vin_to_entity(struct rvin_dev *vin)
+{
+   return >digital;
+}
+
+/* 
-
  * Async notifier
  */
 
diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c 
b/drivers/media/platform/rcar-vin/rcar-dma.c
index 9ccd5ff..eac5c19 100644
--- a/drivers/media/platform/rcar-vin/rcar-dma.c
+++ b/drivers/media/platform/rcar-vin/rcar-dma.c
@@ -131,10 +131,15 @@ static u32 rvin_read(struct rvin_dev *vin, u32 offset)
 
 static int rvin_setup(struct rvin_dev *vin)
 {
+   struct rvin_graph_entity *rent;
u32 vnmc, dmr, dmr2, interrupts;
v4l2_std_id std;
bool progressive = false, output_is_yuv = false, input_is_yuv = false;
 
+   rent = vin_to_entity(vin);
+   if (!rent)
+   return -ENODEV;
+
switch (vin->format.field) {
case V4L2_FIELD_TOP:
vnmc = VNMC_IM_ODD;
@@ -174,7 +179,7 @@ static int rvin_setup(struct rvin_dev *vin)
/*
 * Input interface
 */
-   switch (vin->digital.code) {
+   switch (rent->code) {
case MEDIA_BUS_FMT_YUYV8_1X16:
/* BT.601/BT.1358 16bit YCbCr422 */
vnmc |= VNMC_INF_YUV16;
@@ -182,7 +187,7 @@ static int rvin_setup(struct rvin_dev *vin)
break;
case MEDIA_BUS_FMT_UYVY8_2X8:
/* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */
-   vnmc |= vin->digital.mbus_cfg.type == V4L2_MBUS_BT656 ?
+   vnmc |= rent->mbus_cfg.type == V4L2_MBUS_BT656 ?
VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601;
input_is_yuv = true;
break;
@@ -191,7 +196,7 @@ static int rvin_setup(struct rvin_dev *vin)
break;
case MEDIA_BUS_FMT_UYVY10_2X10:
/* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */
-   vnmc |= vin->digital.mbus_cfg.type == V4L2_MBUS_BT656 ?
+   vnmc |= rent->mbus_cfg.type == V4L2_MBUS_BT656 ?
VNMC_INF_YUV10_BT656 : VNMC_INF_YUV10_BT601;
input_is_yuv = true;
break;
@@ -203,11 +208,11 @@ static int rvin_setup(struct rvin_dev *vin)
dmr2 = VNDMR2_FTEV | VNDMR2_VLV(1);
 
/* Hsync Signal Polarity Select */
-   if (!(vin->digital.mbus_cfg.flags & V4L2_MBUS_HSYNC_ACTIVE_LOW))
+   if (!(rent->mbus_cfg.flags & V4L2_MBUS_HSYNC_ACTIVE_LOW))
dmr2 |= VNDMR2_HPS;
 
/* Vsync Signal Polarity Select */
-   if (!(vin->digital.mbus_cfg.flags & V4L2_MBUS_VSYNC_ACTIVE_LOW))
+   if (!(rent->mbus_cfg.flags & V4L2_MBUS_VSYNC_ACTIVE_LOW))
dmr2 |= VNDMR2_VPS;
 
/*
diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index f9218f2..370bb18 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -164,6 +164,7 @@ static int __rvin_try_format_source(struct rvin_dev *vin,
 {
struct v4l2_subdev *sd;
struct v4l2_subdev_pad_config *pad_cfg;
+   struct rvin_graph_entity *rent;
struct v4l2_subdev_format format = {
.which = which,
};
@@ -171,8 +172,11 @@ static int __rvin_try_format_source(struct rvin_dev *vin,
int ret;
 
sd = vin_to_source(vin);
+   rent = vin_to_entity(vin);
+   if (!rent)
+   return -ENODEV;
 
-   v4l2_fill_mbus_format(, pix, vin->digital.code);
+   v4l2_fill_mbus_format(, pix, rent->code);
 
pad_cfg = v4l2_subdev_alloc_pad_config(sd);
if (pad_cfg == NULL)
diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h 
b/drivers/media/platform/rcar-vin/rcar-vin.h
index 727e215..daec26a 100644
--- a/drivers/media/platform/rcar-vin/rcar-vin.h
+++ b/drivers/media/platform/rcar-vin/rcar-vin.h
@@ -144,6 +144,7 

[PATCH 06/32] media: rcar-vin: fix standard in input enumeration

2016-11-02 Thread Niklas Söderlund
If the subdevice supports dv_timings_cap the driver should not fill in
the standard. Also don't use the standard from probe time ask the
subdevice each time, this is done in preparation for Gen3 support where
the source subdevice might change during runtime.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-v4l2.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index 610f59e..f9218f2 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -483,10 +483,16 @@ static int rvin_enum_input(struct file *file, void *priv,
return ret;
 
i->type = V4L2_INPUT_TYPE_CAMERA;
-   i->std = vin->vdev.tvnorms;
 
-   if (v4l2_subdev_has_op(sd, pad, dv_timings_cap))
+   if (v4l2_subdev_has_op(sd, pad, dv_timings_cap)) {
i->capabilities = V4L2_IN_CAP_DV_TIMINGS;
+   i->std = 0;
+   } else {
+   i->capabilities = V4L2_IN_CAP_STD;
+   ret = v4l2_subdev_call(sd, video, g_tvnorms, >std);
+   if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV)
+   return ret;
+   }
 
strlcpy(i->name, "Camera", sizeof(i->name));
 
-- 
2.10.2

--
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 05/32] media: rcar-vin: fix how pads are handled for v4l2 subdeivce operations

2016-11-02 Thread Niklas Söderlund
The rcar-vin driver only uses one pad, pad number 0.

 All v4l2 operations which did not check that the requested operation
 was for pad 0 have been updated with a check to enforce this.

 All v4l2 operations that stored (and later restore) the requested pad
 before substituting it for the subdeivce pad number have been update
 not store the incoming pad and simply restore it to 0 after the
 subdevice operation is complete.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-v4l2.c | 26 ++
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index 7ca2759..610f59e 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -550,14 +550,16 @@ static int rvin_enum_dv_timings(struct file *file, void 
*priv_fh,
 {
struct rvin_dev *vin = video_drvdata(file);
struct v4l2_subdev *sd = vin_to_source(vin);
-   int pad, ret;
+   int ret;
+
+   if (timings->pad)
+   return -EINVAL;
 
-   pad = timings->pad;
timings->pad = vin->sink_pad_idx;
 
ret = v4l2_subdev_call(sd, pad, enum_dv_timings, timings);
 
-   timings->pad = pad;
+   timings->pad = 0;
 
return ret;
 }
@@ -600,14 +602,16 @@ static int rvin_dv_timings_cap(struct file *file, void 
*priv_fh,
 {
struct rvin_dev *vin = video_drvdata(file);
struct v4l2_subdev *sd = vin_to_source(vin);
-   int pad, ret;
+   int ret;
+
+   if (cap->pad)
+   return -EINVAL;
 
-   pad = cap->pad;
cap->pad = vin->sink_pad_idx;
 
ret = v4l2_subdev_call(sd, pad, dv_timings_cap, cap);
 
-   cap->pad = pad;
+   cap->pad = 0;
 
return ret;
 }
@@ -616,17 +620,16 @@ static int rvin_g_edid(struct file *file, void *fh, 
struct v4l2_edid *edid)
 {
struct rvin_dev *vin = video_drvdata(file);
struct v4l2_subdev *sd = vin_to_source(vin);
-   int input, ret;
+   int ret;
 
if (edid->pad)
return -EINVAL;
 
-   input = edid->pad;
edid->pad = vin->sink_pad_idx;
 
ret = v4l2_subdev_call(sd, pad, get_edid, edid);
 
-   edid->pad = input;
+   edid->pad = 0;
 
return ret;
 }
@@ -635,17 +638,16 @@ static int rvin_s_edid(struct file *file, void *fh, 
struct v4l2_edid *edid)
 {
struct rvin_dev *vin = video_drvdata(file);
struct v4l2_subdev *sd = vin_to_source(vin);
-   int input, ret;
+   int ret;
 
if (edid->pad)
return -EINVAL;
 
-   input = edid->pad;
edid->pad = vin->sink_pad_idx;
 
ret = v4l2_subdev_call(sd, pad, set_edid, edid);
 
-   edid->pad = input;
+   edid->pad = 0;
 
return ret;
 }
-- 
2.10.2

--
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 11/32] media: rcar-vin: refactor pad lookup code

2016-11-02 Thread Niklas Söderlund
The code to lookup which pad is source and sink can be broken out to a
helper function.

A bad check is also dropped in this refactoring. If the subdeivce don't
supply pad information the driver would not be able to use it if the
check is kept.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-core.c | 29 +
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
b/drivers/media/platform/rcar-vin/rcar-core.c
index fb6368c..50058fe 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -66,11 +66,21 @@ static bool rvin_mbus_supported(struct rvin_graph_entity 
*entity)
return false;
 }
 
+static unsigned int rvin_pad_idx(struct v4l2_subdev *sd, int direction)
+{
+   unsigned int pad_idx;
+
+   for (pad_idx = 0; pad_idx < sd->entity.num_pads; pad_idx++)
+   if (sd->entity.pads[pad_idx].flags == direction)
+   return pad_idx;
+
+   return 0;
+}
+
 static int rvin_digital_notify_complete(struct v4l2_async_notifier *notifier)
 {
struct rvin_dev *vin = notifier_to_vin(notifier);
struct v4l2_subdev *sd = vin->digital.subdev;
-   unsigned int pad_idx;
int ret;
 
/* Verify subdevices mbus format */
@@ -84,21 +94,8 @@ static int rvin_digital_notify_complete(struct 
v4l2_async_notifier *notifier)
vin->digital.subdev->name, vin->digital.code);
 
/* Figure out source and sink pad ids */
-   vin->digital.source_pad_idx = 0;
-   for (pad_idx = 0; pad_idx < sd->entity.num_pads; pad_idx++)
-   if (sd->entity.pads[pad_idx].flags == MEDIA_PAD_FL_SOURCE)
-   break;
-   if (pad_idx >= sd->entity.num_pads)
-   return -EINVAL;
-
-   vin->digital.source_pad_idx = pad_idx;
-
-   vin->digital.sink_pad_idx = 0;
-   for (pad_idx = 0; pad_idx < sd->entity.num_pads; pad_idx++)
-   if (sd->entity.pads[pad_idx].flags == MEDIA_PAD_FL_SINK) {
-   vin->digital.sink_pad_idx = pad_idx;
-   break;
-   }
+   vin->digital.source_pad_idx = rvin_pad_idx(sd, MEDIA_PAD_FL_SOURCE);
+   vin->digital.sink_pad_idx = rvin_pad_idx(sd, MEDIA_PAD_FL_SINK);
 
vin_dbg(vin, "Found media pads for %s source: %d sink %d\n",
vin->digital.subdev->name, vin->digital.source_pad_idx,
-- 
2.10.2

--
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 15/32] media: rcar-vin: move max width and height information to chip information

2016-11-02 Thread Niklas Söderlund
On Gen3 the max supported width and height will be different from Gen2.
Move the limits to the struct chip_info to prepare for Gen3 support.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-core.c | 6 ++
 drivers/media/platform/rcar-vin/rcar-v4l2.c | 6 ++
 drivers/media/platform/rcar-vin/rcar-vin.h  | 6 ++
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
b/drivers/media/platform/rcar-vin/rcar-core.c
index 372443e..e3dea60 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -255,14 +255,20 @@ static int rvin_digital_graph_init(struct rvin_dev *vin)
 
 static const struct rvin_info rcar_info_h1 = {
.chip = RCAR_H1,
+   .max_width = 2048,
+   .max_height = 2048,
 };
 
 static const struct rvin_info rcar_info_m1 = {
.chip = RCAR_M1,
+   .max_width = 2048,
+   .max_height = 2048,
 };
 
 static const struct rvin_info rcar_info_gen2 = {
.chip = RCAR_GEN2,
+   .max_width = 2048,
+   .max_height = 2048,
 };
 
 static const struct of_device_id rvin_of_id_table[] = {
diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index 05b0181..f5fbe9f 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -23,8 +23,6 @@
 #include "rcar-vin.h"
 
 #define RVIN_DEFAULT_FORMATV4L2_PIX_FMT_YUYV
-#define RVIN_MAX_WIDTH 2048
-#define RVIN_MAX_HEIGHT2048
 
 /* 
-
  * Format Conversions
@@ -271,8 +269,8 @@ static int __rvin_try_format(struct rvin_dev *vin,
walign = vin->format.pixelformat == V4L2_PIX_FMT_NV16 ? 5 : 1;
 
/* Limit to VIN capabilities */
-   v4l_bound_align_image(>width, 2, RVIN_MAX_WIDTH, walign,
- >height, 4, RVIN_MAX_HEIGHT, 2, 0);
+   v4l_bound_align_image(>width, 2, vin->info->max_width, walign,
+ >height, 4, vin->info->max_height, 2, 0);
 
pix->bytesperline = max_t(u32, pix->bytesperline,
  rvin_format_bytesperline(pix));
diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h 
b/drivers/media/platform/rcar-vin/rcar-vin.h
index 17a5fce..ddeca9f 100644
--- a/drivers/media/platform/rcar-vin/rcar-vin.h
+++ b/drivers/media/platform/rcar-vin/rcar-vin.h
@@ -91,9 +91,15 @@ struct rvin_graph_entity {
 /**
  * struct rvin_info- Information about the particular VIN implementation
  * @chip:  type of VIN chip
+ *
+ * max_width:  max input with the VIN supports
+ * max_height: max input height the VIN supports
  */
 struct rvin_info {
enum chip_id chip;
+
+   unsigned int max_width;
+   unsigned int max_height;
 };
 
 /**
-- 
2.10.2

--
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 10/32] media: rcar-vin: use pad information when verifying media bus format

2016-11-02 Thread Niklas Söderlund
Now that the pad information is present in struct rvin_graph_entity use
it when verifying the media bus format.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
b/drivers/media/platform/rcar-vin/rcar-core.c
index 2c40b6a..fb6368c 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -48,6 +48,7 @@ static bool rvin_mbus_supported(struct rvin_graph_entity 
*entity)
};
 
code.index = 0;
+   code.pad = entity->source_pad_idx;
while (!v4l2_subdev_call(sd, pad, enum_mbus_code, NULL, )) {
code.index++;
switch (code.code) {
-- 
2.10.2

--
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 17/32] media: rcar-vin: clarify error message from the digital notifier

2016-11-02 Thread Niklas Söderlund
Some of the parser functions previously only used by the digital
subdevice OF/V4L2 async code will be shared with the CSI2 group
notifiers. Clarify which notifier register error message and mark which
functions are generic helpers.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-core.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
b/drivers/media/platform/rcar-vin/rcar-core.c
index e3dea60..f961957 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -35,7 +35,7 @@ struct rvin_graph_entity *vin_to_entity(struct rvin_dev *vin)
 }
 
 /* 
-
- * Async notifier
+ * Async notifier helpers
  */
 
 #define notifier_to_vin(n) container_of(n, struct rvin_dev, notifier)
@@ -77,6 +77,10 @@ static unsigned int rvin_pad_idx(struct v4l2_subdev *sd, int 
direction)
return 0;
 }
 
+/* 
-
+ * Digital async notifier
+ */
+
 static int rvin_digital_notify_complete(struct v4l2_async_notifier *notifier)
 {
struct rvin_dev *vin = notifier_to_vin(notifier);
@@ -242,7 +246,7 @@ static int rvin_digital_graph_init(struct rvin_dev *vin)
 
ret = v4l2_async_notifier_register(>v4l2_dev, >notifier);
if (ret < 0) {
-   vin_err(vin, "Notifier registration failed\n");
+   vin_err(vin, "Digital notifier registration failed\n");
return ret;
}
 
-- 
2.10.2

--
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 04/32] media: rcar-vin: use rvin_reset_format() in S_DV_TIMINGS

2016-11-02 Thread Niklas Söderlund
Use rvin_reset_format() in rvin_s_dv_timings() instead if just resetting
a few fields. This fixes an issue where the field format was not
properly set after S_DV_TIMINGS.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-v4l2.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index 69bc4cf..7ca2759 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -573,12 +573,8 @@ static int rvin_s_dv_timings(struct file *file, void 
*priv_fh,
if (ret)
return ret;
 
-   vin->source.width = timings->bt.width;
-   vin->source.height = timings->bt.height;
-   vin->format.width = timings->bt.width;
-   vin->format.height = timings->bt.height;
-
-   return 0;
+   /* Changing the timings will change the width/height */
+   return rvin_reset_format(vin);
 }
 
 static int rvin_g_dv_timings(struct file *file, void *priv_fh,
-- 
2.10.2

--
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 09/32] media: rcar-vin: move pad number discovery to async complete handler

2016-11-02 Thread Niklas Söderlund
The rvin_v4l2_probe() handler will with Gen3 support need to handle more
then one subdevice. To prepare for this move the digital subdev pad
number discover to the digital specific async notification complete
function.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-core.c | 23 +++
 drivers/media/platform/rcar-vin/rcar-v4l2.c | 18 +-
 2 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
b/drivers/media/platform/rcar-vin/rcar-core.c
index 89a9280..2c40b6a 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -68,6 +68,8 @@ static bool rvin_mbus_supported(struct rvin_graph_entity 
*entity)
 static int rvin_digital_notify_complete(struct v4l2_async_notifier *notifier)
 {
struct rvin_dev *vin = notifier_to_vin(notifier);
+   struct v4l2_subdev *sd = vin->digital.subdev;
+   unsigned int pad_idx;
int ret;
 
/* Verify subdevices mbus format */
@@ -80,6 +82,27 @@ static int rvin_digital_notify_complete(struct 
v4l2_async_notifier *notifier)
vin_dbg(vin, "Found media bus format for %s: %d\n",
vin->digital.subdev->name, vin->digital.code);
 
+   /* Figure out source and sink pad ids */
+   vin->digital.source_pad_idx = 0;
+   for (pad_idx = 0; pad_idx < sd->entity.num_pads; pad_idx++)
+   if (sd->entity.pads[pad_idx].flags == MEDIA_PAD_FL_SOURCE)
+   break;
+   if (pad_idx >= sd->entity.num_pads)
+   return -EINVAL;
+
+   vin->digital.source_pad_idx = pad_idx;
+
+   vin->digital.sink_pad_idx = 0;
+   for (pad_idx = 0; pad_idx < sd->entity.num_pads; pad_idx++)
+   if (sd->entity.pads[pad_idx].flags == MEDIA_PAD_FL_SINK) {
+   vin->digital.sink_pad_idx = pad_idx;
+   break;
+   }
+
+   vin_dbg(vin, "Found media pads for %s source: %d sink %d\n",
+   vin->digital.subdev->name, vin->digital.source_pad_idx,
+   vin->digital.sink_pad_idx);
+
ret = v4l2_device_register_subdev_nodes(>v4l2_dev);
if (ret < 0) {
vin_err(vin, "Failed to register subdev nodes\n");
diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index f8ff7c4..51324c6 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -905,7 +905,7 @@ int rvin_v4l2_probe(struct rvin_dev *vin)
 {
struct video_device *vdev = >vdev;
struct v4l2_subdev *sd = vin_to_source(vin);
-   int pad_idx, ret;
+   int ret;
 
v4l2_set_subdev_hostdata(sd, vin);
 
@@ -951,22 +951,6 @@ int rvin_v4l2_probe(struct rvin_dev *vin)
vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING |
V4L2_CAP_READWRITE;
 
-   vin->digital.source_pad_idx = 0;
-   for (pad_idx = 0; pad_idx < sd->entity.num_pads; pad_idx++)
-   if (sd->entity.pads[pad_idx].flags == MEDIA_PAD_FL_SOURCE)
-   break;
-   if (pad_idx >= sd->entity.num_pads)
-   return -EINVAL;
-
-   vin->digital.source_pad_idx = pad_idx;
-
-   vin->digital.sink_pad_idx = 0;
-   for (pad_idx = 0; pad_idx < sd->entity.num_pads; pad_idx++)
-   if (sd->entity.pads[pad_idx].flags == MEDIA_PAD_FL_SINK) {
-   vin->digital.sink_pad_idx = pad_idx;
-   break;
-   }
-
vin->format.pixelformat = RVIN_DEFAULT_FORMAT;
rvin_reset_format(vin);
 
-- 
2.10.2

--
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 08/32] media: rcar-vin: move subdev source and sink pad index to rvin_graph_entity

2016-11-02 Thread Niklas Söderlund
Move the sink and source pad index from struct rvin_dev to struct
rvin_graph_entity. This is done in preparation of Gen3 support where the
active subdeivce can be changed during runtime. And if the subdevice is
changed the pad numbers are different so it's better to read them a
rvin_graph_entity then from directly from the rvin_dev.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-v4l2.c | 45 ++---
 drivers/media/platform/rcar-vin/rcar-vin.h  | 17 ++-
 2 files changed, 44 insertions(+), 18 deletions(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index 370bb18..f8ff7c4 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -109,9 +109,14 @@ static int rvin_reset_format(struct rvin_dev *vin)
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
struct v4l2_mbus_framefmt *mf = 
+   struct rvin_graph_entity *rent;
int ret;
 
-   fmt.pad = vin->src_pad_idx;
+   rent = vin_to_entity(vin);
+   if (!rent)
+   return -ENODEV;
+
+   fmt.pad = rent->source_pad_idx;
 
ret = v4l2_subdev_call(vin_to_source(vin), pad, get_fmt, NULL, );
if (ret)
@@ -182,7 +187,7 @@ static int __rvin_try_format_source(struct rvin_dev *vin,
if (pad_cfg == NULL)
return -ENOMEM;
 
-   format.pad = vin->src_pad_idx;
+   format.pad = rent->source_pad_idx;
 
field = pix->field;
 
@@ -560,12 +565,17 @@ static int rvin_enum_dv_timings(struct file *file, void 
*priv_fh,
 {
struct rvin_dev *vin = video_drvdata(file);
struct v4l2_subdev *sd = vin_to_source(vin);
+   struct rvin_graph_entity *rent;
int ret;
 
+   rent = vin_to_entity(vin);
+   if (!rent)
+   return -ENODEV;
+
if (timings->pad)
return -EINVAL;
 
-   timings->pad = vin->sink_pad_idx;
+   timings->pad = rent->sink_pad_idx;
 
ret = v4l2_subdev_call(sd, pad, enum_dv_timings, timings);
 
@@ -612,12 +622,17 @@ static int rvin_dv_timings_cap(struct file *file, void 
*priv_fh,
 {
struct rvin_dev *vin = video_drvdata(file);
struct v4l2_subdev *sd = vin_to_source(vin);
+   struct rvin_graph_entity *rent;
int ret;
 
+   rent = vin_to_entity(vin);
+   if (!rent)
+   return -ENODEV;
+
if (cap->pad)
return -EINVAL;
 
-   cap->pad = vin->sink_pad_idx;
+   cap->pad = rent->sink_pad_idx;
 
ret = v4l2_subdev_call(sd, pad, dv_timings_cap, cap);
 
@@ -630,12 +645,17 @@ static int rvin_g_edid(struct file *file, void *fh, 
struct v4l2_edid *edid)
 {
struct rvin_dev *vin = video_drvdata(file);
struct v4l2_subdev *sd = vin_to_source(vin);
+   struct rvin_graph_entity *rent;
int ret;
 
+   rent = vin_to_entity(vin);
+   if (!rent)
+   return -ENODEV;
+
if (edid->pad)
return -EINVAL;
 
-   edid->pad = vin->sink_pad_idx;
+   edid->pad = rent->sink_pad_idx;
 
ret = v4l2_subdev_call(sd, pad, get_edid, edid);
 
@@ -648,12 +668,17 @@ static int rvin_s_edid(struct file *file, void *fh, 
struct v4l2_edid *edid)
 {
struct rvin_dev *vin = video_drvdata(file);
struct v4l2_subdev *sd = vin_to_source(vin);
+   struct rvin_graph_entity *rent;
int ret;
 
+   rent = vin_to_entity(vin);
+   if (!rent)
+   return -ENODEV;
+
if (edid->pad)
return -EINVAL;
 
-   edid->pad = vin->sink_pad_idx;
+   edid->pad = rent->sink_pad_idx;
 
ret = v4l2_subdev_call(sd, pad, set_edid, edid);
 
@@ -926,19 +951,19 @@ int rvin_v4l2_probe(struct rvin_dev *vin)
vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING |
V4L2_CAP_READWRITE;
 
-   vin->src_pad_idx = 0;
+   vin->digital.source_pad_idx = 0;
for (pad_idx = 0; pad_idx < sd->entity.num_pads; pad_idx++)
if (sd->entity.pads[pad_idx].flags == MEDIA_PAD_FL_SOURCE)
break;
if (pad_idx >= sd->entity.num_pads)
return -EINVAL;
 
-   vin->src_pad_idx = pad_idx;
+   vin->digital.source_pad_idx = pad_idx;
 
-   vin->sink_pad_idx = 0;
+   vin->digital.sink_pad_idx = 0;
for (pad_idx = 0; pad_idx < sd->entity.num_pads; pad_idx++)
if (sd->entity.pads[pad_idx].flags == MEDIA_PAD_FL_SINK) {
-   vin->sink_pad_idx = pad_idx;
+   vin->digital.sink_pad_idx = pad_idx;
break;
}
 
diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h 
b/drivers/media/platform/rcar-vin/rcar-vin.h
index daec26a..d31212a 100644
--- a/drivers/media/platform/rcar-vin/rcar-vin.h
+++ b/drivers/media/platform/rcar-vin/rcar-vin.h
@@ -70,10 

[PATCH 20/32] media: rcar-vin: expose a sink pad if we are on Gen3

2016-11-02 Thread Niklas Söderlund
Refactor the probe code path to look for the digital subdevice, if one
is found use it just like the driver did before (Gen2 mode) but if it's
not found prepare for a Gen3 mode by registering a pad for the media
controller API to use.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-core.c | 21 -
 drivers/media/platform/rcar-vin/rcar-vin.h  |  9 +
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
b/drivers/media/platform/rcar-vin/rcar-core.c
index f961957..ce8b59a 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -308,6 +308,25 @@ static const struct of_device_id rvin_of_id_table[] = {
 };
 MODULE_DEVICE_TABLE(of, rvin_of_id_table);
 
+static int rvin_graph_init(struct rvin_dev *vin)
+{
+   int ret;
+
+   /* Try to get digital video pipe */
+   ret = rvin_digital_graph_init(vin);
+
+   /* No digital pipe and we are on Gen3 try to joint CSI2 group */
+   if (ret == -ENODEV && vin->info->chip == RCAR_GEN3) {
+
+   vin->pads[RVIN_SINK].flags = MEDIA_PAD_FL_SINK;
+   ret = media_entity_pads_init(>vdev.entity, 1, vin->pads);
+   if (ret)
+   return ret;
+   }
+
+   return ret;
+}
+
 static int rcar_vin_probe(struct platform_device *pdev)
 {
const struct of_device_id *match;
@@ -343,7 +362,7 @@ static int rcar_vin_probe(struct platform_device *pdev)
if (ret)
return ret;
 
-   ret = rvin_digital_graph_init(vin);
+   ret = rvin_graph_init(vin);
if (ret < 0)
goto error;
 
diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h 
b/drivers/media/platform/rcar-vin/rcar-vin.h
index a6a49a96..8ed43be 100644
--- a/drivers/media/platform/rcar-vin/rcar-vin.h
+++ b/drivers/media/platform/rcar-vin/rcar-vin.h
@@ -36,6 +36,11 @@ enum chip_id {
RCAR_GEN3,
 };
 
+enum rvin_pads {
+   RVIN_SINK,
+   RVIN_PAD_MAX,
+};
+
 /**
  * STOPPED  - No operation in progress
  * RUNNING  - Operation in progress have buffers
@@ -115,6 +120,8 @@ struct rvin_info {
  * @notifier:  V4L2 asynchronous subdevs notifier
  * @digital:   entity in the DT for local digital subdevice
  *
+ * @pads:  pads for media controller
+ *
  * @lock:  protects @queue
  * @queue: vb2 buffers queue
  *
@@ -144,6 +151,8 @@ struct rvin_dev {
struct v4l2_async_notifier notifier;
struct rvin_graph_entity digital;
 
+   struct media_pad pads[RVIN_PAD_MAX];
+
struct mutex lock;
struct vb2_queue queue;
 
-- 
2.10.2

--
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 13/32] media: rcar-vin: register the video device early

2016-11-02 Thread Niklas Söderlund
This is done to prepare for Gen3 support where there can be more then
one video pipeline which can terminate in a particular VIN instance.
Each pipeline have its own set of subdevices so to attach to a specific
subdevice at probe time is not possible. The pipelines will be
configured using the media controller API.

This patch changes the rcar-vin behavior so that the video device is
registered at probe time but attaching to a subdeivce is only once the
video device node is opened. If at that time there is no video source
subdevice for the VIN to use the open will fail with -EBUSY.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-core.c |  10 +-
 drivers/media/platform/rcar-vin/rcar-v4l2.c | 226 ++--
 drivers/media/platform/rcar-vin/rcar-vin.h  |   2 +
 3 files changed, 121 insertions(+), 117 deletions(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
b/drivers/media/platform/rcar-vin/rcar-core.c
index 50058fe..5807d8d 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -107,7 +107,7 @@ static int rvin_digital_notify_complete(struct 
v4l2_async_notifier *notifier)
return ret;
}
 
-   return rvin_v4l2_probe(vin);
+   return 0;
 }
 
 static void rvin_digital_notify_unbind(struct v4l2_async_notifier *notifier,
@@ -118,7 +118,6 @@ static void rvin_digital_notify_unbind(struct 
v4l2_async_notifier *notifier,
 
if (vin->digital.subdev == subdev) {
vin_dbg(vin, "unbind digital subdev %s\n", subdev->name);
-   rvin_v4l2_remove(vin);
vin->digital.subdev = NULL;
return;
}
@@ -283,6 +282,7 @@ static int rcar_vin_probe(struct platform_device *pdev)
 
vin->dev = >dev;
vin->chip = (enum chip_id)match->data;
+   vin->last_input = NULL;
 
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (mem == NULL)
@@ -304,6 +304,10 @@ static int rcar_vin_probe(struct platform_device *pdev)
if (ret < 0)
goto error;
 
+   ret = rvin_v4l2_probe(vin);
+   if (ret)
+   goto error;
+
pm_suspend_ignore_children(>dev, true);
pm_runtime_enable(>dev);
 
@@ -322,6 +326,8 @@ static int rcar_vin_remove(struct platform_device *pdev)
 
pm_runtime_disable(>dev);
 
+   rvin_v4l2_remove(vin);
+
v4l2_async_notifier_unregister(>notifier);
 
rvin_dma_remove(vin);
diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index 929f58b..47137d7 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -483,6 +483,94 @@ static int rvin_cropcap(struct file *file, void *priv,
return v4l2_subdev_call(sd, video, g_pixelaspect, >pixelaspect);
 }
 
+static int rvin_attach_subdevices(struct rvin_dev *vin)
+{
+   struct v4l2_subdev_format fmt = {
+   .which = V4L2_SUBDEV_FORMAT_ACTIVE,
+   };
+   struct v4l2_mbus_framefmt *mf = 
+   struct v4l2_subdev *sd = vin_to_source(vin);
+   struct rvin_graph_entity *rent;
+   struct v4l2_format f;
+   int ret;
+
+   rent = vin_to_entity(vin);
+   if (!rent)
+   return -ENODEV;
+
+   ret = v4l2_subdev_call(sd, core, s_power, 1);
+   if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV)
+   return ret;
+
+   if (rent != vin->last_input) {
+   /* Input source have changed, reset our format */
+
+   vin->vdev.tvnorms = 0;
+   ret = v4l2_subdev_call(sd, video, g_tvnorms,
+  >vdev.tvnorms);
+   if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV)
+   goto error;
+
+   /* Free old controls (safe even if there where none) */
+   v4l2_ctrl_handler_free(>ctrl_handler);
+
+   ret = v4l2_ctrl_handler_init(>ctrl_handler, 16);
+   if (ret < 0)
+   goto error;
+
+   /* Add new controls */
+   ret = v4l2_ctrl_add_handler(>ctrl_handler,
+   sd->ctrl_handler, NULL);
+   if (ret < 0)
+   goto error;
+
+   v4l2_ctrl_handler_setup(>ctrl_handler);
+
+   fmt.pad = rent->source_pad_idx;
+
+   /* Try to improve our guess of a reasonable window format */
+   ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, );
+   if (ret)
+   goto error;
+
+   /* Set default format */
+   vin->format.width   = mf->width;
+   vin->format.height  = mf->height;
+   vin->format.colorspace  = mf->colorspace;
+   vin->format.field   = mf->field;
+   vin->format.pixelformat 

[PATCH 22/32] media: rcar-vin: add chsel information to rvin_info

2016-11-02 Thread Niklas Söderlund
Each Gen3 SoC have a limited set of predefined routing possibilities for
which CSI2 device and virtual channel can be routed to which VIN
instance.  Prepare to store this information in the struct rvin_info.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-vin.h | 16 
 1 file changed, 16 insertions(+)

diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h 
b/drivers/media/platform/rcar-vin/rcar-vin.h
index 90c28a7..cd7d959 100644
--- a/drivers/media/platform/rcar-vin/rcar-vin.h
+++ b/drivers/media/platform/rcar-vin/rcar-vin.h
@@ -35,6 +35,9 @@
 /* Max number on VIN instances that can be in a system */
 #define RCAR_VIN_NUM 8
 
+/* Max number of CHSEL values for any Gen3 SoC */
+#define RCAR_CHSEL_MAX 6
+
 enum chip_id {
RCAR_H1,
RCAR_M1,
@@ -111,6 +114,16 @@ struct rvin_graph_entity {
 
 struct rvin_group;
 
+
+/** struct rvin_group_chsel - Map a CSI2 device and channel for a CHSEL value
+ * @csi:   VIN internal number for CSI2 device
+ * @chan:  CSI2 VC number on remote
+ */
+struct rvin_group_chsel {
+   enum rvin_csi_id csi;
+   int chan;
+};
+
 /**
  * struct rvin_info- Information about the particular VIN implementation
  * @chip:  type of VIN chip
@@ -123,6 +136,9 @@ struct rvin_info {
 
unsigned int max_width;
unsigned int max_height;
+
+   unsigned int num_chsels;
+   struct rvin_group_chsel chsels[RCAR_VIN_NUM][RCAR_CHSEL_MAX];
 };
 
 /**
-- 
2.10.2

--
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 21/32] media: rcar-vin: add group allocator functions

2016-11-02 Thread Niklas Söderlund
On Gen3 all VIN instances which wish to interact with with the shared
CSI2 resource needs to be part of the same media device and share other
information, such as subdevices and be able to call routing operations
on other VIN instances.

This patch adds a group allocator which joins all VIN instances in one
group. Inspiration for this patch is taken from Shuah Khans patch series
'Media Device Allocator API' which do a similar thing but allows a media
device to be shared across different drivers. The use case here is to
share group information between multiple instances of the same driver.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-core.c | 103 
 drivers/media/platform/rcar-vin/rcar-vin.h  |  41 +++
 2 files changed, 144 insertions(+)

diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
b/drivers/media/platform/rcar-vin/rcar-core.c
index ce8b59a..68a16c8 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -26,6 +26,102 @@
 #include "rcar-vin.h"
 
 /* 
-
+ * Gen3 CSI2 Group Allocator
+ */
+
+static DEFINE_MUTEX(rvin_group_lock);
+static struct rvin_group *rvin_group_data;
+
+static void rvin_group_release(struct kref *kref)
+{
+   struct rvin_group *group =
+   container_of(kref, struct rvin_group, refcount);
+
+   mutex_lock(_group_lock);
+
+   media_device_unregister(>mdev);
+   media_device_cleanup(>mdev);
+
+   rvin_group_data = NULL;
+
+   mutex_unlock(_group_lock);
+
+   kfree(group);
+}
+
+static struct rvin_group *__rvin_group_allocate(struct rvin_dev *vin)
+{
+   struct rvin_group *group;
+
+   if (rvin_group_data) {
+   group = rvin_group_data;
+   kref_get(>refcount);
+   vin_dbg(vin, "%s: get group=%p\n", __func__, group);
+   return group;
+   }
+
+   group = kzalloc(sizeof(*group), GFP_KERNEL);
+   if (!group)
+   return NULL;
+
+   kref_init(>refcount);
+   rvin_group_data = group;
+
+   vin_dbg(vin, "%s: alloc group=%p\n", __func__, group);
+   return group;
+}
+
+static struct rvin_group *rvin_group_allocate(struct rvin_dev *vin)
+{
+   struct rvin_group *group;
+   struct media_device *mdev;
+   int ret;
+
+   mutex_lock(_group_lock);
+
+   group = __rvin_group_allocate(vin);
+   if (!group) {
+   mutex_unlock(_group_lock);
+   return ERR_PTR(-ENOMEM);
+   }
+
+   /* Init group data if its not already initialized */
+   mdev = >mdev;
+   if (!mdev->dev) {
+   mutex_init(>lock);
+   mdev->dev = vin->dev;
+
+   strlcpy(mdev->driver_name, "Renesas VIN",
+   sizeof(mdev->driver_name));
+   strlcpy(mdev->model, vin->dev->of_node->name,
+   sizeof(mdev->model));
+   strlcpy(mdev->bus_info, of_node_full_name(vin->dev->of_node),
+   sizeof(mdev->bus_info));
+   mdev->driver_version = LINUX_VERSION_CODE;
+   media_device_init(mdev);
+
+   ret = media_device_register(mdev);
+   if (ret) {
+   vin_err(vin, "Failed to register media device\n");
+   mutex_unlock(_group_lock);
+   return ERR_PTR(ret);
+   }
+   }
+
+   vin->v4l2_dev.mdev = mdev;
+
+   mutex_unlock(_group_lock);
+
+   return group;
+}
+
+static void rvin_group_delete(struct rvin_dev *vin)
+{
+   vin_dbg(vin, "%s: group=%p\n", __func__, >group);
+   kref_put(>group->refcount, rvin_group_release);
+}
+
+/* 
-
  * Subdevice helpers
  */
 
@@ -322,6 +418,10 @@ static int rvin_graph_init(struct rvin_dev *vin)
ret = media_entity_pads_init(>vdev.entity, 1, vin->pads);
if (ret)
return ret;
+
+   vin->group = rvin_group_allocate(vin);
+   if (IS_ERR(vin->group))
+   return PTR_ERR(vin->group);
}
 
return ret;
@@ -390,6 +490,9 @@ static int rcar_vin_remove(struct platform_device *pdev)
 
rvin_v4l2_remove(vin);
 
+   if (vin->group)
+   rvin_group_delete(vin);
+
v4l2_async_notifier_unregister(>notifier);
 
rvin_dma_remove(vin);
diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h 
b/drivers/media/platform/rcar-vin/rcar-vin.h
index 8ed43be..90c28a7 100644
--- a/drivers/media/platform/rcar-vin/rcar-vin.h
+++ b/drivers/media/platform/rcar-vin/rcar-vin.h
@@ -17,10 +17,13 @@
 #ifndef __RCAR_VIN__
 #define __RCAR_VIN__
 
+#include 
+
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 
 /* Number of HW buffers 

[PATCH 30/32] media: rcar-vin: add Gen3 devicetree bindings documentation

2016-11-02 Thread Niklas Söderlund
Document the Gen3 devicetree bindings. The new bindings are all handled
in the port@1 node, if a endpoint is described as on Gen2 in port@0 the
driver will work in Gen2 mode and this is supported on Gen3. The new
CSI-2 video sources are only supported on Gen3.

Signed-off-by: Niklas Söderlund 
---
 .../devicetree/bindings/media/rcar_vin.txt | 116 +++--
 1 file changed, 106 insertions(+), 10 deletions(-)

diff --git a/Documentation/devicetree/bindings/media/rcar_vin.txt 
b/Documentation/devicetree/bindings/media/rcar_vin.txt
index 6a4e61c..a51cf70 100644
--- a/Documentation/devicetree/bindings/media/rcar_vin.txt
+++ b/Documentation/devicetree/bindings/media/rcar_vin.txt
@@ -2,8 +2,12 @@ Renesas RCar Video Input driver (rcar_vin)
 --
 
 The rcar_vin device provides video input capabilities for the Renesas R-Car
-family of devices. The current blocks are always slaves and suppot one input
-channel which can be either RGB, YUYV or BT656.
+family of devices.
+
+On Gen2 the current blocks are always slaves and support one input channel
+which can be either RGB, YUYV or BT656. On Gen3 the current blocks are
+always slaves and support multiple input channels which can be ether RGB,
+YUVU, BT656 or CSI-2.
 
  - compatible: Must be one or more of the following
- "renesas,vin-r8a7795" for the R8A7795 device
@@ -28,7 +32,7 @@ channel which can be either RGB, YUYV or BT656.
 Additionally, an alias named vinX will need to be created to specify
 which video input device this is.
 
-The per-board settings:
+The per-board settings Gen2:
  - port sub-node describing a single endpoint connected to the vin
as described in video-interfaces.txt[1]. Only the first one will
be considered as each vin interface has one input port.
@@ -36,13 +40,22 @@ The per-board settings:
These settings are used to work out video input format and widths
into the system.
 
+The per-board settings Gen3:
+
+- ports
+- port@0 - Digital video source (same as port node on Gen2)
+- port@1 - CSI-2 video sources
+-reg 0 - sub-node describing the endpoint which is CSI20
+-reg 1 - sub-node describing the endpoint which is CSI21
+-reg 2 - sub-node describing the endpoint which is CSI40
+-reg 3 - sub-node describing the endpoint which is CSI41
 
-Device node example

+Device node example Gen2
+
 
-   aliases {
-  vin0 = 
-   };
+aliases {
+vin0 = 
+};
 
 vin0: vin@0xe6ef {
 compatible = "renesas,vin-r8a7790", "renesas,rcar-gen2-vin";
@@ -52,8 +65,8 @@ Device node example
 status = "disabled";
 };
 
-Board setup example (vin1 composite video input)
-
+Board setup example Gen2 (vin1 composite video input)
+-
 
{
 status = "ok";
@@ -92,6 +105,89 @@ Board setup example (vin1 composite video input)
 };
 };
 
+Device node example Gen3
+
+
+aliases {
+vin0 = 
+};
+
+vin1: video@e6ef1000 {
+compatible = "renesas,vin-r8a7796";
+reg =  <0 0xe6ef1000 0 0x1000>;
+interrupts = <0 189 IRQ_TYPE_LEVEL_HIGH>;
+clocks = < CPG_MOD 810>;
+power-domains = <>;
+status = "disabled";
+
+ports {
+#address-cells = <1>;
+#size-cells = <0>;
+
+port@1 {
+#address-cells = <1>;
+#size-cells = <0>;
+
+reg = <1>;
+
+vin1csi20: endpoint@0 {
+reg = <0>;
+remote-endpoint= <>;
+};
+};
+};
+};
+
+csi20: csi2@fea8 {
+compatible = "renesas,r8a7796-csi2";
+reg = <0 0xfea8 0 0x1>;
+interrupts = <0 184 IRQ_TYPE_LEVEL_HIGH>;
+clocks = < CPG_MOD 714>;
+power-domains = <>;
+status = "disabled";
+
+ports {
+#address-cells = <1>;
+#size-cells = <0>;
+
+port@1 {
+#address-cells = <1>;
+#size-cells = <0>;
+
+reg = <1>;
+
+csi20vin1: endpoint@1 {
+reg = <1>;
+remote-endpoint = <>;
+};

[PATCH 24/32] media: rcar-vin: add link notify for Gen3

2016-11-02 Thread Niklas Söderlund
Add the ability to process media device link change request. Link
enablement are a bit complicated on Gen3, if it's possible to enable a
link depends on what other links already are enabled. On Gen3 the 8 VIN
are split into two subgroups (VIN0-3 and VIN4-7) and from a routing
perspective these two groups are independent of each other. Each
subgroups routing is controlled by the subgroup VIN master instance
(VIN0 and VIN4).

There are a limited number of possible route setups available for each
subgroup and the configuration of each setup is dictated by the
hardware. On H3 for example there are 6 possible route setups for each
subgroup to choose from.

This leads to the media device link notification code being rather large
since it will find the best routing configuration to try and accommodate
as many links as possible. When it's not possible to enable a new link
due to hardware constrains the link_notifier callback will return
-EBUSY.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-core.c | 205 
 1 file changed, 205 insertions(+)

diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
b/drivers/media/platform/rcar-vin/rcar-core.c
index 20fe377..06876a8 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -26,6 +26,209 @@
 #include "rcar-vin.h"
 
 /* 
-
+ * Media Controller link notification
+ */
+
+static unsigned int rvin_group_csi_pad_to_chan(unsigned int pad)
+{
+   /*
+* The CSI2 driver is rcar-csi2 and we know it's pad layout are
+* 0: Source 1-4: Sinks so if we remove one from the pad we
+* get the rcar-vin internal CSI2 channel number
+*/
+   return pad - 1;
+}
+
+/* group lock should be held when calling this function */
+static int rvin_group_entity_to_vin_num(struct rvin_group *group,
+   struct media_entity *entity)
+{
+   struct video_device *vdev;
+   int i;
+
+   if (!is_media_entity_v4l2_video_device(entity))
+   return -ENODEV;
+
+   vdev = media_entity_to_video_device(entity);
+
+   for (i = 0; i < RCAR_VIN_NUM; i++) {
+   if (!group->vin[i])
+   continue;
+
+   if (>vin[i]->vdev == vdev)
+   return i;
+   }
+
+   return -ENODEV;
+}
+
+/* group lock should be held when calling this function */
+static int rvin_group_entity_to_csi_num(struct rvin_group *group,
+   struct media_entity *entity)
+{
+   struct v4l2_subdev *sd;
+   int i;
+
+   if (!is_media_entity_v4l2_subdev(entity))
+   return -ENODEV;
+
+   sd = media_entity_to_v4l2_subdev(entity);
+
+   for (i = 0; i < RVIN_CSI_MAX; i++)
+   if (group->bridge[i].subdev == sd)
+   return i;
+
+   return -ENODEV;
+}
+
+/* group lock should be held when calling this function */
+static void __rvin_group_build_link_list(struct rvin_group *group,
+struct rvin_group_chsel *map,
+int start, int len)
+{
+   struct media_pad *vin_pad, *remote_pad;
+   unsigned int n;
+
+   for (n = 0; n < len; n++) {
+   map[n].csi = -1;
+   map[n].chan = -1;
+
+   if (!group->vin[start + n])
+   continue;
+
+   vin_pad = >vin[start + n]->vdev.entity.pads[RVIN_SINK];
+
+   remote_pad = media_entity_remote_pad(vin_pad);
+   if (!remote_pad)
+   continue;
+
+   map[n].csi =
+   rvin_group_entity_to_csi_num(group, remote_pad->entity);
+   map[n].chan = rvin_group_csi_pad_to_chan(remote_pad->index);
+   }
+}
+
+/* group lock should be held when calling this function */
+static int __rvin_group_try_get_chsel(struct rvin_group *group,
+ struct rvin_group_chsel *map,
+ int start, int len)
+{
+   const struct rvin_group_chsel *sel;
+   unsigned int i, n;
+   int chsel;
+
+   for (i = 0; i < group->vin[start]->info->num_chsels; i++) {
+   chsel = i;
+   for (n = 0; n < len; n++) {
+
+   /* If the link is not active it's OK */
+   if (map[n].csi == -1)
+   continue;
+
+   /* Check if chsel match requested link */
+   sel = >vin[start]->info->chsels[start + n][i];
+   if (map[n].csi != sel->csi ||
+   map[n].chan != sel->chan) {
+   chsel = -1;
+   break;
+   }
+   }
+
+   

[PATCH 27/32] media: rcar-vin: start/stop the CSI2 bridge stream

2016-11-02 Thread Niklas Söderlund
On Gen3 the CSI2 bridge stream needs to be start/stop in conjunction
with the video source. Create helpers to deal with both the Gen2 single
subdevice case and the Gen3 CSI2 group case.

In the Gen3 case there might be other simultaneous users of the bridge
and source devices so examine each entity stream_count before acting on
any particular device.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-dma.c | 84 +++---
 1 file changed, 77 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c 
b/drivers/media/platform/rcar-vin/rcar-dma.c
index 322e4c1..872f138 100644
--- a/drivers/media/platform/rcar-vin/rcar-dma.c
+++ b/drivers/media/platform/rcar-vin/rcar-dma.c
@@ -1089,15 +1089,87 @@ static void rvin_buffer_queue(struct vb2_buffer *vb)
spin_unlock_irqrestore(>qlock, flags);
 }
 
+static int __rvin_start_streaming(struct rvin_dev *vin)
+{
+   struct v4l2_subdev *source, *bridge = NULL;
+   struct media_pipeline *pipe;
+   int ret;
+
+   source = vin_to_source(vin);
+   if (!source)
+   return -EINVAL;
+
+   if (vin_have_bridge(vin)) {
+   bridge = vin_to_bridge(vin);
+
+   if (!bridge)
+   return -EINVAL;
+
+   mutex_lock(>group->lock);
+
+   pipe = bridge->entity.pipe ? bridge->entity.pipe :
+   >vdev.pipe;
+   ret = media_entity_pipeline_start(>vdev.entity, pipe);
+   if (ret) {
+   mutex_unlock(>group->lock);
+   return ret;
+   }
+
+   /* Only need to start stream if it's not running */
+   if (bridge->entity.stream_count <= 1)
+   v4l2_subdev_call(bridge, video, s_stream, 1);
+   if (source->entity.stream_count <= 1)
+   v4l2_subdev_call(source, video, s_stream, 1);
+
+   mutex_unlock(>group->lock);
+   } else {
+   v4l2_subdev_call(source, video, s_stream, 1);
+   }
+
+   return 0;
+}
+
+static int __rvin_stop_streaming(struct rvin_dev *vin)
+{
+   struct v4l2_subdev *source, *bridge = NULL;
+
+   source = vin_to_source(vin);
+   if (!source)
+   return -EINVAL;
+
+   if (vin_have_bridge(vin)) {
+   bridge = vin_to_bridge(vin);
+
+   if (!bridge)
+   return -EINVAL;
+
+   mutex_lock(>group->lock);
+
+   media_entity_pipeline_stop(>vdev.entity);
+
+   /* Only need to stop stream if there are no other users */
+   if (bridge->entity.stream_count <= 0)
+   v4l2_subdev_call(bridge, video, s_stream, 0);
+   if (source->entity.stream_count <= 0)
+   v4l2_subdev_call(source, video, s_stream, 0);
+
+   mutex_unlock(>group->lock);
+   } else {
+   v4l2_subdev_call(source, video, s_stream, 0);
+   }
+
+   return 0;
+}
+
 static int rvin_start_streaming(struct vb2_queue *vq, unsigned int count)
 {
struct rvin_dev *vin = vb2_get_drv_priv(vq);
-   struct v4l2_subdev *sd;
unsigned long flags;
int ret;
 
-   sd = vin_to_source(vin);
-   v4l2_subdev_call(sd, video, s_stream, 1);
+   ret = __rvin_start_streaming(vin);
+   if (ret)
+   return ret;
 
spin_lock_irqsave(>qlock, flags);
 
@@ -1122,7 +1194,7 @@ static int rvin_start_streaming(struct vb2_queue *vq, 
unsigned int count)
/* Return all buffers if something went wrong */
if (ret) {
return_all_buffers(vin, VB2_BUF_STATE_QUEUED);
-   v4l2_subdev_call(sd, video, s_stream, 0);
+   __rvin_stop_streaming(vin);
}
 
spin_unlock_irqrestore(>qlock, flags);
@@ -1133,7 +1205,6 @@ static int rvin_start_streaming(struct vb2_queue *vq, 
unsigned int count)
 static void rvin_stop_streaming(struct vb2_queue *vq)
 {
struct rvin_dev *vin = vb2_get_drv_priv(vq);
-   struct v4l2_subdev *sd;
unsigned long flags;
int retries = 0;
 
@@ -1172,8 +1243,7 @@ static void rvin_stop_streaming(struct vb2_queue *vq)
 
spin_unlock_irqrestore(>qlock, flags);
 
-   sd = vin_to_source(vin);
-   v4l2_subdev_call(sd, video, s_stream, 0);
+   __rvin_stop_streaming(vin);
 
/* disable interrupts */
rvin_disable_interrupts(vin);
-- 
2.10.2

--
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 29/32] media: rcar-vin: attach to CSI2 group when the video device is opened

2016-11-02 Thread Niklas Söderlund
Attempt to attach to the subdevices pointed out by the routing from the
CSI2 group when the video device is opened. This is the last piece
missing to enable CSI2 groups on Gen3.

If the current CSI2 routing for the group points ta a set of subdevices
which are not present (not all routings are available on all boards) the
open fall will fail with a -EBUSY error. The VIN instance will be
unavailable with this error until the group routing is changed to one
which provides it with a available set of subdevices.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-v4l2.c | 23 ++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index d363531..1801c6e 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -846,6 +846,7 @@ static const struct v4l2_ioctl_ops rvin_ioctl_ops = {
 static int rvin_open(struct file *file)
 {
struct rvin_dev *vin = video_drvdata(file);
+   struct v4l2_subdev *source, *bridge;
int ret;
 
mutex_lock(>lock);
@@ -857,12 +858,28 @@ static int rvin_open(struct file *file)
goto err_out;
 
/* If there is no subdevice there is not much we can do */
-   if (!vin_to_source(vin)) {
+   source = vin_to_source(vin);
+   if (!source) {
ret = -EBUSY;
goto err_open;
}
 
if (v4l2_fh_is_singular_file(file)) {
+   if (vin_have_bridge(vin)) {
+
+   /* If there are no bridge not much we can do */
+   bridge = vin_to_bridge(vin);
+   if (!bridge) {
+   ret = -EBUSY;
+   goto err_open;
+   }
+
+   v4l2_pipeline_pm_use(>vdev.entity, 1);
+
+   vin_dbg(vin, "Group source: %s bridge: %s\n",
+   source->name,
+   bridge->name);
+   }
pm_runtime_get_sync(vin->dev);
ret = rvin_attach_subdevices(vin);
if (ret) {
@@ -876,6 +893,8 @@ static int rvin_open(struct file *file)
return 0;
 err_power:
pm_runtime_put(vin->dev);
+   if (vin_have_bridge(vin))
+   v4l2_pipeline_pm_use(>vdev.entity, 0);
 err_open:
v4l2_fh_release(file);
 err_out:
@@ -904,6 +923,8 @@ static int rvin_release(struct file *file)
if (fh_singular) {
rvin_detach_subdevices(vin);
pm_runtime_put(vin->dev);
+   if (vin_have_bridge(vin))
+   v4l2_pipeline_pm_use(>vdev.entity, 0);
}
 
mutex_unlock(>lock);
-- 
2.10.2

--
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 28/32] media: rcar-vin: propagate format to bridge

2016-11-02 Thread Niklas Söderlund
The CSI2 bridge needs to know the video format, propagate it after the
video source have had its say on the format.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-v4l2.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index e99815f..d363531 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -193,6 +193,21 @@ static int __rvin_try_format_source(struct rvin_dev *vin,
if (ret < 0 && ret != -ENOIOCTLCMD)
goto done;
 
+   /* If we are part of a CSI2 group update bridge */
+   if (vin_have_bridge(vin)) {
+   struct v4l2_subdev *bridge = vin_to_bridge(vin);
+
+   if (!bridge) {
+   ret = -EINVAL;
+   goto done;
+   }
+
+   format.pad = 0;
+   ret = v4l2_subdev_call(bridge, pad, set_fmt, pad_cfg, );
+   if (ret < 0 && ret != -ENOIOCTLCMD)
+   goto done;
+   }
+
v4l2_fill_pix_format(pix, );
 
pix->field = field;
-- 
2.10.2

--
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 19/32] media: rcar-vin: add functions to manipulate Gen3 CHSEL value

2016-11-02 Thread Niklas Söderlund
On Gen3 the CSI routing is controlled by the VnCSI_IFMD register. One
feature of this register is that it's only present in the VIN0 and VIN4
instances. The register in VIN0 controls the routing for VIN0-3 and the
register in VIN4 controls routing for VIN4-7.

To be able to control routing from a media device these functions need
to control runtime PM for the subgroup master (VIN0 and VIN4). The
subgroup master must be switched on before the register is manipulated,
once the operation is complete it's safe to switch the master off and
the new routing will still be in effect.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-dma.c | 43 ++
 drivers/media/platform/rcar-vin/rcar-vin.h |  3 +++
 2 files changed, 46 insertions(+)

diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c 
b/drivers/media/platform/rcar-vin/rcar-dma.c
index 80958e6..322e4c1 100644
--- a/drivers/media/platform/rcar-vin/rcar-dma.c
+++ b/drivers/media/platform/rcar-vin/rcar-dma.c
@@ -16,6 +16,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -1247,3 +1248,45 @@ int rvin_dma_probe(struct rvin_dev *vin, int irq)
 
return ret;
 }
+
+/* 
-
+ * Gen3 CHSEL manipulation
+ */
+
+int rvin_set_chsel(struct rvin_dev *vin, u8 chsel)
+{
+   u32 ifmd;
+
+   pm_runtime_get_sync(vin->dev);
+
+   /*
+* Undocumented feature: Writing to VNCSI_IFMD_REG will go
+* through and on read back look correct but won't have
+* any effect if VNMC_REG is not first set to 0.
+*/
+   rvin_write(vin, 0, VNMC_REG);
+
+   ifmd = VNCSI_IFMD_DES2 | VNCSI_IFMD_DES1 | VNCSI_IFMD_DES0 |
+   VNCSI_IFMD_CSI_CHSEL(chsel);
+
+   rvin_write(vin, ifmd, VNCSI_IFMD_REG);
+
+   vin_dbg(vin, "Set IFMD 0x%x\n", ifmd);
+
+   pm_runtime_put(vin->dev);
+
+   return 0;
+}
+
+int rvin_get_chsel(struct rvin_dev *vin)
+{
+   int chsel;
+
+   pm_runtime_get_sync(vin->dev);
+
+   chsel = rvin_read(vin, VNCSI_IFMD_REG) & VNCSI_IFMD_CSI_CHSEL_MASK;
+
+   pm_runtime_put(vin->dev);
+
+   return chsel;
+}
diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h 
b/drivers/media/platform/rcar-vin/rcar-vin.h
index b8f5634..a6a49a96 100644
--- a/drivers/media/platform/rcar-vin/rcar-vin.h
+++ b/drivers/media/platform/rcar-vin/rcar-vin.h
@@ -184,4 +184,7 @@ void rvin_scale_try(struct rvin_dev *vin, struct 
v4l2_pix_format *pix,
u32 width, u32 height);
 void rvin_crop_scale_comp(struct rvin_dev *vin);
 
+int rvin_set_chsel(struct rvin_dev *vin, u8 chsel);
+int rvin_get_chsel(struct rvin_dev *vin);
+
 #endif
-- 
2.10.2

--
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 26/32] media: rcar-vin: add helpers for bridge

2016-11-02 Thread Niklas Söderlund
On Gen3 there might be a CSI2 bridge between the video source and the
VIN. Add helpers to check for this and to fetch the bridge subdevice.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-core.c | 19 +++
 drivers/media/platform/rcar-vin/rcar-vin.h  |  2 ++
 2 files changed, 21 insertions(+)

diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
b/drivers/media/platform/rcar-vin/rcar-core.c
index f382f91..a409157 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -369,6 +369,11 @@ static int rvin_group_vin_to_csi(struct rvin_dev *vin)
return csi;
 }
 
+bool vin_have_bridge(struct rvin_dev *vin)
+{
+   return vin->digital.subdev == NULL;
+}
+
 struct rvin_graph_entity *vin_to_entity(struct rvin_dev *vin)
 {
int csi;
@@ -399,6 +404,20 @@ struct v4l2_subdev *vin_to_source(struct rvin_dev *vin)
return vin->group->source[csi].subdev;
 }
 
+struct v4l2_subdev *vin_to_bridge(struct rvin_dev *vin)
+{
+   int csi;
+
+   if (vin->digital.subdev)
+   return NULL;
+
+   csi = rvin_group_vin_to_csi(vin);
+   if (csi < 0)
+   return NULL;
+
+   return vin->group->bridge[csi].subdev;
+}
+
 /* 
-
  * Async notifier helpers
  */
diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h 
b/drivers/media/platform/rcar-vin/rcar-vin.h
index 2f1e087..acaed2b 100644
--- a/drivers/media/platform/rcar-vin/rcar-vin.h
+++ b/drivers/media/platform/rcar-vin/rcar-vin.h
@@ -206,8 +206,10 @@ struct rvin_dev {
struct v4l2_rect compose;
 };
 
+bool vin_have_bridge(struct rvin_dev *vin);
 struct rvin_graph_entity *vin_to_entity(struct rvin_dev *vin);
 struct v4l2_subdev *vin_to_source(struct rvin_dev *vin);
+struct v4l2_subdev *vin_to_bridge(struct rvin_dev *vin);
 
 /* Debug */
 #define vin_dbg(d, fmt, arg...)dev_dbg(d->dev, fmt, ##arg)
-- 
2.10.2

--
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 31/32] media: rcar-vin: enable support for r8a7795

2016-11-02 Thread Niklas Söderlund
Add the SoC specific information for Renesas Salvator-X H3 (r8a7795)
board.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/Kconfig |  2 +-
 drivers/media/platform/rcar-vin/rcar-core.c | 71 +
 2 files changed, 72 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/rcar-vin/Kconfig 
b/drivers/media/platform/rcar-vin/Kconfig
index 111d2a1..e0e981c 100644
--- a/drivers/media/platform/rcar-vin/Kconfig
+++ b/drivers/media/platform/rcar-vin/Kconfig
@@ -5,7 +5,7 @@ config VIDEO_RCAR_VIN
select VIDEOBUF2_DMA_CONTIG
---help---
  Support for Renesas R-Car Video Input (VIN) driver.
- Supports R-Car Gen2 SoCs.
+ Supports R-Car Gen2 and Gen3 SoCs.
 
  To compile this driver as a module, choose M here: the
  module will be called rcar-vin.
diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
b/drivers/media/platform/rcar-vin/rcar-core.c
index a409157..2124f0a 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -1130,6 +1130,73 @@ static const struct rvin_info rcar_info_m1 = {
.max_height = 2048,
 };
 
+static const struct rvin_info rcar_info_r8a7795 = {
+   .chip = RCAR_GEN3,
+   .max_width = 4096,
+   .max_height = 4096,
+
+   .num_chsels = 6,
+   .chsels = {
+   {
+   { .csi = RVIN_CSI40, .chan = 0 },
+   { .csi = RVIN_CSI20, .chan = 0 },
+   { .csi = RVIN_CSI21, .chan = 0 },
+   { .csi = RVIN_CSI40, .chan = 0 },
+   { .csi = RVIN_CSI20, .chan = 0 },
+   { .csi = RVIN_CSI21, .chan = 0 },
+   }, {
+   { .csi = RVIN_CSI20, .chan = 0 },
+   { .csi = RVIN_CSI21, .chan = 0 },
+   { .csi = RVIN_CSI40, .chan = 0 },
+   { .csi = RVIN_CSI40, .chan = 1 },
+   { .csi = RVIN_CSI20, .chan = 1 },
+   { .csi = RVIN_CSI21, .chan = 1 },
+   }, {
+   { .csi = RVIN_CSI21, .chan = 0 },
+   { .csi = RVIN_CSI40, .chan = 0 },
+   { .csi = RVIN_CSI20, .chan = 0 },
+   { .csi = RVIN_CSI40, .chan = 2 },
+   { .csi = RVIN_CSI20, .chan = 2 },
+   { .csi = RVIN_CSI21, .chan = 2 },
+   }, {
+   { .csi = RVIN_CSI40, .chan = 1 },
+   { .csi = RVIN_CSI20, .chan = 1 },
+   { .csi = RVIN_CSI21, .chan = 1 },
+   { .csi = RVIN_CSI40, .chan = 3 },
+   { .csi = RVIN_CSI20, .chan = 3 },
+   { .csi = RVIN_CSI21, .chan = 3 },
+   }, {
+   { .csi = RVIN_CSI41, .chan = 0 },
+   { .csi = RVIN_CSI20, .chan = 0 },
+   { .csi = RVIN_CSI21, .chan = 0 },
+   { .csi = RVIN_CSI41, .chan = 0 },
+   { .csi = RVIN_CSI20, .chan = 0 },
+   { .csi = RVIN_CSI21, .chan = 0 },
+   }, {
+   { .csi = RVIN_CSI20, .chan = 0 },
+   { .csi = RVIN_CSI21, .chan = 0 },
+   { .csi = RVIN_CSI41, .chan = 0 },
+   { .csi = RVIN_CSI41, .chan = 1 },
+   { .csi = RVIN_CSI20, .chan = 1 },
+   { .csi = RVIN_CSI21, .chan = 1 },
+   }, {
+   { .csi = RVIN_CSI21, .chan = 0 },
+   { .csi = RVIN_CSI41, .chan = 0 },
+   { .csi = RVIN_CSI20, .chan = 0 },
+   { .csi = RVIN_CSI41, .chan = 2 },
+   { .csi = RVIN_CSI20, .chan = 2 },
+   { .csi = RVIN_CSI21, .chan = 2 },
+   }, {
+   { .csi = RVIN_CSI41, .chan = 1 },
+   { .csi = RVIN_CSI20, .chan = 1 },
+   { .csi = RVIN_CSI21, .chan = 1 },
+   { .csi = RVIN_CSI41, .chan = 3 },
+   { .csi = RVIN_CSI20, .chan = 3 },
+   { .csi = RVIN_CSI21, .chan = 3 },
+   },
+   },
+};
+
 static const struct rvin_info rcar_info_gen2 = {
.chip = RCAR_GEN2,
.max_width = 2048,
@@ -1138,6 +1205,10 @@ static const struct rvin_info rcar_info_gen2 = {
 
 static const struct of_device_id rvin_of_id_table[] = {
{
+   .compatible = "renesas,vin-r8a7795",
+   .data = (void *)_info_r8a7795,
+   },
+   {
.compatible = "renesas,vin-r8a7794",
.data = (void *)_info_gen2,
},
-- 
2.10.2

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

[PATCH 25/32] media: rcar-vin: enable CSI2 group subdevices in lookup helpers

2016-11-02 Thread Niklas Söderlund
Make the subdevice helpers look not only at the local digital subdevice
but also for the CSI2 group subdevices which can be present on Gen3.

Which CSI2 group subdevices are found depends on the CSI2 subgroup
routing which is stored in the CHSEL register of the subgroup master
(VIN0 for VIN0-3 and VIN4 for VIN4-7). The lookup functions look at this
value and returns the correct information or NULL if there is no
attached subdevices for the current routing for this device.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-core.c | 66 -
 drivers/media/platform/rcar-vin/rcar-vin.h  |  2 +-
 2 files changed, 66 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
b/drivers/media/platform/rcar-vin/rcar-core.c
index 06876a8..f382f91 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -330,9 +330,73 @@ static void rvin_group_delete(struct rvin_dev *vin)
  * Subdevice helpers
  */
 
+static int rvin_group_vin_to_csi(struct rvin_dev *vin)
+{
+   int i, vin_num, vin_master, chsel, csi;
+
+   /*
+* Only try to translate to a CSI2 number if there is a enabled
+* link from the VIN sink pad. However if there are no links at
+* all we are at probe time so ignore the need for enabled links
+* to be able to make a better guess of initial format
+*/
+   if (vin->pads[RVIN_SINK].entity->num_links &&
+   !media_entity_remote_pad(>pads[RVIN_SINK]))
+   return -1;
+
+   /* Find which VIN we are */
+   vin_num = -1;
+   for (i = 0; i < RCAR_VIN_NUM; i++)
+   if (vin == vin->group->vin[i])
+   vin_num = i;
+
+   if (vin_num == -1)
+   return -1;
+
+   vin_master = vin_num < 4 ? 0 : 4;
+   if (!vin->group->vin[vin_master])
+   return -1;
+
+   chsel = rvin_get_chsel(vin->group->vin[vin_master]);
+
+   csi = vin->info->chsels[vin_num][chsel].csi;
+   if (csi >= RVIN_CSI_MAX)
+   return -1;
+
+   if (!vin->group->source[csi].subdev || !vin->group->bridge[csi].subdev)
+   return -1;
+
+   return csi;
+}
+
 struct rvin_graph_entity *vin_to_entity(struct rvin_dev *vin)
 {
-   return >digital;
+   int csi;
+
+   /* If there is a digital subdev use it */
+   if (vin->digital.subdev)
+   return >digital;
+
+   csi = rvin_group_vin_to_csi(vin);
+   if (csi < 0)
+   return NULL;
+
+   return >group->source[csi];
+}
+
+struct v4l2_subdev *vin_to_source(struct rvin_dev *vin)
+{
+   int csi;
+
+   /* If there is a digital subdev use it */
+   if (vin->digital.subdev)
+   return vin->digital.subdev;
+
+   csi = rvin_group_vin_to_csi(vin);
+   if (csi < 0)
+   return NULL;
+
+   return vin->group->source[csi].subdev;
 }
 
 /* 
-
diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h 
b/drivers/media/platform/rcar-vin/rcar-vin.h
index cd7d959..2f1e087 100644
--- a/drivers/media/platform/rcar-vin/rcar-vin.h
+++ b/drivers/media/platform/rcar-vin/rcar-vin.h
@@ -207,7 +207,7 @@ struct rvin_dev {
 };
 
 struct rvin_graph_entity *vin_to_entity(struct rvin_dev *vin);
-#define vin_to_source(vin) vin->digital.subdev
+struct v4l2_subdev *vin_to_source(struct rvin_dev *vin);
 
 /* Debug */
 #define vin_dbg(d, fmt, arg...)dev_dbg(d->dev, fmt, ##arg)
-- 
2.10.2

--
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 23/32] media: rcar-vin: parse Gen3 OF and setup media graph

2016-11-02 Thread Niklas Söderlund
Parse the VIN Gen3 OF graph and register all devices in the CSI2 group
common media device. Once a subdevice is added to the common media
device list as many links as possible are added and if possible enabled.

The links between the video source device and the CSI2 bridge are
enabled as immutable since they can't change during runtime. While the
link between the CSI2 bridge and the VIN video device are enabled
according the CHSEL routing table suitable for the SoC.

The parsing and registering subdevices is a collaborative effort shared
between all rcar-vin instances which are part of the CSI2 group. Which
ever rcar-vin instance which fist sees a new subdevice in the graph adds
it to its private v4l2 async notifier and once it's bound it will be
available for the whole CSI2 group.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-core.c | 485 
 1 file changed, 485 insertions(+)

diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
b/drivers/media/platform/rcar-vin/rcar-core.c
index 68a16c8..20fe377 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -350,6 +350,483 @@ static int rvin_digital_graph_init(struct rvin_dev *vin)
 }
 
 /* 
-
+ * CSI async notifier
+ */
+
+/* group lock should be held when calling this function */
+static void rvin_group_update_pads(struct rvin_graph_entity *entity)
+{
+   struct media_entity *ent = >subdev->entity;
+   unsigned int i;
+
+   /* Make sure source pad idx are sane */
+   if (entity->source_pad_idx >= ent->num_pads ||
+   ent->pads[entity->source_pad_idx].flags != MEDIA_PAD_FL_SOURCE) {
+   entity->source_pad_idx =
+   rvin_pad_idx(entity->subdev, MEDIA_PAD_FL_SOURCE);
+   }
+
+   /* Try to find sink for source, fall back 0 which always is sink */
+   entity->sink_pad_idx = 0;
+   for (i = 0; i < ent->num_pads; ++i) {
+   struct media_pad *sink = >pads[i];
+
+   if (!(sink->flags & MEDIA_PAD_FL_SINK))
+   continue;
+
+   if (sink->index == entity->source_pad_idx)
+   continue;
+
+   if (media_entity_has_route(ent, sink->index,
+  entity->source_pad_idx))
+   entity->sink_pad_idx = sink->index;
+   }
+}
+
+/* group lock should be held when calling this function */
+static int rvin_group_add_link(struct rvin_dev *vin,
+  struct media_entity *source,
+  unsigned int source_pad_idx,
+  struct media_entity *sink,
+  unsigned int sink_idx,
+  u32 flags)
+{
+   struct media_pad *source_pad, *sink_pad;
+   int ret = 0;
+
+   source_pad = >pads[source_pad_idx];
+   sink_pad = >pads[sink_idx];
+
+   if (!media_entity_find_link(source_pad, sink_pad))
+   ret = media_create_pad_link(source, source_pad_idx,
+   sink, sink_idx, flags);
+
+   if (ret)
+   vin_err(vin, "Error adding link from %s to %s\n",
+   source->name, sink->name);
+
+   return ret;
+}
+
+static int rvin_group_update_links(struct rvin_dev *vin)
+{
+   struct media_entity *source, *sink;
+   struct rvin_dev *master;
+   unsigned int i, n, idx, chsel, csi;
+   u32 flags;
+   int ret;
+
+   mutex_lock(>group->lock);
+
+   /* Update Source -> Bridge */
+   for (i = 0; i < RVIN_CSI_MAX; i++) {
+   if (!vin->group->source[i].subdev)
+   continue;
+
+   if (!vin->group->bridge[i].subdev)
+   continue;
+
+   source = >group->source[i].subdev->entity;
+   sink = >group->bridge[i].subdev->entity;
+   idx = vin->group->source[i].source_pad_idx;
+   flags = MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE;
+
+   ret = rvin_group_add_link(vin, source, idx, sink, 0, flags);
+   if (ret)
+   goto out;
+   }
+
+   /* Update Bridge -> VIN */
+   for (n = 0; n < RCAR_VIN_NUM; n++) {
+
+   /* Check that VIN is part of the group */
+   if (!vin->group->vin[n])
+   continue;
+
+   /* Check that subgroup master is part of the group */
+   master = vin->group->vin[n < 4 ? 0 : 4];
+   if (!master)
+   continue;
+
+   chsel = rvin_get_chsel(master);
+
+   for (i = 0; i < vin->info->num_chsels; i++) {
+   csi = vin->info->chsels[n][i].csi;
+
+   /* If the CSI is out of bounds it's a no 

[PATCH 02/32] media: entity: Add media_entity_has_route() function

2016-11-02 Thread Niklas Söderlund
From: Laurent Pinchart 

This is a wrapper around the media entity has_route operation.

Signed-off-by: Laurent Pinchart 
Signed-off-by: Michal Simek 
Signed-off-by: Niklas Söderlund 
---
 drivers/media/media-entity.c | 29 +
 include/media/media-entity.h |  3 +++
 2 files changed, 32 insertions(+)

diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index c68239e..4d03ea7 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -242,6 +242,35 @@ EXPORT_SYMBOL_GPL(media_entity_pads_init);
  * Graph traversal
  */
 
+/**
+ * media_entity_has_route - Check if two entity pads are connected internally
+ * @entity: The entity
+ * @pad0: The first pad index
+ * @pad1: The second pad index
+ *
+ * This function can be used to check whether two pads of an entity are
+ * connected internally in the entity.
+ *
+ * The caller must hold entity->source->parent->mutex.
+ *
+ * Return: true if the pads are connected internally and false otherwise.
+ */
+bool media_entity_has_route(struct media_entity *entity, unsigned int pad0,
+   unsigned int pad1)
+{
+   if (pad0 >= entity->num_pads || pad1 >= entity->num_pads)
+   return false;
+
+   if (pad0 == pad1)
+   return true;
+
+   if (!entity->ops || !entity->ops->has_route)
+   return true;
+
+   return entity->ops->has_route(entity, pad0, pad1);
+}
+EXPORT_SYMBOL_GPL(media_entity_has_route);
+
 static struct media_entity *
 media_entity_other(struct media_entity *entity, struct media_link *link)
 {
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 8f9fc85..5fb3f06 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -851,6 +851,9 @@ void media_entity_graph_walk_cleanup(struct 
media_entity_graph *graph);
  */
 void media_entity_put(struct media_entity *entity);
 
+bool media_entity_has_route(struct media_entity *entity, unsigned int sink,
+   unsigned int source);
+
 /**
  * media_entity_graph_walk_start - Start walking the media graph at a
  * given entity
-- 
2.10.2

--
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 03/32] media: rcar-vin: reset bytesperline and sizeimage when resetting format

2016-11-02 Thread Niklas Söderlund
These two fields where forgotten when refactoring the format reset code
path. If they are not also reset at the same time as width and hight the
format read using G_FMT will not match realty.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-v4l2.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index 2bbe6d4..69bc4cf 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -151,6 +151,9 @@ static int rvin_reset_format(struct rvin_dev *vin)
 
rvin_reset_crop_compose(vin);
 
+   vin->format.bytesperline = rvin_format_bytesperline(>format);
+   vin->format.sizeimage = rvin_format_sizeimage(>format);
+
return 0;
 }
 
-- 
2.10.2

--
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 01/32] media: entity: Add has_route entity operation

2016-11-02 Thread Niklas Söderlund
From: Laurent Pinchart 

The optional operation can be used by entities to report whether two
pads are internally connected.

Signed-off-by: Laurent Pinchart 
Signed-off-by: Michal Simek 
Signed-off-by: Niklas Söderlund 
---
 include/media/media-entity.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index b2203ee..8f9fc85 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -181,6 +181,9 @@ struct media_pad {
  * @link_validate: Return whether a link is valid from the entity point of
  * view. The media_entity_pipeline_start() function
  * validates all links by calling this operation. Optional.
+ * @has_route: Return whether a route exists inside the entity between
+ * two given pads. Optional. If the operation isn't
+ * implemented all pads will be considered as connected.
  *
  * .. note::
  *
@@ -192,6 +195,8 @@ struct media_entity_operations {
  const struct media_pad *local,
  const struct media_pad *remote, u32 flags);
int (*link_validate)(struct media_link *link);
+   bool (*has_route)(struct media_entity *entity, unsigned int pad0,
+ unsigned int pad1);
 };
 
 /**
-- 
2.10.2

--
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 00/32] rcar-vin: Add Gen3 with media controller support

2016-11-02 Thread Niklas Söderlund
Hi All,

This series enable Gen3 VIN support in rcar-vin driver for Renesas 
r8a7795 and r8a7796. It is based on top of v4.9-rc3.

Parts of this series was previously part of an different series from me 
which enabled Gen3 support in a different way (using s_input instead of 
a media controller) but after feedback during ELCE the Gen3 enablement 
is now almost completely rewritten.

 Patch 1-2: pick-up media entity features from Laurent which the driver 
 depends on.

 Patch 3-5: fix small issues in the driver.

 Patch 6-13: changes the driver from attaching to a video source 
 subdevice at probe time to when the video device node (/dev/videoX) are 
 opened. It also allows for the subdevice which is attached is not the 
 same as last time it was opened, but only at the time the first user 
 opens, i.e. when v4l2_fh_is_singular_file() is true.

 Patch 14-15: prepare the internal data structures for Gen3.

 Patch 16-17: small refactoring preparing for Gen3 additions.

 Patch 18-19: add logic to work with the Gen3 hardware registers

 Patch 20-24: add media control support, link setup and link notify 
 handlers.

 Patch 25-29: add logic to the driver to work together with the media 
 controller.

 Patch 30-32: document the new Gen3 DT bindings, add r8a7795 and r8a7796 
 definitions and device info structures.

The driver is tested on both Renesas H3 (r8a7795) and M3-W (r8a7796) 
together with the new rcar-csi2 driver (posted separately) and a 
prototype driver of the ADV7482 (not ready for upstream but publicly 
available). It is possible to capture both CVBS and HDMI video streams, 
v4l2-compliance passes with no errors (there is one warning due the 
ADV7482 driver) and media-ctl can be used to change the routing from the 
different CSI-2 sources to the different VIN consumers.

Gen2 compatibility is verified on Koelsch and no problems where found, 
video can be captured just like before and v4l2-compliance passes 
without errors or warnings.

Laurent Pinchart (2):
  media: entity: Add has_route entity operation
  media: entity: Add media_entity_has_route() function

Niklas Söderlund (30):
  media: rcar-vin: reset bytesperline and sizeimage when resetting
format
  media: rcar-vin: use rvin_reset_format() in S_DV_TIMINGS
  media: rcar-vin: fix how pads are handled for v4l2 subdeivce
operations
  media: rcar-vin: fix standard in input enumeration
  media: rcar-vin: add wrapper to get rvin_graph_entity
  media: rcar-vin: move subdev source and sink pad index to
rvin_graph_entity
  media: rcar-vin: move pad number discovery to async complete handler
  media: rcar-vin: use pad information when verifying media bus format
  media: rcar-vin: refactor pad lookup code
  media: rcar-vin: split rvin_s_fmt_vid_cap()
  media: rcar-vin: register the video device early
  media: rcar-vin: move chip information to own struct
  media: rcar-vin: move max width and height information to chip
information
  media: rcar-vin: change name of video device
  media: rcar-vin: clarify error message from the digital notifier
  media: rcar-vin: enable Gen3 hardware configuration
  media: rcar-vin: add functions to manipulate Gen3 CHSEL value
  media: rcar-vin: expose a sink pad if we are on Gen3
  media: rcar-vin: add group allocator functions
  media: rcar-vin: add chsel information to rvin_info
  media: rcar-vin: parse Gen3 OF and setup media graph
  media: rcar-vin: add link notify for Gen3
  media: rcar-vin: enable CSI2 group subdevices in lookup helpers
  media: rcar-vin: add helpers for bridge
  media: rcar-vin: start/stop the CSI2 bridge stream
  media: rcar-vin: propagate format to bridge
  media: rcar-vin: attach to CSI2 group when the video device is opened
  media: rcar-vin: add Gen3 devicetree bindings documentation
  media: rcar-vin: enable support for r8a7795
  media: rcar-vin: enable support for r8a7796

 .../devicetree/bindings/media/rcar_vin.txt |  117 +-
 drivers/media/media-entity.c   |   29 +
 drivers/media/platform/rcar-vin/Kconfig|2 +-
 drivers/media/platform/rcar-vin/rcar-core.c| 1134 +++-
 drivers/media/platform/rcar-vin/rcar-dma.c |  240 -
 drivers/media/platform/rcar-vin/rcar-v4l2.c|  394 ---
 drivers/media/platform/rcar-vin/rcar-vin.h |  112 +-
 include/media/media-entity.h   |8 +
 8 files changed, 1790 insertions(+), 246 deletions(-)

-- 
2.10.2

--
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 12/32] media: rcar-vin: split rvin_s_fmt_vid_cap()

2016-11-02 Thread Niklas Söderlund
The functionality provided by rvin_s_fmt_vid_cap() will be needed in
other places to add Gen3 support. Split it up in a function which do the
work and one which interface with the v4l2 API.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/platform/rcar-vin/rcar-v4l2.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index 51324c6..929f58b 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -313,10 +313,8 @@ static int rvin_try_fmt_vid_cap(struct file *file, void 
*priv,
 );
 }
 
-static int rvin_s_fmt_vid_cap(struct file *file, void *priv,
- struct v4l2_format *f)
+static int __rvin_s_fmt_vid_cap(struct rvin_dev *vin, struct v4l2_format *f)
 {
-   struct rvin_dev *vin = video_drvdata(file);
struct rvin_source_fmt source;
int ret;
 
@@ -338,6 +336,14 @@ static int rvin_s_fmt_vid_cap(struct file *file, void 
*priv,
return 0;
 }
 
+static int rvin_s_fmt_vid_cap(struct file *file, void *priv,
+ struct v4l2_format *f)
+{
+   struct rvin_dev *vin = video_drvdata(file);
+
+   return __rvin_s_fmt_vid_cap(vin, f);
+}
+
 static int rvin_g_fmt_vid_cap(struct file *file, void *priv,
  struct v4l2_format *f)
 {
-- 
2.10.2

--
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


[PATCHv3] media: rcar-csi2: add Renesas R-Car MIPI CSI-2 driver

2016-11-02 Thread Niklas Söderlund
A V4L2 driver for Renesas R-Car MIPI CSI-2 interface. The driver
supports the rcar-vin driver on R-Car Gen3 SoCs where a separate driver
is needed to receive CSI-2.

Driver is based on a prototype by Koji Matsuoka in the Renesas BSP.

Signed-off-by: Niklas Söderlund 
---

Changes since v2:
- Added media control pads as this is needed by the new rcar-vin driver.
- Update DT bindings after review comments and to add r8a7796 support.
- Add get_fmt handler.
- Fix media bus format error s/YUYV8/UYVY8/

Changes since v1:
- Drop dependency on a pad aware s_stream operation.
- Use the DT bindings format "renesas,-", thanks Geert
  for pointing this out.

 .../devicetree/bindings/media/rcar-csi2.txt| 116 
 drivers/media/platform/rcar-vin/Kconfig|  11 +
 drivers/media/platform/rcar-vin/Makefile   |   2 +
 drivers/media/platform/rcar-vin/rcar-csi2.c| 586 +
 4 files changed, 715 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/rcar-csi2.txt
 create mode 100644 drivers/media/platform/rcar-vin/rcar-csi2.c

diff --git a/Documentation/devicetree/bindings/media/rcar-csi2.txt 
b/Documentation/devicetree/bindings/media/rcar-csi2.txt
new file mode 100644
index 000..95a9adf
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/rcar-csi2.txt
@@ -0,0 +1,116 @@
+Renesas R-Car MIPI CSI-2 driver (rcar-csi2)
+---
+
+The rcar-csi2 device provides MIPI CSI-2 capabilities for the Renesas R-Car
+family of devices. It is to be used in conjunction with the rcar-vin driver
+which provides the video input capabilities.
+
+ - compatible: Must be one or more of the following
+   - "renesas,r8a7795-csi2" for the R8A7795 device.
+   - "renesas,r8a7796-csi2" for the R8A7796 device.
+   - "renesas,rcar-gen3-csi2" for a generic R-Car Gen3 compatible device.
+
+   When compatible with a generic version nodes must list the
+   SoC-specific version corresponding to the platform first
+   followed by the generic version.
+
+ - reg: the register base and size for the device registers
+ - interrupts: the interrupt for the device
+ - clocks: Reference to the parent clock
+
+The device node should contain two 'port' child nodes according to the
+bindings defined in Documentation/devicetree/bindings/media/
+video-interfaces.txt. Port 0 should connect the device that is the vidoe
+source for to the CSI-2 . Port 1 should connect the R-Car VIN devices
+(rcar-vin) devices which can use the CSI-2 device.
+
+- Port 0 - Vidoe source
+   - Reg 0 - sub-node describing the endpoint which are the vidoe source
+
+- Port 1 - VIN instacnes
+   - Reg 0 - sub-node describing the endpoint which are VIN0
+   - Reg 1 - sub-node describing the endpoint which are VIN1
+   - Reg 2 - sub-node describing the endpoint which are VIN2
+   - Reg 3 - sub-node describing the endpoint which are VIN3
+   - Reg 4 - sub-node describing the endpoint which are VIN4
+   - Reg 5 - sub-node describing the endpoint which are VIN5
+   - Reg 6 - sub-node describing the endpoint which are VIN6
+   - Reg 7 - sub-node describing the endpoint which are VIN7
+
+Example:
+
+/* SoC properties */
+
+csi20: csi2@fea8 {
+compatible = "renesas,r8a7795-csi2";
+reg = <0 0xfea8 0 0x1>;
+interrupts = <0 184 IRQ_TYPE_LEVEL_HIGH>;
+clocks = < CPG_MOD 714>;
+power-domains = <>;
+status = "disabled";
+
+ports {
+#address-cells = <1>;
+#size-cells = <0>;
+
+port@1 {
+#address-cells = <1>;
+#size-cells = <0>;
+
+reg = <1>;
+
+csi20vin0: endpoint@0 {
+reg = <0>;
+remote-endpoint = <>;
+};
+csi20vin1: endpoint@1 {
+reg = <1>;
+remote-endpoint = <>;
+};
+csi20vin2: endpoint@2 {
+reg = <2>;
+remote-endpoint = <>;
+};
+csi20vin3: endpoint@3 {
+reg = <3>;
+remote-endpoint = <>;
+};
+csi20vin4: endpoint@4 {
+reg = <4>;
+remote-endpoint = <>;
+};
+csi20vin5: endpoint@5 {
+

RE: [RFC 5/5] doc_rst: media: New SDR formats SC16, SC18 & SC20

2016-11-02 Thread Ramesh Shanmugasundaram
Hi Laurent,

Any further thoughts on the SDR format please (especially the comment below). I 
would appreciate your feedback.

> > On Wednesday 12 Oct 2016 15:10:29 Ramesh Shanmugasundaram wrote:
> > > This patch adds documentation for the three new SDR formats
> > >
> > > V4L2_SDR_FMT_SCU16BE
> > > V4L2_SDR_FMT_SCU18BE
> > > V4L2_SDR_FMT_SCU20BE
[snip]
> > > +
> > > +   -  start + 0:
> > > +
> > > +   -  I'\ :sub:`0[D13:D6]`
> > > +
> > > +   -  I'\ :sub:`0[D5:D0]`
> > > +
> > > +-  .. row 2
> > > +
> > > +   -  start + buffer_size/2:
> > > +
> > > +   -  Q'\ :sub:`0[D13:D6]`
> > > +
> > > +   -  Q'\ :sub:`0[D5:D0]`
> >
> > The format looks planar, does it use one V4L2 plane (as does NV12) or
> > two
> > V4L2 planes (as does NV12M) ? Same question for the other formats.
> 
> Thank you for bringing up this topic. This is one of the key design
> dilemma.
> 
> The I & Q data for these three SDR formats comes from two different DMA
> channels and hence two separate pointers -> we could say it is v4l2 multi-
> planar. Right now, I am making it look like a single plane by presenting
> the data in one single buffer ptr.
> 
> For e.g. multi-planar SC16 format would look something like this
> 
> <32bits-->
> <--I(14 bit data) + 2bit status--16bit padded zeros--> : start0 + 0
> <--I(14 bit data) + 2bit status--16bit padded zeros--> : start0 + 4 ...
> <--Q(14 bit data) + 2bit status--16bit padded zeros--> : start1 + 0
> <--Q(14 bit data) + 2bit status--16bit padded zeros--> : start1 + 4
> 
> My concerns are
> 
> 1) These formats are not a standard as the video "Image Formats". These
> formats are possible when we use DRIF + MAX2175 combination. If we
> interface with a different tuner vendor, the above format(s) MAY/MAY NOT
> be re-usable. We do not know at this point. This is the main open item for
> discussion in the cover letter.
> 
> 2) MPLANE support within V4L2 seems specific to video. Please correct me
> if this is wrong interpretation.
>   - struct v4l2_format contains v4l2_sdr_format and
> v4l2_pix_format_mplane as members of union. Should I create a new
> v4l2_sdr_format_mplane? If I have to use v4l2_pix_format_mplane most of
> the video specific members would be unused (it would be similar to using
> v4l2_pix_format itself instead of v4l2_sdr_format)?
> 
>   - The above decision (accomodate SDR & MPLANE) needs to be
> propagated across the framework. Is this the preferred approach?
> 
> It goes back to point (1). As of today, the change set for this combo
> (DRIF+MAX2175) introduces new SDR formats only. Should it add further
> SDR+MPLANE support to the framework as well?
> 
> I would appreciate your suggestions on this regard.
> 

Thanks,
Ramesh
--
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] c8sectpfe: fix error return code in c8sectpfe_probe()

2016-11-02 Thread Patrice Chotard


On 10/30/2016 02:53 AM, Wei Yongjun wrote:
> From: Wei Yongjun 
> 
> Fix to return error code -ENODEV from the error handling
> case instead of 0, as done elsewhere in this function.
> 
> Signed-off-by: Wei Yongjun 
> ---
>  drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c 
> b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
> index 42b123f..69d9a16 100644
> --- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
> +++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
> @@ -813,6 +813,7 @@ static int c8sectpfe_probe(struct platform_device *pdev)
>   i2c_bus = of_parse_phandle(child, "i2c-bus", 0);
>   if (!i2c_bus) {
>   dev_err(>dev, "No i2c-bus found\n");
> + ret = -ENODEV;
>   goto err_clk_disable;
>   }
>   tsin->i2c_adapter =
> @@ -820,6 +821,7 @@ static int c8sectpfe_probe(struct platform_device *pdev)
>   if (!tsin->i2c_adapter) {
>   dev_err(>dev, "No i2c adapter found\n");
>   of_node_put(i2c_bus);
> + ret = -ENODEV;
>   goto err_clk_disable;
>   }
>   of_node_put(i2c_bus);
> 

Hi Wei

Acked-by: Patrice Chotard 

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


From Amir A. K

2016-11-02 Thread usa
Thanks for your last email response to me.
The information required should include the following-:
Your full names
Your address
Telephone number
Your private email
Occupation
Age

This is to enable my further discussion with you in confidence.
Best regards and wishes to you.
Amir A. Khanmammadov
REPLY TO
khanmamma...@vera.com.uy

amir2...@vera.com.uy
--
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


[PATCHv2 08/11] cec: move the CEC framework out of staging and to media

2016-11-02 Thread Hans Verkuil

From: Hans Verkuil 

The last open issues have been addressed, so it is time to move
this out of staging and into the mainline and to move the public
cec headers to include/uapi/linux.

Signed-off-by: Hans Verkuil 
---
Changes since v1:

Fix path to cec.h in Documentation/media/Makefile.
Forgot to make the documentation after moving linux/cec.h to
uapi/linux/cec.h :-(
---
 Documentation/media/Makefile   |  2 +-
 drivers/media/Kconfig  | 16 
 drivers/media/Makefile |  4 
 drivers/{staging => }/media/cec/Makefile   |  2 +-
 drivers/{staging => }/media/cec/cec-adap.c |  0
 drivers/{staging => }/media/cec/cec-api.c  |  0
 drivers/{staging => }/media/cec/cec-core.c |  0
 drivers/{staging => }/media/cec/cec-priv.h |  0
 drivers/media/i2c/Kconfig  |  6 +++---
 drivers/media/platform/vivid/Kconfig   |  2 +-
 drivers/staging/media/Kconfig  |  2 --
 drivers/staging/media/Makefile |  1 -
 drivers/staging/media/cec/Kconfig  | 12 
 drivers/staging/media/cec/TODO |  9 -
 drivers/staging/media/pulse8-cec/Kconfig   |  2 +-
 drivers/staging/media/s5p-cec/Kconfig  |  2 +-
 drivers/staging/media/st-cec/Kconfig   |  2 +-
 include/media/cec.h|  2 +-
 include/uapi/linux/Kbuild  |  2 ++
 include/{ => uapi}/linux/cec-funcs.h   |  6 --
 include/{ => uapi}/linux/cec.h |  6 --
 21 files changed, 32 insertions(+), 46 deletions(-)
 rename drivers/{staging => }/media/cec/Makefile (70%)
 rename drivers/{staging => }/media/cec/cec-adap.c (100%)
 rename drivers/{staging => }/media/cec/cec-api.c (100%)
 rename drivers/{staging => }/media/cec/cec-core.c (100%)
 rename drivers/{staging => }/media/cec/cec-priv.h (100%)
 delete mode 100644 drivers/staging/media/cec/Kconfig
 delete mode 100644 drivers/staging/media/cec/TODO
 rename include/{ => uapi}/linux/cec-funcs.h (99%)
 rename include/{ => uapi}/linux/cec.h (99%)

diff --git a/Documentation/media/Makefile b/Documentation/media/Makefile
index a7fb352..61afa05 100644
--- a/Documentation/media/Makefile
+++ b/Documentation/media/Makefile
@@ -51,7 +51,7 @@ $(BUILDDIR)/videodev2.h.rst: ${UAPI}/videodev2.h 
${PARSER} $(SRC_DIR)/videodev2.
 $(BUILDDIR)/media.h.rst: ${UAPI}/media.h ${PARSER} 
$(SRC_DIR)/media.h.rst.exceptions

@$($(quiet)gen_rst)

-$(BUILDDIR)/cec.h.rst: ${KAPI}/cec.h ${PARSER} 
$(SRC_DIR)/cec.h.rst.exceptions
+$(BUILDDIR)/cec.h.rst: ${UAPI}/cec.h ${PARSER} 
$(SRC_DIR)/cec.h.rst.exceptions

@$($(quiet)gen_rst)

 $(BUILDDIR)/lirc.h.rst: ${UAPI}/lirc.h ${PARSER} 
$(SRC_DIR)/lirc.h.rst.exceptions

diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig
index 7b85402..bc643cb 100644
--- a/drivers/media/Kconfig
+++ b/drivers/media/Kconfig
@@ -80,6 +80,22 @@ config MEDIA_RC_SUPPORT

  Say Y when you have a TV or an IR device.

+config MEDIA_CEC_SUPPORT
+   bool "HDMI CEC support"
+   select MEDIA_CEC_EDID
+   ---help---
+ Enable support for HDMI CEC (Consumer Electronics Control),
+ which is an optional HDMI feature.
+
+ Say Y when you have an HDMI receiver, transmitter or a USB CEC
+ adapter that supports HDMI CEC.
+
+config MEDIA_CEC_DEBUG
+   bool "HDMI CEC debugfs interface"
+   depends on MEDIA_CEC_SUPPORT && DEBUG_FS
+   ---help---
+ Turns on the DebugFS interface for CEC devices.
+
 config MEDIA_CEC_EDID
bool

diff --git a/drivers/media/Makefile b/drivers/media/Makefile
index 0deaa93..d87ccb8 100644
--- a/drivers/media/Makefile
+++ b/drivers/media/Makefile
@@ -6,6 +6,10 @@ ifeq ($(CONFIG_MEDIA_CEC_EDID),y)
   obj-$(CONFIG_MEDIA_SUPPORT) += cec-edid.o
 endif

+ifeq ($(CONFIG_MEDIA_CEC_SUPPORT),y)
+  obj-$(CONFIG_MEDIA_SUPPORT) += cec/
+endif
+
 media-objs := media-device.o media-devnode.o media-entity.o

 #
diff --git a/drivers/staging/media/cec/Makefile b/drivers/media/cec/Makefile
similarity index 70%
rename from drivers/staging/media/cec/Makefile
rename to drivers/media/cec/Makefile
index bd7f3c5..d668633 100644
--- a/drivers/staging/media/cec/Makefile
+++ b/drivers/media/cec/Makefile
@@ -1,5 +1,5 @@
 cec-objs := cec-core.o cec-adap.o cec-api.o

-ifeq ($(CONFIG_MEDIA_CEC),y)
+ifeq ($(CONFIG_MEDIA_CEC_SUPPORT),y)
   obj-$(CONFIG_MEDIA_SUPPORT) += cec.o
 endif
diff --git a/drivers/staging/media/cec/cec-adap.c 
b/drivers/media/cec/cec-adap.c

similarity index 100%
rename from drivers/staging/media/cec/cec-adap.c
rename to drivers/media/cec/cec-adap.c
diff --git a/drivers/staging/media/cec/cec-api.c 
b/drivers/media/cec/cec-api.c

similarity index 100%
rename from drivers/staging/media/cec/cec-api.c
rename to drivers/media/cec/cec-api.c
diff --git a/drivers/staging/media/cec/cec-core.c 
b/drivers/media/cec/cec-core.c

similarity index 100%
rename from drivers/staging/media/cec/cec-core.c
rename to 

From Amir A. K

2016-11-02 Thread usa
Thanks for your last email response to me.
The information required should include the following-:
Your full names
Your address
Telephone number
Your private email
Occupation
Age

This is to enable my further discussion with you in confidence.
Best regards and wishes to you.
Amir A. Khanmammadov
REPLY TO
khanmamma...@vera.com.uy

amir2...@vera.com.uy

---
Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware.
https://www.avast.com/antivirus

--
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 06/11] cec: accept two replies for CEC_MSG_INITIATE_ARC.

2016-11-02 Thread Hans Verkuil
From: Hans Verkuil 

The CEC_MSG_INITIATE_ARC message is special since it is the ONLY
CEC message that accepts two possible valid replies:

CEC_MSG_REPORT_ARC_INITIATED and CEC_MSG_REPORT_ARC_TERMINATED.

So if the transmitted message is CEC_MSG_INITIATE_ARC and the remote
side replied with CEC_MSG_REPORT_ARC_INITIATED or CEC_MSG_REPORT_ARC_TERMINATED,
then a msg->reply value of CEC_MSG_REPORT_ARC_INITIATED or
CEC_MSG_REPORT_ARC_TERMINATED will match either reply.

I thought about either adding a second reply2 field, but that's ugly
for all other messages that have only one reply, and what if in the
future a new message is added that can have three replies?

Another option would be to add a cec_msg flag, but really, the combination
of CEC_MSG_REPORT_ARC_INITIATED and a reply value of one of the two
possible replies already functions as a flag.

Another advantage of this approach is that it is safe to re-use a
cec_msg struct. No need to zero a flags field or a reply2 field.

So since this really is an exception in the CEC specification, I
decided to implement it as an exception as well.

Signed-off-by: Hans Verkuil 
---
 Documentation/media/uapi/cec/cec-ioc-receive.rst |  8 
 drivers/staging/media/cec/TODO   | 15 +--
 drivers/staging/media/cec/cec-adap.c | 12 
 3 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/Documentation/media/uapi/cec/cec-ioc-receive.rst 
b/Documentation/media/uapi/cec/cec-ioc-receive.rst
index b4dffd2..bdf015b 100644
--- a/Documentation/media/uapi/cec/cec-ioc-receive.rst
+++ b/Documentation/media/uapi/cec/cec-ioc-receive.rst
@@ -142,6 +142,14 @@ result.
Feature Abort reply. In this case ``rx_status`` will either be set
to :ref:`CEC_RX_STATUS_TIMEOUT ` or
:ref:`CEC_RX_STATUS_FEATURE_ABORT `.
+
+   If the transmitter message is ``CEC_MSG_INITIATE_ARC`` then the 
``reply``
+   values ``CEC_MSG_REPORT_ARC_INITIATED`` and 
``CEC_MSG_REPORT_ARC_TERMINATED``
+   are processed differently: either value will match both possible 
replies.
+   The reason is that the ``CEC_MSG_INITIATE_ARC`` message is the only CEC
+   message that has two possible replies other than Feature Abort. The
+   ``reply`` field will be updated with the actual reply so that it is
+   synchronized with the contents of the received message.
 * - __u8
   - ``rx_status``
   - The status bits of the received message. See
diff --git a/drivers/staging/media/cec/TODO b/drivers/staging/media/cec/TODO
index ce69001..5a4cfdf8 100644
--- a/drivers/staging/media/cec/TODO
+++ b/drivers/staging/media/cec/TODO
@@ -1,18 +1,5 @@
-The reason why cec.c is still in staging is that I would like
-to have a bit more confidence in the uABI. The kABI is fine,
-no problem there, but I would like to let the public API mature
-a bit.
+TODOs:
 
-Once I'm confident that I didn't miss anything then the cec.c source
-can move to drivers/media and the linux/cec.h and linux/cec-funcs.h
-headers can move to uapi/linux and added to uapi/linux/Kbuild to make
-them public.
-
-Hopefully this will happen later in 2016.
-
-Other TODOs:
-
-- There are two possible replies to CEC_MSG_INITIATE_ARC. How to handle that?
 - Should CEC_LOG_ADDR_TYPE_SPECIFIC be replaced by TYPE_2ND_TV and 
TYPE_PROCESSOR?
   And also TYPE_SWITCH and TYPE_CDC_ONLY in addition to the TYPE_UNREGISTERED?
   This should give the framework more information about the device type
diff --git a/drivers/staging/media/cec/cec-adap.c 
b/drivers/staging/media/cec/cec-adap.c
index 93b53e6..a65d866 100644
--- a/drivers/staging/media/cec/cec-adap.c
+++ b/drivers/staging/media/cec/cec-adap.c
@@ -958,6 +958,18 @@ void cec_received_msg(struct cec_adapter *adap, struct 
cec_msg *msg)
list_for_each_entry(data, >wait_queue, list) {
struct cec_msg *dst = >msg;
 
+   /*
+* The *only* CEC message that has two possible replies
+* is CEC_MSG_INITIATE_ARC.
+* In this case allow either of the two replies.
+*/
+   if (!abort && dst->msg[1] == CEC_MSG_INITIATE_ARC &&
+   (cmd == CEC_MSG_REPORT_ARC_INITIATED ||
+cmd == CEC_MSG_REPORT_ARC_TERMINATED) &&
+   (dst->reply == CEC_MSG_REPORT_ARC_INITIATED ||
+dst->reply == CEC_MSG_REPORT_ARC_TERMINATED))
+   dst->reply = cmd;
+
/* Does the command match? */
if ((abort && cmd != dst->msg[1]) ||
(!abort && cmd != dst->reply))
-- 
2.10.1

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

[PATCH 01/11] pulse8-cec: set all_device_types when restoring config

2016-11-02 Thread Hans Verkuil
From: Hans Verkuil 

When the persistent state is restored, the all_device_types field
was never filled in. Fix this.

Signed-off-by: Hans Verkuil 
---
 drivers/staging/media/pulse8-cec/pulse8-cec.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/staging/media/pulse8-cec/pulse8-cec.c 
b/drivers/staging/media/pulse8-cec/pulse8-cec.c
index 1732c38..9092494 100644
--- a/drivers/staging/media/pulse8-cec/pulse8-cec.c
+++ b/drivers/staging/media/pulse8-cec/pulse8-cec.c
@@ -375,27 +375,35 @@ static int pulse8_setup(struct pulse8 *pulse8, struct 
serio *serio,
switch (log_addrs->primary_device_type[0]) {
case CEC_OP_PRIM_DEVTYPE_TV:
log_addrs->log_addr_type[0] = CEC_LOG_ADDR_TYPE_TV;
+   log_addrs->all_device_types[0] = CEC_OP_ALL_DEVTYPE_TV;
break;
case CEC_OP_PRIM_DEVTYPE_RECORD:
log_addrs->log_addr_type[0] = CEC_LOG_ADDR_TYPE_RECORD;
+   log_addrs->all_device_types[0] = CEC_OP_ALL_DEVTYPE_RECORD;
break;
case CEC_OP_PRIM_DEVTYPE_TUNER:
log_addrs->log_addr_type[0] = CEC_LOG_ADDR_TYPE_TUNER;
+   log_addrs->all_device_types[0] = CEC_OP_ALL_DEVTYPE_TUNER;
break;
case CEC_OP_PRIM_DEVTYPE_PLAYBACK:
log_addrs->log_addr_type[0] = CEC_LOG_ADDR_TYPE_PLAYBACK;
+   log_addrs->all_device_types[0] = CEC_OP_ALL_DEVTYPE_PLAYBACK;
break;
case CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM:
log_addrs->log_addr_type[0] = CEC_LOG_ADDR_TYPE_PLAYBACK;
+   log_addrs->all_device_types[0] = CEC_OP_ALL_DEVTYPE_AUDIOSYSTEM;
break;
case CEC_OP_PRIM_DEVTYPE_SWITCH:
log_addrs->log_addr_type[0] = CEC_LOG_ADDR_TYPE_UNREGISTERED;
+   log_addrs->all_device_types[0] = CEC_OP_ALL_DEVTYPE_SWITCH;
break;
case CEC_OP_PRIM_DEVTYPE_PROCESSOR:
log_addrs->log_addr_type[0] = CEC_LOG_ADDR_TYPE_SPECIFIC;
+   log_addrs->all_device_types[0] = CEC_OP_ALL_DEVTYPE_SWITCH;
break;
default:
log_addrs->log_addr_type[0] = CEC_LOG_ADDR_TYPE_UNREGISTERED;
+   log_addrs->all_device_types[0] = CEC_OP_ALL_DEVTYPE_SWITCH;
dev_info(pulse8->dev, "Unknown Primary Device Type: %d\n",
 log_addrs->primary_device_type[0]);
break;
-- 
2.10.1

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


[PATCH 05/11] cec: filter invalid messages

2016-11-02 Thread Hans Verkuil
From: Hans Verkuil 

As per the CEC specification:

- CEC messages with a too-small payload should be ignored.
- Broadcast messages that are only allowed as directed messages
  should be ignored.
- Directed messages that are only allowed as broadcast messages
  should be ignored.

Implement this in the core CEC framework.

Signed-off-by: Hans Verkuil 
---
 drivers/staging/media/cec/cec-adap.c | 157 ++-
 1 file changed, 155 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/cec/cec-adap.c 
b/drivers/staging/media/cec/cec-adap.c
index 6aceb1d..93b53e6 100644
--- a/drivers/staging/media/cec/cec-adap.c
+++ b/drivers/staging/media/cec/cec-adap.c
@@ -762,14 +762,105 @@ EXPORT_SYMBOL_GPL(cec_transmit_msg);
 static int cec_receive_notify(struct cec_adapter *adap, struct cec_msg *msg,
  bool is_reply);
 
+#define DIRECTED   0x80
+#define BCAST1_4   0x40
+#define BCAST2_0   0x20/* broadcast only allowed for >= 2.0 */
+#define BCAST  (BCAST1_4 | BCAST2_0)
+#define BOTH   (BCAST | DIRECTED)
+
+/*
+ * Specify minimum length and whether the message is directed, broadcast
+ * or both. Messages that do not match the criteria are ignored as per
+ * the CEC specification.
+ */
+static const u8 cec_msg_size[256] = {
+   [CEC_MSG_ACTIVE_SOURCE] = 4 | BCAST,
+   [CEC_MSG_IMAGE_VIEW_ON] = 2 | DIRECTED,
+   [CEC_MSG_TEXT_VIEW_ON] = 2 | DIRECTED,
+   [CEC_MSG_INACTIVE_SOURCE] = 4 | DIRECTED,
+   [CEC_MSG_REQUEST_ACTIVE_SOURCE] = 2 | BCAST,
+   [CEC_MSG_ROUTING_CHANGE] = 6 | BCAST,
+   [CEC_MSG_ROUTING_INFORMATION] = 4 | BCAST,
+   [CEC_MSG_SET_STREAM_PATH] = 4 | BCAST,
+   [CEC_MSG_STANDBY] = 2 | BOTH,
+   [CEC_MSG_RECORD_OFF] = 2 | DIRECTED,
+   [CEC_MSG_RECORD_ON] = 3 | DIRECTED,
+   [CEC_MSG_RECORD_STATUS] = 3 | DIRECTED,
+   [CEC_MSG_RECORD_TV_SCREEN] = 2 | DIRECTED,
+   [CEC_MSG_CLEAR_ANALOGUE_TIMER] = 13 | DIRECTED,
+   [CEC_MSG_CLEAR_DIGITAL_TIMER] = 16 | DIRECTED,
+   [CEC_MSG_CLEAR_EXT_TIMER] = 13 | DIRECTED,
+   [CEC_MSG_SET_ANALOGUE_TIMER] = 13 | DIRECTED,
+   [CEC_MSG_SET_DIGITAL_TIMER] = 16 | DIRECTED,
+   [CEC_MSG_SET_EXT_TIMER] = 13 | DIRECTED,
+   [CEC_MSG_SET_TIMER_PROGRAM_TITLE] = 2 | DIRECTED,
+   [CEC_MSG_TIMER_CLEARED_STATUS] = 3 | DIRECTED,
+   [CEC_MSG_TIMER_STATUS] = 3 | DIRECTED,
+   [CEC_MSG_CEC_VERSION] = 3 | DIRECTED,
+   [CEC_MSG_GET_CEC_VERSION] = 2 | DIRECTED,
+   [CEC_MSG_GIVE_PHYSICAL_ADDR] = 2 | DIRECTED,
+   [CEC_MSG_GET_MENU_LANGUAGE] = 2 | DIRECTED,
+   [CEC_MSG_REPORT_PHYSICAL_ADDR] = 5 | BCAST,
+   [CEC_MSG_SET_MENU_LANGUAGE] = 5 | BCAST,
+   [CEC_MSG_REPORT_FEATURES] = 6 | BCAST,
+   [CEC_MSG_GIVE_FEATURES] = 2 | DIRECTED,
+   [CEC_MSG_DECK_CONTROL] = 3 | DIRECTED,
+   [CEC_MSG_DECK_STATUS] = 3 | DIRECTED,
+   [CEC_MSG_GIVE_DECK_STATUS] = 3 | DIRECTED,
+   [CEC_MSG_PLAY] = 3 | DIRECTED,
+   [CEC_MSG_GIVE_TUNER_DEVICE_STATUS] = 3 | DIRECTED,
+   [CEC_MSG_SELECT_ANALOGUE_SERVICE] = 6 | DIRECTED,
+   [CEC_MSG_SELECT_DIGITAL_SERVICE] = 9 | DIRECTED,
+   [CEC_MSG_TUNER_DEVICE_STATUS] = 7 | DIRECTED,
+   [CEC_MSG_TUNER_STEP_DECREMENT] = 2 | DIRECTED,
+   [CEC_MSG_TUNER_STEP_INCREMENT] = 2 | DIRECTED,
+   [CEC_MSG_DEVICE_VENDOR_ID] = 5 | BCAST,
+   [CEC_MSG_GIVE_DEVICE_VENDOR_ID] = 2 | DIRECTED,
+   [CEC_MSG_VENDOR_COMMAND] = 2 | DIRECTED,
+   [CEC_MSG_VENDOR_COMMAND_WITH_ID] = 5 | BOTH,
+   [CEC_MSG_VENDOR_REMOTE_BUTTON_DOWN] = 2 | BOTH,
+   [CEC_MSG_VENDOR_REMOTE_BUTTON_UP] = 2 | BOTH,
+   [CEC_MSG_SET_OSD_STRING] = 3 | DIRECTED,
+   [CEC_MSG_GIVE_OSD_NAME] = 2 | DIRECTED,
+   [CEC_MSG_SET_OSD_NAME] = 2 | DIRECTED,
+   [CEC_MSG_MENU_REQUEST] = 3 | DIRECTED,
+   [CEC_MSG_MENU_STATUS] = 3 | DIRECTED,
+   [CEC_MSG_USER_CONTROL_PRESSED] = 3 | DIRECTED,
+   [CEC_MSG_USER_CONTROL_RELEASED] = 2 | DIRECTED,
+   [CEC_MSG_GIVE_DEVICE_POWER_STATUS] = 2 | DIRECTED,
+   [CEC_MSG_REPORT_POWER_STATUS] = 3 | DIRECTED | BCAST2_0,
+   [CEC_MSG_FEATURE_ABORT] = 4 | DIRECTED,
+   [CEC_MSG_ABORT] = 2 | DIRECTED,
+   [CEC_MSG_GIVE_AUDIO_STATUS] = 2 | DIRECTED,
+   [CEC_MSG_GIVE_SYSTEM_AUDIO_MODE_STATUS] = 2 | DIRECTED,
+   [CEC_MSG_REPORT_AUDIO_STATUS] = 3 | DIRECTED,
+   [CEC_MSG_REPORT_SHORT_AUDIO_DESCRIPTOR] = 2 | DIRECTED,
+   [CEC_MSG_REQUEST_SHORT_AUDIO_DESCRIPTOR] = 2 | DIRECTED,
+   [CEC_MSG_SET_SYSTEM_AUDIO_MODE] = 3 | BOTH,
+   [CEC_MSG_SYSTEM_AUDIO_MODE_REQUEST] = 2 | DIRECTED,
+   [CEC_MSG_SYSTEM_AUDIO_MODE_STATUS] = 3 | DIRECTED,
+   [CEC_MSG_SET_AUDIO_RATE] = 3 | DIRECTED,
+   [CEC_MSG_INITIATE_ARC] = 2 | DIRECTED,
+   [CEC_MSG_REPORT_ARC_INITIATED] = 2 | DIRECTED,
+   [CEC_MSG_REPORT_ARC_TERMINATED] = 2 | DIRECTED,
+   [CEC_MSG_REQUEST_ARC_INITIATION] = 2 | DIRECTED,
+   

[PATCH 10/11] s5p-cec/st-cec: update TODOs

2016-11-02 Thread Hans Verkuil
From: Hans Verkuil 

Update the TODOs explaining why these two drivers remain in
staging. The reason is that these drivers rely on userspace to
set the physical address, but that should come from the HDMI
output driver. This in turn needs the upcoming HDMI notifier
framework.

Signed-off-by: Hans Verkuil 
---
 drivers/staging/media/s5p-cec/TODO | 12 ++--
 drivers/staging/media/st-cec/TODO  |  7 +++
 2 files changed, 13 insertions(+), 6 deletions(-)
 create mode 100644 drivers/staging/media/st-cec/TODO

diff --git a/drivers/staging/media/s5p-cec/TODO 
b/drivers/staging/media/s5p-cec/TODO
index f51d526..64f21ba 100644
--- a/drivers/staging/media/s5p-cec/TODO
+++ b/drivers/staging/media/s5p-cec/TODO
@@ -1,7 +1,7 @@
-This driver depends on the CEC framework, which is currently in
-staging, so therefor this driver is in staging as well.
+This driver requires that userspace sets the physical address.
+However, this should be passed on from the corresponding
+Samsung HDMI driver.
 
-In addition, this driver requires that userspace sets the physical
-address. However, this should be passed on from the corresponding
-samsung HDMI driver. It is very annoying if userspace has to do this,
-and other than USB CEC adapters this must be handled automatically.
+We have to wait until the HDMI notifier framework has been merged
+in order to handle this gracefully, until that time this driver
+has to remain in staging.
diff --git a/drivers/staging/media/st-cec/TODO 
b/drivers/staging/media/st-cec/TODO
new file mode 100644
index 000..c612897
--- /dev/null
+++ b/drivers/staging/media/st-cec/TODO
@@ -0,0 +1,7 @@
+This driver requires that userspace sets the physical address.
+However, this should be passed on from the corresponding
+ST HDMI driver.
+
+We have to wait until the HDMI notifier framework has been merged
+in order to handle this gracefully, until that time this driver
+has to remain in staging.
-- 
2.10.1

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


[PATCH 09/11] pulse8-cec: move out of staging

2016-11-02 Thread Hans Verkuil
From: Hans Verkuil 

Now that the CEC framework has been moved out of staging and into the
mainline kernel we can do the same for the pulse8-cec driver.

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/Kconfig  |  5 +++
 drivers/media/usb/Makefile |  1 +
 .../media => media/usb}/pulse8-cec/Kconfig |  0
 .../media => media/usb}/pulse8-cec/Makefile|  0
 .../media => media/usb}/pulse8-cec/pulse8-cec.c|  0
 drivers/staging/media/Kconfig  |  2 -
 drivers/staging/media/Makefile |  1 -
 drivers/staging/media/pulse8-cec/TODO  | 52 --
 8 files changed, 6 insertions(+), 55 deletions(-)
 rename drivers/{staging/media => media/usb}/pulse8-cec/Kconfig (100%)
 rename drivers/{staging/media => media/usb}/pulse8-cec/Makefile (100%)
 rename drivers/{staging/media => media/usb}/pulse8-cec/pulse8-cec.c (100%)
 delete mode 100644 drivers/staging/media/pulse8-cec/TODO

diff --git a/drivers/media/usb/Kconfig b/drivers/media/usb/Kconfig
index 7496f33..c9644b6 100644
--- a/drivers/media/usb/Kconfig
+++ b/drivers/media/usb/Kconfig
@@ -60,5 +60,10 @@ source "drivers/media/usb/hackrf/Kconfig"
 source "drivers/media/usb/msi2500/Kconfig"
 endif
 
+if MEDIA_CEC_SUPPORT
+   comment "USB HDMI CEC adapters"
+source "drivers/media/usb/pulse8-cec/Kconfig"
+endif
+
 endif #MEDIA_USB_SUPPORT
 endif #USB
diff --git a/drivers/media/usb/Makefile b/drivers/media/usb/Makefile
index 8874ba7..0f15e33 100644
--- a/drivers/media/usb/Makefile
+++ b/drivers/media/usb/Makefile
@@ -24,3 +24,4 @@ obj-$(CONFIG_VIDEO_EM28XX) += em28xx/
 obj-$(CONFIG_VIDEO_USBTV) += usbtv/
 obj-$(CONFIG_VIDEO_GO7007) += go7007/
 obj-$(CONFIG_DVB_AS102) += as102/
+obj-$(CONFIG_USB_PULSE8_CEC) += pulse8-cec/
diff --git a/drivers/staging/media/pulse8-cec/Kconfig 
b/drivers/media/usb/pulse8-cec/Kconfig
similarity index 100%
rename from drivers/staging/media/pulse8-cec/Kconfig
rename to drivers/media/usb/pulse8-cec/Kconfig
diff --git a/drivers/staging/media/pulse8-cec/Makefile 
b/drivers/media/usb/pulse8-cec/Makefile
similarity index 100%
rename from drivers/staging/media/pulse8-cec/Makefile
rename to drivers/media/usb/pulse8-cec/Makefile
diff --git a/drivers/staging/media/pulse8-cec/pulse8-cec.c 
b/drivers/media/usb/pulse8-cec/pulse8-cec.c
similarity index 100%
rename from drivers/staging/media/pulse8-cec/pulse8-cec.c
rename to drivers/media/usb/pulse8-cec/pulse8-cec.c
diff --git a/drivers/staging/media/Kconfig b/drivers/staging/media/Kconfig
index 0abe5ff..ffb8fa7 100644
--- a/drivers/staging/media/Kconfig
+++ b/drivers/staging/media/Kconfig
@@ -27,8 +27,6 @@ source "drivers/staging/media/davinci_vpfe/Kconfig"
 
 source "drivers/staging/media/omap4iss/Kconfig"
 
-source "drivers/staging/media/pulse8-cec/Kconfig"
-
 source "drivers/staging/media/s5p-cec/Kconfig"
 
 # Keep LIRC at the end, as it has sub-menus
diff --git a/drivers/staging/media/Makefile b/drivers/staging/media/Makefile
index 246299e..a28e82c 100644
--- a/drivers/staging/media/Makefile
+++ b/drivers/staging/media/Makefile
@@ -4,5 +4,4 @@ obj-$(CONFIG_DVB_CXD2099)   += cxd2099/
 obj-$(CONFIG_LIRC_STAGING) += lirc/
 obj-$(CONFIG_VIDEO_DM365_VPFE) += davinci_vpfe/
 obj-$(CONFIG_VIDEO_OMAP4)  += omap4iss/
-obj-$(CONFIG_USB_PULSE8_CEC)+= pulse8-cec/
 obj-$(CONFIG_VIDEO_STI_HDMI_CEC) += st-cec/
diff --git a/drivers/staging/media/pulse8-cec/TODO 
b/drivers/staging/media/pulse8-cec/TODO
deleted file mode 100644
index fa66602..000
--- a/drivers/staging/media/pulse8-cec/TODO
+++ /dev/null
@@ -1,52 +0,0 @@
-This driver needs to mature a bit more and another round of
-code cleanups.
-
-Otherwise it looks to be in good shape. And of course the fact
-that the CEC framework is in staging at the moment also prevents
-this driver from being mainlined.
-
-Some notes:
-
-1) Regarding the "autonomous" mode of the Pulse-Eight: currently this
-is disabled, but the idea is that this allows basic functionality
-when the PC is off, and it can wake-up the PC through USB.
-
-To prevent the device to go into autonomous mode the driver would
-have to send MSGCODE_SET_CONTROLLED 1 and then send a ping every
-30 seconds (in practice once every 15 seconds would be good). When
-powering off or going to standby send MSGCODE_SET_CONTROLLED 0 to
-turn the autonomous mode back on.
-
-This needs to be implemented in the driver. Autonomous mode was
-added in firmware v2.
-
-2) Writing to the EEPROM can only be done once every 10 seconds.
-
-3) To use this driver you also need to patch the inputattach utility,
-this patch will be submitted once this driver is moved out of staging.
-
-diff -urN linuxconsoletools-1.4.9/utils/inputattach.c 
linuxconsoletools-1.4.9.new/utils/inputattach.c
 linuxconsoletools-1.4.9/utils/inputattach.c2016-01-09 
16:27:02.0 +0100
-+++ linuxconsoletools-1.4.9.new/utils/inputattach.c2016-03-20 

[PATCH 11/11] MAINTAINERS: update paths

2016-11-02 Thread Hans Verkuil
From: Hans Verkuil 

The cec framework and the pulse8-cec driver have been moved out
of staging, so update the MAINTAINERS paths.

Signed-off-by: Hans Verkuil 
---
 MAINTAINERS | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 93e9f42..5106590 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2958,15 +2958,15 @@ L:  linux-media@vger.kernel.org
 T: git git://linuxtv.org/media_tree.git
 W: http://linuxtv.org
 S: Supported
-F: Documentation/cec.txt
+F: Documentation/media/kapi/cec-core.rst
 F: Documentation/media/uapi/cec
-F: drivers/staging/media/cec/
+F: drivers/media/cec/
 F: drivers/media/cec-edid.c
 F: drivers/media/rc/keymaps/rc-cec.c
 F: include/media/cec.h
 F: include/media/cec-edid.h
-F: include/linux/cec.h
-F: include/linux/cec-funcs.h
+F: include/uapi/linux/cec.h
+F: include/uapi/linux/cec-funcs.h
 
 CELL BROADBAND ENGINE ARCHITECTURE
 M: Arnd Bergmann 
@@ -9783,7 +9783,7 @@ M:Hans Verkuil 
 L: linux-media@vger.kernel.org
 T: git git://linuxtv.org/media_tree.git
 S: Maintained
-F: drivers/staging/media/pulse8-cec
+F: drivers/media/usb/pulse8-cec/*
 
 PVRUSB2 VIDEO4LINUX DRIVER
 M: Mike Isely 
-- 
2.10.1

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


[PATCH 08/11] cec: move the CEC framework out of staging and to media

2016-11-02 Thread Hans Verkuil
From: Hans Verkuil 

The last open issues have been addressed, so it is time to move
this out of staging and into the mainline and to move the public
cec headers to include/uapi/linux.

Signed-off-by: Hans Verkuil 
---
 drivers/media/Kconfig  | 16 
 drivers/media/Makefile |  4 
 drivers/{staging => }/media/cec/Makefile   |  2 +-
 drivers/{staging => }/media/cec/cec-adap.c |  0
 drivers/{staging => }/media/cec/cec-api.c  |  0
 drivers/{staging => }/media/cec/cec-core.c |  0
 drivers/{staging => }/media/cec/cec-priv.h |  0
 drivers/media/i2c/Kconfig  |  6 +++---
 drivers/media/platform/vivid/Kconfig   |  2 +-
 drivers/staging/media/Kconfig  |  2 --
 drivers/staging/media/Makefile |  1 -
 drivers/staging/media/cec/Kconfig  | 12 
 drivers/staging/media/cec/TODO |  9 -
 drivers/staging/media/pulse8-cec/Kconfig   |  2 +-
 drivers/staging/media/s5p-cec/Kconfig  |  2 +-
 drivers/staging/media/st-cec/Kconfig   |  2 +-
 include/media/cec.h|  2 +-
 include/uapi/linux/Kbuild  |  2 ++
 include/{ => uapi}/linux/cec-funcs.h   |  6 --
 include/{ => uapi}/linux/cec.h |  6 --
 20 files changed, 31 insertions(+), 45 deletions(-)
 rename drivers/{staging => }/media/cec/Makefile (70%)
 rename drivers/{staging => }/media/cec/cec-adap.c (100%)
 rename drivers/{staging => }/media/cec/cec-api.c (100%)
 rename drivers/{staging => }/media/cec/cec-core.c (100%)
 rename drivers/{staging => }/media/cec/cec-priv.h (100%)
 delete mode 100644 drivers/staging/media/cec/Kconfig
 delete mode 100644 drivers/staging/media/cec/TODO
 rename include/{ => uapi}/linux/cec-funcs.h (99%)
 rename include/{ => uapi}/linux/cec.h (99%)

diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig
index 7b85402..bc643cb 100644
--- a/drivers/media/Kconfig
+++ b/drivers/media/Kconfig
@@ -80,6 +80,22 @@ config MEDIA_RC_SUPPORT
 
  Say Y when you have a TV or an IR device.
 
+config MEDIA_CEC_SUPPORT
+   bool "HDMI CEC support"
+   select MEDIA_CEC_EDID
+   ---help---
+ Enable support for HDMI CEC (Consumer Electronics Control),
+ which is an optional HDMI feature.
+
+ Say Y when you have an HDMI receiver, transmitter or a USB CEC
+ adapter that supports HDMI CEC.
+
+config MEDIA_CEC_DEBUG
+   bool "HDMI CEC debugfs interface"
+   depends on MEDIA_CEC_SUPPORT && DEBUG_FS
+   ---help---
+ Turns on the DebugFS interface for CEC devices.
+
 config MEDIA_CEC_EDID
bool
 
diff --git a/drivers/media/Makefile b/drivers/media/Makefile
index 0deaa93..d87ccb8 100644
--- a/drivers/media/Makefile
+++ b/drivers/media/Makefile
@@ -6,6 +6,10 @@ ifeq ($(CONFIG_MEDIA_CEC_EDID),y)
   obj-$(CONFIG_MEDIA_SUPPORT) += cec-edid.o
 endif
 
+ifeq ($(CONFIG_MEDIA_CEC_SUPPORT),y)
+  obj-$(CONFIG_MEDIA_SUPPORT) += cec/
+endif
+
 media-objs := media-device.o media-devnode.o media-entity.o
 
 #
diff --git a/drivers/staging/media/cec/Makefile b/drivers/media/cec/Makefile
similarity index 70%
rename from drivers/staging/media/cec/Makefile
rename to drivers/media/cec/Makefile
index bd7f3c5..d668633 100644
--- a/drivers/staging/media/cec/Makefile
+++ b/drivers/media/cec/Makefile
@@ -1,5 +1,5 @@
 cec-objs := cec-core.o cec-adap.o cec-api.o
 
-ifeq ($(CONFIG_MEDIA_CEC),y)
+ifeq ($(CONFIG_MEDIA_CEC_SUPPORT),y)
   obj-$(CONFIG_MEDIA_SUPPORT) += cec.o
 endif
diff --git a/drivers/staging/media/cec/cec-adap.c b/drivers/media/cec/cec-adap.c
similarity index 100%
rename from drivers/staging/media/cec/cec-adap.c
rename to drivers/media/cec/cec-adap.c
diff --git a/drivers/staging/media/cec/cec-api.c b/drivers/media/cec/cec-api.c
similarity index 100%
rename from drivers/staging/media/cec/cec-api.c
rename to drivers/media/cec/cec-api.c
diff --git a/drivers/staging/media/cec/cec-core.c b/drivers/media/cec/cec-core.c
similarity index 100%
rename from drivers/staging/media/cec/cec-core.c
rename to drivers/media/cec/cec-core.c
diff --git a/drivers/staging/media/cec/cec-priv.h b/drivers/media/cec/cec-priv.h
similarity index 100%
rename from drivers/staging/media/cec/cec-priv.h
rename to drivers/media/cec/cec-priv.h
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 2669b4b..b31fa6f 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -221,7 +221,7 @@ config VIDEO_ADV7604
 
 config VIDEO_ADV7604_CEC
bool "Enable Analog Devices ADV7604 CEC support"
-   depends on VIDEO_ADV7604 && MEDIA_CEC
+   depends on VIDEO_ADV7604 && MEDIA_CEC_SUPPORT
---help---
  When selected the adv7604 will support the optional
  HDMI CEC feature.
@@ -242,7 +242,7 @@ config VIDEO_ADV7842
 
 config VIDEO_ADV7842_CEC
bool "Enable Analog Devices ADV7842 CEC support"
-   depends on VIDEO_ADV7842 && MEDIA_CEC

[PATCH 07/11] cec: add proper support for CDC-Only CEC devices

2016-11-02 Thread Hans Verkuil
From: Hans Verkuil 

CDC-Only CEC devices are CEC devices that can only handle CDC messages,
all other messages are ignored.

Add a flag to signal that this is a CDC-Only device and act accordingly.

Also add helper functions to identify if a CEC device is configured as a
CDC-Only device, a second TV, a switch or a processor, since these variations
cannot be determined by the logical address alone.

Signed-off-by: Hans Verkuil 
---
 drivers/staging/media/cec/TODO   |  4 ---
 drivers/staging/media/cec/cec-adap.c | 31 -
 drivers/staging/media/cec/cec-api.c  |  9 ++-
 include/linux/cec.h  | 52 
 4 files changed, 90 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/media/cec/TODO b/drivers/staging/media/cec/TODO
index 5a4cfdf8..504d35c 100644
--- a/drivers/staging/media/cec/TODO
+++ b/drivers/staging/media/cec/TODO
@@ -1,9 +1,5 @@
 TODOs:
 
-- Should CEC_LOG_ADDR_TYPE_SPECIFIC be replaced by TYPE_2ND_TV and 
TYPE_PROCESSOR?
-  And also TYPE_SWITCH and TYPE_CDC_ONLY in addition to the TYPE_UNREGISTERED?
-  This should give the framework more information about the device type
-  since SPECIFIC and UNREGISTERED give no useful information.
 - Once this is out of staging this should no longer be a separate
   config option, instead it should be selected by drivers that want it.
 - Revisit the IS_REACHABLE(RC_CORE): perhaps the RC_CORE support should
diff --git a/drivers/staging/media/cec/cec-adap.c 
b/drivers/staging/media/cec/cec-adap.c
index a65d866..054cd06 100644
--- a/drivers/staging/media/cec/cec-adap.c
+++ b/drivers/staging/media/cec/cec-adap.c
@@ -1233,7 +1233,8 @@ static int cec_config_thread_func(void *arg)
mutex_unlock(>lock);
 
for (i = 0; i < las->num_log_addrs; i++) {
-   if (las->log_addr[i] == CEC_LOG_ADDR_INVALID)
+   if (las->log_addr[i] == CEC_LOG_ADDR_INVALID ||
+   (las->flags & CEC_LOG_ADDRS_FL_CDC_ONLY))
continue;
 
/*
@@ -1355,6 +1356,29 @@ int __cec_s_log_addrs(struct cec_adapter *adap,
return 0;
}
 
+   if (log_addrs->flags & CEC_LOG_ADDRS_FL_CDC_ONLY) {
+   /*
+* Sanitize log_addrs fields if a CDC-Only device is
+* requested.
+*/
+   log_addrs->num_log_addrs = 1;
+   log_addrs->osd_name[0] = '\0';
+   log_addrs->vendor_id = CEC_VENDOR_ID_NONE;
+   log_addrs->log_addr_type[0] = CEC_LOG_ADDR_TYPE_UNREGISTERED;
+   /*
+* This is just an internal convention since a CDC-Only device
+* doesn't have to be a switch. But switches already use
+* unregistered, so it makes some kind of sense to pick this
+* as the primary device. Since a CDC-Only device never sends
+* any 'normal' CEC messages this primary device type is never
+* sent over the CEC bus.
+*/
+   log_addrs->primary_device_type[0] = CEC_OP_PRIM_DEVTYPE_SWITCH;
+   log_addrs->all_device_types[0] = 0;
+   log_addrs->features[0][0] = 0;
+   log_addrs->features[0][1] = 0;
+   }
+
/* Ensure the osd name is 0-terminated */
log_addrs->osd_name[sizeof(log_addrs->osd_name) - 1] = '\0';
 
@@ -1575,6 +1599,11 @@ static int cec_receive_notify(struct cec_adapter *adap, 
struct cec_msg *msg,
 
dprintk(1, "cec_receive_notify: %*ph\n", msg->len, msg->msg);
 
+   /* If this is a CDC-Only device, then ignore any non-CDC messages */
+   if (cec_is_cdc_only(>log_addrs) &&
+   msg->msg[1] != CEC_MSG_CDC_MESSAGE)
+   return 0;
+
if (adap->ops->received) {
/* Allow drivers to process the message first */
if (adap->ops->received(adap, msg) != -ENOMSG)
diff --git a/drivers/staging/media/cec/cec-api.c 
b/drivers/staging/media/cec/cec-api.c
index 54148a6..d4bc4ee 100644
--- a/drivers/staging/media/cec/cec-api.c
+++ b/drivers/staging/media/cec/cec-api.c
@@ -163,7 +163,8 @@ static long cec_adap_s_log_addrs(struct cec_adapter *adap, 
struct cec_fh *fh,
if (copy_from_user(_addrs, parg, sizeof(log_addrs)))
return -EFAULT;
log_addrs.flags &= CEC_LOG_ADDRS_FL_ALLOW_UNREG_FALLBACK |
-  CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU;
+  CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU |
+  CEC_LOG_ADDRS_FL_CDC_ONLY;
mutex_lock(>lock);
if (!adap->is_configuring &&
(!log_addrs.num_log_addrs || !adap->is_configured) &&
@@ -190,6 +191,12 @@ static long cec_transmit(struct cec_adapter *adap, struct 
cec_fh *fh,
return -ENOTTY;
if (copy_from_user(, parg, sizeof(msg)))
return -EFAULT;
+
+   /* A CDC-Only 

[PATCH 00/11] cec/pulse8-cec: move out of staging

2016-11-02 Thread Hans Verkuil
From: Hans Verkuil 

This patch series makes the final changes so that the cec framework
and the pulse8-cec driver can be moved out of staging.

The first patch fixes a pulse8-cec bug, the second removes the
spurious 'row' comments in the cec documentation using Laurent's script
(Thanks Laurent!).

The next patch adds a flag to enable the passthrough of remote control
keys to the rc subsystem. This is a userspace change since until now this
was always on. I decided that it is safer that this is enabled via an
opt-in flag so the caller can think about whether this is really what
they want.

Patch four adds a new flag that can force replies to a CEC_TRANSMIT to
be sent to followers as well. Depending on how the application is set
up this flag may be needed.

The fifth patch implements filtering for erroneous messages: messages
that are too short, or have the wrong transmit mode (broadcast where
directed is needed or vice versa) are ignored. This is only done for
the CEC messages specified in the spec, unknown messages are passed
on. This filtering is required by the CEC specification.

The next patch handles a corner case where one message can have two
different replies.

Then support for CDC-Only devices is added, which was a previously
not-very-well supported corner case.

The last four patches move the cec framework and pulse8-cec driver
out of staging.

Regards,

Hans


Hans Verkuil (11):
  pulse8-cec: set all_device_types when restoring config
  cec rst: convert tables and drop the 'row' comments
  cec: add flag to cec_log_addrs to enable RC passthrough
  cec: add CEC_MSG_FL_REPLY_TO_FOLLOWERS
  cec: filter invalid messages
  cec: accept two replies for CEC_MSG_INITIATE_ARC.
  cec: add proper support for CDC-Only CEC devices
  cec: move the CEC framework out of staging and to media
  pulse8-cec: move out of staging
  s5p-cec/st-cec: update TODOs
  MAINTAINERS: update paths

 .../media/uapi/cec/cec-ioc-adap-g-caps.rst | 156 +++
 .../media/uapi/cec/cec-ioc-adap-g-log-addrs.rst| 487 -
 Documentation/media/uapi/cec/cec-ioc-dqevent.rst   | 182 +++-
 Documentation/media/uapi/cec/cec-ioc-g-mode.rst| 317 ++
 Documentation/media/uapi/cec/cec-ioc-receive.rst   | 418 --
 MAINTAINERS|  10 +-
 drivers/media/Kconfig  |  16 +
 drivers/media/Makefile |   4 +
 drivers/{staging => }/media/cec/Makefile   |   2 +-
 drivers/{staging => }/media/cec/cec-adap.c | 212 -
 drivers/{staging => }/media/cec/cec-api.c  |  11 +-
 drivers/{staging => }/media/cec/cec-core.c |   0
 drivers/{staging => }/media/cec/cec-priv.h |   0
 drivers/media/i2c/Kconfig  |   6 +-
 drivers/media/platform/vivid/Kconfig   |   2 +-
 drivers/media/usb/Kconfig  |   5 +
 drivers/media/usb/Makefile |   1 +
 .../media => media/usb}/pulse8-cec/Kconfig |   2 +-
 .../media => media/usb}/pulse8-cec/Makefile|   0
 .../media => media/usb}/pulse8-cec/pulse8-cec.c|   8 +
 drivers/staging/media/Kconfig  |   4 -
 drivers/staging/media/Makefile |   2 -
 drivers/staging/media/cec/Kconfig  |  12 -
 drivers/staging/media/cec/TODO |  32 --
 drivers/staging/media/pulse8-cec/TODO  |  52 ---
 drivers/staging/media/s5p-cec/Kconfig  |   2 +-
 drivers/staging/media/s5p-cec/TODO |  12 +-
 drivers/staging/media/st-cec/Kconfig   |   2 +-
 drivers/staging/media/st-cec/TODO  |   7 +
 include/media/cec.h|   2 +-
 include/uapi/linux/Kbuild  |   2 +
 include/{ => uapi}/linux/cec-funcs.h   |   6 -
 include/{ => uapi}/linux/cec.h |  65 ++-
 33 files changed, 951 insertions(+), 1088 deletions(-)
 rename drivers/{staging => }/media/cec/Makefile (70%)
 rename drivers/{staging => }/media/cec/cec-adap.c (86%)
 rename drivers/{staging => }/media/cec/cec-api.c (97%)
 rename drivers/{staging => }/media/cec/cec-core.c (100%)
 rename drivers/{staging => }/media/cec/cec-priv.h (100%)
 rename drivers/{staging/media => media/usb}/pulse8-cec/Kconfig (86%)
 rename drivers/{staging/media => media/usb}/pulse8-cec/Makefile (100%)
 rename drivers/{staging/media => media/usb}/pulse8-cec/pulse8-cec.c (97%)
 delete mode 100644 drivers/staging/media/cec/Kconfig
 delete mode 100644 drivers/staging/media/cec/TODO
 delete mode 100644 drivers/staging/media/pulse8-cec/TODO
 create mode 100644 drivers/staging/media/st-cec/TODO
 rename include/{ => uapi}/linux/cec-funcs.h (99%)
 rename include/{ => uapi}/linux/cec.h (94%)

-- 
2.10.1

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

[PATCH 02/11] cec rst: convert tables and drop the 'row' comments

2016-11-02 Thread Hans Verkuil
From: Hans Verkuil 

This uses Laurent's python script to convert all tables, dropping
the useless 'row' comments.

See commit c2b66cafdf02 ("[media] v4l: doc: Remove row numbers from tables")
for the script that was used.

Signed-off-by: Hans Verkuil 
---
 .../media/uapi/cec/cec-ioc-adap-g-caps.rst | 156 +++
 .../media/uapi/cec/cec-ioc-adap-g-log-addrs.rst| 475 -
 Documentation/media/uapi/cec/cec-ioc-dqevent.rst   | 182 +++-
 Documentation/media/uapi/cec/cec-ioc-g-mode.rst| 317 ++
 Documentation/media/uapi/cec/cec-ioc-receive.rst   | 394 +++--
 5 files changed, 579 insertions(+), 945 deletions(-)

diff --git a/Documentation/media/uapi/cec/cec-ioc-adap-g-caps.rst 
b/Documentation/media/uapi/cec/cec-ioc-adap-g-caps.rst
index a35dca2..2b0ddb1 100644
--- a/Documentation/media/uapi/cec/cec-ioc-adap-g-caps.rst
+++ b/Documentation/media/uapi/cec/cec-ioc-adap-g-caps.rst
@@ -48,41 +48,21 @@ returns the information to the application. The ioctl never 
fails.
 :stub-columns: 0
 :widths:   1 1 16
 
-
--  .. row 1
-
-   -  char
-
-   -  ``driver[32]``
-
-   -  The name of the cec adapter driver.
-
--  .. row 2
-
-   -  char
-
-   -  ``name[32]``
-
-   -  The name of this CEC adapter. The combination ``driver`` and
- ``name`` must be unique.
-
--  .. row 3
-
-   -  __u32
-
-   -  ``capabilities``
-
-   -  The capabilities of the CEC adapter, see
- :ref:`cec-capabilities`.
-
--  .. row 4
-
-   -  __u32
-
-   -  ``version``
-
-   -  CEC Framework API version, formatted with the ``KERNEL_VERSION()``
- macro.
+* - char
+  - ``driver[32]``
+  - The name of the cec adapter driver.
+* - char
+  - ``name[32]``
+  - The name of this CEC adapter. The combination ``driver`` and
+   ``name`` must be unique.
+* - __u32
+  - ``capabilities``
+  - The capabilities of the CEC adapter, see
+   :ref:`cec-capabilities`.
+* - __u32
+  - ``version``
+  - CEC Framework API version, formatted with the ``KERNEL_VERSION()``
+   macro.
 
 
 .. tabularcolumns:: |p{4.4cm}|p{2.5cm}|p{10.6cm}|
@@ -94,68 +74,50 @@ returns the information to the application. The ioctl never 
fails.
 :stub-columns: 0
 :widths:   3 1 8
 
-
--  .. _`CEC-CAP-PHYS-ADDR`:
-
-   -  ``CEC_CAP_PHYS_ADDR``
-
-   -  0x0001
-
-   -  Userspace has to configure the physical address by calling
- :ref:`ioctl CEC_ADAP_S_PHYS_ADDR `. If
- this capability isn't set, then setting the physical address is
- handled by the kernel whenever the EDID is set (for an HDMI
- receiver) or read (for an HDMI transmitter).
-
--  .. _`CEC-CAP-LOG-ADDRS`:
-
-   -  ``CEC_CAP_LOG_ADDRS``
-
-   -  0x0002
-
-   -  Userspace has to configure the logical addresses by calling
- :ref:`ioctl CEC_ADAP_S_LOG_ADDRS `. If
- this capability isn't set, then the kernel will have configured
- this.
-
--  .. _`CEC-CAP-TRANSMIT`:
-
-   -  ``CEC_CAP_TRANSMIT``
-
-   -  0x0004
-
-   -  Userspace can transmit CEC messages by calling
- :ref:`ioctl CEC_TRANSMIT `. This implies that
- userspace can be a follower as well, since being able to transmit
- messages is a prerequisite of becoming a follower. If this
- capability isn't set, then the kernel will handle all CEC
- transmits and process all CEC messages it receives.
-
--  .. _`CEC-CAP-PASSTHROUGH`:
-
-   -  ``CEC_CAP_PASSTHROUGH``
-
-   -  0x0008
-
-   -  Userspace can use the passthrough mode by calling
- :ref:`ioctl CEC_S_MODE `.
-
--  .. _`CEC-CAP-RC`:
-
-   -  ``CEC_CAP_RC``
-
-   -  0x0010
-
-   -  This adapter supports the remote control protocol.
-
--  .. _`CEC-CAP-MONITOR-ALL`:
-
-   -  ``CEC_CAP_MONITOR_ALL``
-
-   -  0x0020
-
-   -  The CEC hardware can monitor all messages, not just directed and
- broadcast messages.
+* .. _`CEC-CAP-PHYS-ADDR`:
+
+  - ``CEC_CAP_PHYS_ADDR``
+  - 0x0001
+  - Userspace has to configure the physical address by calling
+   :ref:`ioctl CEC_ADAP_S_PHYS_ADDR `. If
+   this capability isn't set, then setting the physical address is
+   handled by the kernel whenever the EDID is set (for an HDMI
+   receiver) or read (for an HDMI transmitter).
+* .. _`CEC-CAP-LOG-ADDRS`:
+
+  - ``CEC_CAP_LOG_ADDRS``
+  - 0x0002
+  - Userspace has to configure the logical addresses by calling
+   :ref:`ioctl CEC_ADAP_S_LOG_ADDRS `. If
+   this capability isn't set, then the kernel will have configured
+   this.
+* .. _`CEC-CAP-TRANSMIT`:
+
+  - ``CEC_CAP_TRANSMIT``
+  - 0x0004
+  - Userspace can transmit CEC messages by calling
+   :ref:`ioctl 

[PATCH 04/11] cec: add CEC_MSG_FL_REPLY_TO_FOLLOWERS

2016-11-02 Thread Hans Verkuil
From: Hans Verkuil 

Give the caller more control over how replies to a transmit are
handled. By default the reply will only go to the filehandle that
called CEC_TRANSMIT. If this new flag is set, then the reply will
also go to all followers.

Signed-off-by: Hans Verkuil 
---
 Documentation/media/uapi/cec/cec-ioc-receive.rst | 22 +-
 drivers/staging/media/cec/TODO   |  4 
 drivers/staging/media/cec/cec-adap.c |  6 +++---
 drivers/staging/media/cec/cec-api.c  |  1 +
 include/linux/cec.h  |  5 -
 5 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/Documentation/media/uapi/cec/cec-ioc-receive.rst 
b/Documentation/media/uapi/cec/cec-ioc-receive.rst
index 21a88df..b4dffd2 100644
--- a/Documentation/media/uapi/cec/cec-ioc-receive.rst
+++ b/Documentation/media/uapi/cec/cec-ioc-receive.rst
@@ -119,7 +119,7 @@ result.
transmit.
 * - __u32
   - ``flags``
-  - Flags. No flags are defined yet, so set this to 0.
+  - Flags. See :ref:`cec-msg-flags` for a list of available flags.
 * - __u8
   - ``tx_status``
   - The status bits of the transmitted message. See
@@ -180,6 +180,26 @@ result.
valid if the :ref:`CEC_TX_STATUS_ERROR ` status 
bit is set.
 
 
+.. _cec-msg-flags:
+
+.. flat-table:: Flags for struct cec_msg
+:header-rows:  0
+:stub-columns: 0
+:widths:   3 1 4
+
+* .. _`CEC-MSG-FL-REPLY-TO-FOLLOWERS`:
+
+  - ``CEC_MSG_FL_REPLY_TO_FOLLOWERS``
+  - 1
+  - If a CEC transmit expects a reply, then by default that reply is only 
sent to
+   the filehandle that called :ref:`ioctl CEC_TRANSMIT `. If 
this
+   flag is set, then the reply is also sent to all followers, if any. If 
the
+   filehandle that called :ref:`ioctl CEC_TRANSMIT ` is also 
a
+   follower, then that filehandle will receive the reply twice: once as the
+   result of the :ref:`ioctl CEC_TRANSMIT `, and once via
+   :ref:`ioctl CEC_RECEIVE `.
+
+
 .. tabularcolumns:: |p{5.6cm}|p{0.9cm}|p{11.0cm}|
 
 .. _cec-tx-status:
diff --git a/drivers/staging/media/cec/TODO b/drivers/staging/media/cec/TODO
index 0841206..ce69001 100644
--- a/drivers/staging/media/cec/TODO
+++ b/drivers/staging/media/cec/TODO
@@ -13,10 +13,6 @@ Hopefully this will happen later in 2016.
 Other TODOs:
 
 - There are two possible replies to CEC_MSG_INITIATE_ARC. How to handle that?
-- If the reply field of cec_msg is set then when the reply arrives it
-  is only sent to the filehandle that transmitted the original message
-  and not to any followers. Should this behavior change or perhaps
-  controlled through a cec_msg flag?
 - Should CEC_LOG_ADDR_TYPE_SPECIFIC be replaced by TYPE_2ND_TV and 
TYPE_PROCESSOR?
   And also TYPE_SWITCH and TYPE_CDC_ONLY in addition to the TYPE_UNREGISTERED?
   This should give the framework more information about the device type
diff --git a/drivers/staging/media/cec/cec-adap.c 
b/drivers/staging/media/cec/cec-adap.c
index 589e457..6aceb1d 100644
--- a/drivers/staging/media/cec/cec-adap.c
+++ b/drivers/staging/media/cec/cec-adap.c
@@ -587,7 +587,6 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct 
cec_msg *msg,
msg->tx_nack_cnt = 0;
msg->tx_low_drive_cnt = 0;
msg->tx_error_cnt = 0;
-   msg->flags = 0;
msg->sequence = ++adap->sequence;
if (!msg->sequence)
msg->sequence = ++adap->sequence;
@@ -823,6 +822,7 @@ void cec_received_msg(struct cec_adapter *adap, struct 
cec_msg *msg)
dst->rx_status = msg->rx_status;
if (abort)
dst->rx_status |= CEC_RX_STATUS_FEATURE_ABORT;
+   msg->flags = dst->flags;
/* Remove it from the wait_queue */
list_del_init(>list);
 
@@ -1575,8 +1575,8 @@ static int cec_receive_notify(struct cec_adapter *adap, 
struct cec_msg *msg,
}
 
 skip_processing:
-   /* If this was a reply, then we're done */
-   if (is_reply)
+   /* If this was a reply, then we're done, unless otherwise specified */
+   if (is_reply && !(msg->flags & CEC_MSG_FL_REPLY_TO_FOLLOWERS))
return 0;
 
/*
diff --git a/drivers/staging/media/cec/cec-api.c 
b/drivers/staging/media/cec/cec-api.c
index 040ca7d..54148a6 100644
--- a/drivers/staging/media/cec/cec-api.c
+++ b/drivers/staging/media/cec/cec-api.c
@@ -190,6 +190,7 @@ static long cec_transmit(struct cec_adapter *adap, struct 
cec_fh *fh,
return -ENOTTY;
if (copy_from_user(, parg, sizeof(msg)))
return -EFAULT;
+   msg.flags &= CEC_MSG_FL_REPLY_TO_FOLLOWERS;
mutex_lock(>lock);
if (!adap->is_configured)
err = -ENONET;
diff --git a/include/linux/cec.h b/include/linux/cec.h
index 825455f..3f2f076 100644
--- a/include/linux/cec.h
+++ 

[PATCH 03/11] cec: add flag to cec_log_addrs to enable RC passthrough

2016-11-02 Thread Hans Verkuil
From: Hans Verkuil 

By default the CEC_MSG_USER_CONTROL_PRESSED/RELEASED messages
are passed on to the follower(s) only. If the new
CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU flag is set in the
flags field of struct cec_log_addrs then these messages are also
passed on to the remote control input subsystem and they will appear
as keystrokes.

This used to be the default behavior, but now you have to explicitly
enable it. This is done to force the caller to think about possible
security issues (e.g. if these messages are used to enter passwords).

Signed-off-by: Hans Verkuil 
---
 Documentation/media/uapi/cec/cec-ioc-adap-g-log-addrs.rst | 10 ++
 drivers/staging/media/cec/TODO|  2 --
 drivers/staging/media/cec/cec-adap.c  |  6 --
 drivers/staging/media/cec/cec-api.c   |  3 ++-
 include/linux/cec.h   |  2 ++
 5 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/Documentation/media/uapi/cec/cec-ioc-adap-g-log-addrs.rst 
b/Documentation/media/uapi/cec/cec-ioc-adap-g-log-addrs.rst
index af35f71..571ae57 100644
--- a/Documentation/media/uapi/cec/cec-ioc-adap-g-log-addrs.rst
+++ b/Documentation/media/uapi/cec/cec-ioc-adap-g-log-addrs.rst
@@ -166,6 +166,16 @@ logical address types are already defined will return with 
error ``EBUSY``.
it will go back to the unconfigured state. If this flag is set, then it 
will
fallback to the Unregistered logical address. Note that if the 
Unregistered
logical address was explicitly requested, then this flag has no effect.
+* .. _`CEC-LOG-ADDRS-FL-ALLOW-RC-PASSTHRU`:
+
+  - ``CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU``
+  - 2
+  - By default the ``CEC_MSG_USER_CONTROL_PRESSED`` and 
``CEC_MSG_USER_CONTROL_RELEASED``
+messages are only passed on to the follower(s), if any. If this flag 
is set,
+   then these messages are also passed on to the remote control input 
subsystem
+   and will appear as keystrokes. This features needs to be enabled 
explicitly.
+   If CEC is used to enter e.g. passwords, then you may not want to enable 
this
+   to avoid trivial snooping of the keystrokes.
 
 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
 
diff --git a/drivers/staging/media/cec/TODO b/drivers/staging/media/cec/TODO
index 1322469..0841206 100644
--- a/drivers/staging/media/cec/TODO
+++ b/drivers/staging/media/cec/TODO
@@ -13,8 +13,6 @@ Hopefully this will happen later in 2016.
 Other TODOs:
 
 - There are two possible replies to CEC_MSG_INITIATE_ARC. How to handle that?
-- Add a flag to inhibit passing CEC RC messages to the rc subsystem.
-  Applications should be able to choose this when calling S_LOG_ADDRS.
 - If the reply field of cec_msg is set then when the reply arrives it
   is only sent to the filehandle that transmitted the original message
   and not to any followers. Should this behavior change or perhaps
diff --git a/drivers/staging/media/cec/cec-adap.c 
b/drivers/staging/media/cec/cec-adap.c
index 611e07b..589e457 100644
--- a/drivers/staging/media/cec/cec-adap.c
+++ b/drivers/staging/media/cec/cec-adap.c
@@ -1478,7 +1478,8 @@ static int cec_receive_notify(struct cec_adapter *adap, 
struct cec_msg *msg,
}
 
case CEC_MSG_USER_CONTROL_PRESSED:
-   if (!(adap->capabilities & CEC_CAP_RC))
+   if (!(adap->capabilities & CEC_CAP_RC) ||
+   !(adap->log_addrs.flags & 
CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU))
break;
 
 #if IS_REACHABLE(CONFIG_RC_CORE)
@@ -1515,7 +1516,8 @@ static int cec_receive_notify(struct cec_adapter *adap, 
struct cec_msg *msg,
break;
 
case CEC_MSG_USER_CONTROL_RELEASED:
-   if (!(adap->capabilities & CEC_CAP_RC))
+   if (!(adap->capabilities & CEC_CAP_RC) ||
+   !(adap->log_addrs.flags & 
CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU))
break;
 #if IS_REACHABLE(CONFIG_RC_CORE)
rc_keyup(adap->rc);
diff --git a/drivers/staging/media/cec/cec-api.c 
b/drivers/staging/media/cec/cec-api.c
index e274e2f..040ca7d 100644
--- a/drivers/staging/media/cec/cec-api.c
+++ b/drivers/staging/media/cec/cec-api.c
@@ -162,7 +162,8 @@ static long cec_adap_s_log_addrs(struct cec_adapter *adap, 
struct cec_fh *fh,
return -ENOTTY;
if (copy_from_user(_addrs, parg, sizeof(log_addrs)))
return -EFAULT;
-   log_addrs.flags &= CEC_LOG_ADDRS_FL_ALLOW_UNREG_FALLBACK;
+   log_addrs.flags &= CEC_LOG_ADDRS_FL_ALLOW_UNREG_FALLBACK |
+  CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU;
mutex_lock(>lock);
if (!adap->is_configuring &&
(!log_addrs.num_log_addrs || !adap->is_configured) &&
diff --git a/include/linux/cec.h b/include/linux/cec.h
index 851968e..825455f 100644
--- a/include/linux/cec.h
+++ b/include/linux/cec.h
@@ 

[PATCH RESEND] media: omap3isp: Use dma_request_chan() to requesting DMA channel

2016-11-02 Thread Peter Ujfalusi
With the new dma_request_chan() the client driver does not need to look for
the DMA resource and it does not need to pass filter_fn anymore.
By switching to the new API the driver can now support deferred probing
against DMA.

Signed-off-by: Peter Ujfalusi 
CC: Laurent Pinchart 
CC: Mauro Carvalho Chehab 
---
Hi,

the original patch was sent 29.04.2016:
https://patchwork.kernel.org/patch/8981811/

I have rebased it on top of linux-next.

Regards,
Peter

 drivers/media/platform/omap3isp/isphist.c | 27 +--
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/media/platform/omap3isp/isphist.c 
b/drivers/media/platform/omap3isp/isphist.c
index 7138b043a4aa..e163e3d92517 100644
--- a/drivers/media/platform/omap3isp/isphist.c
+++ b/drivers/media/platform/omap3isp/isphist.c
@@ -18,7 +18,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -486,27 +485,19 @@ int omap3isp_hist_init(struct isp_device *isp)
hist->isp = isp;
 
if (HIST_CONFIG_DMA) {
-   struct platform_device *pdev = to_platform_device(isp->dev);
-   struct resource *res;
-   unsigned int sig = 0;
-   dma_cap_mask_t mask;
-
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-
-   res = platform_get_resource_byname(pdev, IORESOURCE_DMA,
-  "hist");
-   if (res)
-   sig = res->start;
-
-   hist->dma_ch = dma_request_slave_channel_compat(mask,
-   omap_dma_filter_fn, , isp->dev, "hist");
-   if (!hist->dma_ch)
+   hist->dma_ch = dma_request_chan(isp->dev, "hist");
+   if (IS_ERR(hist->dma_ch)) {
+   ret = PTR_ERR(hist->dma_ch);
+   if (ret == -EPROBE_DEFER)
+   return ret;
+
+   hist->dma_ch = NULL;
dev_warn(isp->dev,
 "hist: DMA channel request failed, using 
PIO\n");
-   else
+   } else {
dev_dbg(isp->dev, "hist: using DMA channel %s\n",
dma_chan_name(hist->dma_ch));
+   }
}
 
hist->ops = _ops;
-- 
2.10.2

--
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 v3 3/6] [media] rc-core: add support for IR raw transmitters

2016-11-02 Thread kbuild test robot
Hi Andi,

[auto build test WARNING on hid/for-next]
[also build test WARNING on v4.9-rc3]
[cannot apply to linuxtv-media/master next-20161028]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Andi-Shyti/Add-support-for-IR-transmitters/20161102-184657
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid.git for-next
reproduce: make htmldocs

All warnings (new ones prefixed by >>):

   make[3]: warning: jobserver unavailable: using -j1.  Add '+' to parent make 
rule.
   include/linux/init.h:1: warning: no structured comments found
   include/linux/workqueue.h:392: warning: No description found for parameter 
'...'
   include/linux/workqueue.h:392: warning: Excess function parameter 'args' 
description in 'alloc_workqueue'
   include/linux/workqueue.h:413: warning: No description found for parameter 
'...'
   include/linux/workqueue.h:413: warning: Excess function parameter 'args' 
description in 'alloc_ordered_workqueue'
   include/linux/kthread.h:26: warning: No description found for parameter '...'
   kernel/sys.c:1: warning: no structured comments found
   drivers/dma-buf/seqno-fence.c:1: warning: no structured comments found
   include/linux/fence-array.h:61: warning: No description found for parameter 
'fence'
   include/sound/core.h:324: warning: No description found for parameter '...'
   include/sound/core.h:335: warning: No description found for parameter '...'
   include/sound/core.h:388: warning: No description found for parameter '...'
   include/media/media-entity.h:1054: warning: No description found for 
parameter '...'
>> include/media/rc-core.h:39: warning: bad line:driver 
>> requires pulse/space data sequence.
   include/net/mac80211.h:2148: WARNING: Inline literal start-string without 
end-string.
   include/net/mac80211.h:2153: WARNING: Inline literal start-string without 
end-string.
   include/net/mac80211.h:3202: ERROR: Unexpected indentation.
   include/net/mac80211.h:3205: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   include/net/mac80211.h:3207: ERROR: Unexpected indentation.
   include/net/mac80211.h:3208: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   include/net/mac80211.h:1435: WARNING: Inline emphasis start-string without 
end-string.
   include/net/mac80211.h:1172: WARNING: Inline literal start-string without 
end-string.
   include/net/mac80211.h:1173: WARNING: Inline literal start-string without 
end-string.
   include/net/mac80211.h:814: ERROR: Unexpected indentation.
   include/net/mac80211.h:815: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   include/net/mac80211.h:820: ERROR: Unexpected indentation.
   include/net/mac80211.h:821: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   include/net/mac80211.h:2489: ERROR: Unexpected indentation.
   include/net/mac80211.h:1768: ERROR: Unexpected indentation.
   include/net/mac80211.h:1772: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   include/net/mac80211.h:1746: WARNING: Inline emphasis start-string without 
end-string.
   kernel/sched/fair.c:7252: WARNING: Inline emphasis start-string without 
end-string.
   kernel/time/timer.c:1230: ERROR: Unexpected indentation.
   kernel/time/timer.c:1232: ERROR: Unexpected indentation.
   kernel/time/timer.c:1233: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   include/linux/wait.h:121: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   include/linux/wait.h:124: ERROR: Unexpected indentation.
   include/linux/wait.h:126: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   kernel/time/hrtimer.c:1021: WARNING: Block quote ends without a blank line; 
unexpected unindent.
   kernel/signal.c:317: WARNING: Inline literal start-string without end-string.
   drivers/base/firmware_class.c:1348: WARNING: Bullet list ends without a 
blank line; unexpected unindent.
   drivers/message/fusion/mptbase.c:5054: WARNING: Definition list ends without 
a blank line; unexpected unindent.
   drivers/tty/serial/serial_core.c:1893: WARNING: Definition list ends without 
a blank line; unexpected unindent.
   include/linux/spi/spi.h:369: ERROR: Unexpected indentation.
   WARNING: dvipng command 'dvipng' cannot be run (needed for math display), 
check the imgmath_dvipng setting

vim +39 include/media/rc-core.h

23  #include 
24  
25  extern int rc_core_debug;
26  #define IR_dprintk(level, fmt, ...) \
27  do {\
28  if (rc_core_debug >= level) \
29  printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__);  \
30  } while (0)
31  
32  /**
33   * enum rc_driver_type - type of the RC out

Re: [PATCH 1/3] doc-rst: generic way to build PDF of sub-folders

2016-11-02 Thread Jani Nikula
On Wed, 24 Aug 2016, Markus Heiser  wrote:
> From: Markus Heiser 
>
> This extends the method to build only sub-folders to the targets
> "latexdocs" and "pdfdocs". To do so, a conf.py in the sub-folder is
> required, where the latex_documents of the sub-folder are
> defined. E.g. to build only gpu's PDF add the following to the
> Documentation/gpu/conf.py::
>
>   +latex_documents = [
>   +("index", "gpu.tex", "Linux GPU Driver Developer's Guide",
>   + "The kernel development community", "manual"),
>   +]
>
> and run:
>
>   make SPHINXDIRS=gpu pdfdocs

Did you ever try this with more than one subfolder?

BR,
Jani.

>
> Signed-off-by: Markus Heiser 
> ---
>  Documentation/Makefile.sphinx | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/Makefile.sphinx b/Documentation/Makefile.sphinx
> index 894cfaa..92deea3 100644
> --- a/Documentation/Makefile.sphinx
> +++ b/Documentation/Makefile.sphinx
> @@ -71,12 +71,12 @@ ifeq ($(HAVE_PDFLATEX),0)
>   $(warning The 'xelatex' command was not found. Make sure you have it 
> installed and in PATH to produce PDF output.)
>   @echo "  SKIPSphinx $@ target."
>  else # HAVE_PDFLATEX
> - @$(call loop_cmd,sphinx,latex,.,latex,.)
> + @$(foreach var,$(SPHINXDIRS),$(call 
> loop_cmd,sphinx,latex,$(var),latex,$(var)))
>  endif # HAVE_PDFLATEX
>  
>  pdfdocs: latexdocs
>  ifneq ($(HAVE_PDFLATEX),0)
> - $(Q)$(MAKE) PDFLATEX=xelatex LATEXOPTS="-interaction=nonstopmode" -C 
> $(BUILDDIR)/latex
> + $(foreach var,$(SPHINXDIRS), $(MAKE) PDFLATEX=xelatex 
> LATEXOPTS="-interaction=nonstopmode" -C $(BUILDDIR)/$(var)/latex)
>  endif # HAVE_PDFLATEX
>  
>  epubdocs:

-- 
Jani Nikula, Intel Open Source Technology Center
--
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/6] [media] rc-main: split setup and unregister functions

2016-11-02 Thread Andi Shyti
Move the input device allocation, map and protocol handling to
different functions.

Signed-off-by: Andi Shyti 
---
 drivers/media/rc/rc-main.c | 143 +
 1 file changed, 81 insertions(+), 62 deletions(-)

diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 9e19b73e..7ab1b32 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -1405,16 +1405,12 @@ void rc_free_device(struct rc_dev *dev)
 }
 EXPORT_SYMBOL_GPL(rc_free_device);
 
-int rc_register_device(struct rc_dev *dev)
+static int rc_setup_rx_device(struct rc_dev *dev)
 {
-   static bool raw_init = false; /* raw decoders loaded? */
-   struct rc_map *rc_map;
-   const char *path;
-   int attr = 0;
-   int minor;
int rc;
+   struct rc_map *rc_map;
 
-   if (!dev || !dev->map_name)
+   if (!dev->map_name)
return -EINVAL;
 
rc_map = rc_map_get(dev->map_name);
@@ -1423,6 +1419,19 @@ int rc_register_device(struct rc_dev *dev)
if (!rc_map || !rc_map->scan || rc_map->size == 0)
return -EINVAL;
 
+   rc = ir_setkeytable(dev, rc_map);
+   if (rc)
+   return rc;
+
+   if (dev->change_protocol) {
+   u64 rc_type = (1ll << rc_map->rc_type);
+
+   rc = dev->change_protocol(dev, _type);
+   if (rc < 0)
+   goto out_table;
+   dev->enabled_protocols = rc_type;
+   }
+
set_bit(EV_KEY, dev->input_dev->evbit);
set_bit(EV_REP, dev->input_dev->evbit);
set_bit(EV_MSC, dev->input_dev->evbit);
@@ -1432,6 +1441,61 @@ int rc_register_device(struct rc_dev *dev)
if (dev->close)
dev->input_dev->close = ir_close;
 
+   /*
+* Default delay of 250ms is too short for some protocols, especially
+* since the timeout is currently set to 250ms. Increase it to 500ms,
+* to avoid wrong repetition of the keycodes. Note that this must be
+* set after the call to input_register_device().
+*/
+   dev->input_dev->rep[REP_DELAY] = 500;
+
+   /*
+* As a repeat event on protocols like RC-5 and NEC take as long as
+* 110/114ms, using 33ms as a repeat period is not the right thing
+* to do.
+*/
+   dev->input_dev->rep[REP_PERIOD] = 125;
+
+   /* rc_open will be called here */
+   rc = input_register_device(dev->input_dev);
+   if (rc)
+   goto out_table;
+
+   dev->input_dev->dev.parent = >dev;
+   memcpy(>input_dev->id, >input_id, sizeof(dev->input_id));
+   dev->input_dev->phys = dev->input_phys;
+   dev->input_dev->name = dev->input_name;
+
+   return 0;
+
+out_table:
+   ir_free_table(>rc_map);
+
+   return rc;
+}
+
+static void rc_free_rx_device(struct rc_dev *dev)
+{
+   if (!dev)
+   return;
+
+   ir_free_table(>rc_map);
+
+   input_unregister_device(dev->input_dev);
+   dev->input_dev = NULL;
+}
+
+int rc_register_device(struct rc_dev *dev)
+{
+   static bool raw_init = false; /* raw decoders loaded? */
+   const char *path;
+   int attr = 0;
+   int minor;
+   int rc;
+
+   if (!dev)
+   return -EINVAL;
+
minor = ida_simple_get(_ida, 0, RC_DEV_MAX, GFP_KERNEL);
if (minor < 0)
return minor;
@@ -1455,39 +1519,15 @@ int rc_register_device(struct rc_dev *dev)
if (rc)
goto out_unlock;
 
-   rc = ir_setkeytable(dev, rc_map);
-   if (rc)
-   goto out_dev;
-
-   dev->input_dev->dev.parent = >dev;
-   memcpy(>input_dev->id, >input_id, sizeof(dev->input_id));
-   dev->input_dev->phys = dev->input_phys;
-   dev->input_dev->name = dev->input_name;
-
-   rc = input_register_device(dev->input_dev);
-   if (rc)
-   goto out_table;
-
-   /*
-* Default delay of 250ms is too short for some protocols, especially
-* since the timeout is currently set to 250ms. Increase it to 500ms,
-* to avoid wrong repetition of the keycodes. Note that this must be
-* set after the call to input_register_device().
-*/
-   dev->input_dev->rep[REP_DELAY] = 500;
-
-   /*
-* As a repeat event on protocols like RC-5 and NEC take as long as
-* 110/114ms, using 33ms as a repeat period is not the right thing
-* to do.
-*/
-   dev->input_dev->rep[REP_PERIOD] = 125;
-
path = kobject_get_path(>dev.kobj, GFP_KERNEL);
dev_info(>dev, "%s as %s\n",
dev->input_name ?: "Unspecified device", path ?: "N/A");
kfree(path);
 
+   rc = rc_setup_rx_device(dev);
+   if (rc)
+   goto out_dev;
+
if (dev->driver_type == RC_DRIVER_IR_RAW) {
if (!raw_init) {
request_module_nowait("ir-lirc-codec");
@@ -1495,36 +1535,20 

[PATCH v3 4/6] [media] rc-ir-raw: do not generate any receiving thread for raw transmitters

2016-11-02 Thread Andi Shyti
Raw IR transmitters do not need any thread listening for
occurring events. Check the driver type before running the
thread.

Signed-off-by: Andi Shyti 
---
 drivers/media/rc/rc-ir-raw.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/media/rc/rc-ir-raw.c b/drivers/media/rc/rc-ir-raw.c
index 205ecc6..db3701f 100644
--- a/drivers/media/rc/rc-ir-raw.c
+++ b/drivers/media/rc/rc-ir-raw.c
@@ -275,12 +275,19 @@ int ir_raw_event_register(struct rc_dev *dev)
INIT_KFIFO(dev->raw->kfifo);
 
spin_lock_init(>raw->lock);
-   dev->raw->thread = kthread_run(ir_raw_event_thread, dev->raw,
-  "rc%u", dev->minor);
 
-   if (IS_ERR(dev->raw->thread)) {
-   rc = PTR_ERR(dev->raw->thread);
-   goto out;
+   /*
+* raw transmitters do not need any event registration
+* because the event is coming from userspace
+*/
+   if (dev->driver_type != RC_DRIVER_IR_RAW_TX) {
+   dev->raw->thread = kthread_run(ir_raw_event_thread, dev->raw,
+  "rc%u", dev->minor);
+
+   if (IS_ERR(dev->raw->thread)) {
+   rc = PTR_ERR(dev->raw->thread);
+   goto out;
+   }
}
 
mutex_lock(_raw_handler_lock);
-- 
2.10.1

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


[PATCH v3 5/6] Documentation: bindings: add documentation for ir-spi device driver

2016-11-02 Thread Andi Shyti
Document the ir-spi driver's binding which is a IR led driven
through the SPI line.

Signed-off-by: Andi Shyti 
---
 .../devicetree/bindings/leds/spi-ir-led.txt| 29 ++
 1 file changed, 29 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/spi-ir-led.txt

diff --git a/Documentation/devicetree/bindings/leds/spi-ir-led.txt 
b/Documentation/devicetree/bindings/leds/spi-ir-led.txt
new file mode 100644
index 000..896b699
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/spi-ir-led.txt
@@ -0,0 +1,29 @@
+Device tree bindings for IR LED connected through SPI bus which is used as
+remote controller.
+
+The IR LED switch is connected to the MOSI line of the SPI device and the data
+are delivered thourgh that.
+
+Required properties:
+   - compatible: should be "ir-spi-led".
+
+Optional properties:
+   - duty-cycle: 8 bit balue that represents the percentage of one period
+ in which the signal is active.  It can be 50, 60, 70, 75, 80 or 90.
+   - led-active-low: boolean value that specifies whether the output is
+ negated with a NOT gate.
+   - power-supply: specifies the power source. It can either be a regulator
+ or a gpio which enables a regulator, i.e. a regulator-fixed as
+ described in
+ Documentation/devicetree/bindings/regulator/fixed-regulator.txt
+
+Example:
+
+   irled@0 {
+   compatible = "ir-spi-led";
+   reg = <0x0>;
+   spi-max-frequency = <500>;
+   power-supply = <_led>;
+   led-active-low;
+   duty-cycle = /bits/ 8 <60>;
+   };
-- 
2.10.1

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


[PATCH v3 1/6] [media] rc-main: assign driver type during allocation

2016-11-02 Thread Andi Shyti
The driver type can be assigned immediately when an RC device
requests to the framework to allocate the device.

This is an 'enum rc_driver_type' data type and specifies whether
the device is a raw receiver or scancode receiver. The type will
be given as parameter to the rc_allocate_device device.

Change accordingly all the drivers calling rc_allocate_device()
so that the device type is specified during the rc device
allocation. Whenever the device type is not specified, it will be
set as RC_DRIVER_SCANCODE which was the default '0' value.

Suggested-by: Sean Young 
Signed-off-by: Andi Shyti 
---
 drivers/hid/hid-picolcd_cir.c   |  3 +--
 drivers/media/common/siano/smsir.c  |  3 +--
 drivers/media/i2c/ir-kbd-i2c.c  |  2 +-
 drivers/media/pci/bt8xx/bttv-input.c|  2 +-
 drivers/media/pci/cx23885/cx23885-input.c   | 11 +--
 drivers/media/pci/cx88/cx88-input.c |  3 +--
 drivers/media/pci/dm1105/dm1105.c   |  3 +--
 drivers/media/pci/mantis/mantis_input.c |  2 +-
 drivers/media/pci/saa7134/saa7134-input.c   |  2 +-
 drivers/media/pci/smipcie/smipcie-ir.c  |  3 +--
 drivers/media/pci/ttpci/budget-ci.c |  2 +-
 drivers/media/rc/ati_remote.c   |  3 +--
 drivers/media/rc/ene_ir.c   |  3 +--
 drivers/media/rc/fintek-cir.c   |  3 +--
 drivers/media/rc/gpio-ir-recv.c |  3 +--
 drivers/media/rc/igorplugusb.c  |  3 +--
 drivers/media/rc/iguanair.c |  3 +--
 drivers/media/rc/img-ir/img-ir-hw.c |  2 +-
 drivers/media/rc/img-ir/img-ir-raw.c|  3 +--
 drivers/media/rc/imon.c |  3 +--
 drivers/media/rc/ir-hix5hd2.c   |  3 +--
 drivers/media/rc/ite-cir.c  |  3 +--
 drivers/media/rc/mceusb.c   |  3 +--
 drivers/media/rc/meson-ir.c |  3 +--
 drivers/media/rc/nuvoton-cir.c  |  3 +--
 drivers/media/rc/rc-loopback.c  |  3 +--
 drivers/media/rc/rc-main.c  |  4 +++-
 drivers/media/rc/redrat3.c  |  3 +--
 drivers/media/rc/st_rc.c|  3 +--
 drivers/media/rc/streamzap.c|  3 +--
 drivers/media/rc/sunxi-cir.c|  3 +--
 drivers/media/rc/ttusbir.c  |  3 +--
 drivers/media/rc/winbond-cir.c  |  3 +--
 drivers/media/usb/au0828/au0828-input.c |  3 +--
 drivers/media/usb/cx231xx/cx231xx-input.c   |  2 +-
 drivers/media/usb/dvb-usb-v2/dvb_usb_core.c |  3 +--
 drivers/media/usb/dvb-usb/dvb-usb-remote.c  |  3 +--
 drivers/media/usb/em28xx/em28xx-input.c |  2 +-
 drivers/media/usb/tm6000/tm6000-input.c |  3 +--
 drivers/staging/media/cec/cec-core.c|  3 +--
 include/media/rc-core.h |  4 +++-
 41 files changed, 45 insertions(+), 80 deletions(-)

diff --git a/drivers/hid/hid-picolcd_cir.c b/drivers/hid/hid-picolcd_cir.c
index 9628651..38b0ea8 100644
--- a/drivers/hid/hid-picolcd_cir.c
+++ b/drivers/hid/hid-picolcd_cir.c
@@ -108,12 +108,11 @@ int picolcd_init_cir(struct picolcd_data *data, struct 
hid_report *report)
struct rc_dev *rdev;
int ret = 0;
 
-   rdev = rc_allocate_device();
+   rdev = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!rdev)
return -ENOMEM;
 
rdev->priv = data;
-   rdev->driver_type  = RC_DRIVER_IR_RAW;
rdev->allowed_protocols = RC_BIT_ALL;
rdev->open = picolcd_cir_open;
rdev->close= picolcd_cir_close;
diff --git a/drivers/media/common/siano/smsir.c 
b/drivers/media/common/siano/smsir.c
index 41f2a39..ee30c7b 100644
--- a/drivers/media/common/siano/smsir.c
+++ b/drivers/media/common/siano/smsir.c
@@ -58,7 +58,7 @@ int sms_ir_init(struct smscore_device_t *coredev)
struct rc_dev *dev;
 
pr_debug("Allocating rc device\n");
-   dev = rc_allocate_device();
+   dev = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!dev)
return -ENOMEM;
 
@@ -86,7 +86,6 @@ int sms_ir_init(struct smscore_device_t *coredev)
 #endif
 
dev->priv = coredev;
-   dev->driver_type = RC_DRIVER_IR_RAW;
dev->allowed_protocols = RC_BIT_ALL;
dev->map_name = sms_get_board(board_id)->rc_codes;
dev->driver_name = MODULE_NAME;
diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
index f95a6bc..2848a3e 100644
--- a/drivers/media/i2c/ir-kbd-i2c.c
+++ b/drivers/media/i2c/ir-kbd-i2c.c
@@ -428,7 +428,7 @@ static int ir_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
 * If platform_data doesn't specify rc_dev, initialize it
 * internally
 */
-   rc = rc_allocate_device();
+   rc = rc_allocate_device(RC_DRIVER_SCANCODE);
if (!rc)
return -ENOMEM;
}
diff --git 

[PATCH v3 6/6] [media] rc: add support for IR LEDs driven through SPI

2016-11-02 Thread Andi Shyti
The ir-spi is a simple device driver which supports the
connection between an IR LED and the MOSI line of an SPI device.

The driver, indeed, uses the SPI framework to stream the raw data
provided by userspace through an rc character device. The chardev
is handled by the LIRC framework and its functionality basically
provides:

 - write: the driver gets a pulse/space signal and translates it
   to a binary signal that will be streamed to the IR led through
   the SPI framework.
 - set frequency: sets the frequency whith which the data should
   be sent. This is handle with ioctl with the
   LIRC_SET_SEND_CARRIER flag (as per lirc documentation)
 - set duty cycle: this is also handled with ioctl with the
   LIRC_SET_SEND_DUTY_CYCLE flag. The driver handles duty cycles
   of 50%, 60%, 70%, 75%, 80% and 90%, calculated on 16bit data.

The character device is created under /dev/lircX name, where X is
and ID assigned by the LIRC framework.

Example of usage:

fd = open("/dev/lirc0", O_RDWR);
if (fd < 0)
return -1;

val = 608000;
ret = ioctl(fd, LIRC_SET_SEND_CARRIER, );
if (ret < 0)
return -1;

val = 60;
ret = ioctl(fd, LIRC_SET_SEND_DUTY_CYCLE, );
if (ret < 0)
return -1;

n = write(fd, buffer, BUF_LEN);
if (n < 0 || n != BUF_LEN)
ret = -1;

close(fd);

Signed-off-by: Andi Shyti 
Reviewed-by: Sean Young 
---
 drivers/media/rc/Kconfig  |   9 ++
 drivers/media/rc/Makefile |   1 +
 drivers/media/rc/ir-spi.c | 205 ++
 3 files changed, 215 insertions(+)
 create mode 100644 drivers/media/rc/ir-spi.c

diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig
index 370e16e..207dfcc 100644
--- a/drivers/media/rc/Kconfig
+++ b/drivers/media/rc/Kconfig
@@ -261,6 +261,15 @@ config IR_REDRAT3
   To compile this driver as a module, choose M here: the
   module will be called redrat3.
 
+config IR_SPI
+   tristate "SPI connected IR LED"
+   depends on SPI && LIRC
+   ---help---
+ Say Y if you want to use an IR LED connected through SPI bus.
+
+ To compile this driver as a module, choose M here: the module will be
+ called ir-spi.
+
 config IR_STREAMZAP
tristate "Streamzap PC Remote IR Receiver"
depends on USB_ARCH_HAS_HCD
diff --git a/drivers/media/rc/Makefile b/drivers/media/rc/Makefile
index 379a5c0..1417c8d 100644
--- a/drivers/media/rc/Makefile
+++ b/drivers/media/rc/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_IR_NUVOTON) += nuvoton-cir.o
 obj-$(CONFIG_IR_ENE) += ene_ir.o
 obj-$(CONFIG_IR_REDRAT3) += redrat3.o
 obj-$(CONFIG_IR_RX51) += ir-rx51.o
+obj-$(CONFIG_IR_SPI) += ir-spi.o
 obj-$(CONFIG_IR_STREAMZAP) += streamzap.o
 obj-$(CONFIG_IR_WINBOND_CIR) += winbond-cir.o
 obj-$(CONFIG_RC_LOOPBACK) += rc-loopback.o
diff --git a/drivers/media/rc/ir-spi.c b/drivers/media/rc/ir-spi.c
new file mode 100644
index 000..fcda1e4
--- /dev/null
+++ b/drivers/media/rc/ir-spi.c
@@ -0,0 +1,205 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Author: Andi Shyti 
+ *
+ * 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.
+ *
+ * SPI driven IR LED device driver
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define IR_SPI_DRIVER_NAME "ir-spi"
+
+/* pulse value for different duty cycles */
+#define IR_SPI_PULSE_DC_50 0xff00
+#define IR_SPI_PULSE_DC_60 0xfc00
+#define IR_SPI_PULSE_DC_70 0xf800
+#define IR_SPI_PULSE_DC_75 0xf000
+#define IR_SPI_PULSE_DC_80 0xc000
+#define IR_SPI_PULSE_DC_90 0x8000
+
+#define IR_SPI_DEFAULT_FREQUENCY   38000
+#define IR_SPI_BIT_PER_WORD8
+#define IR_SPI_MAX_BUFSIZE  4096
+
+struct ir_spi_data {
+   u32 freq;
+   u8 duty_cycle;
+   bool negated;
+
+   u16 tx_buf[IR_SPI_MAX_BUFSIZE];
+   u16 pulse;
+   u16 space;
+
+   struct rc_dev *rc;
+   struct spi_device *spi;
+   struct regulator *regulator;
+};
+
+static int ir_spi_tx(struct rc_dev *dev,
+   unsigned int *buffer, unsigned int count)
+{
+   int i;
+   int ret;
+   unsigned int len = 0;
+   struct ir_spi_data *idata = dev->priv;
+   struct spi_transfer xfer;
+
+   /* convert the pulse/space signal to raw binary signal */
+   for (i = 0; i < count; i++) {
+   int j;
+   u16 val = ((i+1) % 2) ? idata->pulse : idata->space;
+
+   if (len + buffer[i] >= IR_SPI_MAX_BUFSIZE)
+   return -EINVAL;
+
+   /*
+* the first value in buffer is a pulse, so that 0, 2, 4, 

[PATCH v3 0/6] Add support for IR transmitters

2016-11-02 Thread Andi Shyti
Hi,

The main goal is to add support in the rc framework for IR
transmitters, which currently is only supported by lirc but that
is not the preferred way.

The last patch adds support for an IR transmitter driven by
the MOSI line of an SPI controller, it's the case of the Samsung
TM2(e) board which support is currently ongoing.

The last patch adds support for an IR transmitter driven by
the MOSI line of an SPI controller, it's the case of the Samsung
TM2(e) board which support is currently ongoing.

Thanks Sean for your prompt reviews.

Andi

Changelog from version 1:

The RFC is now PATCH. The main difference is that this version
doesn't try to add the any bit streaming protocol and doesn't
modify any LIRC interface specification.

patch 1: updates all the drivers using rc_allocate_device
patch 2: fixed errors and warning reported from the kbuild test
 robot
patch 5: this patch has been dropped and replaced with a new one
 which avoids waiting for transmitters.
patch 6: added new properties to the dts specification
patch 7: the driver uses the pulse/space input and converts it to
 a bit stream.


Changelog from version 2:

The original patch number 5 has been abandoned because it was not
bringing much benenfit.

patch 1: rebased on the new kernel.
patch 3: removed the sysfs attribute protocol for transmitters
patch 5: the binding has been moved to the leds section instead
 of the media. Fixed all the comments from Rob
patch 6: fixed all the comments from Sean added also Sean's
 review.

Andi Shyti (6):
  [media] rc-main: assign driver type during allocation
  [media] rc-main: split setup and unregister functions
  [media] rc-core: add support for IR raw transmitters
  [media] rc-ir-raw: do not generate any receiving thread for raw
transmitters
  Documentation: bindings: add documentation for ir-spi device driver
  [media] rc: add support for IR LEDs driven through SPI

 .../devicetree/bindings/leds/spi-ir-led.txt|  29 +++
 drivers/hid/hid-picolcd_cir.c  |   3 +-
 drivers/media/common/siano/smsir.c |   3 +-
 drivers/media/i2c/ir-kbd-i2c.c |   2 +-
 drivers/media/pci/bt8xx/bttv-input.c   |   2 +-
 drivers/media/pci/cx23885/cx23885-input.c  |  11 +-
 drivers/media/pci/cx88/cx88-input.c|   3 +-
 drivers/media/pci/dm1105/dm1105.c  |   3 +-
 drivers/media/pci/mantis/mantis_input.c|   2 +-
 drivers/media/pci/saa7134/saa7134-input.c  |   2 +-
 drivers/media/pci/smipcie/smipcie-ir.c |   3 +-
 drivers/media/pci/ttpci/budget-ci.c|   2 +-
 drivers/media/rc/Kconfig   |   9 +
 drivers/media/rc/Makefile  |   1 +
 drivers/media/rc/ati_remote.c  |   3 +-
 drivers/media/rc/ene_ir.c  |   3 +-
 drivers/media/rc/fintek-cir.c  |   3 +-
 drivers/media/rc/gpio-ir-recv.c|   3 +-
 drivers/media/rc/igorplugusb.c |   3 +-
 drivers/media/rc/iguanair.c|   3 +-
 drivers/media/rc/img-ir/img-ir-hw.c|   2 +-
 drivers/media/rc/img-ir/img-ir-raw.c   |   3 +-
 drivers/media/rc/imon.c|   3 +-
 drivers/media/rc/ir-hix5hd2.c  |   3 +-
 drivers/media/rc/ir-spi.c  | 205 +
 drivers/media/rc/ite-cir.c |   3 +-
 drivers/media/rc/mceusb.c  |   3 +-
 drivers/media/rc/meson-ir.c|   3 +-
 drivers/media/rc/nuvoton-cir.c |   3 +-
 drivers/media/rc/rc-ir-raw.c   |  17 +-
 drivers/media/rc/rc-loopback.c |   3 +-
 drivers/media/rc/rc-main.c | 181 ++
 drivers/media/rc/redrat3.c |   3 +-
 drivers/media/rc/st_rc.c   |   3 +-
 drivers/media/rc/streamzap.c   |   3 +-
 drivers/media/rc/sunxi-cir.c   |   3 +-
 drivers/media/rc/ttusbir.c |   3 +-
 drivers/media/rc/winbond-cir.c |   3 +-
 drivers/media/usb/au0828/au0828-input.c|   3 +-
 drivers/media/usb/cx231xx/cx231xx-input.c  |   2 +-
 drivers/media/usb/dvb-usb-v2/dvb_usb_core.c|   3 +-
 drivers/media/usb/dvb-usb/dvb-usb-remote.c |   3 +-
 drivers/media/usb/em28xx/em28xx-input.c|   2 +-
 drivers/media/usb/tm6000/tm6000-input.c|   3 +-
 drivers/staging/media/cec/cec-core.c   |   3 +-
 include/media/rc-core.h|  13 +-
 46 files changed, 409 insertions(+), 163 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/leds/spi-ir-led.txt
 create mode 100644 drivers/media/rc/ir-spi.c

-- 
2.10.1

--
To unsubscribe from 

[PATCH v3 3/6] [media] rc-core: add support for IR raw transmitters

2016-11-02 Thread Andi Shyti
IR raw transmitter driver type is specified in the enum
rc_driver_type as RC_DRIVER_IR_RAW_TX which includes all those
devices that transmit raw stream of bit to a receiver.

The data are provided by userspace applications, therefore they
don't need any input device allocation, but still they need to be
registered as raw devices.

Suggested-by: Sean Young 
Signed-off-by: Andi Shyti 
---
 drivers/media/rc/rc-main.c | 42 +-
 include/media/rc-core.h|  9 ++---
 2 files changed, 31 insertions(+), 20 deletions(-)

diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 7ab1b32..0d2f440 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -1363,20 +1363,24 @@ struct rc_dev *rc_allocate_device(enum rc_driver_type 
type)
if (!dev)
return NULL;
 
-   dev->input_dev = input_allocate_device();
-   if (!dev->input_dev) {
-   kfree(dev);
-   return NULL;
-   }
+   if (type != RC_DRIVER_IR_RAW_TX) {
+   dev->input_dev = input_allocate_device();
+   if (!dev->input_dev) {
+   kfree(dev);
+   return NULL;
+   }
+
+   dev->input_dev->getkeycode = ir_getkeycode;
+   dev->input_dev->setkeycode = ir_setkeycode;
+   input_set_drvdata(dev->input_dev, dev);
 
-   dev->input_dev->getkeycode = ir_getkeycode;
-   dev->input_dev->setkeycode = ir_setkeycode;
-   input_set_drvdata(dev->input_dev, dev);
+   setup_timer(>timer_keyup, ir_timer_keyup,
+   (unsigned long)dev);
 
-   spin_lock_init(>rc_map.lock);
-   spin_lock_init(>keylock);
+   spin_lock_init(>rc_map.lock);
+   spin_lock_init(>keylock);
+   }
mutex_init(>lock);
-   setup_timer(>timer_keyup, ir_timer_keyup, (unsigned long)dev);
 
dev->dev.type = _dev_type;
dev->dev.class = _class;
@@ -1476,7 +1480,7 @@ static int rc_setup_rx_device(struct rc_dev *dev)
 
 static void rc_free_rx_device(struct rc_dev *dev)
 {
-   if (!dev)
+   if (!dev || dev->driver_type == RC_DRIVER_IR_RAW_TX)
return;
 
ir_free_table(>rc_map);
@@ -1506,7 +1510,8 @@ int rc_register_device(struct rc_dev *dev)
atomic_set(>initialized, 0);
 
dev->dev.groups = dev->sysfs_groups;
-   dev->sysfs_groups[attr++] = _dev_protocol_attr_grp;
+   if (dev->driver_type != RC_DRIVER_IR_RAW_TX)
+   dev->sysfs_groups[attr++] = _dev_protocol_attr_grp;
if (dev->s_filter)
dev->sysfs_groups[attr++] = _dev_filter_attr_grp;
if (dev->s_wakeup_filter)
@@ -1524,11 +1529,14 @@ int rc_register_device(struct rc_dev *dev)
dev->input_name ?: "Unspecified device", path ?: "N/A");
kfree(path);
 
-   rc = rc_setup_rx_device(dev);
-   if (rc)
-   goto out_dev;
+   if (dev->driver_type != RC_DRIVER_IR_RAW_TX) {
+   rc = rc_setup_rx_device(dev);
+   if (rc)
+   goto out_dev;
+   }
 
-   if (dev->driver_type == RC_DRIVER_IR_RAW) {
+   if (dev->driver_type == RC_DRIVER_IR_RAW ||
+   dev->driver_type == RC_DRIVER_IR_RAW_TX) {
if (!raw_init) {
request_module_nowait("ir-lirc-codec");
raw_init = true;
diff --git a/include/media/rc-core.h b/include/media/rc-core.h
index f8ca557..b6f7419 100644
--- a/include/media/rc-core.h
+++ b/include/media/rc-core.h
@@ -32,13 +32,16 @@ do {
\
 /**
  * enum rc_driver_type - type of the RC output
  *
- * @RC_DRIVER_SCANCODE:Driver or hardware generates a scancode
- * @RC_DRIVER_IR_RAW:  Driver or hardware generates pulse/space sequences.
- * It needs a Infra-Red pulse/space decoder
+ * @RC_DRIVER_SCANCODE: Driver or hardware generates a scancode
+ * @RC_DRIVER_IR_RAW:   Driver or hardware generates pulse/space sequences.
+ *  It needs a Infra-Red pulse/space decoder
+ * @RC_DRIVER_IR_RAW_TX: Device transmitter only,
+driver requires pulse/space data sequence.
  */
 enum rc_driver_type {
RC_DRIVER_SCANCODE = 0,
RC_DRIVER_IR_RAW,
+   RC_DRIVER_IR_RAW_TX,
 };
 
 /**
-- 
2.10.1

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


Re: [PATCH v4] media: Driver for Toshiba et8ek8 5MP sensor

2016-11-02 Thread Ivaylo Dimitrov



On  2.11.2016 10:15, Pavel Machek wrote:

Hi!


I'll have to go through the patches, et8ek8 driver is probably not
enough to get useful video. platform/video-bus-switch.c is needed for
camera switching, then some omap3isp patches to bind flash and
autofocus into the subdevice.

Then, device tree support on n900 can be added.


I briefly discussed with with Sebastian.

Do you think the elusive support for the secondary camera is worth keeping
out the main camera from the DT in mainline? As long as there's a reasonable
way to get it working, I'd just merge that. If someone ever gets the
secondary camera working properly and nicely with the video bus switch,
that's cool, we'll somehow deal with the problem then. But frankly I don't
think it's very useful even if we get there: the quality is really bad.



Yes, lets merge what we have till now, it will be way easier to improve on
it once it is part of the mainline.

BTW, I have (had) patched VBS working almost without problems, when it comes
to it I'll dig it.


Do you have a version that switches on runtime?

Best regards,
Pavel



IIRC yes, but I might be wrong, it was a while I was playing with it.

Ivo
--
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 v4] media: Driver for Toshiba et8ek8 5MP sensor

2016-11-02 Thread Pavel Machek
Hi!

> >>I'll have to go through the patches, et8ek8 driver is probably not
> >>enough to get useful video. platform/video-bus-switch.c is needed for
> >>camera switching, then some omap3isp patches to bind flash and
> >>autofocus into the subdevice.
> >>
> >>Then, device tree support on n900 can be added.
> >
> >I briefly discussed with with Sebastian.
> >
> >Do you think the elusive support for the secondary camera is worth keeping
> >out the main camera from the DT in mainline? As long as there's a reasonable
> >way to get it working, I'd just merge that. If someone ever gets the
> >secondary camera working properly and nicely with the video bus switch,
> >that's cool, we'll somehow deal with the problem then. But frankly I don't
> >think it's very useful even if we get there: the quality is really bad.
> >
> 
> Yes, lets merge what we have till now, it will be way easier to improve on
> it once it is part of the mainline.
> 
> BTW, I have (had) patched VBS working almost without problems, when it comes
> to it I'll dig it.

Do you have a version that switches on runtime?

Best regards,
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH] Staging:media:davinci_vpfe: used devm_kzalloc in place of kzalloc

2016-11-02 Thread Julia Lawall


On Wed, 2 Nov 2016, Nadim Almas wrote:

> Switch to resource-managed function devm_kzalloc instead
> of kzolloc and remove unneeded kzfree
>
> Also, remove kzfree in probe function and  remove
> function,vpfe_remove as it is now has nothing to do.
> The Coccinelle semantic patch used to make this change is as follows:
> /
> @platform@
> identifier p, probefn, removefn;
> @@
> struct platform_driver p = {
> .probe = probefn,
> .remove = removefn,
> };
>
> @prb@
> identifier platform.probefn, pdev;
> expression e, e1, e2;
> @@
> probefn(struct platform_device *pdev, ...) {
> <+...
> - e = kzalloc(e1, e2)
> + e = devm_kzalloc(>dev, e1, e2)
> ...
> ?-kzfree(e);
> ...+>
> }
> @rem depends on prb@
> identifier platform.removefn;
> expression prb.e;
> @@
> removefn(...) {
> <...
> - kzfree(e);
> ...>
> }
> //
>
> Signed-off-by: Nadim Almas 
> ---
>  drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c 
> b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
> index bf077f8..cd44f0f 100644
> --- a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
> +++ b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
> @@ -579,7 +579,7 @@ static int vpfe_probe(struct platform_device *pdev)
>   struct resource *res1;
>   int ret = -ENOMEM;
>
> - vpfe_dev = kzalloc(sizeof(*vpfe_dev), GFP_KERNEL);
> + vpfe_dev = devm_kzalloc(>dev, sizeof(*vpfe_dev), GFP_KERNEL);
>   if (!vpfe_dev)
>   return ret;
>
> @@ -681,7 +681,6 @@ static int vpfe_probe(struct platform_device *pdev)
>  probe_disable_clock:
>   vpfe_disable_clock(vpfe_dev);
>  probe_free_dev_mem:
> - kzfree(vpfe_dev);

Kzfree zeroes the data before freeing it.  Devm_kzalloc only causes a
kfree to happen, not a kzfree.  If the kzfree is needed, then a memset 0
would need to replace the calls to kzfree.

There are some other minor issues with the patch.  In the subject line,
there is normally a space after each :.  There is a spelling mistake in
the commit message.  In the commit message there should be one space
betwee words within a sentence, and there should be a space after a comma,
or other puctuation.

julia

>
>   return ret;
>  }
> @@ -702,7 +701,6 @@ static int vpfe_remove(struct platform_device *pdev)
>   v4l2_device_unregister(_dev->v4l2_dev);
>   media_device_unregister(_dev->media_dev);
>   vpfe_disable_clock(vpfe_dev);
> - kzfree(vpfe_dev);
>
>   return 0;
>  }
> --
> 2.7.4
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Staging:media:davinci_vpfe: used devm_kzalloc in place of kzalloc

2016-11-02 Thread Nadim Almas
Switch to resource-managed function devm_kzalloc instead
of kzolloc and remove unneeded kzfree

Also, remove kzfree in probe function and  remove
function,vpfe_remove as it is now has nothing to do.
The Coccinelle semantic patch used to make this change is as follows:
/
@platform@
identifier p, probefn, removefn;
@@
struct platform_driver p = {
.probe = probefn,
.remove = removefn,
};

@prb@
identifier platform.probefn, pdev;
expression e, e1, e2;
@@
probefn(struct platform_device *pdev, ...) {
<+...
- e = kzalloc(e1, e2)
+ e = devm_kzalloc(>dev, e1, e2)
...
?-kzfree(e);
...+>
}
@rem depends on prb@
identifier platform.removefn;
expression prb.e;
@@
removefn(...) {
<...
- kzfree(e);
...>
}
//

Signed-off-by: Nadim Almas 
---
 drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c 
b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
index bf077f8..cd44f0f 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
+++ b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
@@ -579,7 +579,7 @@ static int vpfe_probe(struct platform_device *pdev)
struct resource *res1;
int ret = -ENOMEM;
 
-   vpfe_dev = kzalloc(sizeof(*vpfe_dev), GFP_KERNEL);
+   vpfe_dev = devm_kzalloc(>dev, sizeof(*vpfe_dev), GFP_KERNEL);
if (!vpfe_dev)
return ret;
 
@@ -681,7 +681,6 @@ static int vpfe_probe(struct platform_device *pdev)
 probe_disable_clock:
vpfe_disable_clock(vpfe_dev);
 probe_free_dev_mem:
-   kzfree(vpfe_dev);
 
return ret;
 }
@@ -702,7 +701,6 @@ static int vpfe_remove(struct platform_device *pdev)
v4l2_device_unregister(_dev->v4l2_dev);
media_device_unregister(_dev->media_dev);
vpfe_disable_clock(vpfe_dev);
-   kzfree(vpfe_dev);
 
return 0;
 }
-- 
2.7.4

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